diff --git a/.gitignore b/.gitignore index fe9a88379..493ae21e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ downloads cloud-torrent.json -tmp +tmp/ dev.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..9b68ef442 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,24 @@ +### Contributing guide + +Quick start: + +* Download Go +* Setup `GOPATH` +* `go get github.com/jpillora/cloud-torrent` +* `cd $GOPATH/src/github.com/jpillora/cloud-torrent` +* Fork this repo +* Change remote to your fork +* Edit static files +* Edit backend Go files +* `go generate ./... && go install` +* `$GOPATH/bin/cloud-torrent` + +To add new dependencies: + +* `cd $GOPATH/src/github.com/jpillora/cloud-torrent` +* `rm -rf vendor/` +* `go get -u -v .` Fetch all dependencies into your GOPATH +* `go get github.com/foo/bar` +* `godep save && rm -rf Godep/` +* Now `vendor/` should contain the latest deps for all packages +* Test with `go install -v` and you should see the build targeting packages within `vendor/...` \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index a789406f4..0a0b05f9a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,30 @@ -FROM alpine:3.5 -MAINTAINER dev@jpillora.com +FROM alpine:3.6 +LABEL maintainer="dev@jpillora.com" # prepare go env ENV GOPATH /go ENV NAME cloud-torrent ENV PACKAGE github.com/jpillora/$NAME ENV PACKAGE_DIR $GOPATH/src/$PACKAGE -ENV GOLANG_VERSION 1.8.1 +ENV GOLANG_VERSION 1.9.1 ENV GOLANG_SRC_URL https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz -ENV GOLANG_SRC_SHA256 33daf4c03f86120fdfdc66bddf6bfff4661c7ca11c5da473e537f4d69b470e57 +ENV GOLANG_SRC_SHA256 a84afc9dc7d64fe0fa84d4d735e2ece23831a22117b50dafc75c1484f1cb550e ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH # in one step (to prevent creating superfluous layers): # 1. fetch and install temporary build programs, # 2. build cloud-torrent alpine binary # 3. remove build programs RUN set -ex \ - && apk update \ + && apk update \ && apk add ca-certificates \ && apk add --no-cache --virtual .build-deps \ - bash \ - gcc \ - musl-dev \ - openssl \ - git \ - go \ - curl \ - && curl -s https://raw.githubusercontent.com/docker-library/golang/132cd70768e3bc269902e4c7b579203f66dc9f64/1.8/alpine/no-pic.patch -o /no-pic.patch \ + bash \ + gcc \ + musl-dev \ + openssl \ + git \ + go \ + curl \ + && curl -s https://raw.githubusercontent.com/docker-library/golang/221ee92559f2963c1fe55646d3516f5b8f4c91a4/1.9/alpine3.6/no-pic.patch -o /no-pic.patch \ && cat /no-pic.patch \ && export GOROOT_BOOTSTRAP="$(go env GOROOT)" \ && wget -q "$GOLANG_SRC_URL" -O golang.tar.gz \ diff --git a/engine/engine.go b/engine/engine.go index 6c7834553..0a5a31a14 100644 --- a/engine/engine.go +++ b/engine/engine.go @@ -9,6 +9,7 @@ import ( "sync" "time" + "github.com/anacrolix/dht" "github.com/anacrolix/torrent" "github.com/anacrolix/torrent/metainfo" ) @@ -36,12 +37,16 @@ func (e *Engine) Configure(c Config) error { return fmt.Errorf("Invalid incoming port (%d)", c.IncomingPort) } tc := torrent.Config{ - DataDir: c.DownloadDirectory, - ListenAddr: "0.0.0.0:" + strconv.Itoa(c.IncomingPort), - NoUpload: !c.EnableUpload, - Seed: c.EnableSeeding, - DisableEncryption: c.DisableEncryption, + DHTConfig: dht.ServerConfig{ + StartingNodes: dht.GlobalBootstrapAddrs, + }, + DataDir: c.DownloadDirectory, + ListenAddr: "0.0.0.0:" + strconv.Itoa(c.IncomingPort), + NoUpload: !c.EnableUpload, + Seed: c.EnableSeeding, } + tc.DisableEncryption = c.DisableEncryption + client, err := torrent.NewClient(&tc) if err != nil { return err diff --git a/server/server.go b/server/server.go index c1a9e4127..d11ca8cd7 100644 --- a/server/server.go +++ b/server/server.go @@ -1,6 +1,7 @@ package server import ( + "compress/gzip" "crypto/tls" "encoding/json" "fmt" @@ -14,10 +15,10 @@ import ( "sync" "time" + "github.com/NYTimes/gziphandler" "github.com/jpillora/cloud-torrent/engine" "github.com/jpillora/cloud-torrent/static" "github.com/jpillora/cookieauth" - "github.com/jpillora/gziphandler" "github.com/jpillora/requestlog" "github.com/jpillora/scraper/scraper" "github.com/jpillora/velox" @@ -55,6 +56,7 @@ type Server struct { Version string Runtime string Uptime time.Time + System stats } } } @@ -65,12 +67,11 @@ func (s *Server) Run(version string) error { if isTLS && (s.CertPath == "" || s.KeyPath == "") { return fmt.Errorf("You must provide both key and cert paths") } - s.state.Stats.Title = s.Title s.state.Stats.Version = version s.state.Stats.Runtime = strings.TrimPrefix(runtime.Version(), "go") s.state.Stats.Uptime = time.Now() - + s.state.Stats.System.pusher = velox.Pusher(&s.state) //init maps s.state.Users = map[string]string{} //will use a the local embed/ dir if it exists, otherwise will use the hardcoded embedded binaries @@ -86,13 +87,12 @@ func (s *Server) Run(version string) error { if err := s.scraper.LoadConfig(defaultSearchConfig); err != nil { log.Fatal(err) } - + //scraper s.state.SearchProviders = s.scraper.Config //share scraper config go s.fetchSearchConfigLoop() s.scraperh = http.StripPrefix("/search", s.scraper) - + //torrent engine s.engine = engine.New() - //configure engine c := engine.Config{ DownloadDirectory: "./downloads", @@ -114,7 +114,6 @@ func (s *Server) Run(version string) error { if err := s.reconfigure(c); err != nil { return fmt.Errorf("initial configure failed: %s", err) } - //poll torrents and files go func() { for { @@ -127,6 +126,9 @@ func (s *Server) Run(version string) error { } }() + //start collecting stats + go s.state.Stats.System.loadStatsEvery(5 * time.Second) + host := s.Host if host == "" { host = "0.0.0.0" @@ -148,7 +150,12 @@ func (s *Server) Run(version string) error { } //define handler chain, from last to first h := http.Handler(http.HandlerFunc(s.handle)) - h = gziphandler.GzipHandler(h) + //gzip + compression := gzip.DefaultCompression + minSize := 0 //IMPORTANT + gzipWrap, _ := gziphandler.NewGzipLevelAndMinSize(compression, minSize) + h = gzipWrap(h) + //auth if s.Auth != "" { user := s.Auth pass := "" @@ -156,7 +163,7 @@ func (s *Server) Run(version string) error { user = s[0] pass = s[1] } - h = cookieauth.Wrap(h, user, pass) + h = cookieauth.New().SetUserPass(user, pass).Wrap(h) log.Printf("Enabled HTTP authentication") } if s.Log { diff --git a/server/server_stats.go b/server/server_stats.go new file mode 100644 index 000000000..99f9fb856 --- /dev/null +++ b/server/server_stats.go @@ -0,0 +1,77 @@ +package server + +import ( + "runtime" + "time" + + velox "github.com/jpillora/velox/go" + "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/disk" + "github.com/shirou/gopsutil/mem" +) + +type stats struct { + Set bool `json:"set"` + CPU float64 `json:"cpu"` + DiskUsed int64 `json:"diskUsed"` + DiskTotal int64 `json:"diskTotal"` + MemoryUsed int64 `json:"memoryUsed"` + MemoryTotal int64 `json:"memoryTotal"` + GoMemory int64 `json:"goMemory"` + GoRoutines int `json:"goRoutines"` + //internal + lastCPUStat *cpu.CPUTimesStat + pusher velox.Pusher +} + +func (s *stats) loadStatsEvery(interval time.Duration) { + for { + s.loadStats() + time.Sleep(interval) + } +} + +func (s *stats) loadStats() { + //count cpu cycles between last count + if stats, err := cpu.CPUTimes(false); err == nil { + stat := stats[0] + total := totalCPUTime(stat) + last := s.lastCPUStat + if last != nil { + lastTotal := totalCPUTime(*last) + if lastTotal != 0 { + totalDelta := total - lastTotal + if totalDelta > 0 { + idleDelta := (stat.Iowait + stat.Idle) - (last.Iowait + last.Idle) + usedDelta := (totalDelta - idleDelta) + s.CPU = 100 * usedDelta / totalDelta + } + } + } + s.lastCPUStat = &stat + } + //count disk usage + if stat, err := disk.DiskUsage("/"); err == nil { + s.DiskUsed = int64(stat.Used) + s.DiskTotal = int64(stat.Total) + } + //count memory usage + if stat, err := mem.VirtualMemory(); err == nil { + s.MemoryUsed = int64(stat.Used) + s.MemoryTotal = int64(stat.Total) + } + //count total bytes allocated by the go runtime + memStats := runtime.MemStats{} + runtime.ReadMemStats(&memStats) + s.GoMemory = int64(memStats.Alloc) + //count current number of goroutines + s.GoRoutines = runtime.NumGoroutine() + //done + s.Set = true + s.pusher.Push() +} + +func totalCPUTime(t cpu.CPUTimesStat) float64 { + total := t.User + t.System + t.Nice + t.Iowait + t.Irq + t.Softirq + t.Steal + t.Guest + t.GuestNice + t.Idle + return total +} diff --git a/static/files.go b/static/files.go index f001c6f4a..c4d4094a4 100644 --- a/static/files.go +++ b/static/files.go @@ -221,7 +221,7 @@ func filesCssLatoLatoCss() (*asset, error) { return a, nil } -var _filesCssAppCss = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x84\x55\xff\x6e\xdc\x36\x0c\xfe\xdb\x7a\x0a\xad\xc0\x80\x24\xa8\x75\x3f\xda\x5b\x5b\x1b\x03\xfa\x1e\xc3\xfe\x90\x2d\xda\x47\x44\x16\x0d\x89\xce\xdd\xb5\xc8\xbb\x0f\x92\xec\xcb\xf9\xd6\x6c\x41\x80\xb3\x64\xf2\x23\xf9\x91\x1f\xfd\x1d\x87\x91\x3c\xcb\xc9\xdb\x87\x0f\x6a\x13\xa0\x65\x24\x17\x36\x34\x38\x54\x6d\x08\x1f\x1e\x6b\xf1\x9e\x0d\x93\xf7\xe0\x38\xfc\x9f\x9d\xa1\x93\xb3\xa4\xcd\xd5\x50\x6c\x9e\x64\x6f\xa9\xd1\x56\x06\xbe\x58\x08\x52\x3e\x6d\x84\x38\xf2\x60\x3f\xca\x86\xcc\x45\xfe\x14\xc5\x09\x0d\x1f\x2b\xb9\xdb\x6e\x7f\xaf\x45\x31\x68\xdf\xa3\xab\xe4\xb6\x16\xc5\xa8\x8d\x41\xd7\xa7\xc3\xab\x10\xaa\xd5\x3d\x44\x8f\xf9\xbe\x64\x1a\x2b\xb9\x3f\x8c\xe7\x37\xdb\xb2\x21\x66\x1a\x2a\xf9\x79\x9b\xae\x07\x7d\x2e\xe7\x00\x5f\xb6\xcb\xd5\x1c\x41\xea\x89\x29\x21\x7f\x1f\xc0\xa0\x96\x0f\xb7\xd6\x11\xe0\x31\x46\xbb\x86\xbd\xf1\xdc\x65\xa8\x75\x26\xf3\xe5\xeb\x3b\x88\x9f\xbf\x2e\x88\xa9\x72\xc5\xc8\x16\xa4\x4e\xc8\x1d\x39\x2e\x03\xfe\x80\x4a\xee\xd4\x1f\x07\x0f\xc3\x02\x14\xb9\xca\x54\xa9\x61\x62\x30\xd1\xbc\x25\x4b\xbe\x92\xbd\xd7\x97\x94\x7e\x47\xc4\xe0\xe3\x1b\x86\x33\x97\xda\x62\xef\x2a\xe9\xb1\x3f\x72\x7d\x63\x0d\x97\x5a\xcc\x91\x62\x33\x2a\x89\xac\x2d\xb6\xd7\xcb\x14\x7e\xab\xbe\xa6\xe0\x34\xea\x16\xf9\x12\x2f\xf6\x87\x5a\x14\xec\xb5\x0b\x18\xfb\x5c\xc9\xf9\x9d\x54\x9f\x82\x04\x1d\xa0\x44\x57\xd2\xc4\x37\xb9\x54\x47\x7a\xc9\x19\x5d\x71\x76\xb9\x87\x60\x2d\x8e\x01\x43\x7c\x67\x30\x8c\x56\x5f\x2a\x89\xce\xa2\x83\xb2\xb1\xd4\x3e\xc7\xd8\x2f\xe0\x3b\x4b\xa7\x4a\x1e\xd1\x18\x70\xb5\x28\x4e\x47\x64\x28\xc3\xa8\x5b\xa8\xa4\xa3\x93\xd7\x63\x3d\x97\xfb\x66\xbd\x60\xa7\x48\x7f\xb9\xbe\x6c\x2d\xb6\xcf\x7f\x27\xca\x26\x1f\x22\x0b\x23\xa1\x63\xf0\x39\x17\x83\x41\x37\x76\xe6\x74\x36\x30\xd0\xe9\xc9\xb2\xfc\x2d\xcf\xb8\x76\xb9\x2c\x85\x2d\xb9\x35\xe4\xaa\x67\xfb\x48\x5a\xb4\xd3\xe3\x28\x55\x4b\xce\x41\xcb\xe5\x49\x7b\x87\xae\xff\xd7\xcc\x1e\xf2\xa4\x8c\xb4\x30\xda\xe1\x19\x4c\x2d\x8a\x1f\x25\x3a\x03\xe7\xa4\x86\x6d\x94\x80\x85\x8e\xb3\x18\x92\x63\x7c\x58\xeb\xe5\x08\xb1\xcd\xd7\x63\xa3\xdb\xe7\xde\xd3\xe4\x4c\x39\xf7\xdd\xf7\x8d\x7e\xd8\x7e\x94\xf9\x7f\xf7\xb8\xee\xed\xb7\x43\x4a\x5b\x6c\x9e\x44\xf1\xe7\xdd\x9f\x28\x62\x31\x59\xb8\x22\xea\x76\x1e\xd9\x9f\xb7\x99\x7b\xb0\x9a\xf1\x05\x72\xf5\x37\x33\x7d\x43\xcf\x5e\x7d\xca\x23\xfd\x66\xa2\x02\x6b\x9e\xc2\x1a\x4b\x37\x81\xec\xc4\xb0\x54\xbb\x4f\x2c\xf9\xa5\xc0\x78\xba\xa5\xb8\xc3\x5e\x76\xe4\x07\x05\x06\x39\x22\x65\x7d\x5e\x57\xc0\xce\xdf\x37\x65\xed\x81\x6e\x9c\xf8\x9a\x6a\xa7\x07\xb4\x97\x4a\x0e\xe4\x28\xcd\xd9\x7f\xb9\xaa\x66\x62\x26\x17\xee\x35\xd7\xc2\xdb\x74\x2d\x5b\xb3\x3c\x82\x36\x59\x0c\x73\x82\xb9\xb8\xfb\x19\xb8\x63\xf2\xce\x5b\x75\x68\x21\xa8\x65\xc5\x2e\x53\xf5\x2b\xee\x66\xc2\x32\x7e\xde\x4c\xab\xc5\xf7\x2d\x9d\x56\x9a\xff\x32\xaf\x9c\xd5\xae\x78\x15\x82\xa3\x3e\x14\xb7\xd6\x48\xe5\xf4\x00\xbf\xdc\x31\x2b\xad\x14\x27\xf2\xa6\x6c\x3c\xe8\xe7\x4a\xa6\x9f\x52\x5b\x9b\x6b\x9a\xc6\xf4\x75\x90\xf3\x83\x54\x31\xfc\xfa\x13\x90\x7a\xfc\x4f\x00\x00\x00\xff\xff\x9f\x6c\xec\xff\xac\x06\x00\x00") +var _filesCssAppCss = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x84\x55\xff\x6e\xdb\x38\x0c\xfe\x7b\x7e\x0a\xde\x80\x03\xda\x62\x56\x9c\x6c\xb9\x6d\x2e\x0e\xd8\x7b\x1c\xee\x0f\xd9\xa2\x1d\xa2\xb2\x64\x48\x74\x93\x6c\xe8\xbb\x1f\xf4\x23\x89\xed\x76\xbd\xa2\x40\x22\x8a\xfc\x44\x7e\xe4\xc7\xfc\xa0\x61\xb4\x8e\x61\x72\xfa\xee\xa3\xd8\x78\x6c\x99\xac\xf1\x1b\x3b\x18\x12\xad\xf7\x1f\xef\x1f\x8b\xdf\xf9\xb0\x75\x0e\x0d\xfb\xff\xf3\x53\xf6\x68\xb4\x95\xea\xea\x58\x6c\x1e\xa0\xd7\xb6\x91\x1a\x3c\x9f\x35\x7a\x80\x87\x4d\x51\x1c\x78\xd0\x9f\x8a\xc6\xaa\x33\xfc\x2a\x00\x8e\xa4\xf8\x50\xc3\xb6\xaa\xfe\x7c\x2c\x00\x06\xe9\x7a\x32\x35\x54\xe1\x30\x4a\xa5\xc8\xf4\xf1\xf4\x52\x14\xa2\x95\x3d\xc6\xa0\x7c\x51\xb2\x1d\x6b\xd8\xed\xc7\xd3\xcc\xbb\x6c\x2c\xb3\x1d\x6a\xf8\x52\x25\xfb\x20\x4f\x65\x7e\xe5\x6b\x75\xb5\xe5\x67\x40\x4e\x6c\x23\xfa\x8f\x01\x15\x49\xb8\x9b\xbb\x07\x88\xfb\xf8\xe2\xed\xed\x79\xf0\x36\xc3\xad\x32\xba\x98\x5f\x7e\x83\xfb\xe5\xdb\x15\x37\xf2\x20\x98\x58\x23\xc8\x8c\xdf\x59\xc3\xa5\xa7\x9f\x58\xc3\x56\xfc\xb5\x77\x38\x5c\xc1\x02\x79\x39\x66\x98\x18\x55\x8c\x68\xad\xb6\xae\x86\xde\xc9\x73\xac\xa4\xb3\x96\xd1\xc5\x2b\xc6\x13\x97\x52\x53\x6f\x6a\x70\xd4\x1f\xf8\x71\xee\x8f\xe7\x70\x4c\xcf\x85\x0e\xd5\x40\x2c\x35\xb5\x37\x6b\x4c\xa2\x12\xdf\x52\x0a\x76\x94\x2d\xf1\x39\x58\x76\xfb\x60\x60\x27\x8d\xa7\xd0\xff\xfa\x72\x09\x95\xf8\xec\x01\xa5\xc7\x92\x4c\x69\x27\x9e\xa5\x54\x1f\xec\x73\x4e\xec\x0a\xb5\x7d\x7d\x2f\xf0\xc4\x2e\x91\xa1\xc8\x8f\x5a\x9e\x6b\x20\xa3\xc9\xe0\xbc\xbc\xb7\xbc\x8c\xcd\x3e\x02\xb5\xa6\xd1\x93\x7f\x0b\xa5\x6c\xb4\x6d\x9f\x62\x41\xcf\xe8\x3a\x6d\x8f\x35\x1c\x48\x29\x34\xc1\x76\x3c\x10\x63\xe9\x47\xd9\x62\x00\x3c\x3a\x39\x3e\x5e\x98\xbc\xf9\x5f\xf0\xe3\x6b\xff\x98\xbe\x6c\x35\xb5\x4f\xff\xa6\x7e\x4c\xce\x07\x82\x47\x4b\x86\xd1\xa5\x84\x14\x79\xd9\xe8\x4b\xc7\xb2\x87\xc2\x4e\x4e\x9a\xe1\x8f\xa4\x29\x69\x12\x5b\x82\x5a\x6b\x56\xa0\x8b\xa1\xd8\x85\x7e\x04\x47\x39\x8e\x20\x5a\x6b\x0c\xb6\x5c\x1e\xa5\x33\x64\xfa\xd7\x0a\xd9\xe7\x79\x1c\xed\xa5\x59\x1d\x9d\x50\x05\xd3\xcf\x92\x8c\xc2\x53\x14\x60\x15\x45\xa7\xb1\xe3\xac\xbf\x18\x1c\xbf\xad\x54\x7a\xc0\x30\x4b\xb7\x73\x23\xdb\xa7\xde\xd9\xc9\xa8\x32\x0f\x97\xeb\x1b\x79\x57\x7d\x82\xf4\xbf\xbd\x5f\x8d\xcf\xf7\x7d\xcc\x7f\xf3\x50\x7c\xf8\x7b\xf5\x57\x7c\x08\x45\xa5\x8d\x51\x84\x85\x91\xd5\xf1\x6b\x51\x80\x43\x2d\x99\x9e\x73\xb7\xe7\xfa\x99\x11\xb5\x13\x9f\x93\x7a\x6e\x3e\xc2\xb3\xe4\xc9\xaf\xd0\x64\xe3\xad\x9e\x18\xaf\x45\xef\x12\x61\xee\x52\x66\x38\xce\xf9\xee\xa8\x87\xce\xba\x41\xa0\x22\x8e\x60\x69\x29\x5c\x97\xcf\xd6\xad\x5b\xb4\x0c\x21\x33\x4e\x7c\xcb\xb7\x93\x03\xe9\x73\x0d\x83\x35\x36\x8e\xde\x7b\xb1\xa2\x99\x98\xad\xf1\xaf\x14\xde\xe2\x6d\xde\xf2\x5e\x2e\x0f\x28\x55\xd6\x5c\x4e\x31\x15\xf8\x6a\x24\x96\x8c\xae\xc2\x45\x64\xe2\x1d\xd6\x32\x53\x19\x35\x6d\xc1\xe5\xaa\xfd\x9e\x8e\x8b\xbd\xf2\xf5\xb2\xdc\x16\x2b\xe9\xa5\x28\x38\x68\x45\x70\xab\x15\x08\x23\x07\x7c\x7b\x99\x2d\x74\x03\x70\xb4\x4e\x95\x8d\x43\xf9\x54\x43\xfc\x28\xa5\xd6\xa9\x9c\x69\x8c\x3f\x4d\x90\xbf\x80\x08\x19\xac\x7e\x7f\x52\x8f\xff\x0b\x00\x00\xff\xff\xed\x66\x8a\x79\x2b\x07\x00\x00") func filesCssAppCssBytes() ([]byte, error) { return bindataRead( @@ -236,7 +236,7 @@ func filesCssAppCss() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "files/css/app.css", size: 1708, mode: os.FileMode(420), modTime: time.Unix(1498117139, 0)} + info := bindataFileInfo{name: "files/css/app.css", size: 1835, mode: os.FileMode(420), modTime: time.Unix(1507724932, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -461,7 +461,7 @@ func filesCssThemesDefaultAssetsImagesFlagsPng() (*asset, error) { return a, nil } -var _filesIndexHtml = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x9c\x57\x5b\x6f\xdb\xb8\x12\x7e\x96\x7f\xc5\x84\x38\x40\x5a\x20\xb2\x9a\x83\xf3\xe4\x48\x02\x7a\xda\xa0\xbb\xd8\x2c\x0a\xa4\xe9\xbe\x14\xc5\x82\xa6\xc6\x12\x1b\x8a\x64\x49\xca\x4e\xd6\xd0\x7f\x5f\x90\xba\x44\x89\x9c\xd6\x69\x1e\x12\x9b\x73\xf9\x66\xbe\xb9\x90\x49\x2b\x57\x0b\x90\x65\x4c\xb5\xce\x08\xd5\x9a\xe4\x8b\x45\x5a\x21\x2d\xf2\x45\x94\x3a\xee\x04\x7a\xe9\x9a\xcb\x22\x23\xd6\x51\x87\xcb\x4f\x8e\x3a\xbb\xbc\xf1\x22\x92\xbf\x13\xaa\x29\xe0\x46\x19\x83\xd2\xa5\x49\x30\xf0\x96\x35\x3a\x0a\x92\xd6\x98\x91\x2d\xc7\x9d\x56\xc6\x11\x60\x4a\x3a\x94\x2e\x23\x3b\x5e\xb8\x2a\x2b\x70\xcb\x19\xc6\xe1\xcb\x19\x70\xc9\x1d\xa7\x22\xb6\x8c\x0a\xcc\xce\x97\x6f\xce\xa0\xa6\x77\xbc\x6e\xea\xe9\x51\x63\xd1\x84\xef\x74\x2d\x30\x93\x8a\x78\x30\xc1\xe5\x2d\x18\x14\x3e\xc2\x7b\x81\xb6\x42\x74\x04\xdc\xbd\xc6\x8c\x38\xbc\x73\x09\xb3\x96\x40\x65\x70\x93\x11\x66\x6d\x72\x45\x9d\x0a\xbf\x96\x5e\xf0\x2b\x1e\x2c\xd6\x54\x3a\xce\x96\x35\x97\xbf\xec\x84\x6a\x7d\xc0\x96\x33\x25\x47\x2d\xcf\x6e\xbc\xa1\x5b\x7f\xb8\xd4\xb2\x1c\xdc\xf1\x9a\x96\x98\xdc\xc5\x9d\x72\xe2\x3d\x04\xcc\xa7\x68\xf9\x22\x8a\xbe\xc8\x32\x66\x42\xd1\xdb\xaf\xb0\x5f\x44\x51\x54\x70\xab\x05\xbd\x5f\x81\x54\x12\x2f\x16\x51\xd4\x2e\xa2\x34\x09\xe6\xf9\x22\x4d\xba\xda\x2f\xd2\xb5\x2a\xee\x81\x09\x6a\xed\xd0\x17\x51\x5a\xf0\x2d\x0c\xde\x06\x19\xa3\x25\x06\x9c\x41\xca\x37\x19\x39\x61\x4a\x4a\x64\x0e\x0b\x32\xea\x75\x27\xf1\x8e\x1a\xc9\x65\x09\x0d\x07\x2e\xb7\x68\x1c\x16\xe0\xff\x70\x46\x05\xd4\xd4\x3a\x1f\x00\x30\x94\x0e\x0d\x50\xc1\x4b\x89\x05\x58\x2c\x6b\x94\x2e\xe0\x74\x40\xbd\xd7\x86\x83\x4f\x36\xb4\x16\xe5\x12\x4d\xa7\x12\xa5\xd5\xf9\x44\x65\x04\xf2\xbe\x47\x9d\xe8\x3d\xb7\x63\x9c\x9d\x55\x52\x9d\xbf\xc0\x3e\xe5\x83\x8e\xc1\x02\x04\x2f\x2b\x17\x52\x0b\x55\xc9\xd3\x84\xe7\x8f\xbd\xa6\x49\xc1\xb7\x81\xaa\xf1\xc3\x49\x1c\xc3\xcd\xef\x37\x57\x97\x90\x1d\xfa\x81\x38\x1e\xa9\xed\xa1\x5c\x37\x78\xc1\x5f\xf5\xdf\x1e\x81\xf6\x0d\x53\x39\xa7\xed\x2a\x49\x4a\xee\xaa\x66\xbd\x64\xaa\x4e\xbe\x69\x2e\x84\x32\x34\xe9\x9a\xc9\x75\xa3\x4a\xc0\x51\x53\xa2\xcb\xc8\xdf\x6b\x41\xe5\x2d\x09\x95\x93\xdc\x65\x44\xa8\x52\xfd\xa6\xb6\x68\x20\x83\x0d\x15\x16\x49\xc0\xf0\x0a\xb5\x6a\x2c\x7a\xd1\x63\x2d\x67\x1a\x24\xa3\x5c\x20\xdd\xe2\x21\x37\x33\xd6\xd6\xa2\xc1\x8e\xac\xae\xab\xc2\xe1\x3e\xc4\xb9\x3a\x19\xed\xcf\xa0\xcb\x66\x05\xe3\x51\xdb\xb1\x0b\xfb\x3d\xcc\x76\x52\x07\xd2\xb6\x3d\xf5\xb4\x67\xbe\xa7\x6a\xca\xa4\x37\x6d\xec\xd0\x30\xdc\xc7\x60\x2b\xb5\xf3\xd5\xfc\xde\xa0\x75\x4b\xa6\x1a\xe9\x20\x87\x37\x64\xd2\x0b\x8c\x1b\xd6\x08\x6a\x40\x28\x5a\xf8\x6a\x1b\xd4\x48\xdd\xac\xe8\xbc\xcb\x89\xb3\xdb\x8c\xfc\xc7\x28\xe5\xdd\xc9\x0d\x2f\x97\x58\x70\x07\x19\x9c\xcc\x0e\x2f\x1e\xd1\x50\x1a\x44\xb9\x82\x99\x56\xdb\x97\xe3\x40\x44\x16\x8d\xe7\xbb\x63\x34\x0c\x74\x46\x36\x4a\xba\xd8\xf2\x7f\x70\x05\xe7\xff\xd3\x77\x17\x3f\x0e\x51\xd5\x92\x3f\x09\x70\x3c\xfa\x41\x78\xa3\x4e\x7b\x90\xa9\x9a\x96\x12\x7b\x86\xba\xe0\x8f\x0a\xee\x10\xe7\x8f\x67\x6c\x1a\x10\xf4\x11\x8d\x13\x7d\x06\x06\x8b\x15\x3c\xac\x22\x68\x1f\xfc\x3f\x33\x8a\x1f\xae\x3e\xfe\xff\xed\x15\x5c\x5e\x5f\x7f\xbc\x86\x3f\x2f\x3f\x7d\x7a\xfb\xe1\x88\xc9\xec\x97\x1e\x1a\x33\x4d\x1f\x8d\x51\x06\x6a\xb4\x76\xd8\x90\x93\xa4\x98\x50\xf6\x51\xef\x4f\x8a\x80\xc6\xcf\x8c\x6c\x84\x98\xc4\x3b\xe9\xdb\x61\x09\x5d\x7a\x80\x31\xfe\x28\xd5\xf9\x7e\x8f\xc6\xb4\x6d\x9a\xe8\x49\x6a\xfe\x93\x45\xe6\xb8\x92\x93\x5d\xbc\xe1\x65\x87\xac\xa4\x33\x4a\x08\x3f\xd3\xef\xc2\xf1\xbb\xf1\xa4\x5f\x0a\x4c\x34\x05\x82\x35\x2c\x23\xa7\x0e\x6b\x2d\xa8\xc3\xa4\xef\x48\xff\x7c\x38\xf5\x61\xf6\x08\xf9\x01\x34\xdf\x1d\x33\xac\x8f\xb5\xe4\xc7\x21\x85\xe6\x3a\x06\xa7\x5f\x6d\x76\x86\xd5\x3f\x4f\xec\x71\x78\x83\x9b\xa3\x30\x0b\xb5\x93\x7e\x11\xcc\x41\xdf\x0f\x92\xe3\x50\x47\x47\x07\x60\x3d\xee\x46\x29\x87\xa6\x2b\xb4\xd5\x54\x0e\x4d\x37\xdd\x7f\x9f\xb5\xe3\x35\x92\xbc\xd1\x7e\x33\xd2\x52\xbd\x9a\x4b\x5f\x43\xdb\x46\xb1\xbf\xf0\x35\x95\x0f\xee\xf2\xc9\x8d\x71\xcc\x6d\x32\xbb\x3f\xf2\x41\xe2\x57\xee\x51\x2e\x7e\x72\x21\xe5\x8f\xc4\xde\xab\x7f\x26\x58\xcf\xfd\x93\xb5\xff\x57\x7f\x7c\x30\xb1\x81\x27\xd9\xd4\x7f\xe0\xbd\xed\x19\xf9\x6c\xd1\xd8\xd7\x90\xc3\x39\xc9\xf7\x7b\x38\x28\x6c\xdb\xf0\xda\xb4\x0f\x1b\xe5\x10\x6f\xf3\x4c\x95\xa0\xb2\x5c\x2a\x53\xce\x53\xfa\xa0\x42\x1e\x4f\xe2\xbf\x6e\xa4\xaf\x0c\xf8\xc1\x1d\xbc\xa7\xc9\x50\xf0\xd0\x74\xcc\x70\xed\xba\x96\xf9\x66\x93\x2d\xca\x42\x99\xe4\x7b\x83\xe6\x3e\xb6\xce\x70\x59\x2e\xbf\xd9\xd0\x32\x41\x31\x7f\xde\x86\xca\xd2\x2f\xd2\xf0\x6e\x3d\xd2\xa4\x56\xfe\xe9\x75\xa4\x85\x50\x77\xcf\x69\x05\xd2\x76\x5c\x16\x6a\xb7\xa4\x5a\x43\x06\xc3\x97\x21\x26\x55\x34\x02\x5f\x9d\x52\xad\x4f\xcf\xe0\xcb\xd7\xd7\x17\x81\x88\xe7\xe1\xba\x1d\x34\x99\xba\x9f\x06\xe8\x77\xc9\x4b\xf4\x87\x5d\xf0\x12\x9b\x71\x92\x5f\x62\xd4\x38\x2e\xec\x4f\xb5\x86\x7f\x3b\x62\x56\x21\xbb\x5d\x3f\xcf\xf5\x68\x61\x9a\x59\xd5\xfa\x6b\x21\x4d\xfc\x0b\xdf\xbf\xf4\x13\xbf\x71\xf2\x7f\x03\x00\x00\xff\xff\x18\xe9\x3e\x5e\x0a\x0e\x00\x00") +var _filesIndexHtml = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x9c\x57\x4d\x6f\xdb\x38\x13\x3e\xcb\xbf\x62\x22\xbc\x2f\x92\x2e\x22\x2b\x59\xec\x29\x91\x04\x74\xdb\xa0\xbb\xd8\x14\x05\x92\x74\x2f\x45\xb1\xa0\xa9\xb1\xcc\x86\x22\x55\x72\xe4\xc4\xeb\xea\xbf\x2f\x48\x7d\x44\x89\xed\xc4\x69\x0f\x8d\xc5\x99\x79\x9e\x99\xe1\x7c\x48\xc9\x82\x4a\x09\xaa\x88\x58\x55\xa5\x21\xab\xaa\x30\x9b\x4c\x92\x05\xb2\x3c\x9b\x04\x09\x09\x92\xe8\xa4\x33\xa1\xf2\x34\xb4\xc4\x08\xa7\xd7\xc4\xc8\x4e\x6f\x9c\x28\xcc\xde\x49\x5d\xe7\x70\xa3\x8d\x41\x45\x49\xec\x0d\x9c\x65\x89\xc4\x40\xb1\x12\xd3\x70\x29\xf0\xae\xd2\x86\x42\xe0\x5a\x11\x2a\x4a\xc3\x3b\x91\xd3\x22\xcd\x71\x29\x38\x46\xfe\xe1\x18\x84\x12\x24\x98\x8c\x2c\x67\x12\xd3\xd3\xe9\xc9\x31\x94\xec\x5e\x94\x75\x39\x3e\xaa\x2d\x1a\xff\xcc\x66\x12\x53\xa5\x43\x47\x26\x85\xba\x05\x83\xd2\x79\xb8\x92\x68\x17\x88\x14\x02\xad\x2a\x4c\x43\xc2\x7b\x8a\xb9\xb5\x21\x2c\x0c\xce\xd3\x90\x5b\x1b\x5f\x32\xd2\xfe\xbf\xa9\x13\xfc\x0c\x82\xc5\x92\x29\x12\x7c\x5a\x0a\xf5\xd3\x20\xac\xaa\xb6\xd8\x0a\xae\xd5\xa0\xe5\xb2\x1b\xcd\xd9\xd2\x1d\x4e\x2b\x55\xf4\x70\xa2\x64\x05\xc6\xf7\x51\xab\x1c\x3b\x04\xcf\xf9\x94\x2d\x9b\x04\xc1\x17\x55\x44\x5c\x6a\x76\xfb\x15\xd6\x93\x20\x08\x72\x61\x2b\xc9\x56\x67\xa0\xb4\xc2\xf3\x49\x10\x34\x93\x20\x89\xbd\x79\x36\x49\xe2\xf6\xee\x27\xc9\x4c\xe7\x2b\xe0\x92\x59\xdb\xd7\x45\x90\xe4\x62\x09\x3d\x5a\x2f\xe3\xac\x40\xcf\xd3\x4b\xc5\x3c\x0d\x0f\xb8\x56\x0a\x39\x61\x1e\x0e\x7a\xed\x49\x74\xc7\x8c\x12\xaa\x80\x5a\x80\x50\x4b\x34\x84\x39\xb8\x3f\x82\x33\x09\x25\xb3\xe4\x1c\x00\x8e\x8a\xd0\x00\x93\xa2\x50\x98\x83\xc5\xa2\x44\x45\x9e\xa7\x25\xea\x50\x6b\x01\x2e\x58\x5f\x5a\x4c\x28\x34\xad\x4a\x90\x2c\x4e\x47\x2a\x03\x91\xc3\x1e\x74\x82\xf7\xc2\x0e\x7e\xb6\x56\xf1\xe2\xf4\x15\xf6\x89\xe8\x75\x0c\xe6\x20\x45\xb1\x20\x1f\x9a\xbf\x95\x2c\x89\x45\xf6\x18\x35\x89\x73\xb1\xf4\xa9\x1a\x7e\x1c\x44\x11\xdc\xfc\x79\x73\x79\x01\xe9\xb6\x7f\x10\x45\x43\x6a\x3b\x2a\x6a\x1b\xcf\xe3\x2d\x7e\xed\x18\x58\x57\x30\x0b\xa2\xca\x9e\xc5\x71\x21\x68\x51\xcf\xa6\x5c\x97\xf1\xb7\x4a\x48\xa9\x0d\x8b\xdb\x62\xa2\xb6\x55\x43\x20\x66\x0a\xa4\x34\xfc\x67\x26\x99\xba\x0d\xfd\xcd\x29\x41\x69\x28\x75\xa1\xff\xd0\x4b\x34\x90\xc2\x9c\x49\x8b\xa1\xe7\x70\x0a\xa5\xae\x2d\x3a\xd1\x63\x2d\x32\x35\x86\x83\x5c\x22\x5b\xe2\x36\x98\x8d\xac\xcd\x64\x8d\x6d\xb2\xda\xaa\xf2\x87\x6b\xef\xe7\xd9\xc1\x60\x7f\x0c\x6d\x34\x67\x30\x1c\x35\x6d\x76\x61\xbd\x86\x8d\x99\x04\x4d\xd3\x65\x9d\x75\x49\xef\xb2\x34\x4e\xa2\xb3\xaa\x6d\x5f\x2b\xc2\xd1\xdb\x85\xbe\x73\x17\xf9\xbd\x46\x4b\x53\xae\x6b\x45\x90\xc1\x49\x38\x2a\x03\x2e\x0c\xaf\x25\x33\x20\x35\xcb\xdd\x45\x1b\xac\x90\xd1\xc6\x7d\x8b\x36\x1c\xc1\x6f\xd3\xf0\x7f\x46\x6b\x07\xa7\xe6\xa2\x98\x62\x2e\x08\x52\x38\xd8\x38\x3c\x7f\x94\x81\xc2\x20\xaa\x33\xd8\xd0\x6a\xba\x9b\xd8\xe2\x91\x45\xe3\x52\xdd\x26\xd3\xf7\x72\x1a\xce\xb5\xa2\xc8\x8a\x7f\xf1\x0c\x4e\x7f\xab\xee\xcf\x9f\x77\x51\x97\x4a\x3c\x71\x70\x38\x7a\xc6\xbd\x41\xa7\xd9\x9a\xa9\x92\x15\x0a\xbb\x0c\xb5\xce\xef\xe5\xdc\xb6\x9c\x3f\x6e\xaf\xb1\x43\xd0\x79\x34\x34\xf3\x31\x18\xcc\xcf\xe0\x61\x0a\x41\xf3\x80\xbf\xa3\x0b\x3f\x5c\x7e\xfa\xfd\xed\x25\x5c\x5c\x5d\x7d\xba\x82\x8f\x17\xd7\xd7\x6f\x3f\xec\xd1\x94\xdd\xbc\x43\x63\xc6\xe1\xa3\x31\xda\x40\x89\xd6\xf6\xc3\x71\x14\x14\x97\xda\x3e\x2a\xfb\xd1\x25\xa0\x71\xed\xa2\x6a\x29\x47\xfe\x8e\xea\xb6\x9f\x3f\x17\x8e\x60\xf0\x3f\x48\xaa\x6c\xbd\x46\x63\x9a\x26\x89\xab\x51\x68\xee\x97\x45\x4e\x42\xab\xd1\x18\x9e\x8b\xa2\x65\xd6\x8a\x8c\x96\xd2\xb5\xf3\x3b\x7f\xfc\x6e\x38\xe9\xe6\x01\x97\x75\x8e\x60\x0d\x4f\xc3\x43\xc2\xb2\x92\x8c\x30\xee\x2a\xd2\xbd\x39\x1c\x3a\x37\x3b\x86\x6c\x0b\x9b\xab\x8e\x0d\xae\x4f\xa5\x12\xfb\x31\xf9\xe2\xda\x87\xa7\x9b\x6a\x76\x83\xab\x7b\x33\xb1\xfb\xf1\xf5\x30\x7b\x71\xe6\xfa\x4e\xb9\x41\xb0\x49\xfa\xbe\x97\xec\xc7\x3a\x00\x6d\xa1\x75\xbc\x73\xad\x09\xcd\x50\x0b\x5d\x93\xd8\x8a\xa9\x6c\x34\xe7\xbb\xe1\xba\xc7\x26\xd8\x98\xfd\x59\x2f\x71\x33\xf3\x15\x40\x2f\xac\x94\xec\x91\xd8\x61\xbb\x45\x6f\x5d\x0a\x9f\x0c\xee\xbf\xbb\xe3\xa6\x81\x08\x92\xd8\x87\xf6\x10\x65\xdf\x64\xaa\x2e\xff\xc2\x95\x3d\x6a\x2d\x3f\x5b\x34\xf6\x0d\x64\x70\x1a\x66\xeb\x35\x6c\x15\x36\x8d\x7f\x61\xb4\x0f\x93\x61\x1b\x7e\xb6\x2b\x62\x2d\x99\x2a\xa6\xda\x14\x9b\xa1\x7d\xd0\x3e\x9e\x27\x71\x5c\xd5\x8a\x44\x39\x5a\x41\x03\xfc\xa8\x57\x1f\x5f\x61\x1f\xdc\x18\xe6\x7a\x65\x09\xcb\xa9\x45\x1a\x76\xa6\x57\xed\x0a\x0f\xef\xc9\xb0\x5e\x12\x14\xda\xe8\x9a\x84\x42\xfb\xd4\x9b\x0e\xa6\xd0\x57\xbd\x42\xd3\x1c\x77\x78\xf1\x38\xf0\xe7\xc0\x4b\x2c\x77\xe2\x7e\xc4\x52\x9b\x15\xfc\x80\xd9\x8a\x9e\x47\xef\xf1\x78\x55\xef\x40\x73\x92\x1f\x60\x74\xad\x72\x68\x9a\xff\xbf\x88\xd4\xf9\x75\x74\x7a\x72\xf2\xcb\x16\xb8\xd2\xbb\xf6\xd9\x62\x1e\xef\x94\xde\x68\x62\xf2\xcd\xab\x58\x73\x61\x6f\x9f\xa3\x75\xf2\x5d\xa4\x4e\xb6\x17\xe5\xce\x06\x18\x83\x7e\xae\x5c\xa5\x85\x59\x5d\x39\x7f\x58\xa1\x8f\x36\xa5\xae\x01\x36\x6b\xd0\xaf\x87\x7e\xa6\xf8\xb9\xc6\x8d\xa8\xa8\x9d\x4a\xdf\x6c\xbc\x44\x95\x6b\x13\x7f\xaf\xd1\xac\x22\x4b\x46\xa8\x62\xfa\xcd\xfa\xa9\xe4\x15\xb3\xdd\x36\x4c\x15\x6e\x57\xfb\xaf\xa2\x3d\x4d\x4a\xed\x5e\xec\xf7\xb4\x90\xfa\x7e\x97\x96\x8f\xf0\x4e\xa8\x5c\xdf\x4d\x59\x55\x41\x0a\xfd\x43\xef\x93\xce\x6b\x89\x47\x87\xac\xaa\x0e\x8f\xe1\xcb\xd7\x37\xe7\x3e\x11\xbb\xe9\xda\x35\x37\x1a\xec\x2f\x3a\xe8\xd6\xd5\x6b\xf4\xfb\x75\xf3\x1a\x9b\x61\x59\xbc\xc6\xa8\x26\x21\xed\x8b\x5a\xfd\x47\x6d\xc4\x17\xc8\x6f\x67\xbb\x73\x3d\x58\x98\x7a\xe3\xd6\xba\x22\x4b\x62\xf7\xfd\xe8\xbe\x23\x63\xb7\xd4\xb2\xff\x02\x00\x00\xff\xff\x9d\x1c\x87\x4a\x68\x10\x00\x00") func filesIndexHtmlBytes() ([]byte, error) { return bindataRead( @@ -476,7 +476,7 @@ func filesIndexHtml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "files/index.html", size: 3594, mode: os.FileMode(420), modTime: time.Unix(1499851886, 0)} + info := bindataFileInfo{name: "files/index.html", size: 4200, mode: os.FileMode(420), modTime: time.Unix(1507724978, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -601,7 +601,7 @@ func filesJsTorrentsControllerJs() (*asset, error) { return a, nil } -var _filesJsUtilsJs = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xc4\x56\x5b\x6f\xdb\x36\x14\x7e\xcf\xaf\x38\x23\x52\x88\x8e\x55\x29\x41\xdf\x62\x68\xc3\x8a\x16\x7b\x18\x8a\x0c\x4b\x9f\xe6\x38\x03\x23\x1f\xd9\x6c\x68\x92\x21\x29\xbb\x5e\xea\xff\x3e\xf0\x62\x49\x4e\xec\x61\xc3\x06\xec\x85\x84\xce\xfd\x7c\xe7\x42\x95\x17\xb0\x10\xea\x81\x09\x0b\x4c\xeb\x7c\xc3\xe5\x5c\x6d\xe0\xa2\x3c\x3b\x63\x5a\x17\x0d\xab\x9d\x32\x5b\x9a\x31\xcd\xb3\x1c\x9a\x56\xd6\x8e\x2b\x49\xcf\x8d\x52\xee\xb6\x56\x1a\x73\x38\x5f\x3a\xa7\x73\x30\xf8\x84\xc6\x8c\xe0\xf9\x0c\x20\x5a\x29\x3c\x03\xaa\x28\x30\x39\x03\x58\x33\xe3\xc5\x5a\xb4\x0e\xaa\xde\x18\x0b\x57\x0e\x73\xe6\x58\xd4\x8f\xa2\xad\x11\x50\x01\x61\x9a\x97\x64\x1c\x85\x26\x81\xd9\x7b\x2f\x98\xe6\x5c\x2e\xa0\x02\x67\x5a\x8c\x5c\x83\xae\x35\x32\x7a\x2d\xb4\xb2\x8e\xb6\x46\x24\xeb\x05\x1a\xa3\x0c\x4d\xb1\x16\x0d\x97\x4c\x88\x2d\xed\x42\xd9\xbb\x3f\xee\xa3\x61\xc2\x26\x27\xbb\x91\xbf\x77\xfb\xac\x98\xe6\x50\xc1\x73\xff\x1d\xcc\x59\xa8\x60\x4a\x6a\x25\x1b\xbe\x68\x0d\x92\x9c\xac\xd8\x42\xa2\x23\x39\x69\x8d\x20\x39\x71\xca\x18\x94\xfe\xbb\xe1\x02\xc9\xcc\xab\x27\xd5\xa2\x51\xe6\x23\xab\x97\xf4\x05\x4c\xfb\x08\x99\xe6\xd3\x48\x99\x41\xb5\x47\xb5\x78\xe0\x72\x4e\x65\x2b\x44\x9e\xec\xc4\x30\xc3\x99\x70\x61\x9a\x4f\xce\x3c\xe5\xb0\xc0\x16\x99\xa9\x97\xff\xa0\xc6\xc9\x5c\x8a\x46\x88\xeb\x5e\x53\x1b\xb5\xe6\x73\x34\x39\x3c\xb5\x68\xb6\x39\x68\xb6\xc0\x1e\x5a\x0f\x90\x66\x86\xad\x3c\x3e\xcf\x41\xe4\x3a\x9c\xbb\x49\x92\xe0\x0d\xf5\x2a\xf0\x5d\x55\x41\x2b\xe7\xd8\x70\x89\xf3\x51\x52\x2a\x02\xab\x0a\x46\x27\xaf\xab\x15\x13\x79\xd9\x14\x5d\xf3\xed\xfb\xb1\x58\xa0\xa3\x24\x0a\x97\x64\xdc\x87\xfc\x9c\xdc\x5c\xef\x63\x8c\xe8\xc5\xce\x7a\x3a\x6c\xa0\x21\xe3\x2f\x7a\xe9\x64\x7c\x83\x86\x82\x03\x3f\x01\x5a\x83\x4f\xa9\xd9\xf2\x70\x29\x89\x47\x41\xd6\xcc\x2d\x0f\xd1\x55\xda\x05\x6c\xbb\x54\x9e\x81\x3b\x5c\x5d\x07\x51\xd8\xc1\xee\x3f\xc7\x6d\x4c\x4a\xef\x81\xe4\xc1\xf7\xff\x8f\x58\x1c\xce\x23\x6d\xee\x94\x61\x0b\x1c\xf6\xf9\x41\x3b\xa7\xcd\x25\x54\xcd\xc4\x6d\x94\x85\x6f\xdf\xc2\x64\xbf\x36\x16\x73\x3a\x69\xab\xa3\xa2\x31\x39\x58\xc7\x5c\x6b\xbb\xf1\x15\x68\x9c\x67\x44\x78\xbc\x8f\x1e\x9e\x5a\x49\xab\x04\x26\xe4\xc8\x7e\x65\x46\xc9\xec\x8d\xcd\x80\xbe\xb1\x23\x92\xc3\xd0\xf0\xe4\x65\xca\x5c\x38\x34\x34\x7b\xc4\xad\x3d\x19\xe2\xcd\xc3\x17\xac\x5d\xe1\x65\x8e\xa8\xb2\xf9\xdc\x6a\x56\xe3\x69\xfd\x8e\xda\x25\xc6\x1b\xea\xb6\x1a\x55\x03\x36\x8c\x2f\xb1\xce\x70\xb9\x20\xa3\xc3\x4a\xd9\x83\x5d\x6d\x0b\x83\x5a\xb0\x1a\x69\x49\xa7\x3f\xbe\xfd\x6d\x36\x9e\xb2\xb7\x7f\xcc\x2e\x46\xe5\x62\xe0\xf9\xf7\x1c\x36\xca\xcc\xfb\x2e\x49\xda\x04\x08\x8c\x03\x6b\xbf\x9b\x7b\x73\xf7\x77\x50\xe6\x40\xc8\x49\x78\xfc\xe2\x95\x6c\x75\xba\x23\xfa\x81\x1b\x8c\x59\xe2\xd1\xf2\xae\xa4\xd3\xfb\xbb\x72\x36\x1e\x9d\x97\xa3\xc2\xa1\x75\x49\xee\x07\xf8\x15\x17\x1f\xbf\xea\xe2\xfc\x0a\xe2\xdc\x9d\x8a\xe0\x61\xeb\x0e\x11\x0e\x84\x83\x18\x02\xe5\x58\x07\xbe\xd2\x8d\x6a\x7e\x66\x6d\xcd\x84\x5f\x93\xd3\xec\x7d\x96\x43\xf6\x73\x38\x3f\x85\xf3\xa7\x70\x7e\x0e\xe7\x2f\xef\xb3\xd9\xe4\x48\xb6\x72\xf8\x12\xfb\xc7\xed\x72\xd2\x7d\xfa\xdd\x12\xcc\x4f\xf9\x6c\x92\xaa\x0e\xfb\xb2\xcb\x50\xf6\x4c\xb6\xab\x07\x34\xd9\xeb\x62\xbd\x25\xfd\x88\x02\x6c\x96\x5c\x20\x50\x09\xdf\xc3\xd5\xe5\xe5\x65\x2f\xde\xfb\x18\x8f\xf9\xcc\xcf\x47\xf6\xf5\xea\xf2\x3e\x83\x31\x50\x0e\x17\xf0\xae\x9b\x7d\x09\x15\x7c\x62\x6e\x59\x18\xd5\xfa\xd7\x0f\x4a\x6f\x6a\x14\xae\xa1\xab\x7d\x00\xbe\x59\x24\x8c\x53\xdb\xd8\x97\x65\x99\x73\x83\xb5\xe3\x6b\xa4\x99\x5c\x7c\x94\x0e\xff\xc6\x80\xdb\xf8\x4a\xa2\xc0\x15\x4a\x97\x03\x73\xce\x74\x13\x91\xa8\xf1\x6d\x26\x8f\xb8\x9d\xab\x8d\x84\x47\xdc\x6a\x83\xd6\x92\x81\x71\x5c\xa3\x74\x3d\x04\x1e\xd4\x40\x2a\x36\x4b\x5e\x2f\xa1\xaa\x2a\xb8\x7a\x37\x5c\x92\xc1\x6f\x71\xce\xb4\x3e\xb5\x46\x3b\x19\x5c\x33\x41\x43\x5c\x45\x4a\xab\x03\x70\xb8\x48\x01\xa2\x47\x6d\xc2\xfd\x01\x1b\xd6\x0a\x47\x3b\xfe\xee\xf0\xef\x27\xa0\x56\x96\x9f\x6f\x3e\xdc\x80\xc1\x95\x5a\x23\xb8\x25\xb7\xb0\x64\xf5\xe3\x4b\x34\xbf\xe8\x5b\x53\xff\x4b\x2c\x53\x32\x1b\xe6\xea\x65\xca\x26\x98\x1d\x58\xb5\xa6\xee\x01\xd8\x63\xef\x45\x29\xb1\xa6\x26\x39\x78\x81\xc9\xeb\x34\xfe\x0c\x00\x00\xff\xff\x6a\x95\x61\xe8\x09\x0b\x00\x00") +var _filesJsUtilsJs = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xc4\x56\x5d\x6f\xdb\x36\x17\xbe\xcf\xaf\x38\x15\x52\x94\x4e\x54\xc9\x7e\x7b\x17\x43\x78\xb1\xa1\xc5\x2e\x86\xb6\xc3\xd2\xab\x3a\xee\xc0\x48\x47\x32\x5b\x9a\x64\x48\x2a\xae\x97\xfa\xbf\x0f\xfc\xd0\x97\x13\x03\x19\x86\x61\x37\xb4\x7c\xbe\xcf\xc3\xe7\x1c\x29\xbf\x80\x86\xcb\x5b\xca\x0d\x50\xa5\xd2\x1d\x13\x95\xdc\xc1\x45\x7e\x76\x46\x95\xca\x6a\x5a\x5a\xa9\xf7\x24\xa1\x8a\x25\x29\xd4\xad\x28\x2d\x93\x82\x9c\x6b\x29\xed\x75\x29\x15\xa6\x70\xbe\xb1\x56\xa5\xa0\xf1\x0e\xb5\x9e\xc1\xc3\x19\x40\x88\x92\x39\x05\x14\xc1\x60\x79\x06\x70\x4f\xb5\x33\x6b\xd1\x58\x28\x86\x60\xd4\xff\xa4\x50\x51\x4b\x83\x7f\x30\x6d\x35\x87\x02\x5c\xea\x3c\x81\x4b\x08\x66\x4b\xaf\x1e\xf2\x67\x54\x31\x26\x1a\x28\xc0\xea\x16\x83\x56\xa3\x6d\xb5\x08\x79\xbd\x00\x20\x53\xd2\x58\xd2\x6a\x1e\xd3\x74\x62\xd4\x5a\x6a\x12\x6b\xef\x84\x35\x13\x94\xf3\x3d\xe9\x2b\xec\xaa\x3a\x95\xba\xa6\xdc\xc4\xdc\x00\x87\x99\x7b\x3a\x74\x0d\x53\xc5\xa0\x80\x87\xe1\xbf\x0f\x69\xa0\x80\x55\x52\x4a\x51\xb3\xa6\xd5\x98\xa4\x90\x6c\x69\x23\xd0\xba\xa7\x56\x73\xf7\x63\xa5\xd6\x28\xbc\xa4\x66\x1c\x93\xb5\x0b\x11\xdd\xb3\x5a\xea\x77\xb4\xdc\x90\x23\x14\xbb\x4a\xa9\x62\xab\x20\x59\x43\xd1\x81\x9e\xdd\x32\x51\x11\xd1\x72\x9e\xc6\x38\xa1\x54\x7f\x46\xd0\xa8\x62\xcb\x33\x27\x99\xde\xbf\x41\xaa\xcb\xcd\xdf\xa0\x40\x0c\x17\xab\xe1\xfc\x6a\xf0\x54\x5a\xde\xb3\x0a\x75\x0a\x77\x2d\xea\x7d\x0a\x8a\x36\x38\x40\xec\x40\x52\x54\xd3\xad\xc3\xe8\xc1\x9b\x5c\x05\xcb\x43\x07\x31\xab\x81\x38\x27\x78\x51\x14\xd0\x8a\x0a\x6b\x26\xb0\x9a\x45\xb7\xcc\xab\x0a\x1f\xb6\xf3\x18\xdd\x5a\x68\xe5\x98\x33\x3d\x3b\x3b\xc2\x66\x0d\xda\xae\x6f\xcf\xbf\xa1\xec\x87\x90\xe7\x2a\xe6\x0b\xf8\x05\xe2\xdd\x4d\x19\x35\x56\x3c\x97\x55\xe3\xfa\x9e\x20\xd6\x88\xe0\x1a\xef\x82\xe4\x90\xfa\x1f\x29\xf0\x49\x98\x15\xb5\x9b\x29\xbe\x52\x59\x8f\x6e\xd7\xc8\x03\xb3\xb8\xbd\xf2\x86\x87\xc3\xbf\x80\x19\x5c\x42\x92\xbb\x1c\x49\xea\x73\xff\xf7\x88\x85\x11\x7d\x82\xe8\x56\x6a\xda\xe0\x98\xe9\x13\x42\xc7\xd5\xc6\x65\x49\xf9\x75\xb0\x85\x1f\x3f\xfc\x7c\x3f\x0e\x16\x7a\x3a\x19\xab\x97\xa2\xd6\x29\x18\x4b\x6d\x6b\xfa\x01\xe6\xa8\xad\x53\x04\x78\x5c\x8e\x01\x9e\x52\x0a\x23\x39\x46\xe4\x92\x6e\xa7\x06\xcb\x57\x2f\xcd\x2b\x20\x2f\xcd\x2c\x49\x61\x1c\x78\x79\xdc\x32\xe3\x16\x35\x49\xbe\xe1\xde\x9c\x2c\xf1\xe3\xed\x57\x2c\x6d\xe6\x6c\x9e\x70\xa5\x55\x65\x14\x2d\xf1\xb4\x7f\x2f\xed\x1b\x73\xb3\x6b\xf7\x0a\x65\x0d\xc6\xcf\x6f\x62\xac\x66\xa2\x49\x66\x9d\x8f\x99\x6c\x71\xd3\x6d\x65\x8d\x8a\xd3\x12\x49\x4e\x56\x3f\xbd\xfe\xbc\xbe\x5c\xd1\xd7\x7f\xae\x2f\x66\x79\x33\xca\xfd\x47\x0a\x3b\xa9\xab\x31\x4f\x62\x98\x04\x1c\x1f\x9d\x72\x20\xc7\xa3\xc8\x5f\x6e\x20\x4f\x21\x49\x4e\x62\xe5\xf6\xb0\xa0\xdb\xd3\xf4\x18\xa6\x6f\x34\x73\x51\x97\xdf\xe4\x64\xf5\xe5\x26\x5f\x5f\xce\xce\xf3\xcc\xa2\xb1\xd1\xea\xff\xf0\x3b\x36\xef\xbe\xab\xec\x7c\x01\x61\x08\x4f\xe5\xbf\xdd\xdb\x29\xd8\x5e\x30\xa9\xc0\x4b\xa2\x6b\x9e\x9b\x92\x72\x04\x0a\xa2\xdd\xde\xa2\x06\xa0\xa2\x02\x5a\x55\x40\x61\x8b\x56\xb3\x12\x94\xc6\x9a\x7d\x9f\xd2\xf6\x51\x96\xa7\x5b\x74\xaf\xec\xae\xc5\x3c\x07\x83\x16\x2a\xac\x69\xcb\xad\x39\xbe\x69\x11\x6e\x3a\x54\x91\x38\x32\x33\xf3\x81\x7e\x20\x62\x36\x03\x01\x05\xcc\x97\xbd\xc7\x8b\xca\xa9\xa3\x5f\x35\xf1\x9b\x41\x05\x05\x2c\x96\xe3\x8c\xa1\x41\x26\x2a\xfc\x0e\x8b\xf9\x7c\x9e\xba\x63\x3e\x4f\xb3\x2c\x83\x5b\x2c\xe5\x16\x0d\x2c\xd2\xff\xb9\xff\xfd\x87\x85\x7b\x21\xbf\xa7\x76\x93\xd5\x5c\x4a\x4d\x8e\x1f\xb9\x6c\x16\x73\x5f\x5a\x0e\x6f\xe2\xc4\x39\xb7\xba\x73\x53\x72\x47\x16\x73\xd7\xfd\xa0\x8c\xa4\x75\x5b\x55\x40\x3e\xb5\x63\x70\xd1\x07\x32\x5d\x10\x2d\x5b\x51\x11\x03\x17\x50\xbb\x44\x75\xdf\x55\x29\x45\x49\x2d\x10\x21\xc1\x6a\xca\xb8\xdb\x6b\x73\x33\xf3\x57\x57\x6e\xa4\x34\x18\x9b\xe6\x68\x2d\xea\x31\xc3\x48\x64\xb4\xc9\xac\xbc\xf6\x53\x45\x66\x03\xbb\x6f\xb2\xf9\xe5\x79\xe0\x37\x5c\x46\x4b\x3f\x16\xf1\x79\x95\xb8\x4f\x8d\x5f\xdd\xf1\xde\x1d\xbf\xb8\xe3\x93\x3b\x7e\x73\xc7\xe7\x64\xbd\x62\xeb\xc1\xf3\xe7\xc4\x3f\x9d\x9c\x15\xdf\xe0\x33\x58\xf4\xc4\x62\x10\x47\xd7\xfe\x30\xdd\xe2\x62\xd8\xe1\xbd\x6c\x84\xa9\x80\x0b\x58\xcc\x1d\xa8\x8b\xf9\x71\x71\x15\xd3\x58\x5a\x76\x8f\x24\x11\xcd\x3b\x61\xf1\x19\xdb\xd9\x84\x8f\x1c\xe4\xb8\x45\x61\x53\xa0\xd6\xea\x7e\x9d\x45\x69\xf8\xb4\x72\xbb\xb4\x92\x3b\x01\xdf\x70\xaf\x34\x9a\xc9\x10\xe1\x3d\x0a\x3b\xf4\xe2\xda\xf5\xa2\x6c\xb7\x61\xe5\x06\x8a\xa2\x80\xc5\x9b\xf1\xe6\xf2\x79\xb3\x73\xaa\xd4\xa9\x77\x60\x6f\x83\xf7\x94\x13\x5f\x57\x16\xdb\xea\xdf\x7c\xe3\xb7\x20\x40\xc8\xa8\xb4\xff\x7d\x1b\xa6\x95\xf4\xfa\x80\xe8\x61\x72\xa5\x79\xfe\xe9\xe3\xdb\x8f\xa0\x71\x2b\xef\x11\xec\x86\x19\xd8\xd0\xf2\xdb\x31\x9a\x5f\xd5\xb5\x2e\xff\x21\x96\xb1\x99\x1d\xb5\xe5\x26\x76\xe3\xc3\x8e\xa2\x1a\x5d\x0e\x00\x74\xd8\x3b\x53\x92\x18\x9f\xdf\x19\x2c\x1f\xb7\xf1\x57\x00\x00\x00\xff\xff\x4f\xe8\x29\x29\xe7\x0c\x00\x00") func filesJsUtilsJsBytes() ([]byte, error) { return bindataRead( @@ -616,7 +616,7 @@ func filesJsUtilsJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "files/js/utils.js", size: 2825, mode: os.FileMode(420), modTime: time.Unix(1498117296, 0)} + info := bindataFileInfo{name: "files/js/utils.js", size: 3303, mode: os.FileMode(420), modTime: time.Unix(1507724213, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -701,7 +701,7 @@ func filesTemplateConfigHtml() (*asset, error) { return a, nil } -var _filesTemplateDownloadTreeHtml = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xac\x54\x4d\x6f\xdb\x30\x0c\xbd\xe7\x57\xb0\xc2\x50\x27\x18\xdc\xdc\x57\x3b\x3b\xf4\xbc\x62\xc0\x7e\x81\x2a\x31\x36\x51\x59\x32\x24\x39\x41\x97\xe6\xbf\x0f\x92\x2d\x47\x75\xb2\x5e\xb6\x4b\x62\x7d\xf0\xbd\x47\xf2\x51\xd5\x5d\x59\x42\x25\xe9\x00\x42\x71\xe7\x6a\x46\xc2\xe8\x52\x18\xed\x39\x69\xb4\x6c\x07\x65\xb9\x5b\x55\x94\x8e\x8f\x96\xf7\x3d\x5a\x08\xd7\xd8\x6e\x05\x50\x11\xe8\xa6\xa4\x7d\xcd\xc8\x49\xb2\xeb\x0d\x0b\xeb\x0c\x6c\xde\x21\xf1\x5a\x33\x6f\x9a\x46\xe1\x7a\xc3\x76\xd5\x96\x22\xf0\x1c\xbd\xa7\x78\x70\x1d\x3e\x5d\x8d\x3f\x51\xee\x56\xd2\x61\x14\xb6\xca\xa5\x07\xd5\xa8\xfd\x28\x2b\xdb\x6f\x91\xcb\x90\xca\x0a\x00\xa0\x72\x3d\xd7\x4b\xc9\xbb\xd3\x09\xb4\x91\xf8\xf0\xcc\x3b\x84\xf3\xb9\xda\x86\x5b\x53\x00\x5f\x4a\x84\xfb\x7b\xb8\x23\x27\xcd\x51\x2b\xc3\x25\xe9\x66\x92\xdd\x5a\xdc\xd7\x2c\xed\x6f\x13\xe8\x97\x9e\xfb\x16\xce\xe7\x1b\x34\xfc\xa6\xa8\x0b\xcd\x92\xe5\x53\xa1\x39\xc8\xb5\xbe\xac\x48\xd6\x28\x37\x95\x23\x35\xd0\xb5\xe6\x58\xb3\x3b\x61\xf4\x9e\x6c\x97\x77\xac\xb7\x68\xb1\x33\x07\xcc\x40\x2c\x4a\xf0\x96\xbb\x76\xf2\x41\xec\xcd\x0d\x38\x89\x0a\x3d\xe9\x26\xa4\x72\x03\x7a\x3e\xae\xc1\xdb\x01\x1f\x21\x11\x3d\x7e\x60\x12\x2d\x8a\xd7\xcf\x99\x12\xd2\x1c\xd7\x58\x7c\x03\x6d\xbc\x68\x03\x00\x59\xa1\x10\xa6\x62\x7c\x8e\x44\x1d\x6f\xf0\xa7\xc5\x03\xe1\x11\xde\xdf\xe1\x40\x12\x4d\xb6\xe6\x83\xa4\xb4\xbe\x36\xf6\x74\x90\x95\xea\x45\x0d\x08\xa7\x13\x04\xf4\x04\xf3\x1d\x8a\x49\x92\x19\xbc\x22\x8d\x05\x7c\x83\x22\x32\x41\xaf\xf8\xdb\x65\xfb\x7c\x5e\xaa\xbd\x74\x7c\x1c\x83\x85\xd7\x25\x3a\x61\xa9\xf7\x14\x82\x92\x59\x7e\xd1\x6f\x84\x77\x78\x79\xf3\xe8\x02\xe4\xd0\x4b\xee\x51\x06\x59\xbc\x31\xeb\x78\xe7\x87\x91\xb4\x27\x94\x9b\xe8\xaa\x1b\xc8\x7d\x96\x73\x70\x58\x96\x50\x1a\xad\x58\x9b\x74\xfe\xb1\x50\xc9\x76\x73\xc9\x9d\x19\xac\xc0\x58\x77\x2b\x6a\x76\x55\xa1\x75\x31\xcf\x51\xf1\xf5\x32\x46\x9b\x50\xa9\x22\x0e\xd3\x54\x8e\xc8\x33\x2d\xa8\x6b\xe6\x29\xca\xfa\xc8\xfe\x9d\x66\x6c\x4e\xca\x02\xf8\xe0\x4d\xec\xd4\xc4\x96\xbb\x84\xfd\xff\x1c\x23\xfc\x5f\x7b\xae\xc8\x79\xb6\x78\xd2\xe2\x1b\x25\x94\x71\x28\xc3\xb3\x31\xe2\xe4\xcf\xbc\xc7\x71\x14\x2d\xf6\xc8\x7d\xcd\x02\x3d\x90\x1e\x0d\xf3\xd4\x92\x92\x16\xf5\x68\xf0\x31\x69\x85\xb6\x66\xcf\x46\xe2\xd3\xbc\x1e\x49\xb5\x50\x83\xc4\x29\xe7\x98\x68\xe1\xb1\xeb\x15\xf7\xb8\x4d\xf9\x95\xde\x22\x3e\xb4\xbe\x53\x45\xf0\x72\x4a\x62\xfc\x18\xff\xfe\x04\x00\x00\xff\xff\xac\x4d\xfb\x7a\x8a\x06\x00\x00") +var _filesTemplateDownloadTreeHtml = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xac\x54\xc1\x72\xdb\x20\x10\xbd\xfb\x2b\xd6\x4c\x27\xb2\xa7\xa3\xf8\xde\x48\xee\x21\xe7\x66\x3a\xd3\x2f\x20\xb0\x96\x76\x82\x40\x03\xc8\x9e\xd4\xf1\xbf\x77\x10\x42\x21\x96\x9b\x4b\x7b\x49\x0c\x88\xf7\xf6\xbd\x7d\x4b\xb5\x2e\x4b\xa8\x24\x1d\x41\x28\xee\x5c\xcd\x48\x18\x5d\x0a\xa3\x3d\x27\x8d\x96\xed\xa1\x2c\xf7\xab\x8a\xd2\xf1\xc9\xf2\xbe\x47\x0b\xe1\x33\xb6\x5f\x01\x54\x04\xba\x29\xe9\x50\x33\x72\x92\xec\x66\xcb\xc2\x3a\x03\x9b\x77\x48\xbc\xd4\xcc\x9b\xa6\x51\xb8\xd9\xb2\x7d\xb5\xa3\xeb\xfb\x07\x1a\x8f\x96\x00\xf1\xe3\xf8\x67\x2c\x78\x27\xe9\x18\x4b\x5b\xe5\xc5\x87\xba\x51\xfb\x58\x58\xb6\xdf\x22\x97\x41\xcc\x0a\x00\xa0\xe2\x89\x71\x4d\x4e\x9a\x93\x56\x86\x4b\xd2\xcd\xc4\xdc\x5a\x3c\xd4\x2c\xed\xef\xce\x67\xd0\x46\xe2\xfd\x97\x9e\xfb\x16\x2e\x17\xb6\x4f\x3b\x4f\xbc\x43\xb8\x5c\xaa\x1d\x9f\x70\x5d\xcf\xf5\xb5\x18\xb8\xbb\x83\x6b\x96\x25\x42\xb8\x79\x03\x64\x59\x5f\xa6\xd3\x1a\xe5\x26\x45\xc9\x45\xd7\x9a\x53\xcd\xd6\xc2\xe8\x03\xd9\x2e\xb7\xbd\xb7\x68\xb1\x33\x47\xcc\x40\x2c\x4a\xf0\x96\xbb\x76\x6a\xe6\xd4\x90\x05\x9c\x44\x85\x9e\x74\x13\xa4\xdc\x80\x9e\x8f\x6b\xf0\x76\xc0\x07\x48\x44\x0f\x1f\x98\x44\x8b\xe2\xe5\x73\xa6\x84\x34\xdf\x6b\x2c\xbe\x82\x36\x5e\xb4\x01\x80\xac\x50\x08\x93\x19\x9f\x23\x51\xc7\x1b\xfc\x69\xf1\x48\x78\x82\xb7\x37\x38\x92\x44\x93\xad\xf9\x20\x29\xad\x97\xe9\x9c\x0e\x32\xab\x9e\xd5\x80\x70\x3e\x43\x40\x4f\x30\xdf\xa1\x98\x4a\x32\x83\x57\xa4\xb1\x80\x6f\x50\x8c\x4c\xd0\x2b\xfe\xfa\xbe\x7d\xb9\x5c\x57\xfb\xde\xf1\x98\xe4\xab\xb8\x4a\x74\xc2\x52\xef\x29\x5c\x4a\x61\xf9\x45\xbf\x11\xde\xe0\xf9\xd5\xa3\x0b\x90\x43\x2f\xb9\x47\x19\xca\xe2\x8d\xd9\x8c\xdf\xfc\x30\x92\x0e\x84\x72\x3b\xa6\xea\x06\x72\x9f\x69\x0e\x09\xcb\x04\xcd\xd3\x11\xbc\x49\xe7\x1f\x8d\x4a\xb1\x9b\x2d\x77\x66\xb0\x02\x47\xdf\xad\xa8\xd9\xc2\xa1\x4d\x31\xcf\x51\xf1\xf5\x7d\x8c\xb6\xc1\xa9\x62\x1c\xa6\xc9\x8e\x91\x67\x5a\x50\xd7\xcc\x53\x94\xf5\x91\xfd\x3b\x4d\x6c\x4e\x52\x01\x7c\xf0\x66\xec\xd4\xc4\x96\xa7\x84\xfd\x7f\x8d\x23\xfc\x5f\x7b\xae\xc8\x79\x76\xf5\x94\x86\x89\x5b\x0b\x65\x1c\xca\xf0\x6c\x44\x9c\xfc\xad\xf6\x18\x47\xd1\x62\x8f\xdc\xd7\x2c\xd0\x03\xe9\x18\x98\xc7\x96\x94\xb4\xa8\x63\xc0\xa3\x68\x85\xb6\x66\x4f\x46\xe2\xe3\xbc\x8e\xa4\x5a\xa8\x41\xe2\xa4\x79\x14\x5a\x78\xec\x7a\xc5\x3d\xee\x92\xbe\xd2\x5b\xc4\xfb\xd6\x77\xaa\x08\x59\x4e\x22\xe2\x8f\xf8\xef\x4f\x00\x00\x00\xff\xff\xed\xea\xe2\x50\x4f\x06\x00\x00") func filesTemplateDownloadTreeHtmlBytes() ([]byte, error) { return bindataRead( @@ -716,12 +716,12 @@ func filesTemplateDownloadTreeHtml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "files/template/download-tree.html", size: 1674, mode: os.FileMode(420), modTime: time.Unix(1498117296, 0)} + info := bindataFileInfo{name: "files/template/download-tree.html", size: 1615, mode: os.FileMode(420), modTime: time.Unix(1507722574, 0)} a := &asset{bytes: bytes, info: info} return a, nil } -var _filesTemplateDownloadsHtml = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x7c\x90\xb1\x6e\xc4\x20\x10\x44\x7b\x7f\xc5\x6a\x9b\x4b\x0a\xdb\x91\xae\x05\x9a\x4b\x9d\x7f\x20\x66\xce\x46\x82\xc5\x02\xec\xfc\x7e\xe4\x9c\xcf\x89\x9b\xd0\x00\x3b\xb3\x6f\xb4\xab\xa6\x2b\x0d\xc1\x96\xa2\x79\xf1\x34\xc1\x3a\x64\x36\xef\xe9\x4b\x42\xb2\xae\xa8\x7e\xba\x9a\xa6\x51\xce\xaf\x24\x63\xeb\xef\x9a\x65\x89\x87\xfc\xf2\x4a\x5a\xd3\x1b\xff\x41\x44\x94\x62\x47\x90\x24\xf7\x74\xb1\x69\x88\xd4\x7c\x50\xe9\xee\x03\x0a\xd9\xcf\xb4\x42\xf5\xb3\x69\x54\xef\xfc\xfa\x7f\x8c\x39\xa7\x14\x8c\x11\x52\x1f\xe4\xad\xeb\x57\x0a\xbe\x3c\xea\x67\xc5\x57\x44\xde\xe0\x19\x33\x6c\xd5\x2c\xc9\x81\xbc\x50\xa9\xb6\xa2\x3b\xb2\xba\xdb\xe4\x83\xcb\x10\xfe\x41\x6c\x47\xc6\x76\x48\x52\x73\x0a\x01\x59\xf3\x47\x72\xb8\x1d\xff\x93\xcd\xcb\x10\x16\x07\x2a\x79\xd0\x7c\xa9\x88\x73\xb0\x15\xfd\x73\x13\x6d\xcd\x40\x37\xd5\x18\x2e\x6c\xf6\xa1\x89\xf6\xc7\x7e\x7d\x07\x00\x00\xff\xff\x93\x3e\xf2\x5f\x91\x01\x00\x00") +var _filesTemplateDownloadsHtml = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x8c\x91\xcd\x6e\xc2\x30\x10\x84\xef\x79\x8a\x95\x2f\xc0\x21\x49\x25\xc4\x2d\xce\x85\x9e\x7b\xa1\x7d\x00\x13\x2f\xb1\x55\xff\x44\xde\x0d\x08\x51\xde\xbd\x22\x21\x51\x2a\xb5\x52\x4f\xb6\x35\x9f\x3d\x3b\xe3\x4a\xdb\x33\x34\x4e\x11\x49\x41\xd8\xb0\x8d\x21\x37\xa8\x34\x26\x51\x67\x00\x95\xd9\x4e\x6a\x6f\x61\x21\x00\xbc\xc6\x4b\x70\x51\x69\x7a\x60\xa5\xd9\x8e\xf8\x6e\xc2\x93\x6d\x0d\x0b\x08\x6d\x4e\x26\x5e\xa4\x20\x56\x8c\xc5\x81\x15\x53\x71\xb8\x12\xa3\x2f\x08\xf9\xf9\xd6\xed\x06\xeb\x5f\x00\x6d\xe9\xf3\x3d\xb2\x72\xf9\x1f\xe2\x07\xa1\xde\xc0\x17\x1c\xaf\x8c\x04\xf7\x3b\x9c\x12\xe2\x38\xcf\xae\xce\xaa\x52\xdb\x73\x9d\x65\x43\xc6\xd0\xe6\xf6\x24\x45\xe8\xfd\x3c\xf8\x7a\x03\x52\xc2\x8b\x58\x24\xf4\x48\xa4\x5a\x84\x10\xf5\x44\x8d\x3d\x74\xf5\x74\x0d\x4e\xd6\x21\x81\x3a\xc6\x33\x56\x65\xf7\x2f\x9b\xfa\xa7\x0b\x61\xeb\x31\x8c\xe1\x97\x1f\xd0\x5b\x70\x96\xa6\x52\x96\x8a\x65\xf4\x43\x99\x09\x3b\x54\x2c\x45\x88\x1a\xc1\x06\x18\x8b\x99\xbd\x8a\xbd\xb1\x4e\x27\x0c\x03\xdc\xc4\xc0\x29\x3a\x87\x49\x8a\xb7\xa8\x71\x3f\x9f\xc5\xe0\x00\xc3\xb8\xa1\x71\xbd\x46\xa0\xd4\x48\xb1\x62\xf4\x9d\x53\x8c\xe5\x94\x3f\xe7\x84\x58\x18\xf6\x6e\x25\xea\x67\xd4\x47\xc1\xc3\x66\x5c\xbe\x03\x00\x00\xff\xff\xd9\x73\xa4\x9e\x44\x02\x00\x00") func filesTemplateDownloadsHtmlBytes() ([]byte, error) { return bindataRead( @@ -736,7 +736,7 @@ func filesTemplateDownloadsHtml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "files/template/downloads.html", size: 401, mode: os.FileMode(420), modTime: time.Unix(1498117139, 0)} + info := bindataFileInfo{name: "files/template/downloads.html", size: 580, mode: os.FileMode(420), modTime: time.Unix(1507725004, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -761,7 +761,7 @@ func filesTemplateOmniHtml() (*asset, error) { return a, nil } -var _filesTemplateTorrentsHtml = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x94\x58\x6d\x93\xda\x36\x10\xfe\xce\xaf\x58\xdc\x26\xdc\x4d\x0a\x5c\x9a\xc9\x87\x5e\xc0\x9d\xbe\xa4\xd3\x4e\x33\x99\x4c\x92\x3f\x20\xac\x05\x6b\xce\x48\x1e\x69\x39\xc2\x71\xfe\xef\x9d\xf5\x1b\x92\x6d\x08\xbd\x2f\x80\xbd\x5a\x3d\xcf\x6a\x5f\x1e\xdd\x68\x21\xd5\x23\x24\x99\x70\x6e\x19\x91\xb1\x16\x35\xb9\x69\x8a\x42\xa2\x8d\xe2\x11\xc0\x22\x7d\xd3\xbc\xde\x29\xf0\x5e\x00\x7c\xad\xcd\xd9\x6a\x9e\xbe\xa9\xac\xdf\x7a\xd6\x6b\x95\xa1\x03\x69\xf6\x3a\x33\x42\x2a\xbd\x09\xd7\x1f\x8f\xa0\x77\xdb\x7f\xf1\xe0\x6e\x1c\x09\xc2\x59\xe3\xf0\x16\x8a\x02\x6a\x30\x17\x8c\x96\x4b\x78\x0d\xbf\xc2\x64\x02\xf7\x30\x71\x13\x28\x8a\x0a\xc9\xdb\x78\xb4\x98\x4b\xf5\x18\x8f\x2a\x76\x7a\x33\x55\xeb\x65\xa4\xdc\xfb\x6d\x4e\x87\xae\x9b\xc8\x03\xbc\x45\xe7\xc4\x06\x41\x9b\x06\xb4\xab\x82\x90\xc7\xbf\x49\xd9\x40\x72\x20\x56\xe6\x11\x17\xf3\xbc\xbf\x91\xc5\x1c\x05\x2d\xa3\x9b\x54\xb8\xf4\x27\xa0\x5b\x50\x1a\xc2\x1d\xa3\x11\xb0\x65\xbd\xeb\xd1\xe4\xa8\xef\x81\x66\xfc\x59\xf0\x3b\x0f\x4f\xbd\x21\x38\xdc\x6c\x51\x53\x14\x8f\x18\x8c\xc7\x69\x4c\xb3\x0f\x46\x48\x94\x3e\x0b\x91\x90\x7a\x44\x50\xfa\x11\x2d\xa1\x04\xa9\xb6\xdb\x36\xe8\xfe\x79\xf3\x0e\xf8\x8d\x80\x89\xb2\xc1\x87\xea\x94\x6a\x4e\x1c\xcb\x8a\x5c\x6f\x95\x23\x91\x3c\x88\x55\x86\xb0\xb1\x4a\x0e\x78\xa6\xbd\x81\xc4\x64\xbb\xad\x06\x6b\xf6\xb5\x41\x68\xa2\xf4\xba\xb1\x69\xdf\x87\x16\x5a\x6c\xd1\x7b\x05\xb0\x70\xb9\xd0\x4c\xdd\xa5\x66\xbf\x8c\xc6\x16\x85\x3c\xdc\xd0\xec\xa3\xd8\xe2\xab\xc9\xec\x49\xe5\x93\xdb\x60\x41\x99\x63\xd5\xfb\x2a\x3b\x5a\x4f\x73\x76\x15\xf8\x16\x27\xc7\x83\x7e\x03\xb7\x7a\x33\x4d\x2d\xae\x97\xd1\xf1\x08\x43\xd6\xb3\x9d\xcd\xa0\x28\xae\x05\x23\xbc\x00\x34\xc1\xef\xc7\x83\x53\x2a\x8a\x7f\x28\xbd\xfc\xa3\xd7\xe6\x6f\xe1\x52\x28\x8a\x0b\x2b\x76\x0a\x56\xd9\x0e\x21\xb7\x66\x63\xd1\xb9\xc8\x4f\xbc\x2a\x4d\x38\xf5\x3e\xa1\x4d\x38\xcd\x62\xb8\x83\x97\x2f\xbd\x07\x0b\x78\x7d\x77\x17\xb2\xf0\xdd\xaf\x84\x2d\x3d\x3a\x3a\x64\xb8\x8c\x8e\x7b\x25\x29\xf5\x1d\xbe\x82\xc9\x8b\x49\x37\x0a\xbe\x87\x16\x58\xdc\x61\xd1\x0f\x84\xff\x33\xfc\xe1\xf9\x4b\x8c\x26\x6b\x32\x37\x9c\x58\xe7\x78\x70\xe5\x2b\xad\x60\xb5\x23\x32\xda\x75\xf1\x0a\x3f\x9c\xa5\x49\x10\x47\x8e\x30\x93\xfe\x91\x93\xe7\x2f\x6e\x79\x45\x98\x2c\x75\xb9\xab\xe4\x61\x19\xf9\x66\xb0\x84\xb1\xff\xbb\xb3\x2f\xc0\x42\x35\x3b\x73\x27\x05\x95\x18\xcd\x81\x52\x31\x94\xf6\x21\x4a\x3f\x89\xa0\x4d\x68\xa9\x1c\xd7\xa9\xe4\x9d\xbf\x90\xe0\x7e\x10\x5d\xa6\xb3\xb1\xc8\x0d\x69\xdc\xda\x5f\x60\xe3\x76\xab\xad\xa2\xba\xb1\xdd\x4c\x1c\x2f\x98\x70\xd7\xbb\x40\x25\xc9\xcc\x4e\xb6\x43\xc1\x27\x55\xee\x77\x0d\x29\xee\x7c\x83\x74\x2c\xca\x86\xd2\xf5\x98\x4d\xfe\x3d\xc8\x6c\x13\x02\x35\xf9\xb5\x38\xc7\xdf\x03\x0a\x75\xf5\x3c\x4d\x95\x96\xf8\xed\x1e\x7e\xe1\xbf\x77\x57\x13\x90\x98\x21\xe1\x19\x0a\x4d\xc3\x0c\x67\x45\x7c\xa2\xb6\x12\xda\x67\xf6\x87\xd0\x09\x66\xfd\xee\xd8\x73\x36\xe4\x8b\x2c\x37\x24\xcf\xdb\x67\xdc\x96\x73\xb2\xef\xad\x13\xb0\xe1\x5a\x0f\x5b\xda\xd9\x73\xe7\xe9\xba\x3b\xc9\x8c\xe1\x89\xd1\x64\xf7\x76\x47\x28\xef\x69\xf6\x67\x6d\x8d\x92\x65\x04\xf7\xb8\xe3\x31\x78\xfa\x0c\xab\x03\xa1\xe3\xf6\xda\x1b\x15\xe5\x03\x98\x03\x2f\xf9\xa2\x9e\xf0\x0a\xe3\x69\x69\xdc\xf4\xc5\xa2\x78\x31\x34\x82\x4a\xb0\x75\x3a\xac\x8d\xa6\xe9\x1e\xd5\x26\xa5\xfb\x95\xc9\x64\x74\x89\xc5\x67\x41\xd8\xf0\xa8\xb7\x0a\x5e\xb5\xf8\xe6\xae\xbb\xed\xb9\xbe\xea\x7f\x1d\x4f\xa7\xa3\xee\x39\x8c\x2b\xc5\xd2\x9e\x82\x35\x7b\xe0\x3a\xc9\xcb\x9c\x08\x5a\x72\xd0\x89\xbf\xa6\xca\xb5\xba\x46\x39\x50\xba\x9a\x43\x33\xf8\xc4\x83\x00\x28\x65\x51\x81\xa8\x21\x37\x7b\xb4\x75\x95\x00\x19\x9e\xb3\x6c\xc9\x7c\x8c\x2d\xed\xb8\x8a\xaa\xa4\x4b\x44\x6d\xc2\x09\x07\x8a\x66\x1e\x07\x9f\xe1\x74\xda\xd7\x2a\x2c\x50\x4e\xb3\x3f\x68\xd0\xe5\x30\x6c\x13\xfd\x3c\xa9\x05\x95\x62\xe8\x54\xdf\x3b\x7d\x92\x48\x89\xd9\xe6\x22\x21\x70\x64\x55\x8e\xa7\xd6\xe7\x80\x92\x4c\x42\xb9\xd4\x1f\x54\xc4\x22\x39\xc8\x0b\xb2\x9d\xea\xa1\x34\xd4\x48\x8c\x76\x31\xa7\xf4\xac\x99\x53\x4f\x18\xc5\x9c\xab\x03\x66\xe3\xe9\x94\x6d\xe3\x97\x7a\xe5\xf2\x77\xa5\x41\x1b\xa8\x26\x2f\x7c\x08\x6c\x11\x40\x5c\xd0\xca\xc8\x43\x07\xb2\x97\x28\x55\x30\x9f\x9f\xa1\xfe\x3a\xcb\x50\x6f\x28\x2d\x33\xb6\x3b\x6c\x49\xf2\xec\xe6\x1c\x5d\x46\x3f\xb7\xd9\x55\x26\x7c\x14\x7f\x34\xd5\x9d\x62\x31\x27\x79\x1e\x5f\xb5\x7d\xbd\xb2\x1d\x34\xbc\x30\xf2\x25\xfa\x9a\xa5\x79\x0b\x0e\x8c\x95\x68\x7f\x3f\xdc\x4f\x3e\x09\x4a\x27\x43\xb0\xce\xa8\x52\x18\x50\x17\xf5\xd3\xb2\xd4\x8e\x47\x58\xcf\xd8\x29\x3c\x97\x20\x74\x25\x00\x87\x9b\x6c\xd3\x05\x1a\x7d\x54\x35\x8c\xa8\x09\xe6\xba\xab\xd5\xd6\xa1\x56\x8b\xea\xdd\x2e\xf6\x99\x13\xe4\xab\xdd\xf6\x56\x07\xd7\x94\x52\x63\xd6\xb7\x8e\x93\xa2\x1b\x58\x73\x85\x78\x5c\x5f\x16\x8f\x43\x9e\x2e\x88\xc8\xd6\x7c\xf8\xc5\xb9\xc7\x4d\xc3\x0b\x1e\x7a\x17\x84\x13\x48\xbe\x83\xde\xdd\x45\xc1\x85\xa0\x3e\xed\x9e\xfc\xaf\xfe\xce\xa4\xc3\x00\x36\x31\xb0\x3c\xac\xcb\xb3\x1c\xc2\xc3\x6d\x6a\xe0\xbd\xb5\xc6\xf6\xcf\xf2\x74\x90\xc8\x06\xcd\x2d\x78\x00\x7d\xa0\xe2\x5c\xad\x48\x3d\x69\xd2\xd9\x0a\x96\xa0\x77\x59\x56\xa9\x81\xbe\xb3\x3c\x3e\x1e\x3b\x2b\xb8\x2c\xf2\x2b\x18\x76\x1b\x40\x50\xa1\x55\xb3\x1b\x0d\x84\xdd\x1f\xd6\x50\x14\xcc\xa7\x57\x01\xcd\x89\xd6\xce\xaa\x59\x94\xa4\x98\x3c\x78\xd2\xe6\x22\x98\x5e\xb7\x0c\xbb\xe3\x82\xd6\xc6\x50\xb3\x71\xf3\xcf\x8d\xba\x11\xdd\x42\x0c\xaf\xa3\xff\xd7\xfd\xfb\x4c\x7b\x4e\x8b\x62\xf0\xca\x30\x30\x31\x06\xbc\x51\x2f\x6e\x5f\x0d\x89\xec\xa2\xaf\x5e\x0c\x98\xf3\x49\x66\x94\x43\x2f\x1e\x1a\xd2\xf5\x97\xfa\xe3\xbf\x00\x00\x00\xff\xff\xe9\x36\xc1\x62\x9f\x12\x00\x00") +var _filesTemplateTorrentsHtml = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x8c\x58\xdb\x8e\xdb\x36\x10\x7d\xdf\xaf\x18\xab\x4d\xbc\x8b\xd4\x76\xd2\x20\x0f\xdd\xd8\x2e\x7a\x49\xd1\xa2\x45\x10\x24\xf9\x01\x5a\x1c\x5b\x44\x64\x52\x20\x47\xeb\x78\xbd\xfa\xf7\x62\x74\x33\x29\xc9\x5a\xfb\x65\x25\x71\x38\x37\xce\x9c\x39\xdc\xa5\x54\x0f\x10\xa7\xc2\xb9\x55\xe4\x30\x26\x65\xf4\x2c\x41\x21\xd1\x46\xeb\x1b\x80\x65\xf2\xb6\x59\xcd\x15\x78\x0b\x00\x5f\x8d\xb5\xa8\xc9\xb1\xd4\x22\x79\x5b\x49\xbf\x6b\xa4\xad\xda\x25\x54\x4b\x9e\x4e\xa0\xf3\xfd\xbf\x78\x74\xb7\x8e\x04\xe1\xbc\xd9\x7a\x07\x45\x01\x54\xbd\x8c\x08\xad\x56\xf0\x06\x7e\x85\xe9\x14\xee\x61\xea\xa6\x50\x14\x95\xcd\x77\xeb\x9b\xe5\x42\xaa\x87\xf5\xcd\x4d\x19\x86\xde\xcd\xd4\x76\x15\x29\xf7\x61\x9f\xd1\xb1\xab\x26\xf2\x02\xd9\xa3\x73\x62\x87\xa0\x8d\x34\x07\x9d\x1a\x21\x5d\x15\x6e\xb6\xfe\x4d\xca\xc6\x25\x07\x62\x63\x1e\x70\xb9\xc8\xfa\x86\x2c\x66\x28\x68\x15\xdd\x26\xc2\x25\x3f\x01\xdd\x81\xd2\x10\x5a\x8c\x58\xae\xb6\x79\x32\x19\xea\x7b\xa0\x39\xff\x2d\x7c\x57\x6a\x5b\xe0\x70\xb7\x47\xcd\x29\x63\x3f\xbc\x70\x26\x34\xff\xcf\x08\x89\xd2\xdf\x25\x62\x52\x0f\x08\x4a\x3f\xa0\x25\x94\x20\xd5\x7e\xdf\x9e\x8c\x7f\xa6\x6c\x01\xbf\x13\x70\x8c\x2c\xc0\xaa\x94\xde\xd5\xe1\x70\x1a\xab\xb8\x7a\xbb\x1c\x89\xf8\x9b\xd8\xa4\x08\x3b\xab\xe4\x80\x66\x3a\x18\x88\x4d\x9a\xef\x35\x58\x73\xa8\x05\x42\x11\xa5\xb7\x8d\x4c\xbb\x1e\x4a\x68\xb1\x47\x6f\x09\x60\xe9\x32\xa1\x39\x74\x97\x98\xc3\x2a\x9a\x58\x14\xf2\x78\x4b\xf3\x8f\x62\x8f\xaf\xa6\xf3\x47\x95\x4d\xef\x82\x0d\x65\x79\x55\xeb\x55\x61\xb4\x9a\x16\xac\x2a\xd0\x2d\xce\x8a\x07\xf5\xf2\x72\x62\x71\xbb\x8a\x4e\x27\x18\x92\x98\xe7\x36\x85\xa2\xb8\xd6\x01\xe1\x05\xdd\x24\xbc\x9f\x03\xae\xa0\x68\xfd\x43\xa9\xe5\x1f\xbd\x35\x7f\x0b\x97\x40\x51\x8c\xec\xc8\x15\x6c\xd2\x1c\x21\xb3\x66\x67\xd1\x85\x95\x56\x95\x06\xd7\xda\x27\xb4\x31\x97\xd6\x1a\x5e\xc3\xcb\x97\xde\x87\x25\xbc\x79\xfd\x3a\x8c\xc2\x57\xbf\x11\xb6\xd4\xe8\xe8\x98\xe2\x2a\x3a\x1d\x94\xa4\xc4\x57\xf8\x0a\xa6\x2f\xa6\xdd\x2c\xf8\x1a\x5a\xc7\xd6\x9d\x28\xfa\x89\xf0\x5f\xc3\x17\x4f\x5f\x6c\x34\x59\x93\xba\xe1\x62\xba\x14\x07\x37\xba\xd2\x0a\x36\x39\x91\xd1\xae\xeb\xaf\xf0\xd3\x59\x8a\x04\x79\xe4\x0c\x73\xd0\x3f\x72\xc1\xfc\xa5\x52\x74\x45\xbd\xae\xe2\x6f\xab\xc8\x5f\x80\x15\x4c\xfc\xf7\x8e\x25\x80\xa5\x6a\x6c\x6d\x55\x8a\xa0\x62\xa3\x39\x35\x6a\x0d\xa5\x7c\xe8\x97\x5f\x36\xe7\xb2\x95\xca\x71\x37\x4a\xb6\xfc\x85\x04\x77\x7d\x34\x1e\xc0\xce\x22\x63\xce\xa4\x95\x0f\xfc\x77\xf9\x66\xaf\xa8\xc6\xaa\xdb\xa9\x63\x91\x29\x03\xd9\x88\xf3\x71\x6a\x72\x09\x0d\x64\xfa\x61\x94\x16\xae\x09\x83\x11\x6d\x30\x00\x8b\x32\x0c\x62\xd8\x4b\x93\x3d\xe7\x24\xcb\x84\xae\x99\xec\x5a\xcf\x26\xcf\xba\x56\xf7\xc4\xe3\x4c\x69\x89\xdf\xef\xe1\x17\xfe\xbd\x1f\x71\x59\x62\x8a\x84\x17\x9c\x6e\xc0\x2e\xc4\xf9\xae\x98\x1f\xdd\x46\x68\x3f\xb8\x3f\x84\x8e\x31\xed\x43\x5d\x4f\xfb\x55\xca\xc9\x32\xf4\x78\xea\x3f\xe3\xbe\x1c\x80\x7d\xf5\x9d\x24\x0e\x77\x75\x08\x5e\x17\x4f\x9f\xc7\x66\xee\xda\xba\x1a\x9e\x07\x4d\x55\xef\x73\x42\x79\x4f\xf3\x3f\x6b\x69\x94\xcc\x0f\x18\xcd\x4e\xa7\xe0\xeb\x13\x6c\x8e\x84\x8e\x81\xb4\x37\x08\xca\x0f\xb0\x00\xde\xf2\x45\x3d\xe2\x15\xc2\xb3\x52\xb8\x41\xc0\xa2\x78\x31\x34\x60\x4a\x67\xeb\x12\xd9\x1a\x4d\xb3\x03\x32\x0f\xba\xdf\x98\x54\x46\x63\x51\x7c\x16\x84\x4d\x1c\xb5\xa9\x60\xa9\xf5\x6f\xe1\xba\x66\x2f\x21\xa8\xff\x38\x99\xcd\x6e\xba\xe7\x30\xa9\xc8\x48\x7b\x0a\xd6\x1c\x80\x7b\x27\xe3\x22\x09\xc1\x37\xc0\xdc\xaf\x89\x72\x2d\x6b\x51\x0e\x94\xae\x26\xce\x1c\x3e\x31\xe4\x03\x25\x4c\x19\x10\x35\x64\xe6\x80\xb6\xee\x1c\x20\xc3\x13\x95\x25\x39\x1e\x63\x4b\x39\xee\xac\xaa\xe8\x62\x51\x8b\x70\xc1\x81\xa2\xb9\x17\x83\x1f\xe1\x6c\xd6\x67\x22\x4c\x3f\xce\x93\x3d\x00\xe6\x72\xec\x75\x2a\x7f\x24\x36\x80\x25\x95\x9c\xe7\xdc\xfc\xb9\x3e\x33\xa1\xd8\xec\x33\x11\x13\x38\xb2\x2a\xc3\x33\x12\x3a\xa0\x38\x95\x50\x6e\x0d\xab\x97\x98\x32\x77\x3a\x87\x6c\xaf\x53\x29\x09\x09\x11\x3b\xbf\x5c\x50\x32\x22\xe8\xd4\x23\x46\x6b\x2e\xde\x41\xc1\xc9\x6c\xc6\xd2\xeb\x97\x7a\xe3\xb2\xf7\xa5\x48\x9b\xbb\x73\xe5\x84\xae\xb0\x54\xc7\xdd\x25\x6d\x8c\x3c\xf6\x02\xf0\x6a\xa8\xca\xf3\xd3\x13\xd4\x8f\xf3\x14\xf5\x8e\x92\xb2\x98\xfb\x80\x47\x92\x47\x38\x17\xf0\x2a\xfa\xb9\x2d\xbd\xb2\x1b\xa2\xf5\x47\x03\x3c\x1e\xdd\x72\x41\xdd\x9c\x2d\xba\x49\x63\x27\xea\xdd\xed\x3c\xe2\xcd\x91\x4f\xce\xb7\x4c\xca\x5b\x17\xc1\x58\x89\xf6\xf7\xe3\xfd\xf4\x93\xa0\x64\x3a\xec\xdc\x05\x5a\x5a\x4b\x74\xc8\x46\xfb\xbd\xec\xc8\xd3\x09\xb6\x73\x56\x0d\x4f\xa5\x2b\xba\x62\x84\xc3\xe0\xdc\x6e\x6b\x29\x53\x85\x2c\x51\x93\xda\x6d\x97\xbe\x6d\x43\xfa\x16\xd5\xf6\x46\x01\xc9\x77\xfc\x6a\xc5\x5d\x96\x59\xdf\x35\xce\x9c\x6e\xc0\xc0\x55\x04\x72\x3b\x4e\x20\x87\x75\x8d\x50\x49\x6f\xc3\xa5\xa5\xcb\x0b\x0d\x24\x06\x1f\xbd\x0b\xc2\xd9\x59\xbe\x7e\x72\x5a\xfc\xcb\x41\x7d\xd0\xbd\xab\x40\xf5\xbb\x50\x09\x7d\x7b\x5d\x26\x52\xfe\xba\x6d\x3a\x12\x47\x78\xae\x4d\x23\x7c\xb0\xd6\x58\xff\x18\x91\x3f\x34\x97\xde\x41\x8f\x03\x8e\xe7\x6a\x86\xea\x91\x9a\x8e\x72\x58\x81\xce\xd3\xb4\x62\x09\x43\xea\xb2\xf5\xe9\xd4\xd9\xc3\x9d\x90\x5d\x19\x59\x1f\x01\x82\xf6\xac\xb0\xaf\xa7\xaa\x4c\xbb\x3f\xce\x07\x73\xae\xfa\x8d\xd0\x9c\x70\xad\xbe\x9a\x5e\x71\x82\xf1\x37\x8f\x0c\x3d\xeb\xe2\x00\x9c\x76\xc1\x73\x49\x5b\x63\xa8\x71\xa0\xf9\x7f\x47\x8d\x50\x77\xb0\x86\x37\xdd\x4b\xca\x15\xc3\x62\x28\x0f\x3d\xd5\x45\x31\x70\xd5\xa8\x20\x7f\xc0\xc0\xa0\x4e\xea\xe6\x16\xbe\x1a\x12\xe9\xb3\x1a\x07\xf2\xc2\x59\xf0\x19\x4c\x39\x39\xc7\x38\x4c\xfd\x50\xfd\xf9\x3f\x00\x00\xff\xff\xd3\x33\xb6\x87\xb4\x12\x00\x00") func filesTemplateTorrentsHtmlBytes() ([]byte, error) { return bindataRead( @@ -776,7 +776,7 @@ func filesTemplateTorrentsHtml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "files/template/torrents.html", size: 4767, mode: os.FileMode(420), modTime: time.Unix(1498117139, 0)} + info := bindataFileInfo{name: "files/template/torrents.html", size: 4788, mode: os.FileMode(420), modTime: time.Unix(1507724945, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/static/files/css/app.css b/static/files/css/app.css index 2c11f9884..44a92a5c6 100644 --- a/static/files/css/app.css +++ b/static/files/css/app.css @@ -4,131 +4,139 @@ /* global styles */ -html, body { - width: 100%; - margin: 0; - padding: 0; +html, +body { + width: 100%; + margin: 0; + padding: 0; } .cage { - padding-top: 25px; - padding-bottom: 40px; - max-width: 700px; - margin: 0 auto; + padding-top: 25px; + padding-bottom: 40px; + max-width: 700px; + margin: 0 auto; } @media (max-width: 740px) { - .cage { - margin: 0 10px; - padding-top: 10px; - } + .cage { + margin: 0 10px; + padding-top: 10px; + } } @media (max-width: 480px) { - body .title a { - font-size: 1.65rem; - } + body .title a { + font-size: 1.65rem; + } } html body .muted { - color: gray; + color: gray; } footer { - text-align: right; - color: grey; - font-style: italic; - font-size: 0.8em; - opacity: 0.25; - transition: opacity .3s ease-in-out; + text-align: right; + color: grey; + font-style: italic; + font-size: 0.8em; + opacity: 0.25; + transition: opacity 0.3s ease-in-out; } footer:hover { - opacity: 1; + opacity: 1; +} + +footer:hover .extra { + display: inline; +} + +footer .extra { + display: none; } .ellipsis { - display: inline-block; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; + display: inline-block; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; } [ng-click] { - cursor: pointer; + cursor: pointer; } .disabled { - cursor: default !important; + cursor: default !important; } .icon[ng-click] { - font-size: 1.2em; + font-size: 1.2em; } .app .connect-warning { - padding-top: 50px; - position: fixed; - z-index: 10000; - left: 0; - top: 0; - width: 100%; - height: 100%; - background-color: rgba(0, 0, 0, 1); - opacity: 0.95; + padding-top: 50px; + position: fixed; + z-index: 10000; + left: 0; + top: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 1); + opacity: 0.95; } - /* ================ app styles */ .title { - position: relative; + position: relative; } .title a { - font-size: 2.35rem; + font-size: 2.35rem; } .title .status { - position: absolute; - top: 2px; - right: 10px; + position: absolute; + top: 2px; + right: 10px; } .app .config form.edit { - margin-bottom: 1rem; + margin-bottom: 1rem; } .app .config form.edit input { - font-family: monospace; + font-family: monospace; } .app .config form.edit .buttons { - text-align: center; + text-align: center; } -.torrents-header { - margin-top: 20px; - position: relative; +.section-header { + margin-top: 20px; + position: relative; } -.torrents-header .files.downloading { - position: absolute; - right: 0px; - top: 1px; - margin: 9px; - font-size: 0.75rem; - color: grey; +.section-header .right { + position: absolute; + right: 0px; + top: 1px; + margin: 9px; + font-size: 0.75rem; + color: grey; } table.tcld .name { - text-align: right !important; - word-break: break-all; + text-align: right !important; + word-break: break-all; } .uploads .upload .size { - width: 100px; -} \ No newline at end of file + width: 100px; +} diff --git a/static/files/index.html b/static/files/index.html index 0ee33ced5..1d0b6f53f 100644 --- a/static/files/index.html +++ b/static/files/index.html @@ -31,8 +31,7 @@

- {{ state.Stats.Title - }} + {{ state.Stats.Title }}

@@ -57,10 +56,36 @@

- up {{ ago(state.Stats.Uptime) }} - - github.com/jpillora/cloud-torrent version {{ state.Stats.Version }} - - {{ numKeys(state.Users) }} users connected - - Go {{ state.Stats.Runtime }} +
+ github.com/ + jpillora/ + cloud-torrent version {{ state.Stats.Version }} - + {{ numKeys(state.Users) }} users connected - + + Go {{ state.Stats.Runtime }} + +
+
+ + + goroutines {{ state.Stats.System.goRoutines }}, + + + gomem {{ state.Stats.System.goMemory | bytes }}, + + + cpu {{ state.Stats.System.cpu | round }}%, + + + mem {{ (100*state.Stats.System.memoryUsed/state.Stats.System.memoryTotal) | round }}%, + + + disk {{ (100*state.Stats.System.diskUsed/state.Stats.System.diskTotal) | round }}%, + + + up {{ ago(state.Stats.Uptime) }} +
+
diff --git a/static/files/js/utils.js b/static/files/js/utils.js index fa65c22f1..2eed31bc8 100644 --- a/static/files/js/utils.js +++ b/static/files/js/utils.js @@ -1,29 +1,32 @@ /* globals app,window */ -app.factory('api', function($rootScope, $http, reqerr) { +app.factory("api", function($rootScope, $http, reqerr) { window.http = $http; var request = function(action, data) { - var url = "api/"+action; + var url = "api/" + action; $rootScope.apiing = true; - return $http.post(url, data).error(reqerr).finally(function() { - $rootScope.apiing = false; - }); + return $http + .post(url, data) + .error(reqerr) + .finally(function() { + $rootScope.apiing = false; + }); }; var api = {}; - var actions = ["configure","magnet","url","torrent","file"]; + var actions = ["configure", "magnet", "url", "torrent", "file"]; actions.forEach(function(action) { api[action] = request.bind(null, action); }); return api; }); -app.factory('search', function($rootScope, $http, reqerr) { +app.factory("search", function($rootScope, $http, reqerr) { return { all: function(provider, query, page) { - var params = {query:query}; - if(page !== undefined) params.page = page; + var params = {query: query}; + if (page !== undefined) params.page = page; $rootScope.searching = true; - var req = $http.get("search/"+provider, { params: params }); + var req = $http.get("search/" + provider, {params: params}); req.error(reqerr); req.finally(function() { $rootScope.searching = false; @@ -31,9 +34,9 @@ app.factory('search', function($rootScope, $http, reqerr) { return req; }, one: function(provider, path) { - var opts = { params: { item: path } }; + var opts = {params: {item: path}}; $rootScope.searching = true; - var req = $http.get("search/"+provider+"/item", opts); + var req = $http.get("search/" + provider + "/item", opts); req.error(reqerr); req.finally(function() { $rootScope.searching = false; @@ -43,58 +46,74 @@ app.factory('search', function($rootScope, $http, reqerr) { }; }); -app.factory('storage', function() { +app.factory("storage", function() { return window.localStorage || {}; }); -app.factory('reqerr', function() { +app.factory("reqerr", function() { return function(err, status) { alert(err.error || err); console.error("request error '%s' (%s)", err, status); }; }); -app.filter('keys', function() { +app.filter("keys", function() { return Object.keys; }); -app.filter('addspaces', function() { +app.filter("addspaces", function() { return function(s) { - if(typeof s !== "string") - return s; - return s.replace(/([A-Z]+[a-z]*)/g, function(_, word) { - return " " + word; - }).replace(/^\ /, ""); + if (typeof s !== "string") return s; + return s + .replace(/([A-Z]+[a-z]*)/g, function(_, word) { + return " " + word; + }) + .replace(/^\ /, ""); }; }); -app.filter('filename', function() { +app.filter("filename", function() { return function(path) { - return (/\/([^\/]+)$/).test(path) ? RegExp.$1 : path; + return /\/([^\/]+)$/.test(path) ? RegExp.$1 : path; }; }); -app.filter('bytes', function(bytes) { +app.filter("bytes", function(bytes) { return bytes; }); -app.factory('bytes', function() { - var scale = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']; +//scale a number and add a metric prefix +app.factory("bytes", function() { + return function(n, d) { + // set defaults + if (typeof n !== "number" || isNaN(n)) n = 0; + if (!d || typeof d !== "number") d = 1; + // set scale index 1000,100000,... becomes 1,2,... + var i = Math.floor(Math.floor(Math.log10(n)) / 3); + var f = Math.pow(10, d); + var s; + s = n / Math.pow(10, i * 3); + s = Math.round(s * f) / f; + // concat (no trailing 0s) and choose scale letter + return ( + s.toString().replace(/\.0+$/, "") + + " " + + ["", "K", "M", "G", "T", "P", "Z"][i] + + "B" + ); + }; +}); + +app.filter("round", function() { return function(n) { - var i = 0; - var s = scale[i]; - if (typeof n !== 'number') { - return "-"; - } - while (n > 1000) { - s = scale[++i] || 'x10^' + (i * 3); - n = Math.round(n / 100) / 10; + if (typeof n !== "number") { + return n; } - return "" + n + " " + s; + return Math.round(n * 10) / 10; }; }); -app.directive('ngEnter', function() { +app.directive("ngEnter", function() { return function(scope, element, attrs) { element.bind("keydown keypress", function(event) { if (event.which === 13) { @@ -108,7 +127,7 @@ app.directive('ngEnter', function() { }); //TODO remove this hack -app.directive('jpSrc', function() { +app.directive("jpSrc", function() { return function(scope, element, attrs) { scope.$watch(attrs.jpSrc, function(src) { element.attr("src", src); diff --git a/static/files/template/downloads.html b/static/files/template/downloads.html index c0cd269ba..29a822067 100644 --- a/static/files/template/downloads.html +++ b/static/files/template/downloads.html @@ -1,4 +1,11 @@ -

Downloads

+
+

+ Downloads +

+
+ {{ (state.Stats.System.diskTotal-state.Stats.System.diskUsed) | bytes }} free +
+

Download files above

@@ -6,8 +13,7 @@

Downloads

-
+
-
+
\ No newline at end of file diff --git a/static/files/template/torrents.html b/static/files/template/torrents.html index d862cb39c..ef76833bf 100644 --- a/static/files/template/torrents.html +++ b/static/files/template/torrents.html @@ -1,9 +1,8 @@ - -
+

Torrents

-
+
{{ numKeys(state.Torrents) }} torrent{{ numKeys(state.Torrents) == 1 ? '' : 's' }}
@@ -12,9 +11,7 @@

Add torrents above

-
+
Loading
@@ -27,8 +24,7 @@
{{ t.Name }} - + {{ t.Name }}
@@ -42,22 +38,20 @@
@@ -75,58 +69,59 @@
This torrent is inactive. Press the green power button to reactivate or the red trash can to remove it.
--> -
- - - - - - - - - - - - - - + + + + + + + + + +
FileSize
No files
-
- {{ f.Path | filename }} - {{ f.Percent }}% -
-
-
+
+
+ + + + + + + + + + + + + + - - - - - - - - - -
FileSize
No files
+
+ {{ f.Path | filename }} + {{ f.Percent }}% +
+
+
+
-
- - -
- -

{{f.downloadError}}

-
-
- {{ f.Size | bytes }} -
- {{ numKeys(t.Files) }} Files - - {{ t.Size | bytes }} Total -
-
+
+
+ +

{{f.downloadError}}

+
+
+ {{ f.Size | bytes }} + +
+ {{ numKeys(t.Files) }} Files + + {{ t.Size | bytes }} Total +
+
+
-
+ \ No newline at end of file diff --git a/vendor/github.com/NYTimes/gziphandler/.gitignore b/vendor/github.com/NYTimes/gziphandler/.gitignore new file mode 100644 index 000000000..1377554eb --- /dev/null +++ b/vendor/github.com/NYTimes/gziphandler/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/vendor/github.com/NYTimes/gziphandler/.travis.yml b/vendor/github.com/NYTimes/gziphandler/.travis.yml new file mode 100644 index 000000000..d2b67f69c --- /dev/null +++ b/vendor/github.com/NYTimes/gziphandler/.travis.yml @@ -0,0 +1,6 @@ +language: go + +go: + - 1.7 + - 1.8 + - tip diff --git a/vendor/github.com/NYTimes/gziphandler/CODE_OF_CONDUCT.md b/vendor/github.com/NYTimes/gziphandler/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..cdbca194c --- /dev/null +++ b/vendor/github.com/NYTimes/gziphandler/CODE_OF_CONDUCT.md @@ -0,0 +1,75 @@ +--- +layout: code-of-conduct +version: v1.0 +--- + +This code of conduct outlines our expectations for participants within the **NYTimes/gziphandler** community, as well as steps to reporting unacceptable behavior. We are committed to providing a welcoming and inspiring community for all and expect our code of conduct to be honored. Anyone who violates this code of conduct may be banned from the community. + +Our open source community strives to: + +* **Be friendly and patient.** +* **Be welcoming**: We strive to be a community that welcomes and supports people of all backgrounds and identities. This includes, but is not limited to members of any race, ethnicity, culture, national origin, colour, immigration status, social and economic class, educational level, sex, sexual orientation, gender identity and expression, age, size, family status, political belief, religion, and mental and physical ability. +* **Be considerate**: Your work will be used by other people, and you in turn will depend on the work of others. Any decision you take will affect users and colleagues, and you should take those consequences into account when making decisions. Remember that we're a world-wide community, so you might not be communicating in someone else's primary language. +* **Be respectful**: Not all of us will agree all the time, but disagreement is no excuse for poor behavior and poor manners. We might all experience some frustration now and then, but we cannot allow that frustration to turn into a personal attack. It’s important to remember that a community where people feel uncomfortable or threatened is not a productive one. +* **Be careful in the words that we choose**: we are a community of professionals, and we conduct ourselves professionally. Be kind to others. Do not insult or put down other participants. Harassment and other exclusionary behavior aren't acceptable. +* **Try to understand why we disagree**: Disagreements, both social and technical, happen all the time. It is important that we resolve disagreements and differing views constructively. Remember that we’re different. The strength of our community comes from its diversity, people from a wide range of backgrounds. Different people have different perspectives on issues. Being unable to understand why someone holds a viewpoint doesn’t mean that they’re wrong. Don’t forget that it is human to err and blaming each other doesn’t get us anywhere. Instead, focus on helping to resolve issues and learning from mistakes. + +## Definitions + +Harassment includes, but is not limited to: + +- Offensive comments related to gender, gender identity and expression, sexual orientation, disability, mental illness, neuro(a)typicality, physical appearance, body size, race, age, regional discrimination, political or religious affiliation +- Unwelcome comments regarding a person’s lifestyle choices and practices, including those related to food, health, parenting, drugs, and employment +- Deliberate misgendering. This includes deadnaming or persistently using a pronoun that does not correctly reflect a person's gender identity. You must address people by the name they give you when not addressing them by their username or handle +- Physical contact and simulated physical contact (eg, textual descriptions like “*hug*†or “*backrub*â€) without consent or after a request to stop +- Threats of violence, both physical and psychological +- Incitement of violence towards any individual, including encouraging a person to commit suicide or to engage in self-harm +- Deliberate intimidation +- Stalking or following +- Harassing photography or recording, including logging online activity for harassment purposes +- Sustained disruption of discussion +- Unwelcome sexual attention, including gratuitous or off-topic sexual images or behaviour +- Pattern of inappropriate social contact, such as requesting/assuming inappropriate levels of intimacy with others +- Continued one-on-one communication after requests to cease +- Deliberate “outing†of any aspect of a person’s identity without their consent except as necessary to protect others from intentional abuse +- Publication of non-harassing private communication + +Our open source community prioritizes marginalized people’s safety over privileged people’s comfort. We will not act on complaints regarding: + +- ‘Reverse’ -isms, including ‘reverse racism,’ ‘reverse sexism,’ and ‘cisphobia’ +- Reasonable communication of boundaries, such as “leave me alone,†“go away,†or “I’m not discussing this with you†+- Refusal to explain or debate social justice concepts +- Communicating in a ‘tone’ you don’t find congenial +- Criticizing racist, sexist, cissexist, or otherwise oppressive behavior or assumptions + + +### Diversity Statement + +We encourage everyone to participate and are committed to building a community for all. Although we will fail at times, we seek to treat everyone both as fairly and equally as possible. Whenever a participant has made a mistake, we expect them to take responsibility for it. If someone has been harmed or offended, it is our responsibility to listen carefully and respectfully, and do our best to right the wrong. + +Although this list cannot be exhaustive, we explicitly honor diversity in age, gender, gender identity or expression, culture, ethnicity, language, national origin, political beliefs, profession, race, religion, sexual orientation, socioeconomic status, and technical ability. We will not tolerate discrimination based on any of the protected +characteristics above, including participants with disabilities. + +### Reporting Issues + +If you experience or witness unacceptable behavior—or have any other concerns—please report it by contacting us via **code@nytimes.com**. All reports will be handled with discretion. In your report please include: + +- Your contact information. +- Names (real, nicknames, or pseudonyms) of any individuals involved. If there are additional witnesses, please +include them as well. Your account of what occurred, and if you believe the incident is ongoing. If there is a publicly available record (e.g. a mailing list archive or a public IRC logger), please include a link. +- Any additional information that may be helpful. + +After filing a report, a representative will contact you personally, review the incident, follow up with any additional questions, and make a decision as to how to respond. If the person who is harassing you is part of the response team, they will recuse themselves from handling your incident. If the complaint originates from a member of the response team, it will be handled by a different member of the response team. We will respect confidentiality requests for the purpose of protecting victims of abuse. + +### Attribution & Acknowledgements + +We all stand on the shoulders of giants across many open source communities. We'd like to thank the communities and projects that established code of conducts and diversity statements as our inspiration: + +* [Django](https://www.djangoproject.com/conduct/reporting/) +* [Python](https://www.python.org/community/diversity/) +* [Ubuntu](http://www.ubuntu.com/about/about-ubuntu/conduct) +* [Contributor Covenant](http://contributor-covenant.org/) +* [Geek Feminism](http://geekfeminism.org/about/code-of-conduct/) +* [Citizen Code of Conduct](http://citizencodeofconduct.org/) + +This Code of Conduct was based on https://github.com/todogroup/opencodeofconduct diff --git a/vendor/github.com/NYTimes/gziphandler/CONTRIBUTING.md b/vendor/github.com/NYTimes/gziphandler/CONTRIBUTING.md new file mode 100644 index 000000000..b89a9eb4f --- /dev/null +++ b/vendor/github.com/NYTimes/gziphandler/CONTRIBUTING.md @@ -0,0 +1,30 @@ +# Contributing to NYTimes/gziphandler + +This is an open source project started by handful of developers at The New York Times and open to the entire Go community. + +We really appreciate your help! + +## Filing issues + +When filing an issue, make sure to answer these five questions: + +1. What version of Go are you using (`go version`)? +2. What operating system and processor architecture are you using? +3. What did you do? +4. What did you expect to see? +5. What did you see instead? + +## Contributing code + +Before submitting changes, please follow these guidelines: + +1. Check the open issues and pull requests for existing discussions. +2. Open an issue to discuss a new feature. +3. Write tests. +4. Make sure code follows the ['Go Code Review Comments'](https://github.com/golang/go/wiki/CodeReviewComments). +5. Make sure your changes pass `go test`. +6. Make sure the entire test suite passes locally and on Travis CI. +7. Open a Pull Request. +8. [Squash your commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) after receiving feedback and add a [great commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). + +Unless otherwise noted, the gziphandler source files are distributed under the Apache 2.0-style license found in the LICENSE.md file. diff --git a/vendor/github.com/NYTimes/gziphandler/LICENSE b/vendor/github.com/NYTimes/gziphandler/LICENSE new file mode 100644 index 000000000..df6192d36 --- /dev/null +++ b/vendor/github.com/NYTimes/gziphandler/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2016-2017 The New York Times Company + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/NYTimes/gziphandler/README.md b/vendor/github.com/NYTimes/gziphandler/README.md new file mode 100644 index 000000000..6d7246070 --- /dev/null +++ b/vendor/github.com/NYTimes/gziphandler/README.md @@ -0,0 +1,52 @@ +Gzip Handler +============ + +This is a tiny Go package which wraps HTTP handlers to transparently gzip the +response body, for clients which support it. Although it's usually simpler to +leave that to a reverse proxy (like nginx or Varnish), this package is useful +when that's undesirable. + + +## Usage + +Call `GzipHandler` with any handler (an object which implements the +`http.Handler` interface), and it'll return a new handler which gzips the +response. For example: + +```go +package main + +import ( + "io" + "net/http" + "github.com/NYTimes/gziphandler" +) + +func main() { + withoutGz := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/plain") + io.WriteString(w, "Hello, World") + }) + + withGz := gziphandler.GzipHandler(withoutGz) + + http.Handle("/", withGz) + http.ListenAndServe("0.0.0.0:8000", nil) +} +``` + + +## Documentation + +The docs can be found at [godoc.org][docs], as usual. + + +## License + +[Apache 2.0][license]. + + + + +[docs]: https://godoc.org/github.com/nytimes/gziphandler +[license]: https://github.com/nytimes/gziphandler/blob/master/LICENSE.md diff --git a/vendor/github.com/NYTimes/gziphandler/gzip.go b/vendor/github.com/NYTimes/gziphandler/gzip.go new file mode 100644 index 000000000..b6af9115a --- /dev/null +++ b/vendor/github.com/NYTimes/gziphandler/gzip.go @@ -0,0 +1,407 @@ +package gziphandler + +import ( + "bufio" + "compress/gzip" + "fmt" + "io" + "net" + "net/http" + "strconv" + "strings" + "sync" +) + +const ( + vary = "Vary" + acceptEncoding = "Accept-Encoding" + contentEncoding = "Content-Encoding" + contentType = "Content-Type" + contentLength = "Content-Length" +) + +type codings map[string]float64 + +const ( + // DefaultQValue is the default qvalue to assign to an encoding if no explicit qvalue is set. + // This is actually kind of ambiguous in RFC 2616, so hopefully it's correct. + // The examples seem to indicate that it is. + DefaultQValue = 1.0 + + // DefaultMinSize defines the minimum size to reach to enable compression. + // It's 512 bytes. + DefaultMinSize = 512 +) + +// gzipWriterPools stores a sync.Pool for each compression level for reuse of +// gzip.Writers. Use poolIndex to covert a compression level to an index into +// gzipWriterPools. +var gzipWriterPools [gzip.BestCompression - gzip.BestSpeed + 2]*sync.Pool + +func init() { + for i := gzip.BestSpeed; i <= gzip.BestCompression; i++ { + addLevelPool(i) + } + addLevelPool(gzip.DefaultCompression) +} + +// poolIndex maps a compression level to its index into gzipWriterPools. It +// assumes that level is a valid gzip compression level. +func poolIndex(level int) int { + // gzip.DefaultCompression == -1, so we need to treat it special. + if level == gzip.DefaultCompression { + return gzip.BestCompression - gzip.BestSpeed + 1 + } + return level - gzip.BestSpeed +} + +func addLevelPool(level int) { + gzipWriterPools[poolIndex(level)] = &sync.Pool{ + New: func() interface{} { + // NewWriterLevel only returns error on a bad level, we are guaranteeing + // that this will be a valid level so it is okay to ignore the returned + // error. + w, _ := gzip.NewWriterLevel(nil, level) + return w + }, + } +} + +// GzipResponseWriter provides an http.ResponseWriter interface, which gzips +// bytes before writing them to the underlying response. This doesn't close the +// writers, so don't forget to do that. +// It can be configured to skip response smaller than minSize. +type GzipResponseWriter struct { + http.ResponseWriter + index int // Index for gzipWriterPools. + gw *gzip.Writer + + code int // Saves the WriteHeader value. + + minSize int // Specifed the minimum response size to gzip. If the response length is bigger than this value, it is compressed. + buf []byte // Holds the first part of the write before reaching the minSize or the end of the write. + + contentTypes []string // Only compress if the response is one of these content-types. All are accepted if empty. +} + +// Write appends data to the gzip writer. +func (w *GzipResponseWriter) Write(b []byte) (int, error) { + // If content type is not set. + if _, ok := w.Header()[contentType]; !ok { + // It infer it from the uncompressed body. + w.Header().Set(contentType, http.DetectContentType(b)) + } + + // GZIP responseWriter is initialized. Use the GZIP responseWriter. + if w.gw != nil { + n, err := w.gw.Write(b) + return n, err + } + + // Save the write into a buffer for later use in GZIP responseWriter (if content is long enough) or at close with regular responseWriter. + // On the first write, w.buf changes from nil to a valid slice + w.buf = append(w.buf, b...) + + // If the global writes are bigger than the minSize and we're about to write + // a response containing a content type we want to handle, enable + // compression. + if len(w.buf) >= w.minSize && handleContentType(w.contentTypes, w) && w.Header().Get(contentEncoding) == "" { + err := w.startGzip() + if err != nil { + return 0, err + } + } + + return len(b), nil +} + +// startGzip initialize any GZIP specific informations. +func (w *GzipResponseWriter) startGzip() error { + + // Set the GZIP header. + w.Header().Set(contentEncoding, "gzip") + + // if the Content-Length is already set, then calls to Write on gzip + // will fail to set the Content-Length header since its already set + // See: https://github.com/golang/go/issues/14975. + w.Header().Del(contentLength) + + // Write the header to gzip response. + if w.code != 0 { + w.ResponseWriter.WriteHeader(w.code) + } + + // Initialize the GZIP response. + w.init() + + // Flush the buffer into the gzip response. + n, err := w.gw.Write(w.buf) + + // This should never happen (per io.Writer docs), but if the write didn't + // accept the entire buffer but returned no specific error, we have no clue + // what's going on, so abort just to be safe. + if err == nil && n < len(w.buf) { + return io.ErrShortWrite + } + + w.buf = nil + return err +} + +// WriteHeader just saves the response code until close or GZIP effective writes. +func (w *GzipResponseWriter) WriteHeader(code int) { + w.code = code +} + +// init graps a new gzip writer from the gzipWriterPool and writes the correct +// content encoding header. +func (w *GzipResponseWriter) init() { + // Bytes written during ServeHTTP are redirected to this gzip writer + // before being written to the underlying response. + gzw := gzipWriterPools[w.index].Get().(*gzip.Writer) + gzw.Reset(w.ResponseWriter) + w.gw = gzw +} + +// Close will close the gzip.Writer and will put it back in the gzipWriterPool. +func (w *GzipResponseWriter) Close() error { + if w.gw == nil { + // Gzip not trigged yet, write out regular response. + if w.code != 0 { + w.ResponseWriter.WriteHeader(w.code) + } + if w.buf != nil { + _, writeErr := w.ResponseWriter.Write(w.buf) + // Returns the error if any at write. + if writeErr != nil { + return fmt.Errorf("gziphandler: write to regular responseWriter at close gets error: %q", writeErr.Error()) + } + } + return nil + } + + err := w.gw.Close() + gzipWriterPools[w.index].Put(w.gw) + w.gw = nil + return err +} + +// Flush flushes the underlying *gzip.Writer and then the underlying +// http.ResponseWriter if it is an http.Flusher. This makes GzipResponseWriter +// an http.Flusher. +func (w *GzipResponseWriter) Flush() { + if w.gw != nil { + w.gw.Flush() + } + + if fw, ok := w.ResponseWriter.(http.Flusher); ok { + fw.Flush() + } +} + +// Hijack implements http.Hijacker. If the underlying ResponseWriter is a +// Hijacker, its Hijack method is returned. Otherwise an error is returned. +func (w *GzipResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { + if hj, ok := w.ResponseWriter.(http.Hijacker); ok { + return hj.Hijack() + } + return nil, nil, fmt.Errorf("http.Hijacker interface is not supported") +} + +// verify Hijacker interface implementation +var _ http.Hijacker = &GzipResponseWriter{} + +// MustNewGzipLevelHandler behaves just like NewGzipLevelHandler except that in +// an error case it panics rather than returning an error. +func MustNewGzipLevelHandler(level int) func(http.Handler) http.Handler { + wrap, err := NewGzipLevelHandler(level) + if err != nil { + panic(err) + } + return wrap +} + +// NewGzipLevelHandler returns a wrapper function (often known as middleware) +// which can be used to wrap an HTTP handler to transparently gzip the response +// body if the client supports it (via the Accept-Encoding header). Responses will +// be encoded at the given gzip compression level. An error will be returned only +// if an invalid gzip compression level is given, so if one can ensure the level +// is valid, the returned error can be safely ignored. +func NewGzipLevelHandler(level int) (func(http.Handler) http.Handler, error) { + return NewGzipLevelAndMinSize(level, DefaultMinSize) +} + +// NewGzipLevelAndMinSize behave as NewGzipLevelHandler except it let the caller +// specify the minimum size before compression. +func NewGzipLevelAndMinSize(level, minSize int) (func(http.Handler) http.Handler, error) { + return GzipHandlerWithOpts(CompressionLevel(level), MinSize(minSize)) +} + +func GzipHandlerWithOpts(opts ...option) (func(http.Handler) http.Handler, error) { + c := &config{ + level: gzip.DefaultCompression, + minSize: DefaultMinSize, + } + + for _, o := range opts { + o(c) + } + + if err := c.validate(); err != nil { + return nil, err + } + + return func(h http.Handler) http.Handler { + index := poolIndex(c.level) + + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Add(vary, acceptEncoding) + + if acceptsGzip(r) { + gw := &GzipResponseWriter{ + ResponseWriter: w, + index: index, + minSize: c.minSize, + contentTypes: c.contentTypes, + } + defer gw.Close() + + h.ServeHTTP(gw, r) + } else { + h.ServeHTTP(w, r) + } + }) + }, nil +} + +// Used for functional configuration. +type config struct { + minSize int + level int + contentTypes []string +} + +func (c *config) validate() error { + if c.level != gzip.DefaultCompression && (c.level < gzip.BestSpeed || c.level > gzip.BestCompression) { + return fmt.Errorf("invalid compression level requested: %d", c.level) + } + + if c.minSize < 0 { + return fmt.Errorf("minimum size must be more than zero") + } + + return nil +} + +type option func(c *config) + +func MinSize(size int) option { + return func(c *config) { + c.minSize = size + } +} + +func CompressionLevel(level int) option { + return func(c *config) { + c.level = level + } +} + +func ContentTypes(types []string) option { + return func(c *config) { + c.contentTypes = []string{} + for _, v := range types { + c.contentTypes = append(c.contentTypes, strings.ToLower(v)) + } + } +} + +// GzipHandler wraps an HTTP handler, to transparently gzip the response body if +// the client supports it (via the Accept-Encoding header). This will compress at +// the default compression level. +func GzipHandler(h http.Handler) http.Handler { + wrapper, _ := NewGzipLevelHandler(gzip.DefaultCompression) + return wrapper(h) +} + +// acceptsGzip returns true if the given HTTP request indicates that it will +// accept a gzipped response. +func acceptsGzip(r *http.Request) bool { + acceptedEncodings, _ := parseEncodings(r.Header.Get(acceptEncoding)) + return acceptedEncodings["gzip"] > 0.0 +} + +// returns true if we've been configured to compress the specific content type. +func handleContentType(contentTypes []string, w http.ResponseWriter) bool { + // If contentTypes is empty we handle all content types. + if len(contentTypes) == 0 { + return true + } + + ct := strings.ToLower(w.Header().Get(contentType)) + for _, c := range contentTypes { + if c == ct { + return true + } + } + + return false +} + +// parseEncodings attempts to parse a list of codings, per RFC 2616, as might +// appear in an Accept-Encoding header. It returns a map of content-codings to +// quality values, and an error containing the errors encountered. It's probably +// safe to ignore those, because silently ignoring errors is how the internet +// works. +// +// See: http://tools.ietf.org/html/rfc2616#section-14.3. +func parseEncodings(s string) (codings, error) { + c := make(codings) + var e []string + + for _, ss := range strings.Split(s, ",") { + coding, qvalue, err := parseCoding(ss) + + if err != nil { + e = append(e, err.Error()) + } else { + c[coding] = qvalue + } + } + + // TODO (adammck): Use a proper multi-error struct, so the individual errors + // can be extracted if anyone cares. + if len(e) > 0 { + return c, fmt.Errorf("errors while parsing encodings: %s", strings.Join(e, ", ")) + } + + return c, nil +} + +// parseCoding parses a single conding (content-coding with an optional qvalue), +// as might appear in an Accept-Encoding header. It attempts to forgive minor +// formatting errors. +func parseCoding(s string) (coding string, qvalue float64, err error) { + for n, part := range strings.Split(s, ";") { + part = strings.TrimSpace(part) + qvalue = DefaultQValue + + if n == 0 { + coding = strings.ToLower(part) + } else if strings.HasPrefix(part, "q=") { + qvalue, err = strconv.ParseFloat(strings.TrimPrefix(part, "q="), 64) + + if qvalue < 0.0 { + qvalue = 0.0 + } else if qvalue > 1.0 { + qvalue = 1.0 + } + } + } + + if coding == "" { + err = fmt.Errorf("empty content-coding") + } + + return +} diff --git a/vendor/github.com/NYTimes/gziphandler/gzip_go18.go b/vendor/github.com/NYTimes/gziphandler/gzip_go18.go new file mode 100644 index 000000000..fa9665b7e --- /dev/null +++ b/vendor/github.com/NYTimes/gziphandler/gzip_go18.go @@ -0,0 +1,43 @@ +// +build go1.8 + +package gziphandler + +import "net/http" + +// Push initiates an HTTP/2 server push. +// Push returns ErrNotSupported if the client has disabled push or if push +// is not supported on the underlying connection. +func (w *GzipResponseWriter) Push(target string, opts *http.PushOptions) error { + pusher, ok := w.ResponseWriter.(http.Pusher) + if ok && pusher != nil { + return pusher.Push(target, setAcceptEncodingForPushOptions(opts)) + } + return http.ErrNotSupported +} + +// setAcceptEncodingForPushOptions sets "Accept-Encoding" : "gzip" for PushOptions without overriding existing headers. +func setAcceptEncodingForPushOptions(opts *http.PushOptions) *http.PushOptions { + + if opts == nil { + opts = &http.PushOptions{ + Header: http.Header{ + acceptEncoding: []string{"gzip"}, + }, + } + return opts + } + + if opts.Header == nil { + opts.Header = http.Header{ + acceptEncoding: []string{"gzip"}, + } + return opts + } + + if encoding := opts.Header.Get(acceptEncoding); encoding == "" { + opts.Header.Add(acceptEncoding, "gzip") + return opts + } + + return opts +} diff --git a/vendor/github.com/PuerkitoBio/goquery/array_test.go b/vendor/github.com/PuerkitoBio/goquery/array_test.go deleted file mode 100644 index 8e50f7583..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/array_test.go +++ /dev/null @@ -1,212 +0,0 @@ -package goquery - -import ( - "testing" -) - -func TestFirst(t *testing.T) { - sel := Doc().Find(".pvk-content").First() - assertLength(t, sel.Nodes, 1) -} - -func TestFirstEmpty(t *testing.T) { - sel := Doc().Find(".pvk-zzcontentzz").First() - assertLength(t, sel.Nodes, 0) -} - -func TestFirstInvalid(t *testing.T) { - sel := Doc().Find("").First() - assertLength(t, sel.Nodes, 0) -} - -func TestFirstRollback(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.First().End() - assertEqual(t, sel, sel2) -} - -func TestLast(t *testing.T) { - sel := Doc().Find(".pvk-content").Last() - assertLength(t, sel.Nodes, 1) - - // Should contain Footer - foot := Doc().Find(".footer") - if !sel.Contains(foot.Nodes[0]) { - t.Error("Last .pvk-content should contain .footer.") - } -} - -func TestLastEmpty(t *testing.T) { - sel := Doc().Find(".pvk-zzcontentzz").Last() - assertLength(t, sel.Nodes, 0) -} - -func TestLastInvalid(t *testing.T) { - sel := Doc().Find("").Last() - assertLength(t, sel.Nodes, 0) -} - -func TestLastRollback(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.Last().End() - assertEqual(t, sel, sel2) -} - -func TestEq(t *testing.T) { - sel := Doc().Find(".pvk-content").Eq(1) - assertLength(t, sel.Nodes, 1) -} - -func TestEqNegative(t *testing.T) { - sel := Doc().Find(".pvk-content").Eq(-1) - assertLength(t, sel.Nodes, 1) - - // Should contain Footer - foot := Doc().Find(".footer") - if !sel.Contains(foot.Nodes[0]) { - t.Error("Index -1 of .pvk-content should contain .footer.") - } -} - -func TestEqEmpty(t *testing.T) { - sel := Doc().Find("something_random_that_does_not_exists").Eq(0) - assertLength(t, sel.Nodes, 0) -} - -func TestEqInvalid(t *testing.T) { - sel := Doc().Find("").Eq(0) - assertLength(t, sel.Nodes, 0) -} - -func TestEqInvalidPositive(t *testing.T) { - sel := Doc().Find(".pvk-content").Eq(3) - assertLength(t, sel.Nodes, 0) -} - -func TestEqInvalidNegative(t *testing.T) { - sel := Doc().Find(".pvk-content").Eq(-4) - assertLength(t, sel.Nodes, 0) -} - -func TestEqRollback(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.Eq(1).End() - assertEqual(t, sel, sel2) -} - -func TestSlice(t *testing.T) { - sel := Doc().Find(".pvk-content").Slice(0, 2) - - assertLength(t, sel.Nodes, 2) -} - -func TestSliceEmpty(t *testing.T) { - defer assertPanic(t) - Doc().Find("x").Slice(0, 2) -} - -func TestSliceInvalid(t *testing.T) { - defer assertPanic(t) - Doc().Find("").Slice(0, 2) -} - -func TestSliceOutOfBounds(t *testing.T) { - defer assertPanic(t) - Doc().Find(".pvk-content").Slice(2, 12) -} - -func TestNegativeSliceStart(t *testing.T) { - sel := Doc().Find(".container-fluid").Slice(-2, 3) - assertLength(t, sel.Nodes, 1) - assertSelectionIs(t, sel.Eq(0), "#cf3") -} - -func TestNegativeSliceEnd(t *testing.T) { - sel := Doc().Find(".container-fluid").Slice(1, -1) - assertLength(t, sel.Nodes, 2) - assertSelectionIs(t, sel.Eq(0), "#cf2") - assertSelectionIs(t, sel.Eq(1), "#cf3") -} - -func TestNegativeSliceBoth(t *testing.T) { - sel := Doc().Find(".container-fluid").Slice(-3, -1) - assertLength(t, sel.Nodes, 2) - assertSelectionIs(t, sel.Eq(0), "#cf2") - assertSelectionIs(t, sel.Eq(1), "#cf3") -} - -func TestNegativeSliceOutOfBounds(t *testing.T) { - defer assertPanic(t) - Doc().Find(".container-fluid").Slice(-12, -7) -} - -func TestSliceRollback(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.Slice(0, 2).End() - assertEqual(t, sel, sel2) -} - -func TestGet(t *testing.T) { - sel := Doc().Find(".pvk-content") - node := sel.Get(1) - if sel.Nodes[1] != node { - t.Errorf("Expected node %v to be %v.", node, sel.Nodes[1]) - } -} - -func TestGetNegative(t *testing.T) { - sel := Doc().Find(".pvk-content") - node := sel.Get(-3) - if sel.Nodes[0] != node { - t.Errorf("Expected node %v to be %v.", node, sel.Nodes[0]) - } -} - -func TestGetInvalid(t *testing.T) { - defer assertPanic(t) - sel := Doc().Find(".pvk-content") - sel.Get(129) -} - -func TestIndex(t *testing.T) { - sel := Doc().Find(".pvk-content") - if i := sel.Index(); i != 1 { - t.Errorf("Expected index of 1, got %v.", i) - } -} - -func TestIndexSelector(t *testing.T) { - sel := Doc().Find(".hero-unit") - if i := sel.IndexSelector("div"); i != 4 { - t.Errorf("Expected index of 4, got %v.", i) - } -} - -func TestIndexSelectorInvalid(t *testing.T) { - sel := Doc().Find(".hero-unit") - if i := sel.IndexSelector(""); i != -1 { - t.Errorf("Expected index of -1, got %v.", i) - } -} - -func TestIndexOfNode(t *testing.T) { - sel := Doc().Find("div.pvk-gutter") - if i := sel.IndexOfNode(sel.Nodes[1]); i != 1 { - t.Errorf("Expected index of 1, got %v.", i) - } -} - -func TestIndexOfNilNode(t *testing.T) { - sel := Doc().Find("div.pvk-gutter") - if i := sel.IndexOfNode(nil); i != -1 { - t.Errorf("Expected index of -1, got %v.", i) - } -} - -func TestIndexOfSelection(t *testing.T) { - sel := Doc().Find("div") - sel2 := Doc().Find(".hero-unit") - if i := sel.IndexOfSelection(sel2); i != 4 { - t.Errorf("Expected index of 4, got %v.", i) - } -} diff --git a/vendor/github.com/PuerkitoBio/goquery/bench/v0.1.0 b/vendor/github.com/PuerkitoBio/goquery/bench/v0.1.0 deleted file mode 100644 index eb5847831..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench/v0.1.0 +++ /dev/null @@ -1,436 +0,0 @@ -PASS -BenchmarkFirst 20000000 92.9 ns/op -BenchmarkLast 20000000 91.6 ns/op -BenchmarkEq 20000000 90.6 ns/op -BenchmarkSlice 20000000 86.7 ns/op -BenchmarkGet 1000000000 2.14 ns/op -BenchmarkIndex 500000 5308 ns/op ---- BENCH: BenchmarkIndex - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 -BenchmarkIndexSelector 50000 54962 ns/op ---- BENCH: BenchmarkIndexSelector - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 -BenchmarkIndexOfNode 100000000 11.4 ns/op ---- BENCH: BenchmarkIndexOfNode - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 -BenchmarkIndexOfSelection 100000000 12.1 ns/op ---- BENCH: BenchmarkIndexOfSelection - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 -BenchmarkMetalReviewExample 5000 327144 ns/op ---- BENCH: BenchmarkMetalReviewExample - bench_example_test.go:40: Review 0: Midnight - Complete and Total Hell (8.5). - Review 1: Over Your Threshold - Facticity (6.0). - Review 2: Nuclear Death Terror - Chaos Reigns (7.5). - Review 3: Evoken - Atra Mors (9.5). - - bench_example_test.go:41: MetalReviewExample=10 - bench_example_test.go:40: Review 0: Midnight - Complete and Total Hell (8.5). - Review 1: Over Your Threshold - Facticity (6.0). - Review 2: Nuclear Death Terror - Chaos Reigns (7.5). - Review 3: Evoken - Atra Mors (9.5). - ... [output truncated] -BenchmarkAdd 50000 52945 ns/op ---- BENCH: BenchmarkAdd - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 -BenchmarkAddSelection 10000000 205 ns/op ---- BENCH: BenchmarkAddSelection - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 -BenchmarkAddNodes 10000000 203 ns/op ---- BENCH: BenchmarkAddNodes - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 -BenchmarkAndSelf 1000000 2639 ns/op ---- BENCH: BenchmarkAndSelf - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 -BenchmarkFilter 50000 30182 ns/op ---- BENCH: BenchmarkFilter - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 -BenchmarkNot 50000 34855 ns/op ---- BENCH: BenchmarkNot - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 -BenchmarkFilterFunction 50000 66052 ns/op ---- BENCH: BenchmarkFilterFunction - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 -BenchmarkNotFunction 50000 69721 ns/op ---- BENCH: BenchmarkNotFunction - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 -BenchmarkFilterNodes 50000 66077 ns/op ---- BENCH: BenchmarkFilterNodes - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 -BenchmarkNotNodes 20000 80021 ns/op ---- BENCH: BenchmarkNotNodes - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 -BenchmarkFilterSelection 50000 66256 ns/op ---- BENCH: BenchmarkFilterSelection - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 -BenchmarkNotSelection 20000 79568 ns/op ---- BENCH: BenchmarkNotSelection - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 -BenchmarkHas 5000 569441 ns/op ---- BENCH: BenchmarkHas - bench_filter_test.go:160: Has=13 - bench_filter_test.go:160: Has=13 - bench_filter_test.go:160: Has=13 -BenchmarkHasNodes 10000 230585 ns/op ---- BENCH: BenchmarkHasNodes - bench_filter_test.go:178: HasNodes=15 - bench_filter_test.go:178: HasNodes=15 - bench_filter_test.go:178: HasNodes=15 -BenchmarkHasSelection 10000 231470 ns/op ---- BENCH: BenchmarkHasSelection - bench_filter_test.go:195: HasSelection=15 - bench_filter_test.go:195: HasSelection=15 - bench_filter_test.go:195: HasSelection=15 -BenchmarkEnd 500000000 4.65 ns/op ---- BENCH: BenchmarkEnd - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 -BenchmarkEach 200000 9558 ns/op ---- BENCH: BenchmarkEach - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 -BenchmarkMap 100000 16809 ns/op ---- BENCH: BenchmarkMap - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 -BenchmarkAttr 50000000 37.5 ns/op ---- BENCH: BenchmarkAttr - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading -BenchmarkText 100000 18583 ns/op -BenchmarkLength 2000000000 0.80 ns/op ---- BENCH: BenchmarkLength - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 -BenchmarkHtml 5000000 666 ns/op -BenchmarkIs 50000 34328 ns/op ---- BENCH: BenchmarkIs - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true -BenchmarkIsPositional 50000 32423 ns/op ---- BENCH: BenchmarkIsPositional - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true -BenchmarkIsFunction 1000000 2707 ns/op ---- BENCH: BenchmarkIsFunction - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true -BenchmarkIsSelection 50000 66976 ns/op ---- BENCH: BenchmarkIsSelection - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true -BenchmarkIsNodes 50000 66740 ns/op ---- BENCH: BenchmarkIsNodes - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true -BenchmarkHasClass 5000 701722 ns/op ---- BENCH: BenchmarkHasClass - bench_query_test.go:82: HasClass=true - bench_query_test.go:82: HasClass=true - bench_query_test.go:82: HasClass=true -BenchmarkContains 100000000 11.9 ns/op ---- BENCH: BenchmarkContains - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true -BenchmarkFind 50000 55444 ns/op ---- BENCH: BenchmarkFind - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 -BenchmarkFindWithinSelection 10000 127984 ns/op ---- BENCH: BenchmarkFindWithinSelection - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 -BenchmarkFindSelection 5000 355944 ns/op ---- BENCH: BenchmarkFindSelection - bench_traversal_test.go:51: FindSelection=73 - bench_traversal_test.go:51: FindSelection=73 - bench_traversal_test.go:51: FindSelection=73 -BenchmarkFindNodes 5000 355596 ns/op ---- BENCH: BenchmarkFindNodes - bench_traversal_test.go:69: FindNodes=73 - bench_traversal_test.go:69: FindNodes=73 - bench_traversal_test.go:69: FindNodes=73 -BenchmarkContents 500000 5656 ns/op ---- BENCH: BenchmarkContents - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 -BenchmarkContentsFiltered 200000 9007 ns/op ---- BENCH: BenchmarkContentsFiltered - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 -BenchmarkChildren 1000000 1237 ns/op ---- BENCH: BenchmarkChildren - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 -BenchmarkChildrenFiltered 500000 5613 ns/op ---- BENCH: BenchmarkChildrenFiltered - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 -BenchmarkParent 50000 47026 ns/op ---- BENCH: BenchmarkParent - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 -BenchmarkParentFiltered 50000 51438 ns/op ---- BENCH: BenchmarkParentFiltered - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 -BenchmarkParents 20000 91820 ns/op ---- BENCH: BenchmarkParents - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 -BenchmarkParentsFiltered 20000 95156 ns/op ---- BENCH: BenchmarkParentsFiltered - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 -BenchmarkParentsUntil 10000 134383 ns/op ---- BENCH: BenchmarkParentsUntil - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 -BenchmarkParentsUntilSelection 10000 235456 ns/op ---- BENCH: BenchmarkParentsUntilSelection - bench_traversal_test.go:230: ParentsUntilSelection=70 - bench_traversal_test.go:230: ParentsUntilSelection=70 - bench_traversal_test.go:230: ParentsUntilSelection=70 -BenchmarkParentsUntilNodes 10000 235936 ns/op ---- BENCH: BenchmarkParentsUntilNodes - bench_traversal_test.go:248: ParentsUntilNodes=70 - bench_traversal_test.go:248: ParentsUntilNodes=70 - bench_traversal_test.go:248: ParentsUntilNodes=70 -BenchmarkParentsFilteredUntil 50000 32451 ns/op ---- BENCH: BenchmarkParentsFilteredUntil - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 -BenchmarkParentsFilteredUntilSelection 50000 30570 ns/op ---- BENCH: BenchmarkParentsFilteredUntilSelection - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 -BenchmarkParentsFilteredUntilNodes 50000 30729 ns/op ---- BENCH: BenchmarkParentsFilteredUntilNodes - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 -BenchmarkSiblings 10000 106704 ns/op ---- BENCH: BenchmarkSiblings - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 -BenchmarkSiblingsFiltered 10000 115592 ns/op ---- BENCH: BenchmarkSiblingsFiltered - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 -BenchmarkNext 50000 54449 ns/op ---- BENCH: BenchmarkNext - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 -BenchmarkNextFiltered 50000 58503 ns/op ---- BENCH: BenchmarkNextFiltered - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 -BenchmarkNextAll 20000 77698 ns/op ---- BENCH: BenchmarkNextAll - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 -BenchmarkNextAllFiltered 20000 85034 ns/op ---- BENCH: BenchmarkNextAllFiltered - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 -BenchmarkPrev 50000 56458 ns/op ---- BENCH: BenchmarkPrev - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 -BenchmarkPrevFiltered 50000 60163 ns/op ---- BENCH: BenchmarkPrevFiltered - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 -BenchmarkPrevAll 50000 47679 ns/op ---- BENCH: BenchmarkPrevAll - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 -BenchmarkPrevAllFiltered 50000 51563 ns/op ---- BENCH: BenchmarkPrevAllFiltered - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 -BenchmarkNextUntil 10000 213998 ns/op ---- BENCH: BenchmarkNextUntil - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 -BenchmarkNextUntilSelection 10000 140720 ns/op ---- BENCH: BenchmarkNextUntilSelection - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 -BenchmarkNextUntilNodes 20000 90702 ns/op ---- BENCH: BenchmarkNextUntilNodes - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 -BenchmarkPrevUntil 5000 456039 ns/op ---- BENCH: BenchmarkPrevUntil - bench_traversal_test.go:528: PrevUntil=238 - bench_traversal_test.go:528: PrevUntil=238 - bench_traversal_test.go:528: PrevUntil=238 -BenchmarkPrevUntilSelection 10000 167944 ns/op ---- BENCH: BenchmarkPrevUntilSelection - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 -BenchmarkPrevUntilNodes 20000 82059 ns/op ---- BENCH: BenchmarkPrevUntilNodes - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 -BenchmarkNextFilteredUntil 10000 150883 ns/op ---- BENCH: BenchmarkNextFilteredUntil - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 -BenchmarkNextFilteredUntilSelection 10000 146578 ns/op ---- BENCH: BenchmarkNextFilteredUntilSelection - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 -BenchmarkNextFilteredUntilNodes 10000 148284 ns/op ---- BENCH: BenchmarkNextFilteredUntilNodes - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 -BenchmarkPrevFilteredUntil 10000 154303 ns/op ---- BENCH: BenchmarkPrevFilteredUntil - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 -BenchmarkPrevFilteredUntilSelection 10000 149062 ns/op ---- BENCH: BenchmarkPrevFilteredUntilSelection - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 -BenchmarkPrevFilteredUntilNodes 10000 150584 ns/op ---- BENCH: BenchmarkPrevFilteredUntilNodes - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 -ok github.com/PuerkitoBio/goquery 188.326s diff --git a/vendor/github.com/PuerkitoBio/goquery/bench/v0.1.1 b/vendor/github.com/PuerkitoBio/goquery/bench/v0.1.1 deleted file mode 100644 index c0d9d06c1..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench/v0.1.1 +++ /dev/null @@ -1,438 +0,0 @@ -PASS -BenchmarkFirst 20000000 96.2 ns/op -BenchmarkLast 20000000 95.8 ns/op -BenchmarkEq 20000000 94.4 ns/op -BenchmarkSlice 20000000 89.9 ns/op -BenchmarkGet 1000000000 2.31 ns/op -BenchmarkIndex 1000000 1911 ns/op ---- BENCH: BenchmarkIndex - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 -BenchmarkIndexSelector 50000 56034 ns/op ---- BENCH: BenchmarkIndexSelector - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 -BenchmarkIndexOfNode 100000000 11.8 ns/op ---- BENCH: BenchmarkIndexOfNode - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 -BenchmarkIndexOfSelection 100000000 12.1 ns/op ---- BENCH: BenchmarkIndexOfSelection - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 -BenchmarkMetalReviewExample 5000 336823 ns/op ---- BENCH: BenchmarkMetalReviewExample - bench_example_test.go:40: Review 0: Midnight - Complete and Total Hell (8.5). - Review 1: Over Your Threshold - Facticity (6.0). - Review 2: Nuclear Death Terror - Chaos Reigns (7.5). - Review 3: Evoken - Atra Mors (9.5). - - bench_example_test.go:41: MetalReviewExample=10 - bench_example_test.go:40: Review 0: Midnight - Complete and Total Hell (8.5). - Review 1: Over Your Threshold - Facticity (6.0). - Review 2: Nuclear Death Terror - Chaos Reigns (7.5). - Review 3: Evoken - Atra Mors (9.5). - ... [output truncated] -BenchmarkAdd 50000 54709 ns/op ---- BENCH: BenchmarkAdd - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 -BenchmarkAddSelection 10000000 209 ns/op ---- BENCH: BenchmarkAddSelection - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 -BenchmarkAddNodes 10000000 202 ns/op ---- BENCH: BenchmarkAddNodes - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 -BenchmarkAndSelf 1000000 2634 ns/op ---- BENCH: BenchmarkAndSelf - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 -BenchmarkFilter 50000 31049 ns/op ---- BENCH: BenchmarkFilter - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 -BenchmarkNot 50000 35167 ns/op ---- BENCH: BenchmarkNot - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 -BenchmarkFilterFunction 50000 68974 ns/op ---- BENCH: BenchmarkFilterFunction - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 -BenchmarkNotFunction 50000 74760 ns/op ---- BENCH: BenchmarkNotFunction - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 -BenchmarkFilterNodes 50000 68670 ns/op ---- BENCH: BenchmarkFilterNodes - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 -BenchmarkNotNodes 20000 81357 ns/op ---- BENCH: BenchmarkNotNodes - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 -BenchmarkFilterSelection 50000 68388 ns/op ---- BENCH: BenchmarkFilterSelection - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 -BenchmarkNotSelection 20000 82108 ns/op ---- BENCH: BenchmarkNotSelection - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 -BenchmarkHas 5000 582934 ns/op ---- BENCH: BenchmarkHas - bench_filter_test.go:160: Has=13 - bench_filter_test.go:160: Has=13 - bench_filter_test.go:160: Has=13 -BenchmarkHasNodes 10000 241602 ns/op ---- BENCH: BenchmarkHasNodes - bench_filter_test.go:178: HasNodes=15 - bench_filter_test.go:178: HasNodes=15 - bench_filter_test.go:178: HasNodes=15 -BenchmarkHasSelection 10000 243612 ns/op ---- BENCH: BenchmarkHasSelection - bench_filter_test.go:195: HasSelection=15 - bench_filter_test.go:195: HasSelection=15 - bench_filter_test.go:195: HasSelection=15 -BenchmarkEnd 500000000 4.14 ns/op ---- BENCH: BenchmarkEnd - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 -BenchmarkEach 200000 9848 ns/op ---- BENCH: BenchmarkEach - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 -BenchmarkMap 100000 17569 ns/op ---- BENCH: BenchmarkMap - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 -BenchmarkAttr 50000000 37.6 ns/op ---- BENCH: BenchmarkAttr - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading -BenchmarkText 100000 19345 ns/op -BenchmarkLength 2000000000 0.80 ns/op ---- BENCH: BenchmarkLength - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 -BenchmarkHtml 5000000 688 ns/op -BenchmarkIs 50000 35061 ns/op ---- BENCH: BenchmarkIs - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true -BenchmarkIsPositional 50000 32789 ns/op ---- BENCH: BenchmarkIsPositional - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true -BenchmarkIsFunction 1000000 2816 ns/op ---- BENCH: BenchmarkIsFunction - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true -BenchmarkIsSelection 50000 68272 ns/op ---- BENCH: BenchmarkIsSelection - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true -BenchmarkIsNodes 50000 68107 ns/op ---- BENCH: BenchmarkIsNodes - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true -BenchmarkHasClass 5000 709386 ns/op ---- BENCH: BenchmarkHasClass - bench_query_test.go:82: HasClass=true - bench_query_test.go:82: HasClass=true - bench_query_test.go:82: HasClass=true -BenchmarkContains 100000000 12.4 ns/op ---- BENCH: BenchmarkContains - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true -BenchmarkFind 50000 56342 ns/op ---- BENCH: BenchmarkFind - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 -BenchmarkFindWithinSelection 10000 131878 ns/op ---- BENCH: BenchmarkFindWithinSelection - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 -BenchmarkFindSelection 5000 374240 ns/op ---- BENCH: BenchmarkFindSelection - bench_traversal_test.go:51: FindSelection=73 - bench_traversal_test.go:51: FindSelection=73 - bench_traversal_test.go:51: FindSelection=73 -BenchmarkFindNodes 5000 374447 ns/op ---- BENCH: BenchmarkFindNodes - bench_traversal_test.go:69: FindNodes=73 - bench_traversal_test.go:69: FindNodes=73 - bench_traversal_test.go:69: FindNodes=73 -BenchmarkContents 200000 9721 ns/op ---- BENCH: BenchmarkContents - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 -BenchmarkContentsFiltered 200000 12909 ns/op ---- BENCH: BenchmarkContentsFiltered - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 -BenchmarkChildren 1000000 1869 ns/op ---- BENCH: BenchmarkChildren - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 -BenchmarkChildrenFiltered 500000 5941 ns/op ---- BENCH: BenchmarkChildrenFiltered - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 -BenchmarkParent 50000 46223 ns/op ---- BENCH: BenchmarkParent - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 -BenchmarkParentFiltered 50000 51452 ns/op ---- BENCH: BenchmarkParentFiltered - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 -BenchmarkParents 20000 93967 ns/op ---- BENCH: BenchmarkParents - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 -BenchmarkParentsFiltered 20000 97617 ns/op ---- BENCH: BenchmarkParentsFiltered - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 -BenchmarkParentsUntil 10000 138898 ns/op ---- BENCH: BenchmarkParentsUntil - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 -BenchmarkParentsUntilSelection 10000 247817 ns/op ---- BENCH: BenchmarkParentsUntilSelection - bench_traversal_test.go:230: ParentsUntilSelection=70 - bench_traversal_test.go:230: ParentsUntilSelection=70 - bench_traversal_test.go:230: ParentsUntilSelection=70 -BenchmarkParentsUntilNodes 10000 246055 ns/op ---- BENCH: BenchmarkParentsUntilNodes - bench_traversal_test.go:248: ParentsUntilNodes=70 - bench_traversal_test.go:248: ParentsUntilNodes=70 - bench_traversal_test.go:248: ParentsUntilNodes=70 -BenchmarkParentsFilteredUntil 50000 33201 ns/op ---- BENCH: BenchmarkParentsFilteredUntil - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 -BenchmarkParentsFilteredUntilSelection 50000 31486 ns/op ---- BENCH: BenchmarkParentsFilteredUntilSelection - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 -BenchmarkParentsFilteredUntilNodes 50000 31754 ns/op ---- BENCH: BenchmarkParentsFilteredUntilNodes - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 -BenchmarkSiblings 20000 94749 ns/op ---- BENCH: BenchmarkSiblings - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 -BenchmarkSiblingsFiltered 10000 103926 ns/op ---- BENCH: BenchmarkSiblingsFiltered - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 -BenchmarkNext 50000 33782 ns/op ---- BENCH: BenchmarkNext - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 -BenchmarkNextFiltered 50000 37108 ns/op ---- BENCH: BenchmarkNextFiltered - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 -BenchmarkNextAll 50000 64769 ns/op ---- BENCH: BenchmarkNextAll - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 -BenchmarkNextAllFiltered 50000 71050 ns/op ---- BENCH: BenchmarkNextAllFiltered - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 -BenchmarkPrev 50000 33908 ns/op ---- BENCH: BenchmarkPrev - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 -BenchmarkPrevFiltered 50000 37353 ns/op ---- BENCH: BenchmarkPrevFiltered - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 -BenchmarkPrevAll 50000 31056 ns/op ---- BENCH: BenchmarkPrevAll - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 -BenchmarkPrevAllFiltered 50000 34286 ns/op ---- BENCH: BenchmarkPrevAllFiltered - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 -BenchmarkNextUntil 10000 202553 ns/op ---- BENCH: BenchmarkNextUntil - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 -BenchmarkNextUntilSelection 20000 98693 ns/op ---- BENCH: BenchmarkNextUntilSelection - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 -BenchmarkNextUntilNodes 50000 45532 ns/op ---- BENCH: BenchmarkNextUntilNodes - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 -BenchmarkPrevUntil 5000 454378 ns/op ---- BENCH: BenchmarkPrevUntil - bench_traversal_test.go:528: PrevUntil=238 - bench_traversal_test.go:528: PrevUntil=238 - bench_traversal_test.go:528: PrevUntil=238 -BenchmarkPrevUntilSelection 10000 123594 ns/op ---- BENCH: BenchmarkPrevUntilSelection - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 -BenchmarkPrevUntilNodes 50000 37509 ns/op ---- BENCH: BenchmarkPrevUntilNodes - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 -BenchmarkNextFilteredUntil 10000 109317 ns/op ---- BENCH: BenchmarkNextFilteredUntil - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 -BenchmarkNextFilteredUntilSelection 10000 105959 ns/op ---- BENCH: BenchmarkNextFilteredUntilSelection - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 -BenchmarkNextFilteredUntilNodes 10000 107132 ns/op ---- BENCH: BenchmarkNextFilteredUntilNodes - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 -BenchmarkPrevFilteredUntil 10000 114474 ns/op ---- BENCH: BenchmarkPrevFilteredUntil - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 -BenchmarkPrevFilteredUntilSelection 10000 107592 ns/op ---- BENCH: BenchmarkPrevFilteredUntilSelection - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 -BenchmarkPrevFilteredUntilNodes 10000 107495 ns/op ---- BENCH: BenchmarkPrevFilteredUntilNodes - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 -ok github.com/PuerkitoBio/goquery 187.652s diff --git a/vendor/github.com/PuerkitoBio/goquery/bench/v0.1.1-v0.2.1-go1.1rc1.svg b/vendor/github.com/PuerkitoBio/goquery/bench/v0.1.1-v0.2.1-go1.1rc1.svg deleted file mode 100644 index 849a70b79..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench/v0.1.1-v0.2.1-go1.1rc1.svg +++ /dev/null @@ -1,405 +0,0 @@ - - - - - - - - -+0.10% - -BenchmarkFirst - - --0.10% - -BenchmarkLast - - -+2.86% - -BenchmarkEq - - -+2.67% - -BenchmarkSlice - - --10.82% - -BenchmarkGet - - --44.06% - -BenchmarkIndex - - --52.26% - -BenchmarkIndexSelector - - --9.32% - -BenchmarkIndexOfNode - - --2.48% - -BenchmarkIndexOfSelection - - --34.96% - -BenchmarkMetalReviewExample - - --59.16% - -BenchmarkAdd - - -+0.00% - -BenchmarkAddSelection - - -+3.47% - -BenchmarkAddNodes - - --2.51% - -BenchmarkAndSelf - - --13.96% - -BenchmarkFilter - - --14.53% - -BenchmarkNot - - --3.81% - -BenchmarkFilterFunction - - --2.83% - -BenchmarkNotFunction - - --4.63% - -BenchmarkFilterNodes - - --2.32% - -BenchmarkNotNodes - - --4.23% - -BenchmarkFilterSelection - - --3.31% - -BenchmarkNotSelection - - --33.69% - -BenchmarkHas - - --4.53% - -BenchmarkHasNodes - - --5.30% - -BenchmarkHasSelection - - -+11.35% - -BenchmarkEnd - - --3.33% - -BenchmarkEach - - --9.16% - -BenchmarkMap - - --19.15% - -BenchmarkAttr - - --3.24% - -BenchmarkText - - --61.25% - -BenchmarkLength - - --11.92% - -BenchmarkHtml - - --16.46% - -BenchmarkIs - - --27.31% - -BenchmarkIsPositional - - --13.49% - -BenchmarkIsFunction - - --1.71% - -BenchmarkIsSelection - - --3.03% - -BenchmarkIsNodes - - --20.30% - -BenchmarkHasClass - - --11.29% - -BenchmarkContains - - --50.88% - -BenchmarkFind - - --45.28% - -BenchmarkFindWithinSelection - - -+22.95% - -BenchmarkFindSelection - - -+22.68% - -BenchmarkFindNodes - - --65.08% - -BenchmarkContents - - --59.77% - -BenchmarkContentsFiltered - - --64.31% - -BenchmarkChildren - - --39.56% - -BenchmarkChildrenFiltered - - --6.61% - -BenchmarkParent - - --10.92% - -BenchmarkParentFiltered - - --1.72% - -BenchmarkParents - - --2.37% - -BenchmarkParentsFiltered - - --47.60% - -BenchmarkParentsUntil - - --36.39% - -BenchmarkParentsUntilSelection - - --35.99% - -BenchmarkParentsUntilNodes - - --48.84% - -BenchmarkParentsFilteredUntil - - --32.75% - -BenchmarkParentsFilteredUntilSelection - - --33.12% - -BenchmarkParentsFilteredUntilNodes - - --29.78% - -BenchmarkSiblings - - --30.89% - -BenchmarkSiblingsFiltered - - --68.19% - -BenchmarkNext - - --66.59% - -BenchmarkNextFiltered - - --31.08% - -BenchmarkNextAll - - --30.03% - -BenchmarkNextAllFiltered - - --68.32% - -BenchmarkPrev - - --66.65% - -BenchmarkPrevFiltered - - --43.33% - -BenchmarkPrevAll - - --43.24% - -BenchmarkPrevAllFiltered - - --54.27% - -BenchmarkNextUntil - - --37.90% - -BenchmarkNextUntilSelection - - --43.21% - -BenchmarkNextUntilNodes - - --49.33% - -BenchmarkPrevUntil - - --37.02% - -BenchmarkPrevUntilSelection - - --44.59% - -BenchmarkPrevUntilNodes - - --57.79% - -BenchmarkNextFilteredUntil - - --36.61% - -BenchmarkNextFilteredUntilSelection - - --37.81% - -BenchmarkNextFilteredUntilNodes - - --59.21% - -BenchmarkPrevFilteredUntil - - --36.20% - -BenchmarkPrevFilteredUntilSelection - - --36.05% - -BenchmarkPrevFilteredUntilNodes - - diff --git a/vendor/github.com/PuerkitoBio/goquery/bench/v0.2.0 b/vendor/github.com/PuerkitoBio/goquery/bench/v0.2.0 deleted file mode 100644 index 3ea8dcb19..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench/v0.2.0 +++ /dev/null @@ -1,459 +0,0 @@ -PASS -BenchmarkFirst 20000000 94.3 ns/op -BenchmarkLast 20000000 94.7 ns/op -BenchmarkEq 20000000 93.7 ns/op -BenchmarkSlice 20000000 89.9 ns/op -BenchmarkGet 1000000000 2.72 ns/op -BenchmarkIndex 1000000 1834 ns/op ---- BENCH: BenchmarkIndex -bench_array_test.go:73: Index=3 -bench_array_test.go:73: Index=3 -bench_array_test.go:73: Index=3 -bench_array_test.go:73: Index=3 -BenchmarkIndexSelector 50000 53958 ns/op ---- BENCH: BenchmarkIndexSelector -bench_array_test.go:85: IndexSelector=4 -bench_array_test.go:85: IndexSelector=4 -bench_array_test.go:85: IndexSelector=4 -bench_array_test.go:85: IndexSelector=4 -BenchmarkIndexOfNode 100000000 10.1 ns/op ---- BENCH: BenchmarkIndexOfNode -bench_array_test.go:99: IndexOfNode=2 -bench_array_test.go:99: IndexOfNode=2 -bench_array_test.go:99: IndexOfNode=2 -bench_array_test.go:99: IndexOfNode=2 -bench_array_test.go:99: IndexOfNode=2 -BenchmarkIndexOfSelection 100000000 10.9 ns/op ---- BENCH: BenchmarkIndexOfSelection -bench_array_test.go:111: IndexOfSelection=2 -bench_array_test.go:111: IndexOfSelection=2 -bench_array_test.go:111: IndexOfSelection=2 -bench_array_test.go:111: IndexOfSelection=2 -bench_array_test.go:111: IndexOfSelection=2 -BenchmarkMetalReviewExample 5000 326712 ns/op ---- BENCH: BenchmarkMetalReviewExample -bench_example_test.go:40: Review 0: Midnight - Complete and Total Hell (8.5). - Review 1: Over Your Threshold - Facticity (6.0). - Review 2: Nuclear Death Terror - Chaos Reigns (7.5). - Review 3: Evoken - Atra Mors (9.5). - - bench_example_test.go:41: MetalReviewExample=10 -bench_example_test.go:40: Review 0: Midnight - Complete and Total Hell (8.5). - Review 1: Over Your Threshold - Facticity (6.0). - Review 2: Nuclear Death Terror - Chaos Reigns (7.5). - Review 3: Evoken - Atra Mors (9.5). - ... [output truncated] -BenchmarkAdd 50000 51776 ns/op ---- BENCH: BenchmarkAdd -bench_expand_test.go:20: Add=43 -bench_expand_test.go:20: Add=43 -bench_expand_test.go:20: Add=43 -bench_expand_test.go:20: Add=43 -BenchmarkAddSelection 10000000 196 ns/op ---- BENCH: BenchmarkAddSelection -bench_expand_test.go:37: AddSelection=43 -bench_expand_test.go:37: AddSelection=43 -bench_expand_test.go:37: AddSelection=43 -bench_expand_test.go:37: AddSelection=43 -bench_expand_test.go:37: AddSelection=43 -BenchmarkAddNodes 10000000 191 ns/op ---- BENCH: BenchmarkAddNodes -bench_expand_test.go:55: AddNodes=43 -bench_expand_test.go:55: AddNodes=43 -bench_expand_test.go:55: AddNodes=43 -bench_expand_test.go:55: AddNodes=43 -bench_expand_test.go:55: AddNodes=43 -BenchmarkAndSelf 1000000 2495 ns/op ---- BENCH: BenchmarkAndSelf -bench_expand_test.go:71: AndSelf=44 -bench_expand_test.go:71: AndSelf=44 -bench_expand_test.go:71: AndSelf=44 -bench_expand_test.go:71: AndSelf=44 -BenchmarkFilter 50000 30974 ns/op ---- BENCH: BenchmarkFilter -bench_filter_test.go:20: Filter=13 -bench_filter_test.go:20: Filter=13 -bench_filter_test.go:20: Filter=13 -bench_filter_test.go:20: Filter=13 -BenchmarkNot 50000 35322 ns/op ---- BENCH: BenchmarkNot -bench_filter_test.go:36: Not=371 -bench_filter_test.go:36: Not=371 -bench_filter_test.go:36: Not=371 -bench_filter_test.go:36: Not=371 -BenchmarkFilterFunction 50000 65644 ns/op ---- BENCH: BenchmarkFilterFunction -bench_filter_test.go:55: FilterFunction=112 -bench_filter_test.go:55: FilterFunction=112 -bench_filter_test.go:55: FilterFunction=112 -bench_filter_test.go:55: FilterFunction=112 -BenchmarkNotFunction 50000 69245 ns/op ---- BENCH: BenchmarkNotFunction -bench_filter_test.go:74: NotFunction=261 -bench_filter_test.go:74: NotFunction=261 -bench_filter_test.go:74: NotFunction=261 -bench_filter_test.go:74: NotFunction=261 -BenchmarkFilterNodes 50000 64824 ns/op ---- BENCH: BenchmarkFilterNodes -bench_filter_test.go:92: FilterNodes=2 -bench_filter_test.go:92: FilterNodes=2 -bench_filter_test.go:92: FilterNodes=2 -bench_filter_test.go:92: FilterNodes=2 -BenchmarkNotNodes 20000 76247 ns/op ---- BENCH: BenchmarkNotNodes -bench_filter_test.go:110: NotNodes=360 -bench_filter_test.go:110: NotNodes=360 -bench_filter_test.go:110: NotNodes=360 -bench_filter_test.go:110: NotNodes=360 -BenchmarkFilterSelection 50000 66154 ns/op ---- BENCH: BenchmarkFilterSelection -bench_filter_test.go:127: FilterSelection=2 -bench_filter_test.go:127: FilterSelection=2 -bench_filter_test.go:127: FilterSelection=2 -bench_filter_test.go:127: FilterSelection=2 -BenchmarkNotSelection 20000 76336 ns/op ---- BENCH: BenchmarkNotSelection -bench_filter_test.go:144: NotSelection=360 -bench_filter_test.go:144: NotSelection=360 -bench_filter_test.go:144: NotSelection=360 -bench_filter_test.go:144: NotSelection=360 -BenchmarkHas 5000 569495 ns/op ---- BENCH: BenchmarkHas -bench_filter_test.go:160: Has=13 -bench_filter_test.go:160: Has=13 -bench_filter_test.go:160: Has=13 -BenchmarkHasNodes 10000 227059 ns/op ---- BENCH: BenchmarkHasNodes -bench_filter_test.go:178: HasNodes=15 -bench_filter_test.go:178: HasNodes=15 -bench_filter_test.go:178: HasNodes=15 -BenchmarkHasSelection 10000 227167 ns/op ---- BENCH: BenchmarkHasSelection -bench_filter_test.go:195: HasSelection=15 -bench_filter_test.go:195: HasSelection=15 -bench_filter_test.go:195: HasSelection=15 -BenchmarkEnd 500000000 3.99 ns/op ---- BENCH: BenchmarkEnd -bench_filter_test.go:211: End=373 -bench_filter_test.go:211: End=373 -bench_filter_test.go:211: End=373 -bench_filter_test.go:211: End=373 -bench_filter_test.go:211: End=373 -bench_filter_test.go:211: End=373 -BenchmarkEach 200000 9354 ns/op ---- BENCH: BenchmarkEach -bench_iteration_test.go:22: Each=59 -bench_iteration_test.go:22: Each=59 -bench_iteration_test.go:22: Each=59 -bench_iteration_test.go:22: Each=59 -BenchmarkMap 100000 16557 ns/op ---- BENCH: BenchmarkMap -bench_iteration_test.go:41: Map=59 -bench_iteration_test.go:41: Map=59 -bench_iteration_test.go:41: Map=59 -bench_iteration_test.go:41: Map=59 -BenchmarkAttr 50000000 36.4 ns/op ---- BENCH: BenchmarkAttr -bench_property_test.go:16: Attr=firstHeading -bench_property_test.go:16: Attr=firstHeading -bench_property_test.go:16: Attr=firstHeading -bench_property_test.go:16: Attr=firstHeading -bench_property_test.go:16: Attr=firstHeading -BenchmarkText 100000 18473 ns/op -BenchmarkLength 2000000000 0.76 ns/op ---- BENCH: BenchmarkLength -bench_property_test.go:37: Length=14 -bench_property_test.go:37: Length=14 -bench_property_test.go:37: Length=14 -bench_property_test.go:37: Length=14 -bench_property_test.go:37: Length=14 -bench_property_test.go:37: Length=14 -BenchmarkHtml 5000000 666 ns/op -BenchmarkIs 50000 35174 ns/op ---- BENCH: BenchmarkIs -bench_query_test.go:16: Is=true -bench_query_test.go:16: Is=true -bench_query_test.go:16: Is=true -bench_query_test.go:16: Is=true -BenchmarkIsPositional 50000 31814 ns/op ---- BENCH: BenchmarkIsPositional -bench_query_test.go:28: IsPositional=true -bench_query_test.go:28: IsPositional=true -bench_query_test.go:28: IsPositional=true -bench_query_test.go:28: IsPositional=true -BenchmarkIsFunction 1000000 2754 ns/op ---- BENCH: BenchmarkIsFunction -bench_query_test.go:43: IsFunction=true -bench_query_test.go:43: IsFunction=true -bench_query_test.go:43: IsFunction=true -bench_query_test.go:43: IsFunction=true -BenchmarkIsSelection 50000 66260 ns/op ---- BENCH: BenchmarkIsSelection -bench_query_test.go:56: IsSelection=true -bench_query_test.go:56: IsSelection=true -bench_query_test.go:56: IsSelection=true -bench_query_test.go:56: IsSelection=true -BenchmarkIsNodes 50000 64682 ns/op ---- BENCH: BenchmarkIsNodes -bench_query_test.go:70: IsNodes=true -bench_query_test.go:70: IsNodes=true -bench_query_test.go:70: IsNodes=true -bench_query_test.go:70: IsNodes=true -BenchmarkHasClass 5000 672953 ns/op ---- BENCH: BenchmarkHasClass -bench_query_test.go:82: HasClass=true -bench_query_test.go:82: HasClass=true -bench_query_test.go:82: HasClass=true -BenchmarkContains 100000000 11.3 ns/op ---- BENCH: BenchmarkContains -bench_query_test.go:96: Contains=true -bench_query_test.go:96: Contains=true -bench_query_test.go:96: Contains=true -bench_query_test.go:96: Contains=true -bench_query_test.go:96: Contains=true -BenchmarkFind 50000 53780 ns/op ---- BENCH: BenchmarkFind -bench_traversal_test.go:18: Find=41 -bench_traversal_test.go:18: Find=41 -bench_traversal_test.go:18: Find=41 -bench_traversal_test.go:18: Find=41 -BenchmarkFindWithinSelection 10000 125963 ns/op ---- BENCH: BenchmarkFindWithinSelection -bench_traversal_test.go:34: FindWithinSelection=39 -bench_traversal_test.go:34: FindWithinSelection=39 -bench_traversal_test.go:34: FindWithinSelection=39 -BenchmarkFindSelection 5000 357318 ns/op ---- BENCH: BenchmarkFindSelection -bench_traversal_test.go:51: FindSelection=73 -bench_traversal_test.go:51: FindSelection=73 -bench_traversal_test.go:51: FindSelection=73 -BenchmarkFindNodes 5000 357587 ns/op ---- BENCH: BenchmarkFindNodes -bench_traversal_test.go:69: FindNodes=73 -bench_traversal_test.go:69: FindNodes=73 -bench_traversal_test.go:69: FindNodes=73 -BenchmarkContents 200000 9135 ns/op ---- BENCH: BenchmarkContents -bench_traversal_test.go:85: Contents=16 -bench_traversal_test.go:85: Contents=16 -bench_traversal_test.go:85: Contents=16 -bench_traversal_test.go:85: Contents=16 -BenchmarkContentsFiltered 200000 12383 ns/op ---- BENCH: BenchmarkContentsFiltered -bench_traversal_test.go:101: ContentsFiltered=1 -bench_traversal_test.go:101: ContentsFiltered=1 -bench_traversal_test.go:101: ContentsFiltered=1 -bench_traversal_test.go:101: ContentsFiltered=1 -BenchmarkChildren 1000000 1809 ns/op ---- BENCH: BenchmarkChildren -bench_traversal_test.go:117: Children=2 -bench_traversal_test.go:117: Children=2 -bench_traversal_test.go:117: Children=2 -bench_traversal_test.go:117: Children=2 -BenchmarkChildrenFiltered 500000 5814 ns/op ---- BENCH: BenchmarkChildrenFiltered -bench_traversal_test.go:133: ChildrenFiltered=2 -bench_traversal_test.go:133: ChildrenFiltered=2 -bench_traversal_test.go:133: ChildrenFiltered=2 -bench_traversal_test.go:133: ChildrenFiltered=2 -BenchmarkParent 50000 44810 ns/op ---- BENCH: BenchmarkParent -bench_traversal_test.go:149: Parent=55 -bench_traversal_test.go:149: Parent=55 -bench_traversal_test.go:149: Parent=55 -bench_traversal_test.go:149: Parent=55 -BenchmarkParentFiltered 50000 48795 ns/op ---- BENCH: BenchmarkParentFiltered -bench_traversal_test.go:165: ParentFiltered=4 -bench_traversal_test.go:165: ParentFiltered=4 -bench_traversal_test.go:165: ParentFiltered=4 -bench_traversal_test.go:165: ParentFiltered=4 -BenchmarkParents 20000 89102 ns/op ---- BENCH: BenchmarkParents -bench_traversal_test.go:181: Parents=73 -bench_traversal_test.go:181: Parents=73 -bench_traversal_test.go:181: Parents=73 -bench_traversal_test.go:181: Parents=73 -BenchmarkParentsFiltered 20000 93953 ns/op ---- BENCH: BenchmarkParentsFiltered -bench_traversal_test.go:197: ParentsFiltered=18 -bench_traversal_test.go:197: ParentsFiltered=18 -bench_traversal_test.go:197: ParentsFiltered=18 -bench_traversal_test.go:197: ParentsFiltered=18 -BenchmarkParentsUntil 10000 130783 ns/op ---- BENCH: BenchmarkParentsUntil -bench_traversal_test.go:213: ParentsUntil=52 -bench_traversal_test.go:213: ParentsUntil=52 -bench_traversal_test.go:213: ParentsUntil=52 -BenchmarkParentsUntilSelection 10000 231797 ns/op ---- BENCH: BenchmarkParentsUntilSelection -bench_traversal_test.go:230: ParentsUntilSelection=70 -bench_traversal_test.go:230: ParentsUntilSelection=70 -bench_traversal_test.go:230: ParentsUntilSelection=70 -BenchmarkParentsUntilNodes 10000 233761 ns/op ---- BENCH: BenchmarkParentsUntilNodes -bench_traversal_test.go:248: ParentsUntilNodes=70 -bench_traversal_test.go:248: ParentsUntilNodes=70 -bench_traversal_test.go:248: ParentsUntilNodes=70 -BenchmarkParentsFilteredUntil 50000 31360 ns/op ---- BENCH: BenchmarkParentsFilteredUntil -bench_traversal_test.go:264: ParentsFilteredUntil=2 -bench_traversal_test.go:264: ParentsFilteredUntil=2 -bench_traversal_test.go:264: ParentsFilteredUntil=2 -bench_traversal_test.go:264: ParentsFilteredUntil=2 -BenchmarkParentsFilteredUntilSelection 50000 30272 ns/op ---- BENCH: BenchmarkParentsFilteredUntilSelection -bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 -bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 -bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 -bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 -BenchmarkParentsFilteredUntilNodes 50000 30327 ns/op ---- BENCH: BenchmarkParentsFilteredUntilNodes -bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 -bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 -bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 -bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 -BenchmarkSiblings 20000 89862 ns/op ---- BENCH: BenchmarkSiblings -bench_traversal_test.go:315: Siblings=293 -bench_traversal_test.go:315: Siblings=293 -bench_traversal_test.go:315: Siblings=293 -bench_traversal_test.go:315: Siblings=293 -BenchmarkSiblingsFiltered 20000 97948 ns/op ---- BENCH: BenchmarkSiblingsFiltered -bench_traversal_test.go:331: SiblingsFiltered=46 -bench_traversal_test.go:331: SiblingsFiltered=46 -bench_traversal_test.go:331: SiblingsFiltered=46 -bench_traversal_test.go:331: SiblingsFiltered=46 -BenchmarkNext 50000 31975 ns/op ---- BENCH: BenchmarkNext -bench_traversal_test.go:347: Next=49 -bench_traversal_test.go:347: Next=49 -bench_traversal_test.go:347: Next=49 -bench_traversal_test.go:347: Next=49 -BenchmarkNextFiltered 50000 34887 ns/op ---- BENCH: BenchmarkNextFiltered -bench_traversal_test.go:363: NextFiltered=6 -bench_traversal_test.go:363: NextFiltered=6 -bench_traversal_test.go:363: NextFiltered=6 -bench_traversal_test.go:363: NextFiltered=6 -BenchmarkNextAll 50000 60734 ns/op ---- BENCH: BenchmarkNextAll -bench_traversal_test.go:379: NextAll=234 -bench_traversal_test.go:379: NextAll=234 -bench_traversal_test.go:379: NextAll=234 -bench_traversal_test.go:379: NextAll=234 -BenchmarkNextAllFiltered 50000 67428 ns/op ---- BENCH: BenchmarkNextAllFiltered -bench_traversal_test.go:395: NextAllFiltered=33 -bench_traversal_test.go:395: NextAllFiltered=33 -bench_traversal_test.go:395: NextAllFiltered=33 -bench_traversal_test.go:395: NextAllFiltered=33 -BenchmarkPrev 50000 32399 ns/op ---- BENCH: BenchmarkPrev -bench_traversal_test.go:411: Prev=49 -bench_traversal_test.go:411: Prev=49 -bench_traversal_test.go:411: Prev=49 -bench_traversal_test.go:411: Prev=49 -BenchmarkPrevFiltered 50000 34944 ns/op ---- BENCH: BenchmarkPrevFiltered -bench_traversal_test.go:429: PrevFiltered=7 -bench_traversal_test.go:429: PrevFiltered=7 -bench_traversal_test.go:429: PrevFiltered=7 -bench_traversal_test.go:429: PrevFiltered=7 -BenchmarkPrevAll 100000 29360 ns/op ---- BENCH: BenchmarkPrevAll -bench_traversal_test.go:445: PrevAll=78 -bench_traversal_test.go:445: PrevAll=78 -bench_traversal_test.go:445: PrevAll=78 -bench_traversal_test.go:445: PrevAll=78 -BenchmarkPrevAllFiltered 50000 32291 ns/op ---- BENCH: BenchmarkPrevAllFiltered -bench_traversal_test.go:461: PrevAllFiltered=6 -bench_traversal_test.go:461: PrevAllFiltered=6 -bench_traversal_test.go:461: PrevAllFiltered=6 -bench_traversal_test.go:461: PrevAllFiltered=6 -BenchmarkNextUntil 10000 191890 ns/op ---- BENCH: BenchmarkNextUntil -bench_traversal_test.go:477: NextUntil=84 -bench_traversal_test.go:477: NextUntil=84 -bench_traversal_test.go:477: NextUntil=84 -BenchmarkNextUntilSelection 20000 92054 ns/op ---- BENCH: BenchmarkNextUntilSelection -bench_traversal_test.go:494: NextUntilSelection=42 -bench_traversal_test.go:494: NextUntilSelection=42 -bench_traversal_test.go:494: NextUntilSelection=42 -bench_traversal_test.go:494: NextUntilSelection=42 -BenchmarkNextUntilNodes 50000 43401 ns/op ---- BENCH: BenchmarkNextUntilNodes -bench_traversal_test.go:512: NextUntilNodes=12 -bench_traversal_test.go:512: NextUntilNodes=12 -bench_traversal_test.go:512: NextUntilNodes=12 -bench_traversal_test.go:512: NextUntilNodes=12 -BenchmarkPrevUntil 5000 433383 ns/op ---- BENCH: BenchmarkPrevUntil -bench_traversal_test.go:528: PrevUntil=238 -bench_traversal_test.go:528: PrevUntil=238 -bench_traversal_test.go:528: PrevUntil=238 -BenchmarkPrevUntilSelection 10000 116423 ns/op ---- BENCH: BenchmarkPrevUntilSelection -bench_traversal_test.go:545: PrevUntilSelection=49 -bench_traversal_test.go:545: PrevUntilSelection=49 -bench_traversal_test.go:545: PrevUntilSelection=49 -BenchmarkPrevUntilNodes 50000 35338 ns/op ---- BENCH: BenchmarkPrevUntilNodes -bench_traversal_test.go:563: PrevUntilNodes=11 -bench_traversal_test.go:563: PrevUntilNodes=11 -bench_traversal_test.go:563: PrevUntilNodes=11 -bench_traversal_test.go:563: PrevUntilNodes=11 -BenchmarkNextFilteredUntil 10000 104686 ns/op ---- BENCH: BenchmarkNextFilteredUntil -bench_traversal_test.go:579: NextFilteredUntil=22 -bench_traversal_test.go:579: NextFilteredUntil=22 -bench_traversal_test.go:579: NextFilteredUntil=22 -BenchmarkNextFilteredUntilSelection 20000 99485 ns/op ---- BENCH: BenchmarkNextFilteredUntilSelection -bench_traversal_test.go:596: NextFilteredUntilSelection=22 -bench_traversal_test.go:596: NextFilteredUntilSelection=22 -bench_traversal_test.go:596: NextFilteredUntilSelection=22 -bench_traversal_test.go:596: NextFilteredUntilSelection=22 -BenchmarkNextFilteredUntilNodes 20000 99452 ns/op ---- BENCH: BenchmarkNextFilteredUntilNodes -bench_traversal_test.go:614: NextFilteredUntilNodes=22 -bench_traversal_test.go:614: NextFilteredUntilNodes=22 -bench_traversal_test.go:614: NextFilteredUntilNodes=22 -bench_traversal_test.go:614: NextFilteredUntilNodes=22 -BenchmarkPrevFilteredUntil 10000 112640 ns/op ---- BENCH: BenchmarkPrevFilteredUntil -bench_traversal_test.go:630: PrevFilteredUntil=20 -bench_traversal_test.go:630: PrevFilteredUntil=20 -bench_traversal_test.go:630: PrevFilteredUntil=20 -BenchmarkPrevFilteredUntilSelection 10000 103702 ns/op ---- BENCH: BenchmarkPrevFilteredUntilSelection -bench_traversal_test.go:647: PrevFilteredUntilSelection=20 -bench_traversal_test.go:647: PrevFilteredUntilSelection=20 -bench_traversal_test.go:647: PrevFilteredUntilSelection=20 -BenchmarkPrevFilteredUntilNodes 10000 103277 ns/op ---- BENCH: BenchmarkPrevFilteredUntilNodes -bench_traversal_test.go:665: PrevFilteredUntilNodes=20 -bench_traversal_test.go:665: PrevFilteredUntilNodes=20 -bench_traversal_test.go:665: PrevFilteredUntilNodes=20 -BenchmarkClosest 500000 6530 ns/op ---- BENCH: BenchmarkClosest -bench_traversal_test.go:681: Closest=2 -bench_traversal_test.go:681: Closest=2 -bench_traversal_test.go:681: Closest=2 -bench_traversal_test.go:681: Closest=2 -BenchmarkClosestSelection 1000000 1135 ns/op ---- BENCH: BenchmarkClosestSelection -bench_traversal_test.go:698: ClosestSelection=2 -bench_traversal_test.go:698: ClosestSelection=2 -bench_traversal_test.go:698: ClosestSelection=2 -bench_traversal_test.go:698: ClosestSelection=2 -BenchmarkClosestNodes 1000000 1133 ns/op ---- BENCH: BenchmarkClosestNodes -bench_traversal_test.go:715: ClosestNodes=2 -bench_traversal_test.go:715: ClosestNodes=2 -bench_traversal_test.go:715: ClosestNodes=2 -bench_traversal_test.go:715: ClosestNodes=2 -ok github.com/PuerkitoBio/goquery 192.541s diff --git a/vendor/github.com/PuerkitoBio/goquery/bench/v0.2.0-v0.2.1-go1.1rc1.svg b/vendor/github.com/PuerkitoBio/goquery/bench/v0.2.0-v0.2.1-go1.1rc1.svg deleted file mode 100644 index eaabc618b..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench/v0.2.0-v0.2.1-go1.1rc1.svg +++ /dev/null @@ -1,420 +0,0 @@ - - - - - - - - -+2.12% - -BenchmarkFirst - - -+1.06% - -BenchmarkLast - - -+3.63% - -BenchmarkEq - - -+2.67% - -BenchmarkSlice - - --24.26% - -BenchmarkGet - - --41.71% - -BenchmarkIndex - - --50.42% - -BenchmarkIndexSelector - - -+5.94% - -BenchmarkIndexOfNode - - -+8.26% - -BenchmarkIndexOfSelection - - --32.94% - -BenchmarkMetalReviewExample - - --56.84% - -BenchmarkAdd - - -+6.63% - -BenchmarkAddSelection - - -+9.42% - -BenchmarkAddNodes - - -+2.93% - -BenchmarkAndSelf - - --13.75% - -BenchmarkFilter - - --14.90% - -BenchmarkNot - - -+1.07% - -BenchmarkFilterFunction - - -+4.91% - -BenchmarkNotFunction - - -+1.03% - -BenchmarkFilterNodes - - -+4.22% - -BenchmarkNotNodes - - --1.00% - -BenchmarkFilterSelection - - -+4.00% - -BenchmarkNotSelection - - --32.12% - -BenchmarkHas - - -+1.59% - -BenchmarkHasNodes - - -+1.56% - -BenchmarkHasSelection - - -+15.54% - -BenchmarkEnd - - -+1.77% - -BenchmarkEach - - --3.61% - -BenchmarkMap - - --16.48% - -BenchmarkAttr - - -+1.33% - -BenchmarkText - - --59.21% - -BenchmarkLength - - --9.01% - -BenchmarkHtml - - --16.73% - -BenchmarkIs - - --25.08% - -BenchmarkIsPositional - - --11.55% - -BenchmarkIsFunction - - -+1.28% - -BenchmarkIsSelection - - -+2.10% - -BenchmarkIsNodes - - --15.99% - -BenchmarkHasClass - - --2.65% - -BenchmarkContains - - --48.54% - -BenchmarkFind - - --42.71% - -BenchmarkFindWithinSelection - - -+28.77% - -BenchmarkFindSelection - - -+28.47% - -BenchmarkFindNodes - - --62.84% - -BenchmarkContents - - --58.06% - -BenchmarkContentsFiltered - - --63.13% - -BenchmarkChildren - - --38.24% - -BenchmarkChildrenFiltered - - --3.66% - -BenchmarkParent - - --6.06% - -BenchmarkParentFiltered - - -+3.64% - -BenchmarkParents - - -+1.44% - -BenchmarkParentsFiltered - - --44.35% - -BenchmarkParentsUntil - - --31.99% - -BenchmarkParentsUntilSelection - - --32.62% - -BenchmarkParentsUntilNodes - - --45.83% - -BenchmarkParentsFilteredUntil - - --30.05% - -BenchmarkParentsFilteredUntilSelection - - --29.97% - -BenchmarkParentsFilteredUntilNodes - - --25.96% - -BenchmarkSiblings - - --26.67% - -BenchmarkSiblingsFiltered - - --66.40% - -BenchmarkNext - - --64.46% - -BenchmarkNextFiltered - - --26.50% - -BenchmarkNextAll - - --26.27% - -BenchmarkNextAllFiltered - - --66.84% - -BenchmarkPrev - - --64.35% - -BenchmarkPrevFiltered - - --40.05% - -BenchmarkPrevAll - - --39.74% - -BenchmarkPrevAllFiltered - - --51.73% - -BenchmarkNextUntil - - --33.42% - -BenchmarkNextUntilSelection - - --40.42% - -BenchmarkNextUntilNodes - - --46.87% - -BenchmarkPrevUntil - - --33.14% - -BenchmarkPrevUntilSelection - - --41.19% - -BenchmarkPrevUntilNodes - - --55.92% - -BenchmarkNextFilteredUntil - - --32.49% - -BenchmarkNextFilteredUntilSelection - - --33.00% - -BenchmarkNextFilteredUntilNodes - - --58.54% - -BenchmarkPrevFilteredUntil - - --33.80% - -BenchmarkPrevFilteredUntilSelection - - --33.44% - -BenchmarkPrevFilteredUntilNodes - - --24.82% - -BenchmarkClosest - - --34.45% - -BenchmarkClosestSelection - - --35.30% - -BenchmarkClosestNodes - - diff --git a/vendor/github.com/PuerkitoBio/goquery/bench/v0.2.1-go1.1rc1 b/vendor/github.com/PuerkitoBio/goquery/bench/v0.2.1-go1.1rc1 deleted file mode 100644 index 1f2a426d3..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench/v0.2.1-go1.1rc1 +++ /dev/null @@ -1,470 +0,0 @@ -PASS -BenchmarkFirst 20000000 96.3 ns/op -BenchmarkLast 20000000 95.7 ns/op -BenchmarkEq 20000000 97.1 ns/op -BenchmarkSlice 20000000 92.3 ns/op -BenchmarkGet 1000000000 2.06 ns/op -BenchmarkIndex 1000000 1069 ns/op ---- BENCH: BenchmarkIndex - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 -BenchmarkIndexSelector 100000 26750 ns/op ---- BENCH: BenchmarkIndexSelector - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 -BenchmarkIndexOfNode 100000000 10.7 ns/op ---- BENCH: BenchmarkIndexOfNode - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 -BenchmarkIndexOfSelection 100000000 11.8 ns/op ---- BENCH: BenchmarkIndexOfSelection - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 -BenchmarkMetalReviewExample 10000 219078 ns/op ---- BENCH: BenchmarkMetalReviewExample - bench_example_test.go:40: Review 0: Midnight - Complete and Total Hell (8.5). - Review 1: Over Your Threshold - Facticity (6.0). - Review 2: Nuclear Death Terror - Chaos Reigns (7.5). - Review 3: Evoken - Atra Mors (9.5). - - bench_example_test.go:41: MetalReviewExample=10 - bench_example_test.go:40: Review 0: Midnight - Complete and Total Hell (8.5). - Review 1: Over Your Threshold - Facticity (6.0). - Review 2: Nuclear Death Terror - Chaos Reigns (7.5). - Review 3: Evoken - Atra Mors (9.5). - ... [output truncated] -BenchmarkAdd 100000 22345 ns/op ---- BENCH: BenchmarkAdd - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 -BenchmarkAddSelection 10000000 209 ns/op ---- BENCH: BenchmarkAddSelection - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 -BenchmarkAddNodes 10000000 209 ns/op ---- BENCH: BenchmarkAddNodes - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 -BenchmarkAndSelf 1000000 2568 ns/op ---- BENCH: BenchmarkAndSelf - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 -BenchmarkFilter 100000 26715 ns/op ---- BENCH: BenchmarkFilter - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 -BenchmarkNot 50000 30058 ns/op ---- BENCH: BenchmarkNot - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 -BenchmarkFilterFunction 50000 66346 ns/op ---- BENCH: BenchmarkFilterFunction - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 -BenchmarkNotFunction 50000 72646 ns/op ---- BENCH: BenchmarkNotFunction - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 -BenchmarkFilterNodes 50000 65493 ns/op ---- BENCH: BenchmarkFilterNodes - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 -BenchmarkNotNodes 20000 79466 ns/op ---- BENCH: BenchmarkNotNodes - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 -BenchmarkFilterSelection 50000 65494 ns/op ---- BENCH: BenchmarkFilterSelection - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 -BenchmarkNotSelection 20000 79387 ns/op ---- BENCH: BenchmarkNotSelection - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 -BenchmarkHas 5000 386571 ns/op ---- BENCH: BenchmarkHas - bench_filter_test.go:160: Has=13 - bench_filter_test.go:160: Has=13 - bench_filter_test.go:160: Has=13 -BenchmarkHasNodes 10000 230664 ns/op ---- BENCH: BenchmarkHasNodes - bench_filter_test.go:178: HasNodes=15 - bench_filter_test.go:178: HasNodes=15 - bench_filter_test.go:178: HasNodes=15 -BenchmarkHasSelection 10000 230705 ns/op ---- BENCH: BenchmarkHasSelection - bench_filter_test.go:195: HasSelection=15 - bench_filter_test.go:195: HasSelection=15 - bench_filter_test.go:195: HasSelection=15 -BenchmarkEnd 500000000 4.61 ns/op ---- BENCH: BenchmarkEnd - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 -BenchmarkEach 200000 9520 ns/op ---- BENCH: BenchmarkEach - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 -BenchmarkMap 100000 15960 ns/op ---- BENCH: BenchmarkMap - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 -BenchmarkAttr 50000000 30.4 ns/op ---- BENCH: BenchmarkAttr - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading -BenchmarkText 100000 18718 ns/op -BenchmarkLength 2000000000 0.31 ns/op ---- BENCH: BenchmarkLength - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 -BenchmarkHtml 5000000 606 ns/op -BenchmarkIs 100000 29289 ns/op ---- BENCH: BenchmarkIs - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true -BenchmarkIsPositional 100000 23834 ns/op ---- BENCH: BenchmarkIsPositional - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true -BenchmarkIsFunction 1000000 2436 ns/op ---- BENCH: BenchmarkIsFunction - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true -BenchmarkIsSelection 50000 67106 ns/op ---- BENCH: BenchmarkIsSelection - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true -BenchmarkIsNodes 50000 66042 ns/op ---- BENCH: BenchmarkIsNodes - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true -BenchmarkHasClass 5000 565347 ns/op ---- BENCH: BenchmarkHasClass - bench_query_test.go:82: HasClass=true - bench_query_test.go:82: HasClass=true - bench_query_test.go:82: HasClass=true -BenchmarkContains 100000000 11.0 ns/op ---- BENCH: BenchmarkContains - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true -BenchmarkFind 100000 27677 ns/op ---- BENCH: BenchmarkFind - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 -BenchmarkFindWithinSelection 50000 72162 ns/op ---- BENCH: BenchmarkFindWithinSelection - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 -BenchmarkFindSelection 5000 460124 ns/op ---- BENCH: BenchmarkFindSelection - bench_traversal_test.go:51: FindSelection=73 - bench_traversal_test.go:51: FindSelection=73 - bench_traversal_test.go:51: FindSelection=73 -BenchmarkFindNodes 5000 459390 ns/op ---- BENCH: BenchmarkFindNodes - bench_traversal_test.go:69: FindNodes=73 - bench_traversal_test.go:69: FindNodes=73 - bench_traversal_test.go:69: FindNodes=73 -BenchmarkContents 500000 3395 ns/op ---- BENCH: BenchmarkContents - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 -BenchmarkContentsFiltered 500000 5193 ns/op ---- BENCH: BenchmarkContentsFiltered - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 -BenchmarkChildren 5000000 667 ns/op ---- BENCH: BenchmarkChildren - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 -BenchmarkChildrenFiltered 500000 3591 ns/op ---- BENCH: BenchmarkChildrenFiltered - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 -BenchmarkParent 50000 43168 ns/op ---- BENCH: BenchmarkParent - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 -BenchmarkParentFiltered 50000 45836 ns/op ---- BENCH: BenchmarkParentFiltered - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 -BenchmarkParents 20000 92348 ns/op ---- BENCH: BenchmarkParents - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 -BenchmarkParentsFiltered 20000 95306 ns/op ---- BENCH: BenchmarkParentsFiltered - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 -BenchmarkParentsUntil 50000 72782 ns/op ---- BENCH: BenchmarkParentsUntil - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 -BenchmarkParentsUntilSelection 10000 157639 ns/op ---- BENCH: BenchmarkParentsUntilSelection - bench_traversal_test.go:230: ParentsUntilSelection=70 - bench_traversal_test.go:230: ParentsUntilSelection=70 - bench_traversal_test.go:230: ParentsUntilSelection=70 -BenchmarkParentsUntilNodes 10000 157510 ns/op ---- BENCH: BenchmarkParentsUntilNodes - bench_traversal_test.go:248: ParentsUntilNodes=70 - bench_traversal_test.go:248: ParentsUntilNodes=70 - bench_traversal_test.go:248: ParentsUntilNodes=70 -BenchmarkParentsFilteredUntil 100000 16987 ns/op ---- BENCH: BenchmarkParentsFilteredUntil - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 -BenchmarkParentsFilteredUntilSelection 100000 21174 ns/op ---- BENCH: BenchmarkParentsFilteredUntilSelection - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 -BenchmarkParentsFilteredUntilNodes 100000 21238 ns/op ---- BENCH: BenchmarkParentsFilteredUntilNodes - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 -BenchmarkSiblings 50000 66536 ns/op ---- BENCH: BenchmarkSiblings - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 -BenchmarkSiblingsFiltered 50000 71822 ns/op ---- BENCH: BenchmarkSiblingsFiltered - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 -BenchmarkNext 200000 10745 ns/op ---- BENCH: BenchmarkNext - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 -BenchmarkNextFiltered 200000 12399 ns/op ---- BENCH: BenchmarkNextFiltered - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 -BenchmarkNextAll 50000 44640 ns/op ---- BENCH: BenchmarkNextAll - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 -BenchmarkNextAllFiltered 50000 49713 ns/op ---- BENCH: BenchmarkNextAllFiltered - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 -BenchmarkPrev 200000 10743 ns/op ---- BENCH: BenchmarkPrev - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 -BenchmarkPrevFiltered 200000 12456 ns/op ---- BENCH: BenchmarkPrevFiltered - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 -BenchmarkPrevAll 100000 17600 ns/op ---- BENCH: BenchmarkPrevAll - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 -BenchmarkPrevAllFiltered 100000 19460 ns/op ---- BENCH: BenchmarkPrevAllFiltered - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 -BenchmarkNextUntil 20000 92630 ns/op ---- BENCH: BenchmarkNextUntil - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 -BenchmarkNextUntilSelection 50000 61285 ns/op ---- BENCH: BenchmarkNextUntilSelection - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 -BenchmarkNextUntilNodes 100000 25859 ns/op ---- BENCH: BenchmarkNextUntilNodes - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 -BenchmarkPrevUntil 10000 230236 ns/op ---- BENCH: BenchmarkPrevUntil - bench_traversal_test.go:528: PrevUntil=238 - bench_traversal_test.go:528: PrevUntil=238 - bench_traversal_test.go:528: PrevUntil=238 -BenchmarkPrevUntilSelection 20000 77837 ns/op ---- BENCH: BenchmarkPrevUntilSelection - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 -BenchmarkPrevUntilNodes 100000 20784 ns/op ---- BENCH: BenchmarkPrevUntilNodes - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 -BenchmarkNextFilteredUntil 50000 46147 ns/op ---- BENCH: BenchmarkNextFilteredUntil - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 -BenchmarkNextFilteredUntilSelection 50000 67164 ns/op ---- BENCH: BenchmarkNextFilteredUntilSelection - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 -BenchmarkNextFilteredUntilNodes 50000 66628 ns/op ---- BENCH: BenchmarkNextFilteredUntilNodes - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 -BenchmarkPrevFilteredUntil 50000 46697 ns/op ---- BENCH: BenchmarkPrevFilteredUntil - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 -BenchmarkPrevFilteredUntilSelection 50000 68646 ns/op ---- BENCH: BenchmarkPrevFilteredUntilSelection - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 -BenchmarkPrevFilteredUntilNodes 50000 68745 ns/op ---- BENCH: BenchmarkPrevFilteredUntilNodes - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 -BenchmarkClosest 500000 4909 ns/op ---- BENCH: BenchmarkClosest - bench_traversal_test.go:681: Closest=2 - bench_traversal_test.go:681: Closest=2 - bench_traversal_test.go:681: Closest=2 - bench_traversal_test.go:681: Closest=2 -BenchmarkClosestSelection 5000000 744 ns/op ---- BENCH: BenchmarkClosestSelection - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 -BenchmarkClosestNodes 5000000 733 ns/op ---- BENCH: BenchmarkClosestNodes - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 -ok github.com/PuerkitoBio/goquery 220.793s diff --git a/vendor/github.com/PuerkitoBio/goquery/bench/v0.3.0 b/vendor/github.com/PuerkitoBio/goquery/bench/v0.3.0 deleted file mode 100644 index 037c9a9d2..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench/v0.3.0 +++ /dev/null @@ -1,476 +0,0 @@ -PASS -BenchmarkFirst 20000000 95.5 ns/op -BenchmarkLast 20000000 94.9 ns/op -BenchmarkEq 20000000 95.7 ns/op -BenchmarkSlice 20000000 91.7 ns/op -BenchmarkGet 1000000000 2.05 ns/op -BenchmarkIndex 1000000 1079 ns/op ---- BENCH: BenchmarkIndex - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 -BenchmarkIndexSelector 100000 26972 ns/op ---- BENCH: BenchmarkIndexSelector - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 -BenchmarkIndexOfNode 100000000 10.8 ns/op ---- BENCH: BenchmarkIndexOfNode - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 -BenchmarkIndexOfSelection 100000000 11.7 ns/op ---- BENCH: BenchmarkIndexOfSelection - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 -BenchmarkMetalReviewExample 10000 213800 ns/op ---- BENCH: BenchmarkMetalReviewExample - bench_example_test.go:40: Review 0: Midnight - Complete and Total Hell (8.5). - Review 1: Over Your Threshold - Facticity (6.0). - Review 2: Nuclear Death Terror - Chaos Reigns (7.5). - Review 3: Evoken - Atra Mors (9.5). - - bench_example_test.go:41: MetalReviewExample=10 - bench_example_test.go:40: Review 0: Midnight - Complete and Total Hell (8.5). - Review 1: Over Your Threshold - Facticity (6.0). - Review 2: Nuclear Death Terror - Chaos Reigns (7.5). - Review 3: Evoken - Atra Mors (9.5). - ... [output truncated] -BenchmarkAdd 100000 21811 ns/op ---- BENCH: BenchmarkAdd - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 -BenchmarkAddSelection 10000000 205 ns/op ---- BENCH: BenchmarkAddSelection - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 -BenchmarkAddNodes 10000000 202 ns/op ---- BENCH: BenchmarkAddNodes - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 -BenchmarkAndSelf 1000000 2467 ns/op ---- BENCH: BenchmarkAndSelf - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 -BenchmarkFilter 100000 25643 ns/op ---- BENCH: BenchmarkFilter - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 -BenchmarkNot 100000 29566 ns/op ---- BENCH: BenchmarkNot - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 -BenchmarkFilterFunction 50000 66894 ns/op ---- BENCH: BenchmarkFilterFunction - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 -BenchmarkNotFunction 50000 72183 ns/op ---- BENCH: BenchmarkNotFunction - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 -BenchmarkFilterNodes 50000 65516 ns/op ---- BENCH: BenchmarkFilterNodes - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 -BenchmarkNotNodes 20000 78880 ns/op ---- BENCH: BenchmarkNotNodes - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 -BenchmarkFilterSelection 50000 65232 ns/op ---- BENCH: BenchmarkFilterSelection - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 -BenchmarkNotSelection 20000 78813 ns/op ---- BENCH: BenchmarkNotSelection - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 -BenchmarkHas 5000 388834 ns/op ---- BENCH: BenchmarkHas - bench_filter_test.go:160: Has=13 - bench_filter_test.go:160: Has=13 - bench_filter_test.go:160: Has=13 -BenchmarkHasNodes 10000 228552 ns/op ---- BENCH: BenchmarkHasNodes - bench_filter_test.go:178: HasNodes=15 - bench_filter_test.go:178: HasNodes=15 - bench_filter_test.go:178: HasNodes=15 -BenchmarkHasSelection 10000 228365 ns/op ---- BENCH: BenchmarkHasSelection - bench_filter_test.go:195: HasSelection=15 - bench_filter_test.go:195: HasSelection=15 - bench_filter_test.go:195: HasSelection=15 -BenchmarkEnd 500000000 4.62 ns/op ---- BENCH: BenchmarkEnd - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 -BenchmarkEach 200000 9548 ns/op ---- BENCH: BenchmarkEach - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 -BenchmarkMap 100000 15900 ns/op ---- BENCH: BenchmarkMap - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 -BenchmarkEachWithBreak 1000000 1650 ns/op ---- BENCH: BenchmarkEachWithBreak - bench_iteration_test.go:61: Each=10 - bench_iteration_test.go:61: Each=10 - bench_iteration_test.go:61: Each=10 - bench_iteration_test.go:61: Each=10 -BenchmarkAttr 50000000 30.5 ns/op ---- BENCH: BenchmarkAttr - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading -BenchmarkText 100000 18873 ns/op -BenchmarkLength 2000000000 0.31 ns/op ---- BENCH: BenchmarkLength - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 -BenchmarkHtml 5000000 616 ns/op -BenchmarkIs 100000 29499 ns/op ---- BENCH: BenchmarkIs - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true -BenchmarkIsPositional 100000 23733 ns/op ---- BENCH: BenchmarkIsPositional - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true -BenchmarkIsFunction 1000000 2404 ns/op ---- BENCH: BenchmarkIsFunction - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true -BenchmarkIsSelection 50000 65376 ns/op ---- BENCH: BenchmarkIsSelection - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true -BenchmarkIsNodes 50000 65322 ns/op ---- BENCH: BenchmarkIsNodes - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true -BenchmarkHasClass 5000 558933 ns/op ---- BENCH: BenchmarkHasClass - bench_query_test.go:82: HasClass=true - bench_query_test.go:82: HasClass=true - bench_query_test.go:82: HasClass=true -BenchmarkContains 100000000 11.1 ns/op ---- BENCH: BenchmarkContains - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true -BenchmarkFind 100000 27841 ns/op ---- BENCH: BenchmarkFind - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 -BenchmarkFindWithinSelection 50000 72096 ns/op ---- BENCH: BenchmarkFindWithinSelection - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 -BenchmarkFindSelection 5000 457349 ns/op ---- BENCH: BenchmarkFindSelection - bench_traversal_test.go:51: FindSelection=73 - bench_traversal_test.go:51: FindSelection=73 - bench_traversal_test.go:51: FindSelection=73 -BenchmarkFindNodes 5000 459324 ns/op ---- BENCH: BenchmarkFindNodes - bench_traversal_test.go:69: FindNodes=73 - bench_traversal_test.go:69: FindNodes=73 - bench_traversal_test.go:69: FindNodes=73 -BenchmarkContents 500000 3435 ns/op ---- BENCH: BenchmarkContents - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 -BenchmarkContentsFiltered 500000 5241 ns/op ---- BENCH: BenchmarkContentsFiltered - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 -BenchmarkChildren 5000000 667 ns/op ---- BENCH: BenchmarkChildren - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 -BenchmarkChildrenFiltered 500000 3639 ns/op ---- BENCH: BenchmarkChildrenFiltered - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 -BenchmarkParent 50000 44867 ns/op ---- BENCH: BenchmarkParent - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 -BenchmarkParentFiltered 50000 46476 ns/op ---- BENCH: BenchmarkParentFiltered - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 -BenchmarkParents 20000 92559 ns/op ---- BENCH: BenchmarkParents - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 -BenchmarkParentsFiltered 20000 96142 ns/op ---- BENCH: BenchmarkParentsFiltered - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 -BenchmarkParentsUntil 50000 73931 ns/op ---- BENCH: BenchmarkParentsUntil - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 -BenchmarkParentsUntilSelection 10000 159820 ns/op ---- BENCH: BenchmarkParentsUntilSelection - bench_traversal_test.go:230: ParentsUntilSelection=70 - bench_traversal_test.go:230: ParentsUntilSelection=70 - bench_traversal_test.go:230: ParentsUntilSelection=70 -BenchmarkParentsUntilNodes 10000 158811 ns/op ---- BENCH: BenchmarkParentsUntilNodes - bench_traversal_test.go:248: ParentsUntilNodes=70 - bench_traversal_test.go:248: ParentsUntilNodes=70 - bench_traversal_test.go:248: ParentsUntilNodes=70 -BenchmarkParentsFilteredUntil 100000 17203 ns/op ---- BENCH: BenchmarkParentsFilteredUntil - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 -BenchmarkParentsFilteredUntilSelection 100000 21358 ns/op ---- BENCH: BenchmarkParentsFilteredUntilSelection - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 -BenchmarkParentsFilteredUntilNodes 100000 21338 ns/op ---- BENCH: BenchmarkParentsFilteredUntilNodes - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 -BenchmarkSiblings 50000 66463 ns/op ---- BENCH: BenchmarkSiblings - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 -BenchmarkSiblingsFiltered 50000 72503 ns/op ---- BENCH: BenchmarkSiblingsFiltered - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 -BenchmarkNext 200000 10881 ns/op ---- BENCH: BenchmarkNext - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 -BenchmarkNextFiltered 200000 12588 ns/op ---- BENCH: BenchmarkNextFiltered - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 -BenchmarkNextAll 50000 45075 ns/op ---- BENCH: BenchmarkNextAll - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 -BenchmarkNextAllFiltered 50000 50455 ns/op ---- BENCH: BenchmarkNextAllFiltered - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 -BenchmarkPrev 200000 10933 ns/op ---- BENCH: BenchmarkPrev - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 -BenchmarkPrevFiltered 200000 12579 ns/op ---- BENCH: BenchmarkPrevFiltered - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 -BenchmarkPrevAll 100000 17751 ns/op ---- BENCH: BenchmarkPrevAll - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 -BenchmarkPrevAllFiltered 100000 19702 ns/op ---- BENCH: BenchmarkPrevAllFiltered - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 -BenchmarkNextUntil 20000 93586 ns/op ---- BENCH: BenchmarkNextUntil - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 -BenchmarkNextUntilSelection 50000 61155 ns/op ---- BENCH: BenchmarkNextUntilSelection - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 -BenchmarkNextUntilNodes 100000 25805 ns/op ---- BENCH: BenchmarkNextUntilNodes - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 -BenchmarkPrevUntil 10000 232225 ns/op ---- BENCH: BenchmarkPrevUntil - bench_traversal_test.go:528: PrevUntil=238 - bench_traversal_test.go:528: PrevUntil=238 - bench_traversal_test.go:528: PrevUntil=238 -BenchmarkPrevUntilSelection 20000 78316 ns/op ---- BENCH: BenchmarkPrevUntilSelection - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 -BenchmarkPrevUntilNodes 100000 20657 ns/op ---- BENCH: BenchmarkPrevUntilNodes - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 -BenchmarkNextFilteredUntil 50000 46567 ns/op ---- BENCH: BenchmarkNextFilteredUntil - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 -BenchmarkNextFilteredUntilSelection 50000 67227 ns/op ---- BENCH: BenchmarkNextFilteredUntilSelection - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 -BenchmarkNextFilteredUntilNodes 50000 66995 ns/op ---- BENCH: BenchmarkNextFilteredUntilNodes - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 -BenchmarkPrevFilteredUntil 50000 47361 ns/op ---- BENCH: BenchmarkPrevFilteredUntil - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 -BenchmarkPrevFilteredUntilSelection 50000 68802 ns/op ---- BENCH: BenchmarkPrevFilteredUntilSelection - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 -BenchmarkPrevFilteredUntilNodes 50000 68928 ns/op ---- BENCH: BenchmarkPrevFilteredUntilNodes - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 -BenchmarkClosest 500000 4922 ns/op ---- BENCH: BenchmarkClosest - bench_traversal_test.go:681: Closest=2 - bench_traversal_test.go:681: Closest=2 - bench_traversal_test.go:681: Closest=2 - bench_traversal_test.go:681: Closest=2 -BenchmarkClosestSelection 5000000 738 ns/op ---- BENCH: BenchmarkClosestSelection - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 -BenchmarkClosestNodes 5000000 737 ns/op ---- BENCH: BenchmarkClosestNodes - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 -ok github.com/PuerkitoBio/goquery 224.003s diff --git a/vendor/github.com/PuerkitoBio/goquery/bench/v0.3.2-go1.2 b/vendor/github.com/PuerkitoBio/goquery/bench/v0.3.2-go1.2 deleted file mode 100644 index 0a8704c86..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench/v0.3.2-go1.2 +++ /dev/null @@ -1,478 +0,0 @@ -PASS -BenchmarkFirst 20000000 88.4 ns/op -BenchmarkLast 20000000 88.2 ns/op -BenchmarkEq 20000000 87.4 ns/op -BenchmarkSlice 20000000 84.9 ns/op -BenchmarkGet 2000000000 1.99 ns/op -BenchmarkIndex 2000000 906 ns/op ---- BENCH: BenchmarkIndex - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 -BenchmarkIndexSelector 100000 22276 ns/op ---- BENCH: BenchmarkIndexSelector - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 -BenchmarkIndexOfNode 200000000 9.72 ns/op ---- BENCH: BenchmarkIndexOfNode - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 -BenchmarkIndexOfSelection 100000000 10.4 ns/op ---- BENCH: BenchmarkIndexOfSelection - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 -BenchmarkMetalReviewExample 10000 199277 ns/op ---- BENCH: BenchmarkMetalReviewExample - bench_example_test.go:40: Review 0: Midnight - Complete and Total Hell (8.5). - Review 1: Over Your Threshold - Facticity (6.0). - Review 2: Nuclear Death Terror - Chaos Reigns (7.5). - Review 3: Evoken - Atra Mors (9.5). - - bench_example_test.go:41: MetalReviewExample=10 - bench_example_test.go:40: Review 0: Midnight - Complete and Total Hell (8.5). - Review 1: Over Your Threshold - Facticity (6.0). - Review 2: Nuclear Death Terror - Chaos Reigns (7.5). - Review 3: Evoken - Atra Mors (9.5). - ... [output truncated] -BenchmarkAdd 100000 18277 ns/op ---- BENCH: BenchmarkAdd - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 -BenchmarkAddSelection 10000000 200 ns/op ---- BENCH: BenchmarkAddSelection - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 -BenchmarkAddNodes 10000000 189 ns/op ---- BENCH: BenchmarkAddNodes - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 -BenchmarkAndSelf 1000000 2569 ns/op ---- BENCH: BenchmarkAndSelf - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 -BenchmarkFilter 100000 25195 ns/op ---- BENCH: BenchmarkFilter - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 -BenchmarkNot 100000 29003 ns/op ---- BENCH: BenchmarkNot - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 -BenchmarkFilterFunction 50000 60690 ns/op ---- BENCH: BenchmarkFilterFunction - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 -BenchmarkNotFunction 50000 66008 ns/op ---- BENCH: BenchmarkNotFunction - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 -BenchmarkFilterNodes 50000 59723 ns/op ---- BENCH: BenchmarkFilterNodes - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 -BenchmarkNotNodes 50000 72698 ns/op ---- BENCH: BenchmarkNotNodes - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 -BenchmarkFilterSelection 50000 59598 ns/op ---- BENCH: BenchmarkFilterSelection - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 -BenchmarkNotSelection 50000 72526 ns/op ---- BENCH: BenchmarkNotSelection - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 -BenchmarkHas 5000 367076 ns/op ---- BENCH: BenchmarkHas - bench_filter_test.go:160: Has=13 - bench_filter_test.go:160: Has=13 - bench_filter_test.go:160: Has=13 -BenchmarkHasNodes 10000 219710 ns/op ---- BENCH: BenchmarkHasNodes - bench_filter_test.go:178: HasNodes=15 - bench_filter_test.go:178: HasNodes=15 - bench_filter_test.go:178: HasNodes=15 -BenchmarkHasSelection 10000 219105 ns/op ---- BENCH: BenchmarkHasSelection - bench_filter_test.go:195: HasSelection=15 - bench_filter_test.go:195: HasSelection=15 - bench_filter_test.go:195: HasSelection=15 -BenchmarkEnd 500000000 4.58 ns/op ---- BENCH: BenchmarkEnd - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 -BenchmarkEach 200000 8615 ns/op ---- BENCH: BenchmarkEach - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 -BenchmarkMap 200000 14271 ns/op ---- BENCH: BenchmarkMap - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 -BenchmarkEachWithBreak 1000000 1497 ns/op ---- BENCH: BenchmarkEachWithBreak - bench_iteration_test.go:61: Each=10 - bench_iteration_test.go:61: Each=10 - bench_iteration_test.go:61: Each=10 - bench_iteration_test.go:61: Each=10 -BenchmarkAttr 50000000 30.9 ns/op ---- BENCH: BenchmarkAttr - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading -BenchmarkText 200000 13729 ns/op -BenchmarkLength 2000000000 0.31 ns/op ---- BENCH: BenchmarkLength - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 -BenchmarkHtml 5000000 537 ns/op -BenchmarkIs 100000 28904 ns/op ---- BENCH: BenchmarkIs - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true -BenchmarkIsPositional 100000 23556 ns/op ---- BENCH: BenchmarkIsPositional - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true -BenchmarkIsFunction 1000000 2195 ns/op ---- BENCH: BenchmarkIsFunction - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true -BenchmarkIsSelection 50000 60100 ns/op ---- BENCH: BenchmarkIsSelection - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true -BenchmarkIsNodes 50000 59962 ns/op ---- BENCH: BenchmarkIsNodes - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true -BenchmarkHasClass 5000 388679 ns/op ---- BENCH: BenchmarkHasClass - bench_query_test.go:82: HasClass=true - bench_query_test.go:82: HasClass=true - bench_query_test.go:82: HasClass=true -BenchmarkContains 100000000 11.0 ns/op ---- BENCH: BenchmarkContains - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true -BenchmarkFind 100000 22779 ns/op ---- BENCH: BenchmarkFind - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 -BenchmarkFindWithinSelection 50000 62033 ns/op ---- BENCH: BenchmarkFindWithinSelection - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 -BenchmarkFindSelection 5000 446918 ns/op ---- BENCH: BenchmarkFindSelection - bench_traversal_test.go:51: FindSelection=73 - bench_traversal_test.go:51: FindSelection=73 - bench_traversal_test.go:51: FindSelection=73 -BenchmarkFindNodes 5000 441753 ns/op ---- BENCH: BenchmarkFindNodes - bench_traversal_test.go:69: FindNodes=73 - bench_traversal_test.go:69: FindNodes=73 - bench_traversal_test.go:69: FindNodes=73 -BenchmarkContents 1000000 2807 ns/op ---- BENCH: BenchmarkContents - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 -BenchmarkContentsFiltered 500000 4477 ns/op ---- BENCH: BenchmarkContentsFiltered - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 -BenchmarkChildren 5000000 548 ns/op ---- BENCH: BenchmarkChildren - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 -BenchmarkChildrenFiltered 500000 3304 ns/op ---- BENCH: BenchmarkChildrenFiltered - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 -BenchmarkParent 50000 38248 ns/op ---- BENCH: BenchmarkParent - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 -BenchmarkParentFiltered 50000 40677 ns/op ---- BENCH: BenchmarkParentFiltered - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 -BenchmarkParents 20000 83043 ns/op ---- BENCH: BenchmarkParents - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 -BenchmarkParentsFiltered 20000 85391 ns/op ---- BENCH: BenchmarkParentsFiltered - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 -BenchmarkParentsUntil 50000 65118 ns/op ---- BENCH: BenchmarkParentsUntil - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 -BenchmarkParentsUntilSelection 10000 144028 ns/op ---- BENCH: BenchmarkParentsUntilSelection - bench_traversal_test.go:230: ParentsUntilSelection=70 - bench_traversal_test.go:230: ParentsUntilSelection=70 - bench_traversal_test.go:230: ParentsUntilSelection=70 -BenchmarkParentsUntilNodes 10000 146713 ns/op ---- BENCH: BenchmarkParentsUntilNodes - bench_traversal_test.go:248: ParentsUntilNodes=70 - bench_traversal_test.go:248: ParentsUntilNodes=70 - bench_traversal_test.go:248: ParentsUntilNodes=70 -BenchmarkParentsFilteredUntil 100000 15113 ns/op ---- BENCH: BenchmarkParentsFilteredUntil - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 -BenchmarkParentsFilteredUntilSelection 100000 18881 ns/op ---- BENCH: BenchmarkParentsFilteredUntilSelection - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 -BenchmarkParentsFilteredUntilNodes 100000 18926 ns/op ---- BENCH: BenchmarkParentsFilteredUntilNodes - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 -BenchmarkSiblings 50000 63221 ns/op ---- BENCH: BenchmarkSiblings - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 -BenchmarkSiblingsFiltered 50000 69028 ns/op ---- BENCH: BenchmarkSiblingsFiltered - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 -BenchmarkNext 200000 9133 ns/op ---- BENCH: BenchmarkNext - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 -BenchmarkNextFiltered 200000 10601 ns/op ---- BENCH: BenchmarkNextFiltered - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 -BenchmarkNextAll 50000 43089 ns/op ---- BENCH: BenchmarkNextAll - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 -BenchmarkNextAllFiltered 50000 47867 ns/op ---- BENCH: BenchmarkNextAllFiltered - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 -BenchmarkPrev 200000 9104 ns/op ---- BENCH: BenchmarkPrev - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 -BenchmarkPrevFiltered 200000 10579 ns/op ---- BENCH: BenchmarkPrevFiltered - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 -BenchmarkPrevAll 100000 15185 ns/op ---- BENCH: BenchmarkPrevAll - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 -BenchmarkPrevAllFiltered 100000 17108 ns/op ---- BENCH: BenchmarkPrevAllFiltered - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 -BenchmarkNextUntil 20000 81087 ns/op ---- BENCH: BenchmarkNextUntil - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 -BenchmarkNextUntilSelection 50000 55831 ns/op ---- BENCH: BenchmarkNextUntilSelection - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 -BenchmarkNextUntilNodes 100000 23130 ns/op ---- BENCH: BenchmarkNextUntilNodes - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 -BenchmarkPrevUntil 10000 204673 ns/op ---- BENCH: BenchmarkPrevUntil - bench_traversal_test.go:528: PrevUntil=238 - bench_traversal_test.go:528: PrevUntil=238 - bench_traversal_test.go:528: PrevUntil=238 -BenchmarkPrevUntilSelection 50000 70965 ns/op ---- BENCH: BenchmarkPrevUntilSelection - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 -BenchmarkPrevUntilNodes 100000 18591 ns/op ---- BENCH: BenchmarkPrevUntilNodes - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 -BenchmarkNextFilteredUntil 50000 42004 ns/op ---- BENCH: BenchmarkNextFilteredUntil - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 -BenchmarkNextFilteredUntilSelection 50000 61953 ns/op ---- BENCH: BenchmarkNextFilteredUntilSelection - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 -BenchmarkNextFilteredUntilNodes 50000 62124 ns/op ---- BENCH: BenchmarkNextFilteredUntilNodes - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 -BenchmarkPrevFilteredUntil 50000 42861 ns/op ---- BENCH: BenchmarkPrevFilteredUntil - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 -BenchmarkPrevFilteredUntilSelection 50000 62451 ns/op ---- BENCH: BenchmarkPrevFilteredUntilSelection - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 -BenchmarkPrevFilteredUntilNodes 50000 62631 ns/op ---- BENCH: BenchmarkPrevFilteredUntilNodes - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 -BenchmarkClosest 500000 4684 ns/op ---- BENCH: BenchmarkClosest - bench_traversal_test.go:681: Closest=2 - bench_traversal_test.go:681: Closest=2 - bench_traversal_test.go:681: Closest=2 - bench_traversal_test.go:681: Closest=2 -BenchmarkClosestSelection 5000000 622 ns/op ---- BENCH: BenchmarkClosestSelection - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 -BenchmarkClosestNodes 5000000 617 ns/op ---- BENCH: BenchmarkClosestNodes - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 -ok github.com/PuerkitoBio/goquery 218.724s diff --git a/vendor/github.com/PuerkitoBio/goquery/bench/v0.3.2-go1.2-take2 b/vendor/github.com/PuerkitoBio/goquery/bench/v0.3.2-go1.2-take2 deleted file mode 100644 index 02a811874..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench/v0.3.2-go1.2-take2 +++ /dev/null @@ -1,477 +0,0 @@ -PASS -BenchmarkFirst 20000000 88.3 ns/op -BenchmarkLast 20000000 88.9 ns/op -BenchmarkEq 20000000 86.7 ns/op -BenchmarkSlice 20000000 84.1 ns/op -BenchmarkGet 2000000000 1.99 ns/op -BenchmarkIndex 2000000 907 ns/op ---- BENCH: BenchmarkIndex - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 -BenchmarkIndexSelector 200000 13052 ns/op ---- BENCH: BenchmarkIndexSelector - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 -BenchmarkIndexOfNode 100000000 10.5 ns/op ---- BENCH: BenchmarkIndexOfNode - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 -BenchmarkIndexOfSelection 100000000 11.6 ns/op ---- BENCH: BenchmarkIndexOfSelection - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 -BenchmarkMetalReviewExample 10000 189556 ns/op ---- BENCH: BenchmarkMetalReviewExample - bench_example_test.go:40: Review 0: Midnight - Complete and Total Hell (8.5). - Review 1: Over Your Threshold - Facticity (6.0). - Review 2: Nuclear Death Terror - Chaos Reigns (7.5). - Review 3: Evoken - Atra Mors (9.5). - - bench_example_test.go:41: MetalReviewExample=10 - bench_example_test.go:40: Review 0: Midnight - Complete and Total Hell (8.5). - Review 1: Over Your Threshold - Facticity (6.0). - Review 2: Nuclear Death Terror - Chaos Reigns (7.5). - Review 3: Evoken - Atra Mors (9.5). - ... [output truncated] -BenchmarkAdd 200000 13714 ns/op ---- BENCH: BenchmarkAdd - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 -BenchmarkAddSelection 10000000 200 ns/op ---- BENCH: BenchmarkAddSelection - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 -BenchmarkAddNodes 10000000 186 ns/op ---- BENCH: BenchmarkAddNodes - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 -BenchmarkAndSelf 1000000 2532 ns/op ---- BENCH: BenchmarkAndSelf - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 -BenchmarkFilter 100000 25199 ns/op ---- BENCH: BenchmarkFilter - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 -BenchmarkNot 100000 29162 ns/op ---- BENCH: BenchmarkNot - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 -BenchmarkFilterFunction 50000 60733 ns/op ---- BENCH: BenchmarkFilterFunction - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 -BenchmarkNotFunction 50000 66124 ns/op ---- BENCH: BenchmarkNotFunction - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 -BenchmarkFilterNodes 50000 59489 ns/op ---- BENCH: BenchmarkFilterNodes - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 -BenchmarkNotNodes 50000 73623 ns/op ---- BENCH: BenchmarkNotNodes - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 -BenchmarkFilterSelection 50000 60053 ns/op ---- BENCH: BenchmarkFilterSelection - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 -BenchmarkNotSelection 50000 73477 ns/op ---- BENCH: BenchmarkNotSelection - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 -BenchmarkHas 5000 364859 ns/op ---- BENCH: BenchmarkHas - bench_filter_test.go:160: Has=13 - bench_filter_test.go:160: Has=13 - bench_filter_test.go:160: Has=13 -BenchmarkHasNodes 10000 226980 ns/op ---- BENCH: BenchmarkHasNodes - bench_filter_test.go:178: HasNodes=15 - bench_filter_test.go:178: HasNodes=15 - bench_filter_test.go:178: HasNodes=15 -BenchmarkHasSelection 10000 220471 ns/op ---- BENCH: BenchmarkHasSelection - bench_filter_test.go:195: HasSelection=15 - bench_filter_test.go:195: HasSelection=15 - bench_filter_test.go:195: HasSelection=15 -BenchmarkEnd 500000000 4.64 ns/op ---- BENCH: BenchmarkEnd - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 -BenchmarkEach 200000 8811 ns/op ---- BENCH: BenchmarkEach - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 -BenchmarkMap 100000 15365 ns/op ---- BENCH: BenchmarkMap - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 -BenchmarkEachWithBreak 1000000 1559 ns/op ---- BENCH: BenchmarkEachWithBreak - bench_iteration_test.go:61: Each=10 - bench_iteration_test.go:61: Each=10 - bench_iteration_test.go:61: Each=10 - bench_iteration_test.go:61: Each=10 -BenchmarkAttr 50000000 31.7 ns/op ---- BENCH: BenchmarkAttr - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading -BenchmarkText 200000 13901 ns/op -BenchmarkLength 2000000000 0.31 ns/op ---- BENCH: BenchmarkLength - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 -BenchmarkHtml 5000000 541 ns/op -BenchmarkIs 100000 29435 ns/op ---- BENCH: BenchmarkIs - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true -BenchmarkIsPositional 100000 22938 ns/op ---- BENCH: BenchmarkIsPositional - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true -BenchmarkIsFunction 1000000 2185 ns/op ---- BENCH: BenchmarkIsFunction - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true -BenchmarkIsSelection 50000 60607 ns/op ---- BENCH: BenchmarkIsSelection - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true -BenchmarkIsNodes 50000 61599 ns/op ---- BENCH: BenchmarkIsNodes - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true -BenchmarkHasClass 5000 395436 ns/op ---- BENCH: BenchmarkHasClass - bench_query_test.go:82: HasClass=true - bench_query_test.go:82: HasClass=true - bench_query_test.go:82: HasClass=true -BenchmarkContains 100000000 11.0 ns/op ---- BENCH: BenchmarkContains - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true -BenchmarkFind 200000 13788 ns/op ---- BENCH: BenchmarkFind - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 -BenchmarkFindWithinSelection 50000 54253 ns/op ---- BENCH: BenchmarkFindWithinSelection - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 -BenchmarkFindSelection 5000 438879 ns/op ---- BENCH: BenchmarkFindSelection - bench_traversal_test.go:51: FindSelection=73 - bench_traversal_test.go:51: FindSelection=73 - bench_traversal_test.go:51: FindSelection=73 -BenchmarkFindNodes 5000 437225 ns/op ---- BENCH: BenchmarkFindNodes - bench_traversal_test.go:69: FindNodes=73 - bench_traversal_test.go:69: FindNodes=73 - bench_traversal_test.go:69: FindNodes=73 -BenchmarkContents 1000000 2844 ns/op ---- BENCH: BenchmarkContents - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 -BenchmarkContentsFiltered 500000 4528 ns/op ---- BENCH: BenchmarkContentsFiltered - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 -BenchmarkChildren 5000000 552 ns/op ---- BENCH: BenchmarkChildren - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 -BenchmarkChildrenFiltered 500000 3345 ns/op ---- BENCH: BenchmarkChildrenFiltered - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 -BenchmarkParent 50000 39482 ns/op ---- BENCH: BenchmarkParent - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 -BenchmarkParentFiltered 50000 42113 ns/op ---- BENCH: BenchmarkParentFiltered - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 -BenchmarkParents 20000 84136 ns/op ---- BENCH: BenchmarkParents - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 -BenchmarkParentsFiltered 20000 86041 ns/op ---- BENCH: BenchmarkParentsFiltered - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 -BenchmarkParentsUntil 50000 65844 ns/op ---- BENCH: BenchmarkParentsUntil - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 -BenchmarkParentsUntilSelection 10000 146903 ns/op ---- BENCH: BenchmarkParentsUntilSelection - bench_traversal_test.go:230: ParentsUntilSelection=70 - bench_traversal_test.go:230: ParentsUntilSelection=70 - bench_traversal_test.go:230: ParentsUntilSelection=70 -BenchmarkParentsUntilNodes 10000 146638 ns/op ---- BENCH: BenchmarkParentsUntilNodes - bench_traversal_test.go:248: ParentsUntilNodes=70 - bench_traversal_test.go:248: ParentsUntilNodes=70 - bench_traversal_test.go:248: ParentsUntilNodes=70 -BenchmarkParentsFilteredUntil 100000 16413 ns/op ---- BENCH: BenchmarkParentsFilteredUntil - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 -BenchmarkParentsFilteredUntilSelection 100000 20366 ns/op ---- BENCH: BenchmarkParentsFilteredUntilSelection - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 -BenchmarkParentsFilteredUntilNodes 100000 18800 ns/op ---- BENCH: BenchmarkParentsFilteredUntilNodes - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 -BenchmarkSiblings 50000 63443 ns/op ---- BENCH: BenchmarkSiblings - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 -BenchmarkSiblingsFiltered 50000 69250 ns/op ---- BENCH: BenchmarkSiblingsFiltered - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 -BenchmarkNext 200000 9193 ns/op ---- BENCH: BenchmarkNext - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 -BenchmarkNextFiltered 200000 10767 ns/op ---- BENCH: BenchmarkNextFiltered - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 -BenchmarkNextAll 50000 42829 ns/op ---- BENCH: BenchmarkNextAll - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 -BenchmarkNextAllFiltered 50000 48174 ns/op ---- BENCH: BenchmarkNextAllFiltered - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 -BenchmarkPrev 200000 9114 ns/op ---- BENCH: BenchmarkPrev - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 -BenchmarkPrevFiltered 200000 11114 ns/op ---- BENCH: BenchmarkPrevFiltered - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 -BenchmarkPrevAll 100000 16387 ns/op ---- BENCH: BenchmarkPrevAll - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 -BenchmarkPrevAllFiltered 100000 18322 ns/op ---- BENCH: BenchmarkPrevAllFiltered - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 -BenchmarkNextUntil 20000 83828 ns/op ---- BENCH: BenchmarkNextUntil - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 -BenchmarkNextUntilSelection 50000 58822 ns/op ---- BENCH: BenchmarkNextUntilSelection - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 -BenchmarkNextUntilNodes 100000 23173 ns/op ---- BENCH: BenchmarkNextUntilNodes - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 -BenchmarkPrevUntil 10000 219407 ns/op ---- BENCH: BenchmarkPrevUntil - bench_traversal_test.go:528: PrevUntil=238 - bench_traversal_test.go:528: PrevUntil=238 - bench_traversal_test.go:528: PrevUntil=238 -BenchmarkPrevUntilSelection 20000 76033 ns/op ---- BENCH: BenchmarkPrevUntilSelection - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 -BenchmarkPrevUntilNodes 100000 19417 ns/op ---- BENCH: BenchmarkPrevUntilNodes - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 -BenchmarkNextFilteredUntil 50000 44648 ns/op ---- BENCH: BenchmarkNextFilteredUntil - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 -BenchmarkNextFilteredUntilSelection 50000 62751 ns/op ---- BENCH: BenchmarkNextFilteredUntilSelection - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 -BenchmarkNextFilteredUntilNodes 50000 62035 ns/op ---- BENCH: BenchmarkNextFilteredUntilNodes - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 -BenchmarkPrevFilteredUntil 50000 43331 ns/op ---- BENCH: BenchmarkPrevFilteredUntil - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 -BenchmarkPrevFilteredUntilSelection 50000 64767 ns/op ---- BENCH: BenchmarkPrevFilteredUntilSelection - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 -BenchmarkPrevFilteredUntilNodes 50000 67808 ns/op ---- BENCH: BenchmarkPrevFilteredUntilNodes - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 -BenchmarkClosest 500000 4870 ns/op ---- BENCH: BenchmarkClosest - bench_traversal_test.go:681: Closest=2 - bench_traversal_test.go:681: Closest=2 - bench_traversal_test.go:681: Closest=2 - bench_traversal_test.go:681: Closest=2 -BenchmarkClosestSelection 5000000 656 ns/op ---- BENCH: BenchmarkClosestSelection - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 -BenchmarkClosestNodes 5000000 663 ns/op ---- BENCH: BenchmarkClosestNodes - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 -ok github.com/PuerkitoBio/goquery 218.007s diff --git a/vendor/github.com/PuerkitoBio/goquery/bench/v0.3.2-go1.2rc1 b/vendor/github.com/PuerkitoBio/goquery/bench/v0.3.2-go1.2rc1 deleted file mode 100644 index e1bada783..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench/v0.3.2-go1.2rc1 +++ /dev/null @@ -1,477 +0,0 @@ -PASS -BenchmarkFirst 20000000 91.0 ns/op -BenchmarkLast 20000000 90.5 ns/op -BenchmarkEq 20000000 90.2 ns/op -BenchmarkSlice 20000000 88.0 ns/op -BenchmarkGet 1000000000 2.04 ns/op -BenchmarkIndex 2000000 935 ns/op ---- BENCH: BenchmarkIndex - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 - bench_array_test.go:73: Index=3 -BenchmarkIndexSelector 100000 23613 ns/op ---- BENCH: BenchmarkIndexSelector - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 - bench_array_test.go:85: IndexSelector=4 -BenchmarkIndexOfNode 100000000 10.2 ns/op ---- BENCH: BenchmarkIndexOfNode - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 - bench_array_test.go:99: IndexOfNode=2 -BenchmarkIndexOfSelection 100000000 11.0 ns/op ---- BENCH: BenchmarkIndexOfSelection - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 - bench_array_test.go:111: IndexOfSelection=2 -BenchmarkMetalReviewExample 10000 213843 ns/op ---- BENCH: BenchmarkMetalReviewExample - bench_example_test.go:40: Review 0: Midnight - Complete and Total Hell (8.5). - Review 1: Over Your Threshold - Facticity (6.0). - Review 2: Nuclear Death Terror - Chaos Reigns (7.5). - Review 3: Evoken - Atra Mors (9.5). - - bench_example_test.go:41: MetalReviewExample=10 - bench_example_test.go:40: Review 0: Midnight - Complete and Total Hell (8.5). - Review 1: Over Your Threshold - Facticity (6.0). - Review 2: Nuclear Death Terror - Chaos Reigns (7.5). - Review 3: Evoken - Atra Mors (9.5). - ... [output truncated] -BenchmarkAdd 100000 18671 ns/op ---- BENCH: BenchmarkAdd - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 - bench_expand_test.go:20: Add=43 -BenchmarkAddSelection 10000000 204 ns/op ---- BENCH: BenchmarkAddSelection - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 - bench_expand_test.go:37: AddSelection=43 -BenchmarkAddNodes 10000000 195 ns/op ---- BENCH: BenchmarkAddNodes - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 - bench_expand_test.go:55: AddNodes=43 -BenchmarkAndSelf 1000000 2611 ns/op ---- BENCH: BenchmarkAndSelf - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 - bench_expand_test.go:71: AndSelf=44 -BenchmarkFilter 100000 27571 ns/op ---- BENCH: BenchmarkFilter - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 - bench_filter_test.go:20: Filter=13 -BenchmarkNot 50000 32006 ns/op ---- BENCH: BenchmarkNot - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 - bench_filter_test.go:36: Not=371 -BenchmarkFilterFunction 50000 61388 ns/op ---- BENCH: BenchmarkFilterFunction - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 - bench_filter_test.go:55: FilterFunction=112 -BenchmarkNotFunction 50000 66702 ns/op ---- BENCH: BenchmarkNotFunction - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 - bench_filter_test.go:74: NotFunction=261 -BenchmarkFilterNodes 50000 59699 ns/op ---- BENCH: BenchmarkFilterNodes - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 - bench_filter_test.go:92: FilterNodes=2 -BenchmarkNotNodes 50000 73248 ns/op ---- BENCH: BenchmarkNotNodes - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 - bench_filter_test.go:110: NotNodes=360 -BenchmarkFilterSelection 50000 59242 ns/op ---- BENCH: BenchmarkFilterSelection - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 - bench_filter_test.go:127: FilterSelection=2 -BenchmarkNotSelection 50000 73211 ns/op ---- BENCH: BenchmarkNotSelection - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 - bench_filter_test.go:144: NotSelection=360 -BenchmarkHas 5000 395087 ns/op ---- BENCH: BenchmarkHas - bench_filter_test.go:160: Has=13 - bench_filter_test.go:160: Has=13 - bench_filter_test.go:160: Has=13 -BenchmarkHasNodes 10000 215849 ns/op ---- BENCH: BenchmarkHasNodes - bench_filter_test.go:178: HasNodes=15 - bench_filter_test.go:178: HasNodes=15 - bench_filter_test.go:178: HasNodes=15 -BenchmarkHasSelection 10000 215612 ns/op ---- BENCH: BenchmarkHasSelection - bench_filter_test.go:195: HasSelection=15 - bench_filter_test.go:195: HasSelection=15 - bench_filter_test.go:195: HasSelection=15 -BenchmarkEnd 500000000 4.59 ns/op ---- BENCH: BenchmarkEnd - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 - bench_filter_test.go:211: End=373 -BenchmarkEach 200000 8588 ns/op ---- BENCH: BenchmarkEach - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 - bench_iteration_test.go:22: Each=59 -BenchmarkMap 200000 14444 ns/op ---- BENCH: BenchmarkMap - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 - bench_iteration_test.go:41: Map=59 -BenchmarkEachWithBreak 1000000 1490 ns/op ---- BENCH: BenchmarkEachWithBreak - bench_iteration_test.go:61: Each=10 - bench_iteration_test.go:61: Each=10 - bench_iteration_test.go:61: Each=10 - bench_iteration_test.go:61: Each=10 -BenchmarkAttr 50000000 30.9 ns/op ---- BENCH: BenchmarkAttr - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading - bench_property_test.go:16: Attr=firstHeading -BenchmarkText 200000 14017 ns/op -BenchmarkLength 2000000000 0.31 ns/op ---- BENCH: BenchmarkLength - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 - bench_property_test.go:37: Length=14 -BenchmarkHtml 5000000 577 ns/op -BenchmarkIs 50000 31936 ns/op ---- BENCH: BenchmarkIs - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true - bench_query_test.go:16: Is=true -BenchmarkIsPositional 100000 23372 ns/op ---- BENCH: BenchmarkIsPositional - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true - bench_query_test.go:28: IsPositional=true -BenchmarkIsFunction 1000000 2170 ns/op ---- BENCH: BenchmarkIsFunction - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true - bench_query_test.go:43: IsFunction=true -BenchmarkIsSelection 50000 59814 ns/op ---- BENCH: BenchmarkIsSelection - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true - bench_query_test.go:56: IsSelection=true -BenchmarkIsNodes 50000 59629 ns/op ---- BENCH: BenchmarkIsNodes - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true - bench_query_test.go:70: IsNodes=true -BenchmarkHasClass 5000 384894 ns/op ---- BENCH: BenchmarkHasClass - bench_query_test.go:82: HasClass=true - bench_query_test.go:82: HasClass=true - bench_query_test.go:82: HasClass=true -BenchmarkContains 100000000 11.4 ns/op ---- BENCH: BenchmarkContains - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true - bench_query_test.go:96: Contains=true -BenchmarkFind 100000 23545 ns/op ---- BENCH: BenchmarkFind - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 - bench_traversal_test.go:18: Find=41 -BenchmarkFindWithinSelection 50000 63775 ns/op ---- BENCH: BenchmarkFindWithinSelection - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 - bench_traversal_test.go:34: FindWithinSelection=39 -BenchmarkFindSelection 5000 441958 ns/op ---- BENCH: BenchmarkFindSelection - bench_traversal_test.go:51: FindSelection=73 - bench_traversal_test.go:51: FindSelection=73 - bench_traversal_test.go:51: FindSelection=73 -BenchmarkFindNodes 5000 437717 ns/op ---- BENCH: BenchmarkFindNodes - bench_traversal_test.go:69: FindNodes=73 - bench_traversal_test.go:69: FindNodes=73 - bench_traversal_test.go:69: FindNodes=73 -BenchmarkContents 1000000 2799 ns/op ---- BENCH: BenchmarkContents - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 - bench_traversal_test.go:85: Contents=16 -BenchmarkContentsFiltered 500000 4489 ns/op ---- BENCH: BenchmarkContentsFiltered - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 - bench_traversal_test.go:101: ContentsFiltered=1 -BenchmarkChildren 5000000 546 ns/op ---- BENCH: BenchmarkChildren - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 - bench_traversal_test.go:117: Children=2 -BenchmarkChildrenFiltered 500000 3472 ns/op ---- BENCH: BenchmarkChildrenFiltered - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 - bench_traversal_test.go:133: ChildrenFiltered=2 -BenchmarkParent 50000 39067 ns/op ---- BENCH: BenchmarkParent - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 - bench_traversal_test.go:149: Parent=55 -BenchmarkParentFiltered 50000 41450 ns/op ---- BENCH: BenchmarkParentFiltered - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 - bench_traversal_test.go:165: ParentFiltered=4 -BenchmarkParents 20000 84864 ns/op ---- BENCH: BenchmarkParents - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 - bench_traversal_test.go:181: Parents=73 -BenchmarkParentsFiltered 20000 87823 ns/op ---- BENCH: BenchmarkParentsFiltered - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 - bench_traversal_test.go:197: ParentsFiltered=18 -BenchmarkParentsUntil 50000 65986 ns/op ---- BENCH: BenchmarkParentsUntil - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 - bench_traversal_test.go:213: ParentsUntil=52 -BenchmarkParentsUntilSelection 10000 149798 ns/op ---- BENCH: BenchmarkParentsUntilSelection - bench_traversal_test.go:230: ParentsUntilSelection=70 - bench_traversal_test.go:230: ParentsUntilSelection=70 - bench_traversal_test.go:230: ParentsUntilSelection=70 -BenchmarkParentsUntilNodes 10000 148144 ns/op ---- BENCH: BenchmarkParentsUntilNodes - bench_traversal_test.go:248: ParentsUntilNodes=70 - bench_traversal_test.go:248: ParentsUntilNodes=70 - bench_traversal_test.go:248: ParentsUntilNodes=70 -BenchmarkParentsFilteredUntil 100000 15579 ns/op ---- BENCH: BenchmarkParentsFilteredUntil - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 - bench_traversal_test.go:264: ParentsFilteredUntil=2 -BenchmarkParentsFilteredUntilSelection 100000 19094 ns/op ---- BENCH: BenchmarkParentsFilteredUntilSelection - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 - bench_traversal_test.go:281: ParentsFilteredUntilSelection=2 -BenchmarkParentsFilteredUntilNodes 100000 19037 ns/op ---- BENCH: BenchmarkParentsFilteredUntilNodes - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 - bench_traversal_test.go:299: ParentsFilteredUntilNodes=2 -BenchmarkSiblings 50000 63891 ns/op ---- BENCH: BenchmarkSiblings - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 - bench_traversal_test.go:315: Siblings=293 -BenchmarkSiblingsFiltered 50000 70424 ns/op ---- BENCH: BenchmarkSiblingsFiltered - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 - bench_traversal_test.go:331: SiblingsFiltered=46 -BenchmarkNext 200000 9350 ns/op ---- BENCH: BenchmarkNext - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 - bench_traversal_test.go:347: Next=49 -BenchmarkNextFiltered 200000 10929 ns/op ---- BENCH: BenchmarkNextFiltered - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 - bench_traversal_test.go:363: NextFiltered=6 -BenchmarkNextAll 50000 43398 ns/op ---- BENCH: BenchmarkNextAll - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 - bench_traversal_test.go:379: NextAll=234 -BenchmarkNextAllFiltered 50000 48519 ns/op ---- BENCH: BenchmarkNextAllFiltered - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 - bench_traversal_test.go:395: NextAllFiltered=33 -BenchmarkPrev 200000 9181 ns/op ---- BENCH: BenchmarkPrev - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 - bench_traversal_test.go:411: Prev=49 -BenchmarkPrevFiltered 200000 10811 ns/op ---- BENCH: BenchmarkPrevFiltered - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 - bench_traversal_test.go:429: PrevFiltered=7 -BenchmarkPrevAll 100000 15589 ns/op ---- BENCH: BenchmarkPrevAll - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 - bench_traversal_test.go:445: PrevAll=78 -BenchmarkPrevAllFiltered 100000 17341 ns/op ---- BENCH: BenchmarkPrevAllFiltered - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 - bench_traversal_test.go:461: PrevAllFiltered=6 -BenchmarkNextUntil 20000 80663 ns/op ---- BENCH: BenchmarkNextUntil - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 - bench_traversal_test.go:477: NextUntil=84 -BenchmarkNextUntilSelection 50000 56496 ns/op ---- BENCH: BenchmarkNextUntilSelection - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 - bench_traversal_test.go:494: NextUntilSelection=42 -BenchmarkNextUntilNodes 100000 23729 ns/op ---- BENCH: BenchmarkNextUntilNodes - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 - bench_traversal_test.go:512: NextUntilNodes=12 -BenchmarkPrevUntil 10000 208267 ns/op ---- BENCH: BenchmarkPrevUntil - bench_traversal_test.go:528: PrevUntil=238 - bench_traversal_test.go:528: PrevUntil=238 - bench_traversal_test.go:528: PrevUntil=238 -BenchmarkPrevUntilSelection 50000 72119 ns/op ---- BENCH: BenchmarkPrevUntilSelection - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 - bench_traversal_test.go:545: PrevUntilSelection=49 -BenchmarkPrevUntilNodes 100000 18549 ns/op ---- BENCH: BenchmarkPrevUntilNodes - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 - bench_traversal_test.go:563: PrevUntilNodes=11 -BenchmarkNextFilteredUntil 50000 42339 ns/op ---- BENCH: BenchmarkNextFilteredUntil - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 - bench_traversal_test.go:579: NextFilteredUntil=22 -BenchmarkNextFilteredUntilSelection 50000 61916 ns/op ---- BENCH: BenchmarkNextFilteredUntilSelection - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 - bench_traversal_test.go:596: NextFilteredUntilSelection=22 -BenchmarkNextFilteredUntilNodes 50000 62139 ns/op ---- BENCH: BenchmarkNextFilteredUntilNodes - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 - bench_traversal_test.go:614: NextFilteredUntilNodes=22 -BenchmarkPrevFilteredUntil 50000 43409 ns/op ---- BENCH: BenchmarkPrevFilteredUntil - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 - bench_traversal_test.go:630: PrevFilteredUntil=20 -BenchmarkPrevFilteredUntilSelection 50000 63768 ns/op ---- BENCH: BenchmarkPrevFilteredUntilSelection - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 - bench_traversal_test.go:647: PrevFilteredUntilSelection=20 -BenchmarkPrevFilteredUntilNodes 50000 63543 ns/op ---- BENCH: BenchmarkPrevFilteredUntilNodes - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 - bench_traversal_test.go:665: PrevFilteredUntilNodes=20 -BenchmarkClosest 500000 5110 ns/op ---- BENCH: BenchmarkClosest - bench_traversal_test.go:681: Closest=2 - bench_traversal_test.go:681: Closest=2 - bench_traversal_test.go:681: Closest=2 - bench_traversal_test.go:681: Closest=2 -BenchmarkClosestSelection 5000000 629 ns/op ---- BENCH: BenchmarkClosestSelection - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 - bench_traversal_test.go:698: ClosestSelection=2 -BenchmarkClosestNodes 5000000 627 ns/op ---- BENCH: BenchmarkClosestNodes - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 - bench_traversal_test.go:715: ClosestNodes=2 -ok github.com/PuerkitoBio/goquery 215.785s diff --git a/vendor/github.com/PuerkitoBio/goquery/bench/v1.0.0-go1.7 b/vendor/github.com/PuerkitoBio/goquery/bench/v1.0.0-go1.7 deleted file mode 100644 index 4bc3a1fa8..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench/v1.0.0-go1.7 +++ /dev/null @@ -1,85 +0,0 @@ -BenchmarkFirst-4 30000000 50.7 ns/op 48 B/op 1 allocs/op -BenchmarkLast-4 30000000 50.9 ns/op 48 B/op 1 allocs/op -BenchmarkEq-4 30000000 55.7 ns/op 48 B/op 1 allocs/op -BenchmarkSlice-4 500000000 3.45 ns/op 0 B/op 0 allocs/op -BenchmarkGet-4 2000000000 1.68 ns/op 0 B/op 0 allocs/op -BenchmarkIndex-4 3000000 541 ns/op 248 B/op 10 allocs/op -BenchmarkIndexSelector-4 200000 10749 ns/op 2464 B/op 17 allocs/op -BenchmarkIndexOfNode-4 200000000 6.47 ns/op 0 B/op 0 allocs/op -BenchmarkIndexOfSelection-4 200000000 7.27 ns/op 0 B/op 0 allocs/op -BenchmarkMetalReviewExample-4 10000 138426 ns/op 12240 B/op 319 allocs/op -BenchmarkAdd-4 200000 10192 ns/op 208 B/op 9 allocs/op -BenchmarkAddSelection-4 10000000 158 ns/op 48 B/op 1 allocs/op -BenchmarkAddNodes-4 10000000 156 ns/op 48 B/op 1 allocs/op -BenchmarkAndSelf-4 1000000 1588 ns/op 1008 B/op 5 allocs/op -BenchmarkFilter-4 100000 20427 ns/op 360 B/op 8 allocs/op -BenchmarkNot-4 100000 23508 ns/op 136 B/op 5 allocs/op -BenchmarkFilterFunction-4 50000 34178 ns/op 22976 B/op 755 allocs/op -BenchmarkNotFunction-4 50000 38173 ns/op 29120 B/op 757 allocs/op -BenchmarkFilterNodes-4 50000 34001 ns/op 20960 B/op 749 allocs/op -BenchmarkNotNodes-4 30000 40344 ns/op 29120 B/op 757 allocs/op -BenchmarkFilterSelection-4 50000 33308 ns/op 20960 B/op 749 allocs/op -BenchmarkNotSelection-4 30000 40748 ns/op 29120 B/op 757 allocs/op -BenchmarkHas-4 5000 263346 ns/op 1816 B/op 48 allocs/op -BenchmarkHasNodes-4 10000 160840 ns/op 21184 B/op 752 allocs/op -BenchmarkHasSelection-4 10000 165410 ns/op 21184 B/op 752 allocs/op -BenchmarkEnd-4 2000000000 1.01 ns/op 0 B/op 0 allocs/op -BenchmarkEach-4 300000 4664 ns/op 3304 B/op 118 allocs/op -BenchmarkMap-4 200000 8286 ns/op 5572 B/op 184 allocs/op -BenchmarkEachWithBreak-4 2000000 806 ns/op 560 B/op 20 allocs/op -BenchmarkAttr-4 100000000 21.6 ns/op 0 B/op 0 allocs/op -BenchmarkText-4 200000 8909 ns/op 7536 B/op 110 allocs/op -BenchmarkLength-4 2000000000 0.34 ns/op 0 B/op 0 allocs/op -BenchmarkHtml-4 3000000 422 ns/op 120 B/op 2 allocs/op -BenchmarkIs-4 100000 22615 ns/op 88 B/op 4 allocs/op -BenchmarkIsPositional-4 50000 26655 ns/op 1112 B/op 10 allocs/op -BenchmarkIsFunction-4 1000000 1208 ns/op 784 B/op 28 allocs/op -BenchmarkIsSelection-4 50000 33497 ns/op 20960 B/op 749 allocs/op -BenchmarkIsNodes-4 50000 33572 ns/op 20960 B/op 749 allocs/op -BenchmarkHasClass-4 10000 232802 ns/op 14944 B/op 976 allocs/op -BenchmarkContains-4 200000000 7.33 ns/op 0 B/op 0 allocs/op -BenchmarkFind-4 200000 10715 ns/op 2464 B/op 17 allocs/op -BenchmarkFindWithinSelection-4 50000 35878 ns/op 2176 B/op 78 allocs/op -BenchmarkFindSelection-4 10000 194356 ns/op 2672 B/op 82 allocs/op -BenchmarkFindNodes-4 10000 195510 ns/op 2672 B/op 82 allocs/op -BenchmarkContents-4 1000000 2252 ns/op 864 B/op 34 allocs/op -BenchmarkContentsFiltered-4 500000 3015 ns/op 1016 B/op 39 allocs/op -BenchmarkChildren-4 5000000 364 ns/op 152 B/op 7 allocs/op -BenchmarkChildrenFiltered-4 1000000 2212 ns/op 352 B/op 15 allocs/op -BenchmarkParent-4 50000 24643 ns/op 4048 B/op 381 allocs/op -BenchmarkParentFiltered-4 50000 25967 ns/op 4248 B/op 388 allocs/op -BenchmarkParents-4 30000 50000 ns/op 27776 B/op 830 allocs/op -BenchmarkParentsFiltered-4 30000 53107 ns/op 28360 B/op 838 allocs/op -BenchmarkParentsUntil-4 100000 22423 ns/op 10352 B/op 353 allocs/op -BenchmarkParentsUntilSelection-4 20000 86925 ns/op 51144 B/op 1516 allocs/op -BenchmarkParentsUntilNodes-4 20000 87597 ns/op 51144 B/op 1516 allocs/op -BenchmarkParentsFilteredUntil-4 300000 5568 ns/op 2232 B/op 86 allocs/op -BenchmarkParentsFilteredUntilSelection-4 200000 10966 ns/op 5440 B/op 190 allocs/op -BenchmarkParentsFilteredUntilNodes-4 200000 10919 ns/op 5440 B/op 190 allocs/op -BenchmarkSiblings-4 30000 46018 ns/op 15400 B/op 204 allocs/op -BenchmarkSiblingsFiltered-4 30000 50566 ns/op 16496 B/op 213 allocs/op -BenchmarkNext-4 200000 7921 ns/op 3216 B/op 112 allocs/op -BenchmarkNextFiltered-4 200000 8804 ns/op 3416 B/op 118 allocs/op -BenchmarkNextAll-4 50000 31098 ns/op 9912 B/op 138 allocs/op -BenchmarkNextAllFiltered-4 50000 34677 ns/op 11008 B/op 147 allocs/op -BenchmarkPrev-4 200000 7920 ns/op 3216 B/op 112 allocs/op -BenchmarkPrevFiltered-4 200000 8913 ns/op 3416 B/op 118 allocs/op -BenchmarkPrevAll-4 200000 10845 ns/op 4376 B/op 113 allocs/op -BenchmarkPrevAllFiltered-4 100000 12030 ns/op 4576 B/op 119 allocs/op -BenchmarkNextUntil-4 100000 19193 ns/op 5760 B/op 260 allocs/op -BenchmarkNextUntilSelection-4 50000 34829 ns/op 18480 B/op 542 allocs/op -BenchmarkNextUntilNodes-4 100000 14459 ns/op 7944 B/op 248 allocs/op -BenchmarkPrevUntil-4 20000 66296 ns/op 12856 B/op 448 allocs/op -BenchmarkPrevUntilSelection-4 30000 45037 ns/op 23432 B/op 689 allocs/op -BenchmarkPrevUntilNodes-4 200000 11525 ns/op 6152 B/op 203 allocs/op -BenchmarkNextFilteredUntil-4 100000 12940 ns/op 4512 B/op 173 allocs/op -BenchmarkNextFilteredUntilSelection-4 50000 38924 ns/op 19160 B/op 567 allocs/op -BenchmarkNextFilteredUntilNodes-4 50000 38528 ns/op 19160 B/op 567 allocs/op -BenchmarkPrevFilteredUntil-4 100000 12980 ns/op 4664 B/op 175 allocs/op -BenchmarkPrevFilteredUntilSelection-4 50000 39671 ns/op 19936 B/op 587 allocs/op -BenchmarkPrevFilteredUntilNodes-4 50000 39484 ns/op 19936 B/op 587 allocs/op -BenchmarkClosest-4 500000 3310 ns/op 160 B/op 8 allocs/op -BenchmarkClosestSelection-4 5000000 361 ns/op 96 B/op 6 allocs/op -BenchmarkClosestNodes-4 5000000 359 ns/op 96 B/op 6 allocs/op -PASS -ok github.com/PuerkitoBio/goquery 163.718s diff --git a/vendor/github.com/PuerkitoBio/goquery/bench/v1.0.1a-go1.7 b/vendor/github.com/PuerkitoBio/goquery/bench/v1.0.1a-go1.7 deleted file mode 100644 index 0831aac3a..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench/v1.0.1a-go1.7 +++ /dev/null @@ -1,85 +0,0 @@ -BenchmarkFirst-4 30000000 50.9 ns/op 48 B/op 1 allocs/op -BenchmarkLast-4 30000000 50.0 ns/op 48 B/op 1 allocs/op -BenchmarkEq-4 30000000 50.5 ns/op 48 B/op 1 allocs/op -BenchmarkSlice-4 500000000 3.53 ns/op 0 B/op 0 allocs/op -BenchmarkGet-4 2000000000 1.66 ns/op 0 B/op 0 allocs/op -BenchmarkIndex-4 2000000 832 ns/op 248 B/op 10 allocs/op -BenchmarkIndexSelector-4 100000 16073 ns/op 3839 B/op 21 allocs/op -BenchmarkIndexOfNode-4 200000000 6.38 ns/op 0 B/op 0 allocs/op -BenchmarkIndexOfSelection-4 200000000 7.14 ns/op 0 B/op 0 allocs/op -BenchmarkMetalReviewExample-4 10000 140737 ns/op 12418 B/op 320 allocs/op -BenchmarkAdd-4 100000 13162 ns/op 974 B/op 10 allocs/op -BenchmarkAddSelection-4 500000 3160 ns/op 814 B/op 2 allocs/op -BenchmarkAddNodes-4 500000 3159 ns/op 814 B/op 2 allocs/op -BenchmarkAndSelf-4 200000 7423 ns/op 2404 B/op 9 allocs/op -BenchmarkFilter-4 100000 19671 ns/op 360 B/op 8 allocs/op -BenchmarkNot-4 100000 22577 ns/op 136 B/op 5 allocs/op -BenchmarkFilterFunction-4 50000 33960 ns/op 22976 B/op 755 allocs/op -BenchmarkNotFunction-4 50000 37909 ns/op 29120 B/op 757 allocs/op -BenchmarkFilterNodes-4 50000 34196 ns/op 20960 B/op 749 allocs/op -BenchmarkNotNodes-4 30000 40446 ns/op 29120 B/op 757 allocs/op -BenchmarkFilterSelection-4 50000 33091 ns/op 20960 B/op 749 allocs/op -BenchmarkNotSelection-4 30000 40609 ns/op 29120 B/op 757 allocs/op -BenchmarkHas-4 5000 262936 ns/op 2371 B/op 50 allocs/op -BenchmarkHasNodes-4 10000 148631 ns/op 21184 B/op 752 allocs/op -BenchmarkHasSelection-4 10000 153117 ns/op 21184 B/op 752 allocs/op -BenchmarkEnd-4 2000000000 1.02 ns/op 0 B/op 0 allocs/op -BenchmarkEach-4 300000 4653 ns/op 3304 B/op 118 allocs/op -BenchmarkMap-4 200000 8257 ns/op 5572 B/op 184 allocs/op -BenchmarkEachWithBreak-4 2000000 806 ns/op 560 B/op 20 allocs/op -BenchmarkAttr-4 100000000 22.0 ns/op 0 B/op 0 allocs/op -BenchmarkText-4 200000 8913 ns/op 7536 B/op 110 allocs/op -BenchmarkLength-4 2000000000 0.35 ns/op 0 B/op 0 allocs/op -BenchmarkHtml-4 5000000 398 ns/op 120 B/op 2 allocs/op -BenchmarkIs-4 100000 22392 ns/op 88 B/op 4 allocs/op -BenchmarkIsPositional-4 50000 26259 ns/op 1112 B/op 10 allocs/op -BenchmarkIsFunction-4 1000000 1212 ns/op 784 B/op 28 allocs/op -BenchmarkIsSelection-4 50000 33222 ns/op 20960 B/op 749 allocs/op -BenchmarkIsNodes-4 50000 33408 ns/op 20960 B/op 749 allocs/op -BenchmarkHasClass-4 10000 233208 ns/op 14944 B/op 976 allocs/op -BenchmarkContains-4 200000000 7.57 ns/op 0 B/op 0 allocs/op -BenchmarkFind-4 100000 16121 ns/op 3839 B/op 21 allocs/op -BenchmarkFindWithinSelection-4 20000 68019 ns/op 11521 B/op 97 allocs/op -BenchmarkFindSelection-4 5000 387582 ns/op 59787 B/op 176 allocs/op -BenchmarkFindNodes-4 5000 389246 ns/op 59797 B/op 176 allocs/op -BenchmarkContents-4 200000 11475 ns/op 2878 B/op 42 allocs/op -BenchmarkContentsFiltered-4 200000 11222 ns/op 2498 B/op 46 allocs/op -BenchmarkChildren-4 2000000 650 ns/op 152 B/op 7 allocs/op -BenchmarkChildrenFiltered-4 500000 2568 ns/op 352 B/op 15 allocs/op -BenchmarkParent-4 2000 702513 ns/op 194478 B/op 828 allocs/op -BenchmarkParentFiltered-4 2000 690778 ns/op 194658 B/op 835 allocs/op -BenchmarkParents-4 10000 124855 ns/op 49869 B/op 868 allocs/op -BenchmarkParentsFiltered-4 10000 128535 ns/op 50456 B/op 876 allocs/op -BenchmarkParentsUntil-4 20000 72982 ns/op 23802 B/op 388 allocs/op -BenchmarkParentsUntilSelection-4 10000 156099 ns/op 72453 B/op 1549 allocs/op -BenchmarkParentsUntilNodes-4 10000 156610 ns/op 72455 B/op 1549 allocs/op -BenchmarkParentsFilteredUntil-4 100000 15549 ns/op 4068 B/op 94 allocs/op -BenchmarkParentsFilteredUntilSelection-4 100000 20564 ns/op 7276 B/op 198 allocs/op -BenchmarkParentsFilteredUntilNodes-4 100000 20635 ns/op 7276 B/op 198 allocs/op -BenchmarkSiblings-4 3000 565114 ns/op 205910 B/op 336 allocs/op -BenchmarkSiblingsFiltered-4 3000 580264 ns/op 206993 B/op 345 allocs/op -BenchmarkNext-4 20000 93177 ns/op 26810 B/op 169 allocs/op -BenchmarkNextFiltered-4 20000 94171 ns/op 27013 B/op 175 allocs/op -BenchmarkNextAll-4 5000 270320 ns/op 89289 B/op 237 allocs/op -BenchmarkNextAllFiltered-4 5000 275283 ns/op 90375 B/op 246 allocs/op -BenchmarkPrev-4 20000 92777 ns/op 26810 B/op 169 allocs/op -BenchmarkPrevFiltered-4 20000 95577 ns/op 27007 B/op 175 allocs/op -BenchmarkPrevAll-4 20000 86339 ns/op 27515 B/op 151 allocs/op -BenchmarkPrevAllFiltered-4 20000 87759 ns/op 27715 B/op 157 allocs/op -BenchmarkNextUntil-4 10000 163930 ns/op 48541 B/op 330 allocs/op -BenchmarkNextUntilSelection-4 30000 56382 ns/op 23880 B/op 556 allocs/op -BenchmarkNextUntilNodes-4 100000 18883 ns/op 8703 B/op 252 allocs/op -BenchmarkPrevUntil-4 3000 484668 ns/op 145402 B/op 611 allocs/op -BenchmarkPrevUntilSelection-4 20000 72125 ns/op 28865 B/op 705 allocs/op -BenchmarkPrevUntilNodes-4 100000 14722 ns/op 6510 B/op 205 allocs/op -BenchmarkNextFilteredUntil-4 50000 39006 ns/op 10990 B/op 192 allocs/op -BenchmarkNextFilteredUntilSelection-4 20000 66048 ns/op 25641 B/op 586 allocs/op -BenchmarkNextFilteredUntilNodes-4 20000 65314 ns/op 25640 B/op 586 allocs/op -BenchmarkPrevFilteredUntil-4 50000 33312 ns/op 9709 B/op 189 allocs/op -BenchmarkPrevFilteredUntilSelection-4 20000 64197 ns/op 24981 B/op 601 allocs/op -BenchmarkPrevFilteredUntilNodes-4 20000 64505 ns/op 24982 B/op 601 allocs/op -BenchmarkClosest-4 500000 4065 ns/op 160 B/op 8 allocs/op -BenchmarkClosestSelection-4 2000000 756 ns/op 96 B/op 6 allocs/op -BenchmarkClosestNodes-4 2000000 753 ns/op 96 B/op 6 allocs/op -PASS -ok github.com/PuerkitoBio/goquery 162.053s diff --git a/vendor/github.com/PuerkitoBio/goquery/bench/v1.0.1b-go1.7 b/vendor/github.com/PuerkitoBio/goquery/bench/v1.0.1b-go1.7 deleted file mode 100644 index e8a9e5124..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench/v1.0.1b-go1.7 +++ /dev/null @@ -1,85 +0,0 @@ -BenchmarkFirst-4 30000000 51.8 ns/op 48 B/op 1 allocs/op -BenchmarkLast-4 30000000 50.1 ns/op 48 B/op 1 allocs/op -BenchmarkEq-4 30000000 51.4 ns/op 48 B/op 1 allocs/op -BenchmarkSlice-4 500000000 3.52 ns/op 0 B/op 0 allocs/op -BenchmarkGet-4 2000000000 1.65 ns/op 0 B/op 0 allocs/op -BenchmarkIndex-4 2000000 787 ns/op 248 B/op 10 allocs/op -BenchmarkIndexSelector-4 100000 16952 ns/op 3839 B/op 21 allocs/op -BenchmarkIndexOfNode-4 200000000 6.42 ns/op 0 B/op 0 allocs/op -BenchmarkIndexOfSelection-4 200000000 7.12 ns/op 0 B/op 0 allocs/op -BenchmarkMetalReviewExample-4 10000 141994 ns/op 12418 B/op 320 allocs/op -BenchmarkAdd-4 200000 10367 ns/op 208 B/op 9 allocs/op -BenchmarkAddSelection-4 10000000 152 ns/op 48 B/op 1 allocs/op -BenchmarkAddNodes-4 10000000 147 ns/op 48 B/op 1 allocs/op -BenchmarkAndSelf-4 1000000 1647 ns/op 1008 B/op 5 allocs/op -BenchmarkFilter-4 100000 19522 ns/op 360 B/op 8 allocs/op -BenchmarkNot-4 100000 22546 ns/op 136 B/op 5 allocs/op -BenchmarkFilterFunction-4 50000 35087 ns/op 22976 B/op 755 allocs/op -BenchmarkNotFunction-4 50000 39123 ns/op 29120 B/op 757 allocs/op -BenchmarkFilterNodes-4 50000 34890 ns/op 20960 B/op 749 allocs/op -BenchmarkNotNodes-4 30000 41145 ns/op 29120 B/op 757 allocs/op -BenchmarkFilterSelection-4 50000 33735 ns/op 20960 B/op 749 allocs/op -BenchmarkNotSelection-4 30000 41334 ns/op 29120 B/op 757 allocs/op -BenchmarkHas-4 5000 264058 ns/op 2370 B/op 50 allocs/op -BenchmarkHasNodes-4 10000 151718 ns/op 21184 B/op 752 allocs/op -BenchmarkHasSelection-4 10000 156955 ns/op 21184 B/op 752 allocs/op -BenchmarkEnd-4 2000000000 1.01 ns/op 0 B/op 0 allocs/op -BenchmarkEach-4 300000 4660 ns/op 3304 B/op 118 allocs/op -BenchmarkMap-4 200000 8404 ns/op 5572 B/op 184 allocs/op -BenchmarkEachWithBreak-4 2000000 806 ns/op 560 B/op 20 allocs/op -BenchmarkAttr-4 100000000 21.6 ns/op 0 B/op 0 allocs/op -BenchmarkText-4 200000 8911 ns/op 7536 B/op 110 allocs/op -BenchmarkLength-4 2000000000 0.34 ns/op 0 B/op 0 allocs/op -BenchmarkHtml-4 3000000 405 ns/op 120 B/op 2 allocs/op -BenchmarkIs-4 100000 22228 ns/op 88 B/op 4 allocs/op -BenchmarkIsPositional-4 50000 26469 ns/op 1112 B/op 10 allocs/op -BenchmarkIsFunction-4 1000000 1240 ns/op 784 B/op 28 allocs/op -BenchmarkIsSelection-4 50000 33709 ns/op 20960 B/op 749 allocs/op -BenchmarkIsNodes-4 50000 33711 ns/op 20960 B/op 749 allocs/op -BenchmarkHasClass-4 10000 236005 ns/op 14944 B/op 976 allocs/op -BenchmarkContains-4 200000000 7.47 ns/op 0 B/op 0 allocs/op -BenchmarkFind-4 100000 16075 ns/op 3839 B/op 21 allocs/op -BenchmarkFindWithinSelection-4 30000 41418 ns/op 3539 B/op 82 allocs/op -BenchmarkFindSelection-4 10000 209490 ns/op 5616 B/op 89 allocs/op -BenchmarkFindNodes-4 10000 208206 ns/op 5614 B/op 89 allocs/op -BenchmarkContents-4 300000 4751 ns/op 1420 B/op 36 allocs/op -BenchmarkContentsFiltered-4 300000 5454 ns/op 1570 B/op 41 allocs/op -BenchmarkChildren-4 3000000 527 ns/op 152 B/op 7 allocs/op -BenchmarkChildrenFiltered-4 1000000 2484 ns/op 352 B/op 15 allocs/op -BenchmarkParent-4 50000 34724 ns/op 6940 B/op 387 allocs/op -BenchmarkParentFiltered-4 50000 35596 ns/op 7141 B/op 394 allocs/op -BenchmarkParents-4 20000 62094 ns/op 30720 B/op 837 allocs/op -BenchmarkParentsFiltered-4 20000 63223 ns/op 31304 B/op 845 allocs/op -BenchmarkParentsUntil-4 50000 30391 ns/op 11828 B/op 358 allocs/op -BenchmarkParentsUntilSelection-4 20000 99962 ns/op 54075 B/op 1523 allocs/op -BenchmarkParentsUntilNodes-4 20000 98763 ns/op 54073 B/op 1523 allocs/op -BenchmarkParentsFilteredUntil-4 200000 7982 ns/op 2787 B/op 88 allocs/op -BenchmarkParentsFilteredUntilSelection-4 100000 13618 ns/op 5995 B/op 192 allocs/op -BenchmarkParentsFilteredUntilNodes-4 100000 13639 ns/op 5994 B/op 192 allocs/op -BenchmarkSiblings-4 20000 75287 ns/op 28453 B/op 225 allocs/op -BenchmarkSiblingsFiltered-4 20000 80139 ns/op 29543 B/op 234 allocs/op -BenchmarkNext-4 100000 14270 ns/op 4659 B/op 117 allocs/op -BenchmarkNextFiltered-4 100000 15352 ns/op 4860 B/op 123 allocs/op -BenchmarkNextAll-4 20000 60811 ns/op 22771 B/op 157 allocs/op -BenchmarkNextAllFiltered-4 20000 69079 ns/op 23871 B/op 166 allocs/op -BenchmarkPrev-4 100000 14417 ns/op 4659 B/op 117 allocs/op -BenchmarkPrevFiltered-4 100000 15443 ns/op 4859 B/op 123 allocs/op -BenchmarkPrevAll-4 100000 22008 ns/op 7346 B/op 120 allocs/op -BenchmarkPrevAllFiltered-4 100000 23212 ns/op 7544 B/op 126 allocs/op -BenchmarkNextUntil-4 50000 30589 ns/op 8767 B/op 267 allocs/op -BenchmarkNextUntilSelection-4 30000 40875 ns/op 19862 B/op 546 allocs/op -BenchmarkNextUntilNodes-4 100000 15987 ns/op 8134 B/op 249 allocs/op -BenchmarkPrevUntil-4 20000 98799 ns/op 25727 B/op 467 allocs/op -BenchmarkPrevUntilSelection-4 30000 51874 ns/op 24875 B/op 694 allocs/op -BenchmarkPrevUntilNodes-4 100000 12901 ns/op 6334 B/op 204 allocs/op -BenchmarkNextFilteredUntil-4 100000 19869 ns/op 5909 B/op 177 allocs/op -BenchmarkNextFilteredUntilSelection-4 30000 45412 ns/op 20557 B/op 571 allocs/op -BenchmarkNextFilteredUntilNodes-4 30000 45363 ns/op 20557 B/op 571 allocs/op -BenchmarkPrevFilteredUntil-4 100000 19357 ns/op 6033 B/op 179 allocs/op -BenchmarkPrevFilteredUntilSelection-4 30000 46396 ns/op 21305 B/op 591 allocs/op -BenchmarkPrevFilteredUntilNodes-4 30000 46133 ns/op 21305 B/op 591 allocs/op -BenchmarkClosest-4 500000 3448 ns/op 160 B/op 8 allocs/op -BenchmarkClosestSelection-4 3000000 528 ns/op 96 B/op 6 allocs/op -BenchmarkClosestNodes-4 3000000 523 ns/op 96 B/op 6 allocs/op -PASS -ok github.com/PuerkitoBio/goquery 162.012s diff --git a/vendor/github.com/PuerkitoBio/goquery/bench/v1.0.1c-go1.7 b/vendor/github.com/PuerkitoBio/goquery/bench/v1.0.1c-go1.7 deleted file mode 100644 index e522e5a2d..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench/v1.0.1c-go1.7 +++ /dev/null @@ -1,86 +0,0 @@ -BenchmarkFirst-4 30000000 51.7 ns/op 48 B/op 1 allocs/op -BenchmarkLast-4 30000000 51.9 ns/op 48 B/op 1 allocs/op -BenchmarkEq-4 30000000 50.0 ns/op 48 B/op 1 allocs/op -BenchmarkSlice-4 500000000 3.47 ns/op 0 B/op 0 allocs/op -BenchmarkGet-4 2000000000 1.68 ns/op 0 B/op 0 allocs/op -BenchmarkIndex-4 2000000 804 ns/op 248 B/op 10 allocs/op -BenchmarkIndexSelector-4 100000 16285 ns/op 3839 B/op 21 allocs/op -BenchmarkIndexOfNode-4 200000000 6.50 ns/op 0 B/op 0 allocs/op -BenchmarkIndexOfSelection-4 200000000 7.02 ns/op 0 B/op 0 allocs/op -BenchmarkMetalReviewExample-4 10000 143160 ns/op 12417 B/op 320 allocs/op -BenchmarkAdd-4 200000 10326 ns/op 208 B/op 9 allocs/op -BenchmarkAddSelection-4 10000000 155 ns/op 48 B/op 1 allocs/op -BenchmarkAddNodes-4 10000000 156 ns/op 48 B/op 1 allocs/op -BenchmarkAddNodesBig-4 20000 94439 ns/op 21847 B/op 37 allocs/op -BenchmarkAndSelf-4 1000000 1791 ns/op 1008 B/op 5 allocs/op -BenchmarkFilter-4 100000 19470 ns/op 360 B/op 8 allocs/op -BenchmarkNot-4 100000 22500 ns/op 136 B/op 5 allocs/op -BenchmarkFilterFunction-4 50000 34578 ns/op 22976 B/op 755 allocs/op -BenchmarkNotFunction-4 50000 38703 ns/op 29120 B/op 757 allocs/op -BenchmarkFilterNodes-4 50000 34486 ns/op 20960 B/op 749 allocs/op -BenchmarkNotNodes-4 30000 41094 ns/op 29120 B/op 757 allocs/op -BenchmarkFilterSelection-4 50000 33623 ns/op 20960 B/op 749 allocs/op -BenchmarkNotSelection-4 30000 41483 ns/op 29120 B/op 757 allocs/op -BenchmarkHas-4 5000 266628 ns/op 2371 B/op 50 allocs/op -BenchmarkHasNodes-4 10000 152617 ns/op 21184 B/op 752 allocs/op -BenchmarkHasSelection-4 10000 156682 ns/op 21184 B/op 752 allocs/op -BenchmarkEnd-4 2000000000 1.00 ns/op 0 B/op 0 allocs/op -BenchmarkEach-4 300000 4712 ns/op 3304 B/op 118 allocs/op -BenchmarkMap-4 200000 8434 ns/op 5572 B/op 184 allocs/op -BenchmarkEachWithBreak-4 2000000 819 ns/op 560 B/op 20 allocs/op -BenchmarkAttr-4 100000000 21.7 ns/op 0 B/op 0 allocs/op -BenchmarkText-4 200000 9376 ns/op 7536 B/op 110 allocs/op -BenchmarkLength-4 2000000000 0.35 ns/op 0 B/op 0 allocs/op -BenchmarkHtml-4 5000000 401 ns/op 120 B/op 2 allocs/op -BenchmarkIs-4 100000 22214 ns/op 88 B/op 4 allocs/op -BenchmarkIsPositional-4 50000 26559 ns/op 1112 B/op 10 allocs/op -BenchmarkIsFunction-4 1000000 1228 ns/op 784 B/op 28 allocs/op -BenchmarkIsSelection-4 50000 33471 ns/op 20960 B/op 749 allocs/op -BenchmarkIsNodes-4 50000 34461 ns/op 20960 B/op 749 allocs/op -BenchmarkHasClass-4 10000 232429 ns/op 14944 B/op 976 allocs/op -BenchmarkContains-4 200000000 7.62 ns/op 0 B/op 0 allocs/op -BenchmarkFind-4 100000 16114 ns/op 3839 B/op 21 allocs/op -BenchmarkFindWithinSelection-4 30000 42520 ns/op 3540 B/op 82 allocs/op -BenchmarkFindSelection-4 10000 209801 ns/op 5615 B/op 89 allocs/op -BenchmarkFindNodes-4 10000 209082 ns/op 5614 B/op 89 allocs/op -BenchmarkContents-4 300000 4836 ns/op 1420 B/op 36 allocs/op -BenchmarkContentsFiltered-4 200000 5495 ns/op 1570 B/op 41 allocs/op -BenchmarkChildren-4 3000000 527 ns/op 152 B/op 7 allocs/op -BenchmarkChildrenFiltered-4 500000 2499 ns/op 352 B/op 15 allocs/op -BenchmarkParent-4 50000 34072 ns/op 6942 B/op 387 allocs/op -BenchmarkParentFiltered-4 50000 36077 ns/op 7141 B/op 394 allocs/op -BenchmarkParents-4 20000 64118 ns/op 30719 B/op 837 allocs/op -BenchmarkParentsFiltered-4 20000 63432 ns/op 31303 B/op 845 allocs/op -BenchmarkParentsUntil-4 50000 29589 ns/op 11829 B/op 358 allocs/op -BenchmarkParentsUntilSelection-4 10000 101033 ns/op 54076 B/op 1523 allocs/op -BenchmarkParentsUntilNodes-4 10000 100584 ns/op 54076 B/op 1523 allocs/op -BenchmarkParentsFilteredUntil-4 200000 8061 ns/op 2787 B/op 88 allocs/op -BenchmarkParentsFilteredUntilSelection-4 100000 13848 ns/op 5995 B/op 192 allocs/op -BenchmarkParentsFilteredUntilNodes-4 100000 13766 ns/op 5995 B/op 192 allocs/op -BenchmarkSiblings-4 20000 75135 ns/op 28453 B/op 225 allocs/op -BenchmarkSiblingsFiltered-4 20000 80532 ns/op 29544 B/op 234 allocs/op -BenchmarkNext-4 100000 14200 ns/op 4660 B/op 117 allocs/op -BenchmarkNextFiltered-4 100000 15284 ns/op 4859 B/op 123 allocs/op -BenchmarkNextAll-4 20000 60889 ns/op 22774 B/op 157 allocs/op -BenchmarkNextAllFiltered-4 20000 65125 ns/op 23869 B/op 166 allocs/op -BenchmarkPrev-4 100000 14448 ns/op 4659 B/op 117 allocs/op -BenchmarkPrevFiltered-4 100000 15444 ns/op 4859 B/op 123 allocs/op -BenchmarkPrevAll-4 100000 22019 ns/op 7344 B/op 120 allocs/op -BenchmarkPrevAllFiltered-4 100000 23307 ns/op 7545 B/op 126 allocs/op -BenchmarkNextUntil-4 50000 30287 ns/op 8766 B/op 267 allocs/op -BenchmarkNextUntilSelection-4 30000 41476 ns/op 19862 B/op 546 allocs/op -BenchmarkNextUntilNodes-4 100000 16106 ns/op 8133 B/op 249 allocs/op -BenchmarkPrevUntil-4 20000 98951 ns/op 25728 B/op 467 allocs/op -BenchmarkPrevUntilSelection-4 30000 52390 ns/op 24875 B/op 694 allocs/op -BenchmarkPrevUntilNodes-4 100000 12986 ns/op 6334 B/op 204 allocs/op -BenchmarkNextFilteredUntil-4 100000 19365 ns/op 5908 B/op 177 allocs/op -BenchmarkNextFilteredUntilSelection-4 30000 45334 ns/op 20555 B/op 571 allocs/op -BenchmarkNextFilteredUntilNodes-4 30000 45292 ns/op 20556 B/op 571 allocs/op -BenchmarkPrevFilteredUntil-4 100000 19412 ns/op 6032 B/op 179 allocs/op -BenchmarkPrevFilteredUntilSelection-4 30000 46286 ns/op 21304 B/op 591 allocs/op -BenchmarkPrevFilteredUntilNodes-4 30000 46554 ns/op 21305 B/op 591 allocs/op -BenchmarkClosest-4 500000 3480 ns/op 160 B/op 8 allocs/op -BenchmarkClosestSelection-4 2000000 722 ns/op 96 B/op 6 allocs/op -BenchmarkClosestNodes-4 2000000 719 ns/op 96 B/op 6 allocs/op -PASS -ok github.com/PuerkitoBio/goquery 160.565s diff --git a/vendor/github.com/PuerkitoBio/goquery/bench_array_test.go b/vendor/github.com/PuerkitoBio/goquery/bench_array_test.go deleted file mode 100644 index 29c7e205d..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench_array_test.go +++ /dev/null @@ -1,120 +0,0 @@ -package goquery - -import ( - "testing" -) - -func BenchmarkFirst(b *testing.B) { - b.StopTimer() - sel := DocB().Find("dd") - b.StartTimer() - for i := 0; i < b.N; i++ { - sel.First() - } -} - -func BenchmarkLast(b *testing.B) { - b.StopTimer() - sel := DocB().Find("dd") - b.StartTimer() - for i := 0; i < b.N; i++ { - sel.Last() - } -} - -func BenchmarkEq(b *testing.B) { - b.StopTimer() - sel := DocB().Find("dd") - j := 0 - b.StartTimer() - for i := 0; i < b.N; i++ { - sel.Eq(j) - if j++; j >= sel.Length() { - j = 0 - } - } -} - -func BenchmarkSlice(b *testing.B) { - b.StopTimer() - sel := DocB().Find("dd") - j := 0 - b.StartTimer() - for i := 0; i < b.N; i++ { - sel.Slice(j, j+4) - if j++; j >= (sel.Length() - 4) { - j = 0 - } - } -} - -func BenchmarkGet(b *testing.B) { - b.StopTimer() - sel := DocB().Find("dd") - j := 0 - b.StartTimer() - for i := 0; i < b.N; i++ { - sel.Get(j) - if j++; j >= sel.Length() { - j = 0 - } - } -} - -func BenchmarkIndex(b *testing.B) { - var j int - - b.StopTimer() - sel := DocB().Find("#Main") - b.StartTimer() - for i := 0; i < b.N; i++ { - j = sel.Index() - } - if j != 3 { - b.Fatalf("want 3, got %d", j) - } -} - -func BenchmarkIndexSelector(b *testing.B) { - var j int - - b.StopTimer() - sel := DocB().Find("#manual-nav dl dd:nth-child(1)") - b.StartTimer() - for i := 0; i < b.N; i++ { - j = sel.IndexSelector("dd") - } - if j != 4 { - b.Fatalf("want 4, got %d", j) - } -} - -func BenchmarkIndexOfNode(b *testing.B) { - var j int - - b.StopTimer() - sel := DocB().Find("span a") - sel2 := DocB().Find("span a:nth-child(3)") - n := sel2.Get(0) - b.StartTimer() - for i := 0; i < b.N; i++ { - j = sel.IndexOfNode(n) - } - if j != 2 { - b.Fatalf("want 2, got %d", j) - } -} - -func BenchmarkIndexOfSelection(b *testing.B) { - var j int - b.StopTimer() - sel := DocB().Find("span a") - sel2 := DocB().Find("span a:nth-child(3)") - b.StartTimer() - for i := 0; i < b.N; i++ { - j = sel.IndexOfSelection(sel2) - } - if j != 2 { - b.Fatalf("want 2, got %d", j) - } -} diff --git a/vendor/github.com/PuerkitoBio/goquery/bench_example_test.go b/vendor/github.com/PuerkitoBio/goquery/bench_example_test.go deleted file mode 100644 index ba9ebe5c0..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench_example_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package goquery - -import ( - "bytes" - "fmt" - "strconv" - "testing" -) - -func BenchmarkMetalReviewExample(b *testing.B) { - var n int - var buf bytes.Buffer - - b.StopTimer() - doc := loadDoc("metalreview.html") - b.StartTimer() - for i := 0; i < b.N; i++ { - doc.Find(".slider-row:nth-child(1) .slider-item").Each(func(i int, s *Selection) { - var band, title string - var score float64 - var e error - - n++ - // For each item found, get the band, title and score, and print it - band = s.Find("strong").Text() - title = s.Find("em").Text() - if score, e = strconv.ParseFloat(s.Find(".score").Text(), 64); e != nil { - // Not a valid float, ignore score - if n <= 4 { - buf.WriteString(fmt.Sprintf("Review %d: %s - %s.\n", i, band, title)) - } - } else { - // Print all, including score - if n <= 4 { - buf.WriteString(fmt.Sprintf("Review %d: %s - %s (%2.1f).\n", i, band, title, score)) - } - } - }) - } -} diff --git a/vendor/github.com/PuerkitoBio/goquery/bench_expand_test.go b/vendor/github.com/PuerkitoBio/goquery/bench_expand_test.go deleted file mode 100644 index 61f194753..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench_expand_test.go +++ /dev/null @@ -1,104 +0,0 @@ -package goquery - -import ( - "testing" -) - -func BenchmarkAdd(b *testing.B) { - var n int - - b.StopTimer() - sel := DocB().Find("dd") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.Add("h2[title]").Length() - } else { - sel.Add("h2[title]") - } - } - if n != 43 { - b.Fatalf("want 43, got %d", n) - } -} - -func BenchmarkAddSelection(b *testing.B) { - var n int - - b.StopTimer() - sel := DocB().Find("dd") - sel2 := DocB().Find("h2[title]") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.AddSelection(sel2).Length() - } else { - sel.AddSelection(sel2) - } - } - if n != 43 { - b.Fatalf("want 43, got %d", n) - } -} - -func BenchmarkAddNodes(b *testing.B) { - var n int - - b.StopTimer() - sel := DocB().Find("dd") - sel2 := DocB().Find("h2[title]") - nodes := sel2.Nodes - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.AddNodes(nodes...).Length() - } else { - sel.AddNodes(nodes...) - } - } - if n != 43 { - b.Fatalf("want 43, got %d", n) - } -} - -func BenchmarkAddNodesBig(b *testing.B) { - var n int - - doc := DocW() - sel := doc.Find("li") - // make nodes > 1000 - nodes := sel.Nodes - nodes = append(nodes, nodes...) - nodes = append(nodes, nodes...) - sel = doc.Find("xyz") - b.ResetTimer() - - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.AddNodes(nodes...).Length() - } else { - sel.AddNodes(nodes...) - } - } - if n != 373 { - b.Fatalf("want 373, got %d", n) - } -} - -func BenchmarkAndSelf(b *testing.B) { - var n int - - b.StopTimer() - sel := DocB().Find("dd").Parent() - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.AndSelf().Length() - } else { - sel.AndSelf() - } - } - if n != 44 { - b.Fatalf("want 44, got %d", n) - } -} diff --git a/vendor/github.com/PuerkitoBio/goquery/bench_filter_test.go b/vendor/github.com/PuerkitoBio/goquery/bench_filter_test.go deleted file mode 100644 index 61641c8f4..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench_filter_test.go +++ /dev/null @@ -1,236 +0,0 @@ -package goquery - -import ( - "testing" -) - -func BenchmarkFilter(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.Filter(".toclevel-1").Length() - } else { - sel.Filter(".toclevel-1") - } - } - if n != 13 { - b.Fatalf("want 13, got %d", n) - } -} - -func BenchmarkNot(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.Not(".toclevel-2").Length() - } else { - sel.Filter(".toclevel-2") - } - } - if n != 371 { - b.Fatalf("want 371, got %d", n) - } -} - -func BenchmarkFilterFunction(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li") - f := func(i int, s *Selection) bool { - return len(s.Get(0).Attr) > 0 - } - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.FilterFunction(f).Length() - } else { - sel.FilterFunction(f) - } - } - if n != 112 { - b.Fatalf("want 112, got %d", n) - } -} - -func BenchmarkNotFunction(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li") - f := func(i int, s *Selection) bool { - return len(s.Get(0).Attr) > 0 - } - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.NotFunction(f).Length() - } else { - sel.NotFunction(f) - } - } - if n != 261 { - b.Fatalf("want 261, got %d", n) - } -} - -func BenchmarkFilterNodes(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li") - sel2 := DocW().Find(".toclevel-2") - nodes := sel2.Nodes - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.FilterNodes(nodes...).Length() - } else { - sel.FilterNodes(nodes...) - } - } - if n != 2 { - b.Fatalf("want 2, got %d", n) - } -} - -func BenchmarkNotNodes(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li") - sel2 := DocW().Find(".toclevel-1") - nodes := sel2.Nodes - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.NotNodes(nodes...).Length() - } else { - sel.NotNodes(nodes...) - } - } - if n != 360 { - b.Fatalf("want 360, got %d", n) - } -} - -func BenchmarkFilterSelection(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li") - sel2 := DocW().Find(".toclevel-2") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.FilterSelection(sel2).Length() - } else { - sel.FilterSelection(sel2) - } - } - if n != 2 { - b.Fatalf("want 2, got %d", n) - } -} - -func BenchmarkNotSelection(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li") - sel2 := DocW().Find(".toclevel-1") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.NotSelection(sel2).Length() - } else { - sel.NotSelection(sel2) - } - } - if n != 360 { - b.Fatalf("want 360, got %d", n) - } -} - -func BenchmarkHas(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("h2") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.Has(".editsection").Length() - } else { - sel.Has(".editsection") - } - } - if n != 13 { - b.Fatalf("want 13, got %d", n) - } -} - -func BenchmarkHasNodes(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li") - sel2 := DocW().Find(".tocnumber") - nodes := sel2.Nodes - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.HasNodes(nodes...).Length() - } else { - sel.HasNodes(nodes...) - } - } - if n != 15 { - b.Fatalf("want 15, got %d", n) - } -} - -func BenchmarkHasSelection(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li") - sel2 := DocW().Find(".tocnumber") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.HasSelection(sel2).Length() - } else { - sel.HasSelection(sel2) - } - } - if n != 15 { - b.Fatalf("want 15, got %d", n) - } -} - -func BenchmarkEnd(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li").Has(".tocnumber") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.End().Length() - } else { - sel.End() - } - } - if n != 373 { - b.Fatalf("wnat 373, got %d", n) - } -} diff --git a/vendor/github.com/PuerkitoBio/goquery/bench_iteration_test.go b/vendor/github.com/PuerkitoBio/goquery/bench_iteration_test.go deleted file mode 100644 index 39445b0a6..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench_iteration_test.go +++ /dev/null @@ -1,68 +0,0 @@ -package goquery - -import ( - "testing" -) - -func BenchmarkEach(b *testing.B) { - var tmp, n int - - b.StopTimer() - sel := DocW().Find("td") - f := func(i int, s *Selection) { - tmp++ - } - b.StartTimer() - for i := 0; i < b.N; i++ { - sel.Each(f) - if n == 0 { - n = tmp - } - } - if n != 59 { - b.Fatalf("want 59, got %d", n) - } -} - -func BenchmarkMap(b *testing.B) { - var tmp, n int - - b.StopTimer() - sel := DocW().Find("td") - f := func(i int, s *Selection) string { - tmp++ - return string(tmp) - } - b.StartTimer() - for i := 0; i < b.N; i++ { - sel.Map(f) - if n == 0 { - n = tmp - } - } - if n != 59 { - b.Fatalf("want 59, got %d", n) - } -} - -func BenchmarkEachWithBreak(b *testing.B) { - var tmp, n int - - b.StopTimer() - sel := DocW().Find("td") - f := func(i int, s *Selection) bool { - tmp++ - return tmp < 10 - } - b.StartTimer() - for i := 0; i < b.N; i++ { - tmp = 0 - sel.EachWithBreak(f) - if n == 0 { - n = tmp - } - } - if n != 10 { - b.Fatalf("want 10, got %d", n) - } -} diff --git a/vendor/github.com/PuerkitoBio/goquery/bench_property_test.go b/vendor/github.com/PuerkitoBio/goquery/bench_property_test.go deleted file mode 100644 index 8acf5bfc7..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench_property_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package goquery - -import ( - "testing" -) - -func BenchmarkAttr(b *testing.B) { - var s string - - b.StopTimer() - sel := DocW().Find("h1") - b.StartTimer() - for i := 0; i < b.N; i++ { - s, _ = sel.Attr("id") - } - if s != "firstHeading" { - b.Fatalf("want firstHeading, got %q", s) - } -} - -func BenchmarkText(b *testing.B) { - b.StopTimer() - sel := DocW().Find("h2") - b.StartTimer() - for i := 0; i < b.N; i++ { - sel.Text() - } -} - -func BenchmarkLength(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("h2") - b.StartTimer() - for i := 0; i < b.N; i++ { - n = sel.Length() - } - if n != 14 { - b.Fatalf("want 14, got %d", n) - } -} - -func BenchmarkHtml(b *testing.B) { - b.StopTimer() - sel := DocW().Find("h2") - b.StartTimer() - for i := 0; i < b.N; i++ { - sel.Html() - } -} diff --git a/vendor/github.com/PuerkitoBio/goquery/bench_query_test.go b/vendor/github.com/PuerkitoBio/goquery/bench_query_test.go deleted file mode 100644 index 64fdbc4bd..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench_query_test.go +++ /dev/null @@ -1,111 +0,0 @@ -package goquery - -import ( - "testing" -) - -func BenchmarkIs(b *testing.B) { - var y bool - - b.StopTimer() - sel := DocW().Find("li") - b.StartTimer() - for i := 0; i < b.N; i++ { - y = sel.Is(".toclevel-2") - } - if !y { - b.Fatal("want true") - } -} - -func BenchmarkIsPositional(b *testing.B) { - var y bool - - b.StopTimer() - sel := DocW().Find("li") - b.StartTimer() - for i := 0; i < b.N; i++ { - y = sel.Is("li:nth-child(2)") - } - if !y { - b.Fatal("want true") - } -} - -func BenchmarkIsFunction(b *testing.B) { - var y bool - - b.StopTimer() - sel := DocW().Find(".toclevel-1") - f := func(i int, s *Selection) bool { - return i == 8 - } - b.StartTimer() - for i := 0; i < b.N; i++ { - y = sel.IsFunction(f) - } - if !y { - b.Fatal("want true") - } -} - -func BenchmarkIsSelection(b *testing.B) { - var y bool - - b.StopTimer() - sel := DocW().Find("li") - sel2 := DocW().Find(".toclevel-2") - b.StartTimer() - for i := 0; i < b.N; i++ { - y = sel.IsSelection(sel2) - } - if !y { - b.Fatal("want true") - } -} - -func BenchmarkIsNodes(b *testing.B) { - var y bool - - b.StopTimer() - sel := DocW().Find("li") - sel2 := DocW().Find(".toclevel-2") - nodes := sel2.Nodes - b.StartTimer() - for i := 0; i < b.N; i++ { - y = sel.IsNodes(nodes...) - } - if !y { - b.Fatal("want true") - } -} - -func BenchmarkHasClass(b *testing.B) { - var y bool - - b.StopTimer() - sel := DocW().Find("span") - b.StartTimer() - for i := 0; i < b.N; i++ { - y = sel.HasClass("official") - } - if !y { - b.Fatal("want true") - } -} - -func BenchmarkContains(b *testing.B) { - var y bool - - b.StopTimer() - sel := DocW().Find("span.url") - sel2 := DocW().Find("a[rel=\"nofollow\"]") - node := sel2.Nodes[0] - b.StartTimer() - for i := 0; i < b.N; i++ { - y = sel.Contains(node) - } - if !y { - b.Fatal("want true") - } -} diff --git a/vendor/github.com/PuerkitoBio/goquery/bench_traversal_test.go b/vendor/github.com/PuerkitoBio/goquery/bench_traversal_test.go deleted file mode 100644 index de84bcdff..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/bench_traversal_test.go +++ /dev/null @@ -1,802 +0,0 @@ -package goquery - -import ( - "testing" -) - -func BenchmarkFind(b *testing.B) { - var n int - - for i := 0; i < b.N; i++ { - if n == 0 { - n = DocB().Find("dd").Length() - - } else { - DocB().Find("dd") - } - } - if n != 41 { - b.Fatalf("want 41, got %d", n) - } -} - -func BenchmarkFindWithinSelection(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("ul") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.Find("a[class]").Length() - } else { - sel.Find("a[class]") - } - } - if n != 39 { - b.Fatalf("want 39, got %d", n) - } -} - -func BenchmarkFindSelection(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("ul") - sel2 := DocW().Find("span") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.FindSelection(sel2).Length() - } else { - sel.FindSelection(sel2) - } - } - if n != 73 { - b.Fatalf("want 73, got %d", n) - } -} - -func BenchmarkFindNodes(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("ul") - sel2 := DocW().Find("span") - nodes := sel2.Nodes - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.FindNodes(nodes...).Length() - } else { - sel.FindNodes(nodes...) - } - } - if n != 73 { - b.Fatalf("want 73, got %d", n) - } -} - -func BenchmarkContents(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find(".toclevel-1") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.Contents().Length() - } else { - sel.Contents() - } - } - if n != 16 { - b.Fatalf("want 16, got %d", n) - } -} - -func BenchmarkContentsFiltered(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find(".toclevel-1") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.ContentsFiltered("a[href=\"#Examples\"]").Length() - } else { - sel.ContentsFiltered("a[href=\"#Examples\"]") - } - } - if n != 1 { - b.Fatalf("want 1, got %d", n) - } -} - -func BenchmarkChildren(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find(".toclevel-2") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.Children().Length() - } else { - sel.Children() - } - } - if n != 2 { - b.Fatalf("want 2, got %d", n) - } -} - -func BenchmarkChildrenFiltered(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("h3") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.ChildrenFiltered(".editsection").Length() - } else { - sel.ChildrenFiltered(".editsection") - } - } - if n != 2 { - b.Fatalf("want 2, got %d", n) - } -} - -func BenchmarkParent(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.Parent().Length() - } else { - sel.Parent() - } - } - if n != 55 { - b.Fatalf("want 55, got %d", n) - } -} - -func BenchmarkParentFiltered(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.ParentFiltered("ul[id]").Length() - } else { - sel.ParentFiltered("ul[id]") - } - } - if n != 4 { - b.Fatalf("want 4, got %d", n) - } -} - -func BenchmarkParents(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("th a") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.Parents().Length() - } else { - sel.Parents() - } - } - if n != 73 { - b.Fatalf("want 73, got %d", n) - } -} - -func BenchmarkParentsFiltered(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("th a") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.ParentsFiltered("tr").Length() - } else { - sel.ParentsFiltered("tr") - } - } - if n != 18 { - b.Fatalf("want 18, got %d", n) - } -} - -func BenchmarkParentsUntil(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("th a") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.ParentsUntil("table").Length() - } else { - sel.ParentsUntil("table") - } - } - if n != 52 { - b.Fatalf("want 52, got %d", n) - } -} - -func BenchmarkParentsUntilSelection(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("th a") - sel2 := DocW().Find("#content") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.ParentsUntilSelection(sel2).Length() - } else { - sel.ParentsUntilSelection(sel2) - } - } - if n != 70 { - b.Fatalf("want 70, got %d", n) - } -} - -func BenchmarkParentsUntilNodes(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("th a") - sel2 := DocW().Find("#content") - nodes := sel2.Nodes - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.ParentsUntilNodes(nodes...).Length() - } else { - sel.ParentsUntilNodes(nodes...) - } - } - if n != 70 { - b.Fatalf("want 70, got %d", n) - } -} - -func BenchmarkParentsFilteredUntil(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find(".toclevel-1 a") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.ParentsFilteredUntil(":nth-child(1)", "ul").Length() - } else { - sel.ParentsFilteredUntil(":nth-child(1)", "ul") - } - } - if n != 2 { - b.Fatalf("want 2, got %d", n) - } -} - -func BenchmarkParentsFilteredUntilSelection(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find(".toclevel-1 a") - sel2 := DocW().Find("ul") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.ParentsFilteredUntilSelection(":nth-child(1)", sel2).Length() - } else { - sel.ParentsFilteredUntilSelection(":nth-child(1)", sel2) - } - } - if n != 2 { - b.Fatalf("want 2, got %d", n) - } -} - -func BenchmarkParentsFilteredUntilNodes(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find(".toclevel-1 a") - sel2 := DocW().Find("ul") - nodes := sel2.Nodes - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.ParentsFilteredUntilNodes(":nth-child(1)", nodes...).Length() - } else { - sel.ParentsFilteredUntilNodes(":nth-child(1)", nodes...) - } - } - if n != 2 { - b.Fatalf("want 2, got %d", n) - } -} - -func BenchmarkSiblings(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("ul li:nth-child(1)") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.Siblings().Length() - } else { - sel.Siblings() - } - } - if n != 293 { - b.Fatalf("want 293, got %d", n) - } -} - -func BenchmarkSiblingsFiltered(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("ul li:nth-child(1)") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.SiblingsFiltered("[class]").Length() - } else { - sel.SiblingsFiltered("[class]") - } - } - if n != 46 { - b.Fatalf("want 46, got %d", n) - } -} - -func BenchmarkNext(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li:nth-child(1)") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.Next().Length() - } else { - sel.Next() - } - } - if n != 49 { - b.Fatalf("want 49, got %d", n) - } -} - -func BenchmarkNextFiltered(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li:nth-child(1)") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.NextFiltered("[class]").Length() - } else { - sel.NextFiltered("[class]") - } - } - if n != 6 { - b.Fatalf("want 6, got %d", n) - } -} - -func BenchmarkNextAll(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li:nth-child(3)") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.NextAll().Length() - } else { - sel.NextAll() - } - } - if n != 234 { - b.Fatalf("want 234, got %d", n) - } -} - -func BenchmarkNextAllFiltered(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li:nth-child(3)") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.NextAllFiltered("[class]").Length() - } else { - sel.NextAllFiltered("[class]") - } - } - if n != 33 { - b.Fatalf("want 33, got %d", n) - } -} - -func BenchmarkPrev(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li:last-child") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.Prev().Length() - } else { - sel.Prev() - } - } - if n != 49 { - b.Fatalf("want 49, got %d", n) - } -} - -func BenchmarkPrevFiltered(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li:last-child") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.PrevFiltered("[class]").Length() - } else { - sel.PrevFiltered("[class]") - } - } - // There is one more Prev li with a class, compared to Next li with a class - // (confirmed by looking at the HTML, this is ok) - if n != 7 { - b.Fatalf("want 7, got %d", n) - } -} - -func BenchmarkPrevAll(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li:nth-child(4)") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.PrevAll().Length() - } else { - sel.PrevAll() - } - } - if n != 78 { - b.Fatalf("want 78, got %d", n) - } -} - -func BenchmarkPrevAllFiltered(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li:nth-child(4)") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.PrevAllFiltered("[class]").Length() - } else { - sel.PrevAllFiltered("[class]") - } - } - if n != 6 { - b.Fatalf("want 6, got %d", n) - } -} - -func BenchmarkNextUntil(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li:first-child") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.NextUntil(":nth-child(4)").Length() - } else { - sel.NextUntil(":nth-child(4)") - } - } - if n != 84 { - b.Fatalf("want 84, got %d", n) - } -} - -func BenchmarkNextUntilSelection(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("h2") - sel2 := DocW().Find("ul") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.NextUntilSelection(sel2).Length() - } else { - sel.NextUntilSelection(sel2) - } - } - if n != 42 { - b.Fatalf("want 42, got %d", n) - } -} - -func BenchmarkNextUntilNodes(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("h2") - sel2 := DocW().Find("p") - nodes := sel2.Nodes - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.NextUntilNodes(nodes...).Length() - } else { - sel.NextUntilNodes(nodes...) - } - } - if n != 12 { - b.Fatalf("want 12, got %d", n) - } -} - -func BenchmarkPrevUntil(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("li:last-child") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.PrevUntil(":nth-child(4)").Length() - } else { - sel.PrevUntil(":nth-child(4)") - } - } - if n != 238 { - b.Fatalf("want 238, got %d", n) - } -} - -func BenchmarkPrevUntilSelection(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("h2") - sel2 := DocW().Find("ul") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.PrevUntilSelection(sel2).Length() - } else { - sel.PrevUntilSelection(sel2) - } - } - if n != 49 { - b.Fatalf("want 49, got %d", n) - } -} - -func BenchmarkPrevUntilNodes(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("h2") - sel2 := DocW().Find("p") - nodes := sel2.Nodes - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.PrevUntilNodes(nodes...).Length() - } else { - sel.PrevUntilNodes(nodes...) - } - } - if n != 11 { - b.Fatalf("want 11, got %d", n) - } -} - -func BenchmarkNextFilteredUntil(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("h2") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.NextFilteredUntil("p", "div").Length() - } else { - sel.NextFilteredUntil("p", "div") - } - } - if n != 22 { - b.Fatalf("want 22, got %d", n) - } -} - -func BenchmarkNextFilteredUntilSelection(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("h2") - sel2 := DocW().Find("div") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.NextFilteredUntilSelection("p", sel2).Length() - } else { - sel.NextFilteredUntilSelection("p", sel2) - } - } - if n != 22 { - b.Fatalf("want 22, got %d", n) - } -} - -func BenchmarkNextFilteredUntilNodes(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("h2") - sel2 := DocW().Find("div") - nodes := sel2.Nodes - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.NextFilteredUntilNodes("p", nodes...).Length() - } else { - sel.NextFilteredUntilNodes("p", nodes...) - } - } - if n != 22 { - b.Fatalf("want 22, got %d", n) - } -} - -func BenchmarkPrevFilteredUntil(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("h2") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.PrevFilteredUntil("p", "div").Length() - } else { - sel.PrevFilteredUntil("p", "div") - } - } - if n != 20 { - b.Fatalf("want 20, got %d", n) - } -} - -func BenchmarkPrevFilteredUntilSelection(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("h2") - sel2 := DocW().Find("div") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.PrevFilteredUntilSelection("p", sel2).Length() - } else { - sel.PrevFilteredUntilSelection("p", sel2) - } - } - if n != 20 { - b.Fatalf("want 20, got %d", n) - } -} - -func BenchmarkPrevFilteredUntilNodes(b *testing.B) { - var n int - - b.StopTimer() - sel := DocW().Find("h2") - sel2 := DocW().Find("div") - nodes := sel2.Nodes - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.PrevFilteredUntilNodes("p", nodes...).Length() - } else { - sel.PrevFilteredUntilNodes("p", nodes...) - } - } - if n != 20 { - b.Fatalf("want 20, got %d", n) - } -} - -func BenchmarkClosest(b *testing.B) { - var n int - - b.StopTimer() - sel := Doc().Find(".container-fluid") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.Closest(".pvk-content").Length() - } else { - sel.Closest(".pvk-content") - } - } - if n != 2 { - b.Fatalf("want 2, got %d", n) - } -} - -func BenchmarkClosestSelection(b *testing.B) { - var n int - - b.StopTimer() - sel := Doc().Find(".container-fluid") - sel2 := Doc().Find(".pvk-content") - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.ClosestSelection(sel2).Length() - } else { - sel.ClosestSelection(sel2) - } - } - if n != 2 { - b.Fatalf("want 2, got %d", n) - } -} - -func BenchmarkClosestNodes(b *testing.B) { - var n int - - b.StopTimer() - sel := Doc().Find(".container-fluid") - nodes := Doc().Find(".pvk-content").Nodes - b.StartTimer() - for i := 0; i < b.N; i++ { - if n == 0 { - n = sel.ClosestNodes(nodes...).Length() - } else { - sel.ClosestNodes(nodes...) - } - } - if n != 2 { - b.Fatalf("want 2, got %d", n) - } -} diff --git a/vendor/github.com/PuerkitoBio/goquery/doc/tips.md b/vendor/github.com/PuerkitoBio/goquery/doc/tips.md deleted file mode 100644 index 4e7895285..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/doc/tips.md +++ /dev/null @@ -1,68 +0,0 @@ -# Tips and tricks - -## Handle Non-UTF8 html Pages - -The `go.net/html` package used by `goquery` requires that the html document is UTF-8 encoded. When you know the encoding of the html page is not UTF-8, you can use the `iconv` package to convert it to UTF-8 (there are various implementation of the `iconv` API, see [godoc.org][iconv] for other options): - -``` -$ go get -u github.com/djimenez/iconv-go -``` - -and then: - -``` -// Load the URL -res, err := http.Get(url) -if err != nil { - // handle error -} -defer res.Body.Close() - -// Convert the designated charset HTML to utf-8 encoded HTML. -// `charset` being one of the charsets known by the iconv package. -utfBody, err := iconv.NewReader(res.Body, charset, "utf-8") -if err != nil { - // handler error -} - -// use utfBody using goquery -doc, err := goquery.NewDocumentFromReader(utfBody) -if err != nil { - // handler error -} -// use doc... -``` - -Thanks to github user @YuheiNakasaka. - -Actually, the official go.text repository covers this use case too, see its [godoc page][text] for the details. - - -## Handle Javascript-based Pages - -`goquery` is great to handle normal html pages, but when most of the page is build dynamically using javascript, there's not much it can do. There are various options when faced with this problem: - -* Use a headless browser such as [webloop][]. -* Use a Go javascript parser package, such as [otto][]. - -You can find a code example using `otto` [in this gist][exotto]. Thanks to github user @cryptix. - -## For Loop - -If all you need is a normal `for` loop over all nodes in the current selection, where `Map/Each`-style iteration is not necessary, you can use the following: - -``` -sel := Doc().Find(".selector") -for i := range sel.Nodes { - single := sel.Eq(i) - // use `single` as a selection of 1 node -} -``` - -Thanks to github user @jmoiron. - -[webloop]: https://github.com/sourcegraph/webloop -[otto]: https://github.com/robertkrimen/otto -[exotto]: https://gist.github.com/cryptix/87127f76a94183747b53 -[iconv]: http://godoc.org/?q=iconv -[text]: https://godoc.org/golang.org/x/text/encoding diff --git a/vendor/github.com/PuerkitoBio/goquery/example_test.go b/vendor/github.com/PuerkitoBio/goquery/example_test.go deleted file mode 100644 index 17b2354d0..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/example_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package goquery_test - -import ( - "fmt" - "log" - - "github.com/PuerkitoBio/goquery" -) - -// This example scrapes the reviews shown on the home page of metalsucks.net. -func Example() { - // Load the HTML document - doc, err := goquery.NewDocument("http://metalsucks.net") - if err != nil { - log.Fatal(err) - } - - // Find the review items - doc.Find(".sidebar-reviews article .content-block").Each(func(i int, s *goquery.Selection) { - // For each item found, get the band and title - band := s.Find("a").Text() - title := s.Find("i").Text() - fmt.Printf("Review %d: %s - %s\n", i, band, title) - }) - // To see the output of the Example while running the test suite (go test), simply - // remove the leading "x" before Output on the next line. This will cause the - // example to fail (all the "real" tests should pass). - - // xOutput: voluntarily fail the Example output. -} diff --git a/vendor/github.com/PuerkitoBio/goquery/expand_test.go b/vendor/github.com/PuerkitoBio/goquery/expand_test.go deleted file mode 100644 index 4557025d4..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/expand_test.go +++ /dev/null @@ -1,96 +0,0 @@ -package goquery - -import ( - "testing" -) - -func TestAdd(t *testing.T) { - sel := Doc().Find("div.row-fluid").Add("a") - assertLength(t, sel.Nodes, 19) -} - -func TestAddInvalid(t *testing.T) { - sel1 := Doc().Find("div.row-fluid") - sel2 := sel1.Add("") - assertLength(t, sel1.Nodes, 9) - assertLength(t, sel2.Nodes, 9) - if sel1 == sel2 { - t.Errorf("selections should not be the same") - } -} - -func TestAddRollback(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.Add("a").End() - assertEqual(t, sel, sel2) -} - -func TestAddSelection(t *testing.T) { - sel := Doc().Find("div.row-fluid") - sel2 := Doc().Find("a") - sel = sel.AddSelection(sel2) - assertLength(t, sel.Nodes, 19) -} - -func TestAddSelectionNil(t *testing.T) { - sel := Doc().Find("div.row-fluid") - assertLength(t, sel.Nodes, 9) - - sel = sel.AddSelection(nil) - assertLength(t, sel.Nodes, 9) -} - -func TestAddSelectionRollback(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.Find("a") - sel2 = sel.AddSelection(sel2).End() - assertEqual(t, sel, sel2) -} - -func TestAddNodes(t *testing.T) { - sel := Doc().Find("div.pvk-gutter") - sel2 := Doc().Find(".pvk-content") - sel = sel.AddNodes(sel2.Nodes...) - assertLength(t, sel.Nodes, 9) -} - -func TestAddNodesNone(t *testing.T) { - sel := Doc().Find("div.pvk-gutter").AddNodes() - assertLength(t, sel.Nodes, 6) -} - -func TestAddNodesRollback(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.Find("a") - sel2 = sel.AddNodes(sel2.Nodes...).End() - assertEqual(t, sel, sel2) -} - -func TestAddNodesBig(t *testing.T) { - doc := DocW() - sel := doc.Find("li") - assertLength(t, sel.Nodes, 373) - sel2 := doc.Find("xyz") - assertLength(t, sel2.Nodes, 0) - - nodes := sel.Nodes - sel2 = sel2.AddNodes(nodes...) - assertLength(t, sel2.Nodes, 373) - nodes2 := append(nodes, nodes...) - sel2 = sel2.End().AddNodes(nodes2...) - assertLength(t, sel2.Nodes, 373) - nodes3 := append(nodes2, nodes...) - sel2 = sel2.End().AddNodes(nodes3...) - assertLength(t, sel2.Nodes, 373) -} - -func TestAndSelf(t *testing.T) { - sel := Doc().Find(".span12").Last().AndSelf() - assertLength(t, sel.Nodes, 2) -} - -func TestAndSelfRollback(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.Find("a").AndSelf().End().End() - assertEqual(t, sel, sel2) -} diff --git a/vendor/github.com/PuerkitoBio/goquery/filter_test.go b/vendor/github.com/PuerkitoBio/goquery/filter_test.go deleted file mode 100644 index f663c08f6..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/filter_test.go +++ /dev/null @@ -1,206 +0,0 @@ -package goquery - -import ( - "testing" -) - -func TestFilter(t *testing.T) { - sel := Doc().Find(".span12").Filter(".alert") - assertLength(t, sel.Nodes, 1) -} - -func TestFilterNone(t *testing.T) { - sel := Doc().Find(".span12").Filter(".zzalert") - assertLength(t, sel.Nodes, 0) -} - -func TestFilterInvalid(t *testing.T) { - sel := Doc().Find(".span12").Filter("") - assertLength(t, sel.Nodes, 0) -} - -func TestFilterRollback(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.Filter(".alert").End() - assertEqual(t, sel, sel2) -} - -func TestFilterFunction(t *testing.T) { - sel := Doc().Find(".pvk-content").FilterFunction(func(i int, s *Selection) bool { - return i > 0 - }) - assertLength(t, sel.Nodes, 2) -} - -func TestFilterFunctionRollback(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.FilterFunction(func(i int, s *Selection) bool { - return i > 0 - }).End() - assertEqual(t, sel, sel2) -} - -func TestFilterNode(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.FilterNodes(sel.Nodes[2]) - assertLength(t, sel2.Nodes, 1) -} - -func TestFilterNodeRollback(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.FilterNodes(sel.Nodes[2]).End() - assertEqual(t, sel, sel2) -} - -func TestFilterSelection(t *testing.T) { - sel := Doc().Find(".link") - sel2 := Doc().Find("a[ng-click]") - sel3 := sel.FilterSelection(sel2) - assertLength(t, sel3.Nodes, 1) -} - -func TestFilterSelectionRollback(t *testing.T) { - sel := Doc().Find(".link") - sel2 := Doc().Find("a[ng-click]") - sel2 = sel.FilterSelection(sel2).End() - assertEqual(t, sel, sel2) -} - -func TestFilterSelectionNil(t *testing.T) { - var sel2 *Selection - - sel := Doc().Find(".link") - sel3 := sel.FilterSelection(sel2) - assertLength(t, sel3.Nodes, 0) -} - -func TestNot(t *testing.T) { - sel := Doc().Find(".span12").Not(".alert") - assertLength(t, sel.Nodes, 1) -} - -func TestNotInvalid(t *testing.T) { - sel := Doc().Find(".span12").Not("") - assertLength(t, sel.Nodes, 2) -} - -func TestNotRollback(t *testing.T) { - sel := Doc().Find(".span12") - sel2 := sel.Not(".alert").End() - assertEqual(t, sel, sel2) -} - -func TestNotNone(t *testing.T) { - sel := Doc().Find(".span12").Not(".zzalert") - assertLength(t, sel.Nodes, 2) -} - -func TestNotFunction(t *testing.T) { - sel := Doc().Find(".pvk-content").NotFunction(func(i int, s *Selection) bool { - return i > 0 - }) - assertLength(t, sel.Nodes, 1) -} - -func TestNotFunctionRollback(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.NotFunction(func(i int, s *Selection) bool { - return i > 0 - }).End() - assertEqual(t, sel, sel2) -} - -func TestNotNode(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.NotNodes(sel.Nodes[2]) - assertLength(t, sel2.Nodes, 2) -} - -func TestNotNodeRollback(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.NotNodes(sel.Nodes[2]).End() - assertEqual(t, sel, sel2) -} - -func TestNotSelection(t *testing.T) { - sel := Doc().Find(".link") - sel2 := Doc().Find("a[ng-click]") - sel3 := sel.NotSelection(sel2) - assertLength(t, sel3.Nodes, 6) -} - -func TestNotSelectionRollback(t *testing.T) { - sel := Doc().Find(".link") - sel2 := Doc().Find("a[ng-click]") - sel2 = sel.NotSelection(sel2).End() - assertEqual(t, sel, sel2) -} - -func TestIntersection(t *testing.T) { - sel := Doc().Find(".pvk-gutter") - sel2 := Doc().Find("div").Intersection(sel) - assertLength(t, sel2.Nodes, 6) -} - -func TestIntersectionRollback(t *testing.T) { - sel := Doc().Find(".pvk-gutter") - sel2 := Doc().Find("div") - sel2 = sel.Intersection(sel2).End() - assertEqual(t, sel, sel2) -} - -func TestHas(t *testing.T) { - sel := Doc().Find(".container-fluid").Has(".center-content") - assertLength(t, sel.Nodes, 2) - // Has() returns the high-level .container-fluid div, and the one that is the immediate parent of center-content -} - -func TestHasInvalid(t *testing.T) { - sel := Doc().Find(".container-fluid").Has("") - assertLength(t, sel.Nodes, 0) -} - -func TestHasRollback(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := sel.Has(".center-content").End() - assertEqual(t, sel, sel2) -} - -func TestHasNodes(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := Doc().Find(".center-content") - sel = sel.HasNodes(sel2.Nodes...) - assertLength(t, sel.Nodes, 2) - // Has() returns the high-level .container-fluid div, and the one that is the immediate parent of center-content -} - -func TestHasNodesRollback(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := Doc().Find(".center-content") - sel2 = sel.HasNodes(sel2.Nodes...).End() - assertEqual(t, sel, sel2) -} - -func TestHasSelection(t *testing.T) { - sel := Doc().Find("p") - sel2 := Doc().Find("small") - sel = sel.HasSelection(sel2) - assertLength(t, sel.Nodes, 1) -} - -func TestHasSelectionRollback(t *testing.T) { - sel := Doc().Find("p") - sel2 := Doc().Find("small") - sel2 = sel.HasSelection(sel2).End() - assertEqual(t, sel, sel2) -} - -func TestEnd(t *testing.T) { - sel := Doc().Find("p").Has("small").End() - assertLength(t, sel.Nodes, 4) -} - -func TestEndToTop(t *testing.T) { - sel := Doc().Find("p").Has("small").End().End().End() - assertLength(t, sel.Nodes, 0) -} diff --git a/vendor/github.com/PuerkitoBio/goquery/iteration_test.go b/vendor/github.com/PuerkitoBio/goquery/iteration_test.go deleted file mode 100644 index 9b6aafb7b..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/iteration_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package goquery - -import ( - "testing" - - "golang.org/x/net/html" -) - -func TestEach(t *testing.T) { - var cnt int - - sel := Doc().Find(".hero-unit .row-fluid").Each(func(i int, n *Selection) { - cnt++ - t.Logf("At index %v, node %v", i, n.Nodes[0].Data) - }).Find("a") - - if cnt != 4 { - t.Errorf("Expected Each() to call function 4 times, got %v times.", cnt) - } - assertLength(t, sel.Nodes, 6) -} - -func TestEachWithBreak(t *testing.T) { - var cnt int - - sel := Doc().Find(".hero-unit .row-fluid").EachWithBreak(func(i int, n *Selection) bool { - cnt++ - t.Logf("At index %v, node %v", i, n.Nodes[0].Data) - return false - }).Find("a") - - if cnt != 1 { - t.Errorf("Expected Each() to call function 1 time, got %v times.", cnt) - } - assertLength(t, sel.Nodes, 6) -} - -func TestEachEmptySelection(t *testing.T) { - var cnt int - - sel := Doc().Find("zzzz") - sel.Each(func(i int, n *Selection) { - cnt++ - }) - if cnt > 0 { - t.Error("Expected Each() to not be called on empty Selection.") - } - sel2 := sel.Find("div") - assertLength(t, sel2.Nodes, 0) -} - -func TestMap(t *testing.T) { - sel := Doc().Find(".pvk-content") - vals := sel.Map(func(i int, s *Selection) string { - n := s.Get(0) - if n.Type == html.ElementNode { - return n.Data - } - return "" - }) - for _, v := range vals { - if v != "div" { - t.Error("Expected Map array result to be all 'div's.") - } - } - if len(vals) != 3 { - t.Errorf("Expected Map array result to have a length of 3, found %v.", len(vals)) - } -} - -func TestForRange(t *testing.T) { - sel := Doc().Find(".pvk-content") - initLen := sel.Length() - for i := range sel.Nodes { - single := sel.Eq(i) - //h, err := single.Html() - //if err != nil { - // t.Fatal(err) - //} - //fmt.Println(i, h) - if single.Length() != 1 { - t.Errorf("%d: expected length of 1, got %d", i, single.Length()) - } - } - if sel.Length() != initLen { - t.Errorf("expected initial selection to still have length %d, got %d", initLen, sel.Length()) - } -} diff --git a/vendor/github.com/PuerkitoBio/goquery/manipulation_test.go b/vendor/github.com/PuerkitoBio/goquery/manipulation_test.go deleted file mode 100644 index f1c6e3ef9..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/manipulation_test.go +++ /dev/null @@ -1,453 +0,0 @@ -package goquery - -import ( - "testing" -) - -const ( - wrapHtml = "
test string

" -) - -func TestAfter(t *testing.T) { - doc := Doc2Clone() - doc.Find("#main").After("#nf6") - - assertLength(t, doc.Find("#main #nf6").Nodes, 0) - assertLength(t, doc.Find("#foot #nf6").Nodes, 0) - assertLength(t, doc.Find("#main + #nf6").Nodes, 1) - printSel(t, doc.Selection) -} - -func TestAfterMany(t *testing.T) { - doc := Doc2Clone() - doc.Find(".one").After("#nf6") - - assertLength(t, doc.Find("#foot #nf6").Nodes, 1) - assertLength(t, doc.Find("#main #nf6").Nodes, 1) - assertLength(t, doc.Find(".one + #nf6").Nodes, 2) - printSel(t, doc.Selection) -} - -func TestAfterWithRemoved(t *testing.T) { - doc := Doc2Clone() - s := doc.Find("#main").Remove() - s.After("#nf6") - - assertLength(t, s.Find("#nf6").Nodes, 0) - assertLength(t, doc.Find("#nf6").Nodes, 0) - printSel(t, doc.Selection) -} - -func TestAfterSelection(t *testing.T) { - doc := Doc2Clone() - doc.Find("#main").AfterSelection(doc.Find("#nf1, #nf2")) - - assertLength(t, doc.Find("#main #nf1, #main #nf2").Nodes, 0) - assertLength(t, doc.Find("#foot #nf1, #foot #nf2").Nodes, 0) - assertLength(t, doc.Find("#main + #nf1, #nf1 + #nf2").Nodes, 2) - printSel(t, doc.Selection) -} - -func TestAfterHtml(t *testing.T) { - doc := Doc2Clone() - doc.Find("#main").AfterHtml("new node") - - assertLength(t, doc.Find("#main + strong").Nodes, 1) - printSel(t, doc.Selection) -} - -func TestAppend(t *testing.T) { - doc := Doc2Clone() - doc.Find("#main").Append("#nf6") - - assertLength(t, doc.Find("#foot #nf6").Nodes, 0) - assertLength(t, doc.Find("#main #nf6").Nodes, 1) - printSel(t, doc.Selection) -} - -func TestAppendBody(t *testing.T) { - doc := Doc2Clone() - doc.Find("body").Append("#nf6") - - assertLength(t, doc.Find("#foot #nf6").Nodes, 0) - assertLength(t, doc.Find("#main #nf6").Nodes, 0) - assertLength(t, doc.Find("body > #nf6").Nodes, 1) - printSel(t, doc.Selection) -} - -func TestAppendSelection(t *testing.T) { - doc := Doc2Clone() - doc.Find("#main").AppendSelection(doc.Find("#nf1, #nf2")) - - assertLength(t, doc.Find("#foot #nf1").Nodes, 0) - assertLength(t, doc.Find("#foot #nf2").Nodes, 0) - assertLength(t, doc.Find("#main #nf1").Nodes, 1) - assertLength(t, doc.Find("#main #nf2").Nodes, 1) - printSel(t, doc.Selection) -} - -func TestAppendSelectionExisting(t *testing.T) { - doc := Doc2Clone() - doc.Find("#main").AppendSelection(doc.Find("#n1, #n2")) - - assertClass(t, doc.Find("#main :nth-child(1)"), "three") - assertClass(t, doc.Find("#main :nth-child(5)"), "one") - assertClass(t, doc.Find("#main :nth-child(6)"), "two") - printSel(t, doc.Selection) -} - -func TestAppendClone(t *testing.T) { - doc := Doc2Clone() - doc.Find("#n1").AppendSelection(doc.Find("#nf1").Clone()) - - assertLength(t, doc.Find("#foot #nf1").Nodes, 1) - assertLength(t, doc.Find("#main #nf1").Nodes, 1) - printSel(t, doc.Selection) -} - -func TestAppendHtml(t *testing.T) { - doc := Doc2Clone() - doc.Find("div").AppendHtml("new node") - - assertLength(t, doc.Find("strong").Nodes, 14) - printSel(t, doc.Selection) -} - -func TestBefore(t *testing.T) { - doc := Doc2Clone() - doc.Find("#main").Before("#nf6") - - assertLength(t, doc.Find("#main #nf6").Nodes, 0) - assertLength(t, doc.Find("#foot #nf6").Nodes, 0) - assertLength(t, doc.Find("body > #nf6:first-child").Nodes, 1) - printSel(t, doc.Selection) -} - -func TestBeforeWithRemoved(t *testing.T) { - doc := Doc2Clone() - s := doc.Find("#main").Remove() - s.Before("#nf6") - - assertLength(t, s.Find("#nf6").Nodes, 0) - assertLength(t, doc.Find("#nf6").Nodes, 0) - printSel(t, doc.Selection) -} - -func TestBeforeSelection(t *testing.T) { - doc := Doc2Clone() - doc.Find("#main").BeforeSelection(doc.Find("#nf1, #nf2")) - - assertLength(t, doc.Find("#main #nf1, #main #nf2").Nodes, 0) - assertLength(t, doc.Find("#foot #nf1, #foot #nf2").Nodes, 0) - assertLength(t, doc.Find("body > #nf1:first-child, #nf1 + #nf2").Nodes, 2) - printSel(t, doc.Selection) -} - -func TestBeforeHtml(t *testing.T) { - doc := Doc2Clone() - doc.Find("#main").BeforeHtml("new node") - - assertLength(t, doc.Find("body > strong:first-child").Nodes, 1) - printSel(t, doc.Selection) -} - -func TestEmpty(t *testing.T) { - doc := Doc2Clone() - s := doc.Find("#main").Empty() - - assertLength(t, doc.Find("#main").Children().Nodes, 0) - assertLength(t, s.Filter("div").Nodes, 6) - printSel(t, doc.Selection) -} - -func TestPrepend(t *testing.T) { - doc := Doc2Clone() - doc.Find("#main").Prepend("#nf6") - - assertLength(t, doc.Find("#foot #nf6").Nodes, 0) - assertLength(t, doc.Find("#main #nf6:first-child").Nodes, 1) - printSel(t, doc.Selection) -} - -func TestPrependBody(t *testing.T) { - doc := Doc2Clone() - doc.Find("body").Prepend("#nf6") - - assertLength(t, doc.Find("#foot #nf6").Nodes, 0) - assertLength(t, doc.Find("#main #nf6").Nodes, 0) - assertLength(t, doc.Find("body > #nf6:first-child").Nodes, 1) - printSel(t, doc.Selection) -} - -func TestPrependSelection(t *testing.T) { - doc := Doc2Clone() - doc.Find("#main").PrependSelection(doc.Find("#nf1, #nf2")) - - assertLength(t, doc.Find("#foot #nf1").Nodes, 0) - assertLength(t, doc.Find("#foot #nf2").Nodes, 0) - assertLength(t, doc.Find("#main #nf1:first-child").Nodes, 1) - assertLength(t, doc.Find("#main #nf2:nth-child(2)").Nodes, 1) - printSel(t, doc.Selection) -} - -func TestPrependSelectionExisting(t *testing.T) { - doc := Doc2Clone() - doc.Find("#main").PrependSelection(doc.Find("#n5, #n6")) - - assertClass(t, doc.Find("#main :nth-child(1)"), "five") - assertClass(t, doc.Find("#main :nth-child(2)"), "six") - assertClass(t, doc.Find("#main :nth-child(5)"), "three") - assertClass(t, doc.Find("#main :nth-child(6)"), "four") - printSel(t, doc.Selection) -} - -func TestPrependClone(t *testing.T) { - doc := Doc2Clone() - doc.Find("#n1").PrependSelection(doc.Find("#nf1").Clone()) - - assertLength(t, doc.Find("#foot #nf1:first-child").Nodes, 1) - assertLength(t, doc.Find("#main #nf1:first-child").Nodes, 1) - printSel(t, doc.Selection) -} - -func TestPrependHtml(t *testing.T) { - doc := Doc2Clone() - doc.Find("div").PrependHtml("new node") - - assertLength(t, doc.Find("strong:first-child").Nodes, 14) - printSel(t, doc.Selection) -} - -func TestRemove(t *testing.T) { - doc := Doc2Clone() - doc.Find("#nf1").Remove() - - assertLength(t, doc.Find("#foot #nf1").Nodes, 0) - printSel(t, doc.Selection) -} - -func TestRemoveAll(t *testing.T) { - doc := Doc2Clone() - doc.Find("*").Remove() - - assertLength(t, doc.Find("*").Nodes, 0) - printSel(t, doc.Selection) -} - -func TestRemoveRoot(t *testing.T) { - doc := Doc2Clone() - doc.Find("html").Remove() - - assertLength(t, doc.Find("html").Nodes, 0) - printSel(t, doc.Selection) -} - -func TestRemoveFiltered(t *testing.T) { - doc := Doc2Clone() - nf6 := doc.Find("#nf6") - s := doc.Find("div").RemoveFiltered("#nf6") - - assertLength(t, doc.Find("#nf6").Nodes, 0) - assertLength(t, s.Nodes, 1) - if nf6.Nodes[0] != s.Nodes[0] { - t.Error("Removed node does not match original") - } - printSel(t, doc.Selection) -} - -func TestReplaceWith(t *testing.T) { - doc := Doc2Clone() - - doc.Find("#nf6").ReplaceWith("#main") - assertLength(t, doc.Find("#foot #main:last-child").Nodes, 1) - printSel(t, doc.Selection) - - doc.Find("#foot").ReplaceWith("#main") - assertLength(t, doc.Find("#foot").Nodes, 0) - assertLength(t, doc.Find("#main").Nodes, 1) - - printSel(t, doc.Selection) -} - -func TestReplaceWithHtml(t *testing.T) { - doc := Doc2Clone() - doc.Find("#main, #foot").ReplaceWithHtml("
") - - assertLength(t, doc.Find("#replace").Nodes, 2) - - printSel(t, doc.Selection) -} - -func TestReplaceWithSelection(t *testing.T) { - doc := Doc2Clone() - sel := doc.Find("#nf6").ReplaceWithSelection(doc.Find("#nf5")) - - assertSelectionIs(t, sel, "#nf6") - assertLength(t, doc.Find("#nf6").Nodes, 0) - assertLength(t, doc.Find("#nf5").Nodes, 1) - - printSel(t, doc.Selection) -} - -func TestUnwrap(t *testing.T) { - doc := Doc2Clone() - - doc.Find("#nf5").Unwrap() - assertLength(t, doc.Find("#foot").Nodes, 0) - assertLength(t, doc.Find("body > #nf1").Nodes, 1) - assertLength(t, doc.Find("body > #nf5").Nodes, 1) - - printSel(t, doc.Selection) - - doc = Doc2Clone() - - doc.Find("#nf5, #n1").Unwrap() - assertLength(t, doc.Find("#foot").Nodes, 0) - assertLength(t, doc.Find("#main").Nodes, 0) - assertLength(t, doc.Find("body > #n1").Nodes, 1) - assertLength(t, doc.Find("body > #nf5").Nodes, 1) - - printSel(t, doc.Selection) -} - -func TestUnwrapBody(t *testing.T) { - doc := Doc2Clone() - - doc.Find("#main").Unwrap() - assertLength(t, doc.Find("body").Nodes, 1) - assertLength(t, doc.Find("body > #main").Nodes, 1) - - printSel(t, doc.Selection) -} - -func TestUnwrapHead(t *testing.T) { - doc := Doc2Clone() - - doc.Find("title").Unwrap() - assertLength(t, doc.Find("head").Nodes, 0) - assertLength(t, doc.Find("head > title").Nodes, 0) - assertLength(t, doc.Find("title").Nodes, 1) - - printSel(t, doc.Selection) -} - -func TestUnwrapHtml(t *testing.T) { - doc := Doc2Clone() - - doc.Find("head").Unwrap() - assertLength(t, doc.Find("html").Nodes, 0) - assertLength(t, doc.Find("html head").Nodes, 0) - assertLength(t, doc.Find("head").Nodes, 1) - - printSel(t, doc.Selection) -} - -func TestWrap(t *testing.T) { - doc := Doc2Clone() - doc.Find("#nf1").Wrap("#nf2") - nf1 := doc.Find("#foot #nf2 #nf1") - assertLength(t, nf1.Nodes, 1) - - nf2 := doc.Find("#nf2") - assertLength(t, nf2.Nodes, 2) - - printSel(t, doc.Selection) -} - -func TestWrapEmpty(t *testing.T) { - doc := Doc2Clone() - doc.Find("#nf1").Wrap("#doesnt-exist") - - origHtml, _ := Doc2().Html() - newHtml, _ := doc.Html() - - if origHtml != newHtml { - t.Error("Expected the two documents to be identical.") - } - - printSel(t, doc.Selection) -} - -func TestWrapHtml(t *testing.T) { - doc := Doc2Clone() - doc.Find(".odd").WrapHtml(wrapHtml) - nf2 := doc.Find("#ins #nf2") - assertLength(t, nf2.Nodes, 1) - printSel(t, doc.Selection) -} - -func TestWrapSelection(t *testing.T) { - doc := Doc2Clone() - doc.Find("#nf1").WrapSelection(doc.Find("#nf2")) - nf1 := doc.Find("#foot #nf2 #nf1") - assertLength(t, nf1.Nodes, 1) - - nf2 := doc.Find("#nf2") - assertLength(t, nf2.Nodes, 2) - - printSel(t, doc.Selection) -} - -func TestWrapAll(t *testing.T) { - doc := Doc2Clone() - doc.Find(".odd").WrapAll("#nf1") - nf1 := doc.Find("#main #nf1") - assertLength(t, nf1.Nodes, 1) - - sel := nf1.Find("#n2 ~ #n4 ~ #n6 ~ #nf2 ~ #nf4 ~ #nf6") - assertLength(t, sel.Nodes, 1) - - printSel(t, doc.Selection) -} - -func TestWrapAllHtml(t *testing.T) { - doc := Doc2Clone() - doc.Find(".odd").WrapAllHtml(wrapHtml) - nf1 := doc.Find("#main div#ins div p em b #n2 ~ #n4 ~ #n6 ~ #nf2 ~ #nf4 ~ #nf6") - assertLength(t, nf1.Nodes, 1) - printSel(t, doc.Selection) -} - -func TestWrapInnerNoContent(t *testing.T) { - doc := Doc2Clone() - doc.Find(".one").WrapInner(".two") - - twos := doc.Find(".two") - assertLength(t, twos.Nodes, 4) - assertLength(t, doc.Find(".one .two").Nodes, 2) - - printSel(t, doc.Selection) -} - -func TestWrapInnerWithContent(t *testing.T) { - doc := Doc3Clone() - doc.Find(".one").WrapInner(".two") - - twos := doc.Find(".two") - assertLength(t, twos.Nodes, 4) - assertLength(t, doc.Find(".one .two").Nodes, 2) - - printSel(t, doc.Selection) -} - -func TestWrapInnerNoWrapper(t *testing.T) { - doc := Doc2Clone() - doc.Find(".one").WrapInner(".not-exist") - - twos := doc.Find(".two") - assertLength(t, twos.Nodes, 2) - assertLength(t, doc.Find(".one").Nodes, 2) - assertLength(t, doc.Find(".one .two").Nodes, 0) - - printSel(t, doc.Selection) -} - -func TestWrapInnerHtml(t *testing.T) { - doc := Doc2Clone() - doc.Find("#foot").WrapInnerHtml(wrapHtml) - - foot := doc.Find("#foot div#ins div p em b #nf1 ~ #nf2 ~ #nf3") - assertLength(t, foot.Nodes, 1) - - printSel(t, doc.Selection) -} diff --git a/vendor/github.com/PuerkitoBio/goquery/misc/git/pre-commit b/vendor/github.com/PuerkitoBio/goquery/misc/git/pre-commit deleted file mode 100755 index 6a3d79847..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/misc/git/pre-commit +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh - -echo ">>> golint" -for dir in $(go list ./... | grep -v /vendor/) -do - golint "${dir}" -done -echo "<<< golint" -echo - -echo ">>> go vet" -go vet $(go list ./... | grep -v /vendor/) -echo "<<< go vet" -echo - -echo ">>> gosimple" -gosimple $(go list ./... | grep -v /vendor/) -echo "<<< gosimple" -echo - -echo ">>> staticcheck" -staticcheck $(go list ./... | grep -v /vendor/) -echo "<<< staticcheck" -echo - -echo ">>> unused" -unused $(go list ./... | grep -v /vendor/) -echo "<<< unused" -echo - -echo ">>> gas" -gas $(find . -name "*.go" | grep -v /vendor/ | grep -v '_test.go$') -echo "<<< gas" -echo - -# Check for gofmt problems and report if any. -gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '.go$' | grep -v /vendor/) -[ -z "$gofiles" ] && echo "EXIT $vetres" && exit $vetres - -if [ -n "$gofiles" ]; then - unformatted=$(gofmt -l $gofiles) - - if [ -n "$unformatted" ]; then - # Some files are not gofmt'd. - echo >&2 "Go files must be formatted with gofmt. Please run:" - for fn in $unformatted; do - echo >&2 " gofmt -w $PWD/$fn" - done - fi -fi -echo - diff --git a/vendor/github.com/PuerkitoBio/goquery/property_test.go b/vendor/github.com/PuerkitoBio/goquery/property_test.go deleted file mode 100644 index 1095dcc89..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/property_test.go +++ /dev/null @@ -1,252 +0,0 @@ -package goquery - -import ( - "regexp" - "strings" - "testing" -) - -func TestAttrExists(t *testing.T) { - if val, ok := Doc().Find("a").Attr("href"); !ok { - t.Error("Expected a value for the href attribute.") - } else { - t.Logf("Href of first anchor: %v.", val) - } -} - -func TestAttrOr(t *testing.T) { - if val := Doc().Find("a").AttrOr("fake-attribute", "alternative"); val != "alternative" { - t.Error("Expected an alternative value for 'fake-attribute' attribute.") - } else { - t.Logf("Value returned for not existing attribute: %v.", val) - } - if val := Doc().Find("zz").AttrOr("fake-attribute", "alternative"); val != "alternative" { - t.Error("Expected an alternative value for 'fake-attribute' on an empty selection.") - } else { - t.Logf("Value returned for empty selection: %v.", val) - } -} - -func TestAttrNotExist(t *testing.T) { - if val, ok := Doc().Find("div.row-fluid").Attr("href"); ok { - t.Errorf("Expected no value for the href attribute, got %v.", val) - } -} - -func TestRemoveAttr(t *testing.T) { - sel := Doc2Clone().Find("div") - - sel.RemoveAttr("id") - - _, ok := sel.Attr("id") - if ok { - t.Error("Expected there to be no id attributes set") - } -} - -func TestSetAttr(t *testing.T) { - sel := Doc2Clone().Find("#main") - - sel.SetAttr("id", "not-main") - - val, ok := sel.Attr("id") - if !ok { - t.Error("Expected an id attribute on main") - } - - if val != "not-main" { - t.Errorf("Expected an attribute id to be not-main, got %s", val) - } -} - -func TestSetAttr2(t *testing.T) { - sel := Doc2Clone().Find("#main") - - sel.SetAttr("foo", "bar") - - val, ok := sel.Attr("foo") - if !ok { - t.Error("Expected an 'foo' attribute on main") - } - - if val != "bar" { - t.Errorf("Expected an attribute 'foo' to be 'bar', got '%s'", val) - } -} - -func TestText(t *testing.T) { - txt := Doc().Find("h1").Text() - if strings.Trim(txt, " \n\r\t") != "Provok.in" { - t.Errorf("Expected text to be Provok.in, found %s.", txt) - } -} - -func TestText2(t *testing.T) { - txt := Doc().Find(".hero-unit .container-fluid .row-fluid:nth-child(1)").Text() - if ok, e := regexp.MatchString(`^\s+Provok\.in\s+Prove your point.\s+$`, txt); !ok || e != nil { - t.Errorf("Expected text to be Provok.in Prove your point., found %s.", txt) - if e != nil { - t.Logf("Error: %s.", e.Error()) - } - } -} - -func TestText3(t *testing.T) { - txt := Doc().Find(".pvk-gutter").First().Text() - // There's an   character in there... - if ok, e := regexp.MatchString(`^[\s\x{00A0}]+$`, txt); !ok || e != nil { - t.Errorf("Expected spaces, found <%v>.", txt) - if e != nil { - t.Logf("Error: %s.", e.Error()) - } - } -} - -func TestHtml(t *testing.T) { - txt, e := Doc().Find("h1").Html() - if e != nil { - t.Errorf("Error: %s.", e) - } - - if ok, e := regexp.MatchString(`^\s*Provok\.in\s*$`, txt); !ok || e != nil { - t.Errorf("Unexpected HTML content, found %s.", txt) - if e != nil { - t.Logf("Error: %s.", e.Error()) - } - } -} - -func TestNbsp(t *testing.T) { - src := `

Some text

` - d, err := NewDocumentFromReader(strings.NewReader(src)) - if err != nil { - t.Fatal(err) - } - txt := d.Find("p").Text() - ix := strings.Index(txt, "\u00a0") - if ix != 4 { - t.Errorf("Text: expected a non-breaking space at index 4, got %d", ix) - } - - h, err := d.Find("p").Html() - if err != nil { - t.Fatal(err) - } - ix = strings.Index(h, "\u00a0") - if ix != 4 { - t.Errorf("Html: expected a non-breaking space at index 4, got %d", ix) - } -} - -func TestAddClass(t *testing.T) { - sel := Doc2Clone().Find("#main") - sel.AddClass("main main main") - - // Make sure that class was only added once - if a, ok := sel.Attr("class"); !ok || a != "main" { - t.Error("Expected #main to have class main") - } -} - -func TestAddClassSimilar(t *testing.T) { - sel := Doc2Clone().Find("#nf5") - sel.AddClass("odd") - - assertClass(t, sel, "odd") - assertClass(t, sel, "odder") - printSel(t, sel.Parent()) -} - -func TestAddEmptyClass(t *testing.T) { - sel := Doc2Clone().Find("#main") - sel.AddClass("") - - // Make sure that class was only added once - if a, ok := sel.Attr("class"); ok { - t.Errorf("Expected #main to not to have a class, have: %s", a) - } -} - -func TestAddClasses(t *testing.T) { - sel := Doc2Clone().Find("#main") - sel.AddClass("a b") - - // Make sure that class was only added once - if !sel.HasClass("a") || !sel.HasClass("b") { - t.Errorf("#main does not have classes") - } -} - -func TestHasClass(t *testing.T) { - sel := Doc().Find("div") - if !sel.HasClass("span12") { - t.Error("Expected at least one div to have class span12.") - } -} - -func TestHasClassNone(t *testing.T) { - sel := Doc().Find("h2") - if sel.HasClass("toto") { - t.Error("Expected h1 to have no class.") - } -} - -func TestHasClassNotFirst(t *testing.T) { - sel := Doc().Find(".alert") - if !sel.HasClass("alert-error") { - t.Error("Expected .alert to also have class .alert-error.") - } -} - -func TestRemoveClass(t *testing.T) { - sel := Doc2Clone().Find("#nf1") - sel.RemoveClass("one row") - - if !sel.HasClass("even") || sel.HasClass("one") || sel.HasClass("row") { - classes, _ := sel.Attr("class") - t.Error("Expected #nf1 to have class even, has ", classes) - } -} - -func TestRemoveClassSimilar(t *testing.T) { - sel := Doc2Clone().Find("#nf5, #nf6") - assertLength(t, sel.Nodes, 2) - - sel.RemoveClass("odd") - assertClass(t, sel.Eq(0), "odder") - printSel(t, sel) -} - -func TestRemoveAllClasses(t *testing.T) { - sel := Doc2Clone().Find("#nf1") - sel.RemoveClass() - - if a, ok := sel.Attr("class"); ok { - t.Error("All classes were not removed, has ", a) - } - - sel = Doc2Clone().Find("#main") - sel.RemoveClass() - if a, ok := sel.Attr("class"); ok { - t.Error("All classes were not removed, has ", a) - } -} - -func TestToggleClass(t *testing.T) { - sel := Doc2Clone().Find("#nf1") - - sel.ToggleClass("one") - if sel.HasClass("one") { - t.Error("Expected #nf1 to not have class one") - } - - sel.ToggleClass("one") - if !sel.HasClass("one") { - t.Error("Expected #nf1 to have class one") - } - - sel.ToggleClass("one even row") - if a, ok := sel.Attr("class"); ok { - t.Errorf("Expected #nf1 to have no classes, have %q", a) - } -} diff --git a/vendor/github.com/PuerkitoBio/goquery/query_test.go b/vendor/github.com/PuerkitoBio/goquery/query_test.go deleted file mode 100644 index 54b2a2e0d..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/query_test.go +++ /dev/null @@ -1,103 +0,0 @@ -package goquery - -import ( - "testing" -) - -func TestIs(t *testing.T) { - sel := Doc().Find(".footer p:nth-child(1)") - if !sel.Is("p") { - t.Error("Expected .footer p:nth-child(1) to be p.") - } -} - -func TestIsInvalid(t *testing.T) { - sel := Doc().Find(".footer p:nth-child(1)") - if sel.Is("") { - t.Error("Is should not succeed with invalid selector string") - } -} - -func TestIsPositional(t *testing.T) { - sel := Doc().Find(".footer p:nth-child(2)") - if !sel.Is("p:nth-child(2)") { - t.Error("Expected .footer p:nth-child(2) to be p:nth-child(2).") - } -} - -func TestIsPositionalNot(t *testing.T) { - sel := Doc().Find(".footer p:nth-child(1)") - if sel.Is("p:nth-child(2)") { - t.Error("Expected .footer p:nth-child(1) NOT to be p:nth-child(2).") - } -} - -func TestIsFunction(t *testing.T) { - ok := Doc().Find("div").IsFunction(func(i int, s *Selection) bool { - return s.HasClass("container-fluid") - }) - - if !ok { - t.Error("Expected some div to have a container-fluid class.") - } -} - -func TestIsFunctionRollback(t *testing.T) { - ok := Doc().Find("div").IsFunction(func(i int, s *Selection) bool { - return s.HasClass("container-fluid") - }) - - if !ok { - t.Error("Expected some div to have a container-fluid class.") - } -} - -func TestIsSelection(t *testing.T) { - sel := Doc().Find("div") - sel2 := Doc().Find(".pvk-gutter") - - if !sel.IsSelection(sel2) { - t.Error("Expected some div to have a pvk-gutter class.") - } -} - -func TestIsSelectionNot(t *testing.T) { - sel := Doc().Find("div") - sel2 := Doc().Find("a") - - if sel.IsSelection(sel2) { - t.Error("Expected some div NOT to be an anchor.") - } -} - -func TestIsNodes(t *testing.T) { - sel := Doc().Find("div") - sel2 := Doc().Find(".footer") - - if !sel.IsNodes(sel2.Nodes[0]) { - t.Error("Expected some div to have a footer class.") - } -} - -func TestDocContains(t *testing.T) { - sel := Doc().Find("h1") - if !Doc().Contains(sel.Nodes[0]) { - t.Error("Expected document to contain H1 tag.") - } -} - -func TestSelContains(t *testing.T) { - sel := Doc().Find(".row-fluid") - sel2 := Doc().Find("a[ng-click]") - if !sel.Contains(sel2.Nodes[0]) { - t.Error("Expected .row-fluid to contain a[ng-click] tag.") - } -} - -func TestSelNotContains(t *testing.T) { - sel := Doc().Find("a.link") - sel2 := Doc().Find("span") - if sel.Contains(sel2.Nodes[0]) { - t.Error("Expected a.link to NOT contain span tag.") - } -} diff --git a/vendor/github.com/PuerkitoBio/goquery/testdata/gotesting.html b/vendor/github.com/PuerkitoBio/goquery/testdata/gotesting.html deleted file mode 100644 index ba5348fd4..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/testdata/gotesting.html +++ /dev/null @@ -1,855 +0,0 @@ - - - - - - testing - The Go Programming Language - - - - - - - - - - -
- -
- - -
- -
- -
- - -
-

Package testing

- - - - - - - - - - -
-
-
import "testing"
-
-
-
Overview
-
Index
- - -
Subdirectories
- -
-
- -
- -
-

Overview â–¾

-

-Package testing provides support for automated testing of Go packages. -It is intended to be used in concert with the “go test” command, which automates -execution of any function of the form -

-
func TestXxx(*testing.T)
-
-

-where Xxx can be any alphanumeric string (but the first letter must not be in -[a-z]) and serves to identify the test routine. -These TestXxx routines should be declared within the package they are testing. -

-

-Functions of the form -

-
func BenchmarkXxx(*testing.B)
-
-

-are considered benchmarks, and are executed by the "go test" command when -the -test.bench flag is provided. -

-

-A sample benchmark function looks like this: -

-
func BenchmarkHello(b *testing.B) {
-    for i := 0; i < b.N; i++ {
-        fmt.Sprintf("hello")
-    }
-}
-
-

-The benchmark package will vary b.N until the benchmark function lasts -long enough to be timed reliably. The output -

-
testing.BenchmarkHello    10000000    282 ns/op
-
-

-means that the loop ran 10000000 times at a speed of 282 ns per loop. -

-

-If a benchmark needs some expensive setup before running, the timer -may be stopped: -

-
func BenchmarkBigLen(b *testing.B) {
-    b.StopTimer()
-    big := NewBig()
-    b.StartTimer()
-    for i := 0; i < b.N; i++ {
-        big.Len()
-    }
-}
-
-

-The package also runs and verifies example code. Example functions may -include a concluding comment that begins with "Output:" and is compared with -the standard output of the function when the tests are run, as in these -examples of an example: -

-
func ExampleHello() {
-        fmt.Println("hello")
-        // Output: hello
-}
-
-func ExampleSalutations() {
-        fmt.Println("hello, and")
-        fmt.Println("goodbye")
-        // Output:
-        // hello, and
-        // goodbye
-}
-
-

-Example functions without output comments are compiled but not executed. -

-

-The naming convention to declare examples for a function F, a type T and -method M on type T are: -

-
func ExampleF() { ... }
-func ExampleT() { ... }
-func ExampleT_M() { ... }
-
-

-Multiple example functions for a type/function/method may be provided by -appending a distinct suffix to the name. The suffix must start with a -lower-case letter. -

-
func ExampleF_suffix() { ... }
-func ExampleT_suffix() { ... }
-func ExampleT_M_suffix() { ... }
-
-

-The entire test file is presented as the example when it contains a single -example function, at least one other function, type, variable, or constant -declaration, and no test or benchmark functions. -

- -
-
- - -

Index

- -
-
- - - - -
func Main(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample)
- - -
func RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks []InternalBenchmark)
- - -
func RunExamples(matchString func(pat, str string) (bool, error), examples []InternalExample) (ok bool)
- - -
func RunTests(matchString func(pat, str string) (bool, error), tests []InternalTest) (ok bool)
- - -
func Short() bool
- - - -
type B
- - - -
    func (c *B) Error(args ...interface{})
- - -
    func (c *B) Errorf(format string, args ...interface{})
- - -
    func (c *B) Fail()
- - -
    func (c *B) FailNow()
- - -
    func (c *B) Failed() bool
- - -
    func (c *B) Fatal(args ...interface{})
- - -
    func (c *B) Fatalf(format string, args ...interface{})
- - -
    func (c *B) Log(args ...interface{})
- - -
    func (c *B) Logf(format string, args ...interface{})
- - -
    func (b *B) ResetTimer()
- - -
    func (b *B) SetBytes(n int64)
- - -
    func (b *B) StartTimer()
- - -
    func (b *B) StopTimer()
- - - -
type BenchmarkResult
- - -
    func Benchmark(f func(b *B)) BenchmarkResult
- - - -
    func (r BenchmarkResult) NsPerOp() int64
- - -
    func (r BenchmarkResult) String() string
- - - -
type InternalBenchmark
- - - - -
type InternalExample
- - - - -
type InternalTest
- - - - -
type T
- - - -
    func (c *T) Error(args ...interface{})
- - -
    func (c *T) Errorf(format string, args ...interface{})
- - -
    func (c *T) Fail()
- - -
    func (c *T) FailNow()
- - -
    func (c *T) Failed() bool
- - -
    func (c *T) Fatal(args ...interface{})
- - -
    func (c *T) Fatalf(format string, args ...interface{})
- - -
    func (c *T) Log(args ...interface{})
- - -
    func (c *T) Logf(format string, args ...interface{})
- - -
    func (t *T) Parallel()
- - - -
- - - - -

Package files

-

- - - benchmark.go - - example.go - - testing.go - - -

- - - - - - - -

func Main

-
func Main(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample)
-

-An internal function but exported because it is cross-package; part of the implementation -of the "go test" command. -

- - - - - -

func RunBenchmarks

-
func RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks []InternalBenchmark)
-

-An internal function but exported because it is cross-package; part of the implementation -of the "go test" command. -

- - - - - -

func RunExamples

-
func RunExamples(matchString func(pat, str string) (bool, error), examples []InternalExample) (ok bool)
- - - - - -

func RunTests

-
func RunTests(matchString func(pat, str string) (bool, error), tests []InternalTest) (ok bool)
- - - - - -

func Short

-
func Short() bool
-

-Short reports whether the -test.short flag is set. -

- - - - - - -

type B

-
type B struct {
-    N int
-    // contains filtered or unexported fields
-}
-

-B is a type passed to Benchmark functions to manage benchmark -timing and to specify the number of iterations to run. -

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

func (*B) Error

-
func (c *B) Error(args ...interface{})
-

-Error is equivalent to Log() followed by Fail(). -

- - - - - -

func (*B) Errorf

-
func (c *B) Errorf(format string, args ...interface{})
-

-Errorf is equivalent to Logf() followed by Fail(). -

- - - - - -

func (*B) Fail

-
func (c *B) Fail()
-

-Fail marks the function as having failed but continues execution. -

- - - - - -

func (*B) FailNow

-
func (c *B) FailNow()
-

-FailNow marks the function as having failed and stops its execution. -Execution will continue at the next test or benchmark. -

- - - - - -

func (*B) Failed

-
func (c *B) Failed() bool
-

-Failed returns whether the function has failed. -

- - - - - -

func (*B) Fatal

-
func (c *B) Fatal(args ...interface{})
-

-Fatal is equivalent to Log() followed by FailNow(). -

- - - - - -

func (*B) Fatalf

-
func (c *B) Fatalf(format string, args ...interface{})
-

-Fatalf is equivalent to Logf() followed by FailNow(). -

- - - - - -

func (*B) Log

-
func (c *B) Log(args ...interface{})
-

-Log formats its arguments using default formatting, analogous to Println(), -and records the text in the error log. -

- - - - - -

func (*B) Logf

-
func (c *B) Logf(format string, args ...interface{})
-

-Logf formats its arguments according to the format, analogous to Printf(), -and records the text in the error log. -

- - - - - -

func (*B) ResetTimer

-
func (b *B) ResetTimer()
-

-ResetTimer sets the elapsed benchmark time to zero. -It does not affect whether the timer is running. -

- - - - - -

func (*B) SetBytes

-
func (b *B) SetBytes(n int64)
-

-SetBytes records the number of bytes processed in a single operation. -If this is called, the benchmark will report ns/op and MB/s. -

- - - - - -

func (*B) StartTimer

-
func (b *B) StartTimer()
-

-StartTimer starts timing a test. This function is called automatically -before a benchmark starts, but it can also used to resume timing after -a call to StopTimer. -

- - - - - -

func (*B) StopTimer

-
func (b *B) StopTimer()
-

-StopTimer stops timing a test. This can be used to pause the timer -while performing complex initialization that you don't -want to measure. -

- - - - - - - -

type BenchmarkResult

-
type BenchmarkResult struct {
-    N     int           // The number of iterations.
-    T     time.Duration // The total time taken.
-    Bytes int64         // Bytes processed in one iteration.
-}
-

-The results of a benchmark run. -

- - - - - - - - - - -

func Benchmark

-
func Benchmark(f func(b *B)) BenchmarkResult
-

-Benchmark benchmarks a single function. Useful for creating -custom benchmarks that do not use the "go test" command. -

- - - - - - -

func (BenchmarkResult) NsPerOp

-
func (r BenchmarkResult) NsPerOp() int64
- - - - - -

func (BenchmarkResult) String

-
func (r BenchmarkResult) String() string
- - - - - - - -

type InternalBenchmark

-
type InternalBenchmark struct {
-    Name string
-    F    func(b *B)
-}
-

-An internal type but exported because it is cross-package; part of the implementation -of the "go test" command. -

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

type InternalExample

-
type InternalExample struct {
-    Name   string
-    F      func()
-    Output string
-}
- - - - - - - - - - - - - - -

type InternalTest

-
type InternalTest struct {
-    Name string
-    F    func(*T)
-}
-

-An internal type but exported because it is cross-package; part of the implementation -of the "go test" command. -

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

type T

-
type T struct {
-    // contains filtered or unexported fields
-}
-

-T is a type passed to Test functions to manage test state and support formatted test logs. -Logs are accumulated during execution and dumped to standard error when done. -

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

func (*T) Error

-
func (c *T) Error(args ...interface{})
-

-Error is equivalent to Log() followed by Fail(). -

- - - - - -

func (*T) Errorf

-
func (c *T) Errorf(format string, args ...interface{})
-

-Errorf is equivalent to Logf() followed by Fail(). -

- - - - - -

func (*T) Fail

-
func (c *T) Fail()
-

-Fail marks the function as having failed but continues execution. -

- - - - - -

func (*T) FailNow

-
func (c *T) FailNow()
-

-FailNow marks the function as having failed and stops its execution. -Execution will continue at the next test or benchmark. -

- - - - - -

func (*T) Failed

-
func (c *T) Failed() bool
-

-Failed returns whether the function has failed. -

- - - - - -

func (*T) Fatal

-
func (c *T) Fatal(args ...interface{})
-

-Fatal is equivalent to Log() followed by FailNow(). -

- - - - - -

func (*T) Fatalf

-
func (c *T) Fatalf(format string, args ...interface{})
-

-Fatalf is equivalent to Logf() followed by FailNow(). -

- - - - - -

func (*T) Log

-
func (c *T) Log(args ...interface{})
-

-Log formats its arguments using default formatting, analogous to Println(), -and records the text in the error log. -

- - - - - -

func (*T) Logf

-
func (c *T) Logf(format string, args ...interface{})
-

-Logf formats its arguments according to the format, analogous to Printf(), -and records the text in the error log. -

- - - - - -

func (*T) Parallel

-
func (t *T) Parallel()
-

-Parallel signals that this test is to be run in parallel with (and only with) -other parallel tests in this CPU group. -

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

Subdirectories

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Name    Synopsis
..
iotest    Package iotest implements Readers and Writers useful mainly for testing.
quick    Package quick implements utility functions to help with black box testing.
- - - - -
- - - - - - - - diff --git a/vendor/github.com/PuerkitoBio/goquery/testdata/gowiki.html b/vendor/github.com/PuerkitoBio/goquery/testdata/gowiki.html deleted file mode 100644 index 2ed6bb715..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/testdata/gowiki.html +++ /dev/null @@ -1,1214 +0,0 @@ - - - -Go (programming language) - Wikipedia, the free encyclopedia - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - -
- - -

Go (programming language)

- - -
- -
From Wikipedia, the free encyclopedia
- - -
  (Redirected from Golang)
- - -
- Jump to: navigation, search -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Go
Golang.png
Paradigm(s)compiled, concurrent, imperative, structured
Appeared in2009
Designed byRobert Griesemer
-Rob Pike
-Ken Thompson
DeveloperGoogle Inc.
Stable releaseversion 1.0.2[1] (14 June 2012; 2 months ago (2012-06-14))
Typing disciplinestrong, static
Major implementationsgc (8g, 6g, 5g), gccgo
Influenced byC, Limbo, Modula, Newsqueak, Oberon, Pascal,[2] Python
OSLinux, Mac OS X, FreeBSD, OpenBSD, MS Windows, Plan 9[3]
LicenseBSD-style[4] + Patent grant[5]
Usual filename extensions.go
Websitegolang.org
-

Go is a compiled, garbage-collected, concurrent programming language developed by Google Inc.[6]

-

The initial design of Go was started in September 2007 by Robert Griesemer, Rob Pike, and Ken Thompson.[2] Go was officially announced in November 2009. In May 2010, Rob Pike publicly stated that Go was being used "for real stuff" at Google.[7] Go's "gc" compiler targets the Linux, Mac OS X, FreeBSD, OpenBSD, Plan 9, and Microsoft Windows operating systems and the i386, amd64, and ARM processor architectures.[8]

- - - - -
-
-

Contents

-
- -
-

[edit] Goals

-

Go aims to provide the efficiency of a statically typed compiled language with the ease of programming of a dynamic language.[9] Other goals include:

-
    -
  • Safety: Type-safe and memory-safe.
  • -
  • Good support for concurrency and communication.
  • -
  • Efficient, latency-free garbage collection.
  • -
  • High-speed compilation.
  • -
-

[edit] Description

-

The syntax of Go is broadly similar to that of C: blocks of code are surrounded with curly braces; common control flow structures include for, switch, and if. Unlike C, line-ending semicolons are optional, variable declarations are written differently and are usually optional, type conversions must be made explicit, and new go and select control keywords have been introduced to support concurrent programming. New built-in types include maps, Unicode strings, array slices, and channels for inter-thread communication.

-

Go is designed for exceptionally fast compiling times, even on modest hardware.[10] The language requires garbage collection. Certain concurrency-related structural conventions of Go (channels and alternative channel inputs) are borrowed from Tony Hoare's CSP. Unlike previous concurrent programming languages such as occam or Limbo, Go does not provide any built-in notion of safe or verifiable concurrency.[11]

-

Of features found in C++ or Java, Go does not include type inheritance, generic programming, assertions, method overloading, or pointer arithmetic.[2] Of these, the Go authors express an openness to generic programming, explicitly argue against assertions and pointer arithmetic, while defending the choice to omit type inheritance as giving a more useful language, encouraging heavy use of interfaces instead.[2] Initially, the language did not include exception handling, but in March 2010 a mechanism known as panic/recover was implemented to handle exceptional errors while avoiding some of the problems the Go authors find with exceptions.[12][13]

-

[edit] Type system

-

Go allows a programmer to write functions that can operate on inputs of arbitrary type, provided that the type implements the functions defined by a given interface.

-

Unlike Java, the interfaces a type supports do not need to be specified at the point at which the type is defined, and Go interfaces do not participate in a type hierarchy. A Go interface is best described as a set of methods, each identified by a name and signature. A type is considered to implement an interface if all the required methods have been defined for that type. An interface can be declared to "embed" other interfaces, meaning the declared interface includes the methods defined in the other interfaces.[11]

-

Unlike Java, the in-memory representation of an object does not contain a pointer to a virtual method table. Instead a value of interface type is implemented as a pair of a pointer to the object, and a pointer to a dictionary containing implementations of the interface methods for that type.

-

Consider the following example:

-
-
-
-type Sequence []int
- 
-func (s Sequence) Len() int {
-    return len(s)
-}
- 
-type HasLength interface {
-    Len() int
-}
- 
-func Foo (o HasLength) {
-    ...
-}
-
-
-

These four definitions could have been placed in separate files, in different parts of the program. Notably, the programmer who defined the Sequence type did not need to declare that the type implemented HasLength, and the person who implemented the Len method for Sequence did not need to specify that this method was part of HasLength.

-

[edit] Name visibility

-

Visibility of structures, structure fields, variables, constants, methods, top-level types and functions outside their defining package is defined implicitly according to the capitalization of their identifier.[14]

-

[edit] Concurrency

-

Go provides goroutines, small lightweight threads; the name alludes to coroutines. Goroutines are created with the go statement from anonymous or named functions.

-

Goroutines are executed in parallel with other goroutines, including their caller. They do not necessarily run in separate threads, but a group of goroutines are multiplexed onto multiple threads — execution control is moved between them by blocking them when sending or receiving messages over channels.

-

[edit] Implementations

-

There are currently two Go compilers:

-
    -
  • 6g/8g/5g (the compilers for AMD64, x86, and ARM respectively) with their supporting tools (collectively known as "gc") based on Ken's previous work on Plan 9's C toolchain.
  • -
  • gccgo, a GCC frontend written in C++,[15] and now officially supported as of version 4.6, albeit not part of the standard binary for gcc.[16]
  • -
-

Both compilers work on Unix-like systems, and a port to Microsoft Windows of the gc compiler and runtime have been integrated in the main distribution. Most of the standard libraries also work on Windows.

-

There is also an unmaintained "tiny" runtime environment that allows Go programs to run on bare hardware.[17]

-

[edit] Examples

-

[edit] Hello world

-

The following is a Hello world program in Go:

-
-
-
-package main
- 
-import "fmt"
- 
-func main() {
-        fmt.Println("Hello, World")
-}
-
-
-

Go's automatic semicolon insertion feature requires that opening braces not be placed on their own lines, and this is thus the preferred brace style; the examples shown comply with this style.[18]

-

[edit] Echo

-

Example illustrating how to write a program like the Unix echo command in Go:[19]

-
-
-
-package main
- 
-import (
-        "os"
-        "flag"  // command line option parser
-)
- 
-var omitNewline = flag.Bool("n", false, "don't print final newline")
- 
-const (
-        Space = " "
-        Newline = "\n"
-)
- 
-func main() {
-        flag.Parse()   // Scans the arg list and sets up flags
-        var s string
-        for i := 0; i < flag.NArg(); i++ {
-                if i > 0 {
-                        s += Space
-                }
-                s += flag.Arg(i)
-        }
-        if !*omitNewline {
-                s += Newline
-        }
-        os.Stdout.WriteString(s)
-}
-
-
-

[edit] Reception

-

Go's initial release led to much discussion.

-

Michele Simionato wrote in an article for artima.com:[20]

-
-
Here I just wanted to point out the design choices about interfaces and inheritance. Such ideas are not new and it is a shame that no popular language has followed such particular route in the design space. I hope Go will become popular; if not, I hope such ideas will finally enter in a popular language, we are already 10 or 20 years too late :-(
-
-

Dave Astels at Engine Yard wrote:[21]

-
-
Go is extremely easy to dive into. There are a minimal number of fundamental language concepts and the syntax is clean and designed to be clear and unambiguous. Go is still experimental and still a little rough around the edges.
-
-

Ars Technica interviewed Rob Pike, one of the authors of Go, and asked why a new language was needed. He replied that:[22]

-
-
It wasn't enough to just add features to existing programming languages, because sometimes you can get more in the long run by taking things away. They wanted to start from scratch and rethink everything. ... [But they did not want] to deviate too much from what developers already knew because they wanted to avoid alienating Go's target audience.
-
-

Go was in 15th place on the TIOBE Programming Community Index of programming language popularity in its first year, 2009,[citation needed] surpassing established languages like Pascal. As of March 2012, it ranked 66th in the index.[23]

-

Bruce Eckel stated:[24]

-
-
The complexity of C++ (even more complexity has been added in the new C++), and the resulting impact on productivity, is no longer justified. All the hoops that the C++ programmer had to jump through in order to use a C-compatible language make no sense anymore -- they're just a waste of time and effort. Now, Go makes much more sense for the class of problems that C++ was originally intended to solve.
-
-

[edit] Naming dispute

-

On the day of the general release of the language, Francis McCabe, developer of the Go! programming language (note the exclamation point), requested a name change of Google's language to prevent confusion with his language.[25] The issue was closed by a Google developer on 12 October 2010 with the custom status "Unfortunate", with a comment that "there are many computing products and services named Go. In the 11 months since our release, there has been minimal confusion of the two languages."[26]

-

[edit] See also

- -

[edit] References

- -
-
    -
  1. ^ "golang-announce: go1.0.2 released". https://groups.google.com/forum/#!msg/golang-announce/9-f_fnXNDzw/MiM3tk0iyjYJ. Retrieved 14 June 2012. 
  2. -
  3. ^ a b c d "Language Design FAQ". golang.org. 16 January 2010. http://golang.org/doc/go_faq.html. Retrieved 27 February 2010. 
  4. -
  5. ^ "Go Porting Efforts". Go Language Resources. cat-v. 12 January 2010. http://go-lang.cat-v.org/os-ports. Retrieved 18 January 2010. 
  6. -
  7. ^ "Text file LICENSE". http://golang.org/LICENSE. Retrieved 27 January 2011. 
  8. -
  9. ^ "Additional IP Rights Grant". http://code.google.com/p/go/source/browse/PATENTS. Retrieved 26 July 2012. 
  10. -
  11. ^ Kincaid, Jason (10 November 2009). "Google’s Go: A New Programming Language That’s Python Meets C++". TechCrunch. http://www.techcrunch.com/2009/11/10/google-go-language/. Retrieved 18 January 2010. 
  12. -
  13. ^ Metz, Cade (20 May 2010). "Google programming Frankenstein is a Go". The Register. http://www.theregister.co.uk/2010/05/20/go_in_production_at_google/. 
  14. -
  15. ^ "Installing Go". golang.org. The Go Authors. 11 June 2010. http://golang.org/doc/install.html#tmp_33. Retrieved 11 June 2010. 
  16. -
  17. ^ Pike, Rob. "The Go Programming Language". YouTube. http://www.youtube.com/watch?v=rKnDgT73v8s&feature=related. Retrieved 1 Jul 2011. 
  18. -
  19. ^ Rob Pike (10 November 2009) (flv). The Go Programming Language (Tech talk). Google. Event occurs at 8:53. http://www.youtube.com/watch?v=rKnDgT73v8s#t=8m53. 
  20. -
  21. ^ a b "The Go Memory Model". Google. http://golang.org/doc/go_mem.html. Retrieved 5 January 2011. 
  22. -
  23. ^ Release notes, 30 March 2010
  24. -
  25. ^ "Proposal for an exception-like mechanism". golang-nuts. 25 March 2010. http://groups.google.com/group/golang-nuts/browse_thread/thread/1ce5cd050bb973e4. Retrieved 25 March 2010. 
  26. -
  27. ^ "A Tutorial for the Go Programming Language". The Go Programming Language. Google. http://golang.org/doc/go_tutorial.html. Retrieved 10 March 2010. "In Go the rule about visibility of information is simple: if a name (of a top-level type, function, method, constant or variable, or of a structure field or method) is capitalized, users of the package may see it. Otherwise, the name and hence the thing being named is visible only inside the package in which it is declared." 
  28. -
  29. ^ "FAQ: Implementation". golang.org. 16 January 2010. http://golang.org/doc/go_faq.html#Implementation. Retrieved 18 January 2010. 
  30. -
  31. ^ "Installing GCC: Configuration". http://gcc.gnu.org/install/configure.html. Retrieved 3 December 2011. "Ada, Go and Objective-C++ are not default languages" 
  32. -
  33. ^ Gerrand, Andrew (1 February 2011). "release.2011-02-01". golang-nuts. Google. http://groups.google.com/group/golang-nuts/browse_thread/thread/b877e34723b543a7. Retrieved 5 February 2011. 
  34. -
  35. ^ "A Tutorial for the Go Programming Language". The Go Programming Language. Google. http://golang.org/doc/go_tutorial.html. Retrieved 10 March 2010. "The one surprise is that it's important to put the opening brace of a construct such as an if statement on the same line as the if; however, if you don't, there are situations that may not compile or may give the wrong result. The language forces the brace style to some extent." 
  36. -
  37. ^ "A Tutorial for the Go Programming Language". golang.org. 16 January 2010. http://golang.org/doc/go_tutorial.html. Retrieved 18 January 2010. 
  38. -
  39. ^ Simionato, Michele (15 November 2009). "Interfaces vs Inheritance (or, watch out for Go!)". artima. http://www.artima.com/weblogs/viewpost.jsp?thread=274019. Retrieved 15 November 2009. 
  40. -
  41. ^ Astels, Dave (9 November 2009). "Ready, Set, Go!". engineyard. http://www.engineyard.com/blog/2009/ready-set-go/. Retrieved 9 November 2009. 
  42. -
  43. ^ Paul, Ryan (10 November 2009). "Go: new open source programming language from Google". Ars Technica. http://arstechnica.com/open-source/news/2009/11/go-new-open-source-programming-language-from-google.ars. Retrieved 13 November 2009. 
  44. -
  45. ^ "TIOBE Programming Community Index for March 2012". TIOBE Software. March 2012. http://es.scribd.com/doc/89569304/TIOBE-Programming-Community-Index-for-March-2012. Retrieved 28 April 2012. 
  46. -
  47. ^ Bruce Eckel (27). "Calling Go from Python via JSON-RPC". http://www.artima.com/weblogs/viewpost.jsp?thread=333589. Retrieved 29 August 2011. 
  48. -
  49. ^ Claburn, Thomas (11 November 2009). "Google 'Go' Name Brings Accusations Of Evil'". InformationWeek. http://www.informationweek.com/news/software/web_services/showArticle.jhtml?articleID=221601351. Retrieved 18 January 2010. 
  50. -
  51. ^ "Issue 9 - go - I have already used the name for *MY* programming language". Google Code. Google Inc.. http://code.google.com/p/go/issues/detail?id=9. Retrieved 12 October 2010. 
  52. -
-
-

[edit] Further reading

- -

[edit] External links

- - - - - - - - - - - - - - - - - - - - - -
- - - - - -
- - -
- -
- - -
- - -
-
Personal tools
- -
- - -
- - -
-
Namespaces
- -
- - - - -
-

-

-
Variants
- -
- - -
-
- - -
-
Views
- -
- - - - -
-
Actions
- -
- - - - - - - -
-
- - -
- - - - - -
-
Navigation
- -
- - - - - - - - -
-
Interaction
- -
- - - - -
-
Toolbox
- -
- - - - -
-
Print/export
- -
- - - - -
-
Languages
- -
- - -
- - - - - - - - - - - - - - diff --git a/vendor/github.com/PuerkitoBio/goquery/testdata/metalreview.html b/vendor/github.com/PuerkitoBio/goquery/testdata/metalreview.html deleted file mode 100644 index fc4a38fcd..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/testdata/metalreview.html +++ /dev/null @@ -1,413 +0,0 @@ - - - - - - - - - - - - - - Metal Reviews, News, Blogs, Interviews and Community | Metal Review - - - - - - - - - - -
-
- - - -
- - - - -
-
- - - - -
-
-
- -
-
-
-
- - - - - -
-

Reviews

-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
    - -
  • -

    - Serpentine Path - Serpentine Path - Serpentine Path
    - Serpentine Path
    - -

    -
  • - -
  • -

    - Hunter - Hunter's Ground
    - No God But the Wild
    - -

    -
  • - -
  • -

    - Blut Aus Nord - 777 - Cosmosophy - Blut Aus Nord
    - 777 - Cosmosophy
    - Black -

    -
  • - -
  • -

    - Ufomammut - Oro: Opus Alter - Ufomammut
    - Oro: Opus Alter
    - Doom -

    -
  • - -
  • -

    - Resurgency - False Enlightenment - Resurgency
    - False Enlightenment
    - Death -

    -
  • - -
  • -

    - Morgoth - Cursed to Live - Morgoth
    - Cursed to Live
    - DeathLive -

    -
  • - -
  • -

    - Krallice - Years Past Matter - Krallice
    - Years Past Matter
    - Black -

    -
  • - -
  • -

    - Murder Construct - Results - Murder Construct
    - Results
    - Grindcore -

    -
  • - -
  • -

    - Grave - Endless Procession of Souls - Grave
    - Endless Procession of Souls
    - Death -

    -
  • - -
  • -

    - Master - The New Elite - Master
    - The New Elite
    - Death -

    -
  • - -
-
-
-
-
-
-
- Serpentine Path - Serpentine PathHunter's Ground - No God But the WildBlut Aus Nord - 777 - CosmosophyUfomammut - Oro: Opus AlterResurgency - False EnlightenmentMorgoth - Cursed to LiveKrallice - Years Past MatterMurder Construct - ResultsGrave - Endless Procession of SoulsMaster - The New Elite -
-
-
-
- - - - - - - -
-
-
-
-
- - - - -
Goto Next Group
-
Goto Previous Group
- - - - - -
- -
- - - - - - - -
-

Lashes

-
NEW Katatonia - Dead End Kings
45 minutes ago by Chaosjunkie
-
Katatonia - Dead End Kings
1 hour ago by Harry Dick Rotten
-
Resurgency - False Enlightenment
3 hours ago by Anonymous
-
Witchcraft - The Alchemist
5 hours ago by Luke_22
-
Katatonia - Dead End Kings
9 hours ago by chaosjunkie
-
Katatonia - Dead End Kings
10 hours ago by Compeller
-
Manetheren - Time
10 hours ago by xpmule
-
Ufomammut - Oro: Opus Alter
16 hours ago by Anonymous
-
Ufomammut - Oro: Opus Alter
17 hours ago by Harry Dick Rotten
-
Katatonia - Dead End Kings
yesterday by Chaosjunkie
-
Katatonia - Dead End Kings
yesterday by Anonymous
-
Katatonia - Dead End Kings
yesterday by Anonymous
-
Katatonia - Dead End Kings
yesterday by Anonymous
-
Katatonia - Dead End Kings
yesterday by frantic
-
Blut Aus Nord - 777 - Cosmosophy
yesterday by Dimensional Bleedthrough
- -
- -
-
-
- - - -
-
- - - - - - - - - - - diff --git a/vendor/github.com/PuerkitoBio/goquery/testdata/page.html b/vendor/github.com/PuerkitoBio/goquery/testdata/page.html deleted file mode 100644 index 92ec74eef..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/testdata/page.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - Provok.in - - - - - - - - - -
-
-
-   -
-
-
-
-
-
-

- Provok.in -

-

- Prove your point. -

-
-
-
-
- Beta Version. Things may change. Or disappear. Or fail miserably. If it's the latter, please file an issue. -
-
- -
- Welcome, {{getUserName()}} ( logout ) -
-
-
-
-
-   -
-
-
-
-   -
-
-
-
-
-
- × -

- {{ title }} -

-

- {{ message }} -

-
-
-
-
-
-
-
-
-
-
-   -
-
-
-
-   -
-
- -
-
-   -
-
-
- - \ No newline at end of file diff --git a/vendor/github.com/PuerkitoBio/goquery/testdata/page2.html b/vendor/github.com/PuerkitoBio/goquery/testdata/page2.html deleted file mode 100644 index 4c2f92f4b..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/testdata/page2.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - Tests for siblings - - -
-
-
-
-
-
-
-
- - - diff --git a/vendor/github.com/PuerkitoBio/goquery/testdata/page3.html b/vendor/github.com/PuerkitoBio/goquery/testdata/page3.html deleted file mode 100644 index 17e86241f..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/testdata/page3.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - Tests for siblings - - -
-
hello
-
-
-
-
-
-
- - - diff --git a/vendor/github.com/PuerkitoBio/goquery/traversal_test.go b/vendor/github.com/PuerkitoBio/goquery/traversal_test.go deleted file mode 100644 index 04383a413..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/traversal_test.go +++ /dev/null @@ -1,793 +0,0 @@ -package goquery - -import ( - "strings" - "testing" -) - -func TestFind(t *testing.T) { - sel := Doc().Find("div.row-fluid") - assertLength(t, sel.Nodes, 9) -} - -func TestFindRollback(t *testing.T) { - sel := Doc().Find("div.row-fluid") - sel2 := sel.Find("a").End() - assertEqual(t, sel, sel2) -} - -func TestFindNotSelf(t *testing.T) { - sel := Doc().Find("h1").Find("h1") - assertLength(t, sel.Nodes, 0) -} - -func TestFindInvalid(t *testing.T) { - sel := Doc().Find(":+ ^") - assertLength(t, sel.Nodes, 0) -} - -func TestFindBig(t *testing.T) { - doc := DocW() - sel := doc.Find("li") - assertLength(t, sel.Nodes, 373) - sel2 := doc.Find("span") - assertLength(t, sel2.Nodes, 448) - sel3 := sel.FindSelection(sel2) - assertLength(t, sel3.Nodes, 248) -} - -func TestChainedFind(t *testing.T) { - sel := Doc().Find("div.hero-unit").Find(".row-fluid") - assertLength(t, sel.Nodes, 4) -} - -func TestChainedFindInvalid(t *testing.T) { - sel := Doc().Find("div.hero-unit").Find("") - assertLength(t, sel.Nodes, 0) -} - -func TestChildren(t *testing.T) { - sel := Doc().Find(".pvk-content").Children() - assertLength(t, sel.Nodes, 5) -} - -func TestChildrenRollback(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.Children().End() - assertEqual(t, sel, sel2) -} - -func TestContents(t *testing.T) { - sel := Doc().Find(".pvk-content").Contents() - assertLength(t, sel.Nodes, 13) -} - -func TestContentsRollback(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.Contents().End() - assertEqual(t, sel, sel2) -} - -func TestChildrenFiltered(t *testing.T) { - sel := Doc().Find(".pvk-content").ChildrenFiltered(".hero-unit") - assertLength(t, sel.Nodes, 1) -} - -func TestChildrenFilteredInvalid(t *testing.T) { - sel := Doc().Find(".pvk-content").ChildrenFiltered("") - assertLength(t, sel.Nodes, 0) -} - -func TestChildrenFilteredRollback(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.ChildrenFiltered(".hero-unit").End() - assertEqual(t, sel, sel2) -} - -func TestContentsFiltered(t *testing.T) { - sel := Doc().Find(".pvk-content").ContentsFiltered(".hero-unit") - assertLength(t, sel.Nodes, 1) -} - -func TestContentsFilteredInvalid(t *testing.T) { - sel := Doc().Find(".pvk-content").ContentsFiltered("~") - assertLength(t, sel.Nodes, 0) -} - -func TestContentsFilteredRollback(t *testing.T) { - sel := Doc().Find(".pvk-content") - sel2 := sel.ContentsFiltered(".hero-unit").End() - assertEqual(t, sel, sel2) -} - -func TestChildrenFilteredNone(t *testing.T) { - sel := Doc().Find(".pvk-content").ChildrenFiltered("a.btn") - assertLength(t, sel.Nodes, 0) -} - -func TestParent(t *testing.T) { - sel := Doc().Find(".container-fluid").Parent() - assertLength(t, sel.Nodes, 3) -} - -func TestParentRollback(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := sel.Parent().End() - assertEqual(t, sel, sel2) -} - -func TestParentBody(t *testing.T) { - sel := Doc().Find("body").Parent() - assertLength(t, sel.Nodes, 1) -} - -func TestParentFiltered(t *testing.T) { - sel := Doc().Find(".container-fluid").ParentFiltered(".hero-unit") - assertLength(t, sel.Nodes, 1) - assertClass(t, sel, "hero-unit") -} - -func TestParentFilteredInvalid(t *testing.T) { - sel := Doc().Find(".container-fluid").ParentFiltered("") - assertLength(t, sel.Nodes, 0) -} - -func TestParentFilteredRollback(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := sel.ParentFiltered(".hero-unit").End() - assertEqual(t, sel, sel2) -} - -func TestParents(t *testing.T) { - sel := Doc().Find(".container-fluid").Parents() - assertLength(t, sel.Nodes, 8) -} - -func TestParentsOrder(t *testing.T) { - sel := Doc().Find("#cf2").Parents() - assertLength(t, sel.Nodes, 6) - assertSelectionIs(t, sel, ".hero-unit", ".pvk-content", "div.row-fluid", "#cf1", "body", "html") -} - -func TestParentsRollback(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := sel.Parents().End() - assertEqual(t, sel, sel2) -} - -func TestParentsFiltered(t *testing.T) { - sel := Doc().Find(".container-fluid").ParentsFiltered("body") - assertLength(t, sel.Nodes, 1) -} - -func TestParentsFilteredInvalid(t *testing.T) { - sel := Doc().Find(".container-fluid").ParentsFiltered("") - assertLength(t, sel.Nodes, 0) -} - -func TestParentsFilteredRollback(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := sel.ParentsFiltered("body").End() - assertEqual(t, sel, sel2) -} - -func TestParentsUntil(t *testing.T) { - sel := Doc().Find(".container-fluid").ParentsUntil("body") - assertLength(t, sel.Nodes, 6) -} - -func TestParentsUntilInvalid(t *testing.T) { - sel := Doc().Find(".container-fluid").ParentsUntil("") - assertLength(t, sel.Nodes, 8) -} - -func TestParentsUntilRollback(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := sel.ParentsUntil("body").End() - assertEqual(t, sel, sel2) -} - -func TestParentsUntilSelection(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := Doc().Find(".pvk-content") - sel = sel.ParentsUntilSelection(sel2) - assertLength(t, sel.Nodes, 3) -} - -func TestParentsUntilSelectionRollback(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := Doc().Find(".pvk-content") - sel2 = sel.ParentsUntilSelection(sel2).End() - assertEqual(t, sel, sel2) -} - -func TestParentsUntilNodes(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := Doc().Find(".pvk-content, .hero-unit") - sel = sel.ParentsUntilNodes(sel2.Nodes...) - assertLength(t, sel.Nodes, 2) -} - -func TestParentsUntilNodesRollback(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := Doc().Find(".pvk-content, .hero-unit") - sel2 = sel.ParentsUntilNodes(sel2.Nodes...).End() - assertEqual(t, sel, sel2) -} - -func TestParentsFilteredUntil(t *testing.T) { - sel := Doc().Find(".container-fluid").ParentsFilteredUntil(".pvk-content", "body") - assertLength(t, sel.Nodes, 2) -} - -func TestParentsFilteredUntilInvalid(t *testing.T) { - sel := Doc().Find(".container-fluid").ParentsFilteredUntil("", "") - assertLength(t, sel.Nodes, 0) -} - -func TestParentsFilteredUntilRollback(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := sel.ParentsFilteredUntil(".pvk-content", "body").End() - assertEqual(t, sel, sel2) -} - -func TestParentsFilteredUntilSelection(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := Doc().Find(".row-fluid") - sel = sel.ParentsFilteredUntilSelection("div", sel2) - assertLength(t, sel.Nodes, 3) -} - -func TestParentsFilteredUntilSelectionRollback(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := Doc().Find(".row-fluid") - sel2 = sel.ParentsFilteredUntilSelection("div", sel2).End() - assertEqual(t, sel, sel2) -} - -func TestParentsFilteredUntilNodes(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := Doc().Find(".row-fluid") - sel = sel.ParentsFilteredUntilNodes("body", sel2.Nodes...) - assertLength(t, sel.Nodes, 1) -} - -func TestParentsFilteredUntilNodesRollback(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := Doc().Find(".row-fluid") - sel2 = sel.ParentsFilteredUntilNodes("body", sel2.Nodes...).End() - assertEqual(t, sel, sel2) -} - -func TestSiblings(t *testing.T) { - sel := Doc().Find("h1").Siblings() - assertLength(t, sel.Nodes, 1) -} - -func TestSiblingsRollback(t *testing.T) { - sel := Doc().Find("h1") - sel2 := sel.Siblings().End() - assertEqual(t, sel, sel2) -} - -func TestSiblings2(t *testing.T) { - sel := Doc().Find(".pvk-gutter").Siblings() - assertLength(t, sel.Nodes, 9) -} - -func TestSiblings3(t *testing.T) { - sel := Doc().Find("body>.container-fluid").Siblings() - assertLength(t, sel.Nodes, 0) -} - -func TestSiblingsFiltered(t *testing.T) { - sel := Doc().Find(".pvk-gutter").SiblingsFiltered(".pvk-content") - assertLength(t, sel.Nodes, 3) -} - -func TestSiblingsFilteredInvalid(t *testing.T) { - sel := Doc().Find(".pvk-gutter").SiblingsFiltered("") - assertLength(t, sel.Nodes, 0) -} - -func TestSiblingsFilteredRollback(t *testing.T) { - sel := Doc().Find(".pvk-gutter") - sel2 := sel.SiblingsFiltered(".pvk-content").End() - assertEqual(t, sel, sel2) -} - -func TestNext(t *testing.T) { - sel := Doc().Find("h1").Next() - assertLength(t, sel.Nodes, 1) -} - -func TestNextRollback(t *testing.T) { - sel := Doc().Find("h1") - sel2 := sel.Next().End() - assertEqual(t, sel, sel2) -} - -func TestNext2(t *testing.T) { - sel := Doc().Find(".close").Next() - assertLength(t, sel.Nodes, 1) -} - -func TestNextNone(t *testing.T) { - sel := Doc().Find("small").Next() - assertLength(t, sel.Nodes, 0) -} - -func TestNextFiltered(t *testing.T) { - sel := Doc().Find(".container-fluid").NextFiltered("div") - assertLength(t, sel.Nodes, 2) -} - -func TestNextFilteredInvalid(t *testing.T) { - sel := Doc().Find(".container-fluid").NextFiltered("") - assertLength(t, sel.Nodes, 0) -} - -func TestNextFilteredRollback(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := sel.NextFiltered("div").End() - assertEqual(t, sel, sel2) -} - -func TestNextFiltered2(t *testing.T) { - sel := Doc().Find(".container-fluid").NextFiltered("[ng-view]") - assertLength(t, sel.Nodes, 1) -} - -func TestPrev(t *testing.T) { - sel := Doc().Find(".red").Prev() - assertLength(t, sel.Nodes, 1) - assertClass(t, sel, "green") -} - -func TestPrevRollback(t *testing.T) { - sel := Doc().Find(".red") - sel2 := sel.Prev().End() - assertEqual(t, sel, sel2) -} - -func TestPrev2(t *testing.T) { - sel := Doc().Find(".row-fluid").Prev() - assertLength(t, sel.Nodes, 5) -} - -func TestPrevNone(t *testing.T) { - sel := Doc().Find("h2").Prev() - assertLength(t, sel.Nodes, 0) -} - -func TestPrevFiltered(t *testing.T) { - sel := Doc().Find(".row-fluid").PrevFiltered(".row-fluid") - assertLength(t, sel.Nodes, 5) -} - -func TestPrevFilteredInvalid(t *testing.T) { - sel := Doc().Find(".row-fluid").PrevFiltered("") - assertLength(t, sel.Nodes, 0) -} - -func TestPrevFilteredRollback(t *testing.T) { - sel := Doc().Find(".row-fluid") - sel2 := sel.PrevFiltered(".row-fluid").End() - assertEqual(t, sel, sel2) -} - -func TestNextAll(t *testing.T) { - sel := Doc().Find("#cf2 div:nth-child(1)").NextAll() - assertLength(t, sel.Nodes, 3) -} - -func TestNextAllRollback(t *testing.T) { - sel := Doc().Find("#cf2 div:nth-child(1)") - sel2 := sel.NextAll().End() - assertEqual(t, sel, sel2) -} - -func TestNextAll2(t *testing.T) { - sel := Doc().Find("div[ng-cloak]").NextAll() - assertLength(t, sel.Nodes, 1) -} - -func TestNextAllNone(t *testing.T) { - sel := Doc().Find(".footer").NextAll() - assertLength(t, sel.Nodes, 0) -} - -func TestNextAllFiltered(t *testing.T) { - sel := Doc().Find("#cf2 .row-fluid").NextAllFiltered("[ng-cloak]") - assertLength(t, sel.Nodes, 2) -} - -func TestNextAllFilteredInvalid(t *testing.T) { - sel := Doc().Find("#cf2 .row-fluid").NextAllFiltered("") - assertLength(t, sel.Nodes, 0) -} - -func TestNextAllFilteredRollback(t *testing.T) { - sel := Doc().Find("#cf2 .row-fluid") - sel2 := sel.NextAllFiltered("[ng-cloak]").End() - assertEqual(t, sel, sel2) -} - -func TestNextAllFiltered2(t *testing.T) { - sel := Doc().Find(".close").NextAllFiltered("h4") - assertLength(t, sel.Nodes, 1) -} - -func TestPrevAll(t *testing.T) { - sel := Doc().Find("[ng-view]").PrevAll() - assertLength(t, sel.Nodes, 2) -} - -func TestPrevAllOrder(t *testing.T) { - sel := Doc().Find("[ng-view]").PrevAll() - assertLength(t, sel.Nodes, 2) - assertSelectionIs(t, sel, "#cf4", "#cf3") -} - -func TestPrevAllRollback(t *testing.T) { - sel := Doc().Find("[ng-view]") - sel2 := sel.PrevAll().End() - assertEqual(t, sel, sel2) -} - -func TestPrevAll2(t *testing.T) { - sel := Doc().Find(".pvk-gutter").PrevAll() - assertLength(t, sel.Nodes, 6) -} - -func TestPrevAllFiltered(t *testing.T) { - sel := Doc().Find(".pvk-gutter").PrevAllFiltered(".pvk-content") - assertLength(t, sel.Nodes, 3) -} - -func TestPrevAllFilteredInvalid(t *testing.T) { - sel := Doc().Find(".pvk-gutter").PrevAllFiltered("") - assertLength(t, sel.Nodes, 0) -} - -func TestPrevAllFilteredRollback(t *testing.T) { - sel := Doc().Find(".pvk-gutter") - sel2 := sel.PrevAllFiltered(".pvk-content").End() - assertEqual(t, sel, sel2) -} - -func TestNextUntil(t *testing.T) { - sel := Doc().Find(".alert a").NextUntil("p") - assertLength(t, sel.Nodes, 1) - assertSelectionIs(t, sel, "h4") -} - -func TestNextUntilInvalid(t *testing.T) { - sel := Doc().Find(".alert a").NextUntil("") - assertLength(t, sel.Nodes, 2) -} - -func TestNextUntil2(t *testing.T) { - sel := Doc().Find("#cf2-1").NextUntil("[ng-cloak]") - assertLength(t, sel.Nodes, 1) - assertSelectionIs(t, sel, "#cf2-2") -} - -func TestNextUntilOrder(t *testing.T) { - sel := Doc().Find("#cf2-1").NextUntil("#cf2-4") - assertLength(t, sel.Nodes, 2) - assertSelectionIs(t, sel, "#cf2-2", "#cf2-3") -} - -func TestNextUntilRollback(t *testing.T) { - sel := Doc().Find("#cf2-1") - sel2 := sel.PrevUntil("#cf2-4").End() - assertEqual(t, sel, sel2) -} - -func TestNextUntilSelection(t *testing.T) { - sel := Doc2().Find("#n2") - sel2 := Doc2().Find("#n4") - sel2 = sel.NextUntilSelection(sel2) - assertLength(t, sel2.Nodes, 1) - assertSelectionIs(t, sel2, "#n3") -} - -func TestNextUntilSelectionRollback(t *testing.T) { - sel := Doc2().Find("#n2") - sel2 := Doc2().Find("#n4") - sel2 = sel.NextUntilSelection(sel2).End() - assertEqual(t, sel, sel2) -} - -func TestNextUntilNodes(t *testing.T) { - sel := Doc2().Find("#n2") - sel2 := Doc2().Find("#n5") - sel2 = sel.NextUntilNodes(sel2.Nodes...) - assertLength(t, sel2.Nodes, 2) - assertSelectionIs(t, sel2, "#n3", "#n4") -} - -func TestNextUntilNodesRollback(t *testing.T) { - sel := Doc2().Find("#n2") - sel2 := Doc2().Find("#n5") - sel2 = sel.NextUntilNodes(sel2.Nodes...).End() - assertEqual(t, sel, sel2) -} - -func TestPrevUntil(t *testing.T) { - sel := Doc().Find(".alert p").PrevUntil("a") - assertLength(t, sel.Nodes, 1) - assertSelectionIs(t, sel, "h4") -} - -func TestPrevUntilInvalid(t *testing.T) { - sel := Doc().Find(".alert p").PrevUntil("") - assertLength(t, sel.Nodes, 2) -} - -func TestPrevUntil2(t *testing.T) { - sel := Doc().Find("[ng-cloak]").PrevUntil(":not([ng-cloak])") - assertLength(t, sel.Nodes, 1) - assertSelectionIs(t, sel, "[ng-cloak]") -} - -func TestPrevUntilOrder(t *testing.T) { - sel := Doc().Find("#cf2-4").PrevUntil("#cf2-1") - assertLength(t, sel.Nodes, 2) - assertSelectionIs(t, sel, "#cf2-3", "#cf2-2") -} - -func TestPrevUntilRollback(t *testing.T) { - sel := Doc().Find("#cf2-4") - sel2 := sel.PrevUntil("#cf2-1").End() - assertEqual(t, sel, sel2) -} - -func TestPrevUntilSelection(t *testing.T) { - sel := Doc2().Find("#n4") - sel2 := Doc2().Find("#n2") - sel2 = sel.PrevUntilSelection(sel2) - assertLength(t, sel2.Nodes, 1) - assertSelectionIs(t, sel2, "#n3") -} - -func TestPrevUntilSelectionRollback(t *testing.T) { - sel := Doc2().Find("#n4") - sel2 := Doc2().Find("#n2") - sel2 = sel.PrevUntilSelection(sel2).End() - assertEqual(t, sel, sel2) -} - -func TestPrevUntilNodes(t *testing.T) { - sel := Doc2().Find("#n5") - sel2 := Doc2().Find("#n2") - sel2 = sel.PrevUntilNodes(sel2.Nodes...) - assertLength(t, sel2.Nodes, 2) - assertSelectionIs(t, sel2, "#n4", "#n3") -} - -func TestPrevUntilNodesRollback(t *testing.T) { - sel := Doc2().Find("#n5") - sel2 := Doc2().Find("#n2") - sel2 = sel.PrevUntilNodes(sel2.Nodes...).End() - assertEqual(t, sel, sel2) -} - -func TestNextFilteredUntil(t *testing.T) { - sel := Doc2().Find(".two").NextFilteredUntil(".even", ".six") - assertLength(t, sel.Nodes, 4) - assertSelectionIs(t, sel, "#n3", "#n5", "#nf3", "#nf5") -} - -func TestNextFilteredUntilInvalid(t *testing.T) { - sel := Doc2().Find(".two").NextFilteredUntil("", "") - assertLength(t, sel.Nodes, 0) -} - -func TestNextFilteredUntilRollback(t *testing.T) { - sel := Doc2().Find(".two") - sel2 := sel.NextFilteredUntil(".even", ".six").End() - assertEqual(t, sel, sel2) -} - -func TestNextFilteredUntilSelection(t *testing.T) { - sel := Doc2().Find(".even") - sel2 := Doc2().Find(".five") - sel = sel.NextFilteredUntilSelection(".even", sel2) - assertLength(t, sel.Nodes, 2) - assertSelectionIs(t, sel, "#n3", "#nf3") -} - -func TestNextFilteredUntilSelectionRollback(t *testing.T) { - sel := Doc2().Find(".even") - sel2 := Doc2().Find(".five") - sel3 := sel.NextFilteredUntilSelection(".even", sel2).End() - assertEqual(t, sel, sel3) -} - -func TestNextFilteredUntilNodes(t *testing.T) { - sel := Doc2().Find(".even") - sel2 := Doc2().Find(".four") - sel = sel.NextFilteredUntilNodes(".odd", sel2.Nodes...) - assertLength(t, sel.Nodes, 4) - assertSelectionIs(t, sel, "#n2", "#n6", "#nf2", "#nf6") -} - -func TestNextFilteredUntilNodesRollback(t *testing.T) { - sel := Doc2().Find(".even") - sel2 := Doc2().Find(".four") - sel3 := sel.NextFilteredUntilNodes(".odd", sel2.Nodes...).End() - assertEqual(t, sel, sel3) -} - -func TestPrevFilteredUntil(t *testing.T) { - sel := Doc2().Find(".five").PrevFilteredUntil(".odd", ".one") - assertLength(t, sel.Nodes, 4) - assertSelectionIs(t, sel, "#n4", "#n2", "#nf4", "#nf2") -} - -func TestPrevFilteredUntilInvalid(t *testing.T) { - sel := Doc2().Find(".five").PrevFilteredUntil("", "") - assertLength(t, sel.Nodes, 0) -} - -func TestPrevFilteredUntilRollback(t *testing.T) { - sel := Doc2().Find(".four") - sel2 := sel.PrevFilteredUntil(".odd", ".one").End() - assertEqual(t, sel, sel2) -} - -func TestPrevFilteredUntilSelection(t *testing.T) { - sel := Doc2().Find(".odd") - sel2 := Doc2().Find(".two") - sel = sel.PrevFilteredUntilSelection(".odd", sel2) - assertLength(t, sel.Nodes, 2) - assertSelectionIs(t, sel, "#n4", "#nf4") -} - -func TestPrevFilteredUntilSelectionRollback(t *testing.T) { - sel := Doc2().Find(".even") - sel2 := Doc2().Find(".five") - sel3 := sel.PrevFilteredUntilSelection(".even", sel2).End() - assertEqual(t, sel, sel3) -} - -func TestPrevFilteredUntilNodes(t *testing.T) { - sel := Doc2().Find(".even") - sel2 := Doc2().Find(".four") - sel = sel.PrevFilteredUntilNodes(".odd", sel2.Nodes...) - assertLength(t, sel.Nodes, 2) - assertSelectionIs(t, sel, "#n2", "#nf2") -} - -func TestPrevFilteredUntilNodesRollback(t *testing.T) { - sel := Doc2().Find(".even") - sel2 := Doc2().Find(".four") - sel3 := sel.PrevFilteredUntilNodes(".odd", sel2.Nodes...).End() - assertEqual(t, sel, sel3) -} - -func TestClosestItself(t *testing.T) { - sel := Doc2().Find(".three") - sel2 := sel.Closest(".row") - assertLength(t, sel2.Nodes, sel.Length()) - assertSelectionIs(t, sel2, "#n3", "#nf3") -} - -func TestClosestNoDupes(t *testing.T) { - sel := Doc().Find(".span12") - sel2 := sel.Closest(".pvk-content") - assertLength(t, sel2.Nodes, 1) - assertClass(t, sel2, "pvk-content") -} - -func TestClosestNone(t *testing.T) { - sel := Doc().Find("h4") - sel2 := sel.Closest("a") - assertLength(t, sel2.Nodes, 0) -} - -func TestClosestInvalid(t *testing.T) { - sel := Doc().Find("h4") - sel2 := sel.Closest("") - assertLength(t, sel2.Nodes, 0) -} - -func TestClosestMany(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := sel.Closest(".pvk-content") - assertLength(t, sel2.Nodes, 2) - assertSelectionIs(t, sel2, "#pc1", "#pc2") -} - -func TestClosestRollback(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := sel.Closest(".pvk-content").End() - assertEqual(t, sel, sel2) -} - -func TestClosestSelectionItself(t *testing.T) { - sel := Doc2().Find(".three") - sel2 := sel.ClosestSelection(Doc2().Find(".row")) - assertLength(t, sel2.Nodes, sel.Length()) -} - -func TestClosestSelectionNoDupes(t *testing.T) { - sel := Doc().Find(".span12") - sel2 := sel.ClosestSelection(Doc().Find(".pvk-content")) - assertLength(t, sel2.Nodes, 1) - assertClass(t, sel2, "pvk-content") -} - -func TestClosestSelectionNone(t *testing.T) { - sel := Doc().Find("h4") - sel2 := sel.ClosestSelection(Doc().Find("a")) - assertLength(t, sel2.Nodes, 0) -} - -func TestClosestSelectionMany(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := sel.ClosestSelection(Doc().Find(".pvk-content")) - assertLength(t, sel2.Nodes, 2) - assertSelectionIs(t, sel2, "#pc1", "#pc2") -} - -func TestClosestSelectionRollback(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := sel.ClosestSelection(Doc().Find(".pvk-content")).End() - assertEqual(t, sel, sel2) -} - -func TestClosestNodesItself(t *testing.T) { - sel := Doc2().Find(".three") - sel2 := sel.ClosestNodes(Doc2().Find(".row").Nodes...) - assertLength(t, sel2.Nodes, sel.Length()) -} - -func TestClosestNodesNoDupes(t *testing.T) { - sel := Doc().Find(".span12") - sel2 := sel.ClosestNodes(Doc().Find(".pvk-content").Nodes...) - assertLength(t, sel2.Nodes, 1) - assertClass(t, sel2, "pvk-content") -} - -func TestClosestNodesNone(t *testing.T) { - sel := Doc().Find("h4") - sel2 := sel.ClosestNodes(Doc().Find("a").Nodes...) - assertLength(t, sel2.Nodes, 0) -} - -func TestClosestNodesMany(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := sel.ClosestNodes(Doc().Find(".pvk-content").Nodes...) - assertLength(t, sel2.Nodes, 2) - assertSelectionIs(t, sel2, "#pc1", "#pc2") -} - -func TestClosestNodesRollback(t *testing.T) { - sel := Doc().Find(".container-fluid") - sel2 := sel.ClosestNodes(Doc().Find(".pvk-content").Nodes...).End() - assertEqual(t, sel, sel2) -} - -func TestIssue26(t *testing.T) { - img1 := `150x150` - img2 := `150x150` - cases := []struct { - s string - l int - }{ - {s: img1 + img2, l: 2}, - {s: img1, l: 1}, - {s: img2, l: 1}, - } - for _, c := range cases { - doc, err := NewDocumentFromReader(strings.NewReader(c.s)) - if err != nil { - t.Fatal(err) - } - sel := doc.Find("img[src]") - assertLength(t, sel.Nodes, c.l) - } -} diff --git a/vendor/github.com/PuerkitoBio/goquery/type_test.go b/vendor/github.com/PuerkitoBio/goquery/type_test.go deleted file mode 100644 index 1e82d5ee0..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/type_test.go +++ /dev/null @@ -1,202 +0,0 @@ -package goquery - -import ( - "bytes" - "fmt" - "os" - "strings" - "testing" - - "golang.org/x/net/html" -) - -// Test helper functions and members -var doc *Document -var doc2 *Document -var doc3 *Document -var docB *Document -var docW *Document - -func Doc() *Document { - if doc == nil { - doc = loadDoc("page.html") - } - return doc -} - -func Doc2() *Document { - if doc2 == nil { - doc2 = loadDoc("page2.html") - } - return doc2 -} - -func Doc2Clone() *Document { - return CloneDocument(Doc2()) -} - -func Doc3() *Document { - if doc3 == nil { - doc3 = loadDoc("page3.html") - } - return doc3 -} - -func Doc3Clone() *Document { - return CloneDocument(Doc3()) -} - -func DocB() *Document { - if docB == nil { - docB = loadDoc("gotesting.html") - } - return docB -} - -func DocW() *Document { - if docW == nil { - docW = loadDoc("gowiki.html") - } - return docW -} - -func assertLength(t *testing.T, nodes []*html.Node, length int) { - if len(nodes) != length { - t.Errorf("Expected %d nodes, found %d.", length, len(nodes)) - for i, n := range nodes { - t.Logf("Node %d: %+v.", i, n) - } - } -} - -func assertClass(t *testing.T, sel *Selection, class string) { - if !sel.HasClass(class) { - t.Errorf("Expected node to have class %s, found %+v.", class, sel.Get(0)) - } -} - -func assertPanic(t *testing.T) { - if e := recover(); e == nil { - t.Error("Expected a panic.") - } -} - -func assertEqual(t *testing.T, s1 *Selection, s2 *Selection) { - if s1 != s2 { - t.Error("Expected selection objects to be the same.") - } -} - -func assertSelectionIs(t *testing.T, sel *Selection, is ...string) { - for i := 0; i < sel.Length(); i++ { - if !sel.Eq(i).Is(is[i]) { - t.Errorf("Expected node %d to be %s, found %+v", i, is[i], sel.Get(i)) - } - } -} - -func printSel(t *testing.T, sel *Selection) { - if testing.Verbose() { - h, err := sel.Html() - if err != nil { - t.Fatal(err) - } - t.Log(h) - } -} - -func loadDoc(page string) *Document { - var f *os.File - var e error - - if f, e = os.Open(fmt.Sprintf("./testdata/%s", page)); e != nil { - panic(e.Error()) - } - defer f.Close() - - var node *html.Node - if node, e = html.Parse(f); e != nil { - panic(e.Error()) - } - return NewDocumentFromNode(node) -} - -func TestNewDocument(t *testing.T) { - if f, e := os.Open("./testdata/page.html"); e != nil { - t.Error(e.Error()) - } else { - defer f.Close() - if node, e := html.Parse(f); e != nil { - t.Error(e.Error()) - } else { - doc = NewDocumentFromNode(node) - } - } -} - -func TestNewDocumentFromReader(t *testing.T) { - cases := []struct { - src string - err bool - sel string - cnt int - }{ - 0: { - src: ` - - -Test - -

Hi

- -`, - sel: "h1", - cnt: 1, - }, - 1: { - // Actually pretty hard to make html.Parse return an error - // based on content... - src: `>>qq>`, - }, - } - buf := bytes.NewBuffer(nil) - - for i, c := range cases { - buf.Reset() - buf.WriteString(c.src) - - d, e := NewDocumentFromReader(buf) - if (e != nil) != c.err { - if c.err { - t.Errorf("[%d] - expected error, got none", i) - } else { - t.Errorf("[%d] - expected no error, got %s", i, e) - } - } - if c.sel != "" { - s := d.Find(c.sel) - if s.Length() != c.cnt { - t.Errorf("[%d] - expected %d nodes, found %d", i, c.cnt, s.Length()) - } - } - } -} - -func TestNewDocumentFromResponseNil(t *testing.T) { - _, e := NewDocumentFromResponse(nil) - if e == nil { - t.Error("Expected error, got none") - } -} - -func TestIssue103(t *testing.T) { - d, err := NewDocumentFromReader(strings.NewReader("Scientists Stored These Images in DNA—Then Flawlessly Retrieved Them")) - if err != nil { - t.Error(err) - } - text := d.Find("title").Text() - for i, r := range text { - t.Logf("%d: %d - %q\n", i, r, string(r)) - } - t.Log(text) -} diff --git a/vendor/github.com/PuerkitoBio/goquery/utilities_test.go b/vendor/github.com/PuerkitoBio/goquery/utilities_test.go deleted file mode 100644 index c8e9d5400..000000000 --- a/vendor/github.com/PuerkitoBio/goquery/utilities_test.go +++ /dev/null @@ -1,128 +0,0 @@ -package goquery - -import ( - "reflect" - "sort" - "strings" - "testing" - - "golang.org/x/net/html" -) - -var allNodes = ` - - - - - -

- This is some text. -

-
-

-

- -` - -func TestNodeName(t *testing.T) { - doc, err := NewDocumentFromReader(strings.NewReader(allNodes)) - if err != nil { - t.Fatal(err) - } - - n0 := doc.Nodes[0] - nDT := n0.FirstChild - sMeta := doc.Find("meta") - nMeta := sMeta.Get(0) - sP := doc.Find("p") - nP := sP.Get(0) - nComment := nP.FirstChild - nText := nComment.NextSibling - - cases := []struct { - node *html.Node - typ html.NodeType - want string - }{ - {n0, html.DocumentNode, nodeNames[html.DocumentNode]}, - {nDT, html.DoctypeNode, "html"}, - {nMeta, html.ElementNode, "meta"}, - {nP, html.ElementNode, "p"}, - {nComment, html.CommentNode, nodeNames[html.CommentNode]}, - {nText, html.TextNode, nodeNames[html.TextNode]}, - } - for i, c := range cases { - got := NodeName(newSingleSelection(c.node, doc)) - if c.node.Type != c.typ { - t.Errorf("%d: want type %v, got %v", i, c.typ, c.node.Type) - } - if got != c.want { - t.Errorf("%d: want %q, got %q", i, c.want, got) - } - } -} - -func TestNodeNameMultiSel(t *testing.T) { - doc, err := NewDocumentFromReader(strings.NewReader(allNodes)) - if err != nil { - t.Fatal(err) - } - - in := []string{"p", "h1", "div"} - var out []string - doc.Find(strings.Join(in, ", ")).Each(func(i int, s *Selection) { - got := NodeName(s) - out = append(out, got) - }) - sort.Strings(in) - sort.Strings(out) - if !reflect.DeepEqual(in, out) { - t.Errorf("want %v, got %v", in, out) - } -} - -func TestOuterHtml(t *testing.T) { - doc, err := NewDocumentFromReader(strings.NewReader(allNodes)) - if err != nil { - t.Fatal(err) - } - - n0 := doc.Nodes[0] - nDT := n0.FirstChild - sMeta := doc.Find("meta") - sP := doc.Find("p") - nP := sP.Get(0) - nComment := nP.FirstChild - nText := nComment.NextSibling - sHeaders := doc.Find(".header") - - cases := []struct { - node *html.Node - sel *Selection - want string - }{ - {nDT, nil, ""}, // render makes DOCTYPE all caps - {nil, sMeta, ``}, // and auto-closes the meta - {nil, sP, `

- This is some text. -

`}, - {nComment, nil, ""}, - {nText, nil, ` - This is some text. - `}, - {nil, sHeaders, `

`}, - } - for i, c := range cases { - if c.sel == nil { - c.sel = newSingleSelection(c.node, doc) - } - got, err := OuterHtml(c.sel) - if err != nil { - t.Fatal(err) - } - - if got != c.want { - t.Errorf("%d: want %q, got %q", i, c.want, got) - } - } -} diff --git a/vendor/github.com/RoaringBitmap/roaring/.gitmodules b/vendor/github.com/RoaringBitmap/roaring/.gitmodules index 7d58d8784..e69de29bb 100644 --- a/vendor/github.com/RoaringBitmap/roaring/.gitmodules +++ b/vendor/github.com/RoaringBitmap/roaring/.gitmodules @@ -1,3 +0,0 @@ -[submodule "testdata/real-roaring-datasets"] - path = testdata/real-roaring-datasets - url = https://github.com/RoaringBitmap/real-roaring-datasets diff --git a/vendor/github.com/RoaringBitmap/roaring/.travis.yml b/vendor/github.com/RoaringBitmap/roaring/.travis.yml index cbb5be895..8fabefb12 100644 --- a/vendor/github.com/RoaringBitmap/roaring/.travis.yml +++ b/vendor/github.com/RoaringBitmap/roaring/.travis.yml @@ -10,6 +10,7 @@ notifications: go: - 1.7 - 1.8 +- 1.9 - tip # Next lines seem to fail horribly diff --git a/vendor/github.com/RoaringBitmap/roaring/AUTHORS b/vendor/github.com/RoaringBitmap/roaring/AUTHORS index 4f5f9146f..08c074047 100644 --- a/vendor/github.com/RoaringBitmap/roaring/AUTHORS +++ b/vendor/github.com/RoaringBitmap/roaring/AUTHORS @@ -7,3 +7,4 @@ Bob Potter (@bpot), Tyson Maly (@tvmaly), Will Glynn (@willglynn), Brent Pedersen (@brentp) +Maciej BiÅ‚as (@maciej) diff --git a/vendor/github.com/RoaringBitmap/roaring/README.md b/vendor/github.com/RoaringBitmap/roaring/README.md index e3c5defb6..460203af4 100644 --- a/vendor/github.com/RoaringBitmap/roaring/README.md +++ b/vendor/github.com/RoaringBitmap/roaring/README.md @@ -3,9 +3,23 @@ roaring [![Build Status](https://travis-ci.org/RoaringBitmap/roaring.png)](https This is a go port of the Roaring bitmap data structure. -Roaring is used by [Apache Spark](https://spark.apache.org/), [Apache Kylin](http://kylin.io), [Netflix Atlas](https://github.com/Netflix/atlas), [LinkedIn Pinot](https://github.com/linkedin/pinot/wiki), [Druid.io](http://druid.io/), [Whoosh](https://pypi.python.org/pypi/Whoosh/) -and [Apache Lucene](http://lucene.apache.org/) (as well as supporting systems -such as Solr and Elastic). + +Roaring bitmaps are used by several major systems such as [Apache Lucene][lucene] and derivative systems such as [Solr][solr] and +[Elasticsearch][elasticsearch], [Metamarkets' Druid][druid], [LinkedIn Pinot][pinot], [Netflix Atlas][atlas], [Apache Spark][spark], [OpenSearchServer][opensearchserver], [Cloud Torrent][cloudtorrent], [Whoosh][whoosh], [Pilosa][pilosa], [Microsoft Visual Studio Team Services (VSTS)][vsts], and eBay's [Apache Kylin][kylin]. + +[lucene]: https://lucene.apache.org/ +[solr]: https://lucene.apache.org/solr/ +[elasticsearch]: https://www.elastic.co/products/elasticsearch +[druid]: http://druid.io/ +[spark]: https://spark.apache.org/ +[opensearchserver]: http://www.opensearchserver.com +[cloudtorrent]: https://github.com/jpillora/cloud-torrent +[whoosh]: https://bitbucket.org/mchaput/whoosh/wiki/Home +[pilosa]: https://www.pilosa.com/ +[kylin]: http://kylin.apache.org/ +[pinot]: http://github.com/linkedin/pinot/wiki +[vsts]: https://www.visualstudio.com/team-services/ +[atlas]: https://github.com/Netflix/atlas Roaring bitmaps are found to work well in many important applications: @@ -27,6 +41,7 @@ Copyright 2016 by the authors. ### References +- Daniel Lemire, Owen Kaser, Nathan Kurz, Luca Deri, Chris O'Hara, François Saint-Jacques, Gregory Ssi-Yan-Kai, Roaring Bitmaps: Implementation of an Optimized Software Library [arXiv:1709.07821](https://arxiv.org/abs/1709.07821) - Samy Chambi, Daniel Lemire, Owen Kaser, Robert Godin, Better bitmap performance with Roaring bitmaps, Software: Practice and Experience Volume 46, Issue 5, pages 709–719, May 2016 diff --git a/vendor/github.com/RoaringBitmap/roaring/arraycontainer_gen_test.go b/vendor/github.com/RoaringBitmap/roaring/arraycontainer_gen_test.go deleted file mode 100644 index 292afe9c9..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/arraycontainer_gen_test.go +++ /dev/null @@ -1,125 +0,0 @@ -package roaring - -// NOTE: THIS FILE WAS PRODUCED BY THE -// MSGP CODE GENERATION TOOL (github.com/tinylib/msgp) -// DO NOT EDIT - -import ( - "bytes" - "testing" - - "github.com/tinylib/msgp/msgp" -) - -func TestMarshalUnmarshalarrayContainer(t *testing.T) { - v := arrayContainer{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsgarrayContainer(b *testing.B) { - v := arrayContainer{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgarrayContainer(b *testing.B) { - v := arrayContainer{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshalarrayContainer(b *testing.B) { - v := arrayContainer{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecodearrayContainer(t *testing.T) { - v := arrayContainer{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Logf("WARNING: Msgsize() for %v is inaccurate", v) - } - - vn := arrayContainer{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncodearrayContainer(b *testing.B) { - v := arrayContainer{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecodearrayContainer(b *testing.B) { - v := arrayContainer{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} diff --git a/vendor/github.com/RoaringBitmap/roaring/arraycontainer_test.go b/vendor/github.com/RoaringBitmap/roaring/arraycontainer_test.go deleted file mode 100644 index d3d25a3d9..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/arraycontainer_test.go +++ /dev/null @@ -1,351 +0,0 @@ -package roaring - -// to run just these tests: go test -run TestArrayContainer* - -import ( - "math/rand" - "reflect" - "testing" - - . "github.com/smartystreets/goconvey/convey" -) - -func TestArrayContainerTransition(t *testing.T) { - v := container(newArrayContainer()) - arraytype := reflect.TypeOf(v) - for i := 0; i < arrayDefaultMaxSize; i++ { - v = v.iaddReturnMinimized(uint16(i)) - } - if v.getCardinality() != arrayDefaultMaxSize { - t.Errorf("Bad cardinality.") - } - if reflect.TypeOf(v) != arraytype { - t.Errorf("Should be an array.") - } - for i := 0; i < arrayDefaultMaxSize; i++ { - v = v.iaddReturnMinimized(uint16(i)) - } - if v.getCardinality() != arrayDefaultMaxSize { - t.Errorf("Bad cardinality.") - } - if reflect.TypeOf(v) != arraytype { - t.Errorf("Should be an array.") - } - v = v.iaddReturnMinimized(uint16(arrayDefaultMaxSize)) - if v.getCardinality() != arrayDefaultMaxSize+1 { - t.Errorf("Bad cardinality.") - } - if reflect.TypeOf(v) == arraytype { - t.Errorf("Should be a bitmap.") - } - v = v.iremoveReturnMinimized(uint16(arrayDefaultMaxSize)) - if v.getCardinality() != arrayDefaultMaxSize { - t.Errorf("Bad cardinality.") - } - if reflect.TypeOf(v) != arraytype { - t.Errorf("Should be an array.") - } -} - -func TestArrayContainerRank(t *testing.T) { - v := container(newArrayContainer()) - v = v.iaddReturnMinimized(10) - v = v.iaddReturnMinimized(100) - v = v.iaddReturnMinimized(1000) - if v.getCardinality() != 3 { - t.Errorf("Bogus cardinality.") - } - for i := 0; i <= arrayDefaultMaxSize; i++ { - thisrank := v.rank(uint16(i)) - if i < 10 { - if thisrank != 0 { - t.Errorf("At %d should be zero but is %d ", i, thisrank) - } - } else if i < 100 { - if thisrank != 1 { - t.Errorf("At %d should be zero but is %d ", i, thisrank) - } - } else if i < 1000 { - if thisrank != 2 { - t.Errorf("At %d should be zero but is %d ", i, thisrank) - } - } else { - if thisrank != 3 { - t.Errorf("At %d should be zero but is %d ", i, thisrank) - } - } - } -} - -func TestArrayContainerMassiveSetAndGet(t *testing.T) { - v := container(newArrayContainer()) - for j := 0; j <= arrayDefaultMaxSize; j++ { - - v = v.iaddReturnMinimized(uint16(j)) - if v.getCardinality() != 1+j { - t.Errorf("Bogus cardinality %d %d. ", v.getCardinality(), j) - } - for i := 0; i <= arrayDefaultMaxSize; i++ { - if i <= j { - if v.contains(uint16(i)) != true { - t.Errorf("I added a number in vain.") - } - } else { - if v.contains(uint16(i)) != false { - t.Errorf("Ghost content") - break - } - } - } - } -} - -type FakeContainer struct { - arrayContainer -} - -func TestArrayContainerUnsupportedType(t *testing.T) { - a := container(newArrayContainer()) - testContainerPanics(t, a) - b := container(newBitmapContainer()) - testContainerPanics(t, b) -} - -func testContainerPanics(t *testing.T, c container) { - f := &FakeContainer{} - assertPanic(t, func() { - c.or(f) - }) - assertPanic(t, func() { - c.ior(f) - }) - assertPanic(t, func() { - c.lazyIOR(f) - }) - assertPanic(t, func() { - c.lazyOR(f) - }) - assertPanic(t, func() { - c.and(f) - }) - assertPanic(t, func() { - c.intersects(f) - }) - assertPanic(t, func() { - c.iand(f) - }) - assertPanic(t, func() { - c.xor(f) - }) - assertPanic(t, func() { - c.andNot(f) - }) - assertPanic(t, func() { - c.iandNot(f) - }) -} - -func assertPanic(t *testing.T, f func()) { - defer func() { - if r := recover(); r == nil { - t.Errorf("The code did not panic") - } - }() - f() -} - -func TestArrayContainerNumberOfRuns025(t *testing.T) { - - Convey("arrayContainer's numberOfRuns() function should be correct against the runContainer equivalent", - t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 1000, percentFill: .1, ntrial: 10}, - /* - trial{n: 100, percentFill: .5, ntrial: 10}, - trial{n: 100, percentFill: .01, ntrial: 10}, - trial{n: 100, percentFill: .99, ntrial: 10}, - */ - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestArrayContainerNumberOfRuns023 on check# j=%v", j) - ma := make(map[int]bool) - - n := tr.n - a := []uint16{} - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - } - - showArray16(a, "a") - - // RunContainer computes this automatically - rc := newRunContainer16FromVals(false, a...) - rcNr := rc.numberOfRuns() - - p("rcNr from run container is %v", rcNr) - - // vs arrayContainer - ac := newArrayContainer() - for k := range ma { - ac.iadd(uint16(k)) - } - - acNr := ac.numberOfRuns() - So(acNr, ShouldEqual, rcNr) - - // get coverage of arrayContainer coners... - So(ac.serializedSizeInBytes(), ShouldEqual, 2*len(ma)) - - So(func() { ac.iaddRange(2, 1) }, ShouldNotPanic) - So(func() { ac.iremoveRange(2, 1) }, ShouldNotPanic) - ac.iremoveRange(0, 2) - ac.iremoveRange(0, 2) - delete(ma, 0) - delete(ma, 1) - So(ac.getCardinality(), ShouldEqual, len(ma)) - ac.iadd(0) - ac.iadd(1) - ac.iadd(2) - ma[0] = true - ma[1] = true - ma[2] = true - newguy := ac.not(0, 3).(*arrayContainer) - So(newguy.contains(0), ShouldBeFalse) - So(newguy.contains(1), ShouldBeFalse) - So(newguy.contains(2), ShouldBeFalse) - newguy.notClose(0, 2) - newguy.remove(2) - newguy.remove(2) - newguy.ior(ac) - - messedUp := newArrayContainer() - So(messedUp.numberOfRuns(), ShouldEqual, 0) - - // messed up - messedUp.content = []uint16{1, 1} - So(func() { messedUp.numberOfRuns() }, ShouldPanic) - messedUp.content = []uint16{2, 1} - So(func() { messedUp.numberOfRuns() }, ShouldPanic) - - shouldBeBit := newArrayContainer() - for i := 0; i < arrayDefaultMaxSize+1; i++ { - shouldBeBit.iadd(uint16(i * 2)) - } - bit := shouldBeBit.toEfficientContainer() - _, isBit := bit.(*bitmapContainer) - So(isBit, ShouldBeTrue) - - //fmt.Printf("\nnum runs was: %v\n", rcNr) - } - p("done with randomized arrayContianer.numberOrRuns() checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestArrayContainerIaddRangeNearMax068(t *testing.T) { - - Convey("arrayContainer iaddRange should work near MaxUint16", t, func() { - - iv := []interval16{{65525, 65527}, {65530, 65530}, {65534, 65535}} - rc := newRunContainer16TakeOwnership(iv) - - ac2 := rc.toArrayContainer() - So(ac2.equals(rc), ShouldBeTrue) - So(rc.equals(ac2), ShouldBeTrue) - - ac := newArrayContainer() - endx := int(MaxUint16) + 1 - first := endx - 3 - ac.iaddRange(first-20, endx-20) - ac.iaddRange(first-6, endx-6) - ac.iaddRange(first, endx) - So(ac.getCardinality(), ShouldEqual, 9) - - }) -} - -func TestArrayContainerEtc070(t *testing.T) { - - Convey("arrayContainer rarely exercised code paths should get some coverage", t, func() { - - iv := []interval16{{65525, 65527}, {65530, 65530}, {65534, 65535}} - rc := newRunContainer16TakeOwnership(iv) - ac := rc.toArrayContainer() - - // not when nothing to do just returns a clone - So(ac.equals(ac.not(0, 0)), ShouldBeTrue) - So(ac.equals(ac.notClose(1, 0)), ShouldBeTrue) - - // not will promote to bitmapContainer if card is big enough - - ac = newArrayContainer() - ac.inot(0, MaxUint16+1) - rc = newRunContainer16Range(0, MaxUint16) - - p("ac.card = %v", ac.getCardinality()) - p("rc.card = %v", rc.getCardinality()) - So(rc.equals(ac), ShouldBeTrue) - - // comparing two array containers with different card - ac2 := newArrayContainer() - So(ac2.equals(ac), ShouldBeFalse) - - // comparing two arrays with same card but different content - ac3 := newArrayContainer() - ac4 := newArrayContainer() - ac3.iadd(1) - ac3.iadd(2) - ac4.iadd(1) - So(ac3.equals(ac4), ShouldBeFalse) - - // compare array vs other with different card - So(ac3.equals(rc), ShouldBeFalse) - - // compare array vs other, same card, different content - rc = newRunContainer16Range(0, 0) - So(ac4.equals(rc), ShouldBeFalse) - - // remove from middle of array - ac5 := newArrayContainer() - ac5.iaddRange(0, 10) - So(ac5.getCardinality(), ShouldEqual, 10) - ac6 := ac5.remove(5) - So(ac6.getCardinality(), ShouldEqual, 9) - - // lazyorArray that converts to bitmap - ac5.iaddRange(0, arrayLazyLowerBound-1) - ac6.iaddRange(arrayLazyLowerBound, 2*arrayLazyLowerBound-2) - ac6a := ac6.(*arrayContainer) - bc := ac5.lazyorArray(ac6a) - _, isBitmap := bc.(*bitmapContainer) - So(isBitmap, ShouldBeTrue) - - // andBitmap - ac = newArrayContainer() - ac.iaddRange(0, 10) - bc9 := newBitmapContainer() - bc9.iaddRange(0, 5) - and := ac.andBitmap(bc9) - So(and.getCardinality(), ShouldEqual, 5) - - // numberOfRuns with 1 member - ac10 := newArrayContainer() - ac10.iadd(1) - So(ac10.numberOfRuns(), ShouldEqual, 1) - }) -} diff --git a/vendor/github.com/RoaringBitmap/roaring/benchmark_test.go b/vendor/github.com/RoaringBitmap/roaring/benchmark_test.go deleted file mode 100644 index c6c338cac..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/benchmark_test.go +++ /dev/null @@ -1,535 +0,0 @@ -package roaring - -import ( - "bytes" - "fmt" - "math/rand" - "runtime" - "testing" - - "github.com/willf/bitset" -) - -// BENCHMARKS, to run them type "go test -bench Benchmark -run -" - -var c9 uint - -// go test -bench BenchmarkMemoryUsage -run - -func BenchmarkMemoryUsage(b *testing.B) { - b.StopTimer() - bitmaps := make([]*Bitmap, 0, 10) - - incr := uint32(1 << 16) - max := uint32(1<<32 - 1) - for x := 0; x < 10; x++ { - rb := NewBitmap() - - var i uint32 - for i = 0; i <= max-incr; i += incr { - rb.Add(i) - } - - bitmaps = append(bitmaps, rb) - } - - var stats runtime.MemStats - runtime.ReadMemStats(&stats) - fmt.Printf("\nHeapInUse %d\n", stats.HeapInuse) - fmt.Printf("HeapObjects %d\n", stats.HeapObjects) - b.StartTimer() -} - -// go test -bench BenchmarkIntersection -run - -func BenchmarkIntersectionBitset(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s1 := bitset.New(0) - sz := 150000 - initsize := 65000 - for i := 0; i < initsize; i++ { - s1.Set(uint(r.Int31n(int32(sz)))) - } - s2 := bitset.New(0) - sz = 100000000 - initsize = 65000 - for i := 0; i < initsize; i++ { - s2.Set(uint(r.Int31n(int32(sz)))) - } - b.StartTimer() - card := uint(0) - for j := 0; j < b.N; j++ { - s3 := s1.Intersection(s2) - card = card + s3.Count() - } -} - -// go test -bench BenchmarkIntersection -run - -func BenchmarkIntersectionRoaring(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s1 := NewBitmap() - sz := 150000 - initsize := 65000 - for i := 0; i < initsize; i++ { - s1.Add(uint32(r.Int31n(int32(sz)))) - } - s2 := NewBitmap() - sz = 100000000 - initsize = 65000 - for i := 0; i < initsize; i++ { - s2.Add(uint32(r.Int31n(int32(sz)))) - } - b.StartTimer() - card := uint64(0) - for j := 0; j < b.N; j++ { - s3 := And(s1, s2) - card = card + s3.GetCardinality() - } -} - -// go test -bench BenchmarkIntersectionCardinalityRoaring -run - -func BenchmarkIntersectionCardinalityRoaring(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s1 := NewBitmap() - sz := 150000 - initsize := 65000 - for i := 0; i < initsize; i++ { - s1.Add(uint32(r.Int31n(int32(sz)))) - } - s2 := NewBitmap() - sz = 100000000 - initsize = 65000 - for i := 0; i < initsize; i++ { - s2.Add(uint32(r.Int31n(int32(sz)))) - } - b.StartTimer() - card := uint64(0) - for j := 0; j < b.N; j++ { - card += s1.AndCardinality(s2) - } -} - -// go test -bench BenchmarkUnion -run - -func BenchmarkUnionBitset(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s1 := bitset.New(0) - sz := 150000 - initsize := 65000 - for i := 0; i < initsize; i++ { - s1.Set(uint(r.Int31n(int32(sz)))) - } - s2 := bitset.New(0) - sz = 100000000 - initsize = 65000 - for i := 0; i < initsize; i++ { - s2.Set(uint(r.Int31n(int32(sz)))) - } - b.StartTimer() - card := uint(0) - for j := 0; j < b.N; j++ { - s3 := s1.Union(s2) - card = card + s3.Count() - } -} - -// go test -bench BenchmarkUnion -run - -func BenchmarkUnionRoaring(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s1 := NewBitmap() - sz := 150000 - initsize := 65000 - for i := 0; i < initsize; i++ { - s1.Add(uint32(r.Int31n(int32(sz)))) - } - s2 := NewBitmap() - sz = 100000000 - initsize = 65000 - for i := 0; i < initsize; i++ { - s2.Add(uint32(r.Int31n(int32(sz)))) - } - b.StartTimer() - card := uint64(0) - for j := 0; j < b.N; j++ { - s3 := Or(s1, s2) - card = card + s3.GetCardinality() - } -} - -// go test -bench BenchmarkSize -run - -func BenchmarkSizeBitset(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s1 := bitset.New(0) - sz := 150000 - initsize := 65000 - for i := 0; i < initsize; i++ { - s1.Set(uint(r.Int31n(int32(sz)))) - } - s2 := bitset.New(0) - sz = 100000000 - initsize = 65000 - for i := 0; i < initsize; i++ { - s2.Set(uint(r.Int31n(int32(sz)))) - } - fmt.Printf("%.1f MB ", float32(s1.BinaryStorageSize()+s2.BinaryStorageSize())/(1024.0*1024)) - -} - -// go test -bench BenchmarkSize -run - -func BenchmarkSizeRoaring(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s1 := NewBitmap() - sz := 150000 - initsize := 65000 - for i := 0; i < initsize; i++ { - s1.Add(uint32(r.Int31n(int32(sz)))) - } - s2 := NewBitmap() - sz = 100000000 - initsize = 65000 - for i := 0; i < initsize; i++ { - s2.Add(uint32(r.Int31n(int32(sz)))) - } - fmt.Printf("%.1f MB ", float32(s1.GetSerializedSizeInBytes()+s2.GetSerializedSizeInBytes())/(1024.0*1024)) - -} - -// go test -bench BenchmarkSet -run - -func BenchmarkSetRoaring(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - sz := 1000000 - s := NewBitmap() - b.StartTimer() - for i := 0; i < b.N; i++ { - s.Add(uint32(r.Int31n(int32(sz)))) - } -} - -func BenchmarkSetBitset(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - sz := 1000000 - s := bitset.New(0) - b.StartTimer() - for i := 0; i < b.N; i++ { - s.Set(uint(r.Int31n(int32(sz)))) - } -} - -// go test -bench BenchmarkGetTest -run - -func BenchmarkGetTestRoaring(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - sz := 1000000 - initsize := 50000 - s := NewBitmap() - for i := 0; i < initsize; i++ { - s.Add(uint32(r.Int31n(int32(sz)))) - } - b.StartTimer() - for i := 0; i < b.N; i++ { - s.Contains(uint32(r.Int31n(int32(sz)))) - } -} - -func BenchmarkGetTestBitSet(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - sz := 1000000 - initsize := 50000 - s := bitset.New(0) - for i := 0; i < initsize; i++ { - s.Set(uint(r.Int31n(int32(sz)))) - } - b.StartTimer() - for i := 0; i < b.N; i++ { - s.Test(uint(r.Int31n(int32(sz)))) - } -} - -// go test -bench BenchmarkCount -run - -func BenchmarkCountRoaring(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s := NewBitmap() - sz := 1000000 - initsize := 50000 - for i := 0; i < initsize; i++ { - s.Add(uint32(r.Int31n(int32(sz)))) - } - b.StartTimer() - for i := 0; i < b.N; i++ { - s.GetCardinality() - } -} - -func BenchmarkCountBitset(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s := bitset.New(0) - sz := 1000000 - initsize := 50000 - for i := 0; i < initsize; i++ { - - s.Set(uint(r.Int31n(int32(sz)))) - } - b.StartTimer() - for i := 0; i < b.N; i++ { - s.Count() - } -} - -// go test -bench BenchmarkIterate -run - -func BenchmarkIterateRoaring(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s := NewBitmap() - sz := 150000 - initsize := 65000 - for i := 0; i < initsize; i++ { - s.Add(uint32(r.Int31n(int32(sz)))) - } - b.StartTimer() - for j := 0; j < b.N; j++ { - c9 = uint(0) - i := s.Iterator() - for i.HasNext() { - i.Next() - c9++ - } - } -} - -// go test -bench BenchmarkSparseIterate -run - -func BenchmarkSparseIterateRoaring(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s := NewBitmap() - sz := 100000000 - initsize := 65000 - for i := 0; i < initsize; i++ { - s.Add(uint32(r.Int31n(int32(sz)))) - } - b.StartTimer() - for j := 0; j < b.N; j++ { - c9 = uint(0) - i := s.Iterator() - for i.HasNext() { - i.Next() - c9++ - } - } - -} - -// go test -bench BenchmarkIterate -run - -func BenchmarkIterateBitset(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s := bitset.New(0) - sz := 150000 - initsize := 65000 - for i := 0; i < initsize; i++ { - s.Set(uint(r.Int31n(int32(sz)))) - } - b.StartTimer() - for j := 0; j < b.N; j++ { - c9 = uint(0) - for i, e := s.NextSet(0); e; i, e = s.NextSet(i + 1) { - c9++ - } - } -} - -// go test -bench BenchmarkSparseContains -run - -func BenchmarkSparseContains(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s := NewBitmap() - sz := 10000000 - initsize := 65000 - for i := 0; i < initsize; i++ { - s.Add(uint32(r.Int31n(int32(sz)))) - } - var a [1024]uint32 - for i := 0; i < 1024; i++ { - a[i] = uint32(r.Int31n(int32(sz))) - } - b.StartTimer() - for j := 0; j < b.N; j++ { - c9 = uint(0) - for i := 0; i < 1024; i++ { - if s.Contains(a[i]) { - c9++ - } - - } - } -} - -// go test -bench BenchmarkSparseIterate -run - -func BenchmarkSparseIterateBitset(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s := bitset.New(0) - sz := 100000000 - initsize := 65000 - for i := 0; i < initsize; i++ { - s.Set(uint(r.Int31n(int32(sz)))) - } - b.StartTimer() - for j := 0; j < b.N; j++ { - c9 = uint(0) - for i, e := s.NextSet(0); e; i, e = s.NextSet(i + 1) { - c9++ - } - } -} - -func BenchmarkSerializationSparse(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s := NewBitmap() - sz := 100000000 - initsize := 65000 - for i := 0; i < initsize; i++ { - s.Add(uint32(r.Int31n(int32(sz)))) - } - buf := make([]byte, 0, s.GetSerializedSizeInBytes()) - b.StartTimer() - - for j := 0; j < b.N; j++ { - w := bytes.NewBuffer(buf[:0]) - s.WriteTo(w) - } -} - -func BenchmarkSerializationMid(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s := NewBitmap() - sz := 10000000 - initsize := 65000 - for i := 0; i < initsize; i++ { - s.Add(uint32(r.Int31n(int32(sz)))) - } - buf := make([]byte, 0, s.GetSerializedSizeInBytes()) - b.StartTimer() - - for j := 0; j < b.N; j++ { - w := bytes.NewBuffer(buf[:0]) - s.WriteTo(w) - } -} - -func BenchmarkSerializationDense(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s := NewBitmap() - sz := 150000 - initsize := 65000 - for i := 0; i < initsize; i++ { - s.Add(uint32(r.Int31n(int32(sz)))) - } - buf := make([]byte, 0, s.GetSerializedSizeInBytes()) - b.StartTimer() - - for j := 0; j < b.N; j++ { - w := bytes.NewBuffer(buf[:0]) - s.WriteTo(w) - } -} - -func BenchmarkEqualsSparse(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s := NewBitmap() - t := NewBitmap() - sz := 100000000 - initsize := 65000 - for i := 0; i < initsize; i++ { - n := uint32(r.Int31n(int32(sz))) - s.Add(n) - t.Add(n) - } - b.StartTimer() - - for j := 0; j < b.N; j++ { - s.Equals(t) - } -} - -func BenchmarkEqualsClone(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s := NewBitmap() - sz := 100000000 - initsize := 65000 - for i := 0; i < initsize; i++ { - s.Add(uint32(r.Int31n(int32(sz)))) - } - t := s.Clone() - b.StartTimer() - - for j := 0; j < b.N; j++ { - s.Equals(t) - } -} - -func BenchmarkSequentialAdd(b *testing.B) { - for j := 0; j < b.N; j++ { - s := NewBitmap() - for i := 0; i < 10000000; i += 16 { - s.Add(uint32(i)) - } - } -} - -func BenchmarkXor(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s := NewBitmap() - sz := 100000000 - initsize := 65000 - for i := 0; i < initsize; i++ { - n := uint32(r.Int31n(int32(sz))) - s.Add(n) - } - x2 := NewBitmap() - for i := 0; i < initsize; i++ { - n := uint32(r.Int31n(int32(sz))) - x2.Add(n) - } - b.StartTimer() - - for j := 0; j < b.N; j++ { - s.Clone().Xor(x2) - } -} - -func BenchmarkXorLopsided(b *testing.B) { - b.StopTimer() - r := rand.New(rand.NewSource(0)) - s := NewBitmap() - sz := 100000000 - initsize := 65000 - for i := 0; i < initsize; i++ { - n := uint32(r.Int31n(int32(sz))) - s.Add(n) - } - x2 := NewBitmap() - for i := 0; i < 32; i++ { - n := uint32(r.Int31n(int32(sz))) - x2.Add(n) - } - b.StartTimer() - - for j := 0; j < b.N; j++ { - s.Clone().Xor(x2) - } -} diff --git a/vendor/github.com/RoaringBitmap/roaring/bitmapcontainer.go b/vendor/github.com/RoaringBitmap/roaring/bitmapcontainer.go index 6b6522e2a..503ebebbe 100644 --- a/vendor/github.com/RoaringBitmap/roaring/bitmapcontainer.go +++ b/vendor/github.com/RoaringBitmap/roaring/bitmapcontainer.go @@ -51,7 +51,7 @@ func (bc *bitmapContainer) minimum() uint16 { for i := 0; i < len(bc.bitmap); i += 1 { w := bc.bitmap[i] if w != 0 { - r := countTrailingZerosDeBruijn(w) + r := countTrailingZeros(w) return uint16(r + i*64) } } @@ -847,12 +847,12 @@ func (bc *bitmapContainer) NextSetBit(i int) int { w := bc.bitmap[x] w = w >> uint(i%64) if w != 0 { - return i + countTrailingZerosDeBruijn(w) + return i + countTrailingZeros(w) } x++ for ; x < len(bc.bitmap); x++ { if bc.bitmap[x] != 0 { - return (x * 64) + countTrailingZerosDeBruijn(bc.bitmap[x]) + return (x * 64) + countTrailingZeros(bc.bitmap[x]) } } return -1 diff --git a/vendor/github.com/RoaringBitmap/roaring/bitmapcontainer_gen_test.go b/vendor/github.com/RoaringBitmap/roaring/bitmapcontainer_gen_test.go deleted file mode 100644 index a4f7af42d..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/bitmapcontainer_gen_test.go +++ /dev/null @@ -1,238 +0,0 @@ -package roaring - -// NOTE: THIS FILE WAS PRODUCED BY THE -// MSGP CODE GENERATION TOOL (github.com/tinylib/msgp) -// DO NOT EDIT - -import ( - "bytes" - "testing" - - "github.com/tinylib/msgp/msgp" -) - -func TestMarshalUnmarshalbitmapContainer(t *testing.T) { - v := bitmapContainer{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsgbitmapContainer(b *testing.B) { - v := bitmapContainer{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgbitmapContainer(b *testing.B) { - v := bitmapContainer{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshalbitmapContainer(b *testing.B) { - v := bitmapContainer{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecodebitmapContainer(t *testing.T) { - v := bitmapContainer{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Logf("WARNING: Msgsize() for %v is inaccurate", v) - } - - vn := bitmapContainer{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncodebitmapContainer(b *testing.B) { - v := bitmapContainer{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecodebitmapContainer(b *testing.B) { - v := bitmapContainer{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} - -func TestMarshalUnmarshalbitmapContainerShortIterator(t *testing.T) { - v := bitmapContainerShortIterator{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsgbitmapContainerShortIterator(b *testing.B) { - v := bitmapContainerShortIterator{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgbitmapContainerShortIterator(b *testing.B) { - v := bitmapContainerShortIterator{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshalbitmapContainerShortIterator(b *testing.B) { - v := bitmapContainerShortIterator{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecodebitmapContainerShortIterator(t *testing.T) { - v := bitmapContainerShortIterator{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Logf("WARNING: Msgsize() for %v is inaccurate", v) - } - - vn := bitmapContainerShortIterator{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncodebitmapContainerShortIterator(b *testing.B) { - v := bitmapContainerShortIterator{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecodebitmapContainerShortIterator(b *testing.B) { - v := bitmapContainerShortIterator{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} diff --git a/vendor/github.com/RoaringBitmap/roaring/bitmapcontainer_test.go b/vendor/github.com/RoaringBitmap/roaring/bitmapcontainer_test.go deleted file mode 100644 index 76384b158..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/bitmapcontainer_test.go +++ /dev/null @@ -1,67 +0,0 @@ -package roaring - -import ( - . "github.com/smartystreets/goconvey/convey" - "math/rand" - "testing" -) - -func TestBitmapContainerNumberOfRuns024(t *testing.T) { - - Convey("bitmapContainer's numberOfRuns() function should be correct against the runContainer equivalent", - t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 1000, percentFill: .1, ntrial: 10}, - /* - trial{n: 100, percentFill: .5, ntrial: 10}, - trial{n: 100, percentFill: .01, ntrial: 10}, - trial{n: 100, percentFill: .99, ntrial: 10}, - */ - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestBitmapContainerNumberOfRuns023 on check# j=%v", j) - ma := make(map[int]bool) - - n := tr.n - a := []uint16{} - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - } - - showArray16(a, "a") - - // RunContainer compute this automatically - rc := newRunContainer16FromVals(false, a...) - rcNr := rc.numberOfRuns() - - p("rcNr from run container is %v", rcNr) - - // vs bitmapContainer - bc := newBitmapContainer() - for k := range ma { - bc.iadd(uint16(k)) - } - - bcNr := bc.numberOfRuns() - So(bcNr, ShouldEqual, rcNr) - //fmt.Printf("\nnum runs was: %v\n", rcNr) - } - p("done with randomized bitmapContianer.numberOrRuns() checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} diff --git a/vendor/github.com/RoaringBitmap/roaring/container_test.go b/vendor/github.com/RoaringBitmap/roaring/container_test.go deleted file mode 100644 index 08288bdd6..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/container_test.go +++ /dev/null @@ -1,130 +0,0 @@ -package roaring - -import ( - "log" - "testing" - - . "github.com/smartystreets/goconvey/convey" -) - -func makeContainer(ss []uint16) container { - c := newArrayContainer() - for _, s := range ss { - c.iadd(s) - } - return c -} - -func checkContent(c container, s []uint16) bool { - si := c.getShortIterator() - ctr := 0 - fail := false - for si.hasNext() { - if ctr == len(s) { - log.Println("HERE") - fail = true - break - } - i := si.next() - if i != s[ctr] { - - log.Println("THERE", i, s[ctr]) - fail = true - break - } - ctr++ - } - if ctr != len(s) { - log.Println("LAST") - fail = true - } - if fail { - log.Println("fail, found ") - si = c.getShortIterator() - z := 0 - for si.hasNext() { - si.next() - z++ - } - log.Println(z, len(s)) - } - - return !fail -} - -func TestRoaringContainer(t *testing.T) { - Convey("countTrailingZeros", t, func() { - x := uint64(0) - o := countTrailingZerosDeBruijn(x) - So(o, ShouldEqual, 64) - x = 1 << 3 - o = countTrailingZerosDeBruijn(x) - So(o, ShouldEqual, 3) - }) - Convey("ArrayShortIterator", t, func() { - content := []uint16{1, 3, 5, 7, 9} - c := makeContainer(content) - si := c.getShortIterator() - i := 0 - for si.hasNext() { - si.next() - i++ - } - - So(i, ShouldEqual, 5) - }) - - Convey("BinarySearch", t, func() { - content := []uint16{1, 3, 5, 7, 9} - res := binarySearch(content, 5) - So(res, ShouldEqual, 2) - res = binarySearch(content, 4) - So(res, ShouldBeLessThan, 0) - }) - Convey("bitmapcontainer", t, func() { - content := []uint16{1, 3, 5, 7, 9} - a := newArrayContainer() - b := newBitmapContainer() - for _, v := range content { - a.iadd(v) - b.iadd(v) - } - c := a.toBitmapContainer() - - So(a.getCardinality(), ShouldEqual, b.getCardinality()) - So(c.getCardinality(), ShouldEqual, b.getCardinality()) - - }) - Convey("inottest0", t, func() { - content := []uint16{9} - c := makeContainer(content) - c = c.inot(0, 11) - si := c.getShortIterator() - i := 0 - for si.hasNext() { - si.next() - i++ - } - So(i, ShouldEqual, 10) - }) - - Convey("inotTest1", t, func() { - // Array container, range is complete - content := []uint16{1, 3, 5, 7, 9} - //content := []uint16{1} - edge := 1 << 13 - c := makeContainer(content) - c = c.inot(0, edge+1) - size := edge - len(content) - s := make([]uint16, size+1) - pos := 0 - for i := uint16(0); i < uint16(edge+1); i++ { - if binarySearch(content, i) < 0 { - s[pos] = i - pos++ - } - } - So(checkContent(c, s), ShouldEqual, true) - }) - -} diff --git a/vendor/github.com/RoaringBitmap/roaring/ctz.go b/vendor/github.com/RoaringBitmap/roaring/ctz.go index 58308c5b0..e399dddeb 100644 --- a/vendor/github.com/RoaringBitmap/roaring/ctz.go +++ b/vendor/github.com/RoaringBitmap/roaring/ctz.go @@ -1,69 +1,11 @@ -package roaring - -// Reuse of portions of go/src/math/big standard lib code -// under this license: -/* -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ +// +build go1.9 +// "go1.9", from Go version 1.9 onward +// See https://golang.org/pkg/go/build/#hdr-Build_Constraints -const deBruijn32 = 0x077CB531 - -var deBruijn32Lookup = []byte{ - 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, - 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9, -} - -const deBruijn64 = 0x03f79d71b4ca8b09 +package roaring -var deBruijn64Lookup = []byte{ - 0, 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, - 62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, - 63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11, - 54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6, -} +import "math/bits" -// trailingZeroBits returns the number of consecutive least significant zero -// bits of x. -func countTrailingZerosDeBruijn(x uint64) int { - // x & -x leaves only the right-most bit set in the word. Let k be the - // index of that bit. Since only a single bit is set, the value is two - // to the power of k. Multiplying by a power of two is equivalent to - // left shifting, in this case by k bits. The de Bruijn constant is - // such that all six bit, consecutive substrings are distinct. - // Therefore, if we have a left shifted version of this constant we can - // find by how many bits it was shifted by looking at which six bit - // substring ended up at the top of the word. - // (Knuth, volume 4, section 7.3.1) - if x == 0 { - // We have to special case 0; the fomula - // below doesn't work for 0. - return 64 - } - return int(deBruijn64Lookup[((x&-x)*(deBruijn64))>>58]) +func countTrailingZeros(x uint64) int { + return bits.TrailingZeros64(x) } diff --git a/vendor/github.com/RoaringBitmap/roaring/ctz_compat.go b/vendor/github.com/RoaringBitmap/roaring/ctz_compat.go new file mode 100644 index 000000000..8dfce8977 --- /dev/null +++ b/vendor/github.com/RoaringBitmap/roaring/ctz_compat.go @@ -0,0 +1,71 @@ +// +build !go1.9 + +package roaring + +// Reuse of portions of go/src/math/big standard lib code +// under this license: +/* +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +const deBruijn32 = 0x077CB531 + +var deBruijn32Lookup = []byte{ + 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, + 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9, +} + +const deBruijn64 = 0x03f79d71b4ca8b09 + +var deBruijn64Lookup = []byte{ + 0, 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, + 62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, + 63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11, + 54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6, +} + +// trailingZeroBits returns the number of consecutive least significant zero +// bits of x. +func countTrailingZeros(x uint64) int { + // x & -x leaves only the right-most bit set in the word. Let k be the + // index of that bit. Since only a single bit is set, the value is two + // to the power of k. Multiplying by a power of two is equivalent to + // left shifting, in this case by k bits. The de Bruijn constant is + // such that all six bit, consecutive substrings are distinct. + // Therefore, if we have a left shifted version of this constant we can + // find by how many bits it was shifted by looking at which six bit + // substring ended up at the top of the word. + // (Knuth, volume 4, section 7.3.1) + if x == 0 { + // We have to special case 0; the fomula + // below doesn't work for 0. + return 64 + } + return int(deBruijn64Lookup[((x & -x)*(deBruijn64))>>58]) +} diff --git a/vendor/github.com/RoaringBitmap/roaring/ctz_test.go b/vendor/github.com/RoaringBitmap/roaring/ctz_test.go deleted file mode 100644 index 12567b1d3..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/ctz_test.go +++ /dev/null @@ -1,114 +0,0 @@ -package roaring - -import ( - "encoding/binary" - "math/rand" - "testing" - - . "github.com/smartystreets/goconvey/convey" -) - -func TestCountTrailingZeros072(t *testing.T) { - Convey("countTrailingZeros", t, func() { - So(numberOfTrailingZeros(0), ShouldEqual, 64) - So(numberOfTrailingZeros(8), ShouldEqual, 3) - So(numberOfTrailingZeros(7), ShouldEqual, 0) - So(numberOfTrailingZeros(1<<17), ShouldEqual, 17) - So(numberOfTrailingZeros(7<<17), ShouldEqual, 17) - So(numberOfTrailingZeros(255<<33), ShouldEqual, 33) - - So(countTrailingZerosDeBruijn(0), ShouldEqual, 64) - So(countTrailingZerosDeBruijn(8), ShouldEqual, 3) - So(countTrailingZerosDeBruijn(7), ShouldEqual, 0) - So(countTrailingZerosDeBruijn(1<<17), ShouldEqual, 17) - So(countTrailingZerosDeBruijn(7<<17), ShouldEqual, 17) - So(countTrailingZerosDeBruijn(255<<33), ShouldEqual, 33) - - }) -} - -func getRandomUint64Set(n int) []uint64 { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - var buf [8]byte - var o []uint64 - for i := 0; i < n; i++ { - rand.Read(buf[:]) - o = append(o, binary.LittleEndian.Uint64(buf[:])) - } - return o -} - -func getAllOneBitUint64Set() []uint64 { - var o []uint64 - for i := uint(0); i < 64; i++ { - o = append(o, 1<>63)) -} diff --git a/vendor/github.com/RoaringBitmap/roaring/example_roaring_test.go b/vendor/github.com/RoaringBitmap/roaring/example_roaring_test.go deleted file mode 100644 index 4e270cec0..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/example_roaring_test.go +++ /dev/null @@ -1,124 +0,0 @@ -package roaring - -import ( - "bytes" - "fmt" - "testing" -) - -// Example_roaring demonstrates how to use the roaring library. -func TestExample_roaring060(t *testing.T) { - // example inspired by https://github.com/fzandona/goroar - fmt.Println("==roaring==") - rb1 := BitmapOf(1, 2, 3, 4, 5, 100, 1000) - fmt.Println(rb1.String()) - - rb2 := BitmapOf(3, 4, 1000) - fmt.Println(rb2.String()) - - rb3 := New() - fmt.Println(rb3.String()) - - fmt.Println("Cardinality: ", rb1.GetCardinality()) - if rb1.GetCardinality() != 7 { - t.Errorf("Bad cardinality: %v", rb1.GetCardinality()) - } - - fmt.Println("Contains 3? ", rb1.Contains(3)) - if !rb1.Contains(3) { - t.Errorf("Should contain 3.") - } - - rb1.And(rb2) - - rb3.Add(1) - rb3.Add(5) - - rb3.Or(rb1) - - // prints 1, 3, 4, 5, 1000 - i := rb3.Iterator() - for i.HasNext() { - fmt.Println(i.Next()) - } - fmt.Println() - - // next we include an example of serialization - buf := new(bytes.Buffer) - size, err := rb1.WriteTo(buf) - if err != nil { - fmt.Println("Failed writing") - t.Errorf("Failed writing") - - } else { - fmt.Println("Wrote ", size, " bytes") - } - newrb := New() - _, err = newrb.ReadFrom(buf) - if err != nil { - fmt.Println("Failed reading") - t.Errorf("Failed reading") - - } - if !rb1.Equals(newrb) { - fmt.Println("I did not get back to original bitmap?") - t.Errorf("Bad serialization") - - } else { - fmt.Println("I wrote the content to a byte stream and read it back.") - } -} - -// Example_roaring demonstrates how to use the roaring library with run containers. -func TestExample2_roaring061(t *testing.T) { - - r1 := New() - for i := uint32(100); i < 1000; i++ { - r1.Add(i) - } - if !r1.Contains(500) { - t.Errorf("should contain 500") - } - rb2 := r1.Clone() - // compute how many bits there are: - cardinality := r1.GetCardinality() - - // if your bitmaps have long runs, you can compress them by calling - // run_optimize - size := r1.GetSizeInBytes() - r1.RunOptimize() - if cardinality != r1.GetCardinality() { - t.Errorf("RunOptimize should not change cardinality.") - } - compactSize := r1.GetSizeInBytes() - if compactSize >= size { - t.Errorf("Run optimized size should be smaller.") - } - if !r1.Equals(rb2) { - t.Errorf("RunOptimize should not affect equality.") - } - fmt.Print("size before run optimize: ", size, " bytes, and after: ", compactSize, " bytes.\n") - rb3 := New() - rb3.AddRange(1, 10000000) - r1.Or(rb3) - if !r1.Equals(rb3) { - t.Errorf("union with large run should give back contained set") - } - rb1 := r1.Clone() - rb1.AndNot(rb3) - if !rb1.IsEmpty() { - t.Errorf("And not with large should clear...") - } - for i := uint32(0); i < 10000; i += 3 { - rb1.Add(i) - } - p("rb1card before doing AndNot(rb3): %v, rb3card=%v", - rb1.GetCardinality(), rb3.GetCardinality()) - rb1.AndNot(rb3) - rb1card := rb1.GetCardinality() - if rb1card != 1 { - //rb1.RunOptimize() - //fmt.Printf("\n rb1 = %s\n", rb1) - t.Errorf("Only the value 0 should survive the andNot; rb1card = %v", rb1card) - } -} diff --git a/vendor/github.com/RoaringBitmap/roaring/fastaggregation_test.go b/vendor/github.com/RoaringBitmap/roaring/fastaggregation_test.go deleted file mode 100644 index 824fabfff..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/fastaggregation_test.go +++ /dev/null @@ -1,339 +0,0 @@ -package roaring - -// to run just these tests: go test -run TestFastAggregations* - -import ( - "container/heap" - . "github.com/smartystreets/goconvey/convey" - "testing" -) - -func TestFastAggregations(t *testing.T) { - Convey("Fast", t, func() { - rb1 := NewBitmap() - rb2 := NewBitmap() - rb1.Add(1) - rb2.Add(2) - - So(FastAnd(rb1, rb2).GetCardinality(), ShouldEqual, 0) - So(FastOr(rb1, rb2).GetCardinality(), ShouldEqual, 2) - So(HeapXor(rb1, rb2).GetCardinality(), ShouldEqual, 2) - }) -} - -func TestFastAggregationsNothing(t *testing.T) { - Convey("Fast", t, func() { - So(FastAnd().GetCardinality(), ShouldEqual, 0) - So(FastOr().GetCardinality(), ShouldEqual, 0) - So(HeapXor().GetCardinality(), ShouldEqual, 0) - }) -} - -func TestFastAggregationsOneEmpty(t *testing.T) { - Convey("Fast", t, func() { - rb1 := NewBitmap() - rb2 := NewBitmap() - rb1.Add(1) - - So(FastAnd(rb1, rb2).GetCardinality(), ShouldEqual, 0) - So(FastOr(rb1, rb2).GetCardinality(), ShouldEqual, 1) - So(HeapXor(rb1, rb2).GetCardinality(), ShouldEqual, 1) - }) -} - -func TestFastAggregationsReversed3COW(t *testing.T) { - Convey("Fast", t, func() { - rb1 := NewBitmap() - rb2 := NewBitmap() - rb3 := NewBitmap() - rb1.SetCopyOnWrite(true) - rb2.SetCopyOnWrite(true) - rb3.SetCopyOnWrite(true) - rb1.Add(1) - rb1.Add(100000) - rb2.Add(200000) - rb3.Add(1) - rb3.Add(300000) - - So(FastAnd(rb2, rb1, rb3).GetCardinality(), ShouldEqual, 0) - So(FastOr(rb2, rb1, rb3).GetCardinality(), ShouldEqual, 4) - So(HeapXor(rb2, rb1, rb3).GetCardinality(), ShouldEqual, 3) - }) -} - -func TestFastAggregationsReversed3(t *testing.T) { - Convey("Fast", t, func() { - rb1 := NewBitmap() - rb2 := NewBitmap() - rb3 := NewBitmap() - rb1.Add(1) - rb1.Add(100000) - rb2.Add(200000) - rb3.Add(1) - rb3.Add(300000) - - So(FastAnd(rb2, rb1, rb3).GetCardinality(), ShouldEqual, 0) - So(FastOr(rb2, rb1, rb3).GetCardinality(), ShouldEqual, 4) - So(HeapXor(rb2, rb1, rb3).GetCardinality(), ShouldEqual, 3) - }) -} - -func TestFastAggregations3(t *testing.T) { - Convey("Fast", t, func() { - rb1 := NewBitmap() - rb2 := NewBitmap() - rb3 := NewBitmap() - rb1.Add(1) - rb1.Add(100000) - rb2.Add(200000) - rb3.Add(1) - rb3.Add(300000) - - So(FastAnd(rb1, rb2, rb3).GetCardinality(), ShouldEqual, 0) - So(FastOr(rb1, rb2, rb3).GetCardinality(), ShouldEqual, 4) - So(HeapXor(rb1, rb2, rb3).GetCardinality(), ShouldEqual, 3) - }) -} - -func TestFastAggregations3COW(t *testing.T) { - Convey("Fast", t, func() { - rb1 := NewBitmap() - rb2 := NewBitmap() - rb3 := NewBitmap() - rb1.SetCopyOnWrite(true) - rb2.SetCopyOnWrite(true) - rb3.SetCopyOnWrite(true) - rb1.Add(1) - rb1.Add(100000) - rb2.Add(200000) - rb3.Add(1) - rb3.Add(300000) - - So(FastAnd(rb1, rb2, rb3).GetCardinality(), ShouldEqual, 0) - So(FastOr(rb1, rb2, rb3).GetCardinality(), ShouldEqual, 4) - So(HeapXor(rb1, rb2, rb3).GetCardinality(), ShouldEqual, 3) - }) -} - -func TestFastAggregationsSize(t *testing.T) { - Convey("Fast", t, func() { - rb1 := NewBitmap() - rb2 := NewBitmap() - rb3 := NewBitmap() - for i := uint32(0); i < 1000000; i += 3 { - rb1.Add(i) - } - for i := uint32(0); i < 1000000; i += 7 { - rb2.Add(i) - } - for i := uint32(0); i < 1000000; i += 1001 { - rb3.Add(i) - } - pq := make(priorityQueue, 3) - pq[0] = &item{rb1, 0} - pq[1] = &item{rb2, 1} - pq[2] = &item{rb3, 2} - heap.Init(&pq) - So(heap.Pop(&pq).(*item).value.GetSizeInBytes(), ShouldEqual, rb3.GetSizeInBytes()) - So(heap.Pop(&pq).(*item).value.GetSizeInBytes(), ShouldEqual, rb2.GetSizeInBytes()) - So(heap.Pop(&pq).(*item).value.GetSizeInBytes(), ShouldEqual, rb1.GetSizeInBytes()) - }) -} - -func TestFastAggregationsCont(t *testing.T) { - Convey("Fast", t, func() { - rb1 := NewBitmap() - rb2 := NewBitmap() - rb3 := NewBitmap() - for i := uint32(0); i < 10; i += 3 { - rb1.Add(i) - } - for i := uint32(0); i < 10; i += 7 { - rb2.Add(i) - } - for i := uint32(0); i < 10; i += 1001 { - rb3.Add(i) - } - for i := uint32(1000000); i < 1000000+10; i += 1001 { - rb1.Add(i) - } - for i := uint32(1000000); i < 1000000+10; i += 7 { - rb2.Add(i) - } - for i := uint32(1000000); i < 1000000+10; i += 3 { - rb3.Add(i) - } - rb1.Add(500000) - pq := make(containerPriorityQueue, 3) - pq[0] = &containeritem{rb1, 0, 0} - pq[1] = &containeritem{rb2, 0, 1} - pq[2] = &containeritem{rb3, 0, 2} - heap.Init(&pq) - expected := []int{6, 4, 5, 6, 5, 4, 6} - counter := 0 - for pq.Len() > 0 { - x1 := heap.Pop(&pq).(*containeritem) - So(x1.value.GetCardinality(), ShouldEqual, expected[counter]) - counter++ - x1.keyindex++ - if x1.keyindex < x1.value.highlowcontainer.size() { - heap.Push(&pq, x1) - } - } - }) -} -func TestFastAggregationsAdvanced(t *testing.T) { - Convey("Fast", t, func() { - rb1 := NewBitmap() - rb2 := NewBitmap() - rb3 := NewBitmap() - for i := uint32(0); i < 1000000; i += 3 { - rb1.Add(i) - } - for i := uint32(0); i < 1000000; i += 7 { - rb2.Add(i) - } - for i := uint32(0); i < 1000000; i += 1001 { - rb3.Add(i) - } - for i := uint32(1000000); i < 2000000; i += 1001 { - rb1.Add(i) - } - for i := uint32(1000000); i < 2000000; i += 3 { - rb2.Add(i) - } - for i := uint32(1000000); i < 2000000; i += 7 { - rb3.Add(i) - } - rb1.Or(rb2) - rb1.Or(rb3) - bigand := And(And(rb1, rb2), rb3) - bigxor := Xor(Xor(rb1, rb2), rb3) - So(FastOr(rb1, rb2, rb3).Equals(rb1), ShouldEqual, true) - So(HeapOr(rb1, rb2, rb3).Equals(rb1), ShouldEqual, true) - So(HeapOr(rb1, rb2, rb3).GetCardinality(), ShouldEqual, rb1.GetCardinality()) - So(HeapXor(rb1, rb2, rb3).Equals(bigxor), ShouldEqual, true) - So(FastAnd(rb1, rb2, rb3).Equals(bigand), ShouldEqual, true) - }) -} - -func TestFastAggregationsAdvanced_run(t *testing.T) { - Convey("Fast", t, func() { - rb1 := NewBitmap() - rb2 := NewBitmap() - rb3 := NewBitmap() - for i := uint32(500); i < 75000; i++ { - rb1.Add(i) - } - for i := uint32(0); i < 1000000; i += 7 { - rb2.Add(i) - } - for i := uint32(0); i < 1000000; i += 1001 { - rb3.Add(i) - } - for i := uint32(1000000); i < 2000000; i += 1001 { - rb1.Add(i) - } - for i := uint32(1000000); i < 2000000; i += 3 { - rb2.Add(i) - } - for i := uint32(1000000); i < 2000000; i += 7 { - rb3.Add(i) - } - rb1.RunOptimize() - rb1.Or(rb2) - rb1.Or(rb3) - bigand := And(And(rb1, rb2), rb3) - bigxor := Xor(Xor(rb1, rb2), rb3) - So(FastOr(rb1, rb2, rb3).Equals(rb1), ShouldEqual, true) - So(HeapOr(rb1, rb2, rb3).Equals(rb1), ShouldEqual, true) - So(HeapOr(rb1, rb2, rb3).GetCardinality(), ShouldEqual, rb1.GetCardinality()) - So(HeapXor(rb1, rb2, rb3).Equals(bigxor), ShouldEqual, true) - So(FastAnd(rb1, rb2, rb3).Equals(bigand), ShouldEqual, true) - }) -} - -func TestFastAggregationsXOR(t *testing.T) { - Convey("Fast", t, func() { - rb1 := NewBitmap() - rb2 := NewBitmap() - rb3 := NewBitmap() - - for i := uint32(0); i < 40000; i++ { - rb1.Add(i) - } - for i := uint32(0); i < 40000; i += 4000 { - rb2.Add(i) - } - for i := uint32(0); i < 40000; i += 5000 { - rb3.Add(i) - } - So(rb1.GetCardinality() == 40000, ShouldEqual, true) - - xor1 := Xor(rb1, rb2) - xor1alt := Xor(rb2, rb1) - So(xor1alt.Equals(xor1), ShouldEqual, true) - So(HeapXor(rb1, rb2).Equals(xor1), ShouldEqual, true) - - xor2 := Xor(rb2, rb3) - xor2alt := Xor(rb3, rb2) - So(xor2alt.Equals(xor2), ShouldEqual, true) - So(HeapXor(rb2, rb3).Equals(xor2), ShouldEqual, true) - - bigxor := Xor(Xor(rb1, rb2), rb3) - bigxoralt1 := Xor(rb1, Xor(rb2, rb3)) - bigxoralt2 := Xor(rb1, Xor(rb3, rb2)) - bigxoralt3 := Xor(rb3, Xor(rb1, rb2)) - bigxoralt4 := Xor(Xor(rb1, rb2), rb3) - - So(bigxoralt2.Equals(bigxor), ShouldEqual, true) - So(bigxoralt1.Equals(bigxor), ShouldEqual, true) - So(bigxoralt3.Equals(bigxor), ShouldEqual, true) - So(bigxoralt4.Equals(bigxor), ShouldEqual, true) - - So(HeapXor(rb1, rb2, rb3).Equals(bigxor), ShouldEqual, true) - }) -} - -func TestFastAggregationsXOR_run(t *testing.T) { - Convey("Fast", t, func() { - rb1 := NewBitmap() - rb2 := NewBitmap() - rb3 := NewBitmap() - - for i := uint32(0); i < 40000; i++ { - rb1.Add(i) - } - rb1.RunOptimize() - for i := uint32(0); i < 40000; i += 4000 { - rb2.Add(i) - } - for i := uint32(0); i < 40000; i += 5000 { - rb3.Add(i) - } - So(rb1.GetCardinality() == 40000, ShouldEqual, true) - - xor1 := Xor(rb1, rb2) - xor1alt := Xor(rb2, rb1) - So(xor1alt.Equals(xor1), ShouldEqual, true) - So(HeapXor(rb1, rb2).Equals(xor1), ShouldEqual, true) - - xor2 := Xor(rb2, rb3) - xor2alt := Xor(rb3, rb2) - So(xor2alt.Equals(xor2), ShouldEqual, true) - So(HeapXor(rb2, rb3).Equals(xor2), ShouldEqual, true) - - bigxor := Xor(Xor(rb1, rb2), rb3) - bigxoralt1 := Xor(rb1, Xor(rb2, rb3)) - bigxoralt2 := Xor(rb1, Xor(rb3, rb2)) - bigxoralt3 := Xor(rb3, Xor(rb1, rb2)) - bigxoralt4 := Xor(Xor(rb1, rb2), rb3) - - So(bigxoralt2.Equals(bigxor), ShouldEqual, true) - So(bigxoralt1.Equals(bigxor), ShouldEqual, true) - So(bigxoralt3.Equals(bigxor), ShouldEqual, true) - So(bigxoralt4.Equals(bigxor), ShouldEqual, true) - - So(HeapXor(rb1, rb2, rb3).Equals(bigxor), ShouldEqual, true) - }) -} diff --git a/vendor/github.com/RoaringBitmap/roaring/popcnt.go b/vendor/github.com/RoaringBitmap/roaring/popcnt.go index 912b63591..9d99508ce 100644 --- a/vendor/github.com/RoaringBitmap/roaring/popcnt.go +++ b/vendor/github.com/RoaringBitmap/roaring/popcnt.go @@ -1,55 +1,11 @@ -package roaring - -// bit population count, take from -// https://code.google.com/p/go/issues/detail?id=4988#c11 -// credit: https://code.google.com/u/arnehormann/ -// credit: https://play.golang.org/p/U7SogJ7psJ -// credit: http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel -func popcount(x uint64) uint64 { - x -= (x >> 1) & 0x5555555555555555 - x = (x>>2)&0x3333333333333333 + x&0x3333333333333333 - x += x >> 4 - x &= 0x0f0f0f0f0f0f0f0f - x *= 0x0101010101010101 - return x >> 56 -} - -func popcntSliceGo(s []uint64) uint64 { - cnt := uint64(0) - for _, x := range s { - cnt += popcount(x) - } - return cnt -} +// +build go1.9 +// "go1.9", from Go version 1.9 onward +// See https://golang.org/pkg/go/build/#hdr-Build_Constraints -func popcntMaskSliceGo(s, m []uint64) uint64 { - cnt := uint64(0) - for i := range s { - cnt += popcount(s[i] &^ m[i]) - } - return cnt -} - -func popcntAndSliceGo(s, m []uint64) uint64 { - cnt := uint64(0) - for i := range s { - cnt += popcount(s[i] & m[i]) - } - return cnt -} +package roaring -func popcntOrSliceGo(s, m []uint64) uint64 { - cnt := uint64(0) - for i := range s { - cnt += popcount(s[i] | m[i]) - } - return cnt -} +import "math/bits" -func popcntXorSliceGo(s, m []uint64) uint64 { - cnt := uint64(0) - for i := range s { - cnt += popcount(s[i] ^ m[i]) - } - return cnt +func popcount(x uint64) uint64 { + return uint64(bits.OnesCount64(x)) } diff --git a/vendor/github.com/RoaringBitmap/roaring/popcnt_amd64.s b/vendor/github.com/RoaringBitmap/roaring/popcnt_amd64.s index 18f58784e..1f13fa2ec 100644 --- a/vendor/github.com/RoaringBitmap/roaring/popcnt_amd64.s +++ b/vendor/github.com/RoaringBitmap/roaring/popcnt_amd64.s @@ -1,4 +1,4 @@ -// +build amd64,!appengine +// +build amd64,!appengine,!go1.9 TEXT ·hasAsm(SB),4,$0-1 MOVQ $1, AX diff --git a/vendor/github.com/RoaringBitmap/roaring/popcnt_asm.go b/vendor/github.com/RoaringBitmap/roaring/popcnt_asm.go index 35bfc4402..882d7f4ec 100644 --- a/vendor/github.com/RoaringBitmap/roaring/popcnt_asm.go +++ b/vendor/github.com/RoaringBitmap/roaring/popcnt_asm.go @@ -1,4 +1,4 @@ -// +build amd64,!appengine +// +build amd64,!appengine,!go1.9 package roaring diff --git a/vendor/github.com/RoaringBitmap/roaring/popcnt_compat.go b/vendor/github.com/RoaringBitmap/roaring/popcnt_compat.go new file mode 100644 index 000000000..7ae82d4c8 --- /dev/null +++ b/vendor/github.com/RoaringBitmap/roaring/popcnt_compat.go @@ -0,0 +1,17 @@ +// +build !go1.9 + +package roaring + +// bit population count, take from +// https://code.google.com/p/go/issues/detail?id=4988#c11 +// credit: https://code.google.com/u/arnehormann/ +// credit: https://play.golang.org/p/U7SogJ7psJ +// credit: http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel +func popcount(x uint64) uint64 { + x -= (x >> 1) & 0x5555555555555555 + x = (x>>2)&0x3333333333333333 + x&0x3333333333333333 + x += x >> 4 + x &= 0x0f0f0f0f0f0f0f0f + x *= 0x0101010101010101 + return x >> 56 +} diff --git a/vendor/github.com/RoaringBitmap/roaring/popcnt_generic.go b/vendor/github.com/RoaringBitmap/roaring/popcnt_generic.go index 3c05fb45a..edf2083f1 100644 --- a/vendor/github.com/RoaringBitmap/roaring/popcnt_generic.go +++ b/vendor/github.com/RoaringBitmap/roaring/popcnt_generic.go @@ -1,4 +1,4 @@ -// +build !amd64 appengine +// +build !amd64 appengine go1.9 package roaring diff --git a/vendor/github.com/RoaringBitmap/roaring/popcnt_slices.go b/vendor/github.com/RoaringBitmap/roaring/popcnt_slices.go new file mode 100644 index 000000000..d27c5f383 --- /dev/null +++ b/vendor/github.com/RoaringBitmap/roaring/popcnt_slices.go @@ -0,0 +1,41 @@ +package roaring + +func popcntSliceGo(s []uint64) uint64 { + cnt := uint64(0) + for _, x := range s { + cnt += popcount(x) + } + return cnt +} + +func popcntMaskSliceGo(s, m []uint64) uint64 { + cnt := uint64(0) + for i := range s { + cnt += popcount(s[i] &^ m[i]) + } + return cnt +} + +func popcntAndSliceGo(s, m []uint64) uint64 { + cnt := uint64(0) + for i := range s { + cnt += popcount(s[i] & m[i]) + } + return cnt +} + +func popcntOrSliceGo(s, m []uint64) uint64 { + cnt := uint64(0) + for i := range s { + cnt += popcount(s[i] | m[i]) + } + return cnt +} + +func popcntXorSliceGo(s, m []uint64) uint64 { + cnt := uint64(0) + for i := range s { + cnt += popcount(s[i] ^ m[i]) + } + return cnt +} diff --git a/vendor/github.com/RoaringBitmap/roaring/popcnt_test.go b/vendor/github.com/RoaringBitmap/roaring/popcnt_test.go deleted file mode 100644 index 8f29daf05..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/popcnt_test.go +++ /dev/null @@ -1,78 +0,0 @@ -// +build amd64,!appengine - -// This file tests the popcnt functions - -package roaring - -import ( - "testing" -) - -func TestPopcntSlice(t *testing.T) { - s := []uint64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29} - resGo := popcntSliceGo(s) - resAsm := popcntSliceAsm(s) - if resGo != resAsm { - t.Errorf("The implementations are different: GO %d != ASM %d", resGo, resAsm) - } - res := popcntSlice(s) - if res != resGo { - t.Errorf("The implementations are different") - } -} - -func TestPopcntMaskSlice(t *testing.T) { - s := []uint64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29} - m := []uint64{31, 37, 41, 43, 47, 53, 59, 61, 67, 71} - resGo := popcntMaskSliceGo(s, m) - resAsm := popcntMaskSliceAsm(s, m) - if resGo != resAsm { - t.Errorf("The implementations are different: GO %d != ASM %d", resGo, resAsm) - } - res := popcntMaskSlice(s, m) - if res != resGo { - t.Errorf("The implementations are different") - } -} - -func TestPopcntAndSlice(t *testing.T) { - s := []uint64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29} - m := []uint64{31, 37, 41, 43, 47, 53, 59, 61, 67, 71} - resGo := popcntAndSliceGo(s, m) - resAsm := popcntAndSliceAsm(s, m) - if resGo != resAsm { - t.Errorf("The implementations are different: GO %d != ASM %d", resGo, resAsm) - } - res := popcntAndSlice(s, m) - if res != resGo { - t.Errorf("The implementations are different") - } -} - -func TestPopcntOrSlice(t *testing.T) { - s := []uint64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29} - m := []uint64{31, 37, 41, 43, 47, 53, 59, 61, 67, 71} - resGo := popcntOrSliceGo(s, m) - resAsm := popcntOrSliceAsm(s, m) - if resGo != resAsm { - t.Errorf("The implementations are different: GO %d != ASM %d", resGo, resAsm) - } - res := popcntOrSlice(s, m) - if res != resGo { - t.Errorf("The implementations are different") - } -} - -func TestPopcntXorSlice(t *testing.T) { - s := []uint64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29} - m := []uint64{31, 37, 41, 43, 47, 53, 59, 61, 67, 71} - resGo := popcntXorSliceGo(s, m) - resAsm := popcntXorSliceAsm(s, m) - if resGo != resAsm { - t.Errorf("The implementations are different: GO %d != ASM %d", resGo, resAsm) - } - res := popcntXorSlice(s, m) - if res != resGo { - t.Errorf("The implementations are different") - } -} diff --git a/vendor/github.com/RoaringBitmap/roaring/rle.go b/vendor/github.com/RoaringBitmap/roaring/rle.go index d51fdb14c..843cdbffe 100644 --- a/vendor/github.com/RoaringBitmap/roaring/rle.go +++ b/vendor/github.com/RoaringBitmap/roaring/rle.go @@ -216,7 +216,7 @@ func newRunContainer32FromBitmapContainer(bc *bitmapContainer) *runContainer32 { // wrap up, no more runs return rc } - localRunStart := countTrailingZerosDeBruijn(curWord) + localRunStart := countTrailingZeros(curWord) runStart := localRunStart + 64*longCtr // stuff 1s into number's LSBs curWordWith1s := curWord | (curWord - 1) @@ -235,7 +235,7 @@ func newRunContainer32FromBitmapContainer(bc *bitmapContainer) *runContainer32 { rc.iv[runCount].last = uint32(runEnd) - 1 return rc } - localRunEnd := countTrailingZerosDeBruijn(^curWordWith1s) + localRunEnd := countTrailingZeros(^curWordWith1s) runEnd = localRunEnd + longCtr*64 rc.iv[runCount].start = uint32(runStart) rc.iv[runCount].last = uint32(runEnd) - 1 diff --git a/vendor/github.com/RoaringBitmap/roaring/rle16.go b/vendor/github.com/RoaringBitmap/roaring/rle16.go index 4afa5b903..b3ea1b6eb 100644 --- a/vendor/github.com/RoaringBitmap/roaring/rle16.go +++ b/vendor/github.com/RoaringBitmap/roaring/rle16.go @@ -216,7 +216,7 @@ func newRunContainer16FromBitmapContainer(bc *bitmapContainer) *runContainer16 { // wrap up, no more runs return rc } - localRunStart := countTrailingZerosDeBruijn(curWord) + localRunStart := countTrailingZeros(curWord) runStart := localRunStart + 64*longCtr // stuff 1s into number's LSBs curWordWith1s := curWord | (curWord - 1) @@ -235,7 +235,7 @@ func newRunContainer16FromBitmapContainer(bc *bitmapContainer) *runContainer16 { rc.iv[runCount].last = uint16(runEnd) - 1 return rc } - localRunEnd := countTrailingZerosDeBruijn(^curWordWith1s) + localRunEnd := countTrailingZeros(^curWordWith1s) runEnd = localRunEnd + longCtr*64 rc.iv[runCount].start = uint16(runStart) rc.iv[runCount].last = uint16(runEnd) - 1 diff --git a/vendor/github.com/RoaringBitmap/roaring/rle16_gen_test.go b/vendor/github.com/RoaringBitmap/roaring/rle16_gen_test.go deleted file mode 100644 index 092ffe814..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/rle16_gen_test.go +++ /dev/null @@ -1,577 +0,0 @@ -package roaring - -// NOTE: THIS FILE WAS PRODUCED BY THE -// MSGP CODE GENERATION TOOL (github.com/tinylib/msgp) -// DO NOT EDIT - -import ( - "bytes" - "testing" - - "github.com/tinylib/msgp/msgp" -) - -func TestMarshalUnmarshaladdHelper16(t *testing.T) { - v := addHelper16{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsgaddHelper16(b *testing.B) { - v := addHelper16{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgaddHelper16(b *testing.B) { - v := addHelper16{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshaladdHelper16(b *testing.B) { - v := addHelper16{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecodeaddHelper16(t *testing.T) { - v := addHelper16{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Logf("WARNING: Msgsize() for %v is inaccurate", v) - } - - vn := addHelper16{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncodeaddHelper16(b *testing.B) { - v := addHelper16{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecodeaddHelper16(b *testing.B) { - v := addHelper16{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} - -func TestMarshalUnmarshalinterval16(t *testing.T) { - v := interval16{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsginterval16(b *testing.B) { - v := interval16{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsginterval16(b *testing.B) { - v := interval16{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshalinterval16(b *testing.B) { - v := interval16{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecodeinterval16(t *testing.T) { - v := interval16{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Logf("WARNING: Msgsize() for %v is inaccurate", v) - } - - vn := interval16{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncodeinterval16(b *testing.B) { - v := interval16{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecodeinterval16(b *testing.B) { - v := interval16{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} - -func TestMarshalUnmarshalrunContainer16(t *testing.T) { - v := runContainer16{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsgrunContainer16(b *testing.B) { - v := runContainer16{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgrunContainer16(b *testing.B) { - v := runContainer16{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshalrunContainer16(b *testing.B) { - v := runContainer16{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecoderunContainer16(t *testing.T) { - v := runContainer16{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Logf("WARNING: Msgsize() for %v is inaccurate", v) - } - - vn := runContainer16{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncoderunContainer16(b *testing.B) { - v := runContainer16{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecoderunContainer16(b *testing.B) { - v := runContainer16{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} - -func TestMarshalUnmarshalrunIterator16(t *testing.T) { - v := runIterator16{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsgrunIterator16(b *testing.B) { - v := runIterator16{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgrunIterator16(b *testing.B) { - v := runIterator16{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshalrunIterator16(b *testing.B) { - v := runIterator16{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecoderunIterator16(t *testing.T) { - v := runIterator16{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Logf("WARNING: Msgsize() for %v is inaccurate", v) - } - - vn := runIterator16{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncoderunIterator16(b *testing.B) { - v := runIterator16{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecoderunIterator16(b *testing.B) { - v := runIterator16{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} - -func TestMarshalUnmarshaluint16Slice(t *testing.T) { - v := uint16Slice{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsguint16Slice(b *testing.B) { - v := uint16Slice{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsguint16Slice(b *testing.B) { - v := uint16Slice{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshaluint16Slice(b *testing.B) { - v := uint16Slice{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecodeuint16Slice(t *testing.T) { - v := uint16Slice{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Logf("WARNING: Msgsize() for %v is inaccurate", v) - } - - vn := uint16Slice{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncodeuint16Slice(b *testing.B) { - v := uint16Slice{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecodeuint16Slice(b *testing.B) { - v := uint16Slice{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} diff --git a/vendor/github.com/RoaringBitmap/roaring/rle16_test.go b/vendor/github.com/RoaringBitmap/roaring/rle16_test.go deleted file mode 100644 index 5329424ac..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/rle16_test.go +++ /dev/null @@ -1,737 +0,0 @@ -package roaring - -import ( - "fmt" - "math/rand" - "sort" - "testing" - //"unsafe" - - . "github.com/smartystreets/goconvey/convey" -) - -func init() { - rleVerbose = testing.Verbose() -} - -func TestRleInterval16s(t *testing.T) { - - Convey("canMerge, and mergeInterval16s should do what they say", t, func() { - a := interval16{start: 0, last: 9} - msg := a.String() - p("a is %v", msg) - b := interval16{start: 0, last: 1} - report := sliceToString16([]interval16{a, b}) - _ = report - p("a and b together are: %s", report) - c := interval16{start: 2, last: 4} - d := interval16{start: 2, last: 5} - e := interval16{start: 0, last: 4} - f := interval16{start: 9, last: 9} - g := interval16{start: 8, last: 9} - h := interval16{start: 5, last: 6} - i := interval16{start: 6, last: 6} - - aIb, empty := intersectInterval16s(a, b) - So(empty, ShouldBeFalse) - So(aIb, ShouldResemble, b) - - So(canMerge16(b, c), ShouldBeTrue) - So(canMerge16(c, b), ShouldBeTrue) - So(canMerge16(a, h), ShouldBeTrue) - - So(canMerge16(d, e), ShouldBeTrue) - So(canMerge16(f, g), ShouldBeTrue) - So(canMerge16(c, h), ShouldBeTrue) - - So(canMerge16(b, h), ShouldBeFalse) - So(canMerge16(h, b), ShouldBeFalse) - So(canMerge16(c, i), ShouldBeFalse) - - So(mergeInterval16s(b, c), ShouldResemble, e) - So(mergeInterval16s(c, b), ShouldResemble, e) - - So(mergeInterval16s(h, i), ShouldResemble, h) - So(mergeInterval16s(i, h), ShouldResemble, h) - - ////// start - So(mergeInterval16s(interval16{start: 0, last: 0}, interval16{start: 1, last: 1}), ShouldResemble, interval16{start: 0, last: 1}) - So(mergeInterval16s(interval16{start: 1, last: 1}, interval16{start: 0, last: 0}), ShouldResemble, interval16{start: 0, last: 1}) - So(mergeInterval16s(interval16{start: 0, last: 4}, interval16{start: 3, last: 5}), ShouldResemble, interval16{start: 0, last: 5}) - So(mergeInterval16s(interval16{start: 0, last: 4}, interval16{start: 3, last: 4}), ShouldResemble, interval16{start: 0, last: 4}) - - So(mergeInterval16s(interval16{start: 0, last: 8}, interval16{start: 1, last: 7}), ShouldResemble, interval16{start: 0, last: 8}) - So(mergeInterval16s(interval16{start: 1, last: 7}, interval16{start: 0, last: 8}), ShouldResemble, interval16{start: 0, last: 8}) - - So(func() { _ = mergeInterval16s(interval16{start: 0, last: 0}, interval16{start: 2, last: 3}) }, ShouldPanic) - - }) -} - -func TestRleRunIterator16(t *testing.T) { - - Convey("RunIterator16 unit tests for Cur, Next, HasNext, and Remove should pass", t, func() { - { - rc := newRunContainer16() - msg := rc.String() - _ = msg - p("an empty container: '%s'\n", msg) - So(rc.cardinality(), ShouldEqual, 0) - it := rc.newRunIterator16() - So(it.hasNext(), ShouldBeFalse) - } - { - rc := newRunContainer16TakeOwnership([]interval16{{start: 4, last: 4}}) - So(rc.cardinality(), ShouldEqual, 1) - it := rc.newRunIterator16() - So(it.hasNext(), ShouldBeTrue) - So(it.next(), ShouldResemble, uint16(4)) - So(it.cur(), ShouldResemble, uint16(4)) - } - { - rc := newRunContainer16CopyIv([]interval16{{start: 4, last: 9}}) - So(rc.cardinality(), ShouldEqual, 6) - it := rc.newRunIterator16() - So(it.hasNext(), ShouldBeTrue) - for i := 4; i < 10; i++ { - So(it.next(), ShouldEqual, uint16(i)) - } - So(it.hasNext(), ShouldBeFalse) - } - - { - rc := newRunContainer16TakeOwnership([]interval16{{start: 4, last: 9}}) - card := rc.cardinality() - So(card, ShouldEqual, 6) - //So(rc.serializedSizeInBytes(), ShouldEqual, 2+4*rc.numberOfRuns()) - - it := rc.newRunIterator16() - So(it.hasNext(), ShouldBeTrue) - for i := 4; i < 6; i++ { - So(it.next(), ShouldEqual, uint16(i)) - } - So(it.cur(), ShouldEqual, uint16(5)) - - p("before Remove of 5, rc = '%s'", rc) - - So(it.remove(), ShouldEqual, uint16(5)) - - p("after Remove of 5, rc = '%s'", rc) - So(rc.cardinality(), ShouldEqual, 5) - - it2 := rc.newRunIterator16() - So(rc.cardinality(), ShouldEqual, 5) - So(it2.next(), ShouldEqual, uint16(4)) - for i := 6; i < 10; i++ { - So(it2.next(), ShouldEqual, uint16(i)) - } - } - { - rc := newRunContainer16TakeOwnership([]interval16{ - {start: 0, last: 0}, - {start: 2, last: 2}, - {start: 4, last: 4}, - }) - rc1 := newRunContainer16TakeOwnership([]interval16{ - {start: 6, last: 7}, - {start: 10, last: 11}, - {start: MaxUint16, last: MaxUint16}, - }) - - rc = rc.union(rc1) - - So(rc.cardinality(), ShouldEqual, 8) - it := rc.newRunIterator16() - So(it.next(), ShouldEqual, uint16(0)) - So(it.next(), ShouldEqual, uint16(2)) - So(it.next(), ShouldEqual, uint16(4)) - So(it.next(), ShouldEqual, uint16(6)) - So(it.next(), ShouldEqual, uint16(7)) - So(it.next(), ShouldEqual, uint16(10)) - So(it.next(), ShouldEqual, uint16(11)) - So(it.next(), ShouldEqual, uint16(MaxUint16)) - So(it.hasNext(), ShouldEqual, false) - - rc2 := newRunContainer16TakeOwnership([]interval16{ - {start: 0, last: MaxUint16}, - }) - - p("union with a full [0,2^16-1] container should yield that same single interval run container") - rc2 = rc2.union(rc) - So(rc2.numIntervals(), ShouldEqual, 1) - } - }) -} - -func TestRleRunSearch16(t *testing.T) { - - Convey("RunContainer16.search should respect the prior bounds we provide for efficiency of searching through a subset of the intervals", t, func() { - { - vals := []uint16{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, MaxUint16 - 3, MaxUint16} - exAt := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} // expected at - absent := []uint16{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, MaxUint16 - 2} - - rc := newRunContainer16FromVals(true, vals...) - - So(rc.cardinality(), ShouldEqual, 12) - - var where int64 - var present bool - - for i, v := range vals { - where, present, _ = rc.search(int64(v), nil) - So(present, ShouldBeTrue) - So(where, ShouldEqual, exAt[i]) - } - - for i, v := range absent { - where, present, _ = rc.search(int64(v), nil) - So(present, ShouldBeFalse) - So(where, ShouldEqual, i) - } - - // delete the MaxUint16 so we can test - // the behavior when searching near upper limit. - - p("before removing MaxUint16: %v", rc) - - So(rc.cardinality(), ShouldEqual, 12) - So(rc.numIntervals(), ShouldEqual, 12) - - rc.removeKey(MaxUint16) - p("after removing MaxUint16: %v", rc) - So(rc.cardinality(), ShouldEqual, 11) - So(rc.numIntervals(), ShouldEqual, 11) - - p("search for absent MaxUint16 should return the interval before our key") - where, present, _ = rc.search(MaxUint16, nil) - So(present, ShouldBeFalse) - So(where, ShouldEqual, 10) - - var numCompares int - where, present, numCompares = rc.search(MaxUint16, nil) - So(present, ShouldBeFalse) - So(where, ShouldEqual, 10) - p("numCompares = %v", numCompares) - So(numCompares, ShouldEqual, 3) - - p("confirm that opts searchOptions to search reduces search time") - opts := &searchOptions{ - startIndex: 5, - } - where, present, numCompares = rc.search(MaxUint16, opts) - So(present, ShouldBeFalse) - So(where, ShouldEqual, 10) - p("numCompares = %v", numCompares) - So(numCompares, ShouldEqual, 2) - - p("confirm that opts searchOptions to search is respected") - where, present, _ = rc.search(MaxUint16-3, opts) - So(present, ShouldBeTrue) - So(where, ShouldEqual, 10) - - // with the bound in place, MaxUint16-3 should not be found - opts.endxIndex = 10 - where, present, _ = rc.search(MaxUint16-3, opts) - So(present, ShouldBeFalse) - So(where, ShouldEqual, 9) - - } - }) - -} - -func TestRleIntersection16(t *testing.T) { - - Convey("RunContainer16.intersect of two RunContainer16(s) should return their intersection", t, func() { - { - vals := []uint16{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, MaxUint16 - 3, MaxUint16 - 1} - - a := newRunContainer16FromVals(true, vals[:5]...) - b := newRunContainer16FromVals(true, vals[2:]...) - - p("a is %v", a) - p("b is %v", b) - - So(haveOverlap16(interval16{0, 2}, interval16{2, 2}), ShouldBeTrue) - So(haveOverlap16(interval16{0, 2}, interval16{3, 3}), ShouldBeFalse) - - isect := a.intersect(b) - - p("isect is %v", isect) - - So(isect.cardinality(), ShouldEqual, 3) - So(isect.contains(4), ShouldBeTrue) - So(isect.contains(6), ShouldBeTrue) - So(isect.contains(8), ShouldBeTrue) - - d := newRunContainer16TakeOwnership([]interval16{{start: 0, last: MaxUint16}}) - - isect = isect.intersect(d) - p("isect is %v", isect) - So(isect.cardinality(), ShouldEqual, 3) - So(isect.contains(4), ShouldBeTrue) - So(isect.contains(6), ShouldBeTrue) - So(isect.contains(8), ShouldBeTrue) - - p("test breaking apart intervals") - e := newRunContainer16TakeOwnership([]interval16{{2, 4}, {8, 9}, {14, 16}, {20, 22}}) - f := newRunContainer16TakeOwnership([]interval16{{3, 18}, {22, 23}}) - - p("e = %v", e) - p("f = %v", f) - - { - isect = e.intersect(f) - p("isect of e and f is %v", isect) - So(isect.cardinality(), ShouldEqual, 8) - So(isect.contains(3), ShouldBeTrue) - So(isect.contains(4), ShouldBeTrue) - So(isect.contains(8), ShouldBeTrue) - So(isect.contains(9), ShouldBeTrue) - So(isect.contains(14), ShouldBeTrue) - So(isect.contains(15), ShouldBeTrue) - So(isect.contains(16), ShouldBeTrue) - So(isect.contains(22), ShouldBeTrue) - } - - { - // check for symmetry - isect = f.intersect(e) - p("isect of f and e is %v", isect) - So(isect.cardinality(), ShouldEqual, 8) - So(isect.contains(3), ShouldBeTrue) - So(isect.contains(4), ShouldBeTrue) - So(isect.contains(8), ShouldBeTrue) - So(isect.contains(9), ShouldBeTrue) - So(isect.contains(14), ShouldBeTrue) - So(isect.contains(15), ShouldBeTrue) - So(isect.contains(16), ShouldBeTrue) - So(isect.contains(22), ShouldBeTrue) - } - - } - }) -} - -func TestRleRandomIntersection16(t *testing.T) { - - Convey("RunContainer.intersect of two RunContainers should return their intersection, and this should hold over randomized container content when compared to intersection done with hash maps", t, func() { - - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 100, percentFill: .80, ntrial: 10}, - {n: 1000, percentFill: .20, ntrial: 20}, - {n: 10000, percentFill: .01, ntrial: 10}, - {n: 1000, percentFill: .99, ntrial: 10}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRleRandomIntersection on check# j=%v", j) - ma := make(map[int]bool) - mb := make(map[int]bool) - - n := tr.n - a := []uint16{} - b := []uint16{} - - var first, second int - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - if i == 0 { - first = r0 - second = r0 + 1 - p("i is 0, so appending also to a the r0+1 == %v value", second) - a = append(a, uint16(second)) - ma[second] = true - } - - r1 := rand.Intn(n) - b = append(b, uint16(r1)) - mb[r1] = true - } - - // print a; very likely it has dups - sort.Sort(uint16Slice(a)) - stringA := "" - for i := range a { - stringA += fmt.Sprintf("%v, ", a[i]) - } - p("a is '%v'", stringA) - - // hash version of intersect: - hashi := make(map[int]bool) - for k := range ma { - if mb[k] { - hashi[k] = true - } - } - - // RunContainer's Intersect - brle := newRunContainer16FromVals(false, b...) - - //arle := newRunContainer16FromVals(false, a...) - // instead of the above line, create from array - // get better test coverage: - arr := newArrayContainerRange(int(first), int(second)) - arle := newRunContainer16FromArray(arr) - p("after newRunContainer16FromArray(arr), arle is %v", arle) - arle.set(false, a...) - p("after set(false, a), arle is %v", arle) - - isect := arle.intersect(brle) - - p("isect is %v", isect) - - //showHash("hashi", hashi) - - for k := range hashi { - p("hashi has %v, checking in isect", k) - So(isect.contains(uint16(k)), ShouldBeTrue) - } - - p("checking for cardinality agreement: isect is %v, len(hashi) is %v", isect.cardinality(), len(hashi)) - So(isect.cardinality(), ShouldEqual, len(hashi)) - } - p("done with randomized intersect() checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestRleRandomUnion16(t *testing.T) { - - Convey("RunContainer.union of two RunContainers should return their union, and this should hold over randomized container content when compared to union done with hash maps", t, func() { - - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 100, percentFill: .80, ntrial: 10}, - {n: 1000, percentFill: .20, ntrial: 20}, - {n: 10000, percentFill: .01, ntrial: 10}, - {n: 1000, percentFill: .99, ntrial: 10, percentDelete: .04}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRleRandomUnion on check# j=%v", j) - ma := make(map[int]bool) - mb := make(map[int]bool) - - n := tr.n - a := []uint16{} - b := []uint16{} - - draw := int(float64(n) * tr.percentFill) - numDel := int(float64(n) * tr.percentDelete) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - - r1 := rand.Intn(n) - b = append(b, uint16(r1)) - mb[r1] = true - } - - // hash version of union: - hashu := make(map[int]bool) - for k := range ma { - hashu[k] = true - } - for k := range mb { - hashu[k] = true - } - - //showHash("hashu", hashu) - - // RunContainer's Union - arle := newRunContainer16() - for i := range a { - arle.Add(a[i]) - } - brle := newRunContainer16() - brle.set(false, b...) - - union := arle.union(brle) - - p("union is %v", union) - - p("union.cardinality(): %v, versus len(hashu): %v", union.cardinality(), len(hashu)) - - un := union.AsSlice() - sort.Sort(uint16Slice(un)) - - for kk, v := range un { - p("kk:%v, RunContainer.union has %v, checking hashmap: %v", kk, v, hashu[int(v)]) - _ = kk - So(hashu[int(v)], ShouldBeTrue) - } - - for k := range hashu { - p("hashu has %v, checking in union", k) - So(union.contains(uint16(k)), ShouldBeTrue) - } - - p("checking for cardinality agreement:") - So(union.cardinality(), ShouldEqual, len(hashu)) - - // do the deletes, exercising the remove functionality - for i := 0; i < numDel; i++ { - r1 := rand.Intn(len(a)) - goner := a[r1] - union.removeKey(goner) - delete(hashu, int(goner)) - } - // verify the same as in the hashu - So(union.cardinality(), ShouldEqual, len(hashu)) - for k := range hashu { - p("hashu has %v, checking in union", k) - So(union.contains(uint16(k)), ShouldBeTrue) - } - - } - p("done with randomized Union() checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestRleAndOrXor16(t *testing.T) { - - Convey("RunContainer And, Or, Xor tests", t, func() { - { - rc := newRunContainer16TakeOwnership([]interval16{ - {start: 0, last: 0}, - {start: 2, last: 2}, - {start: 4, last: 4}, - }) - b0 := NewBitmap() - b0.Add(2) - b0.Add(6) - b0.Add(8) - - and := rc.And(b0) - or := rc.Or(b0) - xor := rc.Xor(b0) - - So(and.GetCardinality(), ShouldEqual, 1) - So(or.GetCardinality(), ShouldEqual, 5) - So(xor.GetCardinality(), ShouldEqual, 4) - - // test creating size 0 and 1 from array - arr := newArrayContainerCapacity(0) - empty := newRunContainer16FromArray(arr) - onceler := newArrayContainerCapacity(1) - onceler.content = append(onceler.content, uint16(0)) - oneZero := newRunContainer16FromArray(onceler) - So(empty.cardinality(), ShouldEqual, 0) - So(oneZero.cardinality(), ShouldEqual, 1) - So(empty.And(b0).GetCardinality(), ShouldEqual, 0) - So(empty.Or(b0).GetCardinality(), ShouldEqual, 3) - - // exercise newRunContainer16FromVals() with 0 and 1 inputs. - empty2 := newRunContainer16FromVals(false, []uint16{}...) - So(empty2.cardinality(), ShouldEqual, 0) - one2 := newRunContainer16FromVals(false, []uint16{1}...) - So(one2.cardinality(), ShouldEqual, 1) - } - }) -} - -func TestRlePanics16(t *testing.T) { - - Convey("Some RunContainer calls/methods should panic if misused", t, func() { - - // newRunContainer16FromVals - So(func() { newRunContainer16FromVals(true, 1, 0) }, ShouldPanic) - - arr := newArrayContainerRange(1, 3) - arr.content = []uint16{2, 3, 3, 2, 1} - So(func() { newRunContainer16FromArray(arr) }, ShouldPanic) - }) -} - -func TestRleCoverageOddsAndEnds16(t *testing.T) { - - Convey("Some RunContainer code paths that don't otherwise get coverage -- these should be tested to increase percentage of code coverage in testing", t, func() { - - // p() code path - cur := rleVerbose - rleVerbose = true - p("") - rleVerbose = cur - - // RunContainer.String() - rc := &runContainer16{} - So(rc.String(), ShouldEqual, "runContainer16{}") - rc.iv = make([]interval16, 1) - rc.iv[0] = interval16{start: 3, last: 4} - So(rc.String(), ShouldEqual, "runContainer16{0:[3, 4], }") - - a := interval16{start: 5, last: 9} - b := interval16{start: 0, last: 1} - c := interval16{start: 1, last: 2} - - // intersectInterval16s(a, b interval16) - isect, isEmpty := intersectInterval16s(a, b) - So(isEmpty, ShouldBeTrue) - // [0,0] can't be trusted: So(isect.runlen(), ShouldEqual, 0) - isect, isEmpty = intersectInterval16s(b, c) - So(isEmpty, ShouldBeFalse) - So(isect.runlen(), ShouldEqual, 1) - - // runContainer16.union - { - ra := newRunContainer16FromVals(false, 4, 5) - rb := newRunContainer16FromVals(false, 4, 6, 8, 9, 10) - ra.union(rb) - So(rb.indexOfIntervalAtOrAfter(4, 2), ShouldEqual, 2) - So(rb.indexOfIntervalAtOrAfter(3, 2), ShouldEqual, 2) - } - - // runContainer.intersect - { - ra := newRunContainer16() - rb := newRunContainer16() - So(ra.intersect(rb).cardinality(), ShouldEqual, 0) - } - { - ra := newRunContainer16FromVals(false, 1) - rb := newRunContainer16FromVals(false, 4) - So(ra.intersect(rb).cardinality(), ShouldEqual, 0) - } - - // runContainer.Add - { - ra := newRunContainer16FromVals(false, 1) - rb := newRunContainer16FromVals(false, 4) - So(ra.cardinality(), ShouldEqual, 1) - So(rb.cardinality(), ShouldEqual, 1) - ra.Add(5) - So(ra.cardinality(), ShouldEqual, 2) - - // newRunIterator16() - empty := newRunContainer16() - it := empty.newRunIterator16() - So(func() { it.next() }, ShouldPanic) - it2 := ra.newRunIterator16() - it2.curIndex = int64(len(it2.rc.iv)) - So(func() { it2.next() }, ShouldPanic) - - // runIterator16.remove() - emptyIt := empty.newRunIterator16() - So(func() { emptyIt.remove() }, ShouldPanic) - - // newRunContainer16FromArray - arr := newArrayContainerRange(1, 6) - arr.content = []uint16{5, 5, 5, 6, 9} - rc3 := newRunContainer16FromArray(arr) - So(rc3.cardinality(), ShouldEqual, 3) - - // runContainer16SerializedSizeInBytes - // runContainer16.SerializedSizeInBytes - _ = runContainer16SerializedSizeInBytes(3) - _ = rc3.serializedSizeInBytes() - - // findNextIntervalThatIntersectsStartingFrom - idx, _ := rc3.findNextIntervalThatIntersectsStartingFrom(0, 100) - So(idx, ShouldEqual, 1) - - // deleteAt / remove - rc3.Add(10) - rc3.removeKey(10) - rc3.removeKey(9) - So(rc3.cardinality(), ShouldEqual, 2) - rc3.Add(9) - rc3.Add(10) - rc3.Add(12) - So(rc3.cardinality(), ShouldEqual, 5) - it3 := rc3.newRunIterator16() - it3.next() - it3.next() - it3.next() - it3.next() - So(it3.cur(), ShouldEqual, uint16(10)) - it3.remove() - So(it3.next(), ShouldEqual, uint16(12)) - } - - // runContainer16.equals - { - rc16 := newRunContainer16() - So(rc16.equals16(rc16), ShouldBeTrue) - rc16b := newRunContainer16() - So(rc16.equals16(rc16b), ShouldBeTrue) - rc16.Add(1) - rc16b.Add(2) - So(rc16.equals16(rc16b), ShouldBeFalse) - } - }) -} - -func TestRleStoringMax16(t *testing.T) { - - Convey("Storing the MaxUint16 should be possible, because it may be necessary to do so--users will assume that any valid uint16 should be storable. In particular the smaller 16-bit version will definitely expect full access to all bits.", t, func() { - - rc := newRunContainer16() - rc.Add(MaxUint16) - So(rc.contains(MaxUint16), ShouldBeTrue) - So(rc.cardinality(), ShouldEqual, 1) - rc.removeKey(MaxUint16) - So(rc.contains(MaxUint16), ShouldBeFalse) - So(rc.cardinality(), ShouldEqual, 0) - - rc.set(false, MaxUint16-1, MaxUint16) - So(rc.cardinality(), ShouldEqual, 2) - - So(rc.contains(MaxUint16-1), ShouldBeTrue) - So(rc.contains(MaxUint16), ShouldBeTrue) - rc.removeKey(MaxUint16 - 1) - So(rc.cardinality(), ShouldEqual, 1) - rc.removeKey(MaxUint16) - So(rc.cardinality(), ShouldEqual, 0) - - rc.set(false, MaxUint16-2, MaxUint16-1, MaxUint16) - So(rc.cardinality(), ShouldEqual, 3) - So(rc.numIntervals(), ShouldEqual, 1) - rc.removeKey(MaxUint16 - 1) - So(rc.numIntervals(), ShouldEqual, 2) - So(rc.cardinality(), ShouldEqual, 2) - - }) -} - -// go test -bench BenchmarkFromBitmap -run - -func BenchmarkFromBitmap16(b *testing.B) { - b.StopTimer() - seed := int64(42) - rand.Seed(seed) - - tr := trial{n: 10000, percentFill: .95, ntrial: 1, numRandomOpsPass: 100} - _, _, bc := getRandomSameThreeContainers(tr) - - b.StartTimer() - - for j := 0; j < b.N; j++ { - newRunContainer16FromBitmapContainer(bc) - } -} diff --git a/vendor/github.com/RoaringBitmap/roaring/rle_gen_test.go b/vendor/github.com/RoaringBitmap/roaring/rle_gen_test.go deleted file mode 100644 index 945e9171f..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/rle_gen_test.go +++ /dev/null @@ -1,577 +0,0 @@ -package roaring - -// NOTE: THIS FILE WAS PRODUCED BY THE -// MSGP CODE GENERATION TOOL (github.com/tinylib/msgp) -// DO NOT EDIT - -import ( - "bytes" - "testing" - - "github.com/tinylib/msgp/msgp" -) - -func TestMarshalUnmarshaladdHelper32(t *testing.T) { - v := addHelper32{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsgaddHelper32(b *testing.B) { - v := addHelper32{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgaddHelper32(b *testing.B) { - v := addHelper32{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshaladdHelper32(b *testing.B) { - v := addHelper32{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecodeaddHelper32(t *testing.T) { - v := addHelper32{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Logf("WARNING: Msgsize() for %v is inaccurate", v) - } - - vn := addHelper32{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncodeaddHelper32(b *testing.B) { - v := addHelper32{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecodeaddHelper32(b *testing.B) { - v := addHelper32{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} - -func TestMarshalUnmarshalinterval32(t *testing.T) { - v := interval32{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsginterval32(b *testing.B) { - v := interval32{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsginterval32(b *testing.B) { - v := interval32{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshalinterval32(b *testing.B) { - v := interval32{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecodeinterval32(t *testing.T) { - v := interval32{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Logf("WARNING: Msgsize() for %v is inaccurate", v) - } - - vn := interval32{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncodeinterval32(b *testing.B) { - v := interval32{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecodeinterval32(b *testing.B) { - v := interval32{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} - -func TestMarshalUnmarshalrunContainer32(t *testing.T) { - v := runContainer32{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsgrunContainer32(b *testing.B) { - v := runContainer32{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgrunContainer32(b *testing.B) { - v := runContainer32{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshalrunContainer32(b *testing.B) { - v := runContainer32{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecoderunContainer32(t *testing.T) { - v := runContainer32{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Logf("WARNING: Msgsize() for %v is inaccurate", v) - } - - vn := runContainer32{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncoderunContainer32(b *testing.B) { - v := runContainer32{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecoderunContainer32(b *testing.B) { - v := runContainer32{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} - -func TestMarshalUnmarshalrunIterator32(t *testing.T) { - v := runIterator32{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsgrunIterator32(b *testing.B) { - v := runIterator32{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgrunIterator32(b *testing.B) { - v := runIterator32{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshalrunIterator32(b *testing.B) { - v := runIterator32{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecoderunIterator32(t *testing.T) { - v := runIterator32{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Logf("WARNING: Msgsize() for %v is inaccurate", v) - } - - vn := runIterator32{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncoderunIterator32(b *testing.B) { - v := runIterator32{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecoderunIterator32(b *testing.B) { - v := runIterator32{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} - -func TestMarshalUnmarshaluint32Slice(t *testing.T) { - v := uint32Slice{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsguint32Slice(b *testing.B) { - v := uint32Slice{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsguint32Slice(b *testing.B) { - v := uint32Slice{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshaluint32Slice(b *testing.B) { - v := uint32Slice{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecodeuint32Slice(t *testing.T) { - v := uint32Slice{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Logf("WARNING: Msgsize() for %v is inaccurate", v) - } - - vn := uint32Slice{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncodeuint32Slice(b *testing.B) { - v := uint32Slice{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecodeuint32Slice(b *testing.B) { - v := uint32Slice{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} diff --git a/vendor/github.com/RoaringBitmap/roaring/rle_test.go b/vendor/github.com/RoaringBitmap/roaring/rle_test.go deleted file mode 100644 index 44140da59..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/rle_test.go +++ /dev/null @@ -1,737 +0,0 @@ -package roaring - -import ( - "fmt" - "math/rand" - "sort" - "testing" - //"unsafe" - - . "github.com/smartystreets/goconvey/convey" -) - -func init() { - rleVerbose = testing.Verbose() -} - -func TestRleInterval32s(t *testing.T) { - - Convey("canMerge, and mergeInterval32s should do what they say", t, func() { - a := interval32{start: 0, last: 9} - msg := a.String() - p("a is %v", msg) - b := interval32{start: 0, last: 1} - report := sliceToString32([]interval32{a, b}) - _ = report - p("a and b together are: %s", report) - c := interval32{start: 2, last: 4} - d := interval32{start: 2, last: 5} - e := interval32{start: 0, last: 4} - f := interval32{start: 9, last: 9} - g := interval32{start: 8, last: 9} - h := interval32{start: 5, last: 6} - i := interval32{start: 6, last: 6} - - aIb, empty := intersectInterval32s(a, b) - So(empty, ShouldBeFalse) - So(aIb, ShouldResemble, b) - - So(canMerge32(b, c), ShouldBeTrue) - So(canMerge32(c, b), ShouldBeTrue) - So(canMerge32(a, h), ShouldBeTrue) - - So(canMerge32(d, e), ShouldBeTrue) - So(canMerge32(f, g), ShouldBeTrue) - So(canMerge32(c, h), ShouldBeTrue) - - So(canMerge32(b, h), ShouldBeFalse) - So(canMerge32(h, b), ShouldBeFalse) - So(canMerge32(c, i), ShouldBeFalse) - - So(mergeInterval32s(b, c), ShouldResemble, e) - So(mergeInterval32s(c, b), ShouldResemble, e) - - So(mergeInterval32s(h, i), ShouldResemble, h) - So(mergeInterval32s(i, h), ShouldResemble, h) - - ////// start - So(mergeInterval32s(interval32{start: 0, last: 0}, interval32{start: 1, last: 1}), ShouldResemble, interval32{start: 0, last: 1}) - So(mergeInterval32s(interval32{start: 1, last: 1}, interval32{start: 0, last: 0}), ShouldResemble, interval32{start: 0, last: 1}) - So(mergeInterval32s(interval32{start: 0, last: 4}, interval32{start: 3, last: 5}), ShouldResemble, interval32{start: 0, last: 5}) - So(mergeInterval32s(interval32{start: 0, last: 4}, interval32{start: 3, last: 4}), ShouldResemble, interval32{start: 0, last: 4}) - - So(mergeInterval32s(interval32{start: 0, last: 8}, interval32{start: 1, last: 7}), ShouldResemble, interval32{start: 0, last: 8}) - So(mergeInterval32s(interval32{start: 1, last: 7}, interval32{start: 0, last: 8}), ShouldResemble, interval32{start: 0, last: 8}) - - So(func() { _ = mergeInterval32s(interval32{start: 0, last: 0}, interval32{start: 2, last: 3}) }, ShouldPanic) - - }) -} - -func TestRleRunIterator32(t *testing.T) { - - Convey("RunIterator32 unit tests for Cur, Next, HasNext, and Remove should pass", t, func() { - { - rc := newRunContainer32() - msg := rc.String() - _ = msg - p("an empty container: '%s'\n", msg) - So(rc.cardinality(), ShouldEqual, 0) - it := rc.newRunIterator32() - So(it.hasNext(), ShouldBeFalse) - } - { - rc := newRunContainer32TakeOwnership([]interval32{{start: 4, last: 4}}) - So(rc.cardinality(), ShouldEqual, 1) - it := rc.newRunIterator32() - So(it.hasNext(), ShouldBeTrue) - So(it.next(), ShouldResemble, uint32(4)) - So(it.cur(), ShouldResemble, uint32(4)) - } - { - rc := newRunContainer32CopyIv([]interval32{{start: 4, last: 9}}) - So(rc.cardinality(), ShouldEqual, 6) - it := rc.newRunIterator32() - So(it.hasNext(), ShouldBeTrue) - for i := 4; i < 10; i++ { - So(it.next(), ShouldEqual, uint32(i)) - } - So(it.hasNext(), ShouldBeFalse) - } - - { - rc := newRunContainer32TakeOwnership([]interval32{{start: 4, last: 9}}) - card := rc.cardinality() - So(card, ShouldEqual, 6) - //So(rc.serializedSizeInBytes(), ShouldEqual, 2+4*rc.numberOfRuns()) - - it := rc.newRunIterator32() - So(it.hasNext(), ShouldBeTrue) - for i := 4; i < 6; i++ { - So(it.next(), ShouldEqual, uint32(i)) - } - So(it.cur(), ShouldEqual, uint32(5)) - - p("before Remove of 5, rc = '%s'", rc) - - So(it.remove(), ShouldEqual, uint32(5)) - - p("after Remove of 5, rc = '%s'", rc) - So(rc.cardinality(), ShouldEqual, 5) - - it2 := rc.newRunIterator32() - So(rc.cardinality(), ShouldEqual, 5) - So(it2.next(), ShouldEqual, uint32(4)) - for i := 6; i < 10; i++ { - So(it2.next(), ShouldEqual, uint32(i)) - } - } - { - rc := newRunContainer32TakeOwnership([]interval32{ - {start: 0, last: 0}, - {start: 2, last: 2}, - {start: 4, last: 4}, - }) - rc1 := newRunContainer32TakeOwnership([]interval32{ - {start: 6, last: 7}, - {start: 10, last: 11}, - {start: MaxUint32, last: MaxUint32}, - }) - - rc = rc.union(rc1) - - So(rc.cardinality(), ShouldEqual, 8) - it := rc.newRunIterator32() - So(it.next(), ShouldEqual, uint32(0)) - So(it.next(), ShouldEqual, uint32(2)) - So(it.next(), ShouldEqual, uint32(4)) - So(it.next(), ShouldEqual, uint32(6)) - So(it.next(), ShouldEqual, uint32(7)) - So(it.next(), ShouldEqual, uint32(10)) - So(it.next(), ShouldEqual, uint32(11)) - So(it.next(), ShouldEqual, uint32(MaxUint32)) - So(it.hasNext(), ShouldEqual, false) - - rc2 := newRunContainer32TakeOwnership([]interval32{ - {start: 0, last: MaxUint32}, - }) - - p("union with a full [0,2^32-1] container should yield that same single interval run container") - rc2 = rc2.union(rc) - So(rc2.numIntervals(), ShouldEqual, 1) - } - }) -} - -func TestRleRunSearch32(t *testing.T) { - - Convey("RunContainer32.search should respect the prior bounds we provide for efficiency of searching through a subset of the intervals", t, func() { - { - vals := []uint32{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, MaxUint32 - 3, MaxUint32} - exAt := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} // expected at - absent := []uint32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, MaxUint32 - 2} - - rc := newRunContainer32FromVals(true, vals...) - - So(rc.cardinality(), ShouldEqual, 12) - - var where int64 - var present bool - - for i, v := range vals { - where, present, _ = rc.search(int64(v), nil) - So(present, ShouldBeTrue) - So(where, ShouldEqual, exAt[i]) - } - - for i, v := range absent { - where, present, _ = rc.search(int64(v), nil) - So(present, ShouldBeFalse) - So(where, ShouldEqual, i) - } - - // delete the MaxUint32 so we can test - // the behavior when searching near upper limit. - - p("before removing MaxUint32: %v", rc) - - So(rc.cardinality(), ShouldEqual, 12) - So(rc.numIntervals(), ShouldEqual, 12) - - rc.removeKey(MaxUint32) - p("after removing MaxUint32: %v", rc) - So(rc.cardinality(), ShouldEqual, 11) - So(rc.numIntervals(), ShouldEqual, 11) - - p("search for absent MaxUint32 should return the interval before our key") - where, present, _ = rc.search(MaxUint32, nil) - So(present, ShouldBeFalse) - So(where, ShouldEqual, 10) - - var numCompares int - where, present, numCompares = rc.search(MaxUint32, nil) - So(present, ShouldBeFalse) - So(where, ShouldEqual, 10) - p("numCompares = %v", numCompares) - So(numCompares, ShouldEqual, 3) - - p("confirm that opts searchOptions to search reduces search time") - opts := &searchOptions{ - startIndex: 5, - } - where, present, numCompares = rc.search(MaxUint32, opts) - So(present, ShouldBeFalse) - So(where, ShouldEqual, 10) - p("numCompares = %v", numCompares) - So(numCompares, ShouldEqual, 2) - - p("confirm that opts searchOptions to search is respected") - where, present, _ = rc.search(MaxUint32-3, opts) - So(present, ShouldBeTrue) - So(where, ShouldEqual, 10) - - // with the bound in place, MaxUint32-3 should not be found - opts.endxIndex = 10 - where, present, _ = rc.search(MaxUint32-3, opts) - So(present, ShouldBeFalse) - So(where, ShouldEqual, 9) - - } - }) - -} - -func TestRleIntersection32(t *testing.T) { - - Convey("RunContainer32.intersect of two RunContainer32(s) should return their intersection", t, func() { - { - vals := []uint32{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, MaxUint32 - 3, MaxUint32 - 1} - - a := newRunContainer32FromVals(true, vals[:5]...) - b := newRunContainer32FromVals(true, vals[2:]...) - - p("a is %v", a) - p("b is %v", b) - - So(haveOverlap32(interval32{0, 2}, interval32{2, 2}), ShouldBeTrue) - So(haveOverlap32(interval32{0, 2}, interval32{3, 3}), ShouldBeFalse) - - isect := a.intersect(b) - - p("isect is %v", isect) - - So(isect.cardinality(), ShouldEqual, 3) - So(isect.contains(4), ShouldBeTrue) - So(isect.contains(6), ShouldBeTrue) - So(isect.contains(8), ShouldBeTrue) - - d := newRunContainer32TakeOwnership([]interval32{{start: 0, last: MaxUint32}}) - - isect = isect.intersect(d) - p("isect is %v", isect) - So(isect.cardinality(), ShouldEqual, 3) - So(isect.contains(4), ShouldBeTrue) - So(isect.contains(6), ShouldBeTrue) - So(isect.contains(8), ShouldBeTrue) - - p("test breaking apart intervals") - e := newRunContainer32TakeOwnership([]interval32{{2, 4}, {8, 9}, {14, 16}, {20, 22}}) - f := newRunContainer32TakeOwnership([]interval32{{3, 18}, {22, 23}}) - - p("e = %v", e) - p("f = %v", f) - - { - isect = e.intersect(f) - p("isect of e and f is %v", isect) - So(isect.cardinality(), ShouldEqual, 8) - So(isect.contains(3), ShouldBeTrue) - So(isect.contains(4), ShouldBeTrue) - So(isect.contains(8), ShouldBeTrue) - So(isect.contains(9), ShouldBeTrue) - So(isect.contains(14), ShouldBeTrue) - So(isect.contains(15), ShouldBeTrue) - So(isect.contains(16), ShouldBeTrue) - So(isect.contains(22), ShouldBeTrue) - } - - { - // check for symmetry - isect = f.intersect(e) - p("isect of f and e is %v", isect) - So(isect.cardinality(), ShouldEqual, 8) - So(isect.contains(3), ShouldBeTrue) - So(isect.contains(4), ShouldBeTrue) - So(isect.contains(8), ShouldBeTrue) - So(isect.contains(9), ShouldBeTrue) - So(isect.contains(14), ShouldBeTrue) - So(isect.contains(15), ShouldBeTrue) - So(isect.contains(16), ShouldBeTrue) - So(isect.contains(22), ShouldBeTrue) - } - - } - }) -} - -func TestRleRandomIntersection32(t *testing.T) { - - Convey("RunContainer.intersect of two RunContainers should return their intersection, and this should hold over randomized container content when compared to intersection done with hash maps", t, func() { - - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 100, percentFill: .80, ntrial: 10}, - {n: 1000, percentFill: .20, ntrial: 20}, - {n: 10000, percentFill: .01, ntrial: 10}, - {n: 1000, percentFill: .99, ntrial: 10}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRleRandomIntersection on check# j=%v", j) - ma := make(map[int]bool) - mb := make(map[int]bool) - - n := tr.n - a := []uint32{} - b := []uint32{} - - var first, second int - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint32(r0)) - ma[r0] = true - if i == 0 { - first = r0 - second = r0 + 1 - p("i is 0, so appending also to a the r0+1 == %v value", second) - a = append(a, uint32(second)) - ma[second] = true - } - - r1 := rand.Intn(n) - b = append(b, uint32(r1)) - mb[r1] = true - } - - // print a; very likely it has dups - sort.Sort(uint32Slice(a)) - stringA := "" - for i := range a { - stringA += fmt.Sprintf("%v, ", a[i]) - } - p("a is '%v'", stringA) - - // hash version of intersect: - hashi := make(map[int]bool) - for k := range ma { - if mb[k] { - hashi[k] = true - } - } - - // RunContainer's Intersect - brle := newRunContainer32FromVals(false, b...) - - //arle := newRunContainer32FromVals(false, a...) - // instead of the above line, create from array - // get better test coverage: - arr := newArrayContainerRange(int(first), int(second)) - arle := newRunContainer32FromArray(arr) - p("after newRunContainer32FromArray(arr), arle is %v", arle) - arle.set(false, a...) - p("after set(false, a), arle is %v", arle) - - isect := arle.intersect(brle) - - p("isect is %v", isect) - - //showHash("hashi", hashi) - - for k := range hashi { - p("hashi has %v, checking in isect", k) - So(isect.contains(uint32(k)), ShouldBeTrue) - } - - p("checking for cardinality agreement: isect is %v, len(hashi) is %v", isect.cardinality(), len(hashi)) - So(isect.cardinality(), ShouldEqual, len(hashi)) - } - p("done with randomized intersect() checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestRleRandomUnion32(t *testing.T) { - - Convey("RunContainer.union of two RunContainers should return their union, and this should hold over randomized container content when compared to union done with hash maps", t, func() { - - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 100, percentFill: .80, ntrial: 10}, - {n: 1000, percentFill: .20, ntrial: 20}, - {n: 10000, percentFill: .01, ntrial: 10}, - {n: 1000, percentFill: .99, ntrial: 10, percentDelete: .04}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRleRandomUnion on check# j=%v", j) - ma := make(map[int]bool) - mb := make(map[int]bool) - - n := tr.n - a := []uint32{} - b := []uint32{} - - draw := int(float64(n) * tr.percentFill) - numDel := int(float64(n) * tr.percentDelete) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint32(r0)) - ma[r0] = true - - r1 := rand.Intn(n) - b = append(b, uint32(r1)) - mb[r1] = true - } - - // hash version of union: - hashu := make(map[int]bool) - for k := range ma { - hashu[k] = true - } - for k := range mb { - hashu[k] = true - } - - //showHash("hashu", hashu) - - // RunContainer's Union - arle := newRunContainer32() - for i := range a { - arle.Add(a[i]) - } - brle := newRunContainer32() - brle.set(false, b...) - - union := arle.union(brle) - - p("union is %v", union) - - p("union.cardinality(): %v, versus len(hashu): %v", union.cardinality(), len(hashu)) - - un := union.AsSlice() - sort.Sort(uint32Slice(un)) - - for kk, v := range un { - p("kk:%v, RunContainer.union has %v, checking hashmap: %v", kk, v, hashu[int(v)]) - _ = kk - So(hashu[int(v)], ShouldBeTrue) - } - - for k := range hashu { - p("hashu has %v, checking in union", k) - So(union.contains(uint32(k)), ShouldBeTrue) - } - - p("checking for cardinality agreement:") - So(union.cardinality(), ShouldEqual, len(hashu)) - - // do the deletes, exercising the remove functionality - for i := 0; i < numDel; i++ { - r1 := rand.Intn(len(a)) - goner := a[r1] - union.removeKey(goner) - delete(hashu, int(goner)) - } - // verify the same as in the hashu - So(union.cardinality(), ShouldEqual, len(hashu)) - for k := range hashu { - p("hashu has %v, checking in union", k) - So(union.contains(uint32(k)), ShouldBeTrue) - } - - } - p("done with randomized Union() checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestRleAndOrXor32(t *testing.T) { - - Convey("RunContainer And, Or, Xor tests", t, func() { - { - rc := newRunContainer32TakeOwnership([]interval32{ - {start: 0, last: 0}, - {start: 2, last: 2}, - {start: 4, last: 4}, - }) - b0 := NewBitmap() - b0.Add(2) - b0.Add(6) - b0.Add(8) - - and := rc.And(b0) - or := rc.Or(b0) - xor := rc.Xor(b0) - - So(and.GetCardinality(), ShouldEqual, 1) - So(or.GetCardinality(), ShouldEqual, 5) - So(xor.GetCardinality(), ShouldEqual, 4) - - // test creating size 0 and 1 from array - arr := newArrayContainerCapacity(0) - empty := newRunContainer32FromArray(arr) - onceler := newArrayContainerCapacity(1) - onceler.content = append(onceler.content, uint16(0)) - oneZero := newRunContainer32FromArray(onceler) - So(empty.cardinality(), ShouldEqual, 0) - So(oneZero.cardinality(), ShouldEqual, 1) - So(empty.And(b0).GetCardinality(), ShouldEqual, 0) - So(empty.Or(b0).GetCardinality(), ShouldEqual, 3) - - // exercise newRunContainer32FromVals() with 0 and 1 inputs. - empty2 := newRunContainer32FromVals(false, []uint32{}...) - So(empty2.cardinality(), ShouldEqual, 0) - one2 := newRunContainer32FromVals(false, []uint32{1}...) - So(one2.cardinality(), ShouldEqual, 1) - } - }) -} - -func TestRlePanics32(t *testing.T) { - - Convey("Some RunContainer calls/methods should panic if misused", t, func() { - - // newRunContainer32FromVals - So(func() { newRunContainer32FromVals(true, 1, 0) }, ShouldPanic) - - arr := newArrayContainerRange(1, 3) - arr.content = []uint16{2, 3, 3, 2, 1} - So(func() { newRunContainer32FromArray(arr) }, ShouldPanic) - }) -} - -func TestRleCoverageOddsAndEnds32(t *testing.T) { - - Convey("Some RunContainer code paths that don't otherwise get coverage -- these should be tested to increase percentage of code coverage in testing", t, func() { - - // p() code path - cur := rleVerbose - rleVerbose = true - p("") - rleVerbose = cur - - // RunContainer.String() - rc := &runContainer32{} - So(rc.String(), ShouldEqual, "runContainer32{}") - rc.iv = make([]interval32, 1) - rc.iv[0] = interval32{start: 3, last: 4} - So(rc.String(), ShouldEqual, "runContainer32{0:[3, 4], }") - - a := interval32{start: 5, last: 9} - b := interval32{start: 0, last: 1} - c := interval32{start: 1, last: 2} - - // intersectInterval32s(a, b interval32) - isect, isEmpty := intersectInterval32s(a, b) - So(isEmpty, ShouldBeTrue) - // [0,0] can't be trusted: So(isect.runlen(), ShouldEqual, 0) - isect, isEmpty = intersectInterval32s(b, c) - So(isEmpty, ShouldBeFalse) - So(isect.runlen(), ShouldEqual, 1) - - // runContainer32.union - { - ra := newRunContainer32FromVals(false, 4, 5) - rb := newRunContainer32FromVals(false, 4, 6, 8, 9, 10) - ra.union(rb) - So(rb.indexOfIntervalAtOrAfter(4, 2), ShouldEqual, 2) - So(rb.indexOfIntervalAtOrAfter(3, 2), ShouldEqual, 2) - } - - // runContainer.intersect - { - ra := newRunContainer32() - rb := newRunContainer32() - So(ra.intersect(rb).cardinality(), ShouldEqual, 0) - } - { - ra := newRunContainer32FromVals(false, 1) - rb := newRunContainer32FromVals(false, 4) - So(ra.intersect(rb).cardinality(), ShouldEqual, 0) - } - - // runContainer.Add - { - ra := newRunContainer32FromVals(false, 1) - rb := newRunContainer32FromVals(false, 4) - So(ra.cardinality(), ShouldEqual, 1) - So(rb.cardinality(), ShouldEqual, 1) - ra.Add(5) - So(ra.cardinality(), ShouldEqual, 2) - - // newRunIterator32() - empty := newRunContainer32() - it := empty.newRunIterator32() - So(func() { it.next() }, ShouldPanic) - it2 := ra.newRunIterator32() - it2.curIndex = int64(len(it2.rc.iv)) - So(func() { it2.next() }, ShouldPanic) - - // runIterator32.remove() - emptyIt := empty.newRunIterator32() - So(func() { emptyIt.remove() }, ShouldPanic) - - // newRunContainer32FromArray - arr := newArrayContainerRange(1, 6) - arr.content = []uint16{5, 5, 5, 6, 9} - rc3 := newRunContainer32FromArray(arr) - So(rc3.cardinality(), ShouldEqual, 3) - - // runContainer32SerializedSizeInBytes - // runContainer32.SerializedSizeInBytes - _ = runContainer32SerializedSizeInBytes(3) - _ = rc3.serializedSizeInBytes() - - // findNextIntervalThatIntersectsStartingFrom - idx, _ := rc3.findNextIntervalThatIntersectsStartingFrom(0, 100) - So(idx, ShouldEqual, 1) - - // deleteAt / remove - rc3.Add(10) - rc3.removeKey(10) - rc3.removeKey(9) - So(rc3.cardinality(), ShouldEqual, 2) - rc3.Add(9) - rc3.Add(10) - rc3.Add(12) - So(rc3.cardinality(), ShouldEqual, 5) - it3 := rc3.newRunIterator32() - it3.next() - it3.next() - it3.next() - it3.next() - So(it3.cur(), ShouldEqual, uint32(10)) - it3.remove() - So(it3.next(), ShouldEqual, uint32(12)) - } - - // runContainer32.equals - { - rc32 := newRunContainer32() - So(rc32.equals32(rc32), ShouldBeTrue) - rc32b := newRunContainer32() - So(rc32.equals32(rc32b), ShouldBeTrue) - rc32.Add(1) - rc32b.Add(2) - So(rc32.equals32(rc32b), ShouldBeFalse) - } - }) -} - -func TestRleStoringMax32(t *testing.T) { - - Convey("Storing the MaxUint32 should be possible, because it may be necessary to do so--users will assume that any valid uint32 should be storable. In particular the smaller 16-bit version will definitely expect full access to all bits.", t, func() { - - rc := newRunContainer32() - rc.Add(MaxUint32) - So(rc.contains(MaxUint32), ShouldBeTrue) - So(rc.cardinality(), ShouldEqual, 1) - rc.removeKey(MaxUint32) - So(rc.contains(MaxUint32), ShouldBeFalse) - So(rc.cardinality(), ShouldEqual, 0) - - rc.set(false, MaxUint32-1, MaxUint32) - So(rc.cardinality(), ShouldEqual, 2) - - So(rc.contains(MaxUint32-1), ShouldBeTrue) - So(rc.contains(MaxUint32), ShouldBeTrue) - rc.removeKey(MaxUint32 - 1) - So(rc.cardinality(), ShouldEqual, 1) - rc.removeKey(MaxUint32) - So(rc.cardinality(), ShouldEqual, 0) - - rc.set(false, MaxUint32-2, MaxUint32-1, MaxUint32) - So(rc.cardinality(), ShouldEqual, 3) - So(rc.numIntervals(), ShouldEqual, 1) - rc.removeKey(MaxUint32 - 1) - So(rc.numIntervals(), ShouldEqual, 2) - So(rc.cardinality(), ShouldEqual, 2) - - }) -} - -// go test -bench BenchmarkFromBitmap -run - -func BenchmarkFromBitmap32(b *testing.B) { - b.StopTimer() - seed := int64(42) - rand.Seed(seed) - - tr := trial{n: 10000, percentFill: .95, ntrial: 1, numRandomOpsPass: 100} - _, _, bc := getRandomSameThreeContainers(tr) - - b.StartTimer() - - for j := 0; j < b.N; j++ { - newRunContainer16FromBitmapContainer(bc) - } -} diff --git a/vendor/github.com/RoaringBitmap/roaring/rlei_test.go b/vendor/github.com/RoaringBitmap/roaring/rlei_test.go deleted file mode 100644 index 80b72d59f..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/rlei_test.go +++ /dev/null @@ -1,1794 +0,0 @@ -package roaring - -import ( - "fmt" - "math/rand" - "sort" - "strings" - "testing" - - . "github.com/smartystreets/goconvey/convey" -) - -// showHash utility really only used in testing -func showHash(name string, h map[int]bool) { - hv := []int{} - for k := range h { - hv = append(hv, k) - } - sort.Sort(sort.IntSlice(hv)) - stringH := "" - for i := range hv { - stringH += fmt.Sprintf("%v, ", hv[i]) - } - - fmt.Printf("%s is (len %v): %s", name, len(h), stringH) -} - -func TestRle16RandomIntersectAgainstOtherContainers010(t *testing.T) { - - Convey("runContainer16 `and` operation against other container types should correctly do the intersection", t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 100, percentFill: .95, ntrial: 1}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRleRandomAndAgainstOtherContainers on check# j=%v", j) - ma := make(map[int]bool) - mb := make(map[int]bool) - - n := tr.n - a := []uint16{} - b := []uint16{} - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - - r1 := rand.Intn(n) - b = append(b, uint16(r1)) - mb[r1] = true - } - - //showArray16(a, "a") - //showArray16(b, "b") - - // hash version of intersect: - hashi := make(map[int]bool) - for k := range ma { - if mb[k] { - hashi[k] = true - } - } - - // RunContainer's Intersect - rc := newRunContainer16FromVals(false, a...) - - p("rc from a is %v", rc) - - // vs bitmapContainer - bc := newBitmapContainer() - for _, bv := range b { - bc.iadd(bv) - } - - // vs arrayContainer - ac := newArrayContainer() - for _, bv := range b { - ac.iadd(bv) - } - - // vs runContainer - rcb := newRunContainer16FromVals(false, b...) - - rcVsBcIsect := rc.and(bc) - rcVsAcIsect := rc.and(ac) - rcVsRcbIsect := rc.and(rcb) - - p("rcVsBcIsect is %v", rcVsBcIsect) - p("rcVsAcIsect is %v", rcVsAcIsect) - p("rcVsRcbIsect is %v", rcVsRcbIsect) - - //showHash("hashi", hashi) - - for k := range hashi { - p("hashi has %v, checking in rcVsBcIsect", k) - So(rcVsBcIsect.contains(uint16(k)), ShouldBeTrue) - - p("hashi has %v, checking in rcVsAcIsect", k) - So(rcVsAcIsect.contains(uint16(k)), ShouldBeTrue) - - p("hashi has %v, checking in rcVsRcbIsect", k) - So(rcVsRcbIsect.contains(uint16(k)), ShouldBeTrue) - } - - p("checking for cardinality agreement: rcVsBcIsect is %v, len(hashi) is %v", rcVsBcIsect.getCardinality(), len(hashi)) - p("checking for cardinality agreement: rcVsAcIsect is %v, len(hashi) is %v", rcVsAcIsect.getCardinality(), len(hashi)) - p("checking for cardinality agreement: rcVsRcbIsect is %v, len(hashi) is %v", rcVsRcbIsect.getCardinality(), len(hashi)) - So(rcVsBcIsect.getCardinality(), ShouldEqual, len(hashi)) - So(rcVsAcIsect.getCardinality(), ShouldEqual, len(hashi)) - So(rcVsRcbIsect.getCardinality(), ShouldEqual, len(hashi)) - } - p("done with randomized and() vs bitmapContainer and arrayContainer checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestRle16RandomUnionAgainstOtherContainers011(t *testing.T) { - - Convey("runContainer16 `or` operation against other container types should correctly do the intersection", t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 100, percentFill: .95, ntrial: 1}, - /* trial{n: 100, percentFill: .01, ntrial: 10}, - trial{n: 100, percentFill: .99, ntrial: 10}, - trial{n: 100, percentFill: .50, ntrial: 10}, - trial{n: 10, percentFill: 1.0, ntrial: 10}, - */ - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRleRandomAndAgainstOtherContainers on check# j=%v", j) - ma := make(map[int]bool) - mb := make(map[int]bool) - - n := tr.n - a := []uint16{} - b := []uint16{} - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - - r1 := rand.Intn(n) - b = append(b, uint16(r1)) - mb[r1] = true - } - - //showArray16(a, "a") - //showArray16(b, "b") - - // hash version of union - hashi := make(map[int]bool) - for k := range ma { - hashi[k] = true - } - for k := range mb { - hashi[k] = true - } - - // RunContainer's 'or' - rc := newRunContainer16FromVals(false, a...) - - p("rc from a is %v", rc) - - // vs bitmapContainer - bc := newBitmapContainer() - for _, bv := range b { - bc.iadd(bv) - } - - // vs arrayContainer - ac := newArrayContainer() - for _, bv := range b { - ac.iadd(bv) - } - - // vs runContainer - rcb := newRunContainer16FromVals(false, b...) - - rcVsBcUnion := rc.or(bc) - rcVsAcUnion := rc.or(ac) - rcVsRcbUnion := rc.or(rcb) - - p("rcVsBcUnion is %v", rcVsBcUnion) - p("rcVsAcUnion is %v", rcVsAcUnion) - p("rcVsRcbUnion is %v", rcVsRcbUnion) - - //showHash("hashi", hashi) - - for k := range hashi { - p("hashi has %v, checking in rcVsBcUnion", k) - So(rcVsBcUnion.contains(uint16(k)), ShouldBeTrue) - - p("hashi has %v, checking in rcVsAcUnion", k) - So(rcVsAcUnion.contains(uint16(k)), ShouldBeTrue) - - p("hashi has %v, checking in rcVsRcbUnion", k) - So(rcVsRcbUnion.contains(uint16(k)), ShouldBeTrue) - } - - p("checking for cardinality agreement: rcVsBcUnion is %v, len(hashi) is %v", rcVsBcUnion.getCardinality(), len(hashi)) - p("checking for cardinality agreement: rcVsAcUnion is %v, len(hashi) is %v", rcVsAcUnion.getCardinality(), len(hashi)) - p("checking for cardinality agreement: rcVsRcbUnion is %v, len(hashi) is %v", rcVsRcbUnion.getCardinality(), len(hashi)) - So(rcVsBcUnion.getCardinality(), ShouldEqual, len(hashi)) - So(rcVsAcUnion.getCardinality(), ShouldEqual, len(hashi)) - So(rcVsRcbUnion.getCardinality(), ShouldEqual, len(hashi)) - } - p("done with randomized or() vs bitmapContainer and arrayContainer checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestRle16RandomInplaceUnionAgainstOtherContainers012(t *testing.T) { - - Convey("runContainer16 `ior` inplace union operation against other container types should correctly do the intersection", t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 10, percentFill: .95, ntrial: 1}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRleRandomInplaceUnionAgainstOtherContainers on check# j=%v", j) - ma := make(map[int]bool) - mb := make(map[int]bool) - - n := tr.n - a := []uint16{} - b := []uint16{} - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - - r1 := rand.Intn(n) - b = append(b, uint16(r1)) - mb[r1] = true - } - - //showArray16(a, "a") - //showArray16(b, "b") - - // hash version of union - hashi := make(map[int]bool) - for k := range ma { - hashi[k] = true - } - for k := range mb { - hashi[k] = true - } - - // RunContainer's 'or' - rc := newRunContainer16FromVals(false, a...) - - p("rc from a is %v", rc) - - rcVsBcUnion := rc.Clone() - rcVsAcUnion := rc.Clone() - rcVsRcbUnion := rc.Clone() - - // vs bitmapContainer - bc := newBitmapContainer() - for _, bv := range b { - bc.iadd(bv) - } - - // vs arrayContainer - ac := newArrayContainer() - for _, bv := range b { - ac.iadd(bv) - } - - // vs runContainer - rcb := newRunContainer16FromVals(false, b...) - - rcVsBcUnion.ior(bc) - rcVsAcUnion.ior(ac) - rcVsRcbUnion.ior(rcb) - - p("rcVsBcUnion is %v", rcVsBcUnion) - p("rcVsAcUnion is %v", rcVsAcUnion) - p("rcVsRcbUnion is %v", rcVsRcbUnion) - - //showHash("hashi", hashi) - - for k := range hashi { - p("hashi has %v, checking in rcVsBcUnion", k) - So(rcVsBcUnion.contains(uint16(k)), ShouldBeTrue) - - p("hashi has %v, checking in rcVsAcUnion", k) - So(rcVsAcUnion.contains(uint16(k)), ShouldBeTrue) - - p("hashi has %v, checking in rcVsRcbUnion", k) - So(rcVsRcbUnion.contains(uint16(k)), ShouldBeTrue) - } - - p("checking for cardinality agreement: rcVsBcUnion is %v, len(hashi) is %v", rcVsBcUnion.getCardinality(), len(hashi)) - p("checking for cardinality agreement: rcVsAcUnion is %v, len(hashi) is %v", rcVsAcUnion.getCardinality(), len(hashi)) - p("checking for cardinality agreement: rcVsRcbUnion is %v, len(hashi) is %v", rcVsRcbUnion.getCardinality(), len(hashi)) - So(rcVsBcUnion.getCardinality(), ShouldEqual, len(hashi)) - So(rcVsAcUnion.getCardinality(), ShouldEqual, len(hashi)) - So(rcVsRcbUnion.getCardinality(), ShouldEqual, len(hashi)) - } - p("done with randomized or() vs bitmapContainer and arrayContainer checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestRle16RandomInplaceIntersectAgainstOtherContainers014(t *testing.T) { - - Convey("runContainer16 `iand` inplace-and operation against other container types should correctly do the intersection", t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 100, percentFill: .95, ntrial: 1}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRleRandomAndAgainstOtherContainers on check# j=%v", j) - ma := make(map[int]bool) - mb := make(map[int]bool) - - n := tr.n - a := []uint16{} - b := []uint16{} - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - - r1 := rand.Intn(n) - b = append(b, uint16(r1)) - mb[r1] = true - } - - //showArray16(a, "a") - //showArray16(b, "b") - - // hash version of intersect: - hashi := make(map[int]bool) - for k := range ma { - if mb[k] { - hashi[k] = true - } - } - - // RunContainer's Intersect - rc := newRunContainer16FromVals(false, a...) - - p("rc from a is %v", rc) - - // vs bitmapContainer - bc := newBitmapContainer() - for _, bv := range b { - bc.iadd(bv) - } - - // vs arrayContainer - ac := newArrayContainer() - for _, bv := range b { - ac.iadd(bv) - } - - // vs runContainer - rcb := newRunContainer16FromVals(false, b...) - - rcVsBcIsect := rc.Clone() - rcVsAcIsect := rc.Clone() - rcVsRcbIsect := rc.Clone() - - rcVsBcIsect.iand(bc) - rcVsAcIsect.iand(ac) - rcVsRcbIsect.iand(rcb) - - p("rcVsBcIsect is %v", rcVsBcIsect) - p("rcVsAcIsect is %v", rcVsAcIsect) - p("rcVsRcbIsect is %v", rcVsRcbIsect) - - //showHash("hashi", hashi) - - for k := range hashi { - p("hashi has %v, checking in rcVsBcIsect", k) - So(rcVsBcIsect.contains(uint16(k)), ShouldBeTrue) - - p("hashi has %v, checking in rcVsAcIsect", k) - So(rcVsAcIsect.contains(uint16(k)), ShouldBeTrue) - - p("hashi has %v, checking in rcVsRcbIsect", k) - So(rcVsRcbIsect.contains(uint16(k)), ShouldBeTrue) - } - - p("checking for cardinality agreement: rcVsBcIsect is %v, len(hashi) is %v", rcVsBcIsect.getCardinality(), len(hashi)) - p("checking for cardinality agreement: rcVsAcIsect is %v, len(hashi) is %v", rcVsAcIsect.getCardinality(), len(hashi)) - p("checking for cardinality agreement: rcVsRcbIsect is %v, len(hashi) is %v", rcVsRcbIsect.getCardinality(), len(hashi)) - So(rcVsBcIsect.getCardinality(), ShouldEqual, len(hashi)) - So(rcVsAcIsect.getCardinality(), ShouldEqual, len(hashi)) - So(rcVsRcbIsect.getCardinality(), ShouldEqual, len(hashi)) - } - p("done with randomized and() vs bitmapContainer and arrayContainer checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestRle16RemoveApi015(t *testing.T) { - - Convey("runContainer16 `remove` (a minus b) should work", t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 100, percentFill: .95, ntrial: 1}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRle16RemoveApi015 on check# j=%v", j) - ma := make(map[int]bool) - mb := make(map[int]bool) - - n := tr.n - a := []uint16{} - b := []uint16{} - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - - r1 := rand.Intn(n) - b = append(b, uint16(r1)) - mb[r1] = true - } - - //showArray16(a, "a") - //showArray16(b, "b") - - // hash version of remove: - hashrm := make(map[int]bool) - for k := range ma { - hashrm[k] = true - } - for k := range mb { - delete(hashrm, k) - } - - // RunContainer's remove - rc := newRunContainer16FromVals(false, a...) - - p("rc from a, pre-remove, is %v", rc) - - for k := range mb { - rc.iremove(uint16(k)) - } - - p("rc from a, post-iremove, is %v", rc) - - //showHash("correct answer is hashrm", hashrm) - - for k := range hashrm { - p("hashrm has %v, checking in rc", k) - So(rc.contains(uint16(k)), ShouldBeTrue) - } - - p("checking for cardinality agreement: rc is %v, len(hashrm) is %v", rc.getCardinality(), len(hashrm)) - So(rc.getCardinality(), ShouldEqual, len(hashrm)) - } - p("done with randomized remove() checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func showArray16(a []uint16, name string) { - sort.Sort(uint16Slice(a)) - stringA := "" - for i := range a { - stringA += fmt.Sprintf("%v, ", a[i]) - } - p("%s is '%v'", name, stringA) -} - -func TestRle16RandomAndNot016(t *testing.T) { - - Convey("runContainer16 `andNot` operation against other container types should correctly do the and-not operation", t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 1000, percentFill: .95, ntrial: 2}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRle16RandomAndNot16 on check# j=%v", j) - ma := make(map[int]bool) - mb := make(map[int]bool) - - n := tr.n - a := []uint16{} - b := []uint16{} - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - - r1 := rand.Intn(n) - b = append(b, uint16(r1)) - mb[r1] = true - } - - //showArray16(a, "a") - //showArray16(b, "b") - - // hash version of and-not - hashi := make(map[int]bool) - for k := range ma { - hashi[k] = true - } - for k := range mb { - delete(hashi, k) - } - - // RunContainer's and-not - rc := newRunContainer16FromVals(false, a...) - - p("rc from a is %v", rc) - - // vs bitmapContainer - bc := newBitmapContainer() - for _, bv := range b { - bc.iadd(bv) - } - - // vs arrayContainer - ac := newArrayContainer() - for _, bv := range b { - ac.iadd(bv) - } - - // vs runContainer - rcb := newRunContainer16FromVals(false, b...) - - rcVsBcAndnot := rc.andNot(bc) - rcVsAcAndnot := rc.andNot(ac) - rcVsRcbAndnot := rc.andNot(rcb) - - p("rcVsBcAndnot is %v", rcVsBcAndnot) - p("rcVsAcAndnot is %v", rcVsAcAndnot) - p("rcVsRcbAndnot is %v", rcVsRcbAndnot) - - //showHash("hashi", hashi) - - for k := range hashi { - p("hashi has %v, checking in rcVsBcAndnot", k) - So(rcVsBcAndnot.contains(uint16(k)), ShouldBeTrue) - - p("hashi has %v, checking in rcVsAcAndnot", k) - So(rcVsAcAndnot.contains(uint16(k)), ShouldBeTrue) - - p("hashi has %v, checking in rcVsRcbAndnot", k) - So(rcVsRcbAndnot.contains(uint16(k)), ShouldBeTrue) - } - - p("checking for cardinality agreement: rcVsBcAndnot is %v, len(hashi) is %v", rcVsBcAndnot.getCardinality(), len(hashi)) - p("checking for cardinality agreement: rcVsAcAndnot is %v, len(hashi) is %v", rcVsAcAndnot.getCardinality(), len(hashi)) - p("checking for cardinality agreement: rcVsRcbAndnot is %v, len(hashi) is %v", rcVsRcbAndnot.getCardinality(), len(hashi)) - So(rcVsBcAndnot.getCardinality(), ShouldEqual, len(hashi)) - So(rcVsAcAndnot.getCardinality(), ShouldEqual, len(hashi)) - So(rcVsRcbAndnot.getCardinality(), ShouldEqual, len(hashi)) - } - p("done with randomized andNot() vs bitmapContainer and arrayContainer checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestRle16RandomInplaceAndNot017(t *testing.T) { - - Convey("runContainer16 `iandNot` operation against other container types should correctly do the inplace-and-not operation", t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 1000, percentFill: .95, ntrial: 2}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRle16RandomAndNot16 on check# j=%v", j) - ma := make(map[int]bool) - mb := make(map[int]bool) - - n := tr.n - a := []uint16{} - b := []uint16{} - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - - r1 := rand.Intn(n) - b = append(b, uint16(r1)) - mb[r1] = true - } - - //showArray16(a, "a") - //showArray16(b, "b") - - // hash version of and-not - hashi := make(map[int]bool) - for k := range ma { - hashi[k] = true - } - for k := range mb { - delete(hashi, k) - } - - // RunContainer's and-not - rc := newRunContainer16FromVals(false, a...) - - p("rc from a is %v", rc) - - // vs bitmapContainer - bc := newBitmapContainer() - for _, bv := range b { - bc.iadd(bv) - } - - // vs arrayContainer - ac := newArrayContainer() - for _, bv := range b { - ac.iadd(bv) - } - - // vs runContainer - rcb := newRunContainer16FromVals(false, b...) - - rcVsBcIandnot := rc.Clone() - rcVsAcIandnot := rc.Clone() - rcVsRcbIandnot := rc.Clone() - - rcVsBcIandnot.iandNot(bc) - rcVsAcIandnot.iandNot(ac) - rcVsRcbIandnot.iandNot(rcb) - - p("rcVsBcIandnot is %v", rcVsBcIandnot) - p("rcVsAcIandnot is %v", rcVsAcIandnot) - p("rcVsRcbIandnot is %v", rcVsRcbIandnot) - - //showHash("hashi", hashi) - - for k := range hashi { - p("hashi has %v, checking in rcVsBcIandnot", k) - So(rcVsBcIandnot.contains(uint16(k)), ShouldBeTrue) - - p("hashi has %v, checking in rcVsAcIandnot", k) - So(rcVsAcIandnot.contains(uint16(k)), ShouldBeTrue) - - p("hashi has %v, checking in rcVsRcbIandnot", k) - So(rcVsRcbIandnot.contains(uint16(k)), ShouldBeTrue) - } - - p("checking for cardinality agreement: rcVsBcIandnot is %v, len(hashi) is %v", rcVsBcIandnot.getCardinality(), len(hashi)) - p("checking for cardinality agreement: rcVsAcIandnot is %v, len(hashi) is %v", rcVsAcIandnot.getCardinality(), len(hashi)) - p("checking for cardinality agreement: rcVsRcbIandnot is %v, len(hashi) is %v", rcVsRcbIandnot.getCardinality(), len(hashi)) - So(rcVsBcIandnot.getCardinality(), ShouldEqual, len(hashi)) - So(rcVsAcIandnot.getCardinality(), ShouldEqual, len(hashi)) - So(rcVsRcbIandnot.getCardinality(), ShouldEqual, len(hashi)) - } - p("done with randomized andNot() vs bitmapContainer and arrayContainer checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestRle16InversionOfIntervals018(t *testing.T) { - - Convey("runContainer `invert` operation should do a NOT on the set of intervals, in-place", t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 1000, percentFill: .90, ntrial: 1}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRle16InversinoOfIntervals018 on check# j=%v", j) - ma := make(map[int]bool) - hashNotA := make(map[int]bool) - - n := tr.n - a := []uint16{} - - // hashNotA will be NOT ma - //for i := 0; i < n; i++ { - for i := 0; i < MaxUint16+1; i++ { - hashNotA[i] = true - } - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - delete(hashNotA, r0) - } - - //showArray16(a, "a") - // too big to print: showHash("hashNotA is not a:", hashNotA) - - // RunContainer's invert - rc := newRunContainer16FromVals(false, a...) - - p("rc from a is %v", rc) - p("rc.cardinality = %v", rc.cardinality()) - inv := rc.invert() - - p("inv of a (card=%v) is %v", inv.cardinality(), inv) - - So(inv.cardinality(), ShouldEqual, 1+MaxUint16-rc.cardinality()) - - for k := 0; k < n; k++ { - if hashNotA[k] { - So(inv.contains(uint16(k)), ShouldBeTrue) - } - } - - // skip for now, too big to do 2^16-1 - p("checking for cardinality agreement: inv is %v, len(hashNotA) is %v", inv.getCardinality(), len(hashNotA)) - So(inv.getCardinality(), ShouldEqual, len(hashNotA)) - } - p("done with randomized invert() check for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestRle16SubtractionOfIntervals019(t *testing.T) { - - Convey("runContainer `subtract` operation removes an interval in-place", t, func() { - // basics - - i22 := interval16{start: 2, last: 2} - left, _ := i22.subtractInterval(i22) - So(len(left), ShouldResemble, 0) - - v := interval16{start: 1, last: 6} - left, _ = v.subtractInterval(interval16{start: 3, last: 4}) - So(len(left), ShouldResemble, 2) - So(left[0].start, ShouldEqual, 1) - So(left[0].last, ShouldEqual, 2) - So(left[1].start, ShouldEqual, 5) - So(left[1].last, ShouldEqual, 6) - - v = interval16{start: 1, last: 6} - left, _ = v.subtractInterval(interval16{start: 4, last: 10}) - So(len(left), ShouldResemble, 1) - So(left[0].start, ShouldEqual, 1) - So(left[0].last, ShouldEqual, 3) - - v = interval16{start: 5, last: 10} - left, _ = v.subtractInterval(interval16{start: 0, last: 7}) - So(len(left), ShouldResemble, 1) - So(left[0].start, ShouldEqual, 8) - So(left[0].last, ShouldEqual, 10) - - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 1000, percentFill: .90, ntrial: 1}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRle16SubtractionOfIntervals019 on check# j=%v", j) - ma := make(map[int]bool) - mb := make(map[int]bool) - - n := tr.n - a := []uint16{} - b := []uint16{} - - // hashAminusB will be ma - mb - hashAminusB := make(map[int]bool) - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - hashAminusB[r0] = true - - r1 := rand.Intn(n) - b = append(b, uint16(r1)) - mb[r1] = true - } - - for k := range mb { - delete(hashAminusB, k) - } - - //showHash("hash a is:", ma) - //showHash("hash b is:", mb) - //showHash("hashAminusB is:", hashAminusB) - - // RunContainer's subtract A - B - rc := newRunContainer16FromVals(false, a...) - rcb := newRunContainer16FromVals(false, b...) - - abkup := rc.Clone() - - p("rc from a is %v", rc) - p("rc.cardinality = %v", rc.cardinality()) - p("rcb from b is %v", rcb) - p("rcb.cardinality = %v", rcb.cardinality()) - it := rcb.newRunIterator16() - for it.hasNext() { - nx := it.next() - rc.isubtract(interval16{start: nx, last: nx}) - } - - // also check full interval subtraction - for _, p := range rcb.iv { - abkup.isubtract(p) - } - - p("rc = a - b; has (card=%v), is %v", rc.cardinality(), rc) - p("abkup = a - b; has (card=%v), is %v", abkup.cardinality(), abkup) - - for k := range hashAminusB { - p("hashAminusB has element %v, checking rc and abkup (which are/should be: A - B)", k) - So(rc.contains(uint16(k)), ShouldBeTrue) - So(abkup.contains(uint16(k)), ShouldBeTrue) - } - p("checking for cardinality agreement: sub is %v, len(hashAminusB) is %v", rc.getCardinality(), len(hashAminusB)) - So(rc.getCardinality(), ShouldEqual, len(hashAminusB)) - p("checking for cardinality agreement: sub is %v, len(hashAminusB) is %v", abkup.getCardinality(), len(hashAminusB)) - So(abkup.getCardinality(), ShouldEqual, len(hashAminusB)) - - } - p("done with randomized subtract() check for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestRle16Rank020(t *testing.T) { - v := container(newRunContainer16()) - v = v.iaddReturnMinimized(10) - v = v.iaddReturnMinimized(100) - v = v.iaddReturnMinimized(1000) - if v.getCardinality() != 3 { - t.Errorf("Bogus cardinality.") - } - for i := 0; i <= arrayDefaultMaxSize; i++ { - thisrank := v.rank(uint16(i)) - if i < 10 { - if thisrank != 0 { - t.Errorf("At %d should be zero but is %d ", i, thisrank) - } - } else if i < 100 { - if thisrank != 1 { - t.Errorf("At %d should be zero but is %d ", i, thisrank) - } - } else if i < 1000 { - if thisrank != 2 { - t.Errorf("At %d should be zero but is %d ", i, thisrank) - } - } else { - if thisrank != 3 { - t.Errorf("At %d should be zero but is %d ", i, thisrank) - } - } - } -} - -func TestRle16NotAlsoKnownAsFlipRange021(t *testing.T) { - - Convey("runContainer `Not` operation should flip the bits of a range on the new returned container", t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 100, percentFill: .8, ntrial: 2}, - /* trial{n: 10, percentFill: .01, ntrial: 10}, - trial{n: 10, percentFill: .50, ntrial: 10}, - trial{n: 1000, percentFill: .50, ntrial: 10}, - trial{n: 1000, percentFill: .99, ntrial: 10}, - */ - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRle16NotAlsoKnownAsFlipRange021 on check# j=%v", j) - - // what is the interval we are going to flip? - - ma := make(map[int]bool) - flipped := make(map[int]bool) - - n := tr.n - a := []uint16{} - - draw := int(float64(n) * tr.percentFill) - p("draw is %v", draw) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - flipped[r0] = true - p("draw r0=%v is being added to a and ma", r0) - } - - // pick an interval to flip - begin := rand.Intn(n) - last := rand.Intn(n) - if last < begin { - begin, last = last, begin - } - p("our interval to flip is [%v, %v]", begin, last) - - // do the flip on the hash `flipped` - for i := begin; i <= last; i++ { - if flipped[i] { - delete(flipped, i) - } else { - flipped[i] = true - } - } - - //showArray16(a, "a") - // can be too big to print: - //showHash("hash (correct) version of flipped is:", flipped) - - // RunContainer's Not - rc := newRunContainer16FromVals(false, a...) - flp := rc.Not(begin, last+1) - So(flp.cardinality(), ShouldEqual, len(flipped)) - - for k := 0; k < n; k++ { - if flipped[k] { - So(flp.contains(uint16(k)), ShouldBeTrue) - } else { - So(flp.contains(uint16(k)), ShouldBeFalse) - } - } - - So(flp.getCardinality(), ShouldEqual, len(flipped)) - } - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestRleEquals022(t *testing.T) { - - Convey("runContainer `equals` should accurately compare contents against other container types", t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 100, percentFill: .2, ntrial: 10}, - /* - trial{n: 10, percentFill: .01, ntrial: 10}, - trial{n: 10, percentFill: .50, ntrial: 10}, - trial{n: 1000, percentFill: .50, ntrial: 10}, - trial{n: 1000, percentFill: .99, ntrial: 10}, - */ - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRleEquals022 on check# j=%v", j) - - ma := make(map[int]bool) - - n := tr.n - a := []uint16{} - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - } - - rc := newRunContainer16FromVals(false, a...) - - // make bitmap and array versions: - bc := newBitmapContainer() - ac := newArrayContainer() - for k := range ma { - ac.iadd(uint16(k)) - bc.iadd(uint16(k)) - } - - // compare equals() across all three - So(rc.equals(ac), ShouldBeTrue) - So(rc.equals(bc), ShouldBeTrue) - - So(ac.equals(rc), ShouldBeTrue) - So(ac.equals(bc), ShouldBeTrue) - - So(bc.equals(ac), ShouldBeTrue) - So(bc.equals(rc), ShouldBeTrue) - - // and for good measure, check against the hash - So(rc.getCardinality(), ShouldEqual, len(ma)) - So(ac.getCardinality(), ShouldEqual, len(ma)) - So(bc.getCardinality(), ShouldEqual, len(ma)) - for k := range ma { - So(rc.contains(uint16(k)), ShouldBeTrue) - So(ac.contains(uint16(k)), ShouldBeTrue) - So(bc.contains(uint16(k)), ShouldBeTrue) - } - } - p("done with randomized equals() check for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestRleIntersects023(t *testing.T) { - - Convey("runContainer `intersects` query should work against any mix of container types", t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 10, percentFill: .293, ntrial: 1000}, - /* - trial{n: 10, percentFill: .01, ntrial: 10}, - trial{n: 10, percentFill: .50, ntrial: 10}, - trial{n: 1000, percentFill: .50, ntrial: 10}, - trial{n: 1000, percentFill: .99, ntrial: 10}, - */ - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRleIntersects023 on check# j=%v", j) - - ma := make(map[int]bool) - mb := make(map[int]bool) - - n := tr.n - a := []uint16{} - b := []uint16{} - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - - r1 := rand.Intn(n) - b = append(b, uint16(r1)) - mb[r1] = true - } - - // determine if they intersect from the maps - isect := false - for k := range ma { - if mb[k] { - isect = true - break - } - } - //fmt.Printf("isect was %v\n", isect) - - //showArray16(a, "a") - // can be too big to print: - //showHash("hash (correct) version of flipped is:", flipped) - - rcA := newRunContainer16FromVals(false, a...) - rcB := newRunContainer16FromVals(false, b...) - - // make bitmap and array versions: - bcA := newBitmapContainer() - bcB := newBitmapContainer() - - acA := newArrayContainer() - acB := newArrayContainer() - for k := range ma { - acA.iadd(uint16(k)) - bcA.iadd(uint16(k)) - } - for k := range mb { - acB.iadd(uint16(k)) - bcB.iadd(uint16(k)) - } - - // compare intersects() across all three - - // same type - So(rcA.intersects(rcB), ShouldEqual, isect) - So(acA.intersects(acB), ShouldEqual, isect) - So(bcA.intersects(bcB), ShouldEqual, isect) - - // across types - So(rcA.intersects(acB), ShouldEqual, isect) - So(rcA.intersects(bcB), ShouldEqual, isect) - - So(acA.intersects(rcB), ShouldEqual, isect) - So(acA.intersects(bcB), ShouldEqual, isect) - - So(bcA.intersects(acB), ShouldEqual, isect) - So(bcA.intersects(rcB), ShouldEqual, isect) - - // and swap the call pattern, so we test B intersects A as well. - - // same type - So(rcB.intersects(rcA), ShouldEqual, isect) - So(acB.intersects(acA), ShouldEqual, isect) - So(bcB.intersects(bcA), ShouldEqual, isect) - - // across types - So(rcB.intersects(acA), ShouldEqual, isect) - So(rcB.intersects(bcA), ShouldEqual, isect) - - So(acB.intersects(rcA), ShouldEqual, isect) - So(acB.intersects(bcA), ShouldEqual, isect) - - So(bcB.intersects(acA), ShouldEqual, isect) - So(bcB.intersects(rcA), ShouldEqual, isect) - - } - p("done with randomized intersects() check for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestRleToEfficientContainer027(t *testing.T) { - - Convey("runContainer toEfficientContainer should return equivalent containers", t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - // 4096 or fewer integers -> array typically - - trials := []trial{ - {n: 8000, percentFill: .01, ntrial: 10}, - {n: 8000, percentFill: .99, ntrial: 10}, - /* - trial{n: 10, percentFill: .01, ntrial: 10}, - trial{n: 10, percentFill: .50, ntrial: 10}, - trial{n: 1000, percentFill: .50, ntrial: 10}, - trial{n: 1000, percentFill: .99, ntrial: 10}, - */ - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRleToEfficientContainer027 on check# j=%v", j) - - ma := make(map[int]bool) - - n := tr.n - a := []uint16{} - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - } - - rc := newRunContainer16FromVals(false, a...) - - c := rc.toEfficientContainer() - So(rc.equals(c), ShouldBeTrue) - - switch tc := c.(type) { - case *bitmapContainer: - p("I see a bitmapContainer with card %v", tc.getCardinality()) - case *arrayContainer: - p("I see a arrayContainer with card %v", tc.getCardinality()) - case *runContainer16: - p("I see a runContainer16 with card %v", tc.getCardinality()) - } - - } - p("done with randomized toEfficientContainer() check for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) - - Convey("runContainer toEfficientContainer should return an equivalent bitmap when that is efficient", t, func() { - - a := []uint16{} - - // odd intergers should be smallest as a bitmap - for i := 0; i < MaxUint16; i++ { - if i%2 == 1 { - a = append(a, uint16(i)) - } - } - - rc := newRunContainer16FromVals(false, a...) - - c := rc.toEfficientContainer() - So(rc.equals(c), ShouldBeTrue) - - _, isBitmapContainer := c.(*bitmapContainer) - So(isBitmapContainer, ShouldBeTrue) - - switch tc := c.(type) { - case *bitmapContainer: - p("I see a bitmapContainer with card %v", tc.getCardinality()) - case *arrayContainer: - p("I see a arrayContainer with card %v", tc.getCardinality()) - case *runContainer16: - p("I see a runContainer16 with card %v", tc.getCardinality()) - } - - }) -} - -func TestRle16RandomFillLeastSignificant16bits029(t *testing.T) { - - Convey("runContainer16.fillLeastSignificant16bits() should fill contents as expected, matching the same function on bitmap and array containers", t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 100, percentFill: .95, ntrial: 1}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRle16RandomFillLeastSignificant16bits029 on check# j=%v", j) - ma := make(map[int]bool) - - n := tr.n - a := []uint16{} - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - } - - //showArray16(a, "a") - - // RunContainer - rc := newRunContainer16FromVals(false, a...) - - p("rc from a is %v", rc) - - // vs bitmapContainer - bc := newBitmapContainer() - for _, av := range a { - bc.iadd(av) - } - - // vs arrayContainer - ac := newArrayContainer() - for _, av := range a { - ac.iadd(av) - } - - acOut := make([]uint32, n+10) - bcOut := make([]uint32, n+10) - rcOut := make([]uint32, n+10) - - pos2 := 0 - - // see Bitmap.ToArray() for principal use - hs := uint32(43) << 16 - ac.fillLeastSignificant16bits(acOut, pos2, hs) - bc.fillLeastSignificant16bits(bcOut, pos2, hs) - rc.fillLeastSignificant16bits(rcOut, pos2, hs) - - So(rcOut, ShouldResemble, acOut) - So(rcOut, ShouldResemble, bcOut) - } - p("done with randomized fillLeastSignificant16bits checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestRle16RandomGetShortIterator030(t *testing.T) { - - Convey("runContainer16.getShortIterator should traverse the contents expected, matching the traversal of the bitmap and array containers", t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 100, percentFill: .95, ntrial: 1}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRle16RandomGetShortIterator030 on check# j=%v", j) - ma := make(map[int]bool) - - n := tr.n - a := []uint16{} - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - } - - //showArray16(a, "a") - - // RunContainer - rc := newRunContainer16FromVals(false, a...) - - p("rc from a is %v", rc) - - // vs bitmapContainer - bc := newBitmapContainer() - for _, av := range a { - bc.iadd(av) - } - - // vs arrayContainer - ac := newArrayContainer() - for _, av := range a { - ac.iadd(av) - } - - rit := rc.getShortIterator() - ait := ac.getShortIterator() - bit := bc.getShortIterator() - - for ait.hasNext() { - rn := rit.next() - an := ait.next() - bn := bit.next() - So(rn, ShouldEqual, an) - So(rn, ShouldEqual, bn) - } - } - p("done with randomized TestRle16RandomGetShortIterator030 checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestRle16RandomIaddRangeIremoveRange031(t *testing.T) { - - Convey("runContainer16.iaddRange and iremoveRange should add/remove contents as expected, matching the same operations on the bitmap and array containers and the hashmap pos control", t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 101, percentFill: .9, ntrial: 10}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestRle16RandomIaddRangeIremoveRange031 on check# j=%v", j) - ma := make(map[int]bool) - - n := tr.n - a := []uint16{} - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - } - - //showArray16(a, "a") - - // RunContainer - rc := newRunContainer16FromVals(false, a...) - - p("rc from a is %v", rc) - - // vs bitmapContainer - bc := newBitmapContainer() - for _, av := range a { - bc.iadd(av) - } - - // vs arrayContainer - ac := newArrayContainer() - for _, av := range a { - ac.iadd(av) - } - - // iaddRange and iRemoveRange : pick some distinct random endpoints - a0 := rand.Intn(n) - a1 := a0 - for a1 == a0 { - a1 = rand.Intn(n) - } - if a0 > a1 { - a0, a1 = a1, a0 - } - - r0 := rand.Intn(n) - r1 := r0 - for r1 == r0 { - r1 = rand.Intn(n) - } - if r0 > r1 { - r0, r1 = r1, r0 - } - - // do the add - for i := a0; i <= a1; i++ { - ma[i] = true - } - // then the remove - for i := r0; i <= r1; i++ { - delete(ma, i) - } - - rc.iaddRange(a0, a1+1) - rc.iremoveRange(r0, r1+1) - - bc.iaddRange(a0, a1+1) - bc.iremoveRange(r0, r1+1) - - ac.iaddRange(a0, a1+1) - ac.iremoveRange(r0, r1+1) - - So(rc.getCardinality(), ShouldEqual, len(ma)) - So(rc.getCardinality(), ShouldEqual, ac.getCardinality()) - So(rc.getCardinality(), ShouldEqual, bc.getCardinality()) - - rit := rc.getShortIterator() - ait := ac.getShortIterator() - bit := bc.getShortIterator() - - for ait.hasNext() { - rn := rit.next() - an := ait.next() - bn := bit.next() - So(rn, ShouldEqual, an) - So(rn, ShouldEqual, bn) - } - // verify againt the map - for k := range ma { - So(rc.contains(uint16(k)), ShouldBeTrue) - } - - // coverage for run16 method - So(rc.serializedSizeInBytes(), ShouldEqual, 2+4*rc.numberOfRuns()) - } - p("done with randomized TestRle16RandomIaddRangeIremoveRange031 checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestAllContainerMethodsAllContainerTypes065(t *testing.T) { - - Convey("each of the container methods that takes two containers should handle all 3x3==9 possible ways of being called -- without panic", t, func() { - a := newArrayContainer() - r := newRunContainer16() - b := newBitmapContainer() - - arr := []container{a, r, b} - for _, i := range arr { - for _, j := range arr { - i.and(j) - i.iand(j) - i.andNot(j) - - i.iandNot(j) - i.xor(j) - i.equals(j) - - i.or(j) - i.ior(j) - i.intersects(j) - - i.lazyOR(j) - i.lazyIOR(j) - } - } - }) - -} - -type twoCall func(r container) container - -type twofer struct { - name string - call twoCall - cn container -} - -func TestAllContainerMethodsAllContainerTypesWithData067(t *testing.T) { - - Convey("each of the container methods that takes two containers should handle all 3x3==9 possible ways of being called -- and return results that agree with each other", t, func() { - - //rleVerbose = true - - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 100, percentFill: .7, ntrial: 1, numRandomOpsPass: 100}, - {n: 100, percentFill: .7, ntrial: 1, numRandomOpsPass: 100, srang: &interval16{MaxUint16 - 100, MaxUint16}}} - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestAllContainerMethodsAllContainerTypesWithData067 on check# j=%v", j) - - a, r, b := getRandomSameThreeContainers(tr) - a2, r2, b2 := getRandomSameThreeContainers(tr) - - p("prior to any operations, fresh from getRandom...") - p("receiver (a) is '%s'", a) - p("receiver (r) is '%s'", r) - p("receiver (b) is '%s'", b) - - p("\n argument is '%s'\n", r2) - - m := []string{"array", "run", "bitmap"} - - receiver := []container{a, r, b} - arg := []container{a2, r2, b2} - callme := []twofer{} - - nCalls := 0 - for k, c := range receiver { - callme = append(callme, twofer{"and", c.and, c}) - callme = append(callme, twofer{"iand", c.iand, c}) - callme = append(callme, twofer{"ior", c.ior, c}) - callme = append(callme, twofer{"lazyOR", c.lazyOR, c}) - callme = append(callme, twofer{"lazyIOR", c.lazyIOR, c}) - callme = append(callme, twofer{"or", c.or, c}) - callme = append(callme, twofer{"xor", c.xor, c}) - callme = append(callme, twofer{"andNot", c.andNot, c}) - callme = append(callme, twofer{"iandNot", c.iandNot, c}) - if k == 0 { - nCalls = len(callme) - } - } - - for pass := 0; pass < tr.numRandomOpsPass+1; pass++ { - for k := 0; k < nCalls; k++ { - perm := getRandomPermutation(nCalls) - kk := perm[k] - c1 := callme[kk] // array receiver - c2 := callme[kk+nCalls] // run receiver - c3 := callme[kk+2*nCalls] // bitmap receiver - - if c1.name != c2.name { - panic("internal logic error") - } - if c3.name != c2.name { - panic("internal logic error") - } - - p("\n ========== testing calls to '%s' all match\n", c1.name) - for k2, a := range arg { - - p("\n ------------ on arg as '%s': %s\n", m[k2], a) - p("\n prior to '%s', array receiver c1 is '%s'\n", c1.name, c1.cn) - p("\n prior to '%s', run receiver c2 is '%s'\n", c2.name, c2.cn) - p("\n prior to '%s', bitmap receiver c3 is '%s'\n", c3.name, c3.cn) - if !c1.cn.equals(c2.cn) { - panic("c1 not equal to c2") - } - if !c1.cn.equals(c3.cn) { - panic("c1 not equal to c3") - } - - res1 := c1.call(a) // array - res2 := c2.call(a) // run - res3 := c3.call(a) // bitmap - - z := c1.name - - if strings.HasPrefix(z, "lazy") { - // on purpose, the lazy functions - // do not scan to update their cardinality - if asBc, isBc := res1.(*bitmapContainer); isBc { - asBc.computeCardinality() - } - if asBc, isBc := res2.(*bitmapContainer); isBc { - asBc.computeCardinality() - } - if asBc, isBc := res3.(*bitmapContainer); isBc { - asBc.computeCardinality() - } - } - - // check for equality all ways... - // excercising equals() calls too. - - p("'%s' receiver, '%s' arg, call='%s', res1=%s", - m[0], m[k2], z, res1) - p("'%s' receiver, '%s' arg, call='%s', res2=%s", - m[1], m[k2], z, res2) - p("'%s' receiver, '%s' arg, call='%s', res3=%s", - m[2], m[k2], z, res3) - - if !res1.equals(res2) { - panic(fmt.Sprintf("k:%v, k2:%v, res1 != res2,"+ - " call is '%s'", k, k2, c1.name)) - } - if !res2.equals(res1) { - panic(fmt.Sprintf("k:%v, k2:%v, res2 != res1,"+ - " call is '%s'", k, k2, c1.name)) - } - if !res1.equals(res3) { - p("res1 = %s", res1) - p("res3 = %s", res3) - panic(fmt.Sprintf("k:%v, k2:%v, res1 != res3,"+ - " call is '%s'", k, k2, c1.name)) - } - if !res3.equals(res1) { - panic(fmt.Sprintf("k:%v, k2:%v, res3 != res1,"+ - " call is '%s'", k, k2, c1.name)) - } - if !res2.equals(res3) { - panic(fmt.Sprintf("k:%v, k2:%v, res2 != res3,"+ - " call is '%s'", k, k2, c1.name)) - } - if !res3.equals(res2) { - panic(fmt.Sprintf("k:%v, k2:%v, res3 != res2,"+ - " call is '%s'", k, k2, c1.name)) - } - } - } // end k - } // end pass - - } // end j - p("done with randomized TestAllContainerMethodsAllContainerTypesWithData067 checks for trial %#v", tr) - } // end tester - - for i := range trials { - tester(trials[i]) - } - - }) - -} - -// generate random contents, then return that same -// logical content in three different container types -func getRandomSameThreeContainers(tr trial) (*arrayContainer, *runContainer16, *bitmapContainer) { - - ma := make(map[int]bool) - - n := tr.n - a := []uint16{} - - var samp interval16 - if tr.srang != nil { - samp = *tr.srang - } else { - samp.start = 0 - if n-1 > MaxUint16 { - panic(fmt.Errorf("n out of range: %v", n)) - } - samp.last = uint16(n - 1) - } - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := int(samp.start) + rand.Intn(int(samp.runlen())) - a = append(a, uint16(r0)) - ma[r0] = true - } - - //showArray16(a, "a") - - rc := newRunContainer16FromVals(false, a...) - - p("rc from a is %v", rc) - - // vs bitmapContainer - bc := newBitmapContainerFromRun(rc) - ac := rc.toArrayContainer() - - return ac, rc, bc -} diff --git a/vendor/github.com/RoaringBitmap/roaring/roaring_test.go b/vendor/github.com/RoaringBitmap/roaring/roaring_test.go deleted file mode 100644 index 30fcccf6d..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/roaring_test.go +++ /dev/null @@ -1,1859 +0,0 @@ -package roaring - -import ( - . "github.com/smartystreets/goconvey/convey" - "github.com/willf/bitset" - "log" - "math/rand" - "strconv" - "testing" -) - -func TestFirstLast(t *testing.T) { - bm := New() - bm.AddInt(2) - bm.AddInt(4) - bm.AddInt(8) - if 2 != bm.Minimum() { - t.Errorf("bad minimum") - t.FailNow() - } - if 8 != bm.Maximum() { - t.Errorf("bad maximum") - t.FailNow() - } - i := 1 << 5 - for ; i < (1 << 17); i += 1 { - bm.AddInt(i) - if 2 != bm.Minimum() { - t.Errorf("bad minimum") - t.FailNow() - } - if uint32(i) != bm.Maximum() { - t.Errorf("bad maximum", i, bm.Maximum()) - t.FailNow() - } - } - bm.RunOptimize() - if 2 != bm.Minimum() { - t.Errorf("bad minimum") - t.FailNow() - } - if uint32(i-1) != bm.Maximum() { - t.Errorf("bad maximum", i, bm.Maximum()) - t.FailNow() - } -} - -func TestRoaringBitmapBitmapOf(t *testing.T) { - array := []uint32{5580, 33722, 44031, 57276, 83097} - bmp := BitmapOf(array...) - if len(array) != int(bmp.GetCardinality()) { - t.Errorf("length diff %d!=%d", len(array), bmp.GetCardinality()) - t.FailNow() - } - by, _ := bmp.ToBytes() - if uint64(len(by)) != bmp.GetSerializedSizeInBytes() { - t.Errorf("bad ToBytes") - t.FailNow() - } -} - -func TestRoaringBitmapAdd(t *testing.T) { - array := []uint32{5580, 33722, 44031, 57276, 83097} - bmp := New() - for _, v := range array { - bmp.Add(v) - } - if len(array) != int(bmp.GetCardinality()) { - t.Errorf("length diff %d!=%d", len(array), bmp.GetCardinality()) - t.FailNow() - } -} - -func TestRoaringBitmapAddMany(t *testing.T) { - array := []uint32{5580, 33722, 44031, 57276, 83097} - bmp := NewBitmap() - bmp.AddMany(array) - if len(array) != int(bmp.GetCardinality()) { - t.Errorf("length diff %d!=%d", len(array), bmp.GetCardinality()) - t.FailNow() - } -} - -// https://github.com/RoaringBitmap/roaring/issues/64 -func TestFlip64(t *testing.T) { - bm := New() - bm.AddInt(0) - bm.Flip(1, 2) - i := bm.Iterator() - if i.Next() != 0 || i.Next() != 1 || i.HasNext() { - t.Error("expected {0,1}") - } -} - -// https://github.com/RoaringBitmap/roaring/issues/64 -func TestFlip64Off(t *testing.T) { - bm := New() - bm.AddInt(10) - bm.Flip(11, 12) - i := bm.Iterator() - if i.Next() != 10 || i.Next() != 11 || i.HasNext() { - t.Error("expected {10,11}") - } -} - -func TestStringer(t *testing.T) { - v := NewBitmap() - for i := uint32(0); i < 10; i++ { - v.Add(i) - } - if v.String() != "{0,1,2,3,4,5,6,7,8,9}" { - t.Error("bad string output") - } - v.RunOptimize() - if v.String() != "{0,1,2,3,4,5,6,7,8,9}" { - t.Error("bad string output") - } -} - -func TestFastCard(t *testing.T) { - Convey("fast card", t, func() { - bm := NewBitmap() - bm.Add(1) - bm.AddRange(21, 260000) - bm2 := NewBitmap() - bm2.Add(25) - So(bm2.AndCardinality(bm), ShouldEqual, 1) - So(bm2.OrCardinality(bm), ShouldEqual, bm.GetCardinality()) - So(bm.AndCardinality(bm2), ShouldEqual, 1) - So(bm.OrCardinality(bm2), ShouldEqual, bm.GetCardinality()) - So(bm2.AndCardinality(bm), ShouldEqual, 1) - So(bm2.OrCardinality(bm), ShouldEqual, bm.GetCardinality()) - bm.RunOptimize() - So(bm2.AndCardinality(bm), ShouldEqual, 1) - So(bm2.OrCardinality(bm), ShouldEqual, bm.GetCardinality()) - So(bm.AndCardinality(bm2), ShouldEqual, 1) - So(bm.OrCardinality(bm2), ShouldEqual, bm.GetCardinality()) - So(bm2.AndCardinality(bm), ShouldEqual, 1) - So(bm2.OrCardinality(bm), ShouldEqual, bm.GetCardinality()) - }) -} - -func TestIntersects1(t *testing.T) { - Convey("intersects", t, func() { - bm := NewBitmap() - bm.Add(1) - bm.AddRange(21, 26) - bm2 := NewBitmap() - bm2.Add(25) - So(bm2.Intersects(bm), ShouldEqual, true) - bm.Remove(25) - So(bm2.Intersects(bm), ShouldEqual, false) - bm.AddRange(1, 100000) - So(bm2.Intersects(bm), ShouldEqual, true) - }) -} - -func TestRangePanic(t *testing.T) { - Convey("TestRangePanic", t, func() { - bm := NewBitmap() - bm.Add(1) - bm.AddRange(21, 26) - bm.AddRange(9, 14) - bm.AddRange(11, 16) - }) -} - -func TestRangeRemoval(t *testing.T) { - Convey("TestRangeRemovalPanic", t, func() { - bm := NewBitmap() - bm.Add(1) - bm.AddRange(21, 26) - bm.AddRange(9, 14) - bm.RemoveRange(11, 16) - bm.RemoveRange(1, 26) - c := bm.GetCardinality() - So(c, ShouldEqual, 0) - bm.AddRange(1, 10000) - c = bm.GetCardinality() - So(c, ShouldEqual, 10000-1) - bm.RemoveRange(1, 10000) - c = bm.GetCardinality() - So(c, ShouldEqual, 0) - }) -} - -func TestRangeRemovalFromContent(t *testing.T) { - Convey("TestRangeRemovalPanic", t, func() { - bm := NewBitmap() - for i := 100; i < 10000; i++ { - bm.AddInt(i * 3) - } - bm.AddRange(21, 26) - bm.AddRange(9, 14) - bm.RemoveRange(11, 16) - bm.RemoveRange(0, 30000) - c := bm.GetCardinality() - So(c, ShouldEqual, 00) - }) -} - -func TestFlipOnEmpty(t *testing.T) { - - Convey("TestFlipOnEmpty in-place", t, func() { - bm := NewBitmap() - bm.Flip(0, 10) - c := bm.GetCardinality() - So(c, ShouldEqual, 10) - }) - Convey("TestFlipOnEmpty, generating new result", t, func() { - bm := NewBitmap() - bm = Flip(bm, 0, 10) - c := bm.GetCardinality() - So(c, ShouldEqual, 10) - }) -} - -func TestBitmapRank(t *testing.T) { - for N := uint32(1); N <= 1048576; N *= 2 { - Convey("rank tests"+strconv.Itoa(int(N)), t, func() { - for gap := uint32(1); gap <= 65536; gap *= 2 { - rb1 := NewBitmap() - for x := uint32(0); x <= N; x += gap { - rb1.Add(x) - } - for y := uint32(0); y <= N; y++ { - if rb1.Rank(y) != uint64((y+1+gap-1)/gap) { - So(rb1.Rank(y), ShouldEqual, (y+1+gap-1)/gap) - } - } - } - }) - } -} - -func TestBitmapSelect(t *testing.T) { - for N := uint32(1); N <= 1048576; N *= 2 { - Convey("rank tests"+strconv.Itoa(int(N)), t, func() { - for gap := uint32(1); gap <= 65536; gap *= 2 { - rb1 := NewBitmap() - for x := uint32(0); x <= N; x += gap { - rb1.Add(x) - } - for y := uint32(0); y <= N/gap; y++ { - expectedInt := y * gap - i, err := rb1.Select(y) - if err != nil { - t.Fatal(err) - } - - if i != expectedInt { - So(i, ShouldEqual, expectedInt) - } - } - } - }) - } -} - -// some extra tests -func TestBitmapExtra(t *testing.T) { - for N := uint32(1); N <= 65536; N *= 2 { - Convey("extra tests"+strconv.Itoa(int(N)), t, func() { - for gap := uint32(1); gap <= 65536; gap *= 2 { - bs1 := bitset.New(0) - rb1 := NewBitmap() - for x := uint32(0); x <= N; x += gap { - bs1.Set(uint(x)) - rb1.Add(x) - } - So(bs1.Count(), ShouldEqual, rb1.GetCardinality()) - So(equalsBitSet(bs1, rb1), ShouldEqual, true) - for offset := uint32(1); offset <= gap; offset *= 2 { - bs2 := bitset.New(0) - rb2 := NewBitmap() - for x := uint32(0); x <= N; x += gap { - bs2.Set(uint(x + offset)) - rb2.Add(x + offset) - } - So(bs2.Count(), ShouldEqual, rb2.GetCardinality()) - So(equalsBitSet(bs2, rb2), ShouldEqual, true) - - clonebs1 := bs1.Clone() - clonebs1.InPlaceIntersection(bs2) - if !equalsBitSet(clonebs1, And(rb1, rb2)) { - t := rb1.Clone() - t.And(rb2) - So(equalsBitSet(clonebs1, t), ShouldEqual, true) - } - - // testing OR - clonebs1 = bs1.Clone() - clonebs1.InPlaceUnion(bs2) - - So(equalsBitSet(clonebs1, Or(rb1, rb2)), ShouldEqual, true) - // testing XOR - clonebs1 = bs1.Clone() - clonebs1.InPlaceSymmetricDifference(bs2) - So(equalsBitSet(clonebs1, Xor(rb1, rb2)), ShouldEqual, true) - - //testing NOTAND - clonebs1 = bs1.Clone() - clonebs1.InPlaceDifference(bs2) - So(equalsBitSet(clonebs1, AndNot(rb1, rb2)), ShouldEqual, true) - } - } - }) - } -} - -func FlipRange(start, end int, bs *bitset.BitSet) { - for i := start; i < end; i++ { - bs.Flip(uint(i)) - } -} - -func TestBitmap(t *testing.T) { - - Convey("Test Contains", t, func() { - rbm1 := NewBitmap() - for k := 0; k < 1000; k++ { - rbm1.AddInt(17 * k) - } - for k := 0; k < 17*1000; k++ { - So(rbm1.ContainsInt(k), ShouldEqual, (k/17*17 == k)) - } - }) - - Convey("Test Clone", t, func() { - rb1 := NewBitmap() - rb1.Add(10) - - rb2 := rb1.Clone() - rb2.Remove(10) - - So(rb1.Contains(10), ShouldBeTrue) - }) - - Convey("Test ANDNOT4", t, func() { - rb := NewBitmap() - rb2 := NewBitmap() - - for i := 0; i < 200000; i += 4 { - rb2.AddInt(i) - } - for i := 200000; i < 400000; i += 14 { - rb2.AddInt(i) - } - - off := AndNot(rb2, rb) - andNotresult := AndNot(rb, rb2) - - So(rb.Equals(andNotresult), ShouldEqual, true) - So(rb2.Equals(off), ShouldEqual, true) - rb2.AndNot(rb) - So(rb2.Equals(off), ShouldEqual, true) - - }) - - Convey("Test AND", t, func() { - rr := NewBitmap() - for k := 0; k < 4000; k++ { - rr.AddInt(k) - } - rr.Add(100000) - rr.Add(110000) - rr2 := NewBitmap() - rr2.Add(13) - rrand := And(rr, rr2) - array := rrand.ToArray() - - So(len(array), ShouldEqual, 1) - So(array[0], ShouldEqual, 13) - rr.And(rr2) - array = rr.ToArray() - - So(len(array), ShouldEqual, 1) - So(array[0], ShouldEqual, 13) - }) - - Convey("Test AND 2", t, func() { - rr := NewBitmap() - for k := 4000; k < 4256; k++ { - rr.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr.AddInt(k) - } - for k := 3 * 65536; k < 3*65536+9000; k++ { - rr.AddInt(k) - } - for k := 4 * 65535; k < 4*65535+7000; k++ { - rr.AddInt(k) - } - for k := 6 * 65535; k < 6*65535+10000; k++ { - rr.AddInt(k) - } - for k := 8 * 65535; k < 8*65535+1000; k++ { - rr.AddInt(k) - } - for k := 9 * 65535; k < 9*65535+30000; k++ { - rr.AddInt(k) - } - - rr2 := NewBitmap() - for k := 4000; k < 4256; k++ { - rr2.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr2.AddInt(k) - } - for k := 3*65536 + 2000; k < 3*65536+6000; k++ { - rr2.AddInt(k) - } - for k := 6 * 65535; k < 6*65535+1000; k++ { - rr2.AddInt(k) - } - for k := 7 * 65535; k < 7*65535+1000; k++ { - rr2.AddInt(k) - } - for k := 10 * 65535; k < 10*65535+5000; k++ { - rr2.AddInt(k) - } - correct := And(rr, rr2) - rr.And(rr2) - So(correct.Equals(rr), ShouldEqual, true) - }) - - Convey("Test AND 2", t, func() { - rr := NewBitmap() - for k := 0; k < 4000; k++ { - rr.AddInt(k) - } - rr.AddInt(100000) - rr.AddInt(110000) - rr2 := NewBitmap() - rr2.AddInt(13) - - rrand := And(rr, rr2) - array := rrand.ToArray() - So(len(array), ShouldEqual, 1) - So(array[0], ShouldEqual, 13) - }) - Convey("Test AND 3a", t, func() { - rr := NewBitmap() - rr2 := NewBitmap() - for k := 6 * 65536; k < 6*65536+10000; k++ { - rr.AddInt(k) - } - for k := 6 * 65536; k < 6*65536+1000; k++ { - rr2.AddInt(k) - } - result := And(rr, rr2) - So(result.GetCardinality(), ShouldEqual, 1000) - }) - Convey("Test AND 3", t, func() { - var arrayand [11256]uint32 - //393,216 - pos := 0 - rr := NewBitmap() - for k := 4000; k < 4256; k++ { - rr.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr.AddInt(k) - } - for k := 3 * 65536; k < 3*65536+1000; k++ { - rr.AddInt(k) - } - for k := 3*65536 + 1000; k < 3*65536+7000; k++ { - rr.AddInt(k) - } - for k := 3*65536 + 7000; k < 3*65536+9000; k++ { - rr.AddInt(k) - } - for k := 4 * 65536; k < 4*65536+7000; k++ { - rr.AddInt(k) - } - for k := 8 * 65536; k < 8*65536+1000; k++ { - rr.AddInt(k) - } - for k := 9 * 65536; k < 9*65536+30000; k++ { - rr.AddInt(k) - } - - rr2 := NewBitmap() - for k := 4000; k < 4256; k++ { - rr2.AddInt(k) - arrayand[pos] = uint32(k) - pos++ - } - for k := 65536; k < 65536+4000; k++ { - rr2.AddInt(k) - arrayand[pos] = uint32(k) - pos++ - } - for k := 3*65536 + 1000; k < 3*65536+7000; k++ { - rr2.AddInt(k) - arrayand[pos] = uint32(k) - pos++ - } - for k := 6 * 65536; k < 6*65536+10000; k++ { - rr.AddInt(k) - } - for k := 6 * 65536; k < 6*65536+1000; k++ { - rr2.AddInt(k) - arrayand[pos] = uint32(k) - pos++ - } - - for k := 7 * 65536; k < 7*65536+1000; k++ { - rr2.AddInt(k) - } - for k := 10 * 65536; k < 10*65536+5000; k++ { - rr2.AddInt(k) - } - rrand := And(rr, rr2) - - arrayres := rrand.ToArray() - ok := true - for i := range arrayres { - if i < len(arrayand) { - if arrayres[i] != arrayand[i] { - log.Println(i, arrayres[i], arrayand[i]) - ok = false - } - } else { - log.Println('x', arrayres[i]) - ok = false - } - } - - So(len(arrayand), ShouldEqual, len(arrayres)) - So(ok, ShouldEqual, true) - - }) - - Convey("Test AND 4", t, func() { - rb := NewBitmap() - rb2 := NewBitmap() - - for i := 0; i < 200000; i += 4 { - rb2.AddInt(i) - } - for i := 200000; i < 400000; i += 14 { - rb2.AddInt(i) - } - //TODO: Bitmap.And(bm,bm2) - andresult := And(rb, rb2) - off := And(rb2, rb) - So(andresult.Equals(off), ShouldEqual, true) - So(andresult.GetCardinality(), ShouldEqual, 0) - - for i := 500000; i < 600000; i += 14 { - rb.AddInt(i) - } - for i := 200000; i < 400000; i += 3 { - rb2.AddInt(i) - } - andresult2 := And(rb, rb2) - So(andresult.GetCardinality(), ShouldEqual, 0) - So(andresult2.GetCardinality(), ShouldEqual, 0) - - for i := 0; i < 200000; i += 4 { - rb.AddInt(i) - } - for i := 200000; i < 400000; i += 14 { - rb.AddInt(i) - } - So(andresult.GetCardinality(), ShouldEqual, 0) - rc := And(rb, rb2) - rb.And(rb2) - So(rc.GetCardinality(), ShouldEqual, rb.GetCardinality()) - - }) - - Convey("ArrayContainerCardinalityTest", t, func() { - ac := newArrayContainer() - for k := uint16(0); k < 100; k++ { - ac.iadd(k) - So(ac.getCardinality(), ShouldEqual, k+1) - } - for k := uint16(0); k < 100; k++ { - ac.iadd(k) - So(ac.getCardinality(), ShouldEqual, 100) - } - }) - - Convey("or test", t, func() { - rr := NewBitmap() - for k := 0; k < 4000; k++ { - rr.AddInt(k) - } - rr2 := NewBitmap() - for k := 4000; k < 8000; k++ { - rr2.AddInt(k) - } - result := Or(rr, rr2) - So(result.GetCardinality(), ShouldEqual, rr.GetCardinality()+rr2.GetCardinality()) - }) - Convey("basic test", t, func() { - rr := NewBitmap() - var a [4002]uint32 - pos := 0 - for k := 0; k < 4000; k++ { - rr.AddInt(k) - a[pos] = uint32(k) - pos++ - } - rr.AddInt(100000) - a[pos] = 100000 - pos++ - rr.AddInt(110000) - a[pos] = 110000 - pos++ - array := rr.ToArray() - ok := true - for i := range a { - if array[i] != a[i] { - log.Println("rr : ", array[i], " a : ", a[i]) - ok = false - } - } - So(len(array), ShouldEqual, len(a)) - So(ok, ShouldEqual, true) - }) - - Convey("BitmapContainerCardinalityTest", t, func() { - ac := newBitmapContainer() - for k := uint16(0); k < 100; k++ { - ac.iadd(k) - So(ac.getCardinality(), ShouldEqual, k+1) - } - for k := uint16(0); k < 100; k++ { - ac.iadd(k) - So(ac.getCardinality(), ShouldEqual, 100) - } - }) - - Convey("BitmapContainerTest", t, func() { - rr := newBitmapContainer() - rr.iadd(uint16(110)) - rr.iadd(uint16(114)) - rr.iadd(uint16(115)) - var array [3]uint16 - pos := 0 - for itr := rr.getShortIterator(); itr.hasNext(); { - array[pos] = itr.next() - pos++ - } - - So(array[0], ShouldEqual, uint16(110)) - So(array[1], ShouldEqual, uint16(114)) - So(array[2], ShouldEqual, uint16(115)) - }) - Convey("cardinality test", t, func() { - N := 1024 - for gap := 7; gap < 100000; gap *= 10 { - for offset := 2; offset <= 1024; offset *= 2 { - rb := NewBitmap() - for k := 0; k < N; k++ { - rb.AddInt(k * gap) - So(rb.GetCardinality(), ShouldEqual, k+1) - } - So(rb.GetCardinality(), ShouldEqual, N) - // check the add of existing values - for k := 0; k < N; k++ { - rb.AddInt(k * gap) - So(rb.GetCardinality(), ShouldEqual, N) - } - - rb2 := NewBitmap() - - for k := 0; k < N; k++ { - rb2.AddInt(k * gap * offset) - So(rb2.GetCardinality(), ShouldEqual, k+1) - } - - So(rb2.GetCardinality(), ShouldEqual, N) - - for k := 0; k < N; k++ { - rb2.AddInt(k * gap * offset) - So(rb2.GetCardinality(), ShouldEqual, N) - } - So(And(rb, rb2).GetCardinality(), ShouldEqual, N/offset) - So(Xor(rb, rb2).GetCardinality(), ShouldEqual, 2*N-2*N/offset) - So(Or(rb, rb2).GetCardinality(), ShouldEqual, 2*N-N/offset) - } - } - }) - - Convey("clear test", t, func() { - rb := NewBitmap() - for i := 0; i < 200000; i += 7 { - // dense - rb.AddInt(i) - } - for i := 200000; i < 400000; i += 177 { - // sparse - rb.AddInt(i) - } - - rb2 := NewBitmap() - rb3 := NewBitmap() - for i := 0; i < 200000; i += 4 { - rb2.AddInt(i) - } - for i := 200000; i < 400000; i += 14 { - rb2.AddInt(i) - } - - rb.Clear() - So(rb.GetCardinality(), ShouldEqual, 0) - So(rb2.GetCardinality(), ShouldNotEqual, 0) - - rb.AddInt(4) - rb3.AddInt(4) - andresult := And(rb, rb2) - orresult := Or(rb, rb2) - - So(andresult.GetCardinality(), ShouldEqual, 1) - So(orresult.GetCardinality(), ShouldEqual, rb2.GetCardinality()) - - for i := 0; i < 200000; i += 4 { - rb.AddInt(i) - rb3.AddInt(i) - } - for i := 200000; i < 400000; i += 114 { - rb.AddInt(i) - rb3.AddInt(i) - } - - arrayrr := rb.ToArray() - arrayrr3 := rb3.ToArray() - ok := true - for i := range arrayrr { - if arrayrr[i] != arrayrr3[i] { - ok = false - } - } - So(len(arrayrr), ShouldEqual, len(arrayrr3)) - So(ok, ShouldEqual, true) - }) - - Convey("constainer factory ", t, func() { - - bc1 := newBitmapContainer() - bc2 := newBitmapContainer() - bc3 := newBitmapContainer() - ac1 := newArrayContainer() - ac2 := newArrayContainer() - ac3 := newArrayContainer() - - for i := 0; i < 5000; i++ { - bc1.iadd(uint16(i * 70)) - } - for i := 0; i < 5000; i++ { - bc2.iadd(uint16(i * 70)) - } - for i := 0; i < 5000; i++ { - bc3.iadd(uint16(i * 70)) - } - for i := 0; i < 4000; i++ { - ac1.iadd(uint16(i * 50)) - } - for i := 0; i < 4000; i++ { - ac2.iadd(uint16(i * 50)) - } - for i := 0; i < 4000; i++ { - ac3.iadd(uint16(i * 50)) - } - - rbc := ac1.clone().(*arrayContainer).toBitmapContainer() - So(validate(rbc, ac1), ShouldEqual, true) - rbc = ac2.clone().(*arrayContainer).toBitmapContainer() - So(validate(rbc, ac2), ShouldEqual, true) - rbc = ac3.clone().(*arrayContainer).toBitmapContainer() - So(validate(rbc, ac3), ShouldEqual, true) - }) - Convey("flipTest1 ", t, func() { - rb := NewBitmap() - rb.Flip(100000, 200000) // in-place on empty bitmap - rbcard := rb.GetCardinality() - So(100000, ShouldEqual, rbcard) - - bs := bitset.New(20000 - 10000) - for i := uint(100000); i < 200000; i++ { - bs.Set(i) - } - So(equalsBitSet(bs, rb), ShouldEqual, true) - }) - - Convey("flipTest1A", t, func() { - rb := NewBitmap() - rb1 := Flip(rb, 100000, 200000) - rbcard := rb1.GetCardinality() - So(100000, ShouldEqual, rbcard) - So(0, ShouldEqual, rb.GetCardinality()) - - bs := bitset.New(0) - So(equalsBitSet(bs, rb), ShouldEqual, true) - - for i := uint(100000); i < 200000; i++ { - bs.Set(i) - } - So(equalsBitSet(bs, rb1), ShouldEqual, true) - }) - Convey("flipTest2", t, func() { - rb := NewBitmap() - rb.Flip(100000, 100000) - rbcard := rb.GetCardinality() - So(0, ShouldEqual, rbcard) - - bs := bitset.New(0) - So(equalsBitSet(bs, rb), ShouldEqual, true) - }) - - Convey("flipTest2A", t, func() { - rb := NewBitmap() - rb1 := Flip(rb, 100000, 100000) - - rb.AddInt(1) - rbcard := rb1.GetCardinality() - - So(0, ShouldEqual, rbcard) - So(1, ShouldEqual, rb.GetCardinality()) - - bs := bitset.New(0) - So(equalsBitSet(bs, rb1), ShouldEqual, true) - bs.Set(1) - So(equalsBitSet(bs, rb), ShouldEqual, true) - }) - - Convey("flipTest3A", t, func() { - rb := NewBitmap() - rb.Flip(100000, 200000) // got 100k-199999 - rb.Flip(100000, 199991) // give back 100k-199990 - rbcard := rb.GetCardinality() - So(9, ShouldEqual, rbcard) - - bs := bitset.New(0) - for i := uint(199991); i < 200000; i++ { - bs.Set(i) - } - - So(equalsBitSet(bs, rb), ShouldEqual, true) - }) - - Convey("flipTest4A", t, func() { - // fits evenly on both ends - rb := NewBitmap() - rb.Flip(100000, 200000) // got 100k-199999 - rb.Flip(65536, 4*65536) - rbcard := rb.GetCardinality() - - // 65536 to 99999 are 1s - // 200000 to 262143 are 1s: total card - - So(96608, ShouldEqual, rbcard) - - bs := bitset.New(0) - for i := uint(65536); i < 100000; i++ { - bs.Set(i) - } - for i := uint(200000); i < 262144; i++ { - bs.Set(i) - } - - So(equalsBitSet(bs, rb), ShouldEqual, true) - }) - - Convey("flipTest5", t, func() { - // fits evenly on small end, multiple - // containers - rb := NewBitmap() - rb.Flip(100000, 132000) - rb.Flip(65536, 120000) - rbcard := rb.GetCardinality() - - // 65536 to 99999 are 1s - // 120000 to 131999 - - So(46464, ShouldEqual, rbcard) - - bs := bitset.New(0) - for i := uint(65536); i < 100000; i++ { - bs.Set(i) - } - for i := uint(120000); i < 132000; i++ { - bs.Set(i) - } - So(equalsBitSet(bs, rb), ShouldEqual, true) - }) - - Convey("flipTest6", t, func() { - rb := NewBitmap() - rb1 := Flip(rb, 100000, 132000) - rb2 := Flip(rb1, 65536, 120000) - //rbcard := rb2.GetCardinality() - - bs := bitset.New(0) - for i := uint(65536); i < 100000; i++ { - bs.Set(i) - } - for i := uint(120000); i < 132000; i++ { - bs.Set(i) - } - So(equalsBitSet(bs, rb2), ShouldEqual, true) - }) - - Convey("flipTest6A", t, func() { - rb := NewBitmap() - rb1 := Flip(rb, 100000, 132000) - rb2 := Flip(rb1, 99000, 2*65536) - rbcard := rb2.GetCardinality() - - So(1928, ShouldEqual, rbcard) - - bs := bitset.New(0) - for i := uint(99000); i < 100000; i++ { - bs.Set(i) - } - for i := uint(2 * 65536); i < 132000; i++ { - bs.Set(i) - } - So(equalsBitSet(bs, rb2), ShouldEqual, true) - }) - - Convey("flipTest7", t, func() { - // within 1 word, first container - rb := NewBitmap() - rb.Flip(650, 132000) - rb.Flip(648, 651) - rbcard := rb.GetCardinality() - - // 648, 649, 651-131999 - - So(132000-651+2, ShouldEqual, rbcard) - bs := bitset.New(0) - bs.Set(648) - bs.Set(649) - for i := uint(651); i < 132000; i++ { - bs.Set(i) - } - So(equalsBitSet(bs, rb), ShouldEqual, true) - }) - Convey("flipTestBig", t, func() { - numCases := 1000 - rb := NewBitmap() - bs := bitset.New(0) - //Random r = new Random(3333); - checkTime := 2.0 - - for i := 0; i < numCases; i++ { - start := rand.Intn(65536 * 20) - end := rand.Intn(65536 * 20) - if rand.Float64() < float64(0.1) { - end = start + rand.Intn(100) - } - rb.Flip(uint64(start), uint64(end)) - if start < end { - FlipRange(start, end, bs) // throws exception - } - // otherwise - // insert some more ANDs to keep things sparser - if rand.Float64() < 0.2 { - mask := NewBitmap() - mask1 := bitset.New(0) - startM := rand.Intn(65536 * 20) - endM := startM + 100000 - mask.Flip(uint64(startM), uint64(endM)) - FlipRange(startM, endM, mask1) - mask.Flip(0, 65536*20+100000) - FlipRange(0, 65536*20+100000, mask1) - rb.And(mask) - bs.InPlaceIntersection(mask1) - } - // see if we can detect incorrectly shared containers - if rand.Float64() < 0.1 { - irrelevant := Flip(rb, 10, 100000) - irrelevant.Flip(5, 200000) - irrelevant.Flip(190000, 260000) - } - if float64(i) > checkTime { - So(equalsBitSet(bs, rb), ShouldEqual, true) - checkTime *= 1.5 - } - } - }) - - Convey("ortest", t, func() { - rr := NewBitmap() - for k := 0; k < 4000; k++ { - rr.AddInt(k) - } - rr.AddInt(100000) - rr.AddInt(110000) - rr2 := NewBitmap() - for k := 0; k < 4000; k++ { - rr2.AddInt(k) - } - - rror := Or(rr, rr2) - - array := rror.ToArray() - - rr.Or(rr2) - arrayirr := rr.ToArray() - So(IntsEquals(array, arrayirr), ShouldEqual, true) - }) - - Convey("ORtest", t, func() { - rr := NewBitmap() - for k := 4000; k < 4256; k++ { - rr.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr.AddInt(k) - } - for k := 3 * 65536; k < 3*65536+9000; k++ { - rr.AddInt(k) - } - for k := 4 * 65535; k < 4*65535+7000; k++ { - rr.AddInt(k) - } - for k := 6 * 65535; k < 6*65535+10000; k++ { - rr.AddInt(k) - } - for k := 8 * 65535; k < 8*65535+1000; k++ { - rr.AddInt(k) - } - for k := 9 * 65535; k < 9*65535+30000; k++ { - rr.AddInt(k) - } - - rr2 := NewBitmap() - for k := 4000; k < 4256; k++ { - rr2.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr2.AddInt(k) - } - for k := 3*65536 + 2000; k < 3*65536+6000; k++ { - rr2.AddInt(k) - } - for k := 6 * 65535; k < 6*65535+1000; k++ { - rr2.AddInt(k) - } - for k := 7 * 65535; k < 7*65535+1000; k++ { - rr2.AddInt(k) - } - for k := 10 * 65535; k < 10*65535+5000; k++ { - rr2.AddInt(k) - } - correct := Or(rr, rr2) - rr.Or(rr2) - So(correct.Equals(rr), ShouldEqual, true) - }) - - Convey("ortest2", t, func() { - arrayrr := make([]uint32, 4000+4000+2) - pos := 0 - rr := NewBitmap() - for k := 0; k < 4000; k++ { - rr.AddInt(k) - arrayrr[pos] = uint32(k) - pos++ - } - rr.AddInt(100000) - rr.AddInt(110000) - rr2 := NewBitmap() - for k := 4000; k < 8000; k++ { - rr2.AddInt(k) - arrayrr[pos] = uint32(k) - pos++ - } - - arrayrr[pos] = 100000 - pos++ - arrayrr[pos] = 110000 - pos++ - - rror := Or(rr, rr2) - - arrayor := rror.ToArray() - - So(IntsEquals(arrayor, arrayrr), ShouldEqual, true) - }) - - Convey("ortest3", t, func() { - V1 := make(map[int]bool) - V2 := make(map[int]bool) - - rr := NewBitmap() - rr2 := NewBitmap() - for k := 0; k < 4000; k++ { - rr2.AddInt(k) - V1[k] = true - } - for k := 3500; k < 4500; k++ { - rr.AddInt(k) - V1[k] = true - } - for k := 4000; k < 65000; k++ { - rr2.AddInt(k) - V1[k] = true - } - - // In the second node of each roaring bitmap, we have two bitmap - // containers. - // So, we will check the union between two BitmapContainers - for k := 65536; k < 65536+10000; k++ { - rr.AddInt(k) - V1[k] = true - } - - for k := 65536; k < 65536+14000; k++ { - rr2.AddInt(k) - V1[k] = true - } - - // In the 3rd node of each Roaring Bitmap, we have an - // ArrayContainer, so, we will try the union between two - // ArrayContainers. - for k := 4 * 65535; k < 4*65535+1000; k++ { - rr.AddInt(k) - V1[k] = true - } - - for k := 4 * 65535; k < 4*65535+800; k++ { - rr2.AddInt(k) - V1[k] = true - } - - // For the rest, we will check if the union will take them in - // the result - for k := 6 * 65535; k < 6*65535+1000; k++ { - rr.AddInt(k) - V1[k] = true - } - - for k := 7 * 65535; k < 7*65535+2000; k++ { - rr2.AddInt(k) - V1[k] = true - } - - rror := Or(rr, rr2) - valide := true - - for _, k := range rror.ToArray() { - _, found := V1[int(k)] - if !found { - valide = false - } - V2[int(k)] = true - } - - for k := range V1 { - _, found := V2[k] - if !found { - valide = false - } - } - - So(valide, ShouldEqual, true) - }) - - Convey("ortest4", t, func() { - rb := NewBitmap() - rb2 := NewBitmap() - - for i := 0; i < 200000; i += 4 { - rb2.AddInt(i) - } - for i := 200000; i < 400000; i += 14 { - rb2.AddInt(i) - } - rb2card := rb2.GetCardinality() - - // check or against an empty bitmap - orresult := Or(rb, rb2) - off := Or(rb2, rb) - So(orresult.Equals(off), ShouldEqual, true) - - So(rb2card, ShouldEqual, orresult.GetCardinality()) - - for i := 500000; i < 600000; i += 14 { - rb.AddInt(i) - } - for i := 200000; i < 400000; i += 3 { - rb2.AddInt(i) - } - // check or against an empty bitmap - orresult2 := Or(rb, rb2) - So(rb2card, ShouldEqual, orresult.GetCardinality()) - So(rb2.GetCardinality()+rb.GetCardinality(), ShouldEqual, - orresult2.GetCardinality()) - rb.Or(rb2) - So(rb.Equals(orresult2), ShouldEqual, true) - - }) - - Convey("randomTest", t, func() { - rTest(15) - rTest(1024) - rTest(4096) - rTest(65536) - rTest(65536 * 16) - }) - - Convey("SimpleCardinality", t, func() { - N := 512 - gap := 70 - - rb := NewBitmap() - for k := 0; k < N; k++ { - rb.AddInt(k * gap) - So(rb.GetCardinality(), ShouldEqual, k+1) - } - So(rb.GetCardinality(), ShouldEqual, N) - for k := 0; k < N; k++ { - rb.AddInt(k * gap) - So(rb.GetCardinality(), ShouldEqual, N) - } - - }) - - Convey("XORtest", t, func() { - rr := NewBitmap() - for k := 4000; k < 4256; k++ { - rr.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr.AddInt(k) - } - for k := 3 * 65536; k < 3*65536+9000; k++ { - rr.AddInt(k) - } - for k := 4 * 65535; k < 4*65535+7000; k++ { - rr.AddInt(k) - } - for k := 6 * 65535; k < 6*65535+10000; k++ { - rr.AddInt(k) - } - for k := 8 * 65535; k < 8*65535+1000; k++ { - rr.AddInt(k) - } - for k := 9 * 65535; k < 9*65535+30000; k++ { - rr.AddInt(k) - } - - rr2 := NewBitmap() - for k := 4000; k < 4256; k++ { - rr2.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr2.AddInt(k) - } - for k := 3*65536 + 2000; k < 3*65536+6000; k++ { - rr2.AddInt(k) - } - for k := 6 * 65535; k < 6*65535+1000; k++ { - rr2.AddInt(k) - } - for k := 7 * 65535; k < 7*65535+1000; k++ { - rr2.AddInt(k) - } - for k := 10 * 65535; k < 10*65535+5000; k++ { - rr2.AddInt(k) - } - correct := Xor(rr, rr2) - rr.Xor(rr2) - So(correct.Equals(rr), ShouldEqual, true) - }) - - Convey("xortest1", t, func() { - V1 := make(map[int]bool) - V2 := make(map[int]bool) - - rr := NewBitmap() - rr2 := NewBitmap() - // For the first 65536: rr2 has a bitmap container, and rr has - // an array container. - // We will check the union between a BitmapCintainer and an - // arrayContainer - for k := 0; k < 4000; k++ { - rr2.AddInt(k) - if k < 3500 { - V1[k] = true - } - } - for k := 3500; k < 4500; k++ { - rr.AddInt(k) - } - for k := 4000; k < 65000; k++ { - rr2.AddInt(k) - if k >= 4500 { - V1[k] = true - } - } - - for k := 65536; k < 65536+30000; k++ { - rr.AddInt(k) - } - - for k := 65536; k < 65536+50000; k++ { - rr2.AddInt(k) - if k >= 65536+30000 { - V1[k] = true - } - } - - // In the 3rd node of each Roaring Bitmap, we have an - // ArrayContainer. So, we will try the union between two - // ArrayContainers. - for k := 4 * 65535; k < 4*65535+1000; k++ { - rr.AddInt(k) - if k >= (4*65535 + 800) { - V1[k] = true - } - } - - for k := 4 * 65535; k < 4*65535+800; k++ { - rr2.AddInt(k) - } - - for k := 6 * 65535; k < 6*65535+1000; k++ { - rr.AddInt(k) - V1[k] = true - } - - for k := 7 * 65535; k < 7*65535+2000; k++ { - rr2.AddInt(k) - V1[k] = true - } - - rrxor := Xor(rr, rr2) - valide := true - - for _, i := range rrxor.ToArray() { - _, found := V1[int(i)] - if !found { - valide = false - } - V2[int(i)] = true - } - for k := range V1 { - _, found := V2[k] - if !found { - valide = false - } - } - - So(valide, ShouldEqual, true) - }) -} -func TestXORtest4(t *testing.T) { - Convey("XORtest 4", t, func() { - rb := NewBitmap() - rb2 := NewBitmap() - counter := 0 - - for i := 0; i < 200000; i += 4 { - rb2.AddInt(i) - counter++ - } - So(rb2.GetCardinality(), ShouldEqual, counter) - for i := 200000; i < 400000; i += 14 { - rb2.AddInt(i) - counter++ - } - So(rb2.GetCardinality(), ShouldEqual, counter) - rb2card := rb2.GetCardinality() - So(rb2card, ShouldEqual, counter) - - // check or against an empty bitmap - xorresult := Xor(rb, rb2) - So(xorresult.GetCardinality(), ShouldEqual, counter) - off := Or(rb2, rb) - So(off.GetCardinality(), ShouldEqual, counter) - So(xorresult.Equals(off), ShouldEqual, true) - - So(rb2card, ShouldEqual, xorresult.GetCardinality()) - for i := 500000; i < 600000; i += 14 { - rb.AddInt(i) - } - for i := 200000; i < 400000; i += 3 { - rb2.AddInt(i) - } - // check or against an empty bitmap - xorresult2 := Xor(rb, rb2) - So(rb2card, ShouldEqual, xorresult.GetCardinality()) - - So(rb2.GetCardinality()+rb.GetCardinality(), ShouldEqual, xorresult2.GetCardinality()) - - rb.Xor(rb2) - So(xorresult2.Equals(rb), ShouldEqual, true) - - }) - //need to add the massives -} - -func TestBigRandom(t *testing.T) { - Convey("randomTest", t, func() { - rTest(15) - rTest(100) - rTest(512) - rTest(1023) - rTest(1025) - rTest(4095) - rTest(4096) - rTest(4097) - rTest(65536) - rTest(65536 * 16) - }) -} - -func rTest(N int) { - log.Println("rtest N=", N) - for gap := 1; gap <= 65536; gap *= 2 { - bs1 := bitset.New(0) - rb1 := NewBitmap() - for x := 0; x <= N; x += gap { - bs1.Set(uint(x)) - rb1.AddInt(x) - } - So(bs1.Count(), ShouldEqual, rb1.GetCardinality()) - So(equalsBitSet(bs1, rb1), ShouldEqual, true) - for offset := 1; offset <= gap; offset *= 2 { - bs2 := bitset.New(0) - rb2 := NewBitmap() - for x := 0; x <= N; x += gap { - bs2.Set(uint(x + offset)) - rb2.AddInt(x + offset) - } - So(bs2.Count(), ShouldEqual, rb2.GetCardinality()) - So(equalsBitSet(bs2, rb2), ShouldEqual, true) - - clonebs1 := bs1.Clone() - clonebs1.InPlaceIntersection(bs2) - if !equalsBitSet(clonebs1, And(rb1, rb2)) { - t := rb1.Clone() - t.And(rb2) - So(equalsBitSet(clonebs1, t), ShouldEqual, true) - } - - // testing OR - clonebs1 = bs1.Clone() - clonebs1.InPlaceUnion(bs2) - - So(equalsBitSet(clonebs1, Or(rb1, rb2)), ShouldEqual, true) - // testing XOR - clonebs1 = bs1.Clone() - clonebs1.InPlaceSymmetricDifference(bs2) - So(equalsBitSet(clonebs1, Xor(rb1, rb2)), ShouldEqual, true) - - //testing NOTAND - clonebs1 = bs1.Clone() - clonebs1.InPlaceDifference(bs2) - So(equalsBitSet(clonebs1, AndNot(rb1, rb2)), ShouldEqual, true) - } - } -} - -func equalsBitSet(a *bitset.BitSet, b *Bitmap) bool { - for i, e := a.NextSet(0); e; i, e = a.NextSet(i + 1) { - if !b.ContainsInt(int(i)) { - return false - } - } - i := b.Iterator() - for i.HasNext() { - if !a.Test(uint(i.Next())) { - return false - } - } - return true -} - -func equalsArray(a []int, b *Bitmap) bool { - if uint64(len(a)) != b.GetCardinality() { - return false - } - for _, x := range a { - if !b.ContainsInt(x) { - return false - } - } - return true -} - -func IntsEquals(a, b []uint32) bool { - if len(a) != len(b) { - return false - } - for i, v := range a { - if v != b[i] { - return false - } - } - return true -} - -func validate(bc *bitmapContainer, ac *arrayContainer) bool { - // Checking the cardinalities of each container - - if bc.getCardinality() != ac.getCardinality() { - log.Println("cardinality differs") - return false - } - // Checking that the two containers contain the same values - counter := 0 - - for i := bc.NextSetBit(0); i >= 0; i = bc.NextSetBit(i + 1) { - counter++ - if !ac.contains(uint16(i)) { - log.Println("content differs") - log.Println(bc) - log.Println(ac) - return false - } - - } - - // checking the cardinality of the BitmapContainer - return counter == bc.getCardinality() -} - -func TestRoaringArray(t *testing.T) { - - a := newRoaringArray() - Convey("Test Init", t, func() { - So(a.size(), ShouldEqual, 0) - }) - - Convey("Test Insert", t, func() { - a.appendContainer(0, newArrayContainer(), false) - - So(a.size(), ShouldEqual, 1) - }) - - Convey("Test Remove", t, func() { - a.remove(0) - So(a.size(), ShouldEqual, 0) - }) - - Convey("Test popcount Full", t, func() { - res := popcount(uint64(0xffffffffffffffff)) - So(res, ShouldEqual, 64) - }) - - Convey("Test popcount Empty", t, func() { - res := popcount(0) - So(res, ShouldEqual, 0) - }) - - Convey("Test popcount 16", t, func() { - res := popcount(0xff00ff) - So(res, ShouldEqual, 16) - }) - - Convey("Test ArrayContainer Add", t, func() { - ar := newArrayContainer() - ar.iadd(1) - So(ar.getCardinality(), ShouldEqual, 1) - }) - - Convey("Test ArrayContainer Add wacky", t, func() { - ar := newArrayContainer() - ar.iadd(0) - ar.iadd(5000) - So(ar.getCardinality(), ShouldEqual, 2) - }) - - Convey("Test ArrayContainer Add Reverse", t, func() { - ar := newArrayContainer() - ar.iadd(5000) - ar.iadd(2048) - ar.iadd(0) - So(ar.getCardinality(), ShouldEqual, 3) - }) - - Convey("Test BitmapContainer Add ", t, func() { - bm := newBitmapContainer() - bm.iadd(0) - So(bm.getCardinality(), ShouldEqual, 1) - }) - -} - -func TestFlipBigA(t *testing.T) { - Convey("flipTestBigA ", t, func() { - numCases := 1000 - bs := bitset.New(0) - checkTime := 2.0 - rb1 := NewBitmap() - rb2 := NewBitmap() - - for i := 0; i < numCases; i++ { - start := rand.Intn(65536 * 20) - end := rand.Intn(65536 * 20) - if rand.Float64() < 0.1 { - end = start + rand.Intn(100) - } - - if (i & 1) == 0 { - rb2 = FlipInt(rb1, start, end) - // tweak the other, catch bad sharing - rb1.FlipInt(rand.Intn(65536*20), rand.Intn(65536*20)) - } else { - rb1 = FlipInt(rb2, start, end) - rb2.FlipInt(rand.Intn(65536*20), rand.Intn(65536*20)) - } - - if start < end { - FlipRange(start, end, bs) // throws exception - } - // otherwise - // insert some more ANDs to keep things sparser - if (rand.Float64() < 0.2) && (i&1) == 0 { - mask := NewBitmap() - mask1 := bitset.New(0) - startM := rand.Intn(65536 * 20) - endM := startM + 100000 - mask.FlipInt(startM, endM) - FlipRange(startM, endM, mask1) - mask.FlipInt(0, 65536*20+100000) - FlipRange(0, 65536*20+100000, mask1) - rb2.And(mask) - bs.InPlaceIntersection(mask1) - } - - if float64(i) > checkTime { - var rb *Bitmap - - if (i & 1) == 0 { - rb = rb2 - } else { - rb = rb1 - } - So(equalsBitSet(bs, rb), ShouldEqual, true) - checkTime *= 1.5 - } - } - }) -} - -func TestDoubleAdd(t *testing.T) { - Convey("doubleadd ", t, func() { - rb := NewBitmap() - rb.AddRange(65533, 65536) - rb.AddRange(65530, 65536) - rb2 := NewBitmap() - rb2.AddRange(65530, 65536) - So(rb.Equals(rb2), ShouldEqual, true) - rb2.RemoveRange(65530, 65536) - So(rb2.GetCardinality(), ShouldEqual, 0) - }) -} - -func TestDoubleAdd2(t *testing.T) { - Convey("doubleadd2 ", t, func() { - rb := NewBitmap() - rb.AddRange(65533, 65536*20) - rb.AddRange(65530, 65536*20) - rb2 := NewBitmap() - rb2.AddRange(65530, 65536*20) - So(rb.Equals(rb2), ShouldEqual, true) - rb2.RemoveRange(65530, 65536*20) - So(rb2.GetCardinality(), ShouldEqual, 0) - }) -} - -func TestDoubleAdd3(t *testing.T) { - Convey("doubleadd3 ", t, func() { - rb := NewBitmap() - rb.AddRange(65533, 65536*20+10) - rb.AddRange(65530, 65536*20+10) - rb2 := NewBitmap() - rb2.AddRange(65530, 65536*20+10) - So(rb.Equals(rb2), ShouldEqual, true) - rb2.RemoveRange(65530, 65536*20+1) - So(rb2.GetCardinality(), ShouldEqual, 9) - }) -} - -func TestDoubleAdd4(t *testing.T) { - Convey("doubleadd4 ", t, func() { - rb := NewBitmap() - rb.AddRange(65533, 65536*20) - rb.RemoveRange(65533+5, 65536*20) - So(rb.GetCardinality(), ShouldEqual, 5) - }) -} - -func TestDoubleAdd5(t *testing.T) { - Convey("doubleadd5 ", t, func() { - rb := NewBitmap() - rb.AddRange(65533, 65536*20) - rb.RemoveRange(65533+5, 65536*20-5) - So(rb.GetCardinality(), ShouldEqual, 10) - }) -} - -func TestDoubleAdd6(t *testing.T) { - Convey("doubleadd6 ", t, func() { - rb := NewBitmap() - rb.AddRange(65533, 65536*20-5) - rb.RemoveRange(65533+5, 65536*20-10) - So(rb.GetCardinality(), ShouldEqual, 10) - }) -} - -func TestDoubleAdd7(t *testing.T) { - Convey("doubleadd7 ", t, func() { - rb := NewBitmap() - rb.AddRange(65533, 65536*20+1) - rb.RemoveRange(65533+1, 65536*20) - So(rb.GetCardinality(), ShouldEqual, 2) - }) -} - -func TestDoubleAndNotBug01(t *testing.T) { - Convey("AndNotBug01 ", t, func() { - rb1 := NewBitmap() - rb1.AddRange(0, 60000) - rb2 := NewBitmap() - rb2.AddRange(60000-10, 60000+10) - rb2.AndNot(rb1) - rb3 := NewBitmap() - rb3.AddRange(60000, 60000+10) - - So(rb2.Equals(rb3), ShouldBeTrue) - }) -} - -func TestAndNot(t *testing.T) { - - Convey("Test ANDNOT", t, func() { - rr := NewBitmap() - for k := 4000; k < 4256; k++ { - rr.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr.AddInt(k) - } - for k := 3 * 65536; k < 3*65536+9000; k++ { - rr.AddInt(k) - } - for k := 4 * 65535; k < 4*65535+7000; k++ { - rr.AddInt(k) - } - for k := 6 * 65535; k < 6*65535+10000; k++ { - rr.AddInt(k) - } - for k := 8 * 65535; k < 8*65535+1000; k++ { - rr.AddInt(k) - } - for k := 9 * 65535; k < 9*65535+30000; k++ { - rr.AddInt(k) - } - - rr2 := NewBitmap() - for k := 4000; k < 4256; k++ { - rr2.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr2.AddInt(k) - } - for k := 3*65536 + 2000; k < 3*65536+6000; k++ { - rr2.AddInt(k) - } - for k := 6 * 65535; k < 6*65535+1000; k++ { - rr2.AddInt(k) - } - for k := 7 * 65535; k < 7*65535+1000; k++ { - rr2.AddInt(k) - } - for k := 10 * 65535; k < 10*65535+5000; k++ { - rr2.AddInt(k) - } - correct := AndNot(rr, rr2) - rr.AndNot(rr2) - - So(correct.Equals(rr), ShouldEqual, true) - }) -} - -func TestStats(t *testing.T) { - Convey("Test Stats with empty bitmap", t, func() { - expectedStats := Statistics{} - rr := NewBitmap() - So(rr.Stats(), ShouldResemble, expectedStats) - }) - Convey("Test Stats with bitmap Container", t, func() { - // Given a bitmap that should have a single bitmap container - expectedStats := Statistics{ - Cardinality: 60000, - Containers: 1, - - BitmapContainers: 1, - BitmapContainerValues: 60000, - BitmapContainerBytes: 8192, - - RunContainers: 0, - RunContainerBytes: 0, - RunContainerValues: 0, - } - rr := NewBitmap() - for i := uint32(0); i < 60000; i++ { - rr.Add(i) - } - So(rr.Stats(), ShouldResemble, expectedStats) - }) - - Convey("Test Stats with run Container", t, func() { - // Given that we should have a single run container - expectedStats := Statistics{ - Cardinality: 60000, - Containers: 1, - - BitmapContainers: 0, - BitmapContainerValues: 0, - BitmapContainerBytes: 0, - - RunContainers: 1, - RunContainerBytes: 52, - RunContainerValues: 60000, - } - rr := NewBitmap() - rr.AddRange(0, 60000) - So(rr.Stats(), ShouldResemble, expectedStats) - }) - Convey("Test Stats with Array Container", t, func() { - // Given a bitmap that should have a single array container - expectedStats := Statistics{ - Cardinality: 2, - Containers: 1, - - ArrayContainers: 1, - ArrayContainerValues: 2, - ArrayContainerBytes: 4, - } - rr := NewBitmap() - rr.Add(2) - rr.Add(4) - So(rr.Stats(), ShouldResemble, expectedStats) - }) -} - -func TestFlipVerySmall(t *testing.T) { - Convey("very small basic Flip test", t, func() { - rb := NewBitmap() - rb.Flip(0, 10) // got [0,9], card is 10 - rb.Flip(0, 1) // give back the number 0, card goes to 9 - rbcard := rb.GetCardinality() - So(rbcard, ShouldEqual, 9) - }) -} diff --git a/vendor/github.com/RoaringBitmap/roaring/roaringarray.go b/vendor/github.com/RoaringBitmap/roaring/roaringarray.go index 61244ee87..92e24f88c 100644 --- a/vendor/github.com/RoaringBitmap/roaring/roaringarray.go +++ b/vendor/github.com/RoaringBitmap/roaring/roaringarray.go @@ -735,11 +735,11 @@ func (ra *roaringArray) advanceUntil(min uint16, pos int) int { } // we know that the next-smallest span was too small - lower += (spansize / 2) + lower += (spansize >> 1) mid := 0 for lower+1 != upper { - mid = (lower + upper) / 2 + mid = (lower + upper) >> 1 if ra.keys[mid] == min { return mid } else if ra.keys[mid] < min { diff --git a/vendor/github.com/RoaringBitmap/roaring/roaringarray_gen_test.go b/vendor/github.com/RoaringBitmap/roaring/roaringarray_gen_test.go deleted file mode 100644 index befca2415..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/roaringarray_gen_test.go +++ /dev/null @@ -1,238 +0,0 @@ -package roaring - -// NOTE: THIS FILE WAS PRODUCED BY THE -// MSGP CODE GENERATION TOOL (github.com/tinylib/msgp) -// DO NOT EDIT - -import ( - "bytes" - "testing" - - "github.com/tinylib/msgp/msgp" -) - -func TestMarshalUnmarshalcontainerSerz(t *testing.T) { - v := containerSerz{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsgcontainerSerz(b *testing.B) { - v := containerSerz{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgcontainerSerz(b *testing.B) { - v := containerSerz{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshalcontainerSerz(b *testing.B) { - v := containerSerz{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecodecontainerSerz(t *testing.T) { - v := containerSerz{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Logf("WARNING: Msgsize() for %v is inaccurate", v) - } - - vn := containerSerz{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncodecontainerSerz(b *testing.B) { - v := containerSerz{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecodecontainerSerz(b *testing.B) { - v := containerSerz{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} - -func TestMarshalUnmarshalroaringArray(t *testing.T) { - v := roaringArray{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsgroaringArray(b *testing.B) { - v := roaringArray{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgroaringArray(b *testing.B) { - v := roaringArray{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshalroaringArray(b *testing.B) { - v := roaringArray{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecoderoaringArray(t *testing.T) { - v := roaringArray{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Logf("WARNING: Msgsize() for %v is inaccurate", v) - } - - vn := roaringArray{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncoderoaringArray(b *testing.B) { - v := roaringArray{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecoderoaringArray(b *testing.B) { - v := roaringArray{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} diff --git a/vendor/github.com/RoaringBitmap/roaring/roaringcow_test.go b/vendor/github.com/RoaringBitmap/roaring/roaringcow_test.go deleted file mode 100644 index 2e8fa623f..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/roaringcow_test.go +++ /dev/null @@ -1,1879 +0,0 @@ -package roaring - -import ( - . "github.com/smartystreets/goconvey/convey" - "github.com/willf/bitset" - "log" - "math/rand" - "strconv" - "testing" -) - -func TestCloneOfCOW(t *testing.T) { - rb1 := NewBitmap() - rb1.SetCopyOnWrite(true) - rb1.Add(10) - rb1.Add(12) - rb1.Remove(12) - - rb2 := rb1.Clone() - - rb3 := rb1.Clone() - - rb2.Remove(10) - - rb3.AddRange(100, 200) - if !rb2.IsEmpty() { - t.Errorf("rb2 should be empty") - } - if rb3.GetCardinality() != 100+1 { - t.Errorf("bad cardinality") - } - if !rb1.Contains(10) { - t.Errorf("bad rb1") - } - if rb1.GetCardinality() != 1 { - t.Errorf("bad cardinality") - } -} - -func TestRoaringBitmapBitmapOfCOW(t *testing.T) { - array := []uint32{5580, 33722, 44031, 57276, 83097} - bmp := BitmapOf(array...) - bmp.SetCopyOnWrite(true) - if len(array) != int(bmp.GetCardinality()) { - t.Errorf("length diff %d!=%d", len(array), bmp.GetCardinality()) - t.FailNow() - } -} - -func TestRoaringBitmapAddCOW(t *testing.T) { - array := []uint32{5580, 33722, 44031, 57276, 83097} - bmp := New() - bmp.SetCopyOnWrite(true) - for _, v := range array { - bmp.Add(v) - } - if len(array) != int(bmp.GetCardinality()) { - t.Errorf("length diff %d!=%d", len(array), bmp.GetCardinality()) - t.FailNow() - } -} - -func TestRoaringBitmapAddManyCOW(t *testing.T) { - array := []uint32{5580, 33722, 44031, 57276, 83097} - bmp := NewBitmap() - bmp.SetCopyOnWrite(true) - - bmp.AddMany(array) - if len(array) != int(bmp.GetCardinality()) { - t.Errorf("length diff %d!=%d", len(array), bmp.GetCardinality()) - t.FailNow() - } -} - -// https://github.com/RoaringBitmap/roaring/issues/64 -func TestFlip64COW(t *testing.T) { - bm := New() - bm.SetCopyOnWrite(true) - - bm.AddInt(0) - bm.Flip(1, 2) - i := bm.Iterator() - if i.Next() != 0 || i.Next() != 1 || i.HasNext() { - t.Error("expected {0,1}") - } -} - -// https://github.com/RoaringBitmap/roaring/issues/64 -func TestFlip64OffCOW(t *testing.T) { - bm := New() - bm.SetCopyOnWrite(true) - - bm.AddInt(10) - bm.Flip(11, 12) - i := bm.Iterator() - if i.Next() != 10 || i.Next() != 11 || i.HasNext() { - t.Error("expected {10,11}") - } -} - -func TestStringerCOW(t *testing.T) { - v := NewBitmap() - v.SetCopyOnWrite(true) - for i := uint32(0); i < 10; i++ { - v.Add(i) - } - if v.String() != "{0,1,2,3,4,5,6,7,8,9}" { - t.Error("bad string output") - } - v.RunOptimize() - if v.String() != "{0,1,2,3,4,5,6,7,8,9}" { - t.Error("bad string output") - } -} - -func TestFastCardCOW(t *testing.T) { - Convey("fast card", t, func() { - bm := NewBitmap() - bm.SetCopyOnWrite(true) - bm.Add(1) - bm.AddRange(21, 260000) - bm2 := NewBitmap() - bm2.SetCopyOnWrite(true) - bm2.Add(25) - So(bm2.AndCardinality(bm), ShouldEqual, 1) - So(bm2.OrCardinality(bm), ShouldEqual, bm.GetCardinality()) - So(bm.AndCardinality(bm2), ShouldEqual, 1) - So(bm.OrCardinality(bm2), ShouldEqual, bm.GetCardinality()) - So(bm2.AndCardinality(bm), ShouldEqual, 1) - So(bm2.OrCardinality(bm), ShouldEqual, bm.GetCardinality()) - bm.RunOptimize() - So(bm2.AndCardinality(bm), ShouldEqual, 1) - So(bm2.OrCardinality(bm), ShouldEqual, bm.GetCardinality()) - So(bm.AndCardinality(bm2), ShouldEqual, 1) - So(bm.OrCardinality(bm2), ShouldEqual, bm.GetCardinality()) - So(bm2.AndCardinality(bm), ShouldEqual, 1) - So(bm2.OrCardinality(bm), ShouldEqual, bm.GetCardinality()) - }) -} - -func TestIntersects1COW(t *testing.T) { - Convey("intersects", t, func() { - bm := NewBitmap() - bm.SetCopyOnWrite(true) - bm.Add(1) - bm.AddRange(21, 26) - bm2 := NewBitmap() - bm2.SetCopyOnWrite(true) - bm2.Add(25) - So(bm2.Intersects(bm), ShouldEqual, true) - bm.Remove(25) - So(bm2.Intersects(bm), ShouldEqual, false) - bm.AddRange(1, 100000) - So(bm2.Intersects(bm), ShouldEqual, true) - }) -} - -func TestRangePanicCOW(t *testing.T) { - Convey("TestRangePanic", t, func() { - bm := NewBitmap() - bm.SetCopyOnWrite(true) - bm.Add(1) - bm.AddRange(21, 26) - bm.AddRange(9, 14) - bm.AddRange(11, 16) - }) -} - -func TestRangeRemovalCOW(t *testing.T) { - Convey("TestRangeRemovalPanic", t, func() { - bm := NewBitmap() - bm.SetCopyOnWrite(true) - bm.Add(1) - bm.AddRange(21, 26) - bm.AddRange(9, 14) - bm.RemoveRange(11, 16) - bm.RemoveRange(1, 26) - c := bm.GetCardinality() - So(c, ShouldEqual, 0) - bm.AddRange(1, 10000) - c = bm.GetCardinality() - So(c, ShouldEqual, 10000-1) - bm.RemoveRange(1, 10000) - c = bm.GetCardinality() - So(c, ShouldEqual, 0) - }) -} - -func TestRangeRemovalFromContentCOW(t *testing.T) { - Convey("TestRangeRemovalPanic", t, func() { - bm := NewBitmap() - bm.SetCopyOnWrite(true) - for i := 100; i < 10000; i++ { - bm.AddInt(i * 3) - } - bm.AddRange(21, 26) - bm.AddRange(9, 14) - bm.RemoveRange(11, 16) - bm.RemoveRange(0, 30000) - c := bm.GetCardinality() - So(c, ShouldEqual, 00) - }) -} - -func TestFlipOnEmptyCOW(t *testing.T) { - - Convey("TestFlipOnEmpty in-place", t, func() { - bm := NewBitmap() - bm.SetCopyOnWrite(true) - bm.Flip(0, 10) - c := bm.GetCardinality() - So(c, ShouldEqual, 10) - }) - Convey("TestFlipOnEmpty, generating new result", t, func() { - bm := NewBitmap() - bm.SetCopyOnWrite(true) - bm = Flip(bm, 0, 10) - c := bm.GetCardinality() - So(c, ShouldEqual, 10) - }) -} - -func TestBitmapRankCOW(t *testing.T) { - for N := uint32(1); N <= 1048576; N *= 2 { - Convey("rank tests"+strconv.Itoa(int(N)), t, func() { - for gap := uint32(1); gap <= 65536; gap *= 2 { - rb1 := NewBitmap() - rb1.SetCopyOnWrite(true) - for x := uint32(0); x <= N; x += gap { - rb1.Add(x) - } - for y := uint32(0); y <= N; y++ { - if rb1.Rank(y) != uint64((y+1+gap-1)/gap) { - So(rb1.Rank(y), ShouldEqual, (y+1+gap-1)/gap) - } - } - } - }) - } -} - -func TestBitmapSelectCOW(t *testing.T) { - for N := uint32(1); N <= 1048576; N *= 2 { - Convey("rank tests"+strconv.Itoa(int(N)), t, func() { - for gap := uint32(1); gap <= 65536; gap *= 2 { - rb1 := NewBitmap() - rb1.SetCopyOnWrite(true) - for x := uint32(0); x <= N; x += gap { - rb1.Add(x) - } - for y := uint32(0); y <= N/gap; y++ { - expectedInt := y * gap - i, err := rb1.Select(y) - if err != nil { - t.Fatal(err) - } - - if i != expectedInt { - So(i, ShouldEqual, expectedInt) - } - } - } - }) - } -} - -// some extra tests -func TestBitmapExtraCOW(t *testing.T) { - for N := uint32(1); N <= 65536; N *= 2 { - Convey("extra tests"+strconv.Itoa(int(N)), t, func() { - for gap := uint32(1); gap <= 65536; gap *= 2 { - bs1 := bitset.New(0) - rb1 := NewBitmap() - rb1.SetCopyOnWrite(true) - rb1.SetCopyOnWrite(true) - - for x := uint32(0); x <= N; x += gap { - bs1.Set(uint(x)) - rb1.Add(x) - } - So(bs1.Count(), ShouldEqual, rb1.GetCardinality()) - So(equalsBitSet(bs1, rb1), ShouldEqual, true) - for offset := uint32(1); offset <= gap; offset *= 2 { - bs2 := bitset.New(0) - rb2 := NewBitmap() - rb2.SetCopyOnWrite(true) - - for x := uint32(0); x <= N; x += gap { - bs2.Set(uint(x + offset)) - rb2.Add(x + offset) - } - So(bs2.Count(), ShouldEqual, rb2.GetCardinality()) - So(equalsBitSet(bs2, rb2), ShouldEqual, true) - - clonebs1 := bs1.Clone() - clonebs1.InPlaceIntersection(bs2) - if !equalsBitSet(clonebs1, And(rb1, rb2)) { - t := rb1.Clone() - t.And(rb2) - So(equalsBitSet(clonebs1, t), ShouldEqual, true) - } - - // testing OR - clonebs1 = bs1.Clone() - clonebs1.InPlaceUnion(bs2) - - So(equalsBitSet(clonebs1, Or(rb1, rb2)), ShouldEqual, true) - // testing XOR - clonebs1 = bs1.Clone() - clonebs1.InPlaceSymmetricDifference(bs2) - So(equalsBitSet(clonebs1, Xor(rb1, rb2)), ShouldEqual, true) - - //testing NOTAND - clonebs1 = bs1.Clone() - clonebs1.InPlaceDifference(bs2) - So(equalsBitSet(clonebs1, AndNot(rb1, rb2)), ShouldEqual, true) - } - } - }) - } -} - -func TestBitmapCOW(t *testing.T) { - - Convey("Test Contains", t, func() { - rbm1 := NewBitmap() - rbm1.SetCopyOnWrite(true) - for k := 0; k < 1000; k++ { - rbm1.AddInt(17 * k) - } - for k := 0; k < 17*1000; k++ { - So(rbm1.ContainsInt(k), ShouldEqual, (k/17*17 == k)) - } - }) - - Convey("Test Clone", t, func() { - rb1 := NewBitmap() - rb1.SetCopyOnWrite(true) - rb1.Add(10) - - rb2 := rb1.Clone() - rb2.Remove(10) - - So(rb1.Contains(10), ShouldBeTrue) - }) - - Convey("Test ANDNOT4", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb2 := NewBitmap() - rb2.SetCopyOnWrite(true) - - for i := 0; i < 200000; i += 4 { - rb2.AddInt(i) - } - for i := 200000; i < 400000; i += 14 { - rb2.AddInt(i) - } - - off := AndNot(rb2, rb) - andNotresult := AndNot(rb, rb2) - - So(rb.Equals(andNotresult), ShouldEqual, true) - So(rb2.Equals(off), ShouldEqual, true) - rb2.AndNot(rb) - So(rb2.Equals(off), ShouldEqual, true) - - }) - - Convey("Test AND", t, func() { - rr := NewBitmap() - rr.SetCopyOnWrite(true) - for k := 0; k < 4000; k++ { - rr.AddInt(k) - } - rr.Add(100000) - rr.Add(110000) - rr2 := NewBitmap() - rr2.SetCopyOnWrite(true) - rr2.Add(13) - rrand := And(rr, rr2) - array := rrand.ToArray() - - So(len(array), ShouldEqual, 1) - So(array[0], ShouldEqual, 13) - rr.And(rr2) - array = rr.ToArray() - - So(len(array), ShouldEqual, 1) - So(array[0], ShouldEqual, 13) - }) - - Convey("Test AND 2", t, func() { - rr := NewBitmap() - rr.SetCopyOnWrite(true) - for k := 4000; k < 4256; k++ { - rr.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr.AddInt(k) - } - for k := 3 * 65536; k < 3*65536+9000; k++ { - rr.AddInt(k) - } - for k := 4 * 65535; k < 4*65535+7000; k++ { - rr.AddInt(k) - } - for k := 6 * 65535; k < 6*65535+10000; k++ { - rr.AddInt(k) - } - for k := 8 * 65535; k < 8*65535+1000; k++ { - rr.AddInt(k) - } - for k := 9 * 65535; k < 9*65535+30000; k++ { - rr.AddInt(k) - } - - rr2 := NewBitmap() - rr2.SetCopyOnWrite(true) - for k := 4000; k < 4256; k++ { - rr2.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr2.AddInt(k) - } - for k := 3*65536 + 2000; k < 3*65536+6000; k++ { - rr2.AddInt(k) - } - for k := 6 * 65535; k < 6*65535+1000; k++ { - rr2.AddInt(k) - } - for k := 7 * 65535; k < 7*65535+1000; k++ { - rr2.AddInt(k) - } - for k := 10 * 65535; k < 10*65535+5000; k++ { - rr2.AddInt(k) - } - correct := And(rr, rr2) - rr.And(rr2) - So(correct.Equals(rr), ShouldEqual, true) - }) - - Convey("Test AND 2", t, func() { - rr := NewBitmap() - rr.SetCopyOnWrite(true) - for k := 0; k < 4000; k++ { - rr.AddInt(k) - } - rr.AddInt(100000) - rr.AddInt(110000) - rr2 := NewBitmap() - rr2.SetCopyOnWrite(true) - rr2.AddInt(13) - - rrand := And(rr, rr2) - array := rrand.ToArray() - So(len(array), ShouldEqual, 1) - So(array[0], ShouldEqual, 13) - }) - Convey("Test AND 3a", t, func() { - rr := NewBitmap() - rr.SetCopyOnWrite(true) - rr2 := NewBitmap() - rr2.SetCopyOnWrite(true) - for k := 6 * 65536; k < 6*65536+10000; k++ { - rr.AddInt(k) - } - for k := 6 * 65536; k < 6*65536+1000; k++ { - rr2.AddInt(k) - } - result := And(rr, rr2) - So(result.GetCardinality(), ShouldEqual, 1000) - }) - Convey("Test AND 3", t, func() { - var arrayand [11256]uint32 - //393,216 - pos := 0 - rr := NewBitmap() - rr.SetCopyOnWrite(true) - for k := 4000; k < 4256; k++ { - rr.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr.AddInt(k) - } - for k := 3 * 65536; k < 3*65536+1000; k++ { - rr.AddInt(k) - } - for k := 3*65536 + 1000; k < 3*65536+7000; k++ { - rr.AddInt(k) - } - for k := 3*65536 + 7000; k < 3*65536+9000; k++ { - rr.AddInt(k) - } - for k := 4 * 65536; k < 4*65536+7000; k++ { - rr.AddInt(k) - } - for k := 8 * 65536; k < 8*65536+1000; k++ { - rr.AddInt(k) - } - for k := 9 * 65536; k < 9*65536+30000; k++ { - rr.AddInt(k) - } - - rr2 := NewBitmap() - rr2.SetCopyOnWrite(true) - for k := 4000; k < 4256; k++ { - rr2.AddInt(k) - arrayand[pos] = uint32(k) - pos++ - } - for k := 65536; k < 65536+4000; k++ { - rr2.AddInt(k) - arrayand[pos] = uint32(k) - pos++ - } - for k := 3*65536 + 1000; k < 3*65536+7000; k++ { - rr2.AddInt(k) - arrayand[pos] = uint32(k) - pos++ - } - for k := 6 * 65536; k < 6*65536+10000; k++ { - rr.AddInt(k) - } - for k := 6 * 65536; k < 6*65536+1000; k++ { - rr2.AddInt(k) - arrayand[pos] = uint32(k) - pos++ - } - - for k := 7 * 65536; k < 7*65536+1000; k++ { - rr2.AddInt(k) - } - for k := 10 * 65536; k < 10*65536+5000; k++ { - rr2.AddInt(k) - } - rrand := And(rr, rr2) - - arrayres := rrand.ToArray() - ok := true - for i := range arrayres { - if i < len(arrayand) { - if arrayres[i] != arrayand[i] { - log.Println(i, arrayres[i], arrayand[i]) - ok = false - } - } else { - log.Println('x', arrayres[i]) - ok = false - } - } - - So(len(arrayand), ShouldEqual, len(arrayres)) - So(ok, ShouldEqual, true) - - }) - - Convey("Test AND 4", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb2 := NewBitmap() - rb2.SetCopyOnWrite(true) - - for i := 0; i < 200000; i += 4 { - rb2.AddInt(i) - } - for i := 200000; i < 400000; i += 14 { - rb2.AddInt(i) - } - //TODO: Bitmap.And(bm,bm2) - andresult := And(rb, rb2) - off := And(rb2, rb) - So(andresult.Equals(off), ShouldEqual, true) - So(andresult.GetCardinality(), ShouldEqual, 0) - - for i := 500000; i < 600000; i += 14 { - rb.AddInt(i) - } - for i := 200000; i < 400000; i += 3 { - rb2.AddInt(i) - } - andresult2 := And(rb, rb2) - So(andresult.GetCardinality(), ShouldEqual, 0) - So(andresult2.GetCardinality(), ShouldEqual, 0) - - for i := 0; i < 200000; i += 4 { - rb.AddInt(i) - } - for i := 200000; i < 400000; i += 14 { - rb.AddInt(i) - } - So(andresult.GetCardinality(), ShouldEqual, 0) - rc := And(rb, rb2) - rb.And(rb2) - So(rc.GetCardinality(), ShouldEqual, rb.GetCardinality()) - - }) - - Convey("ArrayContainerCardinalityTest", t, func() { - ac := newArrayContainer() - for k := uint16(0); k < 100; k++ { - ac.iadd(k) - So(ac.getCardinality(), ShouldEqual, k+1) - } - for k := uint16(0); k < 100; k++ { - ac.iadd(k) - So(ac.getCardinality(), ShouldEqual, 100) - } - }) - - Convey("or test", t, func() { - rr := NewBitmap() - rr.SetCopyOnWrite(true) - for k := 0; k < 4000; k++ { - rr.AddInt(k) - } - rr2 := NewBitmap() - rr2.SetCopyOnWrite(true) - for k := 4000; k < 8000; k++ { - rr2.AddInt(k) - } - result := Or(rr, rr2) - So(result.GetCardinality(), ShouldEqual, rr.GetCardinality()+rr2.GetCardinality()) - }) - Convey("basic test", t, func() { - rr := NewBitmap() - rr.SetCopyOnWrite(true) - var a [4002]uint32 - pos := 0 - for k := 0; k < 4000; k++ { - rr.AddInt(k) - a[pos] = uint32(k) - pos++ - } - rr.AddInt(100000) - a[pos] = 100000 - pos++ - rr.AddInt(110000) - a[pos] = 110000 - pos++ - array := rr.ToArray() - ok := true - for i := range a { - if array[i] != a[i] { - log.Println("rr : ", array[i], " a : ", a[i]) - ok = false - } - } - So(len(array), ShouldEqual, len(a)) - So(ok, ShouldEqual, true) - }) - - Convey("BitmapContainerCardinalityTest", t, func() { - ac := newBitmapContainer() - for k := uint16(0); k < 100; k++ { - ac.iadd(k) - So(ac.getCardinality(), ShouldEqual, k+1) - } - for k := uint16(0); k < 100; k++ { - ac.iadd(k) - So(ac.getCardinality(), ShouldEqual, 100) - } - }) - - Convey("BitmapContainerTest", t, func() { - rr := newBitmapContainer() - rr.iadd(uint16(110)) - rr.iadd(uint16(114)) - rr.iadd(uint16(115)) - var array [3]uint16 - pos := 0 - for itr := rr.getShortIterator(); itr.hasNext(); { - array[pos] = itr.next() - pos++ - } - - So(array[0], ShouldEqual, uint16(110)) - So(array[1], ShouldEqual, uint16(114)) - So(array[2], ShouldEqual, uint16(115)) - }) - Convey("cardinality test", t, func() { - N := 1024 - for gap := 7; gap < 100000; gap *= 10 { - for offset := 2; offset <= 1024; offset *= 2 { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - for k := 0; k < N; k++ { - rb.AddInt(k * gap) - So(rb.GetCardinality(), ShouldEqual, k+1) - } - So(rb.GetCardinality(), ShouldEqual, N) - // check the add of existing values - for k := 0; k < N; k++ { - rb.AddInt(k * gap) - So(rb.GetCardinality(), ShouldEqual, N) - } - - rb2 := NewBitmap() - rb2.SetCopyOnWrite(true) - - for k := 0; k < N; k++ { - rb2.AddInt(k * gap * offset) - So(rb2.GetCardinality(), ShouldEqual, k+1) - } - - So(rb2.GetCardinality(), ShouldEqual, N) - - for k := 0; k < N; k++ { - rb2.AddInt(k * gap * offset) - So(rb2.GetCardinality(), ShouldEqual, N) - } - So(And(rb, rb2).GetCardinality(), ShouldEqual, N/offset) - So(Xor(rb, rb2).GetCardinality(), ShouldEqual, 2*N-2*N/offset) - So(Or(rb, rb2).GetCardinality(), ShouldEqual, 2*N-N/offset) - } - } - }) - - Convey("clear test", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - for i := 0; i < 200000; i += 7 { - // dense - rb.AddInt(i) - } - for i := 200000; i < 400000; i += 177 { - // sparse - rb.AddInt(i) - } - - rb2 := NewBitmap() - rb2.SetCopyOnWrite(true) - rb3 := NewBitmap() - rb3.SetCopyOnWrite(true) - for i := 0; i < 200000; i += 4 { - rb2.AddInt(i) - } - for i := 200000; i < 400000; i += 14 { - rb2.AddInt(i) - } - - rb.Clear() - So(rb.GetCardinality(), ShouldEqual, 0) - So(rb2.GetCardinality(), ShouldNotEqual, 0) - - rb.AddInt(4) - rb3.AddInt(4) - andresult := And(rb, rb2) - orresult := Or(rb, rb2) - - So(andresult.GetCardinality(), ShouldEqual, 1) - So(orresult.GetCardinality(), ShouldEqual, rb2.GetCardinality()) - - for i := 0; i < 200000; i += 4 { - rb.AddInt(i) - rb3.AddInt(i) - } - for i := 200000; i < 400000; i += 114 { - rb.AddInt(i) - rb3.AddInt(i) - } - - arrayrr := rb.ToArray() - arrayrr3 := rb3.ToArray() - ok := true - for i := range arrayrr { - if arrayrr[i] != arrayrr3[i] { - ok = false - } - } - So(len(arrayrr), ShouldEqual, len(arrayrr3)) - So(ok, ShouldEqual, true) - }) - - Convey("constainer factory ", t, func() { - - bc1 := newBitmapContainer() - bc2 := newBitmapContainer() - bc3 := newBitmapContainer() - ac1 := newArrayContainer() - ac2 := newArrayContainer() - ac3 := newArrayContainer() - - for i := 0; i < 5000; i++ { - bc1.iadd(uint16(i * 70)) - } - for i := 0; i < 5000; i++ { - bc2.iadd(uint16(i * 70)) - } - for i := 0; i < 5000; i++ { - bc3.iadd(uint16(i * 70)) - } - for i := 0; i < 4000; i++ { - ac1.iadd(uint16(i * 50)) - } - for i := 0; i < 4000; i++ { - ac2.iadd(uint16(i * 50)) - } - for i := 0; i < 4000; i++ { - ac3.iadd(uint16(i * 50)) - } - - rbc := ac1.clone().(*arrayContainer).toBitmapContainer() - So(validate(rbc, ac1), ShouldEqual, true) - rbc = ac2.clone().(*arrayContainer).toBitmapContainer() - So(validate(rbc, ac2), ShouldEqual, true) - rbc = ac3.clone().(*arrayContainer).toBitmapContainer() - So(validate(rbc, ac3), ShouldEqual, true) - }) - Convey("flipTest1 ", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb.Flip(100000, 200000) // in-place on empty bitmap - rbcard := rb.GetCardinality() - So(100000, ShouldEqual, rbcard) - - bs := bitset.New(20000 - 10000) - for i := uint(100000); i < 200000; i++ { - bs.Set(i) - } - So(equalsBitSet(bs, rb), ShouldEqual, true) - }) - - Convey("flipTest1A", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb1 := Flip(rb, 100000, 200000) - rbcard := rb1.GetCardinality() - So(100000, ShouldEqual, rbcard) - So(0, ShouldEqual, rb.GetCardinality()) - - bs := bitset.New(0) - So(equalsBitSet(bs, rb), ShouldEqual, true) - - for i := uint(100000); i < 200000; i++ { - bs.Set(i) - } - So(equalsBitSet(bs, rb1), ShouldEqual, true) - }) - Convey("flipTest2", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb.Flip(100000, 100000) - rbcard := rb.GetCardinality() - So(0, ShouldEqual, rbcard) - - bs := bitset.New(0) - So(equalsBitSet(bs, rb), ShouldEqual, true) - }) - - Convey("flipTest2A", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb1 := Flip(rb, 100000, 100000) - - rb.AddInt(1) - rbcard := rb1.GetCardinality() - - So(0, ShouldEqual, rbcard) - So(1, ShouldEqual, rb.GetCardinality()) - - bs := bitset.New(0) - So(equalsBitSet(bs, rb1), ShouldEqual, true) - bs.Set(1) - So(equalsBitSet(bs, rb), ShouldEqual, true) - }) - - Convey("flipTest3A", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb.Flip(100000, 200000) // got 100k-199999 - rb.Flip(100000, 199991) // give back 100k-199990 - rbcard := rb.GetCardinality() - So(9, ShouldEqual, rbcard) - - bs := bitset.New(0) - for i := uint(199991); i < 200000; i++ { - bs.Set(i) - } - - So(equalsBitSet(bs, rb), ShouldEqual, true) - }) - - Convey("flipTest4A", t, func() { - // fits evenly on both ends - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb.Flip(100000, 200000) // got 100k-199999 - rb.Flip(65536, 4*65536) - rbcard := rb.GetCardinality() - - // 65536 to 99999 are 1s - // 200000 to 262143 are 1s: total card - - So(96608, ShouldEqual, rbcard) - - bs := bitset.New(0) - for i := uint(65536); i < 100000; i++ { - bs.Set(i) - } - for i := uint(200000); i < 262144; i++ { - bs.Set(i) - } - - So(equalsBitSet(bs, rb), ShouldEqual, true) - }) - - Convey("flipTest5", t, func() { - // fits evenly on small end, multiple - // containers - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb.Flip(100000, 132000) - rb.Flip(65536, 120000) - rbcard := rb.GetCardinality() - - // 65536 to 99999 are 1s - // 120000 to 131999 - - So(46464, ShouldEqual, rbcard) - - bs := bitset.New(0) - for i := uint(65536); i < 100000; i++ { - bs.Set(i) - } - for i := uint(120000); i < 132000; i++ { - bs.Set(i) - } - So(equalsBitSet(bs, rb), ShouldEqual, true) - }) - - Convey("flipTest6", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb1 := Flip(rb, 100000, 132000) - rb2 := Flip(rb1, 65536, 120000) - //rbcard := rb2.GetCardinality() - - bs := bitset.New(0) - for i := uint(65536); i < 100000; i++ { - bs.Set(i) - } - for i := uint(120000); i < 132000; i++ { - bs.Set(i) - } - So(equalsBitSet(bs, rb2), ShouldEqual, true) - }) - - Convey("flipTest6A", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb1 := Flip(rb, 100000, 132000) - rb2 := Flip(rb1, 99000, 2*65536) - rbcard := rb2.GetCardinality() - - So(1928, ShouldEqual, rbcard) - - bs := bitset.New(0) - for i := uint(99000); i < 100000; i++ { - bs.Set(i) - } - for i := uint(2 * 65536); i < 132000; i++ { - bs.Set(i) - } - So(equalsBitSet(bs, rb2), ShouldEqual, true) - }) - - Convey("flipTest7", t, func() { - // within 1 word, first container - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb.Flip(650, 132000) - rb.Flip(648, 651) - rbcard := rb.GetCardinality() - - // 648, 649, 651-131999 - - So(132000-651+2, ShouldEqual, rbcard) - bs := bitset.New(0) - bs.Set(648) - bs.Set(649) - for i := uint(651); i < 132000; i++ { - bs.Set(i) - } - So(equalsBitSet(bs, rb), ShouldEqual, true) - }) - Convey("flipTestBig", t, func() { - numCases := 1000 - rb := NewBitmap() - rb.SetCopyOnWrite(true) - bs := bitset.New(0) - //Random r = new Random(3333); - checkTime := 2.0 - - for i := 0; i < numCases; i++ { - start := rand.Intn(65536 * 20) - end := rand.Intn(65536 * 20) - if rand.Float64() < float64(0.1) { - end = start + rand.Intn(100) - } - rb.Flip(uint64(start), uint64(end)) - if start < end { - FlipRange(start, end, bs) // throws exception - } - // otherwise - // insert some more ANDs to keep things sparser - if rand.Float64() < 0.2 { - mask := NewBitmap() - mask.SetCopyOnWrite(true) - mask1 := bitset.New(0) - startM := rand.Intn(65536 * 20) - endM := startM + 100000 - mask.Flip(uint64(startM), uint64(endM)) - FlipRange(startM, endM, mask1) - mask.Flip(0, 65536*20+100000) - FlipRange(0, 65536*20+100000, mask1) - rb.And(mask) - bs.InPlaceIntersection(mask1) - } - // see if we can detect incorrectly shared containers - if rand.Float64() < 0.1 { - irrelevant := Flip(rb, 10, 100000) - irrelevant.Flip(5, 200000) - irrelevant.Flip(190000, 260000) - } - if float64(i) > checkTime { - So(equalsBitSet(bs, rb), ShouldEqual, true) - checkTime *= 1.5 - } - } - }) - - Convey("ortest", t, func() { - rr := NewBitmap() - rr.SetCopyOnWrite(true) - for k := 0; k < 4000; k++ { - rr.AddInt(k) - } - rr.AddInt(100000) - rr.AddInt(110000) - rr2 := NewBitmap() - rr2.SetCopyOnWrite(true) - for k := 0; k < 4000; k++ { - rr2.AddInt(k) - } - - rror := Or(rr, rr2) - - array := rror.ToArray() - - rr.Or(rr2) - arrayirr := rr.ToArray() - So(IntsEquals(array, arrayirr), ShouldEqual, true) - }) - - Convey("ORtest", t, func() { - rr := NewBitmap() - rr.SetCopyOnWrite(true) - for k := 4000; k < 4256; k++ { - rr.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr.AddInt(k) - } - for k := 3 * 65536; k < 3*65536+9000; k++ { - rr.AddInt(k) - } - for k := 4 * 65535; k < 4*65535+7000; k++ { - rr.AddInt(k) - } - for k := 6 * 65535; k < 6*65535+10000; k++ { - rr.AddInt(k) - } - for k := 8 * 65535; k < 8*65535+1000; k++ { - rr.AddInt(k) - } - for k := 9 * 65535; k < 9*65535+30000; k++ { - rr.AddInt(k) - } - - rr2 := NewBitmap() - rr2.SetCopyOnWrite(true) - for k := 4000; k < 4256; k++ { - rr2.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr2.AddInt(k) - } - for k := 3*65536 + 2000; k < 3*65536+6000; k++ { - rr2.AddInt(k) - } - for k := 6 * 65535; k < 6*65535+1000; k++ { - rr2.AddInt(k) - } - for k := 7 * 65535; k < 7*65535+1000; k++ { - rr2.AddInt(k) - } - for k := 10 * 65535; k < 10*65535+5000; k++ { - rr2.AddInt(k) - } - correct := Or(rr, rr2) - rr.Or(rr2) - So(correct.Equals(rr), ShouldEqual, true) - }) - - Convey("ortest2", t, func() { - arrayrr := make([]uint32, 4000+4000+2) - pos := 0 - rr := NewBitmap() - rr.SetCopyOnWrite(true) - for k := 0; k < 4000; k++ { - rr.AddInt(k) - arrayrr[pos] = uint32(k) - pos++ - } - rr.AddInt(100000) - rr.AddInt(110000) - rr2 := NewBitmap() - rr2.SetCopyOnWrite(true) - for k := 4000; k < 8000; k++ { - rr2.AddInt(k) - arrayrr[pos] = uint32(k) - pos++ - } - - arrayrr[pos] = 100000 - pos++ - arrayrr[pos] = 110000 - pos++ - - rror := Or(rr, rr2) - - arrayor := rror.ToArray() - - So(IntsEquals(arrayor, arrayrr), ShouldEqual, true) - }) - - Convey("ortest3", t, func() { - V1 := make(map[int]bool) - V2 := make(map[int]bool) - - rr := NewBitmap() - rr.SetCopyOnWrite(true) - rr2 := NewBitmap() - rr2.SetCopyOnWrite(true) - for k := 0; k < 4000; k++ { - rr2.AddInt(k) - V1[k] = true - } - for k := 3500; k < 4500; k++ { - rr.AddInt(k) - V1[k] = true - } - for k := 4000; k < 65000; k++ { - rr2.AddInt(k) - V1[k] = true - } - - // In the second node of each roaring bitmap, we have two bitmap - // containers. - // So, we will check the union between two BitmapContainers - for k := 65536; k < 65536+10000; k++ { - rr.AddInt(k) - V1[k] = true - } - - for k := 65536; k < 65536+14000; k++ { - rr2.AddInt(k) - V1[k] = true - } - - // In the 3rd node of each Roaring Bitmap, we have an - // ArrayContainer, so, we will try the union between two - // ArrayContainers. - for k := 4 * 65535; k < 4*65535+1000; k++ { - rr.AddInt(k) - V1[k] = true - } - - for k := 4 * 65535; k < 4*65535+800; k++ { - rr2.AddInt(k) - V1[k] = true - } - - // For the rest, we will check if the union will take them in - // the result - for k := 6 * 65535; k < 6*65535+1000; k++ { - rr.AddInt(k) - V1[k] = true - } - - for k := 7 * 65535; k < 7*65535+2000; k++ { - rr2.AddInt(k) - V1[k] = true - } - - rror := Or(rr, rr2) - valide := true - - for _, k := range rror.ToArray() { - _, found := V1[int(k)] - if !found { - valide = false - } - V2[int(k)] = true - } - - for k := range V1 { - _, found := V2[k] - if !found { - valide = false - } - } - - So(valide, ShouldEqual, true) - }) - - Convey("ortest4", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb2 := NewBitmap() - rb2.SetCopyOnWrite(true) - - for i := 0; i < 200000; i += 4 { - rb2.AddInt(i) - } - for i := 200000; i < 400000; i += 14 { - rb2.AddInt(i) - } - rb2card := rb2.GetCardinality() - - // check or against an empty bitmap - orresult := Or(rb, rb2) - off := Or(rb2, rb) - So(orresult.Equals(off), ShouldEqual, true) - - So(rb2card, ShouldEqual, orresult.GetCardinality()) - - for i := 500000; i < 600000; i += 14 { - rb.AddInt(i) - } - for i := 200000; i < 400000; i += 3 { - rb2.AddInt(i) - } - // check or against an empty bitmap - orresult2 := Or(rb, rb2) - So(rb2card, ShouldEqual, orresult.GetCardinality()) - So(rb2.GetCardinality()+rb.GetCardinality(), ShouldEqual, - orresult2.GetCardinality()) - rb.Or(rb2) - So(rb.Equals(orresult2), ShouldEqual, true) - - }) - - Convey("randomTest", t, func() { - rTestCOW(15) - rTestCOW(1024) - rTestCOW(4096) - rTestCOW(65536) - rTestCOW(65536 * 16) - }) - - Convey("SimpleCardinality", t, func() { - N := 512 - gap := 70 - - rb := NewBitmap() - rb.SetCopyOnWrite(true) - for k := 0; k < N; k++ { - rb.AddInt(k * gap) - So(rb.GetCardinality(), ShouldEqual, k+1) - } - So(rb.GetCardinality(), ShouldEqual, N) - for k := 0; k < N; k++ { - rb.AddInt(k * gap) - So(rb.GetCardinality(), ShouldEqual, N) - } - - }) - - Convey("XORtest", t, func() { - rr := NewBitmap() - rr.SetCopyOnWrite(true) - for k := 4000; k < 4256; k++ { - rr.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr.AddInt(k) - } - for k := 3 * 65536; k < 3*65536+9000; k++ { - rr.AddInt(k) - } - for k := 4 * 65535; k < 4*65535+7000; k++ { - rr.AddInt(k) - } - for k := 6 * 65535; k < 6*65535+10000; k++ { - rr.AddInt(k) - } - for k := 8 * 65535; k < 8*65535+1000; k++ { - rr.AddInt(k) - } - for k := 9 * 65535; k < 9*65535+30000; k++ { - rr.AddInt(k) - } - - rr2 := NewBitmap() - rr2.SetCopyOnWrite(true) - for k := 4000; k < 4256; k++ { - rr2.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr2.AddInt(k) - } - for k := 3*65536 + 2000; k < 3*65536+6000; k++ { - rr2.AddInt(k) - } - for k := 6 * 65535; k < 6*65535+1000; k++ { - rr2.AddInt(k) - } - for k := 7 * 65535; k < 7*65535+1000; k++ { - rr2.AddInt(k) - } - for k := 10 * 65535; k < 10*65535+5000; k++ { - rr2.AddInt(k) - } - correct := Xor(rr, rr2) - rr.Xor(rr2) - So(correct.Equals(rr), ShouldEqual, true) - }) - - Convey("xortest1", t, func() { - V1 := make(map[int]bool) - V2 := make(map[int]bool) - - rr := NewBitmap() - rr.SetCopyOnWrite(true) - rr2 := NewBitmap() - rr2.SetCopyOnWrite(true) - // For the first 65536: rr2 has a bitmap container, and rr has - // an array container. - // We will check the union between a BitmapCintainer and an - // arrayContainer - for k := 0; k < 4000; k++ { - rr2.AddInt(k) - if k < 3500 { - V1[k] = true - } - } - for k := 3500; k < 4500; k++ { - rr.AddInt(k) - } - for k := 4000; k < 65000; k++ { - rr2.AddInt(k) - if k >= 4500 { - V1[k] = true - } - } - - for k := 65536; k < 65536+30000; k++ { - rr.AddInt(k) - } - - for k := 65536; k < 65536+50000; k++ { - rr2.AddInt(k) - if k >= 65536+30000 { - V1[k] = true - } - } - - // In the 3rd node of each Roaring Bitmap, we have an - // ArrayContainer. So, we will try the union between two - // ArrayContainers. - for k := 4 * 65535; k < 4*65535+1000; k++ { - rr.AddInt(k) - if k >= (4*65535 + 800) { - V1[k] = true - } - } - - for k := 4 * 65535; k < 4*65535+800; k++ { - rr2.AddInt(k) - } - - for k := 6 * 65535; k < 6*65535+1000; k++ { - rr.AddInt(k) - V1[k] = true - } - - for k := 7 * 65535; k < 7*65535+2000; k++ { - rr2.AddInt(k) - V1[k] = true - } - - rrxor := Xor(rr, rr2) - valide := true - - for _, i := range rrxor.ToArray() { - _, found := V1[int(i)] - if !found { - valide = false - } - V2[int(i)] = true - } - for k := range V1 { - _, found := V2[k] - if !found { - valide = false - } - } - - So(valide, ShouldEqual, true) - }) -} -func TestXORtest4COW(t *testing.T) { - Convey("XORtest 4", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb2 := NewBitmap() - rb2.SetCopyOnWrite(true) - counter := 0 - - for i := 0; i < 200000; i += 4 { - rb2.AddInt(i) - counter++ - } - So(rb2.GetCardinality(), ShouldEqual, counter) - for i := 200000; i < 400000; i += 14 { - rb2.AddInt(i) - counter++ - } - So(rb2.GetCardinality(), ShouldEqual, counter) - rb2card := rb2.GetCardinality() - So(rb2card, ShouldEqual, counter) - - // check or against an empty bitmap - xorresult := Xor(rb, rb2) - So(xorresult.GetCardinality(), ShouldEqual, counter) - off := Or(rb2, rb) - So(off.GetCardinality(), ShouldEqual, counter) - So(xorresult.Equals(off), ShouldEqual, true) - - So(rb2card, ShouldEqual, xorresult.GetCardinality()) - for i := 500000; i < 600000; i += 14 { - rb.AddInt(i) - } - for i := 200000; i < 400000; i += 3 { - rb2.AddInt(i) - } - // check or against an empty bitmap - xorresult2 := Xor(rb, rb2) - So(rb2card, ShouldEqual, xorresult.GetCardinality()) - - So(rb2.GetCardinality()+rb.GetCardinality(), ShouldEqual, xorresult2.GetCardinality()) - - rb.Xor(rb2) - So(xorresult2.Equals(rb), ShouldEqual, true) - - }) - //need to add the massives -} - -func TestBigRandomCOW(t *testing.T) { - Convey("randomTest", t, func() { - rTestCOW(15) - rTestCOW(100) - rTestCOW(512) - rTestCOW(1023) - rTestCOW(1025) - rTestCOW(4095) - rTestCOW(4096) - rTestCOW(4097) - rTestCOW(65536) - rTestCOW(65536 * 16) - }) -} - -func rTestCOW(N int) { - log.Println("rtest N=", N) - for gap := 1; gap <= 65536; gap *= 2 { - bs1 := bitset.New(0) - rb1 := NewBitmap() - rb1.SetCopyOnWrite(true) - for x := 0; x <= N; x += gap { - bs1.Set(uint(x)) - rb1.AddInt(x) - } - So(bs1.Count(), ShouldEqual, rb1.GetCardinality()) - So(equalsBitSet(bs1, rb1), ShouldEqual, true) - for offset := 1; offset <= gap; offset *= 2 { - bs2 := bitset.New(0) - rb2 := NewBitmap() - rb2.SetCopyOnWrite(true) - for x := 0; x <= N; x += gap { - bs2.Set(uint(x + offset)) - rb2.AddInt(x + offset) - } - So(bs2.Count(), ShouldEqual, rb2.GetCardinality()) - So(equalsBitSet(bs2, rb2), ShouldEqual, true) - - clonebs1 := bs1.Clone() - clonebs1.InPlaceIntersection(bs2) - if !equalsBitSet(clonebs1, And(rb1, rb2)) { - t := rb1.Clone() - t.And(rb2) - So(equalsBitSet(clonebs1, t), ShouldEqual, true) - } - - // testing OR - clonebs1 = bs1.Clone() - clonebs1.InPlaceUnion(bs2) - - So(equalsBitSet(clonebs1, Or(rb1, rb2)), ShouldEqual, true) - // testing XOR - clonebs1 = bs1.Clone() - clonebs1.InPlaceSymmetricDifference(bs2) - So(equalsBitSet(clonebs1, Xor(rb1, rb2)), ShouldEqual, true) - - //testing NOTAND - clonebs1 = bs1.Clone() - clonebs1.InPlaceDifference(bs2) - So(equalsBitSet(clonebs1, AndNot(rb1, rb2)), ShouldEqual, true) - } - } -} - -func TestRoaringArrayCOW(t *testing.T) { - - a := newRoaringArray() - Convey("Test Init", t, func() { - So(a.size(), ShouldEqual, 0) - }) - - Convey("Test Insert", t, func() { - a.appendContainer(0, newArrayContainer(), false) - - So(a.size(), ShouldEqual, 1) - }) - - Convey("Test Remove", t, func() { - a.remove(0) - So(a.size(), ShouldEqual, 0) - }) - - Convey("Test popcount Full", t, func() { - res := popcount(uint64(0xffffffffffffffff)) - So(res, ShouldEqual, 64) - }) - - Convey("Test popcount Empty", t, func() { - res := popcount(0) - So(res, ShouldEqual, 0) - }) - - Convey("Test popcount 16", t, func() { - res := popcount(0xff00ff) - So(res, ShouldEqual, 16) - }) - - Convey("Test ArrayContainer Add", t, func() { - ar := newArrayContainer() - ar.iadd(1) - So(ar.getCardinality(), ShouldEqual, 1) - }) - - Convey("Test ArrayContainer Add wacky", t, func() { - ar := newArrayContainer() - ar.iadd(0) - ar.iadd(5000) - So(ar.getCardinality(), ShouldEqual, 2) - }) - - Convey("Test ArrayContainer Add Reverse", t, func() { - ar := newArrayContainer() - ar.iadd(5000) - ar.iadd(2048) - ar.iadd(0) - So(ar.getCardinality(), ShouldEqual, 3) - }) - - Convey("Test BitmapContainer Add ", t, func() { - bm := newBitmapContainer() - bm.iadd(0) - So(bm.getCardinality(), ShouldEqual, 1) - }) - -} - -func TestFlipBigACOW(t *testing.T) { - Convey("flipTestBigA ", t, func() { - numCases := 1000 - bs := bitset.New(0) - checkTime := 2.0 - rb1 := NewBitmap() - rb1.SetCopyOnWrite(true) - rb2 := NewBitmap() - rb2.SetCopyOnWrite(true) - - for i := 0; i < numCases; i++ { - start := rand.Intn(65536 * 20) - end := rand.Intn(65536 * 20) - if rand.Float64() < 0.1 { - end = start + rand.Intn(100) - } - - if (i & 1) == 0 { - rb2 = FlipInt(rb1, start, end) - // tweak the other, catch bad sharing - rb1.FlipInt(rand.Intn(65536*20), rand.Intn(65536*20)) - } else { - rb1 = FlipInt(rb2, start, end) - rb2.FlipInt(rand.Intn(65536*20), rand.Intn(65536*20)) - } - - if start < end { - FlipRange(start, end, bs) // throws exception - } - // otherwise - // insert some more ANDs to keep things sparser - if (rand.Float64() < 0.2) && (i&1) == 0 { - mask := NewBitmap() - mask.SetCopyOnWrite(true) - mask1 := bitset.New(0) - startM := rand.Intn(65536 * 20) - endM := startM + 100000 - mask.FlipInt(startM, endM) - FlipRange(startM, endM, mask1) - mask.FlipInt(0, 65536*20+100000) - FlipRange(0, 65536*20+100000, mask1) - rb2.And(mask) - bs.InPlaceIntersection(mask1) - } - - if float64(i) > checkTime { - var rb *Bitmap - - if (i & 1) == 0 { - rb = rb2 - } else { - rb = rb1 - } - So(equalsBitSet(bs, rb), ShouldEqual, true) - checkTime *= 1.5 - } - } - }) -} - -func TestDoubleAddCOW(t *testing.T) { - Convey("doubleadd ", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb.AddRange(65533, 65536) - rb.AddRange(65530, 65536) - rb2 := NewBitmap() - rb2.SetCopyOnWrite(true) - rb2.AddRange(65530, 65536) - So(rb.Equals(rb2), ShouldEqual, true) - rb2.RemoveRange(65530, 65536) - So(rb2.GetCardinality(), ShouldEqual, 0) - }) -} - -func TestDoubleAdd2COW(t *testing.T) { - Convey("doubleadd2 ", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb.AddRange(65533, 65536*20) - rb.AddRange(65530, 65536*20) - rb2 := NewBitmap() - rb2.SetCopyOnWrite(true) - rb2.AddRange(65530, 65536*20) - So(rb.Equals(rb2), ShouldEqual, true) - rb2.RemoveRange(65530, 65536*20) - So(rb2.GetCardinality(), ShouldEqual, 0) - }) -} - -func TestDoubleAdd3COW(t *testing.T) { - Convey("doubleadd3 ", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb.AddRange(65533, 65536*20+10) - rb.AddRange(65530, 65536*20+10) - rb2 := NewBitmap() - rb2.SetCopyOnWrite(true) - rb2.AddRange(65530, 65536*20+10) - So(rb.Equals(rb2), ShouldEqual, true) - rb2.RemoveRange(65530, 65536*20+1) - So(rb2.GetCardinality(), ShouldEqual, 9) - }) -} - -func TestDoubleAdd4COW(t *testing.T) { - Convey("doubleadd4 ", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb.AddRange(65533, 65536*20) - rb.RemoveRange(65533+5, 65536*20) - So(rb.GetCardinality(), ShouldEqual, 5) - }) -} - -func TestDoubleAdd5COW(t *testing.T) { - Convey("doubleadd5 ", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb.AddRange(65533, 65536*20) - rb.RemoveRange(65533+5, 65536*20-5) - So(rb.GetCardinality(), ShouldEqual, 10) - }) -} - -func TestDoubleAdd6COW(t *testing.T) { - Convey("doubleadd6 ", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb.AddRange(65533, 65536*20-5) - rb.RemoveRange(65533+5, 65536*20-10) - So(rb.GetCardinality(), ShouldEqual, 10) - }) -} - -func TestDoubleAdd7COW(t *testing.T) { - Convey("doubleadd7 ", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb.AddRange(65533, 65536*20+1) - rb.RemoveRange(65533+1, 65536*20) - So(rb.GetCardinality(), ShouldEqual, 2) - }) -} - -func TestDoubleAndNotBug01COW(t *testing.T) { - Convey("AndNotBug01 ", t, func() { - rb1 := NewBitmap() - rb1.SetCopyOnWrite(true) - rb1.AddRange(0, 60000) - rb2 := NewBitmap() - rb2.SetCopyOnWrite(true) - rb2.AddRange(60000-10, 60000+10) - rb2.AndNot(rb1) - rb3 := NewBitmap() - rb3.SetCopyOnWrite(true) - rb3.AddRange(60000, 60000+10) - - So(rb2.Equals(rb3), ShouldBeTrue) - }) -} - -func TestAndNotCOW(t *testing.T) { - - Convey("Test ANDNOT", t, func() { - rr := NewBitmap() - rr.SetCopyOnWrite(true) - for k := 4000; k < 4256; k++ { - rr.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr.AddInt(k) - } - for k := 3 * 65536; k < 3*65536+9000; k++ { - rr.AddInt(k) - } - for k := 4 * 65535; k < 4*65535+7000; k++ { - rr.AddInt(k) - } - for k := 6 * 65535; k < 6*65535+10000; k++ { - rr.AddInt(k) - } - for k := 8 * 65535; k < 8*65535+1000; k++ { - rr.AddInt(k) - } - for k := 9 * 65535; k < 9*65535+30000; k++ { - rr.AddInt(k) - } - - rr2 := NewBitmap() - rr2.SetCopyOnWrite(true) - for k := 4000; k < 4256; k++ { - rr2.AddInt(k) - } - for k := 65536; k < 65536+4000; k++ { - rr2.AddInt(k) - } - for k := 3*65536 + 2000; k < 3*65536+6000; k++ { - rr2.AddInt(k) - } - for k := 6 * 65535; k < 6*65535+1000; k++ { - rr2.AddInt(k) - } - for k := 7 * 65535; k < 7*65535+1000; k++ { - rr2.AddInt(k) - } - for k := 10 * 65535; k < 10*65535+5000; k++ { - rr2.AddInt(k) - } - correct := AndNot(rr, rr2) - rr.AndNot(rr2) - - So(correct.Equals(rr), ShouldEqual, true) - }) -} - -func TestStatsCOW(t *testing.T) { - Convey("Test Stats with empty bitmap", t, func() { - expectedStats := Statistics{} - rr := NewBitmap() - rr.SetCopyOnWrite(true) - So(rr.Stats(), ShouldResemble, expectedStats) - }) - Convey("Test Stats with bitmap Container", t, func() { - // Given a bitmap that should have a single bitmap container - expectedStats := Statistics{ - Cardinality: 60000, - Containers: 1, - - BitmapContainers: 1, - BitmapContainerValues: 60000, - BitmapContainerBytes: 8192, - - RunContainers: 0, - RunContainerBytes: 0, - RunContainerValues: 0, - } - rr := NewBitmap() - rr.SetCopyOnWrite(true) - for i := uint32(0); i < 60000; i++ { - rr.Add(i) - } - So(rr.Stats(), ShouldResemble, expectedStats) - }) - - Convey("Test Stats with run Container", t, func() { - // Given that we should have a single run container - expectedStats := Statistics{ - Cardinality: 60000, - Containers: 1, - - BitmapContainers: 0, - BitmapContainerValues: 0, - BitmapContainerBytes: 0, - - RunContainers: 1, - RunContainerBytes: 52, - RunContainerValues: 60000, - } - rr := NewBitmap() - rr.SetCopyOnWrite(true) - rr.AddRange(0, 60000) - So(rr.Stats(), ShouldResemble, expectedStats) - }) - Convey("Test Stats with Array Container", t, func() { - // Given a bitmap that should have a single array container - expectedStats := Statistics{ - Cardinality: 2, - Containers: 1, - - ArrayContainers: 1, - ArrayContainerValues: 2, - ArrayContainerBytes: 4, - } - rr := NewBitmap() - rr.SetCopyOnWrite(true) - rr.Add(2) - rr.Add(4) - So(rr.Stats(), ShouldResemble, expectedStats) - }) -} - -func TestFlipVerySmallCOW(t *testing.T) { - Convey("very small basic Flip test", t, func() { - rb := NewBitmap() - rb.SetCopyOnWrite(true) - rb.Flip(0, 10) // got [0,9], card is 10 - rb.Flip(0, 1) // give back the number 0, card goes to 9 - rbcard := rb.GetCardinality() - So(rbcard, ShouldEqual, 9) - }) -} diff --git a/vendor/github.com/RoaringBitmap/roaring/serialization_test.go b/vendor/github.com/RoaringBitmap/roaring/serialization_test.go deleted file mode 100644 index 0cef474b5..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/serialization_test.go +++ /dev/null @@ -1,680 +0,0 @@ -package roaring - -// to run just these tests: go test -run TestSerialization* - -import ( - "bytes" - "encoding/gob" - "fmt" - "io/ioutil" - "math/rand" - "os" - "testing" - - . "github.com/smartystreets/goconvey/convey" -) - -func TestSerializationOfEmptyBitmap(t *testing.T) { - rb := NewBitmap() - - buf := &bytes.Buffer{} - _, err := rb.WriteTo(buf) - if err != nil { - t.Errorf("Failed writing") - } - - newrb := NewBitmap() - _, err = newrb.ReadFrom(buf) - if err != nil { - t.Errorf("Failed reading: %v", err) - } - if !rb.Equals(newrb) { - p("rb = '%s'", rb) - p("but newrb = '%s'", newrb) - t.Errorf("Cannot retrieve serialized version; rb != newrb") - } -} - -func TestBase64_036(t *testing.T) { - rb := BitmapOf(1, 2, 3, 4, 5, 100, 1000) - - bstr, _ := rb.ToBase64() - - if bstr == "" { - t.Errorf("ToBase64 failed returned empty string") - } - - newrb := NewBitmap() - - _, err := newrb.FromBase64(bstr) - - if err != nil { - t.Errorf("Failed reading from base64 string") - } - - if !rb.Equals(newrb) { - t.Errorf("comparing the base64 to and from failed cannot retrieve serialized version") - } -} - -func TestSerializationBasic037(t *testing.T) { - - rb := BitmapOf(1, 2, 3, 4, 5, 100, 1000) - - buf := &bytes.Buffer{} - _, err := rb.WriteTo(buf) - if err != nil { - t.Errorf("Failed writing") - } - - newrb := NewBitmap() - _, err = newrb.ReadFrom(buf) - if err != nil { - t.Errorf("Failed reading") - } - if !rb.Equals(newrb) { - p("rb = '%s'", rb) - p("but newrb = '%s'", newrb) - t.Errorf("Cannot retrieve serialized version; rb != newrb") - } -} - -func TestSerializationToFile038(t *testing.T) { - rb := BitmapOf(1, 2, 3, 4, 5, 100, 1000) - fname := "myfile.bin" - fout, err := os.OpenFile(fname, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0660) - if err != nil { - t.Errorf("Can't open a file for writing") - } - _, err = rb.WriteTo(fout) - if err != nil { - t.Errorf("Failed writing") - } - fout.Close() - - newrb := NewBitmap() - fin, err := os.Open(fname) - - if err != nil { - t.Errorf("Failed reading") - } - defer func() { - fin.Close() - err := os.Remove(fname) - if err != nil { - t.Errorf("could not delete %s ", fname) - } - }() - _, _ = newrb.ReadFrom(fin) - if !rb.Equals(newrb) { - t.Errorf("Cannot retrieve serialized version") - } -} - -func TestSerializationReadRunsFromFile039(t *testing.T) { - fn := "testdata/bitmapwithruns.bin" - - p("reading file '%s'", fn) - by, err := ioutil.ReadFile(fn) - if err != nil { - panic(err) - } - - newrb := NewBitmap() - _, err = newrb.ReadFrom(bytes.NewBuffer(by)) - if err != nil { - t.Errorf("Failed reading %s: %s", fn, err) - } -} - -func TestSerializationBasic4WriteAndReadFile040(t *testing.T) { - - //fname := "testdata/all3.msgp.snappy" - fname := "testdata/all3.classic" - - rb := NewBitmap() - for k := uint32(0); k < 100000; k += 1000 { - rb.Add(k) - } - for k := uint32(100000); k < 200000; k++ { - rb.Add(3 * k) - } - for k := uint32(700000); k < 800000; k++ { - rb.Add(k) - } - rb.highlowcontainer.runOptimize() - - p("TestSerializationBasic4WriteAndReadFile is writing to '%s'", fname) - fout, err := os.Create(fname) - if err != nil { - t.Errorf("Failed creating '%s'", fname) - } - _, err = rb.WriteTo(fout) - if err != nil { - t.Errorf("Failed writing to '%s'", fname) - } - fout.Close() - - fin, err := os.Open(fname) - if err != nil { - t.Errorf("Failed to Open '%s'", fname) - } - defer fin.Close() - - newrb := NewBitmap() - _, err = newrb.ReadFrom(fin) - if err != nil { - t.Errorf("Failed reading from '%s': %s", fname, err) - } - if !rb.Equals(newrb) { - t.Errorf("Bad serialization") - } -} - -func TestSerializationFromJava051(t *testing.T) { - fname := "testdata/bitmapwithoutruns.bin" - newrb := NewBitmap() - fin, err := os.Open(fname) - - if err != nil { - t.Errorf("Failed reading") - } - defer func() { - fin.Close() - }() - - _, _ = newrb.ReadFrom(fin) - fmt.Println(newrb.GetCardinality()) - rb := NewBitmap() - for k := uint32(0); k < 100000; k += 1000 { - rb.Add(k) - } - for k := uint32(100000); k < 200000; k++ { - rb.Add(3 * k) - } - for k := uint32(700000); k < 800000; k++ { - rb.Add(k) - } - fmt.Println(rb.GetCardinality()) - if !rb.Equals(newrb) { - t.Errorf("Bad serialization") - } - -} - -func TestSerializationFromJavaWithRuns052(t *testing.T) { - fname := "testdata/bitmapwithruns.bin" - newrb := NewBitmap() - fin, err := os.Open(fname) - - if err != nil { - t.Errorf("Failed reading") - } - defer func() { - fin.Close() - }() - _, _ = newrb.ReadFrom(fin) - rb := NewBitmap() - for k := uint32(0); k < 100000; k += 1000 { - rb.Add(k) - } - for k := uint32(100000); k < 200000; k++ { - rb.Add(3 * k) - } - for k := uint32(700000); k < 800000; k++ { - rb.Add(k) - } - if !rb.Equals(newrb) { - t.Errorf("Bad serialization") - } - -} - -func TestSerializationBasic2_041(t *testing.T) { - - rb := BitmapOf(1, 2, 3, 4, 5, 100, 1000, 10000, 100000, 1000000) - buf := &bytes.Buffer{} - sz := rb.GetSerializedSizeInBytes() - ub := BoundSerializedSizeInBytes(rb.GetCardinality(), 1000001) - if sz > ub+10 { - t.Errorf("Bad GetSerializedSizeInBytes; sz=%v, upper-bound=%v", sz, ub) - } - l := int(rb.GetSerializedSizeInBytes()) - _, err := rb.WriteTo(buf) - if err != nil { - t.Errorf("Failed writing") - } - if l != buf.Len() { - t.Errorf("Bad GetSerializedSizeInBytes") - } - newrb := NewBitmap() - _, err = newrb.ReadFrom(buf) - if err != nil { - t.Errorf("Failed reading") - } - if !rb.Equals(newrb) { - t.Errorf("Cannot retrieve serialized version") - } -} - -func TestSerializationBasic3_042(t *testing.T) { - - Convey("roaringarray.writeTo and .readFrom should serialize and unserialize when containing all 3 container types", t, func() { - rb := BitmapOf(1, 2, 3, 4, 5, 100, 1000, 10000, 100000, 1000000) - for i := 5000000; i < 5000000+2*(1<<16); i++ { - rb.AddInt(i) - } - - // confirm all three types present - var bc, ac, rc bool - for _, v := range rb.highlowcontainer.containers { - switch cn := v.(type) { - case *bitmapContainer: - bc = true - case *arrayContainer: - ac = true - case *runContainer16: - rc = true - default: - panic(fmt.Errorf("Unrecognized container implementation: %T", cn)) - } - } - if !bc { - t.Errorf("no bitmapContainer found, change your test input so we test all three!") - } - if !ac { - t.Errorf("no arrayContainer found, change your test input so we test all three!") - } - if !rc { - t.Errorf("no runContainer16 found, change your test input so we test all three!") - } - - var buf bytes.Buffer - _, err := rb.WriteTo(&buf) - if err != nil { - t.Errorf("Failed writing") - } - - newrb := NewBitmap() - _, err = newrb.ReadFrom(&buf) - if err != nil { - t.Errorf("Failed reading") - } - c1, c2 := rb.GetCardinality(), newrb.GetCardinality() - So(c2, ShouldEqual, c1) - So(newrb.Equals(rb), ShouldBeTrue) - //fmt.Printf("\n Basic3: good: match on card = %v", c1) - }) -} - -func TestGobcoding043(t *testing.T) { - rb := BitmapOf(1, 2, 3, 4, 5, 100, 1000) - - buf := new(bytes.Buffer) - encoder := gob.NewEncoder(buf) - err := encoder.Encode(rb) - if err != nil { - t.Errorf("Gob encoding failed") - } - - var b Bitmap - decoder := gob.NewDecoder(buf) - err = decoder.Decode(&b) - if err != nil { - t.Errorf("Gob decoding failed") - } - - if !b.Equals(rb) { - t.Errorf("Decoded bitmap does not equal input bitmap") - } -} - -func TestSerializationRunContainerMsgpack028(t *testing.T) { - - Convey("runContainer writeTo and readFrom should return logically equivalent containers", t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 10, percentFill: .2, ntrial: 10}, - {n: 10, percentFill: .8, ntrial: 10}, - {n: 10, percentFill: .50, ntrial: 10}, - /* - trial{n: 10, percentFill: .01, ntrial: 10}, - trial{n: 1000, percentFill: .50, ntrial: 10}, - trial{n: 1000, percentFill: .99, ntrial: 10}, - */ - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestSerializationRunContainerMsgpack028 on check# j=%v", j) - - ma := make(map[int]bool) - - n := tr.n - a := []uint16{} - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint16(r0)) - ma[r0] = true - } - - orig := newRunContainer16FromVals(false, a...) - - // serialize - var buf bytes.Buffer - _, err := orig.writeToMsgpack(&buf) - if err != nil { - panic(err) - } - - // deserialize - restored := &runContainer16{} - _, err = restored.readFromMsgpack(&buf) - if err != nil { - panic(err) - } - - // and compare - So(restored.equals(orig), ShouldBeTrue) - - } - p("done with serialization of runContainer16 check for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} - -func TestSerializationArrayOnly032(t *testing.T) { - - Convey("arrayContainer writeTo and readFrom should return logically equivalent containers, so long as you pre-size the write target properly", t, func() { - - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 101, percentFill: .50, ntrial: 10}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p(" on check# j=%v", j) - ma := make(map[int]bool) - - n := tr.n - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - ma[r0] = true - } - - //showArray16(a, "a") - - // vs arrayContainer - ac := newArrayContainer() - for k := range ma { - ac.iadd(uint16(k)) - } - - buf := &bytes.Buffer{} - _, err := ac.writeTo(buf) - panicOn(err) - - // have to pre-size the array write-target properly - // by telling it the cardinality to read. - ac2 := newArrayContainerSize(int(ac.getCardinality())) - - _, err = ac2.readFrom(buf) - panicOn(err) - So(ac2.String(), ShouldResemble, ac.String()) - } - p("done with randomized writeTo/readFrom for arrayContainer"+ - " checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - }) -} - -func TestSerializationRunOnly033(t *testing.T) { - - Convey("runContainer16 writeTo and readFrom should return logically equivalent containers", t, func() { - - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 100, percentFill: .50, ntrial: 1}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p(" on check# j=%v", j) - ma := make(map[int]bool) - - n := tr.n - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - ma[r0] = true - } - - ac := newRunContainer16() - for k := range ma { - ac.iadd(uint16(k)) - } - - buf := &bytes.Buffer{} - _, err := ac.writeTo(buf) - panicOn(err) - - ac2 := newRunContainer16() - - _, err = ac2.readFrom(buf) - panicOn(err) - So(ac2.equals(ac), ShouldBeTrue) - So(ac2.String(), ShouldResemble, ac.String()) - } - p("done with randomized writeTo/readFrom for runContainer16"+ - " checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - }) -} - -func TestSerializationBitmapOnly034(t *testing.T) { - - Convey("bitmapContainer writeTo and readFrom should return logically equivalent containers", t, func() { - - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 1010, percentFill: .50, ntrial: 10}, - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p(" on check# j=%v", j) - ma := make(map[int]bool) - - n := tr.n - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - ma[r0] = true - } - - //showArray16(a, "a") - - bc := newBitmapContainer() - for k := range ma { - bc.iadd(uint16(k)) - } - - buf := &bytes.Buffer{} - _, err := bc.writeTo(buf) - panicOn(err) - - bc2 := newBitmapContainer() - - _, err = bc2.readFrom(buf) - panicOn(err) - So(bc2.String(), ShouldResemble, bc.String()) - So(bc2.equals(bc), ShouldBeTrue) - } - p("done with randomized writeTo/readFrom for bitmapContainer"+ - " checks for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - }) -} - -func TestSerializationBasicMsgpack035(t *testing.T) { - - Convey("roaringarray.writeToMsgpack and .readFromMsgpack should serialize and unserialize when containing all 3 container types", t, func() { - rb := BitmapOf(1, 2, 3, 4, 5, 100, 1000, 10000, 100000, 1000000) - for i := 5000000; i < 5000000+2*(1<<16); i++ { - rb.AddInt(i) - } - - // confirm all three types present - var bc, ac, rc bool - for _, v := range rb.highlowcontainer.containers { - switch cn := v.(type) { - case *bitmapContainer: - bc = true - So(cn.containerType(), ShouldEqual, bitmapContype) - case *arrayContainer: - ac = true - So(cn.containerType(), ShouldEqual, arrayContype) - case *runContainer16: - rc = true - So(cn.containerType(), ShouldEqual, run16Contype) - default: - panic(fmt.Errorf("Unrecognized container implementation: %T", cn)) - } - } - if !bc { - t.Errorf("no bitmapContainer found, change your test input so we test all three!") - } - if !ac { - t.Errorf("no arrayContainer found, change your test input so we test all three!") - } - if !rc { - t.Errorf("no runContainer16 found, change your test input so we test all three!") - } - - var buf bytes.Buffer - _, err := rb.WriteToMsgpack(&buf) - if err != nil { - t.Errorf("Failed writing") - } - - newrb := NewBitmap() - _, err = newrb.ReadFromMsgpack(&buf) - if err != nil { - t.Errorf("Failed reading") - } - c1, c2 := rb.GetCardinality(), newrb.GetCardinality() - So(c2, ShouldEqual, c1) - So(newrb.Equals(rb), ShouldBeTrue) - //fmt.Printf("\n Basic3: good: match on card = %v", c1) - }) -} - -func TestSerializationRunContainer32Msgpack050(t *testing.T) { - - Convey("runContainer32 writeToMsgpack and readFromMsgpack should save/load data", t, func() { - seed := int64(42) - p("seed is %v", seed) - rand.Seed(seed) - - trials := []trial{ - {n: 10, percentFill: .2, ntrial: 1}, - /* trial{n: 10, percentFill: .8, ntrial: 10}, - trial{n: 10, percentFill: .50, ntrial: 10}, - - trial{n: 10, percentFill: .01, ntrial: 10}, - trial{n: 1000, percentFill: .50, ntrial: 10}, - trial{n: 1000, percentFill: .99, ntrial: 10}, - */ - } - - tester := func(tr trial) { - for j := 0; j < tr.ntrial; j++ { - p("TestSerializationRunContainer32Msgpack050 on check# j=%v", j) - - ma := make(map[int]bool) - - n := tr.n - a := []uint32{} - - draw := int(float64(n) * tr.percentFill) - for i := 0; i < draw; i++ { - r0 := rand.Intn(n) - a = append(a, uint32(r0)) - ma[r0] = true - } - - orig := newRunContainer32FromVals(false, a...) - - // serialize - var buf bytes.Buffer - _, err := orig.writeToMsgpack(&buf) - if err != nil { - panic(err) - } - - // deserialize - restored := &runContainer32{} - _, err = restored.readFromMsgpack(&buf) - if err != nil { - panic(err) - } - - // and compare - So(restored.equals32(orig), ShouldBeTrue) - orig.removeKey(1) - - // coverage - var notEq = newRunContainer32Range(1, 1) - So(notEq.equals32(orig), ShouldBeFalse) - - bc := newBitmapContainer() - bc.iadd(1) - bc.iadd(2) - rc22 := newRunContainer32FromBitmapContainer(bc) - So(rc22.cardinality(), ShouldEqual, 2) - } - p("done with msgpack serialization of runContainer32 check for trial %#v", tr) - } - - for i := range trials { - tester(trials[i]) - } - - }) -} diff --git a/vendor/github.com/RoaringBitmap/roaring/setutil.go b/vendor/github.com/RoaringBitmap/roaring/setutil.go index 2babd0775..3e8c01dd1 100644 --- a/vendor/github.com/RoaringBitmap/roaring/setutil.go +++ b/vendor/github.com/RoaringBitmap/roaring/setutil.go @@ -468,11 +468,11 @@ func advanceUntil( } // we know that the next-smallest span was too small - lower += (spansize / 2) + lower += (spansize >> 1) mid := 0 for lower+1 != upper { - mid = (lower + upper) / 2 + mid = (lower + upper) >> 1 if array[mid] == min { return mid } else if array[mid] < min { diff --git a/vendor/github.com/RoaringBitmap/roaring/setutil_test.go b/vendor/github.com/RoaringBitmap/roaring/setutil_test.go deleted file mode 100644 index 43d82cc6b..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/setutil_test.go +++ /dev/null @@ -1,130 +0,0 @@ -package roaring - -// to run just these tests: go test -run TestSetUtil* - -import ( - "testing" -) - -func TestSetUtilDifference(t *testing.T) { - data1 := []uint16{0, 1, 2, 3, 4, 9} - data2 := []uint16{2, 3, 4, 5, 8, 9, 11} - result := make([]uint16, 0, len(data1)+len(data2)) - expectedresult := []uint16{0, 1} - nl := difference(data1, data2, result) - result = result[:nl] - if !equal(result, expectedresult) { - t.Errorf("Difference is broken") - } - expectedresult = []uint16{5, 8, 11} - nl = difference(data2, data1, result) - result = result[:nl] - if !equal(result, expectedresult) { - t.Errorf("Difference is broken") - } -} - -func TestSetUtilUnion(t *testing.T) { - data1 := []uint16{0, 1, 2, 3, 4, 9} - data2 := []uint16{2, 3, 4, 5, 8, 9, 11} - result := make([]uint16, 0, len(data1)+len(data2)) - expectedresult := []uint16{0, 1, 2, 3, 4, 5, 8, 9, 11} - nl := union2by2(data1, data2, result) - result = result[:nl] - if !equal(result, expectedresult) { - t.Errorf("Union is broken") - } - nl = union2by2(data2, data1, result) - result = result[:nl] - if !equal(result, expectedresult) { - t.Errorf("Union is broken") - } -} - -func TestSetUtilExclusiveUnion(t *testing.T) { - data1 := []uint16{0, 1, 2, 3, 4, 9} - data2 := []uint16{2, 3, 4, 5, 8, 9, 11} - result := make([]uint16, 0, len(data1)+len(data2)) - expectedresult := []uint16{0, 1, 5, 8, 11} - nl := exclusiveUnion2by2(data1, data2, result) - result = result[:nl] - if !equal(result, expectedresult) { - t.Errorf("Exclusive Union is broken") - } - nl = exclusiveUnion2by2(data2, data1, result) - result = result[:nl] - if !equal(result, expectedresult) { - t.Errorf("Exclusive Union is broken") - } -} - -func TestSetUtilIntersection(t *testing.T) { - data1 := []uint16{0, 1, 2, 3, 4, 9} - data2 := []uint16{2, 3, 4, 5, 8, 9, 11} - result := make([]uint16, 0, len(data1)+len(data2)) - expectedresult := []uint16{2, 3, 4, 9} - nl := intersection2by2(data1, data2, result) - result = result[:nl] - result = result[:len(expectedresult)] - if !equal(result, expectedresult) { - t.Errorf("Intersection is broken") - } - nl = intersection2by2(data2, data1, result) - result = result[:nl] - if !equal(result, expectedresult) { - t.Errorf("Intersection is broken") - } - data1 = []uint16{4} - - data2 = make([]uint16, 10000) - for i := range data2 { - data2[i] = uint16(i) - } - result = make([]uint16, 0, len(data1)+len(data2)) - expectedresult = data1 - nl = intersection2by2(data1, data2, result) - result = result[:nl] - - if !equal(result, expectedresult) { - t.Errorf("Long intersection is broken") - } - nl = intersection2by2(data2, data1, result) - result = result[:nl] - if !equal(result, expectedresult) { - t.Errorf("Long intersection is broken") - } - -} - -func TestSetUtilIntersection2(t *testing.T) { - data1 := []uint16{0, 2, 4, 6, 8, 10, 12, 14, 16, 18} - data2 := []uint16{0, 3, 6, 9, 12, 15, 18} - result := make([]uint16, 0, len(data1)+len(data2)) - expectedresult := []uint16{0, 6, 12, 18} - nl := intersection2by2(data1, data2, result) - result = result[:nl] - result = result[:len(expectedresult)] - if !equal(result, expectedresult) { - t.Errorf("Intersection is broken") - } -} - -func TestSetUtilBinarySearch(t *testing.T) { - data := make([]uint16, 256) - for i := range data { - data[i] = uint16(2 * i) - } - for i := 0; i < 2*len(data); i++ { - key := uint16(i) - loc := binarySearch(data, key) - if (key & 1) == 0 { - if loc != int(key)/2 { - t.Errorf("binary search is broken") - } - } else { - if loc != -int(key)/2-2 { - t.Errorf("neg binary search is broken") - } - } - } -} diff --git a/vendor/github.com/RoaringBitmap/roaring/smat_generate_test.go b/vendor/github.com/RoaringBitmap/roaring/smat_generate_test.go deleted file mode 100644 index 3d0f5c488..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/smat_generate_test.go +++ /dev/null @@ -1,55 +0,0 @@ -// +build gofuzz - -package roaring - -import ( - "fmt" - "io/ioutil" - "os" - "testing" - - "github.com/mschoch/smat" -) - -func TestGenerateSmatCorpus(t *testing.T) { - for i, actionSeq := range smatActionSeqs { - byteSequence, err := actionSeq.ByteEncoding(&smatContext{}, - smat.ActionID('S'), smat.ActionID('T'), smatActionMap) - if err != nil { - t.Fatalf("error from ByteEncoding, err: %v, i: %d, actonSeq: %#v", - err, i, actionSeq) - } - os.MkdirAll("workdir/corpus", 0700) - ioutil.WriteFile(fmt.Sprintf("workdir/corpus/%d", i), byteSequence, 0600) - } -} - -var smatActionSeqs = []smat.ActionSeq{ - { - smat.ActionID('X'), - smat.ActionID('X'), - smat.ActionID('Y'), - smat.ActionID('Y'), - smat.ActionID('<'), - smat.ActionID('<'), - smat.ActionID('*'), - smat.ActionID('x'), - smat.ActionID('y'), - smat.ActionID('*'), - smat.ActionID('['), - smat.ActionID('['), - smat.ActionID('B'), - smat.ActionID('a'), - smat.ActionID('o'), - smat.ActionID('A'), - smat.ActionID('O'), - smat.ActionID('#'), - smat.ActionID('X'), - smat.ActionID('Y'), - smat.ActionID('B'), - smat.ActionID('e'), - smat.ActionID('f'), - smat.ActionID('-'), - smat.ActionID('e'), - }, -} diff --git a/vendor/github.com/RoaringBitmap/roaring/smat_hits_test.go b/vendor/github.com/RoaringBitmap/roaring/smat_hits_test.go deleted file mode 100644 index 5369a3e1d..000000000 --- a/vendor/github.com/RoaringBitmap/roaring/smat_hits_test.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2016 Couchbase, Inc. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the -// License. You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an "AS -// IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either -// express or implied. See the License for the specific language -// governing permissions and limitations under the License. - -// +build gofuzz - -package roaring - -import ( - "log" - "testing" - - "github.com/mschoch/smat" -) - -// Crashers reported by smat, captured as pairs of strings. A pair is -// a short descrption of the crash then the corresponding crash-input. -var smatHits = []string{ - "0001:\n" + - "in a bitset, not b bitmap, pos: 0\n" + - " a bitset: {0,1}\n" + - " b bitmap: {1,0}\n" + - "panic: bitset mismatch\n" + - " SETUP\n" + - " pushPair\n" + - " setBit\n" + - " y++\n" + - " flip\n", - "]5S\xa5", -} - -// Test the previous issues found by smat. -func TestSmatHits(t *testing.T) { - smatDebugPrev := smatDebug - smatDebug = true // Use true when diagnosing a crash. - - for i := 0; i < len(smatHits); i += 2 { - desc := smatHits[i] - hit := []byte(smatHits[i+1]) - - log.Printf("testing smat hit: (%d) %s\n", i/2, desc) - - // fuzz the hit input - smat.Fuzz(&smatContext{}, smat.ActionID('S'), smat.ActionID('T'), - smatActionMap, hit) - } - - smatDebug = smatDebugPrev -} diff --git a/vendor/github.com/RoaringBitmap/roaring/testdata/bitmapwithoutruns.bin b/vendor/github.com/RoaringBitmap/roaring/testdata/bitmapwithoutruns.bin deleted file mode 100644 index a99fd50af..000000000 Binary files a/vendor/github.com/RoaringBitmap/roaring/testdata/bitmapwithoutruns.bin and /dev/null differ diff --git a/vendor/github.com/RoaringBitmap/roaring/testdata/bitmapwithruns.bin b/vendor/github.com/RoaringBitmap/roaring/testdata/bitmapwithruns.bin deleted file mode 100644 index 5ed243753..000000000 Binary files a/vendor/github.com/RoaringBitmap/roaring/testdata/bitmapwithruns.bin and /dev/null differ diff --git a/vendor/github.com/StackExchange/wmi/LICENSE b/vendor/github.com/StackExchange/wmi/LICENSE new file mode 100644 index 000000000..ae80b6720 --- /dev/null +++ b/vendor/github.com/StackExchange/wmi/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2013 Stack Exchange + +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/StackExchange/wmi/README.md b/vendor/github.com/StackExchange/wmi/README.md new file mode 100644 index 000000000..3d5f67e14 --- /dev/null +++ b/vendor/github.com/StackExchange/wmi/README.md @@ -0,0 +1,4 @@ +wmi +=== + +Package wmi provides a WQL interface for WMI on Windows. diff --git a/vendor/github.com/StackExchange/wmi/wmi.go b/vendor/github.com/StackExchange/wmi/wmi.go new file mode 100644 index 000000000..b931ca57a --- /dev/null +++ b/vendor/github.com/StackExchange/wmi/wmi.go @@ -0,0 +1,416 @@ +// +build windows + +/* +Package wmi provides a WQL interface for WMI on Windows. + +Example code to print names of running processes: + + type Win32_Process struct { + Name string + } + + func main() { + var dst []Win32_Process + q := wmi.CreateQuery(&dst, "") + err := wmi.Query(q, &dst) + if err != nil { + log.Fatal(err) + } + for i, v := range dst { + println(i, v.Name) + } + } + +*/ +package wmi + +import ( + "bytes" + "errors" + "fmt" + "log" + "os" + "reflect" + "runtime" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-ole/go-ole" + "github.com/go-ole/go-ole/oleutil" +) + +var l = log.New(os.Stdout, "", log.LstdFlags) + +var ( + ErrInvalidEntityType = errors.New("wmi: invalid entity type") + lock sync.Mutex +) + +// QueryNamespace invokes Query with the given namespace on the local machine. +func QueryNamespace(query string, dst interface{}, namespace string) error { + return Query(query, dst, nil, namespace) +} + +// Query runs the WQL query and appends the values to dst. +// +// dst must have type *[]S or *[]*S, for some struct type S. Fields selected in +// the query must have the same name in dst. Supported types are all signed and +// unsigned integers, time.Time, string, bool, or a pointer to one of those. +// Array types are not supported. +// +// By default, the local machine and default namespace are used. These can be +// changed using connectServerArgs. See +// http://msdn.microsoft.com/en-us/library/aa393720.aspx for details. +// +// Query is a wrapper around DefaultClient.Query. +func Query(query string, dst interface{}, connectServerArgs ...interface{}) error { + return DefaultClient.Query(query, dst, connectServerArgs...) +} + +// A Client is an WMI query client. +// +// Its zero value (DefaultClient) is a usable client. +type Client struct { + // NonePtrZero specifies if nil values for fields which aren't pointers + // should be returned as the field types zero value. + // + // Setting this to true allows stucts without pointer fields to be used + // without the risk failure should a nil value returned from WMI. + NonePtrZero bool + + // PtrNil specifies if nil values for pointer fields should be returned + // as nil. + // + // Setting this to true will set pointer fields to nil where WMI + // returned nil, otherwise the types zero value will be returned. + PtrNil bool + + // AllowMissingFields specifies that struct fields not present in the + // query result should not result in an error. + // + // Setting this to true allows custom queries to be used with full + // struct definitions instead of having to define multiple structs. + AllowMissingFields bool +} + +// DefaultClient is the default Client and is used by Query, QueryNamespace +var DefaultClient = &Client{} + +// Query runs the WQL query and appends the values to dst. +// +// dst must have type *[]S or *[]*S, for some struct type S. Fields selected in +// the query must have the same name in dst. Supported types are all signed and +// unsigned integers, time.Time, string, bool, or a pointer to one of those. +// Array types are not supported. +// +// By default, the local machine and default namespace are used. These can be +// changed using connectServerArgs. See +// http://msdn.microsoft.com/en-us/library/aa393720.aspx for details. +func (c *Client) Query(query string, dst interface{}, connectServerArgs ...interface{}) error { + dv := reflect.ValueOf(dst) + if dv.Kind() != reflect.Ptr || dv.IsNil() { + return ErrInvalidEntityType + } + dv = dv.Elem() + mat, elemType := checkMultiArg(dv) + if mat == multiArgTypeInvalid { + return ErrInvalidEntityType + } + + lock.Lock() + defer lock.Unlock() + runtime.LockOSThread() + defer runtime.UnlockOSThread() + + err := ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED) + if err != nil { + oleerr := err.(*ole.OleError) + // S_FALSE = 0x00000001 // CoInitializeEx was already called on this thread + if oleerr.Code() != ole.S_OK && oleerr.Code() != 0x00000001 { + return err + } + } else { + // Only invoke CoUninitialize if the thread was not initizlied before. + // This will allow other go packages based on go-ole play along + // with this library. + defer ole.CoUninitialize() + } + + unknown, err := oleutil.CreateObject("WbemScripting.SWbemLocator") + if err != nil { + return err + } + defer unknown.Release() + + wmi, err := unknown.QueryInterface(ole.IID_IDispatch) + if err != nil { + return err + } + defer wmi.Release() + + // service is a SWbemServices + serviceRaw, err := oleutil.CallMethod(wmi, "ConnectServer", connectServerArgs...) + if err != nil { + return err + } + service := serviceRaw.ToIDispatch() + defer serviceRaw.Clear() + + // result is a SWBemObjectSet + resultRaw, err := oleutil.CallMethod(service, "ExecQuery", query) + if err != nil { + return err + } + result := resultRaw.ToIDispatch() + defer resultRaw.Clear() + + count, err := oleInt64(result, "Count") + if err != nil { + return err + } + + // Initialize a slice with Count capacity + dv.Set(reflect.MakeSlice(dv.Type(), 0, int(count))) + + var errFieldMismatch error + for i := int64(0); i < count; i++ { + err := func() error { + // item is a SWbemObject, but really a Win32_Process + itemRaw, err := oleutil.CallMethod(result, "ItemIndex", i) + if err != nil { + return err + } + item := itemRaw.ToIDispatch() + defer itemRaw.Clear() + + ev := reflect.New(elemType) + if err = c.loadEntity(ev.Interface(), item); err != nil { + if _, ok := err.(*ErrFieldMismatch); ok { + // We continue loading entities even in the face of field mismatch errors. + // If we encounter any other error, that other error is returned. Otherwise, + // an ErrFieldMismatch is returned. + errFieldMismatch = err + } else { + return err + } + } + if mat != multiArgTypeStructPtr { + ev = ev.Elem() + } + dv.Set(reflect.Append(dv, ev)) + return nil + }() + if err != nil { + return err + } + } + return errFieldMismatch +} + +// ErrFieldMismatch is returned when a field is to be loaded into a different +// type than the one it was stored from, or when a field is missing or +// unexported in the destination struct. +// StructType is the type of the struct pointed to by the destination argument. +type ErrFieldMismatch struct { + StructType reflect.Type + FieldName string + Reason string +} + +func (e *ErrFieldMismatch) Error() string { + return fmt.Sprintf("wmi: cannot load field %q into a %q: %s", + e.FieldName, e.StructType, e.Reason) +} + +var timeType = reflect.TypeOf(time.Time{}) + +// loadEntity loads a SWbemObject into a struct pointer. +func (c *Client) loadEntity(dst interface{}, src *ole.IDispatch) (errFieldMismatch error) { + v := reflect.ValueOf(dst).Elem() + for i := 0; i < v.NumField(); i++ { + f := v.Field(i) + of := f + isPtr := f.Kind() == reflect.Ptr + if isPtr { + ptr := reflect.New(f.Type().Elem()) + f.Set(ptr) + f = f.Elem() + } + n := v.Type().Field(i).Name + if !f.CanSet() { + return &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: "CanSet() is false", + } + } + prop, err := oleutil.GetProperty(src, n) + if err != nil { + if !c.AllowMissingFields { + errFieldMismatch = &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: "no such struct field", + } + } + continue + } + defer prop.Clear() + + switch val := prop.Value().(type) { + case int8, int16, int32, int64, int: + v := reflect.ValueOf(val).Int() + switch f.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + f.SetInt(v) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + f.SetUint(uint64(v)) + default: + return &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: "not an integer class", + } + } + case uint8, uint16, uint32, uint64: + v := reflect.ValueOf(val).Uint() + switch f.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + f.SetInt(int64(v)) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + f.SetUint(v) + default: + return &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: "not an integer class", + } + } + case string: + switch f.Kind() { + case reflect.String: + f.SetString(val) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + iv, err := strconv.ParseInt(val, 10, 64) + if err != nil { + return err + } + f.SetInt(iv) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + uv, err := strconv.ParseUint(val, 10, 64) + if err != nil { + return err + } + f.SetUint(uv) + case reflect.Struct: + switch f.Type() { + case timeType: + if len(val) == 25 { + mins, err := strconv.Atoi(val[22:]) + if err != nil { + return err + } + val = val[:22] + fmt.Sprintf("%02d%02d", mins/60, mins%60) + } + t, err := time.Parse("20060102150405.000000-0700", val) + if err != nil { + return err + } + f.Set(reflect.ValueOf(t)) + } + } + case bool: + switch f.Kind() { + case reflect.Bool: + f.SetBool(val) + default: + return &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: "not a bool", + } + } + default: + typeof := reflect.TypeOf(val) + if typeof == nil && (isPtr || c.NonePtrZero) { + if (isPtr && c.PtrNil) || (!isPtr && c.NonePtrZero) { + of.Set(reflect.Zero(of.Type())) + } + break + } + return &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: fmt.Sprintf("unsupported type (%T)", val), + } + } + } + return errFieldMismatch +} + +type multiArgType int + +const ( + multiArgTypeInvalid multiArgType = iota + multiArgTypeStruct + multiArgTypeStructPtr +) + +// checkMultiArg checks that v has type []S, []*S for some struct type S. +// +// It returns what category the slice's elements are, and the reflect.Type +// that represents S. +func checkMultiArg(v reflect.Value) (m multiArgType, elemType reflect.Type) { + if v.Kind() != reflect.Slice { + return multiArgTypeInvalid, nil + } + elemType = v.Type().Elem() + switch elemType.Kind() { + case reflect.Struct: + return multiArgTypeStruct, elemType + case reflect.Ptr: + elemType = elemType.Elem() + if elemType.Kind() == reflect.Struct { + return multiArgTypeStructPtr, elemType + } + } + return multiArgTypeInvalid, nil +} + +func oleInt64(item *ole.IDispatch, prop string) (int64, error) { + v, err := oleutil.GetProperty(item, prop) + if err != nil { + return 0, err + } + defer v.Clear() + + i := int64(v.Val) + return i, nil +} + +// CreateQuery returns a WQL query string that queries all columns of src. where +// is an optional string that is appended to the query, to be used with WHERE +// clauses. In such a case, the "WHERE" string should appear at the beginning. +func CreateQuery(src interface{}, where string) string { + var b bytes.Buffer + b.WriteString("SELECT ") + s := reflect.Indirect(reflect.ValueOf(src)) + t := s.Type() + if s.Kind() == reflect.Slice { + t = t.Elem() + } + if t.Kind() != reflect.Struct { + return "" + } + var fields []string + for i := 0; i < t.NumField(); i++ { + fields = append(fields, t.Field(i).Name) + } + b.WriteString(strings.Join(fields, ", ")) + b.WriteString(" FROM ") + b.WriteString(t.Name()) + b.WriteString(" " + where) + return b.String() +} diff --git a/vendor/github.com/anacrolix/dht/LICENSE b/vendor/github.com/anacrolix/dht/LICENSE new file mode 100644 index 000000000..be2cc4dfb --- /dev/null +++ b/vendor/github.com/anacrolix/dht/LICENSE @@ -0,0 +1,362 @@ +Mozilla Public License, version 2.0 + +1. Definitions + +1.1. "Contributor" + + means each individual or legal entity that creates, contributes to the + creation of, or owns Covered Software. + +1.2. "Contributor Version" + + means the combination of the Contributions of others (if any) used by a + Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + + means Source Code Form to which the initial Contributor has attached the + notice in Exhibit A, the Executable Form of such Source Code Form, and + Modifications of such Source Code Form, in each case including portions + thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + a. that the initial Contributor has attached the notice described in + Exhibit B to the Covered Software; or + + b. that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the terms of + a Secondary License. + +1.6. "Executable Form" + + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + + means a work that combines Covered Software with other material, in a + separate file or files, that is not Covered Software. + +1.8. "License" + + means this document. + +1.9. "Licensable" + + means having the right to grant, to the maximum extent possible, whether + at the time of the initial grant or subsequently, any and all of the + rights conveyed by this License. + +1.10. "Modifications" + + means any of the following: + + a. any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered Software; or + + b. any new file in Source Code Form that contains any Covered Software. + +1.11. "Patent Claims" of a Contributor + + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the License, + by the making, using, selling, offering for sale, having made, import, + or transfer of either its Contributions or its Contributor Version. + +1.12. "Secondary License" + + means either the GNU General Public License, Version 2.0, the GNU Lesser + General Public License, Version 2.1, the GNU Affero General Public + License, Version 3.0, or any later versions of those licenses. + +1.13. "Source Code Form" + + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that controls, is + controlled by, or is under common control with You. For purposes of this + definition, "control" means (a) the power, direct or indirect, to cause + the direction or management of such entity, whether by contract or + otherwise, or (b) ownership of more than fifty percent (50%) of the + outstanding shares or beneficial ownership of such entity. + + +2. License Grants and Conditions + +2.1. Grants + + Each Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + a. under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + + b. under Patent Claims of such Contributor to make, use, sell, offer for + sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + + The licenses granted in Section 2.1 with respect to any Contribution + become effective for each Contribution on the date the Contributor first + distributes such Contribution. + +2.3. Limitations on Grant Scope + + The licenses granted in this Section 2 are the only rights granted under + this License. No additional rights or licenses will be implied from the + distribution or licensing of Covered Software under this License. + Notwithstanding Section 2.1(b) above, no patent license is granted by a + Contributor: + + a. for any code that a Contributor has removed from Covered Software; or + + b. for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + + c. under Patent Claims infringed by Covered Software in the absence of + its Contributions. + + This License does not grant any rights in the trademarks, service marks, + or logos of any Contributor (except as may be necessary to comply with + the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + + No Contributor makes additional grants as a result of Your choice to + distribute the Covered Software under a subsequent version of this + License (see Section 10.2) or under the terms of a Secondary License (if + permitted under the terms of Section 3.3). + +2.5. Representation + + Each Contributor represents that the Contributor believes its + Contributions are its original creation(s) or it has sufficient rights to + grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + + This License is not intended to limit any rights You have under + applicable copyright doctrines of fair use, fair dealing, or other + equivalents. + +2.7. Conditions + + Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in + Section 2.1. + + +3. Responsibilities + +3.1. Distribution of Source Form + + All distribution of Covered Software in Source Code Form, including any + Modifications that You create or to which You contribute, must be under + the terms of this License. You must inform recipients that the Source + Code Form of the Covered Software is governed by the terms of this + License, and how they can obtain a copy of this License. You may not + attempt to alter or restrict the recipients' rights in the Source Code + Form. + +3.2. Distribution of Executable Form + + If You distribute Covered Software in Executable Form then: + + a. such Covered Software must also be made available in Source Code Form, + as described in Section 3.1, and You must inform recipients of the + Executable Form how they can obtain a copy of such Source Code Form by + reasonable means in a timely manner, at a charge no more than the cost + of distribution to the recipient; and + + b. You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter the + recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + + You may create and distribute a Larger Work under terms of Your choice, + provided that You also comply with the requirements of this License for + the Covered Software. If the Larger Work is a combination of Covered + Software with a work governed by one or more Secondary Licenses, and the + Covered Software is not Incompatible With Secondary Licenses, this + License permits You to additionally distribute such Covered Software + under the terms of such Secondary License(s), so that the recipient of + the Larger Work may, at their option, further distribute the Covered + Software under the terms of either this License or such Secondary + License(s). + +3.4. Notices + + You may not remove or alter the substance of any license notices + (including copyright notices, patent notices, disclaimers of warranty, or + limitations of liability) contained within the Source Code Form of the + Covered Software, except that You may alter any license notices to the + extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + + You may choose to offer, and to charge a fee for, warranty, support, + indemnity or liability obligations to one or more recipients of Covered + Software. However, You may do so only on Your own behalf, and not on + behalf of any Contributor. You must make it absolutely clear that any + such warranty, support, indemnity, or liability obligation is offered by + You alone, and You hereby agree to indemnify every Contributor for any + liability incurred by such Contributor as a result of warranty, support, + indemnity or liability terms You offer. You may include additional + disclaimers of warranty and limitations of liability specific to any + jurisdiction. + +4. Inability to Comply Due to Statute or Regulation + + If it is impossible for You to comply with any of the terms of this License + with respect to some or all of the Covered Software due to statute, + judicial order, or regulation then You must: (a) comply with the terms of + this License to the maximum extent possible; and (b) describe the + limitations and the code they affect. Such description must be placed in a + text file included with all distributions of the Covered Software under + this License. Except to the extent prohibited by statute or regulation, + such description must be sufficiently detailed for a recipient of ordinary + skill to be able to understand it. + +5. Termination + +5.1. The rights granted under this License will terminate automatically if You + fail to comply with any of its terms. However, if You become compliant, + then the rights granted under this License from a particular Contributor + are reinstated (a) provisionally, unless and until such Contributor + explicitly and finally terminates Your grants, and (b) on an ongoing + basis, if such Contributor fails to notify You of the non-compliance by + some reasonable means prior to 60 days after You have come back into + compliance. Moreover, Your grants from a particular Contributor are + reinstated on an ongoing basis if such Contributor notifies You of the + non-compliance by some reasonable means, this is the first time You have + received notice of non-compliance with this License from such + Contributor, and You become compliant prior to 30 days after Your receipt + of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent + infringement claim (excluding declaratory judgment actions, + counter-claims, and cross-claims) alleging that a Contributor Version + directly or indirectly infringes any patent, then the rights granted to + You by any and all Contributors for the Covered Software under Section + 2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user + license agreements (excluding distributors and resellers) which have been + validly granted by You or Your distributors under this License prior to + termination shall survive termination. + +6. Disclaimer of Warranty + + Covered Software is provided under this License on an "as is" basis, + without warranty of any kind, either expressed, implied, or statutory, + including, without limitation, warranties that the Covered Software is free + of defects, merchantable, fit for a particular purpose or non-infringing. + The entire risk as to the quality and performance of the Covered Software + is with You. Should any Covered Software prove defective in any respect, + You (not any Contributor) assume the cost of any necessary servicing, + repair, or correction. This disclaimer of warranty constitutes an essential + part of this License. No use of any Covered Software is authorized under + this License except under this disclaimer. + +7. Limitation of Liability + + Under no circumstances and under no legal theory, whether tort (including + negligence), contract, or otherwise, shall any Contributor, or anyone who + distributes Covered Software as permitted above, be liable to You for any + direct, indirect, special, incidental, or consequential damages of any + character including, without limitation, damages for lost profits, loss of + goodwill, work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses, even if such party shall have been + informed of the possibility of such damages. This limitation of liability + shall not apply to liability for death or personal injury resulting from + such party's negligence to the extent applicable law prohibits such + limitation. Some jurisdictions do not allow the exclusion or limitation of + incidental or consequential damages, so this exclusion and limitation may + not apply to You. + +8. Litigation + + Any litigation relating to this License may be brought only in the courts + of a jurisdiction where the defendant maintains its principal place of + business and such litigation shall be governed by laws of that + jurisdiction, without reference to its conflict-of-law provisions. Nothing + in this Section shall prevent a party's ability to bring cross-claims or + counter-claims. + +9. Miscellaneous + + This License represents the complete agreement concerning the subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. Any law or regulation which provides that + the language of a contract shall be construed against the drafter shall not + be used to construe this License against a Contributor. + + +10. Versions of the License + +10.1. New Versions + + Mozilla Foundation is the license steward. Except as provided in Section + 10.3, no one other than the license steward has the right to modify or + publish new versions of this License. Each version will be given a + distinguishing version number. + +10.2. Effect of New Versions + + You may distribute the Covered Software under the terms of the version + of the License under which You originally received the Covered Software, + or under the terms of any subsequent version published by the license + steward. + +10.3. Modified Versions + + If you create software not governed by this License, and you want to + create a new license for such software, you may create and use a + modified version of this License if you rename the license and remove + any references to the name of the license steward (except to note that + such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary + Licenses If You choose to distribute Source Code Form that is + Incompatible With Secondary Licenses under the terms of this version of + the License, the notice described in Exhibit B of this License must be + attached. + +Exhibit A - Source Code Form License Notice + + This Source Code Form is subject to the + terms of the Mozilla Public License, v. + 2.0. If a copy of the MPL was not + distributed with this file, You can + obtain one at + http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular file, +then You may include the notice in a location (such as a LICENSE file in a +relevant directory) where a recipient would be likely to look for such a +notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice + + This Source Code Form is "Incompatible + With Secondary Licenses", as defined by + the Mozilla Public License, v. 2.0. diff --git a/vendor/github.com/anacrolix/dht/README.md b/vendor/github.com/anacrolix/dht/README.md new file mode 100644 index 000000000..705ff47dc --- /dev/null +++ b/vendor/github.com/anacrolix/dht/README.md @@ -0,0 +1,25 @@ +# dht + +[![CircleCI](https://circleci.com/gh/anacrolix/dht.svg?style=shield)](https://circleci.com/gh/anacrolix/dht) +[![GoDoc](https://godoc.org/github.com/anacrolix/dht?status.svg)](https://godoc.org/github.com/anacrolix/dht) +[![Join the chat at https://gitter.im/anacrolix/torrent](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/anacrolix/torrent?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +## Installation + +Install the library package with `go get github.com/anacrolix/dht`, or the provided cmds with `go get github.com/anacrolix/dht/cmd/...`. + +## Commands + +Here I'll describe what some of the provided commands in `./cmd` do. + +Note that the [`godo`](https://github.com/anacrolix/godo) command which is invoked in the following examples builds and executes a Go import path, like `go run`. It's easier to use this convention than to spell out the install/invoke cycle for every single example. + +### dht-ping + +Pings DHT nodes with the given network addresses. + + $ godo ./cmd/dht-ping router.bittorrent.com:6881 router.utorrent.com:6881 + 2015/04/01 17:21:23 main.go:33: dht server on [::]:60058 + 32f54e697351ff4aec29cdbaabf2fbe3467cc267 (router.bittorrent.com:6881): 648.218621ms + ebff36697351ff4aec29cdbaabf2fbe3467cc267 (router.utorrent.com:6881): 873.864706ms + 2/2 responses (100.000000%) diff --git a/vendor/github.com/anacrolix/dht/announce.go b/vendor/github.com/anacrolix/dht/announce.go index 4c033111a..26e7fb7d0 100644 --- a/vendor/github.com/anacrolix/dht/announce.go +++ b/vendor/github.com/anacrolix/dht/announce.go @@ -3,8 +3,6 @@ package dht // get_peers and announce_peers. import ( - "errors" - "log" "time" "github.com/anacrolix/sync" @@ -31,7 +29,7 @@ type Announce struct { // How many transactions are still ongoing. pending int server *Server - infoHash string + infoHash int160 // Count of (probably) distinct addresses we've sent get_peers requests // to. numContacted int @@ -49,38 +47,28 @@ func (a *Announce) NumContacted() int { return a.numContacted } +func newBloomFilterForTraversal() *bloom.BloomFilter { + return bloom.NewWithEstimates(1000, 0.5) +} + // This is kind of the main thing you want to do with DHT. It traverses the // graph toward nodes that store peers for the infohash, streaming them to the // caller, and announcing the local node to each node if allowed and // specified. func (s *Server) Announce(infoHash [20]byte, port int, impliedPort bool) (*Announce, error) { - startAddrs := func() (ret []Addr) { - s.mu.Lock() - defer s.mu.Unlock() - for _, n := range s.closestGoodNodes(160, string(infoHash[:])) { - ret = append(ret, n.addr) - } - return - }() - if len(startAddrs) == 0 && !s.config.NoDefaultBootstrap { - addrs, err := bootstrapAddrs(s.bootstrapNodes) - if err != nil { - return nil, err - } - for _, addr := range addrs { - startAddrs = append(startAddrs, NewAddr(addr)) - } - } - if len(startAddrs) == 0 { - return nil, errors.New("server has no starting nodes") + s.mu.Lock() + defer s.mu.Unlock() + startAddrs, err := s.traversalStartingAddrs() + if err != nil { + return nil, err } disc := &Announce{ Peers: make(chan PeersValues, 100), stop: make(chan struct{}), values: make(chan PeersValues), - triedAddrs: bloom.NewWithEstimates(1000, 0.5), + triedAddrs: newBloomFilterForTraversal(), server: s, - infoHash: string(infoHash[:]), + infoHash: int160FromByteArray(infoHash), announcePort: port, announcePortImplied: impliedPort, } @@ -142,12 +130,6 @@ func (a *Announce) gotNodeAddr(addr Addr) { if a.server.ipBlocked(addr.UDPAddr().IP) { return } - a.server.mu.Lock() - if a.server.badNodes.Test([]byte(addr.String())) { - a.server.mu.Unlock() - return - } - a.server.mu.Unlock() a.contact(addr) } @@ -156,7 +138,6 @@ func (a *Announce) contact(addr Addr) { a.numContacted++ a.triedAddrs.Add([]byte(addr.String())) if err := a.getPeers(addr); err != nil { - log.Printf("error sending get_peers request to %s: %#v", addr, err) return } a.pending++ @@ -177,23 +158,14 @@ func (a *Announce) responseNode(node krpc.NodeInfo) { a.gotNodeAddr(NewAddr(node.Addr)) } -func (a *Announce) closingCh() chan struct{} { - return a.stop -} - // Announce to a peer, if appropriate. -func (a *Announce) maybeAnnouncePeer(to Addr, token, peerId string) { +func (a *Announce) maybeAnnouncePeer(to Addr, token string, peerId [20]byte) { + if !a.server.config.NoSecurity && !NodeIdSecure(peerId, to.UDPAddr().IP) { + return + } a.server.mu.Lock() defer a.server.mu.Unlock() - if !a.server.config.NoSecurity { - if len(peerId) != 20 { - return - } - if !NodeIdSecure(peerId, to.UDPAddr().IP) { - return - } - } - err := a.server.announcePeer(to, a.infoHash, a.announcePort, token, a.announcePortImplied) + err := a.server.announcePeer(to, a.infoHash, a.announcePort, token, a.announcePortImplied, nil) if err != nil { logonce.Stderr.Printf("error announcing peer: %s", err) } @@ -202,11 +174,7 @@ func (a *Announce) maybeAnnouncePeer(to Addr, token, peerId string) { func (a *Announce) getPeers(addr Addr) error { a.server.mu.Lock() defer a.server.mu.Unlock() - t, err := a.server.getPeers(addr, a.infoHash) - if err != nil { - return err - } - t.SetResponseHandler(func(m krpc.Msg, ok bool) { + return a.server.getPeers(addr, a.infoHash, func(m krpc.Msg, err error) { // Register suggested nodes closer to the target info-hash. if m.R != nil { a.mu.Lock() @@ -217,9 +185,9 @@ func (a *Announce) getPeers(addr Addr) error { if vs := m.R.Values; len(vs) != 0 { nodeInfo := krpc.NodeInfo{ - Addr: t.remoteAddr.UDPAddr(), + Addr: addr.UDPAddr(), + ID: *m.SenderID(), } - copy(nodeInfo.ID[:], m.SenderID()) select { case a.values <- PeersValues{ Peers: func() (ret []Peer) { @@ -234,14 +202,13 @@ func (a *Announce) getPeers(addr Addr) error { } } - a.maybeAnnouncePeer(addr, m.R.Token, m.SenderID()) + a.maybeAnnouncePeer(addr, m.R.Token, *m.SenderID()) } a.mu.Lock() a.transactionClosed() a.mu.Unlock() }) - return nil } // Corresponds to the "values" key in a get_peers KRPC response. A list of diff --git a/vendor/github.com/anacrolix/dht/announce_test.go b/vendor/github.com/anacrolix/dht/announce_test.go deleted file mode 100644 index 2effe9c0c..000000000 --- a/vendor/github.com/anacrolix/dht/announce_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package dht - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestAnnounceNoStartingNodes(t *testing.T) { - s, err := NewServer(&ServerConfig{ - NoDefaultBootstrap: true, - }) - require.NoError(t, err) - defer s.Close() - var ih [20]byte - copy(ih[:], "blah") - _, err = s.Announce(ih, 0, true) - require.EqualError(t, err, "server has no starting nodes") -} diff --git a/vendor/github.com/anacrolix/dht/bitcount_test.go b/vendor/github.com/anacrolix/dht/bitcount_test.go deleted file mode 100644 index 05f7d8b85..000000000 --- a/vendor/github.com/anacrolix/dht/bitcount_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package dht - -// TODO: The bitcounting is a relic of the old and incorrect distance -// calculation. It is still useful in some tests but should eventually be -// replaced with actual distances. - -// How many bits? -func bitCount(b []byte) int { - var count int = 0 - for _, c := range b { - count += int(bitCounts[c]) - } - return count -} - -// The bit counts for each byte value (0 - 255). -var bitCounts = []int8{ - // Generated by Java BitCount of all values from 0 to 255 - 0, 1, 1, 2, 1, 2, 2, 3, - 1, 2, 2, 3, 2, 3, 3, 4, - 1, 2, 2, 3, 2, 3, 3, 4, - 2, 3, 3, 4, 3, 4, 4, 5, - 1, 2, 2, 3, 2, 3, 3, 4, - 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, - 3, 4, 4, 5, 4, 5, 5, 6, - 1, 2, 2, 3, 2, 3, 3, 4, - 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, - 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, - 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, - 4, 5, 5, 6, 5, 6, 6, 7, - 1, 2, 2, 3, 2, 3, 3, 4, - 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, - 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, - 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, - 4, 5, 5, 6, 5, 6, 6, 7, - 2, 3, 3, 4, 3, 4, 4, 5, - 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, - 4, 5, 5, 6, 5, 6, 6, 7, - 3, 4, 4, 5, 4, 5, 5, 6, - 4, 5, 5, 6, 5, 6, 6, 7, - 4, 5, 5, 6, 5, 6, 6, 7, - 5, 6, 6, 7, 6, 7, 7, 8, -} diff --git a/vendor/github.com/anacrolix/dht/bucket.go b/vendor/github.com/anacrolix/dht/bucket.go new file mode 100644 index 000000000..82a28ab3b --- /dev/null +++ b/vendor/github.com/anacrolix/dht/bucket.go @@ -0,0 +1,37 @@ +package dht + +type bucket struct { + nodes map[*node]struct{} +} + +func (b *bucket) Len() int { + return len(b.nodes) +} + +func (b *bucket) EachNode(f func(*node) bool) bool { + for n := range b.nodes { + if !f(n) { + return false + } + } + return true +} + +func (b *bucket) AddNode(n *node, k int) { + if _, ok := b.nodes[n]; ok { + return + } + if b.nodes == nil { + b.nodes = make(map[*node]struct{}, k) + } + b.nodes[n] = struct{}{} +} + +func (b *bucket) GetNode(addr Addr, id int160) *node { + for n := range b.nodes { + if n.hasAddrAndID(addr, id) { + return n + } + } + return nil +} diff --git a/vendor/github.com/anacrolix/dht/closest_nodes.go b/vendor/github.com/anacrolix/dht/closest_nodes.go deleted file mode 100644 index 5024d1ff6..000000000 --- a/vendor/github.com/anacrolix/dht/closest_nodes.go +++ /dev/null @@ -1,51 +0,0 @@ -package dht - -import ( - "container/heap" - "encoding/hex" - "fmt" - - "github.com/anacrolix/missinggo/container/xheap" - "github.com/anacrolix/missinggo/iter" -) - -type nodeIDAndDistance struct { - nodeID nodeID - distance int160 -} - -func (me nodeIDAndDistance) String() string { - return fmt.Sprintf("%s: %q", hex.EncodeToString(me.distance.Bytes()), me.nodeID) -} - -type kClosestNodeIDs struct { - sl []interface{} - target nodeID - h heap.Interface - k int -} - -func (me *kClosestNodeIDs) Push(id nodeID) { - d := me.target.Distance(&id) - heap.Push(me.h, nodeIDAndDistance{id, d}) - if me.h.Len() > me.k { - heap.Pop(me.h) - } -} - -func newKClosestNodeIDs(k int, target nodeID) (ret *kClosestNodeIDs) { - ret = &kClosestNodeIDs{ - target: target, - k: k, - } - ret.h = xheap.Slice(&ret.sl, func(l, r interface{}) bool { - return l.(nodeIDAndDistance).distance.Cmp(r.(nodeIDAndDistance).distance) > 0 - }) - return -} - -func (me *kClosestNodeIDs) IDs() iter.Iterator { - return iter.Map(iter.Slice(me.sl), func(i interface{}) interface{} { - return i.(nodeIDAndDistance).nodeID - }) -} diff --git a/vendor/github.com/anacrolix/dht/dht.go b/vendor/github.com/anacrolix/dht/dht.go index 6b927a9d7..60e305e85 100644 --- a/vendor/github.com/anacrolix/dht/dht.go +++ b/vendor/github.com/anacrolix/dht/dht.go @@ -1,6 +1,7 @@ package dht import ( + "crypto" _ "crypto/sha1" "errors" "math/rand" @@ -8,19 +9,16 @@ import ( "strconv" "time" + "github.com/anacrolix/missinggo" "github.com/anacrolix/torrent/iplist" "github.com/anacrolix/torrent/metainfo" "github.com/anacrolix/dht/krpc" ) -const ( - maxNodes = 320 -) - -var ( - queryResendEvery = 5 * time.Second -) +func defaultQueryResendDelay() time.Duration { + return jitterDuration(5*time.Second, time.Second) +} // Uniquely identifies a transaction to us. type transactionKey struct { @@ -31,25 +29,13 @@ type transactionKey struct { // ServerConfig allows to set up a configuration of the `Server` instance // to be created with NewServer type ServerConfig struct { - // Listen address. Used if Conn is nil. - Addr string - - // Set NodeId Manually. Caller must ensure that, if NodeId does not - // conform to DHT Security Extensions, that NoSecurity is also set. This - // should be given as a HEX string. - NodeIdHex string - - Conn net.PacketConn + // Set NodeId Manually. Caller must ensure that if NodeId does not conform + // to DHT Security Extensions, that NoSecurity is also set. + NodeId [20]byte + Conn net.PacketConn // Don't respond to queries from other nodes. - Passive bool - // DHT Bootstrap nodes - BootstrapNodes []string - // Disable bootstrapping from global servers even if given no BootstrapNodes. - // This creates a solitary node that awaits other nodes; it's only useful if - // you're creating your own DHT and want to avoid accidental crossover, without - // spoofing a bootstrap node and filling your logs with connection errors. - NoDefaultBootstrap bool - + Passive bool + StartingNodes func() ([]Addr, error) // Disable the DHT security extension: // http://www.libtorrent.org/dht_sec.html. NoSecurity bool @@ -66,6 +52,9 @@ type ServerConfig struct { OnQuery func(query *krpc.Msg, source net.Addr) (propagate bool) // Called when a peer successfully announces to us. OnAnnouncePeer func(infoHash metainfo.Hash, peer Peer) + // How long to wait before resending queries that haven't received a + // response. Defaults to a random value between 4.5 and 5.5s. + QueryResendDelay func() time.Duration } // ServerStats instance is returned by Server.Stats() and stores Server metrics @@ -83,71 +72,6 @@ type ServerStats struct { BadNodes uint } -func makeSocket(addr string) (socket *net.UDPConn, err error) { - addr_, err := net.ResolveUDPAddr("", addr) - if err != nil { - return - } - socket, err = net.ListenUDP("udp", addr_) - return -} - -type node struct { - addr Addr - id nodeID - announceToken string - - lastGotQuery time.Time - lastGotResponse time.Time - lastSentQuery time.Time -} - -func (n *node) IsSecure() bool { - if !n.id.IsSet() { - return false - } - return NodeIdSecure(n.id.ByteString(), n.addr.UDPAddr().IP) -} - -func (n *node) idString() string { - return n.id.ByteString() -} - -func (n *node) SetIDFromBytes(b []byte) { - n.id.SetFromBytes(b) -} - -func (n *node) SetIDFromString(s string) { - n.SetIDFromBytes([]byte(s)) -} - -func (n *node) IDNotSet() bool { - return !n.id.IsSet() -} - -func (n *node) NodeInfo() (ret krpc.NodeInfo) { - ret.Addr = n.addr.UDPAddr() - if n := copy(ret.ID[:], n.idString()); n != 20 { - panic(n) - } - return -} - -func (n *node) DefinitelyGood() bool { - if !n.id.IsSet() { - return false - } - // No reason to think ill of them if they've never been queried. - if n.lastSentQuery.IsZero() { - return true - } - // They answered our last query. - if n.lastSentQuery.Before(n.lastGotResponse) { - return true - } - return true -} - func jitterDuration(average time.Duration, plusMinus time.Duration) time.Duration { return average - plusMinus/2 + time.Duration(rand.Int63n(int64(plusMinus))) } @@ -161,23 +85,34 @@ func (p *Peer) String() string { return net.JoinHostPort(p.IP.String(), strconv.FormatInt(int64(p.Port), 10)) } -func bootstrapAddrs(nodeAddrs []string) (addrs []*net.UDPAddr, err error) { - bootstrapNodes := nodeAddrs - if len(bootstrapNodes) == 0 { - bootstrapNodes = []string{ - "router.utorrent.com:6881", - "router.bittorrent.com:6881", - } - } - for _, addrStr := range bootstrapNodes { - udpAddr, err := net.ResolveUDPAddr("udp4", addrStr) +func GlobalBootstrapAddrs() (addrs []Addr, err error) { + for _, s := range []string{ + "router.utorrent.com:6881", + "router.bittorrent.com:6881", + "dht.transmissionbt.com:6881", + "dht.aelitis.com:6881", // Vuze + } { + ua, err := net.ResolveUDPAddr("udp4", s) if err != nil { continue } - addrs = append(addrs, udpAddr) + addrs = append(addrs, NewAddr(ua)) } if len(addrs) == 0 { err = errors.New("nothing resolved") } return } + +func RandomNodeID() (id [20]byte) { + rand.Read(id[:]) + return +} + +func MakeDeterministicNodeID(public net.Addr) (id [20]byte) { + h := crypto.SHA1.New() + h.Write([]byte(public.String())) + h.Sum(id[:0:20]) + SecureNodeId(&id, missinggo.AddrIP(public)) + return +} diff --git a/vendor/github.com/anacrolix/dht/dht_test.go b/vendor/github.com/anacrolix/dht/dht_test.go deleted file mode 100644 index b1f869beb..000000000 --- a/vendor/github.com/anacrolix/dht/dht_test.go +++ /dev/null @@ -1,234 +0,0 @@ -package dht - -import ( - "encoding/hex" - "log" - "math/big" - "math/rand" - "net" - "testing" - "time" - - _ "github.com/anacrolix/envpprof" - "github.com/anacrolix/missinggo/iter" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/anacrolix/dht/krpc" -) - -func TestSetNilBigInt(t *testing.T) { - i := new(big.Int) - i.SetBytes(make([]byte, 2)) -} - -func TestMarshalCompactNodeInfo(t *testing.T) { - cni := krpc.NodeInfo{ - ID: [20]byte{'a', 'b', 'c'}, - } - addr, err := net.ResolveUDPAddr("udp4", "1.2.3.4:5") - require.NoError(t, err) - cni.Addr = addr - var b [krpc.CompactIPv4NodeInfoLen]byte - err = cni.PutCompact(b[:]) - require.NoError(t, err) - var bb [26]byte - copy(bb[:], []byte("abc")) - copy(bb[20:], []byte("\x01\x02\x03\x04\x00\x05")) - assert.EqualValues(t, bb, b) -} - -func recoverPanicOrDie(t *testing.T, f func()) { - defer func() { - r := recover() - if r == nil { - t.Fatal("expected panic") - } - }() - f() -} - -const zeroID = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" - -var testIDs []nodeID - -func init() { - log.SetFlags(log.Flags() | log.Lshortfile) - for _, s := range []string{ - zeroID, - "\x03" + zeroID[1:], - "\x03" + zeroID[1:18] + "\x55\xf0", - "\x55" + zeroID[1:17] + "\xff\x55\x0f", - "\x54" + zeroID[1:18] + "\x50\x0f", - } { - testIDs = append(testIDs, nodeIDFromString(s)) - } - testIDs = append(testIDs, nodeID{}) -} - -func TestDistances(t *testing.T) { - expectBitcount := func(i int160, count int) { - if bitCount(i.Bytes()) != count { - t.Fatalf("expected bitcount of %d: got %d", count, bitCount(i.Bytes())) - } - } - expectBitcount(testIDs[3].Distance(&testIDs[0]), 4+8+4+4) - expectBitcount(testIDs[3].Distance(&testIDs[1]), 4+8+4+4) - expectBitcount(testIDs[3].Distance(&testIDs[2]), 4+8+8) - var max int160 - max.SetMax() - for i := 0; i < 5; i++ { - dist := testIDs[i].Distance(&testIDs[5]) - if dist.Cmp(max) != 0 { - t.Fatal("expected max distance for comparison with unset node id") - } - } -} - -func TestMaxDistanceString(t *testing.T) { - var max int160 - max.SetMax() - require.EqualValues(t, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", max.Bytes()) -} - -func TestClosestNodes(t *testing.T) { - cn := newKClosestNodeIDs(2, testIDs[3]) - for _, i := range rand.Perm(len(testIDs)) { - cn.Push(testIDs[i]) - } - ids := iter.ToSlice(cn.IDs()) - assert.Len(t, ids, 2) - m := map[string]bool{} - for _, id := range ids { - m[id.(nodeID).ByteString()] = true - } - log.Printf("%q", m) - assert.True(t, m[testIDs[3].ByteString()]) - assert.True(t, m[testIDs[4].ByteString()]) -} - -func TestDHTDefaultConfig(t *testing.T) { - s, err := NewServer(nil) - assert.NoError(t, err) - s.Close() -} - -func TestPing(t *testing.T) { - srv, err := NewServer(&ServerConfig{ - Addr: "127.0.0.1:5680", - NoDefaultBootstrap: true, - }) - require.NoError(t, err) - defer srv.Close() - srv0, err := NewServer(&ServerConfig{ - Addr: "127.0.0.1:5681", - BootstrapNodes: []string{"127.0.0.1:5680"}, - }) - require.NoError(t, err) - defer srv0.Close() - tn, err := srv.Ping(&net.UDPAddr{ - IP: []byte{127, 0, 0, 1}, - Port: srv0.Addr().(*net.UDPAddr).Port, - }) - require.NoError(t, err) - defer tn.Close() - ok := make(chan bool) - tn.SetResponseHandler(func(msg krpc.Msg, msgOk bool) { - ok <- msg.SenderID() == srv0.ID() - }) - require.True(t, <-ok) -} - -func TestServerCustomNodeId(t *testing.T) { - customId := "5a3ce1c14e7a08645677bbd1cfe7d8f956d53256" - id, err := hex.DecodeString(customId) - assert.NoError(t, err) - // How to test custom *secure* Id when tester computers will have - // different Ids? Generate custom ids for local IPs and use mini-Id? - s, err := NewServer(&ServerConfig{ - NodeIdHex: customId, - NoDefaultBootstrap: true, - }) - require.NoError(t, err) - defer s.Close() - assert.Equal(t, string(id), s.ID()) -} - -func TestAnnounceTimeout(t *testing.T) { - if testing.Short() { - t.SkipNow() - } - s, err := NewServer(&ServerConfig{ - BootstrapNodes: []string{"1.2.3.4:5"}, - }) - require.NoError(t, err) - var ih [20]byte - copy(ih[:], "12341234123412341234") - a, err := s.Announce(ih, 0, true) - assert.NoError(t, err) - <-a.Peers - a.Close() - s.Close() -} - -func TestEqualPointers(t *testing.T) { - assert.EqualValues(t, &krpc.Msg{R: &krpc.Return{}}, &krpc.Msg{R: &krpc.Return{}}) -} - -func TestHook(t *testing.T) { - t.Log("TestHook: Starting with Ping intercept/passthrough") - srv, err := NewServer(&ServerConfig{ - Addr: "127.0.0.1:5678", - NoDefaultBootstrap: true, - }) - require.NoError(t, err) - defer srv.Close() - // Establish server with a hook attached to "ping" - hookCalled := make(chan bool) - srv0, err := NewServer(&ServerConfig{ - Addr: "127.0.0.1:5679", - BootstrapNodes: []string{"127.0.0.1:5678"}, - OnQuery: func(m *krpc.Msg, addr net.Addr) bool { - if m.Q == "ping" { - hookCalled <- true - } - return true - }, - }) - require.NoError(t, err) - defer srv0.Close() - // Ping srv0 from srv to trigger hook. Should also receive a response. - t.Log("TestHook: Servers created, hook for ping established. Calling Ping.") - tn, err := srv.Ping(&net.UDPAddr{ - IP: []byte{127, 0, 0, 1}, - Port: srv0.Addr().(*net.UDPAddr).Port, - }) - assert.NoError(t, err) - defer tn.Close() - // Await response from hooked server - tn.SetResponseHandler(func(msg krpc.Msg, b bool) { - t.Log("TestHook: Sender received response from pinged hook server, so normal execution resumed.") - }) - // Await signal that hook has been called. - select { - case <-hookCalled: - { - // Success, hook was triggered. Todo: Ensure that "ok" channel - // receives, also, indicating normal handling proceeded also. - t.Log("TestHook: Received ping, hook called and returned to normal execution!") - return - } - case <-time.After(time.Second * 1): - { - t.Error("Failed to see evidence of ping hook being called after 2 seconds.") - } - } -} - -// Check that address resolution doesn't rat out invalid SendTo addr -// arguments. -func TestResolveBadAddr(t *testing.T) { - ua, err := net.ResolveUDPAddr("udp", "0.131.255.145:33085") - require.NoError(t, err) - assert.False(t, validNodeAddr(NewAddr(ua))) -} diff --git a/vendor/github.com/anacrolix/dht/doc.go b/vendor/github.com/anacrolix/dht/doc.go index 3e65bc1d0..2ac45631f 100644 --- a/vendor/github.com/anacrolix/dht/doc.go +++ b/vendor/github.com/anacrolix/dht/doc.go @@ -1,22 +1,22 @@ // Package dht implements a Distributed Hash Table (DHT) part of -// the BitTorrent protocol, -// as specified by BEP 5: http://www.bittorrent.org/beps/bep_0005.html +// the BitTorrent protocol, +// as specified by BEP 5: http://www.bittorrent.org/beps/bep_0005.html // -// BitTorrent uses a "distributed hash table" (DHT) -// for storing peer contact information for "trackerless" torrents. -// In effect, each peer becomes a tracker. -// The protocol is based on Kademila DHT protocol and is implemented over UDP. +// BitTorrent uses a "distributed hash table" (DHT) +// for storing peer contact information for "trackerless" torrents. +// In effect, each peer becomes a tracker. +// The protocol is based on Kademila DHT protocol and is implemented over UDP. // -// Please note the terminology used to avoid confusion. -// A "peer" is a client/server listening on a TCP port that -// implements the BitTorrent protocol. -// A "node" is a client/server listening on a UDP port implementing -// the distributed hash table protocol. -// The DHT is composed of nodes and stores the location of peers. -// BitTorrent clients include a DHT node, which is used to contact other nodes -// in the DHT to get the location of peers to -// download from using the BitTorrent protocol. - -// Standard use involves creating a Server, and calling Announce on it with -// the details of your local torrent client and infohash of interest. +// Please note the terminology used to avoid confusion. +// A "peer" is a client/server listening on a TCP port that +// implements the BitTorrent protocol. +// A "node" is a client/server listening on a UDP port implementing +// the distributed hash table protocol. +// The DHT is composed of nodes and stores the location of peers. +// BitTorrent clients include a DHT node, which is used to contact other nodes +// in the DHT to get the location of peers to +// download from using the BitTorrent protocol. +// +// Standard use involves creating a Server, and calling Announce on it with +// the details of your local torrent client and infohash of interest. package dht diff --git a/vendor/github.com/anacrolix/dht/int160.go b/vendor/github.com/anacrolix/dht/int160.go index cc30b9b91..04664635a 100644 --- a/vendor/github.com/anacrolix/dht/int160.go +++ b/vendor/github.com/anacrolix/dht/int160.go @@ -1,11 +1,28 @@ package dht -import "math" +import ( + "math" + "math/big" +) type int160 struct { bits [20]uint8 } +func (me *int160) AsByteArray() [20]byte { + return me.bits +} + +func (me *int160) ByteString() string { + return string(me.bits[:]) +} + +func (me *int160) BitLen() int { + var a big.Int + a.SetBytes(me.bits[:]) + return a.BitLen() +} + func (me *int160) SetBytes(b []byte) { n := copy(me.bits[:], b) if n != 20 { @@ -39,3 +56,32 @@ func (me *int160) Xor(a, b *int160) { me.bits[i] = a.bits[i] ^ b.bits[i] } } + +func (me *int160) IsZero() bool { + for _, b := range me.bits { + if b != 0 { + return false + } + } + return true +} + +func int160FromBytes(b []byte) (ret int160) { + ret.SetBytes(b) + return +} + +func int160FromByteArray(b [20]byte) (ret int160) { + ret.SetBytes(b[:]) + return +} + +func int160FromByteString(s string) (ret int160) { + ret.SetBytes([]byte(s)) + return +} + +func distance(a, b *int160) (ret int160) { + ret.Xor(a, b) + return +} diff --git a/vendor/github.com/anacrolix/dht/krpc/error.go b/vendor/github.com/anacrolix/dht/krpc/error.go index 3196c94f4..623a09266 100644 --- a/vendor/github.com/anacrolix/dht/krpc/error.go +++ b/vendor/github.com/anacrolix/dht/krpc/error.go @@ -18,8 +18,8 @@ type Error struct { } var ( - _ bencode.Unmarshaler = &Error{} - _ bencode.Marshaler = &Error{} + _ bencode.Unmarshaler = (*Error)(nil) + _ bencode.Marshaler = (*Error)(nil) _ error = Error{} ) @@ -31,8 +31,17 @@ func (e *Error) UnmarshalBencode(_b []byte) (err error) { } switch v := _v.(type) { case []interface{}: - e.Code = int(v[0].(int64)) - e.Msg = v[1].(string) + func() { + defer func() { + r := recover() + if r == nil { + return + } + err = fmt.Errorf("unpacking %#v: %s", v, r) + }() + e.Code = int(v[0].(int64)) + e.Msg = v[1].(string) + }() case string: e.Msg = v default: diff --git a/vendor/github.com/anacrolix/dht/krpc/id.go b/vendor/github.com/anacrolix/dht/krpc/id.go new file mode 100644 index 000000000..0e746d207 --- /dev/null +++ b/vendor/github.com/anacrolix/dht/krpc/id.go @@ -0,0 +1,36 @@ +package krpc + +import ( + "fmt" + + "github.com/anacrolix/torrent/bencode" +) + +type ID [20]byte + +var _ interface { + bencode.Marshaler + bencode.Unmarshaler +} = (*ID)(nil) + +func IdFromString(s string) (id ID) { + if n := copy(id[:], s); n != 20 { + panic(n) + } + return +} + +func (id *ID) MarshalBencode() ([]byte, error) { + return []byte("20:" + string(id[:])), nil +} + +func (id *ID) UnmarshalBencode(b []byte) error { + var s string + if err := bencode.Unmarshal(b, &s); err != nil { + return err + } + if n := copy(id[:], s); n != 20 { + return fmt.Errorf("string has wrong length: %d", n) + } + return nil +} diff --git a/vendor/github.com/anacrolix/dht/krpc/msg.go b/vendor/github.com/anacrolix/dht/krpc/msg.go index 9c171497c..2ba5c9322 100644 --- a/vendor/github.com/anacrolix/dht/krpc/msg.go +++ b/vendor/github.com/anacrolix/dht/krpc/msg.go @@ -19,26 +19,27 @@ import ( // may be correlated with multiple queries to the same node. The transaction ID should be encoded as a short string of binary numbers, typically 2 characters are enough as they cover 2^16 outstanding queries. The other key contained in every KRPC message is "y" with a single character value describing the type of message. The value of the "y" key is one of "q" for query, "r" for response, or "e" for error. // 3 message types: QUERY, RESPONSE, ERROR type Msg struct { - Q string `bencode:"q,omitempty"` // Query method (one of 4: "ping", "find_node", "get_peers", "announce_peer") - A *MsgArgs `bencode:"a,omitempty"` // named arguments sent with a query - T string `bencode:"t"` // required: transaction ID - Y string `bencode:"y"` // required: type of the message: q for QUERY, r for RESPONSE, e for ERROR - R *Return `bencode:"r,omitempty"` // RESPONSE type only - E *Error `bencode:"e,omitempty"` // ERROR type only - IP util.CompactPeer `bencode:"ip,omitempty"` + Q string `bencode:"q,omitempty"` // Query method (one of 4: "ping", "find_node", "get_peers", "announce_peer") + A *MsgArgs `bencode:"a,omitempty"` // named arguments sent with a query + T string `bencode:"t"` // required: transaction ID + Y string `bencode:"y"` // required: type of the message: q for QUERY, r for RESPONSE, e for ERROR + R *Return `bencode:"r,omitempty"` // RESPONSE type only + E *Error `bencode:"e,omitempty"` // ERROR type only + IP util.CompactPeer `bencode:"ip,omitempty"` + ReadOnly bool `bencode:"ro,omitempty"` } type MsgArgs struct { - ID string `bencode:"id"` // ID of the quirying Node - InfoHash string `bencode:"info_hash"` // InfoHash of the torrent - Target string `bencode:"target"` // ID of the node sought - Token string `bencode:"token"` // Token received from an earlier get_peers query - Port int `bencode:"port"` // Senders torrent port - ImpliedPort int `bencode:"implied_port"` // Use senders apparent DHT port + ID ID `bencode:"id"` // ID of the querying Node + InfoHash ID `bencode:"info_hash,omitempty"` // InfoHash of the torrent + Target ID `bencode:"target,omitempty"` // ID of the node sought + Token string `bencode:"token,omitempty"` // Token received from an earlier get_peers query + Port int `bencode:"port,omitempty"` // Senders torrent port + ImpliedPort bool `bencode:"implied_port,omitempty"` // Use senders apparent DHT port } type Return struct { - ID string `bencode:"id"` // ID of the querying node + ID ID `bencode:"id"` // ID of the querying node Nodes CompactIPv4NodeInfo `bencode:"nodes,omitempty"` // K closest nodes to the requested target Token string `bencode:"token,omitempty"` // Token for future announce_peer Values []util.CompactPeer `bencode:"values,omitempty"` // Torrent peers @@ -51,14 +52,14 @@ func (m Msg) String() string { } // The node ID of the source of this Msg. -func (m Msg) SenderID() string { +func (m Msg) SenderID() *ID { switch m.Y { case "q": - return m.A.ID + return &m.A.ID case "r": - return m.R.ID + return &m.R.ID } - return "" + return nil } func (m Msg) Error() *Error { diff --git a/vendor/github.com/anacrolix/dht/krpc/msg_test.go b/vendor/github.com/anacrolix/dht/krpc/msg_test.go deleted file mode 100644 index 6854d8994..000000000 --- a/vendor/github.com/anacrolix/dht/krpc/msg_test.go +++ /dev/null @@ -1,89 +0,0 @@ -package krpc - -import ( - "net" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/anacrolix/torrent/bencode" - "github.com/anacrolix/torrent/util" -) - -func testMarshalUnmarshalMsg(t *testing.T, m Msg, expected string) { - b, err := bencode.Marshal(m) - require.NoError(t, err) - assert.Equal(t, expected, string(b)) - var _m Msg - err = bencode.Unmarshal([]byte(expected), &_m) - assert.NoError(t, err) - assert.EqualValues(t, m, _m) - assert.EqualValues(t, m.A, _m.A) - assert.EqualValues(t, m.R, _m.R) -} - -func TestMarshalUnmarshalMsg(t *testing.T) { - testMarshalUnmarshalMsg(t, Msg{}, "d1:t0:1:y0:e") - testMarshalUnmarshalMsg(t, Msg{ - Y: "q", - Q: "ping", - T: "hi", - }, "d1:q4:ping1:t2:hi1:y1:qe") - testMarshalUnmarshalMsg(t, Msg{ - Y: "e", - T: "42", - E: &Error{Code: 200, Msg: "fuck"}, - }, "d1:eli200e4:fucke1:t2:421:y1:ee") - testMarshalUnmarshalMsg(t, Msg{ - Y: "r", - T: "\x8c%", - R: &Return{}, - }, "d1:rd2:id0:e1:t2:\x8c%1:y1:re") - testMarshalUnmarshalMsg(t, Msg{ - Y: "r", - T: "\x8c%", - R: &Return{ - Nodes: CompactIPv4NodeInfo{ - NodeInfo{ - Addr: &net.UDPAddr{ - IP: net.IPv4(1, 2, 3, 4).To4(), - Port: 0x1234, - }, - }, - }, - }, - }, "d1:rd2:id0:5:nodes26:\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x124e1:t2:\x8c%1:y1:re") - testMarshalUnmarshalMsg(t, Msg{ - Y: "r", - T: "\x8c%", - R: &Return{ - Values: []util.CompactPeer{ - { - IP: net.IPv4(1, 2, 3, 4).To4(), - Port: 0x5678, - }, - }, - }, - }, "d1:rd2:id0:6:valuesl6:\x01\x02\x03\x04\x56\x78ee1:t2:\x8c%1:y1:re") - testMarshalUnmarshalMsg(t, Msg{ - Y: "r", - T: "\x03", - R: &Return{ - ID: "\xeb\xff6isQ\xffJ\xec)ͺ\xab\xf2\xfb\xe3F|\xc2g", - }, - IP: util.CompactPeer{ - IP: net.IPv4(124, 168, 180, 8).To4(), - Port: 62844, - }, - }, "d2:ip6:|\xa8\xb4\b\xf5|1:rd2:id20:\xeb\xff6isQ\xffJ\xec)ͺ\xab\xf2\xfb\xe3F|\xc2ge1:t1:\x031:y1:re") -} - -func TestUnmarshalGetPeersResponse(t *testing.T) { - var msg Msg - err := bencode.Unmarshal([]byte("d1:rd6:valuesl6:\x01\x02\x03\x04\x05\x066:\x07\x08\x09\x0a\x0b\x0ce5:nodes52:\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x02\x03\x04\x05\x06\x07\x08\x09\x02\x03\x04\x05\x06\x07\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x02\x03\x04\x05\x06\x07\x08\x09\x02\x03\x04\x05\x06\x07ee"), &msg) - require.NoError(t, err) - assert.Len(t, msg.R.Values, 2) - assert.Len(t, msg.R.Nodes, 2) - assert.Nil(t, msg.E) -} diff --git a/vendor/github.com/anacrolix/dht/misc.go b/vendor/github.com/anacrolix/dht/misc.go new file mode 100644 index 000000000..8c41ec12a --- /dev/null +++ b/vendor/github.com/anacrolix/dht/misc.go @@ -0,0 +1,18 @@ +package dht + +import "net" + +func mustListen(addr string) net.PacketConn { + ret, err := net.ListenPacket("udp", addr) + if err != nil { + panic(err) + } + return ret +} + +func addrResolver(addr string) func() ([]Addr, error) { + return func() ([]Addr, error) { + ua, err := net.ResolveUDPAddr("udp", addr) + return []Addr{NewAddr(ua)}, err + } +} diff --git a/vendor/github.com/anacrolix/dht/node.go b/vendor/github.com/anacrolix/dht/node.go new file mode 100644 index 000000000..361922c38 --- /dev/null +++ b/vendor/github.com/anacrolix/dht/node.go @@ -0,0 +1,57 @@ +package dht + +import ( + "time" + + "github.com/anacrolix/dht/krpc" +) + +type nodeKey struct { + addr Addr + id int160 +} + +type node struct { + nodeKey + announceToken string + readOnly bool + + lastGotQuery time.Time + lastGotResponse time.Time + + consecutiveFailures int +} + +func (n *node) hasAddrAndID(addr Addr, id int160) bool { + return id == n.id && n.addr.String() == addr.String() +} + +func (n *node) IsSecure() bool { + return NodeIdSecure(n.id.AsByteArray(), n.addr.UDPAddr().IP) +} + +func (n *node) idString() string { + return n.id.ByteString() +} + +func (n *node) NodeInfo() (ret krpc.NodeInfo) { + ret.Addr = n.addr.UDPAddr() + if n := copy(ret.ID[:], n.idString()); n != 20 { + panic(n) + } + return +} + +// Per the spec in BEP 5. +func (n *node) IsGood() bool { + if n.id.IsZero() { + return false + } + if time.Since(n.lastGotResponse) < 15*time.Minute { + return true + } + if !n.lastGotResponse.IsZero() && time.Since(n.lastGotQuery) < 15*time.Minute { + return true + } + return false +} diff --git a/vendor/github.com/anacrolix/dht/nodeid.go b/vendor/github.com/anacrolix/dht/nodeid.go deleted file mode 100644 index 8520fce4e..000000000 --- a/vendor/github.com/anacrolix/dht/nodeid.go +++ /dev/null @@ -1,50 +0,0 @@ -package dht - -import "encoding/hex" - -type nodeID struct { - _int int160 - set bool -} - -func (me *nodeID) SetFromBytes(b []byte) { - me._int.SetBytes(b) - me.set = true -} - -func (me nodeID) String() string { - b := me._int.bits[:] - if len(b) != 20 { - panic(len(b)) - } - return hex.EncodeToString(b) -} - -func (nid *nodeID) IsSet() bool { - return nid.set -} - -func (me *nodeID) Int160() *int160 { - if !me.set { - panic("not set") - } - return &me._int -} - -func nodeIDFromString(s string) (ret nodeID) { - ret.SetFromBytes([]byte(s)) - return -} - -func (nid0 *nodeID) Distance(nid1 *nodeID) (ret int160) { - if nid0.IsSet() != nid1.IsSet() { - ret.SetMax() - return - } - ret.Xor(&nid0._int, &nid1._int) - return -} - -func (nid nodeID) ByteString() string { - return string(nid.Int160().Bytes()) -} diff --git a/vendor/github.com/anacrolix/dht/security.go b/vendor/github.com/anacrolix/dht/security.go index 9355b7b51..cf38f1014 100644 --- a/vendor/github.com/anacrolix/dht/security.go +++ b/vendor/github.com/anacrolix/dht/security.go @@ -1,7 +1,6 @@ package dht import ( - "fmt" "hash/crc32" "net" ) @@ -33,7 +32,7 @@ func crcIP(ip net.IP, rand uint8) uint32 { // Makes a node ID secure, in-place. The ID is 20 raw bytes. // http://www.libtorrent.org/dht_sec.html -func SecureNodeId(id []byte, ip net.IP) { +func SecureNodeId(id *[20]byte, ip net.IP) { crc := crcIP(ip, id[19]) id[0] = byte(crc >> 24 & 0xff) id[1] = byte(crc >> 16 & 0xff) @@ -42,13 +41,10 @@ func SecureNodeId(id []byte, ip net.IP) { // Returns whether the node ID is considered secure. The id is the 20 raw // bytes. http://www.libtorrent.org/dht_sec.html -func NodeIdSecure(id string, ip net.IP) bool { +func NodeIdSecure(id [20]byte, ip net.IP) bool { if isLocalNetwork(ip) { return true } - if len(id) != 20 { - panic(fmt.Sprintf("%q", id)) - } if ip4 := ip.To4(); ip4 != nil { ip = ip4 } diff --git a/vendor/github.com/anacrolix/dht/security_test.go b/vendor/github.com/anacrolix/dht/security_test.go deleted file mode 100644 index 9cd844707..000000000 --- a/vendor/github.com/anacrolix/dht/security_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package dht - -import ( - "encoding/hex" - "net" - "testing" - - "github.com/anacrolix/missinggo" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestDHTSec(t *testing.T) { - for _, case_ := range []struct { - ipStr string - nodeIDHex string - valid bool - }{ - // These 5 are from the spec example. They are all valid. - {"124.31.75.21", "5fbfbff10c5d6a4ec8a88e4c6ab4c28b95eee401", true}, - {"21.75.31.124", "5a3ce9c14e7a08645677bbd1cfe7d8f956d53256", true}, - {"65.23.51.170", "a5d43220bc8f112a3d426c84764f8c2a1150e616", true}, - {"84.124.73.14", "1b0321dd1bb1fe518101ceef99462b947a01ff41", true}, - {"43.213.53.83", "e56f6cbf5b7c4be0237986d5243b87aa6d51305a", true}, - // spec[0] with one of the rand() bytes changed. Valid. - {"124.31.75.21", "5fbfbff10c5d7a4ec8a88e4c6ab4c28b95eee401", true}, - // spec[1] with the 21st leading bit changed. Not Valid. - {"21.75.31.124", "5a3ce1c14e7a08645677bbd1cfe7d8f956d53256", false}, - // spec[2] with the 22nd leading bit changed. Valid. - {"65.23.51.170", "a5d43620bc8f112a3d426c84764f8c2a1150e616", true}, - // spec[3] with the 4th last bit changed. Valid. - {"84.124.73.14", "1b0321dd1bb1fe518101ceef99462b947a01fe01", true}, - // spec[4] with the 3rd last bit changed. Not valid. - {"43.213.53.83", "e56f6cbf5b7c4be0237986d5243b87aa6d51303e", false}, - // Because class A network. - {"10.213.53.83", "e56f6cbf5b7c4be0237986d5243b87aa6d51305a", true}, - // Because not class A, and id[0]&3 does not match. - {"12.213.53.83", "e56f6cbf5b7c4be0237986d5243b87aa6d51305a", false}, - // Because class C. - {"192.168.53.83", "e56f6cbf5b7c4be0237986d5243b87aa6d51305a", true}, - } { - ip := net.ParseIP(case_.ipStr) - id, err := hex.DecodeString(case_.nodeIDHex) - require.NoError(t, err) - secure := NodeIdSecure(string(id), ip) - assert.Equal(t, case_.valid, secure, "%v", case_) - if !secure { - // It's not secure, so secure it in place and then check it again. - SecureNodeId(id, ip) - assert.True(t, NodeIdSecure(string(id), ip), "%v", case_) - } - } -} - -func TestServerDefaultNodeIdSecure(t *testing.T) { - s, err := NewServer(&ServerConfig{ - NoDefaultBootstrap: true, - }) - require.NoError(t, err) - defer s.Close() - if !NodeIdSecure(s.ID(), missinggo.AddrIP(s.Addr())) { - t.Fatal("not secure") - } -} diff --git a/vendor/github.com/anacrolix/dht/server.go b/vendor/github.com/anacrolix/dht/server.go index 1ea95cb62..52bddff06 100644 --- a/vendor/github.com/anacrolix/dht/server.go +++ b/vendor/github.com/anacrolix/dht/server.go @@ -1,17 +1,15 @@ package dht import ( - "crypto" "crypto/rand" "encoding/binary" - "encoding/hex" "errors" "fmt" "io" "log" "net" - "os" "sync" + "text/tabwriter" "time" "github.com/anacrolix/missinggo" @@ -19,49 +17,95 @@ import ( "github.com/anacrolix/torrent/iplist" "github.com/anacrolix/torrent/logonce" "github.com/anacrolix/torrent/metainfo" - "github.com/tylertreat/BoomFilters" "github.com/anacrolix/dht/krpc" ) -// A Server defines parameters for a DHT node server that is able to -// send queries, and respond to the ones from the network. -// Each node has a globally unique identifier known as the "node ID." -// Node IDs are chosen at random from the same 160-bit space -// as BitTorrent infohashes and define the behaviour of the node. -// Zero valued Server does not have a valid ID and thus -// is unable to function properly. Use `NewServer(nil)` -// to initialize a default node. +// A Server defines parameters for a DHT node server that is able to send +// queries, and respond to the ones from the network. Each node has a globally +// unique identifier known as the "node ID." Node IDs are chosen at random +// from the same 160-bit space as BitTorrent infohashes and define the +// behaviour of the node. Zero valued Server does not have a valid ID and thus +// is unable to function properly. Use `NewServer(nil)` to initialize a +// default node. type Server struct { - id string - socket net.PacketConn - transactions map[transactionKey]*Transaction - transactionIDInt uint64 - nodes map[string]*node // Keyed by dHTAddr.String(). - mu sync.Mutex - closed missinggo.Event - ipBlockList iplist.Ranger - badNodes *boom.BloomFilter - tokenServer tokenServer - + id int160 + socket net.PacketConn + + mu sync.Mutex + transactions map[transactionKey]*Transaction + nextT uint64 // unique "t" field for outbound queries + table table + closed missinggo.Event + ipBlockList iplist.Ranger + tokenServer tokenServer // Manages tokens we issue to our queriers. numConfirmedAnnounces int - bootstrapNodes []string config ServerConfig } +func (s *Server) numGoodNodes() (num int) { + s.table.forNodes(func(n *node) bool { + if n.IsGood() { + num++ + } + return true + }) + return +} + +func prettySince(t time.Time) string { + if t.IsZero() { + return "never" + } + d := time.Since(t) + d /= time.Second + d *= time.Second + return fmt.Sprintf("%s ago", d) +} + +func (s *Server) WriteStatus(w io.Writer) { + fmt.Fprintf(w, "Listening on %s\n", s.Addr()) + s.mu.Lock() + defer s.mu.Unlock() + fmt.Fprintf(w, "Nodes in table: %d good, %d total\n", s.numGoodNodes(), s.numNodes()) + fmt.Fprintf(w, "Ongoing transactions: %d\n", len(s.transactions)) + fmt.Fprintf(w, "Server node ID: %x\n", s.id.Bytes()) + fmt.Fprintln(w) + tw := tabwriter.NewWriter(w, 0, 0, 1, ' ', 0) + fmt.Fprintf(tw, "b#\tnode id\taddr\tanntok\tlast query\tlast response\tcf\n") + for i, b := range s.table.buckets { + b.EachNode(func(n *node) bool { + fmt.Fprintf(tw, "%d\t%x\t%s\t%v\t%s\t%s\t%d\n", + i, + n.id.Bytes(), + n.addr, + len(n.announceToken), + prettySince(n.lastGotQuery), + prettySince(n.lastGotResponse), + n.consecutiveFailures, + ) + return true + }) + } + tw.Flush() +} + +func (s *Server) numNodes() (num int) { + s.table.forNodes(func(n *node) bool { + num++ + return true + }) + return +} + // Stats returns statistics for the server. func (s *Server) Stats() (ss ServerStats) { s.mu.Lock() defer s.mu.Unlock() - for _, n := range s.nodes { - if n.DefinitelyGood() { - ss.GoodNodes++ - } - } - ss.Nodes = len(s.nodes) + ss.GoodNodes = s.numGoodNodes() + ss.Nodes = s.numNodes() ss.OutstandingTransactions = len(s.transactions) ss.ConfirmedAnnounces = s.numConfirmedAnnounces - ss.BadNodes = s.badNodes.Count() return } @@ -74,40 +118,34 @@ func (s *Server) Addr() net.Addr { // NewServer initializes a new DHT node server. func NewServer(c *ServerConfig) (s *Server, err error) { if c == nil { - c = &ServerConfig{} + c = &ServerConfig{ + Conn: mustListen(":0"), + NoSecurity: true, + } + } + if missinggo.IsZeroValue(c.NodeId) { + c.NodeId = RandomNodeID() + if !c.NoSecurity && c.PublicIP != nil { + SecureNodeId(&c.NodeId, c.PublicIP) + } } s = &Server{ config: *c, ipBlockList: c.IPBlocklist, - badNodes: boom.NewBloomFilter(1000, 0.1), tokenServer: tokenServer{ maxIntervalDelta: 2, interval: 5 * time.Minute, secret: make([]byte, 20), }, + transactions: make(map[transactionKey]*Transaction), + table: table{ + k: 8, + }, } rand.Read(s.tokenServer.secret) - if c.Conn != nil { - s.socket = c.Conn - } else { - s.socket, err = makeSocket(c.Addr) - if err != nil { - return - } - } - s.bootstrapNodes = c.BootstrapNodes - if c.NodeIdHex != "" { - var rawID []byte - rawID, err = hex.DecodeString(c.NodeIdHex) - if err != nil { - return - } - s.id = string(rawID) - } - err = s.init() - if err != nil { - return - } + s.socket = c.Conn + s.id = int160FromByteArray(c.NodeId) + s.table.rootID = s.id go func() { err := s.serve() s.mu.Lock() @@ -119,16 +157,6 @@ func NewServer(c *ServerConfig) (s *Server, err error) { panic(err) } }() - go func() { - err := s.bootstrap() - if err != nil { - s.mu.Lock() - if !s.closed.IsSet() { - log.Printf("error bootstrapping DHT: %s", err) - } - s.mu.Unlock() - } - }() return } @@ -148,15 +176,6 @@ func (s *Server) IPBlocklist() iplist.Ranger { return s.ipBlockList } -func (s *Server) init() (err error) { - err = s.setDefaults() - if err != nil { - return - } - s.transactions = make(map[transactionKey]*Transaction) - return -} - func (s *Server) processPacket(b []byte, addr Addr) { if len(b) < 2 || b[0] != 'd' || b[len(b)-1] != 'e' { // KRPC messages are bencoded dicts. @@ -193,6 +212,13 @@ func (s *Server) processPacket(b []byte, addr Addr) { if s.closed.IsSet() { return } + var n *node + if sid := d.SenderID(); sid != nil { + n, _ = s.getNode(addr, int160FromByteArray(*sid), !d.ReadOnly) + if n != nil && d.ReadOnly { + n.readOnly = true + } + } if d.Y == "q" { readQuery.Add(1) s.handleQuery(addr, d) @@ -200,13 +226,13 @@ func (s *Server) processPacket(b []byte, addr Addr) { } t := s.findResponseTransaction(d.T, addr) if t == nil { - //log.Printf("unexpected message: %#v", d) return } - node := s.getNode(addr, d.SenderID()) - node.lastGotResponse = time.Now() - // TODO: Update node ID as this is an authoritative packet. go t.handleResponse(d) + if n != nil { + n.lastGotResponse = time.Now() + n.consecutiveFailures = 0 + } s.deleteTransaction(t) } @@ -246,29 +272,21 @@ func (s *Server) ipBlocked(ip net.IP) (blocked bool) { } // Adds directly to the node table. -func (s *Server) AddNode(ni krpc.NodeInfo) { - s.mu.Lock() - defer s.mu.Unlock() - if s.nodes == nil { - s.nodes = make(map[string]*node) +func (s *Server) AddNode(ni krpc.NodeInfo) error { + id := int160FromByteArray(ni.ID) + if id.IsZero() { + return s.Ping(ni.Addr, nil) } - s.getNode(NewAddr(ni.Addr), string(ni.ID[:])) -} - -func (s *Server) nodeByID(id string) *node { - for _, node := range s.nodes { - if node.id.IsSet() && node.id.ByteString() == id { - return node - } - } - return nil + _, err := s.getNode(NewAddr(ni.Addr), int160FromByteArray(ni.ID), true) + return err } // TODO: Probably should write error messages back to senders if something is // wrong. func (s *Server) handleQuery(source Addr, m krpc.Msg) { - node := s.getNode(source, m.SenderID()) - node.lastGotQuery = time.Now() + if n, _ := s.getNode(source, int160FromByteArray(*m.SenderID()), !m.ReadOnly); n != nil { + n.lastGotQuery = time.Now() + } if s.config.OnQuery != nil { propagate := s.config.OnQuery(&m, source.UDPAddr()) if !propagate { @@ -279,41 +297,26 @@ func (s *Server) handleQuery(source Addr, m krpc.Msg) { if s.config.Passive { return } + // TODO: Should we disallow replying to ourself? args := m.A switch m.Q { case "ping": s.reply(source, m.T, krpc.Return{}) - case "get_peers": // TODO: Extract common behaviour with find_node. - targetID := args.InfoHash - if len(targetID) != 20 { + case "get_peers": + if len(args.InfoHash) != 20 { break } - var rNodes []krpc.NodeInfo - // TODO: Reply with "values" list if we have peers instead. - for _, node := range s.closestGoodNodes(8, targetID) { - rNodes = append(rNodes, node.NodeInfo()) - } s.reply(source, m.T, krpc.Return{ - Nodes: rNodes, + Nodes: s.closestGoodNodeInfos(8, int160FromByteArray(args.InfoHash)), Token: s.createToken(source), }) case "find_node": // TODO: Extract common behaviour with get_peers. - targetID := args.Target - if len(targetID) != 20 { + if len(args.Target) != 20 { log.Printf("bad DHT query: %v", m) return } - var rNodes []krpc.NodeInfo - if node := s.nodeByID(targetID); node != nil { - rNodes = append(rNodes, node.NodeInfo()) - } else { - // This will probably cause a crash for IPv6, but meh. - for _, node := range s.closestGoodNodes(8, targetID) { - rNodes = append(rNodes, node.NodeInfo()) - } - } s.reply(source, m.T, krpc.Return{ - Nodes: rNodes, + Nodes: s.closestGoodNodeInfos(8, int160FromByteArray(args.Target)), }) case "announce_peer": readAnnouncePeer.Add(1) @@ -326,16 +329,14 @@ func (s *Server) handleQuery(source Addr, m krpc.Msg) { return } if h := s.config.OnAnnouncePeer; h != nil { - var ih metainfo.Hash - copy(ih[:], args.InfoHash) p := Peer{ IP: source.UDPAddr().IP, Port: args.Port, } - if args.ImpliedPort != 0 { + if args.ImpliedPort { p.Port = source.UDPAddr().Port } - go h(ih, p) + go h(metainfo.Hash(args.InfoHash), p) } default: s.sendError(source, m.T, krpc.ErrorMethodUnknown) @@ -359,7 +360,7 @@ func (s *Server) sendError(addr Addr, t string, e krpc.Error) { } func (s *Server) reply(addr Addr, t string, r krpc.Return) { - r.ID = s.ID() + r.ID = s.id.AsByteArray() m := krpc.Msg{ T: t, Y: "r", @@ -375,49 +376,63 @@ func (s *Server) reply(addr Addr, t string, r krpc.Return) { } } -// Returns a node struct for the addr. It is taken from the table or created -// and possibly added if required and meets validity constraints. -func (s *Server) getNode(addr Addr, id string) (n *node) { - addrStr := addr.String() - n = s.nodes[addrStr] - if n != nil { - if id != "" { - n.SetIDFromString(id) - } - return +// Returns the node if it's in the routing table, adding it if appropriate. +func (s *Server) getNode(addr Addr, id int160, tryAdd bool) (*node, error) { + if n := s.table.getNode(addr, id); n != nil { + return n, nil } - n = &node{ + n := &node{nodeKey: nodeKey{ + id: id, addr: addr, + }} + // Check that the node would be good to begin with. (It might have a bad + // ID or banned address, or we fucked up the initial node field + // invariant.) + if err := s.nodeErr(n); err != nil { + return nil, err + } + if !tryAdd { + return nil, errors.New("node not present and add flag false") + } + b := s.table.bucketForID(id) + if b.Len() >= s.table.k { + if b.EachNode(func(n *node) bool { + if s.nodeIsBad(n) { + s.table.dropNode(n) + } + return b.Len() >= s.table.k + }) { + // No room. + return nil, errors.New("no room in bucket") + } } - if len(id) == 20 { - n.SetIDFromString(id) - } - if len(s.nodes) >= maxNodes { - return - } - // Exclude insecure nodes from the node table. - if !s.config.NoSecurity && !n.IsSecure() { - return - } - if s.badNodes.Test([]byte(addrStr)) { - return + if err := s.table.addNode(n); err != nil { + panic(fmt.Sprintf("expected to add node: %s", err)) } - s.nodes[addrStr] = n - return + return n, nil } -func (s *Server) nodeTimedOut(addr Addr) { - node, ok := s.nodes[addr.String()] - if !ok { - return +func (s *Server) nodeIsBad(n *node) bool { + return s.nodeErr(n) != nil +} + +func (s *Server) nodeErr(n *node) error { + if n.id == s.id { + return errors.New("is self") } - if node.DefinitelyGood() { - return + if n.id.IsZero() { + return errors.New("has zero id") } - if len(s.nodes) < maxNodes { - return + if !s.config.NoSecurity && !n.IsSecure() { + return errors.New("not secure") + } + if n.IsGood() { + return nil + } + if n.consecutiveFailures >= 3 { + return fmt.Errorf("has %d consecutive failures", n.consecutiveFailures) } - delete(s.nodes, addr.String()) + return nil } func (s *Server) writeToNode(b []byte, node Addr) (err error) { @@ -427,6 +442,7 @@ func (s *Server) writeToNode(b []byte, node Addr) (err error) { return } } + // log.Printf("writing to %s: %q", node.UDPAddr(), b) n, err := s.socket.WriteTo(b, node.UDPAddr()) writes.Add(1) if err != nil { @@ -449,8 +465,8 @@ func (s *Server) findResponseTransaction(transactionID string, sourceNode Addr) func (s *Server) nextTransactionID() string { var b [binary.MaxVarintLen64]byte - n := binary.PutUvarint(b[:], s.transactionIDInt) - s.transactionIDInt++ + n := binary.PutUvarint(b[:], s.nextT) + s.nextT++ return string(b[:n]) } @@ -458,6 +474,12 @@ func (s *Server) deleteTransaction(t *Transaction) { delete(s.transactions, t.key()) } +func (s *Server) deleteTransactionUnlocked(t *Transaction) { + s.mu.Lock() + defer s.mu.Unlock() + s.deleteTransaction(t) +} + func (s *Server) addTransaction(t *Transaction) { if _, ok := s.transactions[t.key()]; ok { panic("transaction not unique") @@ -467,11 +489,8 @@ func (s *Server) addTransaction(t *Transaction) { // ID returns the 20-byte server ID. This is the ID used to communicate with the // DHT network. -func (s *Server) ID() string { - if len(s.id) != 20 { - panic("bad node id") - } - return s.id +func (s *Server) ID() [20]byte { + return s.id.AsByteArray() } func (s *Server) createToken(addr Addr) string { @@ -482,191 +501,180 @@ func (s *Server) validToken(token string, addr Addr) bool { return s.tokenServer.ValidToken(token, addr) } -func (s *Server) query(node Addr, q string, a map[string]interface{}, onResponse func(krpc.Msg)) (t *Transaction, err error) { +func (s *Server) query(addr Addr, q string, a *krpc.MsgArgs, callback func(krpc.Msg, error)) error { tid := s.nextTransactionID() if a == nil { - a = make(map[string]interface{}, 1) + a = &krpc.MsgArgs{} + } + if callback == nil { + callback = func(krpc.Msg, error) {} } - a["id"] = s.ID() - d := map[string]interface{}{ - "t": tid, - "y": "q", - "q": q, - "a": a, + a.ID = s.ID() + m := krpc.Msg{ + T: tid, + Y: "q", + Q: q, + A: a, } - // BEP 43. Outgoing queries from uncontactiable nodes should contain - // "ro":1 in the top level dictionary. + // BEP 43. Outgoing queries from passive nodes should contain "ro":1 in + // the top level dictionary. if s.config.Passive { - d["ro"] = 1 + m.ReadOnly = true } - b, err := bencode.Marshal(d) + b, err := bencode.Marshal(m) if err != nil { - return + return err } - _t := &Transaction{ - remoteAddr: node, - t: tid, - response: make(chan krpc.Msg, 1), - done: make(chan struct{}), - queryPacket: b, - s: s, - onResponse: onResponse, + var t *Transaction + t = &Transaction{ + remoteAddr: addr, + t: tid, + querySender: func() error { + return s.writeToNode(b, addr) + }, + onResponse: func(m krpc.Msg) { + go callback(m, nil) + go s.deleteTransactionUnlocked(t) + }, + onTimeout: func() { + go callback(krpc.Msg{}, errors.New("query timed out")) + s.mu.Lock() + defer s.mu.Unlock() + s.deleteTransaction(t) + for _, n := range s.table.addrNodes(addr) { + n.consecutiveFailures++ + } + }, + onSendError: func(err error) { + go callback(krpc.Msg{}, fmt.Errorf("error resending query: %s", err)) + s.mu.Lock() + defer s.mu.Unlock() + s.deleteTransaction(t) + for _, n := range s.table.addrNodes(addr) { + n.consecutiveFailures++ + } + }, + queryResendDelay: func() time.Duration { + if s.config.QueryResendDelay != nil { + return s.config.QueryResendDelay() + } + return defaultQueryResendDelay() + }, } - err = _t.sendQuery() + err = t.sendQuery() if err != nil { - return + return err } - s.getNode(node, "").lastSentQuery = time.Now() - _t.mu.Lock() - _t.startTimer() - _t.mu.Unlock() - s.addTransaction(_t) - t = _t - return + // s.getNode(node, "").lastSentQuery = time.Now() + t.mu.Lock() + t.startResendTimer() + t.mu.Unlock() + s.addTransaction(t) + return nil } // Sends a ping query to the address given. -func (s *Server) Ping(node *net.UDPAddr) (*Transaction, error) { +func (s *Server) Ping(node *net.UDPAddr, callback func(krpc.Msg, error)) error { s.mu.Lock() defer s.mu.Unlock() - return s.query(NewAddr(node), "ping", nil, nil) + return s.ping(node, callback) +} + +func (s *Server) ping(node *net.UDPAddr, callback func(krpc.Msg, error)) error { + return s.query(NewAddr(node), "ping", nil, callback) } -func (s *Server) announcePeer(node Addr, infoHash string, port int, token string, impliedPort bool) (err error) { +func (s *Server) announcePeer(node Addr, infoHash int160, port int, token string, impliedPort bool, callback func(krpc.Msg, error)) error { if port == 0 && !impliedPort { return errors.New("nothing to announce") } - _, err = s.query(node, "announce_peer", map[string]interface{}{ - "implied_port": func() int { - if impliedPort { - return 1 - } else { - return 0 - } - }(), - "info_hash": infoHash, - "port": port, - "token": token, - }, func(m krpc.Msg) { + return s.query(node, "announce_peer", &krpc.MsgArgs{ + ImpliedPort: impliedPort, + InfoHash: infoHash.AsByteArray(), + Port: port, + Token: token, + }, func(m krpc.Msg, err error) { + if callback != nil { + go callback(m, err) + } if err := m.Error(); err != nil { announceErrors.Add(1) - // log.Print(token) - // logonce.Stderr.Printf("announce_peer response: %s", err) return } + s.mu.Lock() + defer s.mu.Unlock() s.numConfirmedAnnounces++ }) - return } // Add response nodes to node table. -func (s *Server) liftNodes(d krpc.Msg) { - if d.Y != "r" { +func (s *Server) addResponseNodes(d krpc.Msg) { + if d.R == nil { return } for _, cni := range d.R.Nodes { - if cni.Addr.Port == 0 { - // TODO: Why would people even do this? - continue - } - if s.ipBlocked(cni.Addr.IP) { - continue - } - n := s.getNode(NewAddr(cni.Addr), string(cni.ID[:])) - n.SetIDFromBytes(cni.ID[:]) + s.getNode(NewAddr(cni.Addr), int160FromByteArray(cni.ID), true) } } // Sends a find_node query to addr. targetID is the node we're looking for. -func (s *Server) findNode(addr Addr, targetID string) (t *Transaction, err error) { - t, err = s.query(addr, "find_node", map[string]interface{}{"target": targetID}, func(d krpc.Msg) { +func (s *Server) findNode(addr Addr, targetID int160, callback func(krpc.Msg, error)) (err error) { + return s.query(addr, "find_node", &krpc.MsgArgs{ + Target: targetID.AsByteArray(), + }, func(m krpc.Msg, err error) { // Scrape peers from the response to put in the server's table before // handing the response back to the caller. - s.liftNodes(d) + s.mu.Lock() + s.addResponseNodes(m) + s.mu.Unlock() + callback(m, err) }) - if err != nil { - return - } - return } -// Adds bootstrap nodes directly to table, if there's room. Node ID security -// is bypassed, but the IP blocklist is not. -func (s *Server) addRootNodes() error { - addrs, err := bootstrapAddrs(s.bootstrapNodes) - if err != nil { - return err - } - for _, addr := range addrs { - if len(s.nodes) >= maxNodes { - break - } - if s.nodes[addr.String()] != nil { - continue - } - if s.ipBlocked(addr.IP) { - log.Printf("dht root node is in the blocklist: %s", addr.IP) - continue - } - s.nodes[addr.String()] = &node{ - addr: NewAddr(addr), - } - } - return nil +type TraversalStats struct { + NumAddrsTried int + NumResponses int } // Populates the node table. -func (s *Server) bootstrap() (err error) { +func (s *Server) Bootstrap() (ts TraversalStats, err error) { s.mu.Lock() - defer s.mu.Unlock() - if len(s.nodes) == 0 && !s.config.NoDefaultBootstrap { - err = s.addRootNodes() - } + initialAddrs, err := s.traversalStartingAddrs() + s.mu.Unlock() if err != nil { return } - for { - var outstanding sync.WaitGroup - for _, node := range s.nodes { - var t *Transaction - t, err = s.findNode(node.addr, s.id) + var outstanding sync.WaitGroup + triedAddrs := newBloomFilterForTraversal() + var onAddr func(addr Addr) + onAddr = func(addr Addr) { + if triedAddrs.Test([]byte(addr.String())) { + return + } + ts.NumAddrsTried++ + outstanding.Add(1) + triedAddrs.AddString(addr.String()) + s.findNode(addr, s.id, func(m krpc.Msg, err error) { + defer outstanding.Done() + s.mu.Lock() + defer s.mu.Unlock() if err != nil { - err = fmt.Errorf("error sending find_node: %s", err) return } - outstanding.Add(1) - t.SetResponseHandler(func(krpc.Msg, bool) { - outstanding.Done() - }) - } - noOutstanding := make(chan struct{}) - go func() { - outstanding.Wait() - close(noOutstanding) - }() - s.mu.Unlock() - select { - case <-s.closed.LockedChan(&s.mu): - s.mu.Lock() - return - case <-time.After(15 * time.Second): - case <-noOutstanding: - } - s.mu.Lock() - // log.Printf("now have %d nodes", len(s.nodes)) - if s.numGoodNodes() >= 160 { - break - } + ts.NumResponses++ + if r := m.R; r != nil { + for _, addr := range r.Nodes { + onAddr(NewAddr(addr.Addr)) + } + } + }) } - return -} - -func (s *Server) numGoodNodes() (num int) { - for _, n := range s.nodes { - if n.DefinitelyGood() { - num++ - } + s.mu.Lock() + for _, addr := range initialAddrs { + onAddr(addr) } + s.mu.Unlock() + outstanding.Wait() return } @@ -674,25 +682,20 @@ func (s *Server) numGoodNodes() (num int) { func (s *Server) NumNodes() int { s.mu.Lock() defer s.mu.Unlock() - return len(s.nodes) + return s.numNodes() } // Exports the current node table. func (s *Server) Nodes() (nis []krpc.NodeInfo) { s.mu.Lock() defer s.mu.Unlock() - for _, node := range s.nodes { - // if !node.Good() { - // continue - // } - ni := krpc.NodeInfo{ - Addr: node.addr.UDPAddr(), - } - if n := copy(ni.ID[:], node.idString()); n != 20 && n != 0 { - panic(n) - } - nis = append(nis, ni) - } + s.table.forNodes(func(n *node) bool { + nis = append(nis, krpc.NodeInfo{ + Addr: n.addr.UDPAddr(), + ID: n.id.AsByteArray(), + }) + return true + }) return } @@ -704,73 +707,49 @@ func (s *Server) Close() { s.socket.Close() } -func (s *Server) setDefaults() (err error) { - if s.id == "" { - var id [20]byte - h := crypto.SHA1.New() - ss, err := os.Hostname() - if err != nil { - log.Print(err) - } - ss += s.socket.LocalAddr().String() - h.Write([]byte(ss)) - if b := h.Sum(id[:0:20]); len(b) != 20 { - panic(len(b)) - } - if len(id) != 20 { - panic(len(id)) - } - publicIP := func() net.IP { - if s.config.PublicIP != nil { - return s.config.PublicIP - } else { - return missinggo.AddrIP(s.socket.LocalAddr()) +func (s *Server) getPeers(addr Addr, infoHash int160, callback func(krpc.Msg, error)) (err error) { + return s.query(addr, "get_peers", &krpc.MsgArgs{ + InfoHash: infoHash.AsByteArray(), + }, func(m krpc.Msg, err error) { + go callback(m, err) + s.mu.Lock() + defer s.mu.Unlock() + s.addResponseNodes(m) + if m.R != nil && m.R.Token != "" { + if n, _ := s.getNode(addr, int160FromByteArray(*m.SenderID()), false); n != nil { + n.announceToken = m.R.Token } - }() - SecureNodeId(id[:], publicIP) - s.id = string(id[:]) - } - s.nodes = make(map[string]*node, maxNodes) - return + } + }) } -func (s *Server) getPeers(addr Addr, infoHash string) (t *Transaction, err error) { - if len(infoHash) != 20 { - err = fmt.Errorf("infohash has bad length") - return +func (s *Server) closestGoodNodeInfos(k int, targetID int160) (ret []krpc.NodeInfo) { + for _, n := range s.closestNodes(k, targetID, func(n *node) bool { return n.IsGood() }) { + ret = append(ret, n.NodeInfo()) } - t, err = s.query(addr, "get_peers", map[string]interface{}{"info_hash": infoHash}, func(m krpc.Msg) { - s.liftNodes(m) - if m.R != nil && m.R.Token != "" { - s.getNode(addr, m.SenderID()).announceToken = m.R.Token - } - }) return } -func (s *Server) closestGoodNodes(k int, targetID string) []*node { - return s.closestNodes(k, nodeIDFromString(targetID), func(n *node) bool { return n.DefinitelyGood() }) +func (s *Server) closestNodes(k int, target int160, filter func(*node) bool) []*node { + return s.table.closestNodes(k, target, filter) } -func (s *Server) closestNodes(k int, target nodeID, filter func(*node) bool) []*node { - sel := newKClosestNodeIDs(k, target) - idNodes := make(map[string]*node, len(s.nodes)) - for _, node := range s.nodes { - if !filter(node) { - continue +func (s *Server) traversalStartingAddrs() (addrs []Addr, err error) { + s.table.forNodes(func(n *node) bool { + addrs = append(addrs, n.addr) + return true + }) + if len(addrs) > 0 { + return + } + if s.config.StartingNodes != nil { + addrs, err = s.config.StartingNodes() + if err != nil { + return } - sel.Push(node.id) - idNodes[node.idString()] = node } - ret := make([]*node, 0, k) - for it := sel.IDs(); it.Next(); { - id := it.Value().(nodeID) - ret = append(ret, idNodes[id.ByteString()]) + if len(addrs) == 0 { + err = errors.New("no initial nodes") } - return ret -} - -func (s *Server) badNode(addr Addr) { - s.badNodes.Add([]byte(addr.String())) - delete(s.nodes, addr.String()) + return } diff --git a/vendor/github.com/anacrolix/dht/table.go b/vendor/github.com/anacrolix/dht/table.go new file mode 100644 index 000000000..827843d5e --- /dev/null +++ b/vendor/github.com/anacrolix/dht/table.go @@ -0,0 +1,115 @@ +package dht + +import "errors" + +// Node table, with indexes on distance from root ID to bucket, and node addr. +type table struct { + rootID int160 + k int + buckets [160]bucket + addrs map[string]map[int160]struct{} +} + +func (tbl *table) addrNodes(addr Addr) []*node { + a := tbl.addrs[addr.String()] + ret := make([]*node, 0, len(a)) + for id := range a { + ret = append(ret, tbl.getNode(addr, id)) + } + return ret +} + +func (tbl *table) dropNode(n *node) { + as := n.addr.String() + if _, ok := tbl.addrs[as][n.id]; !ok { + panic("missing id for addr") + } + delete(tbl.addrs[as], n.id) + if len(tbl.addrs[as]) == 0 { + delete(tbl.addrs, as) + } + b := tbl.bucketForID(n.id) + if _, ok := b.nodes[n]; !ok { + panic("expected node in bucket") + } + delete(b.nodes, n) +} + +func (tbl *table) bucketForID(id int160) *bucket { + return &tbl.buckets[tbl.bucketIndex(id)] +} + +func (tbl *table) numNodes() (num int) { + for _, b := range tbl.buckets { + num += b.Len() + } + return +} + +func (tbl *table) bucketIndex(id int160) int { + if id == tbl.rootID { + panic("nobody puts the root ID in a bucket") + } + var a int160 + a.Xor(&tbl.rootID, &id) + index := 160 - a.BitLen() + return index +} + +func (tbl *table) forNodes(f func(*node) bool) bool { + for _, b := range tbl.buckets { + if !b.EachNode(f) { + return false + } + } + return true +} + +func (tbl *table) getNode(addr Addr, id int160) *node { + if id == tbl.rootID { + return nil + } + return tbl.buckets[tbl.bucketIndex(id)].GetNode(addr, id) +} + +func (tbl *table) closestNodes(k int, target int160, filter func(*node) bool) (ret []*node) { + for bi := func() int { + if target == tbl.rootID { + return len(tbl.buckets) - 1 + } else { + return tbl.bucketIndex(target) + } + }(); bi >= 0 && len(ret) < k; bi-- { + for n := range tbl.buckets[bi].nodes { + ret = append(ret, n) + } + } + // TODO: Keep only the closest. + if len(ret) > k { + ret = ret[:k] + } + return +} + +func (tbl *table) addNode(n *node) error { + if n.id == tbl.rootID { + return errors.New("is root id") + } + b := &tbl.buckets[tbl.bucketIndex(n.id)] + if b.GetNode(n.addr, n.id) != nil { + return errors.New("already present") + } + if b.Len() >= tbl.k { + return errors.New("bucket is full") + } + b.AddNode(n, tbl.k) + if tbl.addrs == nil { + tbl.addrs = make(map[string]map[int160]struct{}, 160*tbl.k) + } + as := n.addr.String() + if tbl.addrs[as] == nil { + tbl.addrs[as] = make(map[int160]struct{}, 1) + } + tbl.addrs[as][n.id] = struct{}{} + return nil +} diff --git a/vendor/github.com/anacrolix/dht/tokens.go b/vendor/github.com/anacrolix/dht/tokens.go index 9ecb6e3e2..757666526 100644 --- a/vendor/github.com/anacrolix/dht/tokens.go +++ b/vendor/github.com/anacrolix/dht/tokens.go @@ -10,8 +10,11 @@ import ( // Manages creation and validation of tokens issued to querying nodes. type tokenServer struct { - secret []byte - interval time.Duration + // Something only we know that peers can't guess, so they can't deduce valid tokens. + secret []byte + // How long between token changes. + interval time.Duration + // How many intervals may pass between the current interval, and one used to generate a token before it is invalid. maxIntervalDelta int timeNow func() time.Time } diff --git a/vendor/github.com/anacrolix/dht/tokens_test.go b/vendor/github.com/anacrolix/dht/tokens_test.go deleted file mode 100644 index ae19e6630..000000000 --- a/vendor/github.com/anacrolix/dht/tokens_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package dht - -import ( - "net" - "testing" - "time" - - "github.com/stretchr/testify/assert" -) - -func TestTokenServer(t *testing.T) { - addr1 := NewAddr(&net.UDPAddr{ - IP: []byte{1, 2, 3, 4}, - }) - addr2 := NewAddr(&net.UDPAddr{ - IP: []byte{1, 2, 3, 3}, - }) - ts := tokenServer{ - secret: []byte("42"), - interval: 5 * time.Minute, - maxIntervalDelta: 2, - } - tok := ts.CreateToken(addr1) - assert.Len(t, tok, 20) - assert.True(t, ts.ValidToken(tok, addr1)) - assert.False(t, ts.ValidToken(tok[1:], addr1)) - assert.False(t, ts.ValidToken(tok, addr2)) - func() { - ts0 := ts - ts0.secret = nil - assert.False(t, ts0.ValidToken(tok, addr1)) - }() - now := time.Now() - setTime := func(t time.Time) { - ts.timeNow = func() time.Time { - return t - } - } - setTime(now) - tok = ts.CreateToken(addr1) - assert.True(t, ts.ValidToken(tok, addr1)) - setTime(time.Time{}) - assert.False(t, ts.ValidToken(tok, addr1)) - setTime(now.Add(-5 * time.Minute)) - assert.False(t, ts.ValidToken(tok, addr1)) - setTime(now) - assert.True(t, ts.ValidToken(tok, addr1)) - setTime(now.Add(5 * time.Minute)) - assert.True(t, ts.ValidToken(tok, addr1)) - setTime(now.Add(2 * 5 * time.Minute)) - assert.True(t, ts.ValidToken(tok, addr1)) - setTime(now.Add(3 * 5 * time.Minute)) - assert.False(t, ts.ValidToken(tok, addr1)) -} diff --git a/vendor/github.com/anacrolix/dht/transaction.go b/vendor/github.com/anacrolix/dht/transaction.go index 69308225f..b8324c74a 100644 --- a/vendor/github.com/anacrolix/dht/transaction.go +++ b/vendor/github.com/anacrolix/dht/transaction.go @@ -10,40 +10,26 @@ import ( // Transaction keeps track of a message exchange between nodes, such as a // query message and a response message. type Transaction struct { - mu sync.Mutex - remoteAddr Addr - t string - response chan krpc.Msg - onResponse func(krpc.Msg) // Called with the server locked. - done chan struct{} - queryPacket []byte - timer *time.Timer - s *Server - retries int - lastSend time.Time - userOnResponse func(krpc.Msg, bool) -} + remoteAddr Addr + t string + onResponse func(krpc.Msg) + onTimeout func() + onSendError func(error) + querySender func() error + queryResendDelay func() time.Duration -// SetResponseHandler sets up a function to be called when the query response -// is available. -func (t *Transaction) SetResponseHandler(f func(krpc.Msg, bool)) { - t.mu.Lock() - defer t.mu.Unlock() - t.userOnResponse = f - t.tryHandleResponse() + mu sync.Mutex + gotResponse bool + timer *time.Timer + retries int + lastSend time.Time } -func (t *Transaction) tryHandleResponse() { - if t.userOnResponse == nil { - return - } - select { - case r, ok := <-t.response: - t.userOnResponse(r, ok) - // Shouldn't be called more than once. - t.userOnResponse = nil - default: - } +func (t *Transaction) handleResponse(m krpc.Msg) { + t.mu.Lock() + t.gotResponse = true + t.mu.Unlock() + t.onResponse(m) } func (t *Transaction) key() transactionKey { @@ -53,98 +39,34 @@ func (t *Transaction) key() transactionKey { } } -func (t *Transaction) startTimer() { - t.timer = time.AfterFunc(jitterDuration(queryResendEvery, time.Second), t.timerCallback) +func (t *Transaction) startResendTimer() { + t.timer = time.AfterFunc(t.queryResendDelay(), t.resendCallback) } -func (t *Transaction) timerCallback() { +func (t *Transaction) resendCallback() { t.mu.Lock() defer t.mu.Unlock() - select { - case <-t.done: + if t.gotResponse { return - default: } if t.retries == 2 { - t.timeout() + go t.onTimeout() return } t.retries++ - t.sendQuery() - if t.timer.Reset(jitterDuration(queryResendEvery, time.Second)) { + if err := t.sendQuery(); err != nil { + go t.onSendError(err) + return + } + if t.timer.Reset(t.queryResendDelay()) { panic("timer should have fired to get here") } } func (t *Transaction) sendQuery() error { - err := t.s.writeToNode(t.queryPacket, t.remoteAddr) - if err != nil { + if err := t.querySender(); err != nil { return err } t.lastSend = time.Now() return nil } - -func (t *Transaction) timeout() { - go func() { - t.s.mu.Lock() - defer t.s.mu.Unlock() - t.s.nodeTimedOut(t.remoteAddr) - }() - t.close() -} - -func (t *Transaction) close() { - if t.closing() { - return - } - t.queryPacket = nil - close(t.response) - t.tryHandleResponse() - close(t.done) - t.timer.Stop() - go func() { - t.s.mu.Lock() - defer t.s.mu.Unlock() - t.s.deleteTransaction(t) - }() -} - -func (t *Transaction) closing() bool { - select { - case <-t.done: - return true - default: - return false - } -} - -// Close (abandon) the transaction. -func (t *Transaction) Close() { - t.mu.Lock() - defer t.mu.Unlock() - t.close() -} - -func (t *Transaction) handleResponse(m krpc.Msg) { - t.mu.Lock() - if t.closing() { - t.mu.Unlock() - return - } - close(t.done) - t.mu.Unlock() - if t.onResponse != nil { - t.s.mu.Lock() - t.onResponse(m) - t.s.mu.Unlock() - } - t.queryPacket = nil - select { - case t.response <- m: - default: - panic("blocked handling response") - } - close(t.response) - t.tryHandleResponse() -} diff --git a/vendor/github.com/anacrolix/go-libutp/.gitignore b/vendor/github.com/anacrolix/go-libutp/.gitignore new file mode 100644 index 000000000..1aedb3da8 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/.gitignore @@ -0,0 +1,6 @@ +*.o +*.a +*.so +tags +*~ +_obj diff --git a/vendor/github.com/anacrolix/go-libutp/LICENSE b/vendor/github.com/anacrolix/go-libutp/LICENSE new file mode 100644 index 000000000..7f6e16c5f --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2010-2013 BitTorrent, Inc. + +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/anacrolix/go-libutp/README.md b/vendor/github.com/anacrolix/go-libutp/README.md new file mode 100644 index 000000000..85fbbf7a8 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/README.md @@ -0,0 +1,74 @@ +[![CircleCI](https://circleci.com/gh/anacrolix/go-libutp.svg?style=shield)](https://circleci.com/gh/anacrolix/go-libutp) +[![Appveyor Status](https://ci.appveyor.com/api/projects/status/github/anacrolix/go-libutp?branch=master&svg=true)](https://ci.appveyor.com/project/anacrolix/go-libutp) +[![Go Report Card](https://goreportcard.com/badge/github.com/anacrolix/go-libutp)](https://goreportcard.com/report/github.com/anacrolix/go-libutp) +[![GoDoc](https://godoc.org/github.com/anacrolix/go-libutp?status.svg)](http://godoc.org/github.com/anacrolix/go-libutp) +[![MIT License](http://img.shields.io/badge/License-MIT-green.svg)](LICENSE) + +# libutp - The uTorrent Transport Protocol library. +Copyright (c) 2010 BitTorrent, Inc. + +uTP is a TCP-like implementation of [LEDBAT][ledbat] documented as a BitTorrent +extension in [BEP-29][bep29]. uTP provides provides reliable, ordered delivery +while maintaining minimum extra delay. It is implemented on top of UDP to be +cross-platform and functional today. As a result, uTP is the primary transport +for uTorrent peer-to-peer connections. + +uTP is written in C++, but the external interface is strictly C (ANSI C89). + +## The Interface + +The uTP socket interface is a bit different from the Berkeley socket API to +avoid the need for our own select() implementation, and to make it easier to +write event-based code with minimal buffering. + +When you create a uTP socket, you register a set of callbacks. Most notably, the +on_read callback is a reactive callback which occurs when bytes arrive off the +network. The write side of the socket is proactive, and you call UTP_Write to +indicate the number of bytes you wish to write. As packets are created, the +on_write callback is called for each packet, so you can fill the buffers with +data. + +The libutp interface is not thread-safe. It was designed for use in a +single-threaded asyncronous context, although with proper synchronization +it may be used from a multi-threaded environment as well. + +See utp.h for more details and other API documentation. + +## Example + +See ucat.c. Build with: + + make ucat + +## Building + +uTP has been known to build on Windows with MSVC and on linux and OS X with gcc. +On Windows, use the MSVC project files (utp.sln, and friends). On other platforms, +building the shared library is as simple as: + + make + +To build one of the examples, which will statically link in everything it needs +from libutp: + + cd utp_test && make + +## Packaging and API + +The libutp API is considered unstable, and probably always will be. We encourage +you to test with the version of libutp you have, and be mindful when upgrading. +For this reason, it is probably also a good idea to bundle libutp with your +application. + +## License + +libutp is released under the [MIT][lic] license. + +## Related Work + +Research and analysis of congestion control mechanisms can be found [here.][survey] + +[ledbat]: http://datatracker.ietf.org/wg/ledbat/charter/ +[bep29]: http://www.bittorrent.org/beps/bep_0029.html +[lic]: http://www.opensource.org/licenses/mit-license.php +[survey]: http://datatracker.ietf.org/doc/draft-ietf-ledbat-survey/ diff --git a/vendor/github.com/anacrolix/go-libutp/appveyor.yml b/vendor/github.com/anacrolix/go-libutp/appveyor.yml new file mode 100644 index 000000000..87642db92 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/appveyor.yml @@ -0,0 +1,18 @@ +image: + - Visual Studio 2017 + +environment: + GOPATH: c:\gopath + +install: + - set PATH=%GOPATH%\bin;%PATH% + - set PATH=C:\msys64\mingw64\bin;%PATH% + - go get github.com/anacrolix/envpprof + - go get github.com/anacrolix/tagflag + - go get github.com/stretchr/testify/assert + +build_script: + - go build -v -x -a + +before_test: + - go test -v diff --git a/vendor/github.com/anacrolix/go-libutp/callbacks.go b/vendor/github.com/anacrolix/go-libutp/callbacks.go new file mode 100644 index 000000000..baacd71ef --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/callbacks.go @@ -0,0 +1,131 @@ +package utp + +/* +#include "utp.h" +*/ +import "C" +import ( + "log" + "reflect" + "sync/atomic" + "unsafe" +) + +func (a *C.utp_callback_arguments) bufBytes() []byte { + return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{uintptr(unsafe.Pointer(a.buf)), int(a.len), int(a.len)})) +} + +func (a *C.utp_callback_arguments) state() C.int { + return *(*C.int)(unsafe.Pointer(&a.anon0)) +} + +func (a *C.utp_callback_arguments) error_code() C.int { + return *(*C.int)(unsafe.Pointer(&a.anon0)) +} + +var sends int64 + +//export sendtoCallback +func sendtoCallback(a *C.utp_callback_arguments) (ret C.uint64) { + s := getSocketForLibContext(a.context) + sa := *(**C.struct_sockaddr)(unsafe.Pointer(&a.anon0[0])) + b := a.bufBytes() + addr := structSockaddrToUDPAddr(sa) + atomic.AddInt64(&sends, 1) + if logCallbacks { + Logger.Printf("sending %d bytes, %d packets", len(b), sends) + } + n, err := s.pc.WriteTo(b, addr) + if err != nil { + Logger.Printf("error sending packet: %s", err) + return + } + if n != len(b) { + Logger.Printf("expected to send %d bytes but only sent %d", len(b), n) + } + return +} + +//export errorCallback +func errorCallback(a *C.utp_callback_arguments) C.uint64 { + codeName := libErrorCodeNames(a.error_code()) + if logCallbacks { + log.Printf("error callback: socket %p: %s", a.socket, codeName) + } + libContextToSocket[a.context].conns[a.socket].onLibError(codeName) + return 0 +} + +//export logCallback +func logCallback(a *C.utp_callback_arguments) C.uint64 { + Logger.Printf("libutp: %s", C.GoString((*C.char)(unsafe.Pointer(a.buf)))) + return 0 +} + +//export stateChangeCallback +func stateChangeCallback(a *C.utp_callback_arguments) C.uint64 { + s := libContextToSocket[a.context] + c := s.conns[a.socket] + if logCallbacks { + Logger.Printf("state changed: conn %p: %s", c, libStateName(a.state())) + } + switch a.state() { + case C.UTP_STATE_CONNECT: + c.setConnected() + // A dialled connection will not tell the remote it's ready until it + // writes. If the dialer has no intention of writing, this will stall + // everything. We do an empty write to get things rolling again. This + // circumstance occurs when c1 in the RacyRead nettest is the dialer. + C.utp_write(a.socket, nil, 0) + case C.UTP_STATE_WRITABLE: + c.cond.Broadcast() + case C.UTP_STATE_EOF: + c.setGotEOF() + case C.UTP_STATE_DESTROYING: + c.onDestroyed() + s.onLibSocketDestroyed(a.socket) + default: + panic(a.state) + } + return 0 +} + +//export readCallback +func readCallback(a *C.utp_callback_arguments) C.uint64 { + s := libContextToSocket[a.context] + c := s.conns[a.socket] + b := a.bufBytes() + if logCallbacks { + log.Printf("read callback: conn %p: %d bytes", c, len(b)) + } + if len(b) == 0 { + panic("that will break the read drain invariant") + } + c.readBuf.Write(b) + c.cond.Broadcast() + return 0 +} + +//export acceptCallback +func acceptCallback(a *C.utp_callback_arguments) C.uint64 { + if logCallbacks { + log.Printf("accept callback: %#v", *a) + } + s := getSocketForLibContext(a.context) + s.pushBacklog(s.newConn(a.socket)) + return 0 +} + +//export getReadBufferSizeCallback +func getReadBufferSizeCallback(a *C.utp_callback_arguments) (ret C.uint64) { + s := libContextToSocket[a.context] + c := s.conns[a.socket] + if c == nil { + // socket hasn't been added to the Socket.conns yet. The read buffer + // starts out empty, and the default implementation for this callback + // returns 0, so we'll return that. + return 0 + } + ret = C.uint64(c.readBuf.Len()) + return +} diff --git a/vendor/github.com/anacrolix/go-libutp/conn.go b/vendor/github.com/anacrolix/go-libutp/conn.go new file mode 100644 index 000000000..0a67fb625 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/conn.go @@ -0,0 +1,272 @@ +package utp + +/* +#include "utp.h" +*/ +import "C" +import ( + "bytes" + "context" + "errors" + "io" + "net" + "sync" + "syscall" + "time" + "unsafe" +) + +type Conn struct { + s *C.utp_socket + cond sync.Cond + readBuf bytes.Buffer + gotEOF bool + gotConnect bool + // Set on state changed to UTP_STATE_DESTROYING. Not valid to refer to the + // socket after getting this. + destroyed bool + // Conn.Close was called. + closed bool + libError error + + writeDeadline time.Time + writeDeadlineTimer *time.Timer + readDeadline time.Time + readDeadlineTimer *time.Timer + + numBytesRead int64 + numBytesWritten int64 +} + +func (c *Conn) onLibError(codeName string) { + c.libError = errors.New(codeName) + c.cond.Broadcast() +} + +func (c *Conn) setConnected() { + c.gotConnect = true + c.cond.Broadcast() +} + +func (c *Conn) waitForConnect(ctx context.Context) error { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + go func() { + <-ctx.Done() + c.cond.Broadcast() + }() + for { + if c.libError != nil { + return c.libError + } + if c.gotConnect { + return nil + } + if ctx.Err() != nil { + return ctx.Err() + } + c.cond.Wait() + } +} + +func (c *Conn) Close() (err error) { + mu.Lock() + defer mu.Unlock() + c.close() + return nil +} + +func (c *Conn) close() { + // log.Printf("conn %p: closed", c) + if c.closed { + return + } + if !c.destroyed { + C.utp_close(c.s) + // C.utp_issue_deferred_acks(C.utp_get_context(c.s)) + } + c.closed = true + c.cond.Broadcast() +} + +func (c *Conn) LocalAddr() net.Addr { + mu.Lock() + defer mu.Unlock() + return getSocketForLibContext(C.utp_get_context(c.s)).pc.LocalAddr() +} + +func (c *Conn) readNoWait(b []byte) (n int, err error) { + n, _ = c.readBuf.Read(b) + if n != 0 && c.readBuf.Len() == 0 { + // Can we call this if the utp_socket is closed, destroyed or errored? + if c.s != nil { + C.utp_read_drained(c.s) + // C.utp_issue_deferred_acks(C.utp_get_context(c.s)) + } + } + if c.readBuf.Len() != 0 { + return + } + err = func() error { + switch { + case c.gotEOF: + return io.EOF + case c.libError != nil: + return c.libError + case c.destroyed: + return errors.New("destroyed") + case c.closed: + return errors.New("closed") + case !c.readDeadline.IsZero() && !time.Now().Before(c.readDeadline): + return errDeadlineExceeded{} + default: + return nil + } + }() + return +} + +func (c *Conn) Read(b []byte) (int, error) { + mu.Lock() + defer mu.Unlock() + for { + n, err := c.readNoWait(b) + c.numBytesRead += int64(n) + // log.Printf("read %d bytes", c.numBytesRead) + if n != 0 || len(b) == 0 || err != nil { + // log.Printf("conn %p: read %d bytes: %s", c, n, err) + return n, err + } + c.cond.Wait() + } +} + +func (c *Conn) writeNoWait(b []byte) (n int, err error) { + err = func() error { + switch { + case c.libError != nil: + return c.libError + case c.closed: + return errors.New("closed") + case c.destroyed: + return errors.New("destroyed") + case !c.writeDeadline.IsZero() && !time.Now().Before(c.writeDeadline): + return errDeadlineExceeded{} + default: + return nil + } + }() + if err != nil { + return + } + n = int(C.utp_write(c.s, unsafe.Pointer(&b[0]), C.size_t(len(b)))) + if n < 0 { + panic(n) + } + // log.Print(n) + // C.utp_issue_deferred_acks(C.utp_get_context(c.s)) + return +} + +func (c *Conn) Write(b []byte) (n int, err error) { + // defer func() { log.Printf("wrote %d bytes: %s", n, err) }() + // log.Print(len(b)) + mu.Lock() + defer mu.Unlock() + for len(b) != 0 { + var n1 int + n1, err = c.writeNoWait(b) + b = b[n1:] + n += n1 + if err != nil { + break + } + if n1 != 0 { + continue + } + c.cond.Wait() + } + c.numBytesWritten += int64(n) + // log.Printf("wrote %d bytes", c.numBytesWritten) + return +} + +func (c *Conn) RemoteAddr() net.Addr { + var rsa syscall.RawSockaddrAny + var addrlen C.socklen_t = C.socklen_t(unsafe.Sizeof(rsa)) + C.utp_getpeername(c.s, (*C.struct_sockaddr)(unsafe.Pointer(&rsa)), &addrlen) + sa, err := anyToSockaddr(&rsa) + if err != nil { + panic(err) + } + return sockaddrToUDP(sa) +} + +func (c *Conn) SetDeadline(t time.Time) error { + mu.Lock() + defer mu.Unlock() + c.readDeadline = t + c.writeDeadline = t + if t.IsZero() { + c.readDeadlineTimer.Stop() + c.writeDeadlineTimer.Stop() + } else { + d := t.Sub(time.Now()) + c.readDeadlineTimer.Reset(d) + c.writeDeadlineTimer.Reset(d) + } + c.cond.Broadcast() + return nil +} +func (c *Conn) SetReadDeadline(t time.Time) error { + mu.Lock() + defer mu.Unlock() + c.readDeadline = t + if t.IsZero() { + c.readDeadlineTimer.Stop() + } else { + d := t.Sub(time.Now()) + c.readDeadlineTimer.Reset(d) + } + c.cond.Broadcast() + return nil +} +func (c *Conn) SetWriteDeadline(t time.Time) error { + mu.Lock() + defer mu.Unlock() + c.writeDeadline = t + if t.IsZero() { + c.writeDeadlineTimer.Stop() + } else { + d := t.Sub(time.Now()) + c.writeDeadlineTimer.Reset(d) + } + c.cond.Broadcast() + return nil +} + +func (c *Conn) setGotEOF() { + c.gotEOF = true + c.cond.Broadcast() +} + +func (c *Conn) onDestroyed() { + c.destroyed = true + c.s = nil + c.cond.Broadcast() +} + +func (c *Conn) WriteBufferLen() int { + mu.Lock() + defer mu.Unlock() + return int(C.utp_getsockopt(c.s, C.UTP_SNDBUF)) +} + +func (c *Conn) SetWriteBufferLen(len int) { + mu.Lock() + defer mu.Unlock() + i := C.utp_setsockopt(c.s, C.UTP_SNDBUF, C.int(len)) + if i != 0 { + panic(i) + } +} diff --git a/vendor/github.com/anacrolix/go-libutp/deadline.go b/vendor/github.com/anacrolix/go-libutp/deadline.go new file mode 100644 index 000000000..f5e7b9f10 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/deadline.go @@ -0,0 +1,11 @@ +package utp + +import "net" + +type errDeadlineExceeded struct{} + +var _ net.Error = errDeadlineExceeded{} + +func (errDeadlineExceeded) Error() string { return "deadline exceeded" } +func (errDeadlineExceeded) Temporary() bool { return false } +func (errDeadlineExceeded) Timeout() bool { return true } diff --git a/vendor/github.com/anacrolix/go-libutp/expvars.go b/vendor/github.com/anacrolix/go-libutp/expvars.go new file mode 100644 index 000000000..c9d1acd2a --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/expvars.go @@ -0,0 +1,11 @@ +package utp + +import ( + "expvar" +) + +var ( + socketUtpPacketsReceived = expvar.NewInt("utpSocketUtpPacketsReceived") + socketNonUtpPacketsReceived = expvar.NewInt("utpSocketNonUtpPacketsReceived") + nonUtpPacketsDropped = expvar.NewInt("utpNonUtpPacketsDropped") +) diff --git a/vendor/github.com/anacrolix/go-libutp/libapi.go b/vendor/github.com/anacrolix/go-libutp/libapi.go new file mode 100644 index 000000000..a39b1ca22 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/libapi.go @@ -0,0 +1,16 @@ +package utp + +/* +#include "utp.h" +*/ +import "C" +import "sync" + +var ( + mu sync.Mutex + libContextToSocket = map[*C.utp_context]*Socket{} +) + +func getSocketForLibContext(uc *C.utp_context) *Socket { + return libContextToSocket[uc] +} diff --git a/vendor/github.com/anacrolix/go-libutp/libutp-2012.vcxproj.filters b/vendor/github.com/anacrolix/go-libutp/libutp-2012.vcxproj.filters new file mode 100644 index 000000000..d0eac576e --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/libutp-2012.vcxproj.filters @@ -0,0 +1,65 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/vendor/github.com/anacrolix/go-libutp/libutp.vcxproj b/vendor/github.com/anacrolix/go-libutp/libutp.vcxproj new file mode 100644 index 000000000..580c7a695 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/libutp.vcxproj @@ -0,0 +1,258 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + WinRTDebug + Win32 + + + WinRTDebug + x64 + + + WinRTRelease + Win32 + + + WinRTRelease + x64 + + + + + + + + + + + + + + + + + + + + + + + + {5984D5CD-6ADD-4EB7-82E7-A555888FBBBD} + libutp2012 + libutp + + + + StaticLibrary + true + v140_xp + Unicode + + + StaticLibrary + true + v120_xp + Unicode + + + StaticLibrary + true + v120 + Unicode + + + StaticLibrary + true + v120 + Unicode + + + StaticLibrary + false + true + Unicode + v140_xp + + + StaticLibrary + false + true + Unicode + v120_xp + + + StaticLibrary + false + v120 + true + Unicode + + + StaticLibrary + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + Sync + 4996 + + + true + + + + + Level3 + Disabled + MultiThreadedDebugDLL + + + true + + + + + Level3 + Disabled + + + true + + + + + Level3 + Disabled + + + true + + + + + Level3 + MaxSpeed + true + true + _WIN32_WINNT=0x501;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + Sync + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + %(PreprocessorDefinitions) + MultiThreadedDLL + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + + + true + true + true + + + + + + \ No newline at end of file diff --git a/vendor/github.com/anacrolix/go-libutp/libutp_inet_ntop.h b/vendor/github.com/anacrolix/go-libutp/libutp_inet_ntop.h new file mode 100644 index 000000000..33881d624 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/libutp_inet_ntop.h @@ -0,0 +1,68 @@ +#ifndef LIBUTP_INET_NTOP_H +#define LIBUTP_INET_NTOP_H + +/* + * Copyright (c) 2010-2013 BitTorrent, Inc. + * + * 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. + */ + +// About us linking the system inet_pton and inet_ntop symbols: +// 1) These symbols are usually defined on POSIX systems +// 2) They are not defined on Windows versions earlier than Vista +// Defined in: +// ut_utils/src/sockaddr.cpp +// libutp/win32_inet_ntop.obj +// +// When we drop support for XP we can just #include , and use the system functions +// For now, we will always use our functions on windows, on all builds +// The reason is: we would like the debug build to behave as much as the release build as possible +// It is much better to catch a problem in the debug build, than to link the system version +// in debug, and our version int he wild. + +#if defined(_WIN32_WINNT) +#if _WIN32_WINNT >= 0x600 // Win32, post-XP +#include // for inet_ntop, inet_pton +#define INET_NTOP inet_ntop +#define INET_PTON inet_pton +#else +#define INET_NTOP libutp::inet_ntop // Win32, pre-XP: Use ours +#define INET_PTON libutp::inet_pton +#endif +#else // not WIN32 +#include // for inet_ntop, inet_pton +#define INET_NTOP inet_ntop +#define INET_PTON inet_pton +#endif + +//###################################################################### +//###################################################################### +namespace libutp { + + +//###################################################################### +const char *inet_ntop(int af, const void *src, char *dest, size_t length); + +//###################################################################### +int inet_pton(int af, const char* src, void* dest); + + +} //namespace libutp + +#endif // LIBUTP_INET_NTOP_H \ No newline at end of file diff --git a/vendor/github.com/anacrolix/go-libutp/logging.go b/vendor/github.com/anacrolix/go-libutp/logging.go new file mode 100644 index 000000000..1af5f4e23 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/logging.go @@ -0,0 +1,13 @@ +package utp + +import ( + "log" + "os" +) + +const ( + logCallbacks = false + utpLogging = false +) + +var Logger = log.New(os.Stderr, "go-libutp: ", log.LstdFlags|log.Lshortfile) diff --git a/vendor/github.com/anacrolix/go-libutp/parse_log.py b/vendor/github.com/anacrolix/go-libutp/parse_log.py new file mode 100644 index 000000000..44f69256e --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/parse_log.py @@ -0,0 +1,288 @@ +import os, sys, time + +# usage: parse_log.py log-file [socket-index to focus on] + + +socket_filter = None +if len(sys.argv) >= 3: + socket_filter = sys.argv[2].strip() + +if socket_filter == None: + print "scanning for socket with the most packets" + file = open(sys.argv[1], 'rb') + + sockets = {} + + for l in file: + if not 'our_delay' in l: continue + + try: + a = l.strip().split(" ") + socket_index = a[1][:-1] + except: + continue + + # msvc's runtime library doesn't prefix pointers + # with '0x' +# if socket_index[:2] != '0x': +# continue + + if socket_index in sockets: + sockets[socket_index] += 1 + else: + sockets[socket_index] = 1 + + items = sockets.items() + items.sort(lambda x, y: y[1] - x[1]) + + count = 0 + for i in items: + print '%s: %d' % (i[0], i[1]) + count += 1 + if count > 5: break + + file.close() + socket_filter = items[0][0] + print '\nfocusing on socket %s' % socket_filter + +file = open(sys.argv[1], 'rb') +out_file = 'utp.out%s' % socket_filter; +out = open(out_file, 'wb') + +delay_samples = 'dots lc rgb "blue"' +delay_base = 'steps lw 2 lc rgb "purple"' +target_delay = 'steps lw 2 lc rgb "red"' +off_target = 'dots lc rgb "blue"' +cwnd = 'steps lc rgb "green"' +window_size = 'steps lc rgb "sea-green"' +rtt = 'lines lc rgb "light-blue"' + +metrics = { + 'our_delay':['our delay (ms)', 'x1y2', delay_samples], + 'upload_rate':['send rate (B/s)', 'x1y1', 'lines'], + 'max_window':['cwnd (B)', 'x1y1', cwnd], + 'target_delay':['target delay (ms)', 'x1y2', target_delay], + 'cur_window':['bytes in-flight (B)', 'x1y1', window_size], + 'cur_window_packets':['number of packets in-flight', 'x1y2', 'steps'], + 'packet_size':['current packet size (B)', 'x1y2', 'steps'], + 'rtt':['rtt (ms)', 'x1y2', rtt], + 'off_target':['off-target (ms)', 'x1y2', off_target], + 'delay_sum':['delay sum (ms)', 'x1y2', 'steps'], + 'their_delay':['their delay (ms)', 'x1y2', delay_samples], + 'get_microseconds':['clock (us)', 'x1y1', 'steps'], + 'wnduser':['advertised window size (B)', 'x1y1', 'steps'], + + 'delay_base':['delay base (us)', 'x1y1', delay_base], + 'their_delay_base':['their delay base (us)', 'x1y1', delay_base], + 'their_actual_delay':['their actual delay (us)', 'x1y1', delay_samples], + 'actual_delay':['actual_delay (us)', 'x1y1', delay_samples] +} + +histogram_quantization = 1 +socket_index = None + +columns = [] + +begin = None + +title = "-" +packet_loss = 0 +packet_timeout = 0 + +delay_histogram = {} +window_size = {'0': 0, '1': 0} + +# [35301484] 0x00ec1190: actual_delay:1021583 our_delay:102 their_delay:-1021345 off_target:297 max_window:2687 upload_rate:18942 delay_base:1021481154 delay_sum:-1021242 target_delay:400 acked_bytes:1441 cur_window:2882 scaled_gain:2.432 + +counter = 0 + +print "reading log file" + +for l in file: + if "UTP_Connect" in l: + title = l[:-2] + if socket_filter != None: + title += ' socket: %s' % socket_filter + else: + title += ' sum of all sockets' + continue + + try: + a = l.strip().split(" ") + t = a[0][1:-1] + socket_index = a[1][:-1] + except: + continue +# if socket_index[:2] != '0x': +# continue + + if socket_filter != None and socket_index != socket_filter: + continue + + counter += 1 + if (counter % 300 == 0): + print "\r%d " % counter, + + if "lost." in l: + packet_loss = packet_loss + 1 + continue + if "Packet timeout" in l: + packet_timeout = packet_timeout + 1 + continue + if "our_delay:" not in l: + continue + +# used for Logf timestamps +# t, m = t.split(".") +# t = time.strptime(t, "%H:%M:%S") +# t = list(t) +# t[0] += 107 +# t = tuple(t) +# m = float(m) +# m /= 1000.0 +# t = time.mktime(t) + m + +# used for tick count timestamps + t = int(t) + + if begin is None: + begin = t + t = t - begin + # print time. Convert from milliseconds to seconds + print >>out, '%f\t' % (float(t)/1000.), + + #if t > 200000: + # break + + fill_columns = not columns + for i in a[2:]: + try: + n, v = i.split(':') + except: + continue + v = float(v) + if n == "our_delay": + bucket = v / histogram_quantization + delay_histogram[bucket] = 1 + delay_histogram.get(bucket, 0) + if not n in metrics: continue + if fill_columns: + columns.append(n) + if n == "max_window": + window_size[socket_index] = v + print >>out, '%f\t' % int(reduce(lambda a,b: a+b, window_size.values())), + else: + print >>out, '%f\t' % v, + print >>out, float(packet_loss * 8000), float(packet_timeout * 8000) + packet_loss = 0 + packet_timeout = 0 + +out.close() + +out = open('%s.histogram' % out_file, 'wb') +for d,f in delay_histogram.iteritems(): + print >>out, float(d*histogram_quantization) + histogram_quantization / 2, f +out.close() + + +plot = [ + { + 'data': ['upload_rate', 'max_window', 'cur_window', 'wnduser', 'cur_window_packets', 'packet_size', 'rtt'], + 'title': 'send-packet-size', + 'y1': 'Bytes', + 'y2': 'Time (ms)' + }, + { + 'data': ['our_delay', 'max_window', 'target_delay', 'cur_window', 'wnduser', 'cur_window_packets'], + 'title': 'uploading', + 'y1': 'Bytes', + 'y2': 'Time (ms)' + }, + { + 'data': ['our_delay', 'max_window', 'target_delay', 'cur_window', 'cur_window_packets'], + 'title': 'uploading_packets', + 'y1': 'Bytes', + 'y2': 'Time (ms)' + }, + { + 'data': ['get_microseconds'], + 'title': 'timer', + 'y1': 'Time microseconds', + 'y2': 'Time (ms)' + }, + { + 'data': ['their_delay', 'target_delay', 'rtt'], + 'title': 'their_delay', + 'y1': '', + 'y2': 'Time (ms)' + }, + { + 'data': ['their_actual_delay','their_delay_base'], + 'title': 'their_delay_base', + 'y1': 'Time (us)', + 'y2': '' + }, + { + 'data': ['our_delay', 'target_delay', 'rtt'], + 'title': 'our-delay', + 'y1': '', + 'y2': 'Time (ms)' + }, + { + 'data': ['actual_delay', 'delay_base'], + 'title': 'our_delay_base', + 'y1': 'Time (us)', + 'y2': '' + } +] + +out = open('utp.gnuplot', 'w+') + +files = '' + +#print >>out, 'set xtics 0, 20' +print >>out, "set term png size 1280,800" +print >>out, 'set output "%s.delays.png"' % out_file +print >>out, 'set xrange [0:250]' +print >>out, 'set xlabel "delay (ms)"' +print >>out, 'set boxwidth 1' +print >>out, 'set style fill solid' +print >>out, 'set ylabel "number of packets"' +print >>out, 'plot "%s.histogram" using 1:2 with boxes' % out_file + +print >>out, "set style data steps" +#print >>out, "set yrange [0:*]" +print >>out, "set y2range [*:*]" +files += out_file + '.delays.png ' +#set hidden3d +#set title "Peer bandwidth distribution" +#set xlabel "Ratio" + +for p in plot: + print >>out, 'set title "%s %s"' % (p['title'], title) + print >>out, 'set xlabel "time (s)"' + print >>out, 'set ylabel "%s"' % p['y1'] + print >>out, "set tics nomirror" + print >>out, 'set y2tics' + print >>out, 'set y2label "%s"' % p['y2'] + print >>out, 'set xrange [0:*]' + print >>out, "set key box" + print >>out, "set term png size 1280,800" + print >>out, 'set output "%s-%s.png"' % (out_file, p['title']) + files += '%s-%s.png ' % (out_file, p['title']) + + comma = '' + print >>out, "plot", + + for c in p['data']: + if not c in metrics: continue + i = columns.index(c) + print >>out, '%s"%s" using 1:%d title "%s-%s" axes %s with %s' % (comma, out_file, i + 2, metrics[c][0], metrics[c][1], metrics[c][1], metrics[c][2]), + comma = ', ' + print >>out, '' + +out.close() + +os.system("gnuplot utp.gnuplot") + +os.system("open %s" % files) + diff --git a/vendor/github.com/anacrolix/go-libutp/sockaddr.go b/vendor/github.com/anacrolix/go-libutp/sockaddr.go new file mode 100644 index 000000000..a1e957ffd --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/sockaddr.go @@ -0,0 +1,114 @@ +package utp + +/* +#include "utp.h" +*/ +import "C" +import ( + "net" + "strconv" + "syscall" + + "github.com/anacrolix/missinggo/inproc" + + "unsafe" +) + +func toSockaddrInet(ip net.IP, port int, zone string) (*C.struct_sockaddr, C.socklen_t) { + if ip4 := ip.To4(); ip4 != nil && zone == "" { + rsa := syscall.RawSockaddrInet4{ + // Len: syscall.SizeofSockaddrInet4, + Family: syscall.AF_INET, + Port: uint16(port), + } + if n := copy(rsa.Addr[:], ip4); n != 4 { + panic(n) + } + return (*C.struct_sockaddr)(unsafe.Pointer(&rsa)), C.socklen_t(unsafe.Sizeof(rsa)) + } + rsa := syscall.RawSockaddrInet6{ + // Len: syscall.SizeofSockaddrInet6, + Family: syscall.AF_INET6, + Scope_id: zoneToScopeId(zone), + Port: uint16(port), + } + if n := copy(rsa.Addr[:], ip); n != 16 { + panic(n) + } + return (*C.struct_sockaddr)(unsafe.Pointer(&rsa)), C.socklen_t(unsafe.Sizeof(rsa)) +} + +func zoneToScopeId(zone string) uint32 { + if zone == "" { + return 0 + } + if ifi, err := net.InterfaceByName(zone); err == nil { + return uint32(ifi.Index) + } + ui64, _ := strconv.ParseUint(zone, 10, 32) + return uint32(ui64) +} + +func structSockaddrToUDPAddr(sa *C.struct_sockaddr) *net.UDPAddr { + meh, err := anyToSockaddr((*syscall.RawSockaddrAny)(unsafe.Pointer(sa))) + if err != nil { + panic(err) + } + return sockaddrToUDP(meh).(*net.UDPAddr) +} + +func anyToSockaddr(rsa *syscall.RawSockaddrAny) (syscall.Sockaddr, error) { + // log.Printf("anyToSockaddr %#v", rsa) + switch rsa.Addr.Family { + + case syscall.AF_INET: + pp := (*syscall.RawSockaddrInet4)(unsafe.Pointer(rsa)) + sa := new(syscall.SockaddrInet4) + // p := (*[2]byte)(unsafe.Pointer(&pp.Port)) + // sa.Port = int(p[0])<<8 + int(p[1]) + // I don't know why the port isn't reversed when it comes from utp. + sa.Port = int(pp.Port) + for i := 0; i < len(sa.Addr); i++ { + sa.Addr[i] = pp.Addr[i] + } + return sa, nil + + case syscall.AF_INET6: + pp := (*syscall.RawSockaddrInet6)(unsafe.Pointer(rsa)) + sa := new(syscall.SockaddrInet6) + // p := (*[2]byte)(unsafe.Pointer(&pp.Port)) + // sa.Port = int(p[0])<<8 + int(p[1]) + // I don't know why the port isn't reversed when it comes from utp. + sa.Port = int(pp.Port) + sa.ZoneId = pp.Scope_id + for i := 0; i < len(sa.Addr); i++ { + sa.Addr[i] = pp.Addr[i] + } + return sa, nil + } + return nil, syscall.EAFNOSUPPORT +} + +func sockaddrToUDP(sa syscall.Sockaddr) net.Addr { + switch sa := sa.(type) { + case *syscall.SockaddrInet4: + return &net.UDPAddr{IP: sa.Addr[0:], Port: sa.Port} + case *syscall.SockaddrInet6: + return &net.UDPAddr{IP: sa.Addr[0:], Port: sa.Port /*Zone: zoneToString(int(sa.ZoneId))*/} + } + return nil +} + +func netAddrToLibSockaddr(na net.Addr) (*C.struct_sockaddr, C.socklen_t) { + switch v := na.(type) { + case *net.UDPAddr: + return toSockaddrInet(v.IP, v.Port, v.Zone) + case inproc.Addr: + rsa := syscall.RawSockaddrInet6{ + Port: uint16(v.Port), + } + return (*C.struct_sockaddr)(unsafe.Pointer(&rsa)), C.socklen_t(unsafe.Sizeof(rsa)) + default: + panic(na) + } +} diff --git a/vendor/github.com/anacrolix/go-libutp/socket.go b/vendor/github.com/anacrolix/go-libutp/socket.go new file mode 100644 index 000000000..13c95d429 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/socket.go @@ -0,0 +1,282 @@ +package utp + +/* +#include "utp.h" +*/ +import "C" +import ( + "context" + "errors" + "net" + "sync/atomic" + "time" + + "github.com/anacrolix/missinggo/inproc" +) + +type Socket struct { + pc net.PacketConn + ctx *C.utp_context + backlog chan *Conn + closed bool + conns map[*C.utp_socket]*Conn + nonUtpReads chan packet + writeDeadline time.Time + readDeadline time.Time +} + +var ( + _ net.PacketConn = (*Socket)(nil) +) + +type packet struct { + b []byte + from net.Addr +} + +func listenPacket(network, addr string) (pc net.PacketConn, err error) { + if network == "inproc" { + return inproc.ListenPacket(network, addr) + } + return net.ListenPacket(network, addr) +} + +func NewSocket(network, addr string) (*Socket, error) { + pc, err := listenPacket(network, addr) + if err != nil { + return nil, err + } + mu.Lock() + defer mu.Unlock() + ctx := C.utp_init(2) + if ctx == nil { + panic(ctx) + } + ctx.setCallbacks() + if utpLogging { + ctx.setOption(C.UTP_LOG_NORMAL, 1) + ctx.setOption(C.UTP_LOG_MTU, 1) + ctx.setOption(C.UTP_LOG_DEBUG, 1) + } + s := &Socket{ + pc: pc, + ctx: ctx, + backlog: make(chan *Conn, 5), + conns: make(map[*C.utp_socket]*Conn), + nonUtpReads: make(chan packet, 100), + } + libContextToSocket[ctx] = s + go s.timeoutChecker() + go s.packetReader() + return s, nil +} + +func (s *Socket) onLibSocketDestroyed(ls *C.utp_socket) { + delete(s.conns, ls) +} + +func (s *Socket) newConn(us *C.utp_socket) *Conn { + c := &Conn{ + s: us, + } + c.cond.L = &mu + s.conns[us] = c + c.writeDeadlineTimer = time.AfterFunc(-1, c.cond.Broadcast) + c.readDeadlineTimer = time.AfterFunc(-1, c.cond.Broadcast) + return c +} + +var reads int64 + +func (s *Socket) packetReader() { + var b [0x1000]byte + for { + // In C, all the reads are processed and when it threatens to block, + // only then do we call utp_issue_deferred_acks. I don't know how we + // can do this in Go. + n, addr, err := s.pc.ReadFrom(b[:]) + if err != nil { + mu.Lock() + closed := s.closed + mu.Unlock() + if closed { + return + } + panic(err) + } + sa, sal := netAddrToLibSockaddr(addr) + atomic.AddInt64(&reads, 1) + // log.Printf("received %d bytes, %d packets", n, reads) + func() { + mu.Lock() + defer mu.Unlock() + if s.closed { + return + } + ret := C.utp_process_udp(s.ctx, (*C.byte)(&b[0]), C.size_t(n), sa, sal) + switch ret { + case 1: + socketUtpPacketsReceived.Add(1) + C.utp_issue_deferred_acks(s.ctx) + C.utp_check_timeouts(s.ctx) + case 0: + s.onReadNonUtp(b[:n], addr) + default: + panic(ret) + } + }() + } +} + +func (s *Socket) timeoutChecker() { + for { + mu.Lock() + if s.closed { + mu.Unlock() + return + } + // C.utp_issue_deferred_acks(s.ctx) + C.utp_check_timeouts(s.ctx) + mu.Unlock() + time.Sleep(500 * time.Millisecond) + } +} + +func (me *Socket) Close() error { + mu.Lock() + defer mu.Unlock() + if me.closed { + return nil + } + C.utp_destroy(me.ctx) + me.ctx = nil + me.pc.Close() + close(me.backlog) + close(me.nonUtpReads) + me.closed = true + return nil +} + +func (me *Socket) Addr() net.Addr { + return me.pc.LocalAddr() +} + +func (me *Socket) LocalAddr() net.Addr { + return me.pc.LocalAddr() +} + +func (s *Socket) Accept() (net.Conn, error) { + nc, ok := <-s.backlog + if !ok { + return nil, errors.New("closed") + } + return nc, nil +} + +func (s *Socket) Dial(addr string) (net.Conn, error) { + return s.DialTimeout(addr, 0) +} + +func (s *Socket) DialTimeout(addr string, timeout time.Duration) (net.Conn, error) { + ctx := context.Background() + if timeout != 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, timeout) + defer cancel() + } + return s.DialContext(ctx, addr) +} + +func (s *Socket) resolveAddr(addr string) (net.Addr, error) { + n := s.Addr().Network() + switch n { + case "inproc": + return inproc.ResolveAddr(n, addr) + default: + return net.ResolveUDPAddr(n, addr) + } +} + +func (s *Socket) DialContext(ctx context.Context, addr string) (net.Conn, error) { + ua, err := s.resolveAddr(addr) + if err != nil { + panic(err) + } + sa, sl := netAddrToLibSockaddr(ua) + mu.Lock() + c := s.newConn(C.utp_create_socket(s.ctx)) + C.utp_connect(c.s, sa, sl) + defer mu.Unlock() + err = c.waitForConnect(ctx) + if err != nil { + c.close() + return nil, err + } + return c, nil +} + +func (s *Socket) pushBacklog(c *Conn) { + select { + case s.backlog <- c: + default: + c.close() + } +} + +func (s *Socket) ReadFrom(b []byte) (n int, addr net.Addr, err error) { + p, ok := <-s.nonUtpReads + if !ok { + err = errors.New("closed") + return + } + n = copy(b, p.b) + addr = p.from + return +} + +func (s *Socket) onReadNonUtp(b []byte, from net.Addr) { + socketNonUtpPacketsReceived.Add(1) + select { + case s.nonUtpReads <- packet{append([]byte(nil), b...), from}: + default: + // log.Printf("dropped non utp packet: no room in buffer") + nonUtpPacketsDropped.Add(1) + } +} + +func (s *Socket) SetReadDeadline(t time.Time) error { + panic("not implemented") +} + +func (s *Socket) SetWriteDeadline(t time.Time) error { + panic("not implemented") +} + +func (s *Socket) SetDeadline(t time.Time) error { + panic("not implemented") +} + +func (s *Socket) WriteTo(b []byte, addr net.Addr) (int, error) { + return s.pc.WriteTo(b, addr) +} + +func (s *Socket) ReadBufferLen() int { + mu.Lock() + defer mu.Unlock() + return int(C.utp_context_get_option(s.ctx, C.UTP_RCVBUF)) +} + +func (s *Socket) WriteBufferLen() int { + mu.Lock() + defer mu.Unlock() + return int(C.utp_context_get_option(s.ctx, C.UTP_SNDBUF)) +} + +func (s *Socket) SetWriteBufferLen(len int) { + mu.Lock() + defer mu.Unlock() + i := C.utp_context_set_option(s.ctx, C.UTP_SNDBUF, C.int(len)) + if i != 0 { + panic(i) + } +} diff --git a/vendor/github.com/anacrolix/go-libutp/status.go b/vendor/github.com/anacrolix/go-libutp/status.go new file mode 100644 index 000000000..9973b93ce --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/status.go @@ -0,0 +1,17 @@ +package utp + +import ( + "fmt" + "io" +) + +func WriteStatus(w io.Writer) { + mu.Lock() + defer mu.Unlock() + for _, s := range libContextToSocket { + fmt.Fprintf(w, "listening at %s\n", s.Addr()) + fmt.Fprintf(w, "has %d conns\n", len(s.conns)) + fmt.Fprintf(w, "backlog: %d\n", len(s.backlog)) + fmt.Fprintf(w, "\n") + } +} diff --git a/vendor/github.com/anacrolix/go-libutp/utp.go b/vendor/github.com/anacrolix/go-libutp/utp.go new file mode 100644 index 000000000..38089f521 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/utp.go @@ -0,0 +1,48 @@ +package utp + +/* +#cgo CPPFLAGS: -DPOSIX -DUTP_DEBUG_LOGGING=0 +#cgo CFLAGS: -Wall -O3 -fno-exceptions +// These are all copied from the libutp Makefile. +#cgo CXXFLAGS: -Wall -O3 -fno-exceptions -fPIC -fno-rtti -Wno-sign-compare -fpermissive +// There are some variables that aren't used unless UTP_DEBUG_LOGGING is defined. +#cgo CXXFLAGS: -Wno-unused-const-variable +// Windows additional flags +#cgo windows LDFLAGS: -lws2_32 +#cgo windows CXXFLAGS: -D_WIN32_WINNT=0x600 +#include "utp.h" + +uint64_t errorCallback(utp_callback_arguments *); +uint64_t logCallback(utp_callback_arguments *); +uint64_t acceptCallback(utp_callback_arguments *); +uint64_t sendtoCallback(utp_callback_arguments *); +uint64_t stateChangeCallback(utp_callback_arguments *); +uint64_t readCallback(utp_callback_arguments *); +uint64_t getReadBufferSizeCallback(utp_callback_arguments *); +*/ +import "C" +import "unsafe" + +type socklen C.socklen_t + +func (ctx *C.utp_context) setCallbacks() { + C.utp_set_callback(ctx, C.UTP_LOG, (*C.utp_callback_t)(C.logCallback)) + C.utp_set_callback(ctx, C.UTP_ON_ACCEPT, (*C.utp_callback_t)(C.acceptCallback)) + C.utp_set_callback(ctx, C.UTP_SENDTO, (*C.utp_callback_t)(C.sendtoCallback)) + C.utp_set_callback(ctx, C.UTP_ON_STATE_CHANGE, (*C.utp_callback_t)(C.stateChangeCallback)) + C.utp_set_callback(ctx, C.UTP_ON_READ, (*C.utp_callback_t)(C.readCallback)) + C.utp_set_callback(ctx, C.UTP_ON_ERROR, (*C.utp_callback_t)(C.errorCallback)) + C.utp_set_callback(ctx, C.UTP_GET_READ_BUFFER_SIZE, (*C.utp_callback_t)(C.getReadBufferSizeCallback)) +} + +func (ctx *C.utp_context) setOption(opt, val int) int { + return int(C.utp_context_set_option(ctx, C.int(opt), C.int(val))) +} + +func libStateName(state C.int) string { + return C.GoString((*[5]*C.char)(unsafe.Pointer(&C.utp_state_names))[state]) +} + +func libErrorCodeNames(error_code C.int) string { + return C.GoString((*[3]*C.char)(unsafe.Pointer(&C.utp_error_code_names))[error_code]) +} diff --git a/vendor/github.com/anacrolix/go-libutp/utp.h b/vendor/github.com/anacrolix/go-libutp/utp.h new file mode 100644 index 000000000..eeca22bc8 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/utp.h @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2010-2013 BitTorrent, Inc. + * + * 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. + */ + +#ifndef __UTP_H__ +#define __UTP_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _WIN32 +#include +#endif + +#include +#include "utp_types.h" + +typedef struct UTPSocket utp_socket; +typedef struct struct_utp_context utp_context; + +enum { + UTP_UDP_DONTFRAG = 2, // Used to be a #define as UDP_IP_DONTFRAG +}; + +enum { + // socket has reveived syn-ack (notification only for outgoing connection completion) + // this implies writability + UTP_STATE_CONNECT = 1, + + // socket is able to send more data + UTP_STATE_WRITABLE = 2, + + // connection closed + UTP_STATE_EOF = 3, + + // socket is being destroyed, meaning all data has been sent if possible. + // it is not valid to refer to the socket after this state change occurs + UTP_STATE_DESTROYING = 4, +}; + +extern const char *utp_state_names[]; + +// Errors codes that can be passed to UTP_ON_ERROR callback +enum { + UTP_ECONNREFUSED = 0, + UTP_ECONNRESET, + UTP_ETIMEDOUT, +}; + +extern const char *utp_error_code_names[]; + +enum { + // callback names + UTP_ON_FIREWALL = 0, + UTP_ON_ACCEPT, + UTP_ON_CONNECT, + UTP_ON_ERROR, + UTP_ON_READ, + UTP_ON_OVERHEAD_STATISTICS, + UTP_ON_STATE_CHANGE, + UTP_GET_READ_BUFFER_SIZE, + UTP_ON_DELAY_SAMPLE, + UTP_GET_UDP_MTU, + UTP_GET_UDP_OVERHEAD, + UTP_GET_MILLISECONDS, + UTP_GET_MICROSECONDS, + UTP_GET_RANDOM, + UTP_LOG, + UTP_SENDTO, + + // context and socket options that may be set/queried + UTP_LOG_NORMAL, + UTP_LOG_MTU, + UTP_LOG_DEBUG, + UTP_SNDBUF, + UTP_RCVBUF, + UTP_TARGET_DELAY, + + UTP_ARRAY_SIZE, // must be last +}; + +extern const char *utp_callback_names[]; + +typedef struct { + utp_context *context; + utp_socket *socket; + size_t len; + uint32 flags; + int callback_type; + const byte *buf; + + union { + const struct sockaddr *address; + int send; + int sample_ms; + int error_code; + int state; + }; + + union { + socklen_t address_len; + int type; + }; +} utp_callback_arguments; + +typedef uint64 utp_callback_t(utp_callback_arguments *); + +// Returned by utp_get_context_stats() +typedef struct { + uint32 _nraw_recv[5]; // total packets recieved less than 300/600/1200/MTU bytes fpr all connections (context-wide) + uint32 _nraw_send[5]; // total packets sent less than 300/600/1200/MTU bytes for all connections (context-wide) +} utp_context_stats; + +// Returned by utp_get_stats() +typedef struct { + uint64 nbytes_recv; // total bytes received + uint64 nbytes_xmit; // total bytes transmitted + uint32 rexmit; // retransmit counter + uint32 fastrexmit; // fast retransmit counter + uint32 nxmit; // transmit counter + uint32 nrecv; // receive counter (total) + uint32 nduprecv; // duplicate receive counter + uint32 mtu_guess; // Best guess at MTU +} utp_socket_stats; + +#define UTP_IOV_MAX 1024 + +// For utp_writev, to writes data from multiple buffers +struct utp_iovec { + void *iov_base; + size_t iov_len; +}; + +// Public Functions +utp_context* utp_init (int version); +void utp_destroy (utp_context *ctx); +void utp_set_callback (utp_context *ctx, int callback_name, utp_callback_t *proc); +void* utp_context_set_userdata (utp_context *ctx, void *userdata); +void* utp_context_get_userdata (utp_context *ctx); +int utp_context_set_option (utp_context *ctx, int opt, int val); +int utp_context_get_option (utp_context *ctx, int opt); +int utp_process_udp (utp_context *ctx, const byte *buf, size_t len, const struct sockaddr *to, socklen_t tolen); +int utp_process_icmp_error (utp_context *ctx, const byte *buffer, size_t len, const struct sockaddr *to, socklen_t tolen); +int utp_process_icmp_fragmentation (utp_context *ctx, const byte *buffer, size_t len, const struct sockaddr *to, socklen_t tolen, uint16 next_hop_mtu); +void utp_check_timeouts (utp_context *ctx); +void utp_issue_deferred_acks (utp_context *ctx); +utp_context_stats* utp_get_context_stats (utp_context *ctx); +utp_socket* utp_create_socket (utp_context *ctx); +void* utp_set_userdata (utp_socket *s, void *userdata); +void* utp_get_userdata (utp_socket *s); +int utp_setsockopt (utp_socket *s, int opt, int val); +int utp_getsockopt (utp_socket *s, int opt); +int utp_connect (utp_socket *s, const struct sockaddr *to, socklen_t tolen); +ssize_t utp_write (utp_socket *s, void *buf, size_t count); +ssize_t utp_writev (utp_socket *s, struct utp_iovec *iovec, size_t num_iovecs); +int utp_getpeername (utp_socket *s, struct sockaddr *addr, socklen_t *addrlen); +void utp_read_drained (utp_socket *s); +int utp_get_delays (utp_socket *s, uint32 *ours, uint32 *theirs, uint32 *age); +utp_socket_stats* utp_get_stats (utp_socket *s); +utp_context* utp_get_context (utp_socket *s); +void utp_close (utp_socket *s); + +#ifdef __cplusplus +} +#endif + +#endif //__UTP_H__ diff --git a/vendor/github.com/anacrolix/go-libutp/utp_api.cpp b/vendor/github.com/anacrolix/go-libutp/utp_api.cpp new file mode 100644 index 000000000..63aff189c --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/utp_api.cpp @@ -0,0 +1,139 @@ +// vim:set ts=4 sw=4 ai: + +/* + * Copyright (c) 2010-2013 BitTorrent, Inc. + * + * 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. + */ + +#include +#include "utp_internal.h" +#include "utp_utils.h" + +extern "C" { + +const char * utp_callback_names[] = { + "UTP_ON_FIREWALL", + "UTP_ON_ACCEPT", + "UTP_ON_CONNECT", + "UTP_ON_ERROR", + "UTP_ON_READ", + "UTP_ON_OVERHEAD_STATISTICS", + "UTP_ON_STATE_CHANGE", + "UTP_GET_READ_BUFFER_SIZE", + "UTP_ON_DELAY_SAMPLE", + "UTP_GET_UDP_MTU", + "UTP_GET_UDP_OVERHEAD", + "UTP_GET_MILLISECONDS", + "UTP_GET_MICROSECONDS", + "UTP_GET_RANDOM", + "UTP_LOG", + "UTP_SENDTO", +}; + +const char * utp_error_code_names[] = { + "UTP_ECONNREFUSED", + "UTP_ECONNRESET", + "UTP_ETIMEDOUT", +}; + +const char *utp_state_names[] = { + NULL, + "UTP_STATE_CONNECT", + "UTP_STATE_WRITABLE", + "UTP_STATE_EOF", + "UTP_STATE_DESTROYING", +}; + +struct_utp_context::struct_utp_context() + : userdata(NULL) + , current_ms(0) + , last_utp_socket(NULL) + , log_normal(false) + , log_mtu(false) + , log_debug(false) +{ + memset(&context_stats, 0, sizeof(context_stats)); + memset(callbacks, 0, sizeof(callbacks)); + target_delay = CCONTROL_TARGET; + utp_sockets = new UTPSocketHT; + + callbacks[UTP_GET_UDP_MTU] = &utp_default_get_udp_mtu; + callbacks[UTP_GET_UDP_OVERHEAD] = &utp_default_get_udp_overhead; + callbacks[UTP_GET_MILLISECONDS] = &utp_default_get_milliseconds; + callbacks[UTP_GET_MICROSECONDS] = &utp_default_get_microseconds; + callbacks[UTP_GET_RANDOM] = &utp_default_get_random; + + // 1 MB of receive buffer (i.e. max bandwidth delay product) + // means that from a peer with 200 ms RTT, we cannot receive + // faster than 5 MB/s + // from a peer with 10 ms RTT, we cannot receive faster than + // 100 MB/s. This is assumed to be good enough, since bandwidth + // often is proportional to RTT anyway + // when setting a download rate limit, all sockets should have + // their receive buffer set much lower, to say 60 kiB or so + opt_rcvbuf = opt_sndbuf = 1024 * 1024; + last_check = 0; +} + +struct_utp_context::~struct_utp_context() { + delete this->utp_sockets; +} + +utp_context* utp_init (int version) +{ + assert(version == 2); + if (version != 2) + return NULL; + utp_context *ctx = new utp_context; + return ctx; +} + +void utp_destroy(utp_context *ctx) { + assert(ctx); + if (ctx) delete ctx; +} + +void utp_set_callback(utp_context *ctx, int callback_name, utp_callback_t *proc) { + assert(ctx); + if (ctx) ctx->callbacks[callback_name] = proc; +} + +void* utp_context_set_userdata(utp_context *ctx, void *userdata) { + assert(ctx); + if (ctx) ctx->userdata = userdata; + return ctx ? ctx->userdata : NULL; +} + +void* utp_context_get_userdata(utp_context *ctx) { + assert(ctx); + return ctx ? ctx->userdata : NULL; +} + +utp_context_stats* utp_get_context_stats(utp_context *ctx) { + assert(ctx); + return ctx ? &ctx->context_stats : NULL; +} + +ssize_t utp_write(utp_socket *socket, void *buf, size_t len) { + struct utp_iovec iovec = { buf, len }; + return utp_writev(socket, &iovec, 1); +} + +} diff --git a/vendor/github.com/anacrolix/go-libutp/utp_callbacks.cpp b/vendor/github.com/anacrolix/go-libutp/utp_callbacks.cpp new file mode 100644 index 000000000..9540d8c40 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/utp_callbacks.cpp @@ -0,0 +1,208 @@ +// vim:set ts=4 sw=4 ai: + +/* + * Copyright (c) 2010-2013 BitTorrent, Inc. + * + * 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. + */ + +#include "utp_callbacks.h" + +int utp_call_on_firewall(utp_context *ctx, const struct sockaddr *address, socklen_t address_len) +{ + utp_callback_arguments args; + if (!ctx->callbacks[UTP_ON_FIREWALL]) return 0; + args.callback_type = UTP_ON_FIREWALL; + args.context = ctx; + args.socket = NULL; + args.address = address; + args.address_len = address_len; + return (int)ctx->callbacks[UTP_ON_FIREWALL](&args); +} + +void utp_call_on_accept(utp_context *ctx, utp_socket *socket, const struct sockaddr *address, socklen_t address_len) +{ + utp_callback_arguments args; + if (!ctx->callbacks[UTP_ON_ACCEPT]) return; + args.callback_type = UTP_ON_ACCEPT; + args.context = ctx; + args.socket = socket; + args.address = address; + args.address_len = address_len; + ctx->callbacks[UTP_ON_ACCEPT](&args); +} + +void utp_call_on_connect(utp_context *ctx, utp_socket *socket) +{ + utp_callback_arguments args; + if (!ctx->callbacks[UTP_ON_CONNECT]) return; + args.callback_type = UTP_ON_CONNECT; + args.context = ctx; + args.socket = socket; + ctx->callbacks[UTP_ON_CONNECT](&args); +} + +void utp_call_on_error(utp_context *ctx, utp_socket *socket, int error_code) +{ + utp_callback_arguments args; + if (!ctx->callbacks[UTP_ON_ERROR]) return; + args.callback_type = UTP_ON_ERROR; + args.context = ctx; + args.socket = socket; + args.error_code = error_code; + ctx->callbacks[UTP_ON_ERROR](&args); +} + +void utp_call_on_read(utp_context *ctx, utp_socket *socket, const byte *buf, size_t len) +{ + utp_callback_arguments args; + if (!ctx->callbacks[UTP_ON_READ]) return; + args.callback_type = UTP_ON_READ; + args.context = ctx; + args.socket = socket; + args.buf = buf; + args.len = len; + ctx->callbacks[UTP_ON_READ](&args); +} + +void utp_call_on_overhead_statistics(utp_context *ctx, utp_socket *socket, int send, size_t len, int type) +{ + utp_callback_arguments args; + if (!ctx->callbacks[UTP_ON_OVERHEAD_STATISTICS]) return; + args.callback_type = UTP_ON_OVERHEAD_STATISTICS; + args.context = ctx; + args.socket = socket; + args.send = send; + args.len = len; + args.type = type; + ctx->callbacks[UTP_ON_OVERHEAD_STATISTICS](&args); +} + +void utp_call_on_delay_sample(utp_context *ctx, utp_socket *socket, int sample_ms) +{ + utp_callback_arguments args; + if (!ctx->callbacks[UTP_ON_DELAY_SAMPLE]) return; + args.callback_type = UTP_ON_DELAY_SAMPLE; + args.context = ctx; + args.socket = socket; + args.sample_ms = sample_ms; + ctx->callbacks[UTP_ON_DELAY_SAMPLE](&args); +} + +void utp_call_on_state_change(utp_context *ctx, utp_socket *socket, int state) +{ + utp_callback_arguments args; + if (!ctx->callbacks[UTP_ON_STATE_CHANGE]) return; + args.callback_type = UTP_ON_STATE_CHANGE; + args.context = ctx; + args.socket = socket; + args.state = state; + ctx->callbacks[UTP_ON_STATE_CHANGE](&args); +} + +uint16 utp_call_get_udp_mtu(utp_context *ctx, utp_socket *socket, const struct sockaddr *address, socklen_t address_len) +{ + utp_callback_arguments args; + if (!ctx->callbacks[UTP_GET_UDP_MTU]) return 0; + args.callback_type = UTP_GET_UDP_MTU; + args.context = ctx; + args.socket = socket; + args.address = address; + args.address_len = address_len; + return (uint16)ctx->callbacks[UTP_GET_UDP_MTU](&args); +} + +uint16 utp_call_get_udp_overhead(utp_context *ctx, utp_socket *socket, const struct sockaddr *address, socklen_t address_len) +{ + utp_callback_arguments args; + if (!ctx->callbacks[UTP_GET_UDP_OVERHEAD]) return 0; + args.callback_type = UTP_GET_UDP_OVERHEAD; + args.context = ctx; + args.socket = socket; + args.address = address; + args.address_len = address_len; + return (uint16)ctx->callbacks[UTP_GET_UDP_OVERHEAD](&args); +} + +uint64 utp_call_get_milliseconds(utp_context *ctx, utp_socket *socket) +{ + utp_callback_arguments args; + if (!ctx->callbacks[UTP_GET_MILLISECONDS]) return 0; + args.callback_type = UTP_GET_MILLISECONDS; + args.context = ctx; + args.socket = socket; + return ctx->callbacks[UTP_GET_MILLISECONDS](&args); +} + +uint64 utp_call_get_microseconds(utp_context *ctx, utp_socket *socket) +{ + utp_callback_arguments args; + if (!ctx->callbacks[UTP_GET_MICROSECONDS]) return 0; + args.callback_type = UTP_GET_MICROSECONDS; + args.context = ctx; + args.socket = socket; + return ctx->callbacks[UTP_GET_MICROSECONDS](&args); +} + +uint32 utp_call_get_random(utp_context *ctx, utp_socket *socket) +{ + utp_callback_arguments args; + if (!ctx->callbacks[UTP_GET_RANDOM]) return 0; + args.callback_type = UTP_GET_RANDOM; + args.context = ctx; + args.socket = socket; + return (uint32)ctx->callbacks[UTP_GET_RANDOM](&args); +} + +size_t utp_call_get_read_buffer_size(utp_context *ctx, utp_socket *socket) +{ + utp_callback_arguments args; + if (!ctx->callbacks[UTP_GET_READ_BUFFER_SIZE]) return 0; + args.callback_type = UTP_GET_READ_BUFFER_SIZE; + args.context = ctx; + args.socket = socket; + return (size_t)ctx->callbacks[UTP_GET_READ_BUFFER_SIZE](&args); +} + +void utp_call_log(utp_context *ctx, utp_socket *socket, const byte *buf) +{ + utp_callback_arguments args; + if (!ctx->callbacks[UTP_LOG]) return; + args.callback_type = UTP_LOG; + args.context = ctx; + args.socket = socket; + args.buf = buf; + ctx->callbacks[UTP_LOG](&args); +} + +void utp_call_sendto(utp_context *ctx, utp_socket *socket, const byte *buf, size_t len, const struct sockaddr *address, socklen_t address_len, uint32 flags) +{ + utp_callback_arguments args; + if (!ctx->callbacks[UTP_SENDTO]) return; + args.callback_type = UTP_SENDTO; + args.context = ctx; + args.socket = socket; + args.buf = buf; + args.len = len; + args.address = address; + args.address_len = address_len; + args.flags = flags; + ctx->callbacks[UTP_SENDTO](&args); +} + diff --git a/vendor/github.com/anacrolix/go-libutp/utp_callbacks.h b/vendor/github.com/anacrolix/go-libutp/utp_callbacks.h new file mode 100644 index 000000000..649e7e14f --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/utp_callbacks.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2010-2013 BitTorrent, Inc. + * + * 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. + */ + +#ifndef __UTP_CALLBACKS_H__ +#define __UTP_CALLBACKS_H__ + +#include "utp.h" +#include "utp_internal.h" + +// Generated by running: grep ^[a-z] utp_callbacks.cpp | sed 's/$/;/' +int utp_call_on_firewall(utp_context *ctx, const struct sockaddr *address, socklen_t address_len); +void utp_call_on_accept(utp_context *ctx, utp_socket *s, const struct sockaddr *address, socklen_t address_len); +void utp_call_on_connect(utp_context *ctx, utp_socket *s); +void utp_call_on_error(utp_context *ctx, utp_socket *s, int error_code); +void utp_call_on_read(utp_context *ctx, utp_socket *s, const byte *buf, size_t len); +void utp_call_on_overhead_statistics(utp_context *ctx, utp_socket *s, int send, size_t len, int type); +void utp_call_on_delay_sample(utp_context *ctx, utp_socket *s, int sample_ms); +void utp_call_on_state_change(utp_context *ctx, utp_socket *s, int state); +uint16 utp_call_get_udp_mtu(utp_context *ctx, utp_socket *s, const struct sockaddr *address, socklen_t address_len); +uint16 utp_call_get_udp_overhead(utp_context *ctx, utp_socket *s, const struct sockaddr *address, socklen_t address_len); +uint64 utp_call_get_milliseconds(utp_context *ctx, utp_socket *s); +uint64 utp_call_get_microseconds(utp_context *ctx, utp_socket *s); +uint32 utp_call_get_random(utp_context *ctx, utp_socket *s); +size_t utp_call_get_read_buffer_size(utp_context *ctx, utp_socket *s); +void utp_call_log(utp_context *ctx, utp_socket *s, const byte *buf); +void utp_call_sendto(utp_context *ctx, utp_socket *s, const byte *buf, size_t len, const struct sockaddr *address, socklen_t address_len, uint32 flags); + +#endif // __UTP_CALLBACKS_H__ diff --git a/vendor/github.com/anacrolix/go-libutp/utp_hash.cpp b/vendor/github.com/anacrolix/go-libutp/utp_hash.cpp new file mode 100644 index 000000000..a4a71d906 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/utp_hash.cpp @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2010-2013 BitTorrent, Inc. + * + * 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. + */ + +#include "utp_hash.h" +#include "utp_types.h" + +#define LIBUTP_HASH_UNUSED ((utp_link_t)-1) + +#ifdef STRICT_ALIGN +inline uint32 Read32(const void *p) +{ + uint32 tmp; + memcpy(&tmp, p, sizeof tmp); + return tmp; +} + +#else +inline uint32 Read32(const void *p) { return *(uint32*)p; } +#endif + + +// Get the amount of memory required for the hash parameters and the bucket set +// Waste a space for an unused bucket in order to ensure the following managed memory have 32-bit aligned addresses +// TODO: make this 64-bit clean +#define BASE_SIZE(bc) (sizeof(utp_hash_t) + sizeof(utp_link_t) * ((bc) + 1)) + +// Get a pointer to the base of the structure array managed by the hash table +#define get_bep(h) ((byte*)(h)) + BASE_SIZE((h)->N) + +// Get the address of the information associated with a specific structure in the array, +// given the address of the base of the structure. +// This assumes a utp_link_t link member is at the end of the structure. +// Given compilers filling out the memory to a 32-bit clean value, this may mean that +// the location named in the structure may not be the location actually used by the hash table, +// since the compiler may have padded the end of the structure with 2 bytes after the utp_link_t member. +// TODO: this macro should not require that the variable pointing at the hash table be named 'hash' +#define ptr_to_link(p) (utp_link_t *) (((byte *) (p)) + hash->E - sizeof(utp_link_t)) + +// Calculate how much to allocate for a hash table with bucket count, total size, and structure count +// TODO: make this 64-bit clean +#define ALLOCATION_SIZE(bc, ts, sc) (BASE_SIZE((bc)) + (ts) * (sc)) + +utp_hash_t *utp_hash_create(int N, int key_size, int total_size, int initial, utp_hash_compute_t hashfun, utp_hash_equal_t compfun) +{ + // Must have odd number of hash buckets (prime number is best) + assert(N % 2); + // Ensure structures will be at aligned memory addresses + // TODO: make this 64-bit clean + assert(0 == (total_size % 4)); + + int size = ALLOCATION_SIZE(N, total_size, initial); + utp_hash_t *hash = (utp_hash_t *) malloc( size ); + memset( hash, 0, size ); + + for (int i = 0; i < N + 1; ++i) + hash->inits[i] = LIBUTP_HASH_UNUSED; + hash->N = N; + hash->K = key_size; + hash->E = total_size; + hash->hash_compute = hashfun; + hash->hash_equal = compfun; + hash->allocated = initial; + hash->count = 0; + hash->used = 0; + hash->free = LIBUTP_HASH_UNUSED; + return hash; +} + +uint utp_hash_mem(const void *keyp, size_t keysize) +{ + uint hash = 0; + uint n = keysize; + while (n >= 4) { + hash ^= Read32(keyp); + keyp = (byte*)keyp + sizeof(uint32); + hash = (hash << 13) | (hash >> 19); + n -= 4; + } + while (n != 0) { + hash ^= *(byte*)keyp; + keyp = (byte*)keyp + sizeof(byte); + hash = (hash << 8) | (hash >> 24); + n--; + } + return hash; +} + +uint utp_hash_mkidx(utp_hash_t *hash, const void *keyp) +{ + // Generate a key from the hash + return hash->hash_compute(keyp, hash->K) % hash->N; +} + +static inline bool compare(byte *a, byte *b,int n) +{ + assert(n >= 4); + if (Read32(a) != Read32(b)) return false; + return memcmp(a+4, b+4, n-4) == 0; +} + +#define COMPARE(h,k1,k2,ks) (((h)->hash_equal) ? (h)->hash_equal((void*)k1,(void*)k2,ks) : compare(k1,k2,ks)) + +// Look-up a key in the hash table. +// Returns NULL if not found +void *utp_hash_lookup(utp_hash_t *hash, const void *key) +{ + utp_link_t idx = utp_hash_mkidx(hash, key); + + // base pointer + byte *bep = get_bep(hash); + + utp_link_t cur = hash->inits[idx]; + while (cur != LIBUTP_HASH_UNUSED) { + byte *key2 = bep + (cur * hash->E); + if (COMPARE(hash, (byte*)key, key2, hash->K)) + return key2; + cur = *ptr_to_link(key2); + } + + return NULL; +} + +// Add a new element to the hash table. +// Returns a pointer to the new element. +// This assumes the element is not already present! +void *utp_hash_add(utp_hash_t **hashp, const void *key) +{ + //Allocate a new entry + byte *elemp; + utp_link_t elem; + utp_hash_t *hash = *hashp; + utp_link_t idx = utp_hash_mkidx(hash, key); + + if ((elem=hash->free) == LIBUTP_HASH_UNUSED) { + utp_link_t all = hash->allocated; + if (hash->used == all) { + utp_hash_t *nhash; + if (all <= (LIBUTP_HASH_UNUSED/2)) { + all *= 2; + } else if (all != LIBUTP_HASH_UNUSED) { + all = LIBUTP_HASH_UNUSED; + } else { + // too many items! can't grow! + assert(0); + return NULL; + } + // otherwise need to allocate. + nhash = (utp_hash_t*)realloc(hash, ALLOCATION_SIZE(hash->N, hash->E, all)); + if (!nhash) { + // out of memory (or too big to allocate) + assert(nhash); + return NULL; + } + hash = *hashp = nhash; + hash->allocated = all; + } + + elem = hash->used++; + elemp = get_bep(hash) + elem * hash->E; + } else { + elemp = get_bep(hash) + elem * hash->E; + hash->free = *ptr_to_link(elemp); + } + + *ptr_to_link(elemp) = hash->inits[idx]; + hash->inits[idx] = elem; + hash->count++; + + // copy key into it + memcpy(elemp, key, hash->K); + return elemp; +} + +// Delete an element from the utp_hash_t +// Returns a pointer to the already deleted element. +void *utp_hash_del(utp_hash_t *hash, const void *key) +{ + utp_link_t idx = utp_hash_mkidx(hash, key); + + // base pointer + byte *bep = get_bep(hash); + + utp_link_t *curp = &hash->inits[idx]; + utp_link_t cur; + while ((cur=*curp) != LIBUTP_HASH_UNUSED) { + byte *key2 = bep + (cur * hash->E); + if (COMPARE(hash,(byte*)key,(byte*)key2, hash->K )) { + // found an item that matched. unlink it + *curp = *ptr_to_link(key2); + // Insert into freelist + *ptr_to_link(key2) = hash->free; + hash->free = cur; + hash->count--; + return key2; + } + curp = ptr_to_link(key2); + } + + return NULL; +} + +void *utp_hash_iterate(utp_hash_t *hash, utp_hash_iterator_t *iter) +{ + utp_link_t elem; + + if ((elem=iter->elem) == LIBUTP_HASH_UNUSED) { + // Find a bucket with an element + utp_link_t buck = iter->bucket + 1; + for(;;) { + if (buck >= hash->N) + return NULL; + if ((elem = hash->inits[buck]) != LIBUTP_HASH_UNUSED) + break; + buck++; + } + iter->bucket = buck; + } + + byte *elemp = get_bep(hash) + (elem * hash->E); + iter->elem = *ptr_to_link(elemp); + return elemp; +} + +void utp_hash_free_mem(utp_hash_t* hash) +{ + free(hash); +} diff --git a/vendor/github.com/anacrolix/go-libutp/utp_hash.h b/vendor/github.com/anacrolix/go-libutp/utp_hash.h new file mode 100644 index 000000000..72c17e3bd --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/utp_hash.h @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2010-2013 BitTorrent, Inc. + * + * 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. + */ + +#ifndef __UTP_HASH_H__ +#define __UTP_HASH_H__ + +#include // memset +#include // malloc + +#include "utp_types.h" +#include "utp_templates.h" + +// TODO: make utp_link_t a template parameter to HashTable +typedef uint32 utp_link_t; + +#ifdef _MSC_VER +// Silence the warning about the C99-compliant zero-length array at the end of the structure +#pragma warning (disable: 4200) +#endif + +typedef uint32 (*utp_hash_compute_t)(const void *keyp, size_t keysize); +typedef uint (*utp_hash_equal_t)(const void *key_a, const void *key_b, size_t keysize); + +// In memory the HashTable is laid out as follows: +// ---------------------------- low +// | hash table data members | +// ---------------------------- _ +// | indices | ^ +// | . | | utp_link_t indices into the key-values. +// | . | . +// ---------------------------- - <----- bep +// | keys and values | each key-value pair has size total_size +// | . | +// | . | +// ---------------------------- high +// +// The code depends on the ability of the compiler to pad the length +// of the hash table data members structure to +// a length divisible by 32-bits with no remainder. +// +// Since the number of hash buckets (indices) should be odd, the code +// asserts this and adds one to the hash bucket count to ensure that the +// following key-value pairs array starts on a 32-bit boundary. +// +// The key-value pairs array should start on a 32-bit boundary, otherwise +// processors like the ARM will silently mangle 32-bit data in these structures +// (e.g., turning 0xABCD into 0XCDAB when moving a value from memory to register +// when the memory address is 16 bits offset from a 32-bit boundary), +// also, the value will be stored at an address two bytes lower than the address +// value would ordinarily indicate. +// +// The key-value pair is of type T. The first field in T must +// be the key, i.e., the first K bytes of T contains the key. +// total_size = sizeof(T) and thus sizeof(T) >= sizeof(K) +// +// N is the number of buckets. +// +struct utp_hash_t { + utp_link_t N; + byte K; + byte E; + size_t count; + utp_hash_compute_t hash_compute; + utp_hash_equal_t hash_equal; + utp_link_t allocated; + utp_link_t used; + utp_link_t free; + utp_link_t inits[0]; +}; + +#ifdef _MSC_VER +#pragma warning (default: 4200) +#endif + +struct utp_hash_iterator_t { + utp_link_t bucket; + utp_link_t elem; + + utp_hash_iterator_t() : bucket(0xffffffff), elem(0xffffffff) {} +}; + +uint utp_hash_mem(const void *keyp, size_t keysize); +uint utp_hash_comp(const void *key_a, const void *key_b, size_t keysize); + +utp_hash_t *utp_hash_create(int N, int key_size, int total_size, int initial, utp_hash_compute_t hashfun = utp_hash_mem, utp_hash_equal_t eqfun = NULL); +void *utp_hash_lookup(utp_hash_t *hash, const void *key); +void *utp_hash_add(utp_hash_t **hashp, const void *key); +void *utp_hash_del(utp_hash_t *hash, const void *key); + +void *utp_hash_iterate(utp_hash_t *hash, utp_hash_iterator_t *iter); +void utp_hash_free_mem(utp_hash_t *hash); + +/* + This HashTable requires that T have at least sizeof(K)+sizeof(utp_link_t) bytes. + Usually done like this: + + struct K { + int whatever; + }; + + struct T { + K wtf; + utp_link_t link; // also wtf + }; +*/ + +template class utpHashTable { + utp_hash_t *hash; +public: + static uint compare(const void *k1, const void *k2, size_t ks) { + return *((K*)k1) == *((K*)k2); + } + static uint32 compute_hash(const void *k, size_t ks) { + return ((K*)k)->compute_hash(); + } + void Init() { hash = NULL; } + bool Allocated() { return (hash != NULL); } + void Free() { utp_hash_free_mem(hash); hash = NULL; } + void Create(int N, int initial) { hash = utp_hash_create(N, sizeof(K), sizeof(T), initial, &compute_hash, &compare); } + T *Lookup(const K &key) { return (T*)utp_hash_lookup(hash, &key); } + T *Add(const K &key) { return (T*)utp_hash_add(&hash, &key); } + T *Delete(const K &key) { return (T*)utp_hash_del(hash, &key); } + T *Iterate(utp_hash_iterator_t &iterator) { return (T*)utp_hash_iterate(hash, &iterator); } + size_t GetCount() { return hash->count; } +}; + +#endif //__UTP_HASH_H__ diff --git a/vendor/github.com/anacrolix/go-libutp/utp_internal.cpp b/vendor/github.com/anacrolix/go-libutp/utp_internal.cpp new file mode 100644 index 000000000..bacf32986 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/utp_internal.cpp @@ -0,0 +1,3443 @@ +/* + * Copyright (c) 2010-2013 BitTorrent, Inc. + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include // for UINT_MAX +#include + +#include "utp_types.h" +#include "utp_packedsockaddr.h" +#include "utp_internal.h" +#include "utp_hash.h" + +#define TIMEOUT_CHECK_INTERVAL 500 + +// number of bytes to increase max window size by, per RTT. This is +// scaled down linearly proportional to off_target. i.e. if all packets +// in one window have 0 delay, window size will increase by this number. +// Typically it's less. TCP increases one MSS per RTT, which is 1500 +#define MAX_CWND_INCREASE_BYTES_PER_RTT 3000 +#define CUR_DELAY_SIZE 3 +// experiments suggest that a clock skew of 10 ms per 325 seconds +// is not impossible. Reset delay_base every 13 minutes. The clock +// skew is dealt with by observing the delay base in the other +// direction, and adjusting our own upwards if the opposite direction +// delay base keeps going down +#define DELAY_BASE_HISTORY 13 +#define MAX_WINDOW_DECAY 100 // ms + +#define REORDER_BUFFER_SIZE 32 +#define REORDER_BUFFER_MAX_SIZE 1024 +#define OUTGOING_BUFFER_MAX_SIZE 1024 + +#define PACKET_SIZE 1435 + +// this is the minimum max_window value. It can never drop below this +#define MIN_WINDOW_SIZE 10 + +// if we receive 4 or more duplicate acks, we resend the packet +// that hasn't been acked yet +#define DUPLICATE_ACKS_BEFORE_RESEND 3 + +// Allow a reception window of at least 3 ack_nrs behind seq_nr +// A non-SYN packet with an ack_nr difference greater than this is +// considered suspicious and ignored +#define ACK_NR_ALLOWED_WINDOW DUPLICATE_ACKS_BEFORE_RESEND + +#define RST_INFO_TIMEOUT 10000 +#define RST_INFO_LIMIT 1000 +// 29 seconds determined from measuring many home NAT devices +#define KEEPALIVE_INTERVAL 29000 + + +#define SEQ_NR_MASK 0xFFFF +#define ACK_NR_MASK 0xFFFF +#define TIMESTAMP_MASK 0xFFFFFFFF + +#define DIV_ROUND_UP(num, denom) ((num + denom - 1) / denom) + +// The totals are derived from the following data: +// 45: IPv6 address including embedded IPv4 address +// 11: Scope Id +// 2: Brackets around IPv6 address when port is present +// 6: Port (including colon) +// 1: Terminating null byte +char addrbuf[65]; +#define addrfmt(x, s) x.fmt(s, sizeof(s)) + + +#if (defined(__SVR4) && defined(__sun)) + #pragma pack(1) +#else + #pragma pack(push,1) +#endif + + +// these packet sizes are including the uTP header wich +// is either 20 or 23 bytes depending on version +#define PACKET_SIZE_EMPTY_BUCKET 0 +#define PACKET_SIZE_EMPTY 23 +#define PACKET_SIZE_SMALL_BUCKET 1 +#define PACKET_SIZE_SMALL 373 +#define PACKET_SIZE_MID_BUCKET 2 +#define PACKET_SIZE_MID 723 +#define PACKET_SIZE_BIG_BUCKET 3 +#define PACKET_SIZE_BIG 1400 +#define PACKET_SIZE_HUGE_BUCKET 4 + +struct PACKED_ATTRIBUTE PacketFormatV1 { + // packet_type (4 high bits) + // protocol version (4 low bits) + byte ver_type; + byte version() const { return ver_type & 0xf; } + byte type() const { return ver_type >> 4; } + void set_version(byte v) { ver_type = (ver_type & 0xf0) | (v & 0xf); } + void set_type(byte t) { ver_type = (ver_type & 0xf) | (t << 4); } + + // Type of the first extension header + byte ext; + // connection ID + uint16_big connid; + uint32_big tv_usec; + uint32_big reply_micro; + // receive window size in bytes + uint32_big windowsize; + // Sequence number + uint16_big seq_nr; + // Acknowledgment number + uint16_big ack_nr; +}; + +struct PACKED_ATTRIBUTE PacketFormatAckV1 { + PacketFormatV1 pf; + byte ext_next; + byte ext_len; + byte acks[4]; +}; + +#if (defined(__SVR4) && defined(__sun)) + #pragma pack(0) +#else + #pragma pack(pop) +#endif + +enum { + ST_DATA = 0, // Data packet. + ST_FIN = 1, // Finalize the connection. This is the last packet. + ST_STATE = 2, // State packet. Used to transmit an ACK with no data. + ST_RESET = 3, // Terminate connection forcefully. + ST_SYN = 4, // Connect SYN + ST_NUM_STATES, // used for bounds checking +}; + +static const cstr flagnames[] = { + "ST_DATA","ST_FIN","ST_STATE","ST_RESET","ST_SYN" +}; + +enum CONN_STATE { + CS_UNINITIALIZED = 0, + CS_IDLE, + CS_SYN_SENT, + CS_SYN_RECV, + CS_CONNECTED, + CS_CONNECTED_FULL, + CS_GOT_FIN, + CS_DESTROY_DELAY, + CS_FIN_SENT, + CS_RESET, + CS_DESTROY +}; + +static const cstr statenames[] = { + "UNINITIALIZED", "IDLE","SYN_SENT", "SYN_RECV", "CONNECTED","CONNECTED_FULL","GOT_FIN","DESTROY_DELAY","FIN_SENT","RESET","DESTROY" +}; + +struct OutgoingPacket { + size_t length; + size_t payload; + uint64 time_sent; // microseconds + uint transmissions:31; + bool need_resend:1; + byte data[1]; +}; + +struct SizableCircularBuffer { + // This is the mask. Since it's always a power of 2, adding 1 to this value will return the size. + size_t mask; + // This is the elements that the circular buffer points to + void **elements; + + void *get(size_t i) const { assert(elements); return elements ? elements[i & mask] : NULL; } + void put(size_t i, void *data) { assert(elements); elements[i&mask] = data; } + + void grow(size_t item, size_t index); + void ensure_size(size_t item, size_t index) { if (index > mask) grow(item, index); } + size_t size() { return mask + 1; } +}; + +// Item contains the element we want to make space for +// index is the index in the list. +void SizableCircularBuffer::grow(size_t item, size_t index) +{ + // Figure out the new size. + size_t size = mask + 1; + do size *= 2; while (index >= size); + + // Allocate the new buffer + void **buf = (void**)calloc(size, sizeof(void*)); + + size--; + + // Copy elements from the old buffer to the new buffer + for (size_t i = 0; i <= mask; i++) { + buf[(item - index + i) & size] = get(item - index + i); + } + + // Swap to the newly allocated buffer + mask = size; + free(elements); + elements = buf; +} + +// compare if lhs is less than rhs, taking wrapping +// into account. if lhs is close to UINT_MAX and rhs +// is close to 0, lhs is assumed to have wrapped and +// considered smaller +bool wrapping_compare_less(uint32 lhs, uint32 rhs, uint32 mask) +{ + // distance walking from lhs to rhs, downwards + const uint32 dist_down = (lhs - rhs) & mask; + // distance walking from lhs to rhs, upwards + const uint32 dist_up = (rhs - lhs) & mask; + + // if the distance walking up is shorter, lhs + // is less than rhs. If the distance walking down + // is shorter, then rhs is less than lhs + return dist_up < dist_down; +} + +struct DelayHist { + uint32 delay_base; + + // this is the history of delay samples, + // normalized by using the delay_base. These + // values are always greater than 0 and measures + // the queuing delay in microseconds + uint32 cur_delay_hist[CUR_DELAY_SIZE]; + size_t cur_delay_idx; + + // this is the history of delay_base. It's + // a number that doesn't have an absolute meaning + // only relative. It doesn't make sense to initialize + // it to anything other than values relative to + // what's been seen in the real world. + uint32 delay_base_hist[DELAY_BASE_HISTORY]; + size_t delay_base_idx; + // the time when we last stepped the delay_base_idx + uint64 delay_base_time; + + bool delay_base_initialized; + + void clear(uint64 current_ms) + { + delay_base_initialized = false; + delay_base = 0; + cur_delay_idx = 0; + delay_base_idx = 0; + delay_base_time = current_ms; + for (size_t i = 0; i < CUR_DELAY_SIZE; i++) { + cur_delay_hist[i] = 0; + } + for (size_t i = 0; i < DELAY_BASE_HISTORY; i++) { + delay_base_hist[i] = 0; + } + } + + void shift(const uint32 offset) + { + // the offset should never be "negative" + // assert(offset < 0x10000000); + + // increase all of our base delays by this amount + // this is used to take clock skew into account + // by observing the other side's changes in its base_delay + for (size_t i = 0; i < DELAY_BASE_HISTORY; i++) { + delay_base_hist[i] += offset; + } + delay_base += offset; + } + + void add_sample(const uint32 sample, uint64 current_ms) + { + // The two clocks (in the two peers) are assumed not to + // progress at the exact same rate. They are assumed to be + // drifting, which causes the delay samples to contain + // a systematic error, either they are under- + // estimated or over-estimated. This is why we update the + // delay_base every two minutes, to adjust for this. + + // This means the values will keep drifting and eventually wrap. + // We can cross the wrapping boundry in two directions, either + // going up, crossing the highest value, or going down, crossing 0. + + // if the delay_base is close to the max value and sample actually + // wrapped on the other end we would see something like this: + // delay_base = 0xffffff00, sample = 0x00000400 + // sample - delay_base = 0x500 which is the correct difference + + // if the delay_base is instead close to 0, and we got an even lower + // sample (that will eventually update the delay_base), we may see + // something like this: + // delay_base = 0x00000400, sample = 0xffffff00 + // sample - delay_base = 0xfffffb00 + // this needs to be interpreted as a negative number and the actual + // recorded delay should be 0. + + // It is important that all arithmetic that assume wrapping + // is done with unsigned intergers. Signed integers are not guaranteed + // to wrap the way unsigned integers do. At least GCC takes advantage + // of this relaxed rule and won't necessarily wrap signed ints. + + // remove the clock offset and propagation delay. + // delay base is min of the sample and the current + // delay base. This min-operation is subject to wrapping + // and care needs to be taken to correctly choose the + // true minimum. + + // specifically the problem case is when delay_base is very small + // and sample is very large (because it wrapped past zero), sample + // needs to be considered the smaller + + if (!delay_base_initialized) { + // delay_base being 0 suggests that we haven't initialized + // it or its history with any real measurements yet. Initialize + // everything with this sample. + for (size_t i = 0; i < DELAY_BASE_HISTORY; i++) { + // if we don't have a value, set it to the current sample + delay_base_hist[i] = sample; + continue; + } + delay_base = sample; + delay_base_initialized = true; + } + + if (wrapping_compare_less(sample, delay_base_hist[delay_base_idx], TIMESTAMP_MASK)) { + // sample is smaller than the current delay_base_hist entry + // update it + delay_base_hist[delay_base_idx] = sample; + } + + // is sample lower than delay_base? If so, update delay_base + if (wrapping_compare_less(sample, delay_base, TIMESTAMP_MASK)) { + // sample is smaller than the current delay_base + // update it + delay_base = sample; + } + + // this operation may wrap, and is supposed to + const uint32 delay = sample - delay_base; + // sanity check. If this is triggered, something fishy is going on + // it means the measured sample was greater than 32 seconds! + //assert(delay < 0x2000000); + + cur_delay_hist[cur_delay_idx] = delay; + cur_delay_idx = (cur_delay_idx + 1) % CUR_DELAY_SIZE; + + // once every minute + if (current_ms - delay_base_time > 60 * 1000) { + delay_base_time = current_ms; + delay_base_idx = (delay_base_idx + 1) % DELAY_BASE_HISTORY; + // clear up the new delay base history spot by initializing + // it to the current sample, then update it + delay_base_hist[delay_base_idx] = sample; + delay_base = delay_base_hist[0]; + // Assign the lowest delay in the last 2 minutes to delay_base + for (size_t i = 0; i < DELAY_BASE_HISTORY; i++) { + if (wrapping_compare_less(delay_base_hist[i], delay_base, TIMESTAMP_MASK)) + delay_base = delay_base_hist[i]; + } + } + } + + uint32 get_value() + { + uint32 value = UINT_MAX; + for (size_t i = 0; i < CUR_DELAY_SIZE; i++) { + value = min(cur_delay_hist[i], value); + } + // value could be UINT_MAX if we have no samples yet... + return value; + } +}; + +struct UTPSocket { + ~UTPSocket(); + + PackedSockAddr addr; + utp_context *ctx; + + int ida; //for ack socket list + + uint16 retransmit_count; + + uint16 reorder_count; + byte duplicate_ack; + + // the number of packets in the send queue. Packets that haven't + // yet been sent count as well as packets marked as needing resend + // the oldest un-acked packet in the send queue is seq_nr - cur_window_packets + uint16 cur_window_packets; + + // how much of the window is used, number of bytes in-flight + // packets that have not yet been sent do not count, packets + // that are marked as needing to be re-sent (due to a timeout) + // don't count either + size_t cur_window; + // maximum window size, in bytes + size_t max_window; + // UTP_SNDBUF setting, in bytes + size_t opt_sndbuf; + // UTP_RCVBUF setting, in bytes + size_t opt_rcvbuf; + + // this is the target delay, in microseconds + // for this socket. defaults to 100000. + size_t target_delay; + + // Is a FIN packet in the reassembly buffer? + bool got_fin:1; + // Timeout procedure + bool fast_timeout:1; + + // max receive window for other end, in bytes + size_t max_window_user; + CONN_STATE state; + // TickCount when we last decayed window (wraps) + int64 last_rwin_decay; + + // the sequence number of the FIN packet. This field is only set + // when we have received a FIN, and the flag field has the FIN flag set. + // it is used to know when it is safe to destroy the socket, we must have + // received all packets up to this sequence number first. + uint16 eof_pkt; + + // All sequence numbers up to including this have been properly received + // by us + uint16 ack_nr; + // This is the sequence number for the next packet to be sent. + uint16 seq_nr; + + uint16 timeout_seq_nr; + + // This is the sequence number of the next packet we're allowed to + // do a fast resend with. This makes sure we only do a fast-resend + // once per packet. We can resend the packet with this sequence number + // or any later packet (with a higher sequence number). + uint16 fast_resend_seq_nr; + + uint32 reply_micro; + + uint64 last_got_packet; + uint64 last_sent_packet; + uint64 last_measured_delay; + + // timestamp of the last time the cwnd was full + // this is used to prevent the congestion window + // from growing when we're not sending at capacity + mutable uint64 last_maxed_out_window; + + void *userdata; + + // Round trip time + uint rtt; + // Round trip time variance + uint rtt_var; + // Round trip timeout + uint rto; + DelayHist rtt_hist; + uint retransmit_timeout; + // The RTO timer will timeout here. + uint64 rto_timeout; + // When the window size is set to zero, start this timer. It will send a new packet every 30secs. + uint64 zerowindow_time; + + uint32 conn_seed; + // Connection ID for packets I receive + uint32 conn_id_recv; + // Connection ID for packets I send + uint32 conn_id_send; + // Last rcv window we advertised, in bytes + size_t last_rcv_win; + + DelayHist our_hist; + DelayHist their_hist; + + // extension bytes from SYN packet + byte extensions[8]; + + // MTU Discovery + // time when we should restart the MTU discovery + uint64 mtu_discover_time; + // ceiling and floor of binary search. last is the mtu size + // we're currently using + uint32 mtu_ceiling, mtu_floor, mtu_last; + // we only ever have a single probe in flight at any given time. + // this is the sequence number of that probe, and the size of + // that packet + uint32 mtu_probe_seq, mtu_probe_size; + + // this is the average delay samples, as compared to the initial + // sample. It's averaged over 5 seconds + int32 average_delay; + // this is the sum of all the delay samples + // we've made recently. The important distinction + // of these samples is that they are all made compared + // to the initial sample, this is to deal with + // wrapping in a simple way. + int64 current_delay_sum; + // number of sample ins current_delay_sum + int current_delay_samples; + // initialized to 0, set to the first raw delay sample + // each sample that's added to current_delay_sum + // is subtracted from the value first, to make it + // a delay relative to this sample + uint32 average_delay_base; + // the next time we should add an average delay + // sample into average_delay_hist + uint64 average_sample_time; + // the estimated clock drift between our computer + // and the endpoint computer. The unit is microseconds + // per 5 seconds + int32 clock_drift; + // just used for logging + int32 clock_drift_raw; + + SizableCircularBuffer inbuf, outbuf; + + #ifdef _DEBUG + // Public per-socket statistics, returned by utp_get_stats() + utp_socket_stats _stats; + #endif + + // true if we're in slow-start (exponential growth) phase + bool slow_start; + + // the slow-start threshold, in bytes + size_t ssthresh; + + void log(int level, char const *fmt, ...) + { + va_list va; + char buf[4096], buf2[4096]; + + // don't bother with vsnprintf() etc calls if we're not going to log. + if (!ctx->would_log(level)) { + return; + } + + va_start(va, fmt); + vsnprintf(buf, 4096, fmt, va); + va_end(va); + buf[4095] = '\0'; + + snprintf(buf2, 4096, "%p %s %06u %s", this, addrfmt(addr, addrbuf), conn_id_recv, buf); + buf2[4095] = '\0'; + + ctx->log_unchecked(this, buf2); + } + + void schedule_ack(); + + // called every time mtu_floor or mtu_ceiling are adjusted + void mtu_search_update(); + void mtu_reset(); + + // Calculates the current receive window + size_t get_rcv_window() + { + // Trim window down according to what's already in buffer. + const size_t numbuf = utp_call_get_read_buffer_size(this->ctx, this); + assert((int)numbuf >= 0); + return opt_rcvbuf > numbuf ? opt_rcvbuf - numbuf : 0; + } + + // Test if we're ready to decay max_window + // XXX this breaks when spaced by > INT_MAX/2, which is 49 + // days; the failure mode in that case is we do an extra decay + // or fail to do one when we really shouldn't. + bool can_decay_win(int64 msec) const + { + return (msec - last_rwin_decay) >= MAX_WINDOW_DECAY; + } + + // If we can, decay max window, returns true if we actually did so + void maybe_decay_win(uint64 current_ms) + { + if (can_decay_win(current_ms)) { + // TCP uses 0.5 + max_window = (size_t)(max_window * .5); + last_rwin_decay = current_ms; + if (max_window < MIN_WINDOW_SIZE) + max_window = MIN_WINDOW_SIZE; + slow_start = false; + ssthresh = max_window; + } + } + + size_t get_header_size() const + { + return sizeof(PacketFormatV1); + } + + size_t get_udp_mtu() + { + socklen_t len; + SOCKADDR_STORAGE sa = addr.get_sockaddr_storage(&len); + return utp_call_get_udp_mtu(this->ctx, this, (const struct sockaddr *)&sa, len); + } + + size_t get_udp_overhead() + { + socklen_t len; + SOCKADDR_STORAGE sa = addr.get_sockaddr_storage(&len); + return utp_call_get_udp_overhead(this->ctx, this, (const struct sockaddr *)&sa, len); + } + + size_t get_overhead() + { + return get_udp_overhead() + get_header_size(); + } + + void send_data(byte* b, size_t length, bandwidth_type_t type, uint32 flags = 0); + + void send_ack(bool synack = false); + + void send_keep_alive(); + + static void send_rst(utp_context *ctx, + const PackedSockAddr &addr, uint32 conn_id_send, + uint16 ack_nr, uint16 seq_nr); + + void send_packet(OutgoingPacket *pkt); + + bool is_full(int bytes = -1); + bool flush_packets(); + void write_outgoing_packet(size_t payload, uint flags, struct utp_iovec *iovec, size_t num_iovecs); + + #ifdef _DEBUG + void check_invariant(); + #endif + + void check_timeouts(); + int ack_packet(uint16 seq); + size_t selective_ack_bytes(uint base, const byte* mask, byte len, int64& min_rtt); + void selective_ack(uint base, const byte *mask, byte len); + void apply_ccontrol(size_t bytes_acked, uint32 actual_delay, int64 min_rtt); + size_t get_packet_size() const; +}; + +void removeSocketFromAckList(UTPSocket *conn) +{ + if (conn->ida >= 0) + { + UTPSocket *last = conn->ctx->ack_sockets[conn->ctx->ack_sockets.GetCount() - 1]; + + assert(last->ida < (int)(conn->ctx->ack_sockets.GetCount())); + assert(conn->ctx->ack_sockets[last->ida] == last); + last->ida = conn->ida; + conn->ctx->ack_sockets[conn->ida] = last; + conn->ida = -1; + + // Decrease the count + conn->ctx->ack_sockets.SetCount(conn->ctx->ack_sockets.GetCount() - 1); + } +} + +static void utp_register_sent_packet(utp_context *ctx, size_t length) +{ + if (length <= PACKET_SIZE_MID) { + if (length <= PACKET_SIZE_EMPTY) { + ctx->context_stats._nraw_send[PACKET_SIZE_EMPTY_BUCKET]++; + } else if (length <= PACKET_SIZE_SMALL) { + ctx->context_stats._nraw_send[PACKET_SIZE_SMALL_BUCKET]++; + } else + ctx->context_stats._nraw_send[PACKET_SIZE_MID_BUCKET]++; + } else { + if (length <= PACKET_SIZE_BIG) { + ctx->context_stats._nraw_send[PACKET_SIZE_BIG_BUCKET]++; + } else + ctx->context_stats._nraw_send[PACKET_SIZE_HUGE_BUCKET]++; + } +} + +void send_to_addr(utp_context *ctx, const byte *p, size_t len, const PackedSockAddr &addr, int flags = 0) +{ + socklen_t tolen; + SOCKADDR_STORAGE to = addr.get_sockaddr_storage(&tolen); + utp_register_sent_packet(ctx, len); + utp_call_sendto(ctx, NULL, p, len, (const struct sockaddr *)&to, tolen, flags); +} + +void UTPSocket::schedule_ack() +{ + if (ida == -1){ + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "schedule_ack"); + #endif + ida = ctx->ack_sockets.Append(this); + } else { + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "schedule_ack: already in list"); + #endif + } +} + +void UTPSocket::send_data(byte* b, size_t length, bandwidth_type_t type, uint32 flags) +{ + // time stamp this packet with local time, the stamp goes into + // the header of every packet at the 8th byte for 8 bytes : + // two integers, check packet.h for more + uint64 time = utp_call_get_microseconds(ctx, this); + + PacketFormatV1* b1 = (PacketFormatV1*)b; + b1->tv_usec = (uint32)time; + b1->reply_micro = reply_micro; + + last_sent_packet = ctx->current_ms; + + #ifdef _DEBUG + _stats.nbytes_xmit += length; + ++_stats.nxmit; + #endif + + if (ctx->callbacks[UTP_ON_OVERHEAD_STATISTICS]) { + size_t n; + if (type == payload_bandwidth) { + // if this packet carries payload, just + // count the header as overhead + type = header_overhead; + n = get_overhead(); + } else { + n = length + get_udp_overhead(); + } + utp_call_on_overhead_statistics(ctx, this, true, n, type); + } +#if UTP_DEBUG_LOGGING + int flags2 = b1->type(); + uint16 seq_nr = b1->seq_nr; + uint16 ack_nr = b1->ack_nr; + log(UTP_LOG_DEBUG, "send %s len:%u id:%u timestamp:" I64u " reply_micro:%u flags:%s seq_nr:%u ack_nr:%u", + addrfmt(addr, addrbuf), (uint)length, conn_id_send, time, reply_micro, flagnames[flags2], + seq_nr, ack_nr); +#endif + send_to_addr(ctx, b, length, addr, flags); + removeSocketFromAckList(this); +} + +void UTPSocket::send_ack(bool synack) +{ + PacketFormatAckV1 pfa; + zeromem(&pfa); + + size_t len; + last_rcv_win = get_rcv_window(); + pfa.pf.set_version(1); + pfa.pf.set_type(ST_STATE); + pfa.pf.ext = 0; + pfa.pf.connid = conn_id_send; + pfa.pf.ack_nr = ack_nr; + pfa.pf.seq_nr = seq_nr; + pfa.pf.windowsize = (uint32)last_rcv_win; + len = sizeof(PacketFormatV1); + + // we never need to send EACK for connections + // that are shutting down + if (reorder_count != 0 && state < CS_GOT_FIN) { + // if reorder count > 0, send an EACK. + // reorder count should always be 0 + // for synacks, so this should not be + // as synack + assert(!synack); + pfa.pf.ext = 1; + pfa.ext_next = 0; + pfa.ext_len = 4; + uint m = 0; + + // reorder count should only be non-zero + // if the packet ack_nr + 1 has not yet + // been received + assert(inbuf.get(ack_nr + 1) == NULL); + size_t window = min(14+16, inbuf.size()); + // Generate bit mask of segments received. + for (size_t i = 0; i < window; i++) { + if (inbuf.get(ack_nr + i + 2) != NULL) { + m |= 1 << i; + + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "EACK packet [%u]", ack_nr + i + 2); + #endif + } + } + pfa.acks[0] = (byte)m; + pfa.acks[1] = (byte)(m >> 8); + pfa.acks[2] = (byte)(m >> 16); + pfa.acks[3] = (byte)(m >> 24); + len += 4 + 2; + + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "Sending EACK %u [%u] bits:[%032b]", ack_nr, conn_id_send, m); + #endif + } else { + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "Sending ACK %u [%u]", ack_nr, conn_id_send); + #endif + } + + send_data((byte*)&pfa, len, ack_overhead); + removeSocketFromAckList(this); +} + +void UTPSocket::send_keep_alive() +{ + ack_nr--; + + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "Sending KeepAlive ACK %u [%u]", ack_nr, conn_id_send); + #endif + + send_ack(); + ack_nr++; +} + +void UTPSocket::send_rst(utp_context *ctx, + const PackedSockAddr &addr, uint32 conn_id_send, uint16 ack_nr, uint16 seq_nr) +{ + PacketFormatV1 pf1; + zeromem(&pf1); + + size_t len; + pf1.set_version(1); + pf1.set_type(ST_RESET); + pf1.ext = 0; + pf1.connid = conn_id_send; + pf1.ack_nr = ack_nr; + pf1.seq_nr = seq_nr; + pf1.windowsize = 0; + len = sizeof(PacketFormatV1); + +// LOG_DEBUG("%s: Sending RST id:%u seq_nr:%u ack_nr:%u", addrfmt(addr, addrbuf), conn_id_send, seq_nr, ack_nr); +// LOG_DEBUG("send %s len:%u id:%u", addrfmt(addr, addrbuf), (uint)len, conn_id_send); + send_to_addr(ctx, (const byte*)&pf1, len, addr); +} + +void UTPSocket::send_packet(OutgoingPacket *pkt) +{ + // only count against the quota the first time we + // send the packet. Don't enforce quota when closing + // a socket. Only enforce the quota when we're sending + // at slow rates (max window < packet size) + + //size_t max_send = min(max_window, opt_sndbuf, max_window_user); + time_t cur_time = utp_call_get_milliseconds(this->ctx, this); + + if (pkt->transmissions == 0 || pkt->need_resend) { + cur_window += pkt->payload; + } + + pkt->need_resend = false; + + PacketFormatV1* p1 = (PacketFormatV1*)pkt->data; + p1->ack_nr = ack_nr; + pkt->time_sent = utp_call_get_microseconds(this->ctx, this); + + //socklen_t salen; + //SOCKADDR_STORAGE sa = addr.get_sockaddr_storage(&salen); + bool use_as_mtu_probe = false; + + // TODO: this is subject to nasty wrapping issues! Below as well + if (mtu_discover_time < (uint64)cur_time) { + // it's time to reset our MTU assupmtions + // and trigger a new search + mtu_reset(); + } + + // don't use packets that are larger then mtu_ceiling + // as probes, since they were probably used as probes + // already and failed, now we need it to fragment + // just to get it through + // if seq_nr == 1, the probe would end up being 0 + // which is a magic number representing no-probe + // that why we don't send a probe for a packet with + // sequence number 0 + if (mtu_floor < mtu_ceiling + && pkt->length > mtu_floor + && pkt->length <= mtu_ceiling + && mtu_probe_seq == 0 + && seq_nr != 1 + && pkt->transmissions == 0) { + + // we've already incremented seq_nr + // for this packet + mtu_probe_seq = (seq_nr - 1) & ACK_NR_MASK; + mtu_probe_size = pkt->length; + assert(pkt->length >= mtu_floor); + assert(pkt->length <= mtu_ceiling); + use_as_mtu_probe = true; + log(UTP_LOG_MTU, "MTU [PROBE] floor:%d ceiling:%d current:%d" + , mtu_floor, mtu_ceiling, mtu_probe_size); + } + + pkt->transmissions++; + send_data((byte*)pkt->data, pkt->length, + (state == CS_SYN_SENT) ? connect_overhead + : (pkt->transmissions == 1) ? payload_bandwidth + : retransmit_overhead, use_as_mtu_probe ? UTP_UDP_DONTFRAG : 0); +} + +bool UTPSocket::is_full(int bytes) +{ + size_t packet_size = get_packet_size(); + if (bytes < 0) bytes = packet_size; + else if (bytes > (int)packet_size) bytes = (int)packet_size; + size_t max_send = min(max_window, opt_sndbuf, max_window_user); + + // subtract one to save space for the FIN packet + if (cur_window_packets >= OUTGOING_BUFFER_MAX_SIZE - 1) { + + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "is_full:false cur_window_packets:%d MAX:%d", cur_window_packets, OUTGOING_BUFFER_MAX_SIZE - 1); + #endif + + last_maxed_out_window = ctx->current_ms; + return true; + } + + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "is_full:%s. cur_window:%u pkt:%u max:%u cur_window_packets:%u max_window:%u" + , (cur_window + bytes > max_send) ? "true" : "false" + , cur_window, bytes, max_send, cur_window_packets + , max_window); + #endif + + if (cur_window + bytes > max_send) { + last_maxed_out_window = ctx->current_ms; + return true; + } + return false; +} + +bool UTPSocket::flush_packets() +{ + size_t packet_size = get_packet_size(); + + // send packets that are waiting on the pacer to be sent + // i has to be an unsigned 16 bit counter to wrap correctly + // signed types are not guaranteed to wrap the way you expect + for (uint16 i = seq_nr - cur_window_packets; i != seq_nr; ++i) { + OutgoingPacket *pkt = (OutgoingPacket*)outbuf.get(i); + if (pkt == 0 || (pkt->transmissions > 0 && pkt->need_resend == false)) continue; + // have we run out of quota? + if (is_full()) return true; + + // Nagle check + // don't send the last packet if we have one packet in-flight + // and the current packet is still smaller than packet_size. + if (i != ((seq_nr - 1) & ACK_NR_MASK) || + cur_window_packets == 1 || + pkt->payload >= packet_size) { + send_packet(pkt); + } + } + return false; +} + +// @payload: number of bytes to send +// @flags: either ST_DATA, or ST_FIN +// @iovec: base address of iovec array +// @num_iovecs: number of iovecs in array +void UTPSocket::write_outgoing_packet(size_t payload, uint flags, struct utp_iovec *iovec, size_t num_iovecs) +{ + // Setup initial timeout timer + if (cur_window_packets == 0) { + retransmit_timeout = rto; + rto_timeout = ctx->current_ms + retransmit_timeout; + assert(cur_window == 0); + } + + size_t packet_size = get_packet_size(); + do { + assert(cur_window_packets < OUTGOING_BUFFER_MAX_SIZE); + assert(flags == ST_DATA || flags == ST_FIN); + + size_t added = 0; + + OutgoingPacket *pkt = NULL; + + if (cur_window_packets > 0) { + pkt = (OutgoingPacket*)outbuf.get(seq_nr - 1); + } + + const size_t header_size = get_header_size(); + bool append = true; + + // if there's any room left in the last packet in the window + // and it hasn't been sent yet, fill that frame first + if (payload && pkt && !pkt->transmissions && pkt->payload < packet_size) { + // Use the previous unsent packet + added = min(payload + pkt->payload, max(packet_size, pkt->payload)) - pkt->payload; + pkt = (OutgoingPacket*)realloc(pkt, + (sizeof(OutgoingPacket) - 1) + + header_size + + pkt->payload + added); + outbuf.put(seq_nr - 1, pkt); + append = false; + assert(!pkt->need_resend); + } else { + // Create the packet to send. + added = payload; + pkt = (OutgoingPacket*)malloc((sizeof(OutgoingPacket) - 1) + + header_size + + added); + pkt->payload = 0; + pkt->transmissions = 0; + pkt->need_resend = false; + } + + if (added) { + assert(flags == ST_DATA); + + // Fill it with data from the upper layer. + unsigned char *p = pkt->data + header_size + pkt->payload; + size_t needed = added; + + /* + while (needed) { + *p = *(char*)iovec[0].iov_base; + p++; + iovec[0].iov_base = (char *)iovec[0].iov_base + 1; + needed--; + } + */ + + for (size_t i = 0; i < num_iovecs && needed; i++) { + if (iovec[i].iov_len == 0) + continue; + + size_t num = min(needed, iovec[i].iov_len); + memcpy(p, iovec[i].iov_base, num); + + p += num; + + iovec[i].iov_len -= num; + iovec[i].iov_base = (byte*)iovec[i].iov_base + num; // iovec[i].iov_base += num, but without void* pointers + needed -= num; + } + + assert(needed == 0); + } + pkt->payload += added; + pkt->length = header_size + pkt->payload; + + last_rcv_win = get_rcv_window(); + + PacketFormatV1* p1 = (PacketFormatV1*)pkt->data; + p1->set_version(1); + p1->set_type(flags); + p1->ext = 0; + p1->connid = conn_id_send; + p1->windowsize = (uint32)last_rcv_win; + p1->ack_nr = ack_nr; + + if (append) { + // Remember the message in the outgoing queue. + outbuf.ensure_size(seq_nr, cur_window_packets); + outbuf.put(seq_nr, pkt); + p1->seq_nr = seq_nr; + seq_nr++; + cur_window_packets++; + } + + payload -= added; + + } while (payload); + + flush_packets(); +} + +#ifdef _DEBUG +void UTPSocket::check_invariant() +{ + if (reorder_count > 0) { + assert(inbuf.get(ack_nr + 1) == NULL); + } + + size_t outstanding_bytes = 0; + for (int i = 0; i < cur_window_packets; ++i) { + OutgoingPacket *pkt = (OutgoingPacket*)outbuf.get(seq_nr - i - 1); + if (pkt == 0 || pkt->transmissions == 0 || pkt->need_resend) continue; + outstanding_bytes += pkt->payload; + } + assert(outstanding_bytes == cur_window); +} +#endif + +void UTPSocket::check_timeouts() +{ + #ifdef _DEBUG + check_invariant(); + #endif + + // this invariant should always be true + assert(cur_window_packets == 0 || outbuf.get(seq_nr - cur_window_packets)); + + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "CheckTimeouts timeout:%d max_window:%u cur_window:%u " + "state:%s cur_window_packets:%u", + (int)(rto_timeout - ctx->current_ms), (uint)max_window, (uint)cur_window, + statenames[state], cur_window_packets); + #endif + + if (state != CS_DESTROY) flush_packets(); + + switch (state) { + case CS_SYN_SENT: + case CS_SYN_RECV: + case CS_CONNECTED_FULL: + case CS_CONNECTED: + case CS_FIN_SENT: { + + // Reset max window... + if ((int)(ctx->current_ms - zerowindow_time) >= 0 && max_window_user == 0) { + max_window_user = PACKET_SIZE; + } + + if ((int)(ctx->current_ms - rto_timeout) >= 0 + && rto_timeout > 0) { + + bool ignore_loss = false; + + if (cur_window_packets == 1 + && ((seq_nr - 1) & ACK_NR_MASK) == mtu_probe_seq + && mtu_probe_seq != 0) { + // we only had a single outstanding packet that timed out, and it was the probe + mtu_ceiling = mtu_probe_size - 1; + mtu_search_update(); + // this packet was most likely dropped because the packet size being + // too big and not because congestion. To accelerate the binary search for + // the MTU, resend immediately and don't reset the window size + ignore_loss = true; + log(UTP_LOG_MTU, "MTU [PROBE-TIMEOUT] floor:%d ceiling:%d current:%d" + , mtu_floor, mtu_ceiling, mtu_last); + } + // we dropepd the probe, clear these fields to + // allow us to send a new one + mtu_probe_seq = mtu_probe_size = 0; + log(UTP_LOG_MTU, "MTU [TIMEOUT]"); + + /* + OutgoingPacket *pkt = (OutgoingPacket*)outbuf.get(seq_nr - cur_window_packets); + + // If there were a lot of retransmissions, force recomputation of round trip time + if (pkt->transmissions >= 4) + rtt = 0; + */ + + // Increase RTO + const uint new_timeout = ignore_loss ? retransmit_timeout : retransmit_timeout * 2; + + // They initiated the connection but failed to respond before the rto. + // A malicious client can also spoof the destination address of a ST_SYN bringing us to this state. + // Kill the connection and do not notify the upper layer + if (state == CS_SYN_RECV) { + state = CS_DESTROY; + utp_call_on_error(ctx, this, UTP_ETIMEDOUT); + return; + } + + // We initiated the connection but the other side failed to respond before the rto + if (retransmit_count >= 4 || (state == CS_SYN_SENT && retransmit_count >= 2)) { + // 4 consecutive transmissions have timed out. Kill it. If we + // haven't even connected yet, give up after only 2 consecutive + // failed transmissions. + if (state == CS_FIN_SENT) + state = CS_DESTROY; + else + state = CS_RESET; + utp_call_on_error(ctx, this, UTP_ETIMEDOUT); + return; + } + + retransmit_timeout = new_timeout; + rto_timeout = ctx->current_ms + new_timeout; + + if (!ignore_loss) { + // On Timeout + duplicate_ack = 0; + + int packet_size = get_packet_size(); + + if ((cur_window_packets == 0) && ((int)max_window > packet_size)) { + // we don't have any packets in-flight, even though + // we could. This implies that the connection is just + // idling. No need to be aggressive about resetting the + // congestion window. Just let it decay by a 3:rd. + // don't set it any lower than the packet size though + max_window = max(max_window * 2 / 3, size_t(packet_size)); + } else { + // our delay was so high that our congestion window + // was shrunk below one packet, preventing us from + // sending anything for one time-out period. Now, reset + // the congestion window to fit one packet, to start over + // again + max_window = packet_size; + slow_start = true; + } + } + + // every packet should be considered lost + for (int i = 0; i < cur_window_packets; ++i) { + OutgoingPacket *pkt = (OutgoingPacket*)outbuf.get(seq_nr - i - 1); + if (pkt == 0 || pkt->transmissions == 0 || pkt->need_resend) continue; + pkt->need_resend = true; + assert(cur_window >= pkt->payload); + cur_window -= pkt->payload; + } + + if (cur_window_packets > 0) { + retransmit_count++; + // used in parse_log.py + log(UTP_LOG_NORMAL, "Packet timeout. Resend. seq_nr:%u. timeout:%u " + "max_window:%u cur_window_packets:%d" + , seq_nr - cur_window_packets, retransmit_timeout + , (uint)max_window, int(cur_window_packets)); + + fast_timeout = true; + timeout_seq_nr = seq_nr; + + OutgoingPacket *pkt = (OutgoingPacket*)outbuf.get(seq_nr - cur_window_packets); + assert(pkt); + + // Re-send the packet. + send_packet(pkt); + } + } + + // Mark the socket as writable. If the cwnd has grown, or if the number of + // bytes in-flight is lower than cwnd, we need to make the socket writable again + // in case it isn't + if (state == CS_CONNECTED_FULL && !is_full()) { + state = CS_CONNECTED; + + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "Socket writable. max_window:%u cur_window:%u packet_size:%u", + (uint)max_window, (uint)cur_window, (uint)get_packet_size()); + #endif + utp_call_on_state_change(this->ctx, this, UTP_STATE_WRITABLE); + } + + if (state >= CS_CONNECTED && state < CS_GOT_FIN) { + if ((int)(ctx->current_ms - last_sent_packet) >= KEEPALIVE_INTERVAL) { + send_keep_alive(); + } + } + break; + } + + // Close? + case CS_GOT_FIN: + case CS_DESTROY_DELAY: + if ((int)(ctx->current_ms - rto_timeout) >= 0) { + state = (state == CS_DESTROY_DELAY) ? CS_DESTROY : CS_RESET; + if (cur_window_packets > 0) { + utp_call_on_error(ctx, this, UTP_ECONNRESET); + } + } + break; + // prevent warning + case CS_UNINITIALIZED: + case CS_IDLE: + case CS_RESET: + case CS_DESTROY: + break; + } +} + +// this should be called every time we change mtu_floor or mtu_ceiling +void UTPSocket::mtu_search_update() +{ + assert(mtu_floor <= mtu_ceiling); + + // binary search + mtu_last = (mtu_floor + mtu_ceiling) / 2; + + // enable a new probe to be sent + mtu_probe_seq = mtu_probe_size = 0; + + // if the floor and ceiling are close enough, consider the + // MTU binary search complete. We set the current value + // to floor since that's the only size we know can go through + // also set the ceiling to floor to terminate the searching + if (mtu_ceiling - mtu_floor <= 16) { + mtu_last = mtu_floor; + log(UTP_LOG_MTU, "MTU [DONE] floor:%d ceiling:%d current:%d" + , mtu_floor, mtu_ceiling, mtu_last); + mtu_ceiling = mtu_floor; + assert(mtu_floor <= mtu_ceiling); + // Do another search in 30 minutes + mtu_discover_time = utp_call_get_milliseconds(this->ctx, this) + 30 * 60 * 1000; + } +} + +void UTPSocket::mtu_reset() +{ + mtu_ceiling = get_udp_mtu(); + // Less would not pass TCP... + mtu_floor = 576; + log(UTP_LOG_MTU, "MTU [RESET] floor:%d ceiling:%d current:%d" + , mtu_floor, mtu_ceiling, mtu_last); + assert(mtu_floor <= mtu_ceiling); + mtu_discover_time = utp_call_get_milliseconds(this->ctx, this) + 30 * 60 * 1000; +} + +// returns: +// 0: the packet was acked. +// 1: it means that the packet had already been acked +// 2: the packet has not been sent yet +int UTPSocket::ack_packet(uint16 seq) +{ + OutgoingPacket *pkt = (OutgoingPacket*)outbuf.get(seq); + + // the packet has already been acked (or not sent) + if (pkt == NULL) { + + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "got ack for:%u (already acked, or never sent)", seq); + #endif + + return 1; + } + + // can't ack packets that haven't been sent yet! + if (pkt->transmissions == 0) { + + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "got ack for:%u (never sent, pkt_size:%u need_resend:%u)", + seq, (uint)pkt->payload, pkt->need_resend); + #endif + + return 2; + } + + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "got ack for:%u (pkt_size:%u need_resend:%u)", + seq, (uint)pkt->payload, pkt->need_resend); + #endif + + outbuf.put(seq, NULL); + + // if we never re-sent the packet, update the RTT estimate + if (pkt->transmissions == 1) { + // Estimate the round trip time. + const uint32 ertt = (uint32)((utp_call_get_microseconds(this->ctx, this) - pkt->time_sent) / 1000); + if (rtt == 0) { + // First round trip time sample + rtt = ertt; + rtt_var = ertt / 2; + // sanity check. rtt should never be more than 6 seconds +// assert(rtt < 6000); + } else { + // Compute new round trip times + const int delta = (int)rtt - ertt; + rtt_var = rtt_var + (int)(abs(delta) - rtt_var) / 4; + rtt = rtt - rtt/8 + ertt/8; + // sanity check. rtt should never be more than 6 seconds +// assert(rtt < 6000); + rtt_hist.add_sample(ertt, ctx->current_ms); + } + rto = max(rtt + rtt_var * 4, 1000); + + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "rtt:%u avg:%u var:%u rto:%u", + ertt, rtt, rtt_var, rto); + #endif + + } + retransmit_timeout = rto; + rto_timeout = ctx->current_ms + rto; + // if need_resend is set, this packet has already + // been considered timed-out, and is not included in + // the cur_window anymore + if (!pkt->need_resend) { + assert(cur_window >= pkt->payload); + cur_window -= pkt->payload; + } + free(pkt); + retransmit_count = 0; + return 0; +} + +// count the number of bytes that were acked by the EACK header +size_t UTPSocket::selective_ack_bytes(uint base, const byte* mask, byte len, int64& min_rtt) +{ + if (cur_window_packets == 0) return 0; + + size_t acked_bytes = 0; + int bits = len * 8; + uint64 now = utp_call_get_microseconds(this->ctx, this); + + do { + uint v = base + bits; + + // ignore bits that haven't been sent yet + // see comment in UTPSocket::selective_ack + if (((seq_nr - v - 1) & ACK_NR_MASK) >= (uint16)(cur_window_packets - 1)) + continue; + + // ignore bits that represents packets we haven't sent yet + // or packets that have already been acked + OutgoingPacket *pkt = (OutgoingPacket*)outbuf.get(v); + if (!pkt || pkt->transmissions == 0) + continue; + + // Count the number of segments that were successfully received past it. + if (bits >= 0 && mask[bits>>3] & (1 << (bits & 7))) { + assert((int)(pkt->payload) >= 0); + acked_bytes += pkt->payload; + if (pkt->time_sent < now) + min_rtt = min(min_rtt, now - pkt->time_sent); + else + min_rtt = min(min_rtt, 50000); + continue; + } + } while (--bits >= -1); + return acked_bytes; +} + +enum { MAX_EACK = 128 }; + +void UTPSocket::selective_ack(uint base, const byte *mask, byte len) +{ + if (cur_window_packets == 0) return; + + // the range is inclusive [0, 31] bits + int bits = len * 8 - 1; + + int count = 0; + + // resends is a stack of sequence numbers we need to resend. Since we + // iterate in reverse over the acked packets, at the end, the top packets + // are the ones we want to resend + int resends[MAX_EACK]; + int nr = 0; + +#if UTP_DEBUG_LOGGING + char bitmask[1024] = {0}; + int counter = bits; + for (int i = 0; i <= bits; ++i) { + bool bit_set = counter >= 0 && mask[counter>>3] & (1 << (counter & 7)); + bitmask[i] = bit_set ? '1' : '0'; + --counter; + } + + log(UTP_LOG_DEBUG, "Got EACK [%s] base:%u", bitmask, base); +#endif + + do { + // we're iterating over the bits from higher sequence numbers + // to lower (kind of in reverse order, wich might not be very + // intuitive) + uint v = base + bits; + + // ignore bits that haven't been sent yet + // and bits that fall below the ACKed sequence number + // this can happen if an EACK message gets + // reordered and arrives after a packet that ACKs up past + // the base for thie EACK message + + // this is essentially the same as: + // if v >= seq_nr || v <= seq_nr - cur_window_packets + // but it takes wrapping into account + + // if v == seq_nr the -1 will make it wrap. if v > seq_nr + // it will also wrap (since it will fall further below 0) + // and be > cur_window_packets. + // if v == seq_nr - cur_window_packets, the result will be + // seq_nr - (seq_nr - cur_window_packets) - 1 + // == seq_nr - seq_nr + cur_window_packets - 1 + // == cur_window_packets - 1 which will be caught by the + // test. If v < seq_nr - cur_window_packets the result will grow + // fall furhter outside of the cur_window_packets range. + + // sequence number space: + // + // rejected < accepted > rejected + // <============+--------------+============> + // ^ ^ + // | | + // (seq_nr-wnd) seq_nr + + if (((seq_nr - v - 1) & ACK_NR_MASK) >= (uint16)(cur_window_packets - 1)) + continue; + + // this counts as a duplicate ack, even though we might have + // received an ack for this packet previously (in another EACK + // message for instance) + bool bit_set = bits >= 0 && mask[bits>>3] & (1 << (bits & 7)); + + // if this packet is acked, it counts towards the duplicate ack counter + if (bit_set) count++; + + // ignore bits that represents packets we haven't sent yet + // or packets that have already been acked + OutgoingPacket *pkt = (OutgoingPacket*)outbuf.get(v); + if (!pkt || pkt->transmissions == 0) { + + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "skipping %u. pkt:%08x transmissions:%u %s", + v, pkt, pkt?pkt->transmissions:0, pkt?"(not sent yet?)":"(already acked?)"); + #endif + continue; + } + + // Count the number of segments that were successfully received past it. + if (bit_set) { + // the selective ack should never ACK the packet we're waiting for to decrement cur_window_packets + assert((v & outbuf.mask) != ((seq_nr - cur_window_packets) & outbuf.mask)); + ack_packet(v); + continue; + } + + // Resend segments + // if count is less than our re-send limit, we haven't seen enough + // acked packets in front of this one to warrant a re-send. + // if count == 0, we're still going through the tail of zeroes + if (((v - fast_resend_seq_nr) & ACK_NR_MASK) <= OUTGOING_BUFFER_MAX_SIZE && + count >= DUPLICATE_ACKS_BEFORE_RESEND) { + // resends is a stack, and we're mostly interested in the top of it + // if we're full, just throw away the lower half + if (nr >= MAX_EACK - 2) { + memmove(resends, &resends[MAX_EACK/2], MAX_EACK/2 * sizeof(resends[0])); + nr -= MAX_EACK / 2; + } + resends[nr++] = v; + + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "no ack for %u", v); + #endif + + } else { + + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "not resending %u count:%d dup_ack:%u fast_resend_seq_nr:%u", + v, count, duplicate_ack, fast_resend_seq_nr); + #endif + } + } while (--bits >= -1); + + if (((base - 1 - fast_resend_seq_nr) & ACK_NR_MASK) <= OUTGOING_BUFFER_MAX_SIZE && + count >= DUPLICATE_ACKS_BEFORE_RESEND) { + // if we get enough duplicate acks to start + // resending, the first packet we should resend + // is base-1 + resends[nr++] = (base - 1) & ACK_NR_MASK; + + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "no ack for %u", (base - 1) & ACK_NR_MASK); + #endif + + } else { + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "not resending %u count:%d dup_ack:%u fast_resend_seq_nr:%u", + base - 1, count, duplicate_ack, fast_resend_seq_nr); + #endif + } + + bool back_off = false; + int i = 0; + while (nr > 0) { + uint v = resends[--nr]; + // don't consider the tail of 0:es to be lost packets + // only unacked packets with acked packets after should + // be considered lost + OutgoingPacket *pkt = (OutgoingPacket*)outbuf.get(v); + + // this may be an old (re-ordered) packet, and some of the + // packets in here may have been acked already. In which + // case they will not be in the send queue anymore + if (!pkt) continue; + + // used in parse_log.py + log(UTP_LOG_NORMAL, "Packet %u lost. Resending", v); + + // On Loss + back_off = true; + + #ifdef _DEBUG + ++_stats.rexmit; + #endif + + send_packet(pkt); + fast_resend_seq_nr = (v + 1) & ACK_NR_MASK; + + // Re-send max 4 packets. + if (++i >= 4) break; + } + + if (back_off) + maybe_decay_win(ctx->current_ms); + + duplicate_ack = count; +} + +void UTPSocket::apply_ccontrol(size_t bytes_acked, uint32 actual_delay, int64 min_rtt) +{ + // the delay can never be greater than the rtt. The min_rtt + // variable is the RTT in microseconds + + assert(min_rtt >= 0); + int32 our_delay = min(our_hist.get_value(), uint32(min_rtt)); + assert(our_delay != INT_MAX); + assert(our_delay >= 0); + + utp_call_on_delay_sample(this->ctx, this, our_delay / 1000); + + // This test the connection under heavy load from foreground + // traffic. Pretend that our delays are very high to force the + // connection to use sub-packet size window sizes + //our_delay *= 4; + + // target is microseconds + int target = target_delay; + if (target <= 0) target = 100000; + + // this is here to compensate for very large clock drift that affects + // the congestion controller into giving certain endpoints an unfair + // share of the bandwidth. We have an estimate of the clock drift + // (clock_drift). The unit of this is microseconds per 5 seconds. + // empirically, a reasonable cut-off appears to be about 200000 + // (which is pretty high). The main purpose is to compensate for + // people trying to "cheat" uTP by making their clock run slower, + // and this definitely catches that without any risk of false positives + // if clock_drift < -200000 start applying a penalty delay proportional + // to how far beoynd -200000 the clock drift is + int32 penalty = 0; + if (clock_drift < -200000) { + penalty = (-clock_drift - 200000) / 7; + our_delay += penalty; + } + + double off_target = target - our_delay; + + // this is the same as: + // + // (min(off_target, target) / target) * (bytes_acked / max_window) * MAX_CWND_INCREASE_BYTES_PER_RTT + // + // so, it's scaling the max increase by the fraction of the window this ack represents, and the fraction + // of the target delay the current delay represents. + // The min() around off_target protects against crazy values of our_delay, which may happen when th + // timestamps wraps, or by just having a malicious peer sending garbage. This caps the increase + // of the window size to MAX_CWND_INCREASE_BYTES_PER_RTT per rtt. + // as for large negative numbers, this direction is already capped at the min packet size further down + // the min around the bytes_acked protects against the case where the window size was recently + // shrunk and the number of acked bytes exceeds that. This is considered no more than one full + // window, in order to keep the gain within sane boundries. + + assert(bytes_acked > 0); + double window_factor = (double)min(bytes_acked, max_window) / (double)max(max_window, bytes_acked); + + double delay_factor = off_target / target; + double scaled_gain = MAX_CWND_INCREASE_BYTES_PER_RTT * window_factor * delay_factor; + + // since MAX_CWND_INCREASE_BYTES_PER_RTT is a cap on how much the window size (max_window) + // may increase per RTT, we may not increase the window size more than that proportional + // to the number of bytes that were acked, so that once one window has been acked (one rtt) + // the increase limit is not exceeded + // the +1. is to allow for floating point imprecision + assert(scaled_gain <= 1. + MAX_CWND_INCREASE_BYTES_PER_RTT * (double)min(bytes_acked, max_window) / (double)max(max_window, bytes_acked)); + + if (scaled_gain > 0 && ctx->current_ms - last_maxed_out_window > 1000) { + // if it was more than 1 second since we tried to send a packet + // and stopped because we hit the max window, we're most likely rate + // limited (which prevents us from ever hitting the window size) + // if this is the case, we cannot let the max_window grow indefinitely + scaled_gain = 0; + } + + size_t ledbat_cwnd = (max_window + scaled_gain < MIN_WINDOW_SIZE) ? MIN_WINDOW_SIZE : (size_t)(max_window + scaled_gain); + + if (slow_start) { + size_t ss_cwnd = (size_t)(max_window + window_factor*get_packet_size()); + if (ss_cwnd > ssthresh) { + slow_start = false; + } else if (our_delay > target*0.9) { + // even if we're a little under the target delay, we conservatively + // discontinue the slow start phase + slow_start = false; + ssthresh = max_window; + } else { + max_window = max(ss_cwnd, ledbat_cwnd); + } + } else { + max_window = ledbat_cwnd; + } + + + // make sure that the congestion window is below max + // make sure that we don't shrink our window too small + max_window = clamp(max_window, MIN_WINDOW_SIZE, opt_sndbuf); + + // used in parse_log.py + log(UTP_LOG_NORMAL, "actual_delay:%u our_delay:%d their_delay:%u off_target:%d max_window:%u " + "delay_base:%u delay_sum:%d target_delay:%d acked_bytes:%u cur_window:%u " + "scaled_gain:%f rtt:%u rate:%u wnduser:%u rto:%u timeout:%d get_microseconds:" I64u " " + "cur_window_packets:%u packet_size:%u their_delay_base:%u their_actual_delay:%u " + "average_delay:%d clock_drift:%d clock_drift_raw:%d delay_penalty:%d current_delay_sum:" I64u + "current_delay_samples:%d average_delay_base:%d last_maxed_out_window:" I64u " opt_sndbuf:%d " + "current_ms:" I64u "", + actual_delay, our_delay / 1000, their_hist.get_value() / 1000, + int(off_target / 1000), uint(max_window), uint32(our_hist.delay_base), + int((our_delay + their_hist.get_value()) / 1000), int(target / 1000), uint(bytes_acked), + (uint)(cur_window - bytes_acked), (float)(scaled_gain), rtt, + (uint)(max_window * 1000 / (rtt_hist.delay_base?rtt_hist.delay_base:50)), + (uint)max_window_user, rto, (int)(rto_timeout - ctx->current_ms), + utp_call_get_microseconds(this->ctx, this), cur_window_packets, (uint)get_packet_size(), + their_hist.delay_base, their_hist.delay_base + their_hist.get_value(), + average_delay, clock_drift, clock_drift_raw, penalty / 1000, + current_delay_sum, current_delay_samples, average_delay_base, + uint64(last_maxed_out_window), int(opt_sndbuf), uint64(ctx->current_ms)); +} + +static void utp_register_recv_packet(UTPSocket *conn, size_t len) +{ + #ifdef _DEBUG + ++conn->_stats.nrecv; + conn->_stats.nbytes_recv += len; + #endif + + if (len <= PACKET_SIZE_MID) { + if (len <= PACKET_SIZE_EMPTY) { + conn->ctx->context_stats._nraw_recv[PACKET_SIZE_EMPTY_BUCKET]++; + } else if (len <= PACKET_SIZE_SMALL) { + conn->ctx->context_stats._nraw_recv[PACKET_SIZE_SMALL_BUCKET]++; + } else + conn->ctx->context_stats._nraw_recv[PACKET_SIZE_MID_BUCKET]++; + } else { + if (len <= PACKET_SIZE_BIG) { + conn->ctx->context_stats._nraw_recv[PACKET_SIZE_BIG_BUCKET]++; + } else + conn->ctx->context_stats._nraw_recv[PACKET_SIZE_HUGE_BUCKET]++; + } +} + +// returns the max number of bytes of payload the uTP +// connection is allowed to send +size_t UTPSocket::get_packet_size() const +{ + int header_size = sizeof(PacketFormatV1); + size_t mtu = mtu_last ? mtu_last : mtu_ceiling; + return mtu - header_size; +} + +// Process an incoming packet +// syn is true if this is the first packet received. It will cut off parsing +// as soon as the header is done +size_t utp_process_incoming(UTPSocket *conn, const byte *packet, size_t len, bool syn = false) +{ + utp_register_recv_packet(conn, len); + + conn->ctx->current_ms = utp_call_get_milliseconds(conn->ctx, conn); + + const PacketFormatV1 *pf1 = (PacketFormatV1*)packet; + const byte *packet_end = packet + len; + + uint16 pk_seq_nr = pf1->seq_nr; + uint16 pk_ack_nr = pf1->ack_nr; + uint8 pk_flags = pf1->type(); + + if (pk_flags >= ST_NUM_STATES) return 0; + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "Got %s. seq_nr:%u ack_nr:%u state:%s timestamp:" I64u " reply_micro:%u" + , flagnames[pk_flags], pk_seq_nr, pk_ack_nr, statenames[conn->state] + , uint64(pf1->tv_usec), (uint32)(pf1->reply_micro)); + #endif + + // mark receipt time + uint64 time = utp_call_get_microseconds(conn->ctx, conn); + + // window packets size is used to calculate a minimum + // permissible range for received acks. connections with acks falling + // out of this range are dropped + const uint16 curr_window = max(conn->cur_window_packets + ACK_NR_ALLOWED_WINDOW, ACK_NR_ALLOWED_WINDOW); + + // ignore packets whose ack_nr is invalid. This would imply a spoofed address + // or a malicious attempt to attach the uTP implementation. + // acking a packet that hasn't been sent yet! + // SYN packets have an exception, since there are no previous packets + if ((pk_flags != ST_SYN || conn->state != CS_SYN_RECV) && + (wrapping_compare_less(conn->seq_nr - 1, pk_ack_nr, ACK_NR_MASK) + || wrapping_compare_less(pk_ack_nr, conn->seq_nr - 1 - curr_window, ACK_NR_MASK))) { +#if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "Invalid ack_nr: %u. our seq_nr: %u last unacked: %u" + , pk_ack_nr, conn->seq_nr, (conn->seq_nr - conn->cur_window_packets) & ACK_NR_MASK); +#endif + return 0; + } + + // RSTs are handled earlier, since the connid matches the send id not the recv id + assert(pk_flags != ST_RESET); + + // TODO: maybe send a ST_RESET if we're in CS_RESET? + + const byte *selack_ptr = NULL; + + // Unpack UTP packet options + // Data pointer + const byte *data = (const byte*)pf1 + conn->get_header_size(); + if (conn->get_header_size() > len) { + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "Invalid packet size (less than header size)"); + #endif + + return 0; + } + // Skip the extension headers + uint extension = pf1->ext; + if (extension != 0) { + do { + // Verify that the packet is valid. + data += 2; + + if ((int)(packet_end - data) < 0 || (int)(packet_end - data) < data[-1]) { + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "Invalid len of extensions"); + #endif + + return 0; + } + + switch(extension) { + case 1: // Selective Acknowledgment + selack_ptr = data; + break; + case 2: // extension bits + if (data[-1] != 8) { + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "Invalid len of extension bits header"); + #endif + + return 0; + } + memcpy(conn->extensions, data, 8); + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "got extension bits:%02x%02x%02x%02x%02x%02x%02x%02x", + conn->extensions[0], conn->extensions[1], conn->extensions[2], conn->extensions[3], + conn->extensions[4], conn->extensions[5], conn->extensions[6], conn->extensions[7]); + #endif + } + extension = data[-2]; + data += data[-1]; + } while (extension); + } + + if (conn->state == CS_SYN_SENT) { + // if this is a syn-ack, initialize our ack_nr + // to match the sequence number we got from + // the other end + conn->ack_nr = (pk_seq_nr - 1) & SEQ_NR_MASK; + } + + conn->last_got_packet = conn->ctx->current_ms; + + if (syn) { + return 0; + } + + // seqnr is the number of packets past the expected + // packet this is. ack_nr is the last acked, seq_nr is the + // current. Subtracring 1 makes 0 mean "this is the next + // expected packet". + const uint seqnr = (pk_seq_nr - conn->ack_nr - 1) & SEQ_NR_MASK; + + // Getting an invalid sequence number? + if (seqnr >= REORDER_BUFFER_MAX_SIZE) { + if (seqnr >= (SEQ_NR_MASK + 1) - REORDER_BUFFER_MAX_SIZE && pk_flags != ST_STATE) { + conn->schedule_ack(); + } + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, " Got old Packet/Ack (%u/%u)=%u" + , pk_seq_nr, conn->ack_nr, seqnr); + #endif + return 0; + } + + // Process acknowledgment + // acks is the number of packets that was acked + int acks = (pk_ack_nr - (conn->seq_nr - 1 - conn->cur_window_packets)) & ACK_NR_MASK; + + // this happens when we receive an old ack nr + if (acks > conn->cur_window_packets) acks = 0; + + // if we get the same ack_nr as in the last packet + // increase the duplicate_ack counter, otherwise reset + // it to 0. + // It's important to only count ACKs in ST_STATE packets. Any other + // packet (primarily ST_DATA) is likely to have been sent because of the + // other end having new outgoing data, not in response to incoming data. + // For instance, if we're receiving a steady stream of payload with no + // outgoing data, and we suddently have a few bytes of payload to send (say, + // a bittorrent HAVE message), we're very likely to see 3 duplicate ACKs + // immediately after sending our payload packet. This effectively disables + // the fast-resend on duplicate-ack logic for bi-directional connections + // (except in the case of a selective ACK). This is in line with BSD4.4 TCP + // implementation. + if (conn->cur_window_packets > 0) { + if (pk_ack_nr == ((conn->seq_nr - conn->cur_window_packets - 1) & ACK_NR_MASK) + && conn->cur_window_packets > 0 + && pk_flags == ST_STATE) { + ++conn->duplicate_ack; + if (conn->duplicate_ack == DUPLICATE_ACKS_BEFORE_RESEND && conn->mtu_probe_seq) { + // It's likely that the probe was rejected due to its size, but we haven't got an + // ICMP report back yet + if (pk_ack_nr == ((conn->mtu_probe_seq - 1) & ACK_NR_MASK)) { + conn->mtu_ceiling = conn->mtu_probe_size - 1; + conn->mtu_search_update(); + conn->log(UTP_LOG_MTU, "MTU [DUPACK] floor:%d ceiling:%d current:%d" + , conn->mtu_floor, conn->mtu_ceiling, conn->mtu_last); + } else { + // A non-probe was blocked before our probe. + // Can't conclude much, send a new probe + conn->mtu_probe_seq = conn->mtu_probe_size = 0; + } + } + } else { + conn->duplicate_ack = 0; + } + + // TODO: if duplicate_ack == DUPLICATE_ACK_BEFORE_RESEND + // and fast_resend_seq_nr <= ack_nr + 1 + // resend ack_nr + 1 + // also call maybe_decay_win() + } + + // figure out how many bytes were acked + size_t acked_bytes = 0; + + // the minimum rtt of all acks + // this is the upper limit on the delay we get back + // from the other peer. Our delay cannot exceed + // the rtt of the packet. If it does, clamp it. + // this is done in apply_ledbat_ccontrol() + int64 min_rtt = INT64_MAX; + + uint64 now = utp_call_get_microseconds(conn->ctx, conn); + + for (int i = 0; i < acks; ++i) { + int seq = (conn->seq_nr - conn->cur_window_packets + i) & ACK_NR_MASK; + OutgoingPacket *pkt = (OutgoingPacket*)conn->outbuf.get(seq); + if (pkt == 0 || pkt->transmissions == 0) continue; + assert((int)(pkt->payload) >= 0); + acked_bytes += pkt->payload; + if (conn->mtu_probe_seq && seq == conn->mtu_probe_seq) { + conn->mtu_floor = conn->mtu_probe_size; + conn->mtu_search_update(); + conn->log(UTP_LOG_MTU, "MTU [ACK] floor:%d ceiling:%d current:%d" + , conn->mtu_floor, conn->mtu_ceiling, conn->mtu_last); + } + + // in case our clock is not monotonic + if (pkt->time_sent < now) + min_rtt = min(min_rtt, now - pkt->time_sent); + else + min_rtt = min(min_rtt, 50000); + } + + // count bytes acked by EACK + if (selack_ptr != NULL) { + acked_bytes += conn->selective_ack_bytes((pk_ack_nr + 2) & ACK_NR_MASK, + selack_ptr, selack_ptr[-1], min_rtt); + } + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "acks:%d acked_bytes:%u seq_nr:%d cur_window:%u cur_window_packets:%u relative_seqnr:%u max_window:%u min_rtt:%u rtt:%u", + acks, (uint)acked_bytes, conn->seq_nr, (uint)conn->cur_window, conn->cur_window_packets, + seqnr, (uint)conn->max_window, (uint)(min_rtt / 1000), conn->rtt); + #endif + + uint64 p = pf1->tv_usec; + + conn->last_measured_delay = conn->ctx->current_ms; + + // get delay in both directions + // record the delay to report back + const uint32 their_delay = (uint32)(p == 0 ? 0 : time - p); + conn->reply_micro = their_delay; + uint32 prev_delay_base = conn->their_hist.delay_base; + if (their_delay != 0) conn->their_hist.add_sample(their_delay, conn->ctx->current_ms); + + // if their new delay base is less than their previous one + // we should shift our delay base in the other direction in order + // to take the clock skew into account + if (prev_delay_base != 0 && + wrapping_compare_less(conn->their_hist.delay_base, prev_delay_base, TIMESTAMP_MASK)) { + // never adjust more than 10 milliseconds + if (prev_delay_base - conn->their_hist.delay_base <= 10000) { + conn->our_hist.shift(prev_delay_base - conn->their_hist.delay_base); + } + } + + const uint32 actual_delay = (uint32(pf1->reply_micro)==INT_MAX?0:uint32(pf1->reply_micro)); + + // if the actual delay is 0, it means the other end + // hasn't received a sample from us yet, and doesn't + // know what it is. We can't update out history unless + // we have a true measured sample + if (actual_delay != 0) { + conn->our_hist.add_sample(actual_delay, conn->ctx->current_ms); + + // this is keeping an average of the delay samples + // we've recevied within the last 5 seconds. We sum + // all the samples and increase the count in order to + // calculate the average every 5 seconds. The samples + // are based off of the average_delay_base to deal with + // wrapping counters. + if (conn->average_delay_base == 0) conn->average_delay_base = actual_delay; + int64 average_delay_sample = 0; + // distance walking from lhs to rhs, downwards + const uint32 dist_down = conn->average_delay_base - actual_delay; + // distance walking from lhs to rhs, upwards + const uint32 dist_up = actual_delay - conn->average_delay_base; + + if (dist_down > dist_up) { +// assert(dist_up < INT_MAX / 4); + // average_delay_base < actual_delay, we should end up + // with a positive sample + average_delay_sample = dist_up; + } else { +// assert(-int64(dist_down) < INT_MAX / 4); + // average_delay_base >= actual_delay, we should end up + // with a negative sample + average_delay_sample = -int64(dist_down); + } + conn->current_delay_sum += average_delay_sample; + ++conn->current_delay_samples; + + if (conn->ctx->current_ms > conn->average_sample_time) { + + int32 prev_average_delay = conn->average_delay; + + assert(conn->current_delay_sum / conn->current_delay_samples < INT_MAX); + assert(conn->current_delay_sum / conn->current_delay_samples > -INT_MAX); + // write the new average + conn->average_delay = (int32)(conn->current_delay_sum / conn->current_delay_samples); + // each slot represents 5 seconds + conn->average_sample_time += 5000; + + conn->current_delay_sum = 0; + conn->current_delay_samples = 0; + + // this makes things very confusing when logging the average delay +//#if !g_log_utp + // normalize the average samples + // since we're only interested in the slope + // of the curve formed by the average delay samples, + // we can cancel out the actual offset to make sure + // we won't have problems with wrapping. + int min_sample = min(prev_average_delay, conn->average_delay); + int max_sample = max(prev_average_delay, conn->average_delay); + + // normalize around zero. Try to keep the min <= 0 and max >= 0 + int adjust = 0; + if (min_sample > 0) { + // adjust all samples (and the baseline) down by min_sample + adjust = -min_sample; + } else if (max_sample < 0) { + // adjust all samples (and the baseline) up by -max_sample + adjust = -max_sample; + } + if (adjust) { + conn->average_delay_base -= adjust; + conn->average_delay += adjust; + prev_average_delay += adjust; + } +//#endif + + // update the clock drift estimate + // the unit is microseconds per 5 seconds + // what we're doing is just calculating the average of the + // difference between each slot. Since each slot is 5 seconds + // and the timestamps unit are microseconds, we'll end up with + // the average slope across our history. If there is a consistent + // trend, it will show up in this value + + //int64 slope = 0; + int32 drift = conn->average_delay - prev_average_delay; + + // clock_drift is a rolling average + conn->clock_drift = (int64(conn->clock_drift) * 7 + drift) / 8; + conn->clock_drift_raw = drift; + } + } + + // if our new delay base is less than our previous one + // we should shift the other end's delay base in the other + // direction in order to take the clock skew into account + // This is commented out because it creates bad interactions + // with our adjustment in the other direction. We don't really + // need our estimates of the other peer to be very accurate + // anyway. The problem with shifting here is that we're more + // likely shift it back later because of a low latency. This + // second shift back would cause us to shift our delay base + // which then get's into a death spiral of shifting delay bases +/* if (prev_delay_base != 0 && + wrapping_compare_less(conn->our_hist.delay_base, prev_delay_base)) { + // never adjust more than 10 milliseconds + if (prev_delay_base - conn->our_hist.delay_base <= 10000) { + conn->their_hist.Shift(prev_delay_base - conn->our_hist.delay_base); + } + } +*/ + + // if the delay estimate exceeds the RTT, adjust the base_delay to + // compensate + assert(min_rtt >= 0); + if (int64(conn->our_hist.get_value()) > min_rtt) { + conn->our_hist.shift((uint32)(conn->our_hist.get_value() - min_rtt)); + } + + // only apply the congestion controller on acks + // if we don't have a delay measurement, there's + // no point in invoking the congestion control + if (actual_delay != 0 && acked_bytes >= 1) + conn->apply_ccontrol(acked_bytes, actual_delay, min_rtt); + + // sanity check, the other end should never ack packets + // past the point we've sent + if (acks <= conn->cur_window_packets) { + conn->max_window_user = pf1->windowsize; + + // If max user window is set to 0, then we startup a timer + // That will reset it to 1 after 15 seconds. + if (conn->max_window_user == 0) + // Reset max_window_user to 1 every 15 seconds. + conn->zerowindow_time = conn->ctx->current_ms + 15000; + + // Respond to connect message + // Switch to CONNECTED state. + // If this is an ack and we're in still handshaking + // transition over to the connected state. + + // Incoming connection completion + if (pk_flags == ST_DATA && conn->state == CS_SYN_RECV) { + conn->state = CS_CONNECTED; + } + + // Outgoing connection completion + if (pk_flags == ST_STATE && conn->state == CS_SYN_SENT) { + conn->state = CS_CONNECTED; + + // If the user has defined the ON_CONNECT callback, use that to + // notify the user that the socket is now connected. If ON_CONNECT + // has not been defined, notify the user via ON_STATE_CHANGE. + if (conn->ctx->callbacks[UTP_ON_CONNECT]) + utp_call_on_connect(conn->ctx, conn); + else + utp_call_on_state_change(conn->ctx, conn, UTP_STATE_CONNECT); + + // We've sent a fin, and everything was ACKed (including the FIN), + // it's safe to destroy the socket. cur_window_packets == acks + // means that this packet acked all the remaining packets that + // were in-flight. + } else if (conn->state == CS_FIN_SENT && conn->cur_window_packets == acks) { + conn->state = CS_DESTROY; + } + + // Update fast resend counter + if (wrapping_compare_less(conn->fast_resend_seq_nr + , (pk_ack_nr + 1) & ACK_NR_MASK, ACK_NR_MASK)) + conn->fast_resend_seq_nr = (pk_ack_nr + 1) & ACK_NR_MASK; + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "fast_resend_seq_nr:%u", conn->fast_resend_seq_nr); + #endif + + for (int i = 0; i < acks; ++i) { + int ack_status = conn->ack_packet(conn->seq_nr - conn->cur_window_packets); + // if ack_status is 0, the packet was acked. + // if acl_stauts is 1, it means that the packet had already been acked + // if it's 2, the packet has not been sent yet + // We need to break this loop in the latter case. This could potentially + // happen if we get an ack_nr that does not exceed what we have stuffed + // into the outgoing buffer, but does exceed what we have sent + if (ack_status == 2) { + #ifdef _DEBUG + OutgoingPacket* pkt = (OutgoingPacket*)conn->outbuf.get(conn->seq_nr - conn->cur_window_packets); + assert(pkt->transmissions == 0); + #endif + + break; + } + conn->cur_window_packets--; + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "decementing cur_window_packets:%u", conn->cur_window_packets); + #endif + + } + + #ifdef _DEBUG + if (conn->cur_window_packets == 0) + assert(conn->cur_window == 0); + #endif + + // packets in front of this may have been acked by a + // selective ack (EACK). Keep decreasing the window packet size + // until we hit a packet that is still waiting to be acked + // in the send queue + // this is especially likely to happen when the other end + // has the EACK send bug older versions of uTP had + while (conn->cur_window_packets > 0 && !conn->outbuf.get(conn->seq_nr - conn->cur_window_packets)) { + conn->cur_window_packets--; + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "decementing cur_window_packets:%u", conn->cur_window_packets); + #endif + + } + + #ifdef _DEBUG + if (conn->cur_window_packets == 0) + assert(conn->cur_window == 0); + #endif + + // this invariant should always be true + assert(conn->cur_window_packets == 0 || conn->outbuf.get(conn->seq_nr - conn->cur_window_packets)); + + // flush Nagle + if (conn->cur_window_packets == 1) { + OutgoingPacket *pkt = (OutgoingPacket*)conn->outbuf.get(conn->seq_nr - 1); + // do we still have quota? + if (pkt->transmissions == 0) { + conn->send_packet(pkt); + } + } + + // Fast timeout-retry + if (conn->fast_timeout) { + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "Fast timeout %u,%u,%u?", (uint)conn->cur_window, conn->seq_nr - conn->timeout_seq_nr, conn->timeout_seq_nr); + #endif + + // if the fast_resend_seq_nr is not pointing to the oldest outstanding packet, it suggests that we've already + // resent the packet that timed out, and we should leave the fast-timeout mode. + if (((conn->seq_nr - conn->cur_window_packets) & ACK_NR_MASK) != conn->fast_resend_seq_nr) { + conn->fast_timeout = false; + } else { + // resend the oldest packet and increment fast_resend_seq_nr + // to not allow another fast resend on it again + OutgoingPacket *pkt = (OutgoingPacket*)conn->outbuf.get(conn->seq_nr - conn->cur_window_packets); + if (pkt && pkt->transmissions > 0) { + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "Packet %u fast timeout-retry.", conn->seq_nr - conn->cur_window_packets); + #endif + + #ifdef _DEBUG + ++conn->_stats.fastrexmit; + #endif + + conn->fast_resend_seq_nr++; + conn->send_packet(pkt); + } + } + } + } + + // Process selective acknowledgent + if (selack_ptr != NULL) { + conn->selective_ack(pk_ack_nr + 2, selack_ptr, selack_ptr[-1]); + } + + // this invariant should always be true + assert(conn->cur_window_packets == 0 || conn->outbuf.get(conn->seq_nr - conn->cur_window_packets)); + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "acks:%d acked_bytes:%u seq_nr:%u cur_window:%u cur_window_packets:%u ", + acks, (uint)acked_bytes, conn->seq_nr, (uint)conn->cur_window, conn->cur_window_packets); + #endif + + // In case the ack dropped the current window below + // the max_window size, Mark the socket as writable + if (conn->state == CS_CONNECTED_FULL && !conn->is_full()) { + conn->state = CS_CONNECTED; + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "Socket writable. max_window:%u cur_window:%u packet_size:%u", + (uint)conn->max_window, (uint)conn->cur_window, (uint)conn->get_packet_size()); + #endif + utp_call_on_state_change(conn->ctx, conn, UTP_STATE_WRITABLE); + } + + if (pk_flags == ST_STATE) { + // This is a state packet only. + return 0; + } + + // The connection is not in a state that can accept data? + if (conn->state != CS_CONNECTED && + conn->state != CS_CONNECTED_FULL && + conn->state != CS_FIN_SENT) { + return 0; + } + + // Is this a finalize packet? + if (pk_flags == ST_FIN && !conn->got_fin) { + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "Got FIN eof_pkt:%u", pk_seq_nr); + #endif + + conn->got_fin = true; + conn->eof_pkt = pk_seq_nr; + // at this point, it is possible for the + // other end to have sent packets with + // sequence numbers higher than seq_nr. + // if this is the case, our reorder_count + // is out of sync. This case is dealt with + // when we re-order and hit the eof_pkt. + // we'll just ignore any packets with + // sequence numbers past this + } + + // Getting an in-order packet? + if (seqnr == 0) { + size_t count = packet_end - data; + if (count > 0 && conn->state != CS_FIN_SENT) { + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "Got Data len:%u (rb:%u)", (uint)count, (uint)utp_call_get_read_buffer_size(conn->ctx, conn)); + #endif + + // Post bytes to the upper layer + utp_call_on_read(conn->ctx, conn, data, count); + } + conn->ack_nr++; + + // Check if the next packet has been received too, but waiting + // in the reorder buffer. + for (;;) { + + if (conn->got_fin && conn->eof_pkt == conn->ack_nr) { + if (conn->state != CS_FIN_SENT) { + conn->state = CS_GOT_FIN; + conn->rto_timeout = conn->ctx->current_ms + min(conn->rto * 3, 60); + + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "Posting EOF"); + #endif + + utp_call_on_state_change(conn->ctx, conn, UTP_STATE_EOF); + } + + // if the other end wants to close, ack + conn->send_ack(); + + // reorder_count is not necessarily 0 at this point. + // even though it is most of the time, the other end + // may have sent packets with higher sequence numbers + // than what later end up being eof_pkt + // since we have received all packets up to eof_pkt + // just ignore the ones after it. + conn->reorder_count = 0; + } + + // Quick get-out in case there is nothing to reorder + if (conn->reorder_count == 0) + break; + + // Check if there are additional buffers in the reorder buffers + // that need delivery. + byte *p = (byte*)conn->inbuf.get(conn->ack_nr+1); + if (p == NULL) + break; + conn->inbuf.put(conn->ack_nr+1, NULL); + count = *(uint*)p; + if (count > 0 && conn->state != CS_FIN_SENT) { + // Pass the bytes to the upper layer + utp_call_on_read(conn->ctx, conn, p + sizeof(uint), count); + } + conn->ack_nr++; + + // Free the element from the reorder buffer + free(p); + assert(conn->reorder_count > 0); + conn->reorder_count--; + } + + conn->schedule_ack(); + } else { + // Getting an out of order packet. + // The packet needs to be remembered and rearranged later. + + // if we have received a FIN packet, and the EOF-sequence number + // is lower than the sequence number of the packet we just received + // something is wrong. + if (conn->got_fin && pk_seq_nr > conn->eof_pkt) { + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "Got an invalid packet sequence number, past EOF " + "reorder_count:%u len:%u (rb:%u)", + conn->reorder_count, (uint)(packet_end - data), (uint)utp_call_get_read_buffer_size(conn->ctx, conn)); + #endif + return 0; + } + + // if the sequence number is entirely off the expected + // one, just drop it. We can't allocate buffer space in + // the inbuf entirely based on untrusted input + if (seqnr > 0x3ff) { + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "0x%08x: Got an invalid packet sequence number, too far off " + "reorder_count:%u len:%u (rb:%u)", + conn->reorder_count, (uint)(packet_end - data), (uint)utp_call_get_read_buffer_size(conn->ctx, conn)); + #endif + return 0; + } + + // we need to grow the circle buffer before we + // check if the packet is already in here, so that + // we don't end up looking at an older packet (since + // the indices wraps around). + conn->inbuf.ensure_size(pk_seq_nr + 1, seqnr + 1); + + // Has this packet already been received? (i.e. a duplicate) + // If that is the case, just discard it. + if (conn->inbuf.get(pk_seq_nr) != NULL) { + #ifdef _DEBUG + ++conn->_stats.nduprecv; + #endif + + return 0; + } + + // Allocate memory to fit the packet that needs to re-ordered + byte *mem = (byte*)malloc((packet_end - data) + sizeof(uint)); + *(uint*)mem = (uint)(packet_end - data); + memcpy(mem + sizeof(uint), data, packet_end - data); + + // Insert into reorder buffer and increment the count + // of # of packets to be reordered. + // we add one to seqnr in order to leave the last + // entry empty, that way the assert in send_ack + // is valid. we have to add one to seqnr too, in order + // to make the circular buffer grow around the correct + // point (which is conn->ack_nr + 1). + assert(conn->inbuf.get(pk_seq_nr) == NULL); + assert((pk_seq_nr & conn->inbuf.mask) != ((conn->ack_nr+1) & conn->inbuf.mask)); + conn->inbuf.put(pk_seq_nr, mem); + conn->reorder_count++; + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "0x%08x: Got out of order data reorder_count:%u len:%u (rb:%u)", + conn->reorder_count, (uint)(packet_end - data), (uint)utp_call_get_read_buffer_size(conn->ctx, conn)); + #endif + + conn->schedule_ack(); + } + + return (size_t)(packet_end - data); +} + +inline byte UTP_Version(PacketFormatV1 const* pf) +{ + return (pf->type() < ST_NUM_STATES && pf->ext < 3 ? pf->version() : 0); +} + +UTPSocket::~UTPSocket() +{ + #if UTP_DEBUG_LOGGING + log(UTP_LOG_DEBUG, "Killing socket"); + #endif + + utp_call_on_state_change(ctx, this, UTP_STATE_DESTROYING); + + if (ctx->last_utp_socket == this) { + ctx->last_utp_socket = NULL; + } + + // Remove object from the global hash table + UTPSocketKeyData* kd = ctx->utp_sockets->Delete(UTPSocketKey(addr, conn_id_recv)); + assert(kd); + + // remove the socket from ack_sockets if it was there also + removeSocketFromAckList(this); + + // Free all memory occupied by the socket object. + for (size_t i = 0; i <= inbuf.mask; i++) { + free(inbuf.elements[i]); + } + for (size_t i = 0; i <= outbuf.mask; i++) { + free(outbuf.elements[i]); + } + // TODO: The circular buffer should have a destructor + free(inbuf.elements); + free(outbuf.elements); +} + +void UTP_FreeAll(struct UTPSocketHT *utp_sockets) { + utp_hash_iterator_t it; + UTPSocketKeyData* keyData; + while ((keyData = utp_sockets->Iterate(it))) { + delete keyData->socket; + } +} + +void utp_initialize_socket( utp_socket *conn, + const struct sockaddr *addr, + socklen_t addrlen, + bool need_seed_gen, + uint32 conn_seed, + uint32 conn_id_recv, + uint32 conn_id_send) +{ + PackedSockAddr psaddr = PackedSockAddr((const SOCKADDR_STORAGE*)addr, addrlen); + + if (need_seed_gen) { + do { + conn_seed = utp_call_get_random(conn->ctx, conn); + // we identify v1 and higher by setting the first two bytes to 0x0001 + conn_seed &= 0xffff; + } while (conn->ctx->utp_sockets->Lookup(UTPSocketKey(psaddr, conn_seed))); + + conn_id_recv += conn_seed; + conn_id_send += conn_seed; + } + + conn->state = CS_IDLE; + conn->conn_seed = conn_seed; + conn->conn_id_recv = conn_id_recv; + conn->conn_id_send = conn_id_send; + conn->addr = psaddr; + conn->ctx->current_ms = utp_call_get_milliseconds(conn->ctx, NULL); + conn->last_got_packet = conn->ctx->current_ms; + conn->last_sent_packet = conn->ctx->current_ms; + conn->last_measured_delay = conn->ctx->current_ms + 0x70000000; + conn->average_sample_time = conn->ctx->current_ms + 5000; + conn->last_rwin_decay = conn->ctx->current_ms - MAX_WINDOW_DECAY; + + conn->our_hist.clear(conn->ctx->current_ms); + conn->their_hist.clear(conn->ctx->current_ms); + conn->rtt_hist.clear(conn->ctx->current_ms); + + // initialize MTU floor and ceiling + conn->mtu_reset(); + conn->mtu_last = conn->mtu_ceiling; + + conn->ctx->utp_sockets->Add(UTPSocketKey(conn->addr, conn->conn_id_recv))->socket = conn; + + // we need to fit one packet in the window when we start the connection + conn->max_window = conn->get_packet_size(); + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "UTP socket initialized"); + #endif +} + +utp_socket* utp_create_socket(utp_context *ctx) +{ + assert(ctx); + if (!ctx) return NULL; + + UTPSocket *conn = new UTPSocket; // TODO: UTPSocket should have a constructor + + conn->state = CS_UNINITIALIZED; + conn->ctx = ctx; + conn->userdata = NULL; + conn->reorder_count = 0; + conn->duplicate_ack = 0; + conn->timeout_seq_nr = 0; + conn->last_rcv_win = 0; + conn->got_fin = false; + conn->fast_timeout = false; + conn->rtt = 0; + conn->retransmit_timeout = 0; + conn->rto_timeout = 0; + conn->zerowindow_time = 0; + conn->average_delay = 0; + conn->current_delay_samples = 0; + conn->cur_window = 0; + conn->eof_pkt = 0; + conn->last_maxed_out_window = 0; + conn->mtu_probe_seq = 0; + conn->mtu_probe_size = 0; + conn->current_delay_sum = 0; + conn->average_delay_base = 0; + conn->retransmit_count = 0; + conn->rto = 3000; + conn->rtt_var = 800; + conn->seq_nr = 1; + conn->ack_nr = 0; + conn->max_window_user = 255 * PACKET_SIZE; + conn->cur_window_packets = 0; + conn->fast_resend_seq_nr = conn->seq_nr; + conn->target_delay = ctx->target_delay; + conn->reply_micro = 0; + conn->opt_sndbuf = ctx->opt_sndbuf; + conn->opt_rcvbuf = ctx->opt_rcvbuf; + conn->slow_start = true; + conn->ssthresh = conn->opt_sndbuf; + conn->clock_drift = 0; + conn->clock_drift_raw = 0; + conn->outbuf.mask = 15; + conn->inbuf.mask = 15; + conn->outbuf.elements = (void**)calloc(16, sizeof(void*)); + conn->inbuf.elements = (void**)calloc(16, sizeof(void*)); + conn->ida = -1; // set the index of every new socket in ack_sockets to + // -1, which also means it is not in ack_sockets yet + + memset(conn->extensions, 0, sizeof(conn->extensions)); + + #ifdef _DEBUG + memset(&conn->_stats, 0, sizeof(utp_socket_stats)); + #endif + + return conn; +} + +int utp_context_set_option(utp_context *ctx, int opt, int val) +{ + assert(ctx); + if (!ctx) return -1; + + switch (opt) { + case UTP_LOG_NORMAL: + ctx->log_normal = val ? true : false; + return 0; + + case UTP_LOG_MTU: + ctx->log_mtu = val ? true : false; + return 0; + + case UTP_LOG_DEBUG: + ctx->log_debug = val ? true : false; + return 0; + + case UTP_TARGET_DELAY: + ctx->target_delay = val; + return 0; + + case UTP_SNDBUF: + assert(val >= 1); + ctx->opt_sndbuf = val; + return 0; + + case UTP_RCVBUF: + assert(val >= 1); + ctx->opt_rcvbuf = val; + return 0; + } + return -1; +} + +int utp_context_get_option(utp_context *ctx, int opt) +{ + assert(ctx); + if (!ctx) return -1; + + switch (opt) { + case UTP_LOG_NORMAL: return ctx->log_normal ? 1 : 0; + case UTP_LOG_MTU: return ctx->log_mtu ? 1 : 0; + case UTP_LOG_DEBUG: return ctx->log_debug ? 1 : 0; + case UTP_TARGET_DELAY: return ctx->target_delay; + case UTP_SNDBUF: return ctx->opt_sndbuf; + case UTP_RCVBUF: return ctx->opt_rcvbuf; + } + return -1; +} + + +int utp_setsockopt(UTPSocket* conn, int opt, int val) +{ + assert(conn); + if (!conn) return -1; + + switch (opt) { + + case UTP_SNDBUF: + assert(val >= 1); + conn->opt_sndbuf = val; + return 0; + + case UTP_RCVBUF: + assert(val >= 1); + conn->opt_rcvbuf = val; + return 0; + + case UTP_TARGET_DELAY: + conn->target_delay = val; + return 0; + } + + return -1; +} + +int utp_getsockopt(UTPSocket* conn, int opt) +{ + assert(conn); + if (!conn) return -1; + + switch (opt) { + case UTP_SNDBUF: return conn->opt_sndbuf; + case UTP_RCVBUF: return conn->opt_rcvbuf; + case UTP_TARGET_DELAY: return conn->target_delay; + } + + return -1; +} + +// Try to connect to a specified host. +int utp_connect(utp_socket *conn, const struct sockaddr *to, socklen_t tolen) +{ + assert(conn); + if (!conn) return -1; + + assert(conn->state == CS_UNINITIALIZED); + if (conn->state != CS_UNINITIALIZED) { + conn->state = CS_DESTROY; + return -1; + } + + utp_initialize_socket(conn, to, tolen, true, 0, 0, 1); + + assert(conn->cur_window_packets == 0); + assert(conn->outbuf.get(conn->seq_nr) == NULL); + assert(sizeof(PacketFormatV1) == 20); + + conn->state = CS_SYN_SENT; + conn->ctx->current_ms = utp_call_get_milliseconds(conn->ctx, conn); + + // Create and send a connect message + + // used in parse_log.py + conn->log(UTP_LOG_NORMAL, "UTP_Connect conn_seed:%u packet_size:%u (B) " + "target_delay:%u (ms) delay_history:%u " + "delay_base_history:%u (minutes)", + conn->conn_seed, PACKET_SIZE, conn->target_delay / 1000, + CUR_DELAY_SIZE, DELAY_BASE_HISTORY); + + // Setup initial timeout timer. + conn->retransmit_timeout = 3000; + conn->rto_timeout = conn->ctx->current_ms + conn->retransmit_timeout; + conn->last_rcv_win = conn->get_rcv_window(); + + // if you need compatibiltiy with 1.8.1, use this. it increases attackability though. + //conn->seq_nr = 1; + conn->seq_nr = utp_call_get_random(conn->ctx, conn); + + // Create the connect packet. + const size_t header_size = sizeof(PacketFormatV1); + + OutgoingPacket *pkt = (OutgoingPacket*)malloc(sizeof(OutgoingPacket) - 1 + header_size); + PacketFormatV1* p1 = (PacketFormatV1*)pkt->data; + + memset(p1, 0, header_size); + // SYN packets are special, and have the receive ID in the connid field, + // instead of conn_id_send. + p1->set_version(1); + p1->set_type(ST_SYN); + p1->ext = 0; + p1->connid = conn->conn_id_recv; + p1->windowsize = (uint32)conn->last_rcv_win; + p1->seq_nr = conn->seq_nr; + pkt->transmissions = 0; + pkt->length = header_size; + pkt->payload = 0; + + /* + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "Sending connect %s [%u].", + addrfmt(conn->addr, addrbuf), conn_seed); + #endif + */ + + // Remember the message in the outgoing queue. + conn->outbuf.ensure_size(conn->seq_nr, conn->cur_window_packets); + conn->outbuf.put(conn->seq_nr, pkt); + conn->seq_nr++; + conn->cur_window_packets++; + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "incrementing cur_window_packets:%u", conn->cur_window_packets); + #endif + + conn->send_packet(pkt); + return 0; +} + +// Returns 1 if the UDP payload was recognized as a UTP packet, or 0 if it was not +int utp_process_udp(utp_context *ctx, const byte *buffer, size_t len, const struct sockaddr *to, socklen_t tolen) +{ + assert(ctx); + if (!ctx) return 0; + + assert(buffer); + if (!buffer) return 0; + + assert(to); + if (!to) return 0; + + const PackedSockAddr addr((const SOCKADDR_STORAGE*)to, tolen); + + if (len < sizeof(PacketFormatV1)) { + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "recv %s len:%u too small", addrfmt(addr, addrbuf), (uint)len); + #endif + return 0; + } + + const PacketFormatV1 *pf1 = (PacketFormatV1*)buffer; + const byte version = UTP_Version(pf1); + const uint32 id = uint32(pf1->connid); + + if (version != 1) { + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "recv %s len:%u version:%u unsupported version", addrfmt(addr, addrbuf), (uint)len, version); + #endif + + return 0; + } + + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "recv %s len:%u id:%u", addrfmt(addr, addrbuf), (uint)len, id); + ctx->log(UTP_LOG_DEBUG, NULL, "recv id:%u seq_nr:%u ack_nr:%u", id, (uint)pf1->seq_nr, (uint)pf1->ack_nr); + #endif + + const byte flags = pf1->type(); + + if (flags == ST_RESET) { + // id is either our recv id or our send id + // if it's our send id, and we initiated the connection, our recv id is id + 1 + // if it's our send id, and we did not initiate the connection, our recv id is id - 1 + // we have to check every case + + UTPSocketKeyData* keyData; + if ( (keyData = ctx->utp_sockets->Lookup(UTPSocketKey(addr, id))) || + ((keyData = ctx->utp_sockets->Lookup(UTPSocketKey(addr, id + 1))) && keyData->socket->conn_id_send == id) || + ((keyData = ctx->utp_sockets->Lookup(UTPSocketKey(addr, id - 1))) && keyData->socket->conn_id_send == id)) + { + UTPSocket* conn = keyData->socket; + + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "recv RST for existing connection"); + #endif + + if (conn->state == CS_FIN_SENT) + conn->state = CS_DESTROY; + else + conn->state = CS_RESET; + + utp_call_on_overhead_statistics(conn->ctx, conn, false, len + conn->get_udp_overhead(), close_overhead); + const int err = (conn->state == CS_SYN_SENT) ? UTP_ECONNREFUSED : UTP_ECONNRESET; + utp_call_on_error(conn->ctx, conn, err); + } + else { + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "recv RST for unknown connection"); + #endif + } + return 1; + } + else if (flags != ST_SYN) { + UTPSocket* conn = NULL; + + if (ctx->last_utp_socket && ctx->last_utp_socket->addr == addr && ctx->last_utp_socket->conn_id_recv == id) { + conn = ctx->last_utp_socket; + } else { + UTPSocketKeyData* keyData = ctx->utp_sockets->Lookup(UTPSocketKey(addr, id)); + if (keyData) { + conn = keyData->socket; + ctx->last_utp_socket = conn; + } + } + + if (conn) { + + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "recv processing"); + #endif + + const size_t read = utp_process_incoming(conn, buffer, len); + utp_call_on_overhead_statistics(conn->ctx, conn, false, (len - read) + conn->get_udp_overhead(), header_overhead); + return 1; + } + } + + // We have not found a matching utp_socket, and this isn't a SYN. Reject it. + const uint32 seq_nr = pf1->seq_nr; + if (flags != ST_SYN) { + ctx->current_ms = utp_call_get_milliseconds(ctx, NULL); + + for (size_t i = 0; i < ctx->rst_info.GetCount(); i++) { + if ((ctx->rst_info[i].connid == id) && + (ctx->rst_info[i].addr == addr) && + (ctx->rst_info[i].ack_nr == seq_nr)) + { + ctx->rst_info[i].timestamp = ctx->current_ms; + + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "recv not sending RST to non-SYN (stored)"); + #endif + + return 1; + } + } + + if (ctx->rst_info.GetCount() > RST_INFO_LIMIT) { + + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "recv not sending RST to non-SYN (limit at %u stored)", (uint)ctx->rst_info.GetCount()); + #endif + + return 1; + } + + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "recv send RST to non-SYN (%u stored)", (uint)ctx->rst_info.GetCount()); + #endif + + RST_Info &r = ctx->rst_info.Append(); + r.addr = addr; + r.connid = id; + r.ack_nr = seq_nr; + r.timestamp = ctx->current_ms; + + UTPSocket::send_rst(ctx, addr, id, seq_nr, utp_call_get_random(ctx, NULL)); + return 1; + } + + if (ctx->callbacks[UTP_ON_ACCEPT]) { + + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "Incoming connection from %s", addrfmt(addr, addrbuf)); + #endif + + UTPSocketKeyData* keyData = ctx->utp_sockets->Lookup(UTPSocketKey(addr, id + 1)); + if (keyData) { + + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "rejected incoming connection, connection already exists"); + #endif + + return 1; + } + + if (ctx->utp_sockets->GetCount() > 3000) { + + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "rejected incoming connection, too many uTP sockets %d", ctx->utp_sockets->GetCount()); + #endif + + return 1; + } + // true means yes, block connection. false means no, don't block. + if (utp_call_on_firewall(ctx, to, tolen)) { + + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "rejected incoming connection, firewall callback returned true"); + #endif + + return 1; + } + + // Create a new UTP socket to handle this new connection + UTPSocket *conn = utp_create_socket(ctx); + utp_initialize_socket(conn, to, tolen, false, id, id+1, id); + conn->ack_nr = seq_nr; + conn->seq_nr = utp_call_get_random(ctx, NULL); + conn->fast_resend_seq_nr = conn->seq_nr; + conn->state = CS_SYN_RECV; + + const size_t read = utp_process_incoming(conn, buffer, len, true); + + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "recv send connect ACK"); + #endif + + conn->send_ack(true); + + utp_call_on_accept(ctx, conn, to, tolen); + + // we report overhead after on_accept(), because the callbacks are setup now + utp_call_on_overhead_statistics(conn->ctx, conn, false, (len - read) + conn->get_udp_overhead(), header_overhead); // SYN + utp_call_on_overhead_statistics(conn->ctx, conn, true, conn->get_overhead(), ack_overhead); // SYNACK + } + else { + + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "rejected incoming connection, UTP_ON_ACCEPT callback not set"); + #endif + + } + + return 1; +} + +// Called by utp_process_icmp_fragmentation() and utp_process_icmp_error() below +static UTPSocket* parse_icmp_payload(utp_context *ctx, const byte *buffer, size_t len, const struct sockaddr *to, socklen_t tolen) +{ + assert(ctx); + if (!ctx) return NULL; + + assert(buffer); + if (!buffer) return NULL; + + assert(to); + if (!to) return NULL; + + const PackedSockAddr addr((const SOCKADDR_STORAGE*)to, tolen); + + // ICMP packets are only required to quote the first 8 bytes of the layer4 + // payload. The UDP payload is 8 bytes, and the UTP header is another 20 + // bytes. So, in order to find the entire UTP header, we need the ICMP + // packet to quote 28 bytes. + if (len < sizeof(PacketFormatV1)) { + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "Ignoring ICMP from %s: runt length %d", addrfmt(addr, addrbuf), len); + #endif + return NULL; + } + + const PacketFormatV1 *pf = (PacketFormatV1*)buffer; + const byte version = UTP_Version(pf); + const uint32 id = uint32(pf->connid); + + if (version != 1) { + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "Ignoring ICMP from %s: not UTP version 1", addrfmt(addr, addrbuf)); + #endif + return NULL; + } + + UTPSocketKeyData* keyData; + + if ( (keyData = ctx->utp_sockets->Lookup(UTPSocketKey(addr, id))) || + ((keyData = ctx->utp_sockets->Lookup(UTPSocketKey(addr, id + 1))) && keyData->socket->conn_id_send == id) || + ((keyData = ctx->utp_sockets->Lookup(UTPSocketKey(addr, id - 1))) && keyData->socket->conn_id_send == id)) + { + return keyData->socket; + } + + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "Ignoring ICMP from %s: No matching connection found for id %u", addrfmt(addr, addrbuf), id); + #endif + return NULL; +} + +// Should be called when an ICMP Type 3, Code 4 packet (fragmentation needed) is received, to adjust the MTU +// +// Returns 1 if the UDP payload (delivered in the ICMP packet) was recognized as a UTP packet, or 0 if it was not +// +// @ctx: utp_context +// @buf: Contents of the original UDP payload, which the ICMP packet quoted. *Not* the ICMP packet itself. +// @len: buffer length +// @to: destination address of the original UDP pakcet +// @tolen: address length +// @next_hop_mtu: +int utp_process_icmp_fragmentation(utp_context *ctx, const byte* buffer, size_t len, const struct sockaddr *to, socklen_t tolen, uint16 next_hop_mtu) +{ + UTPSocket* conn = parse_icmp_payload(ctx, buffer, len, to, tolen); + if (!conn) return 0; + + // Constrain the next_hop_mtu to sane values. It might not be initialized or sent properly + if (next_hop_mtu >= 576 && next_hop_mtu < 0x2000) { + conn->mtu_ceiling = min(next_hop_mtu, conn->mtu_ceiling); + conn->mtu_search_update(); + // this is something of a speecial case, where we don't set mtu_last + // to the value in between the floor and the ceiling. We can update the + // floor, because there might be more network segments after the one + // that sent this ICMP with smaller MTUs. But we want to test this + // MTU size first. If the next probe gets through, mtu_floor is updated + conn->mtu_last = conn->mtu_ceiling; + } else { + // Otherwise, binary search. At this point we don't actually know + // what size the packet that failed was, and apparently we can't + // trust the next hop mtu either. It seems reasonably conservative + // to just lower the ceiling. This should not happen on working networks + // anyway. + conn->mtu_ceiling = (conn->mtu_floor + conn->mtu_ceiling) / 2; + conn->mtu_search_update(); + } + + conn->log(UTP_LOG_MTU, "MTU [ICMP] floor:%d ceiling:%d current:%d", conn->mtu_floor, conn->mtu_ceiling, conn->mtu_last); + return 1; +} + +// Should be called when an ICMP message is received that should tear down the connection. +// +// Returns 1 if the UDP payload (delivered in the ICMP packet) was recognized as a UTP packet, or 0 if it was not +// +// @ctx: utp_context +// @buf: Contents of the original UDP payload, which the ICMP packet quoted. *Not* the ICMP packet itself. +// @len: buffer length +// @to: destination address of the original UDP pakcet +// @tolen: address length +int utp_process_icmp_error(utp_context *ctx, const byte *buffer, size_t len, const struct sockaddr *to, socklen_t tolen) +{ + UTPSocket* conn = parse_icmp_payload(ctx, buffer, len, to, tolen); + if (!conn) return 0; + + const int err = (conn->state == CS_SYN_SENT) ? UTP_ECONNREFUSED : UTP_ECONNRESET; + const PackedSockAddr addr((const SOCKADDR_STORAGE*)to, tolen); + + switch(conn->state) { + // Don't pass on errors for idle/closed connections + case CS_IDLE: + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "ICMP from %s in state CS_IDLE, ignoring", addrfmt(addr, addrbuf)); + #endif + return 1; + + case CS_FIN_SENT: + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "ICMP from %s in state CS_FIN_SENT, setting state to CS_DESTROY and causing error %d", addrfmt(addr, addrbuf), err); + #endif + conn->state = CS_DESTROY; + break; + + default: + #if UTP_DEBUG_LOGGING + ctx->log(UTP_LOG_DEBUG, NULL, "ICMP from %s, setting state to CS_RESET and causing error %d", addrfmt(addr, addrbuf), err); + #endif + conn->state = CS_RESET; + break; + } + + utp_call_on_error(conn->ctx, conn, err); + return 1; +} + +// Write bytes to the UTP socket. Returns the number of bytes written. +// 0 indicates the socket is no longer writable, -1 indicates an error +ssize_t utp_writev(utp_socket *conn, struct utp_iovec *iovec_input, size_t num_iovecs) +{ + static utp_iovec iovec[UTP_IOV_MAX]; + + assert(conn); + if (!conn) return -1; + + assert(iovec_input); + if (!iovec_input) return -1; + + assert(num_iovecs); + if (!num_iovecs) return -1; + + if (num_iovecs > UTP_IOV_MAX) + num_iovecs = UTP_IOV_MAX; + + memcpy(iovec, iovec_input, sizeof(struct utp_iovec)*num_iovecs); + + size_t bytes = 0; + size_t sent = 0; + for (size_t i = 0; i < num_iovecs; i++) + bytes += iovec[i].iov_len; + + #if UTP_DEBUG_LOGGING + size_t param = bytes; + #endif + + if (conn->state != CS_CONNECTED) { + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "UTP_Write %u bytes = false (not CS_CONNECTED)", (uint)bytes); + #endif + return 0; + } + + conn->ctx->current_ms = utp_call_get_milliseconds(conn->ctx, conn); + + // don't send unless it will all fit in the window + size_t packet_size = conn->get_packet_size(); + size_t num_to_send = min(bytes, packet_size); + while (!conn->is_full(num_to_send)) { + // Send an outgoing packet. + // Also add it to the outgoing of packets that have been sent but not ACKed. + + bytes -= num_to_send; + sent += num_to_send; + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "Sending packet. seq_nr:%u ack_nr:%u wnd:%u/%u/%u rcv_win:%u size:%u cur_window_packets:%u", + conn->seq_nr, conn->ack_nr, + (uint)(conn->cur_window + num_to_send), + (uint)conn->max_window, (uint)conn->max_window_user, + (uint)conn->last_rcv_win, num_to_send, + conn->cur_window_packets); + #endif + conn->write_outgoing_packet(num_to_send, ST_DATA, iovec, num_iovecs); + num_to_send = min(bytes, packet_size); + + if (num_to_send == 0) { + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "UTP_Write %u bytes = true", (uint)param); + #endif + return sent; + } + } + + bool full = conn->is_full(); + if (full) { + // mark the socket as not being writable. + conn->state = CS_CONNECTED_FULL; + } + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "UTP_Write %u bytes = %s", (uint)bytes, full ? "false" : "true"); + #endif + + // returns whether or not the socket is still writable + // if the congestion window is not full, we can still write to it + //return !full; + return sent; +} + +void utp_read_drained(utp_socket *conn) +{ + assert(conn); + if (!conn) return; + + assert(conn->state != CS_UNINITIALIZED); + if (conn->state == CS_UNINITIALIZED) return; + + const size_t rcvwin = conn->get_rcv_window(); + + if (rcvwin > conn->last_rcv_win) { + // If last window was 0 send ACK immediately, otherwise should set timer + if (conn->last_rcv_win == 0) { + conn->send_ack(); + } else { + conn->ctx->current_ms = utp_call_get_milliseconds(conn->ctx, conn); + conn->schedule_ack(); + } + } +} + +// Should be called each time the UDP socket is drained +void utp_issue_deferred_acks(utp_context *ctx) +{ + assert(ctx); + if (!ctx) return; + + for (size_t i = 0; i < ctx->ack_sockets.GetCount(); i++) { + UTPSocket *conn = ctx->ack_sockets[i]; + conn->send_ack(); + i--; + } +} + +// Should be called every 500ms +void utp_check_timeouts(utp_context *ctx) +{ + assert(ctx); + if (!ctx) return; + + ctx->current_ms = utp_call_get_milliseconds(ctx, NULL); + + if (ctx->current_ms - ctx->last_check < TIMEOUT_CHECK_INTERVAL) + return; + + ctx->last_check = ctx->current_ms; + + for (size_t i = 0; i < ctx->rst_info.GetCount(); i++) { + if ((int)(ctx->current_ms - ctx->rst_info[i].timestamp) >= RST_INFO_TIMEOUT) { + ctx->rst_info.MoveUpLast(i); + i--; + } + } + if (ctx->rst_info.GetCount() != ctx->rst_info.GetAlloc()) { + ctx->rst_info.Compact(); + } + + utp_hash_iterator_t it; + UTPSocketKeyData* keyData; + while ((keyData = ctx->utp_sockets->Iterate(it))) { + UTPSocket *conn = keyData->socket; + conn->check_timeouts(); + + // Check if the object was deleted + if (conn->state == CS_DESTROY) { + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "Destroying"); + #endif + delete conn; + } + } +} + +int utp_getpeername(utp_socket *conn, struct sockaddr *addr, socklen_t *addrlen) +{ + assert(addr); + if (!addr) return -1; + + assert(addrlen); + if (!addrlen) return -1; + + assert(conn); + if (!conn) return -1; + + assert(conn->state != CS_UNINITIALIZED); + if (conn->state == CS_UNINITIALIZED) return -1; + + socklen_t len; + const SOCKADDR_STORAGE sa = conn->addr.get_sockaddr_storage(&len); + *addrlen = min(len, *addrlen); + memcpy(addr, &sa, *addrlen); + return 0; +} + +int utp_get_delays(UTPSocket *conn, uint32 *ours, uint32 *theirs, uint32 *age) +{ + assert(conn); + if (!conn) return -1; + + assert(conn->state != CS_UNINITIALIZED); + if (conn->state == CS_UNINITIALIZED) { + if (ours) *ours = 0; + if (theirs) *theirs = 0; + if (age) *age = 0; + return -1; + } + + if (ours) *ours = conn->our_hist.get_value(); + if (theirs) *theirs = conn->their_hist.get_value(); + if (age) *age = (uint32)(conn->ctx->current_ms - conn->last_measured_delay); + return 0; +} + +// Close the UTP socket. +// It is not valid for the upper layer to refer to socket after it is closed. +// Data will keep to try being delivered after the close. +void utp_close(UTPSocket *conn) +{ + assert(conn); + if (!conn) return; + + assert(conn->state != CS_UNINITIALIZED + && conn->state != CS_DESTROY_DELAY + && conn->state != CS_FIN_SENT + && conn->state != CS_DESTROY); + + #if UTP_DEBUG_LOGGING + conn->log(UTP_LOG_DEBUG, "UTP_Close in state:%s", statenames[conn->state]); + #endif + + switch(conn->state) { + case CS_CONNECTED: + case CS_CONNECTED_FULL: + conn->state = CS_FIN_SENT; + conn->write_outgoing_packet(0, ST_FIN, NULL, 0); + break; + + case CS_SYN_SENT: + conn->rto_timeout = utp_call_get_milliseconds(conn->ctx, conn) + min(conn->rto * 2, 60); + // fall through + case CS_GOT_FIN: + conn->state = CS_DESTROY_DELAY; + break; + case CS_SYN_RECV: + // fall through + default: + conn->state = CS_DESTROY; + break; + } +} + +utp_context* utp_get_context(utp_socket *socket) { + assert(socket); + return socket ? socket->ctx : NULL; +} + +void* utp_set_userdata(utp_socket *socket, void *userdata) { + assert(socket); + if (socket) socket->userdata = userdata; + return socket ? socket->userdata : NULL; +} + +void* utp_get_userdata(utp_socket *socket) { + assert(socket); + return socket ? socket->userdata : NULL; +} + +void struct_utp_context::log(int level, utp_socket *socket, char const *fmt, ...) +{ + if (!would_log(level)) { + return; + } + + va_list va; + va_start(va, fmt); + log_unchecked(socket, fmt, va); + va_end(va); +} + +void struct_utp_context::log_unchecked(utp_socket *socket, char const *fmt, ...) +{ + va_list va; + char buf[4096]; + + va_start(va, fmt); + vsnprintf(buf, 4096, fmt, va); + buf[4095] = '\0'; + va_end(va); + + utp_call_log(this, socket, (const byte *)buf); +} + +inline bool struct_utp_context::would_log(int level) +{ + if (level == UTP_LOG_NORMAL) return log_normal; + if (level == UTP_LOG_MTU) return log_mtu; + if (level == UTP_LOG_DEBUG) return log_debug; + return true; +} + +utp_socket_stats* utp_get_stats(utp_socket *socket) +{ + #ifdef _DEBUG + assert(socket); + if (!socket) return NULL; + socket->_stats.mtu_guess = socket->mtu_last ? socket->mtu_last : socket->mtu_ceiling; + return &socket->_stats; + #else + return NULL; + #endif +} diff --git a/vendor/github.com/anacrolix/go-libutp/utp_internal.h b/vendor/github.com/anacrolix/go-libutp/utp_internal.h new file mode 100644 index 000000000..641814630 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/utp_internal.h @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2010-2013 BitTorrent, Inc. + * + * 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. + */ + +#ifndef __UTP_INTERNAL_H__ +#define __UTP_INTERNAL_H__ + +#include +#include +#include +#include + +#include "utp.h" +#include "utp_callbacks.h" +#include "utp_templates.h" +#include "utp_hash.h" +#include "utp_hash.h" +#include "utp_packedsockaddr.h" + +/* These originally lived in utp_config.h */ +#define CCONTROL_TARGET (100 * 1000) // us + +enum bandwidth_type_t { + payload_bandwidth, connect_overhead, + close_overhead, ack_overhead, + header_overhead, retransmit_overhead +}; + +#ifdef WIN32 + #ifdef _MSC_VER + #include "libutp_inet_ntop.h" + #endif + + // newer versions of MSVC define these in errno.h + #ifndef ECONNRESET + #define ECONNRESET WSAECONNRESET + #define EMSGSIZE WSAEMSGSIZE + #define ECONNREFUSED WSAECONNREFUSED + #define ETIMEDOUT WSAETIMEDOUT + #endif +#endif + +struct PACKED_ATTRIBUTE RST_Info { + PackedSockAddr addr; + uint32 connid; + uint16 ack_nr; + uint64 timestamp; +}; + +// It's really important that we don't have duplicate keys in the hash table. +// If we do, we'll eventually crash. if we try to remove the second instance +// of the key, we'll accidentally remove the first instead. then later, +// checkTimeouts will try to access the second one's already freed memory. +void UTP_FreeAll(struct UTPSocketHT *utp_sockets); + +struct UTPSocketKey { + PackedSockAddr addr; + uint32 recv_id; // "conn_seed", "conn_id" + + UTPSocketKey(const PackedSockAddr& _addr, uint32 _recv_id) { + memset(this, 0, sizeof(*this)); + addr = _addr; + recv_id = _recv_id; + } + + bool operator == (const UTPSocketKey &other) const { + return recv_id == other.recv_id && addr == other.addr; + } + + uint32 compute_hash() const { + return recv_id ^ addr.compute_hash(); + } +}; + +struct UTPSocketKeyData { + UTPSocketKey key; + UTPSocket *socket; + utp_link_t link; +}; + +#define UTP_SOCKET_BUCKETS 79 +#define UTP_SOCKET_INIT 15 + +struct UTPSocketHT : utpHashTable { + UTPSocketHT() { + const int buckets = UTP_SOCKET_BUCKETS; + const int initial = UTP_SOCKET_INIT; + this->Create(buckets, initial); + } + ~UTPSocketHT() { + UTP_FreeAll(this); + this->Free(); + } +}; + +struct struct_utp_context { + void *userdata; + utp_callback_t* callbacks[UTP_ARRAY_SIZE]; + + uint64 current_ms; + utp_context_stats context_stats; + UTPSocket *last_utp_socket; + Array ack_sockets; + Array rst_info; + UTPSocketHT *utp_sockets; + size_t target_delay; + size_t opt_sndbuf; + size_t opt_rcvbuf; + uint64 last_check; + + struct_utp_context(); + ~struct_utp_context(); + + void log(int level, utp_socket *socket, char const *fmt, ...); + void log_unchecked(utp_socket *socket, char const *fmt, ...); + bool would_log(int level); + + bool log_normal:1; // log normal events? + bool log_mtu:1; // log MTU related events? + bool log_debug:1; // log debugging events? (Must also compile with UTP_DEBUG_LOGGING defined) +}; + +#endif //__UTP_INTERNAL_H__ diff --git a/vendor/github.com/anacrolix/go-libutp/utp_packedsockaddr.cpp b/vendor/github.com/anacrolix/go-libutp/utp_packedsockaddr.cpp new file mode 100644 index 000000000..ab65ae56c --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/utp_packedsockaddr.cpp @@ -0,0 +1,139 @@ +// vim:set ts=4 sw=4 ai: + +/* + * Copyright (c) 2010-2013 BitTorrent, Inc. + * + * 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. + */ + +#include +#include +#include + +#include "utp_types.h" +#include "utp_hash.h" +#include "utp_packedsockaddr.h" + +#include "libutp_inet_ntop.h" + +byte PackedSockAddr::get_family() const +{ + #if defined(__sh__) + return ((_sin6d[0] == 0) && (_sin6d[1] == 0) && (_sin6d[2] == htonl(0xffff)) != 0) ? + AF_INET : AF_INET6; + #else + return (IN6_IS_ADDR_V4MAPPED(&_in._in6addr) != 0) ? AF_INET : AF_INET6; + #endif // defined(__sh__) +} + +bool PackedSockAddr::operator==(const PackedSockAddr& rhs) const +{ + if (&rhs == this) + return true; + if (_port != rhs._port) + return false; + return memcmp(_sin6, rhs._sin6, sizeof(_sin6)) == 0; +} + +bool PackedSockAddr::operator!=(const PackedSockAddr& rhs) const +{ + return !(*this == rhs); +} + +uint32 PackedSockAddr::compute_hash() const { + return utp_hash_mem(&_in, sizeof(_in)) ^ _port; +} + +void PackedSockAddr::set(const SOCKADDR_STORAGE* sa, socklen_t len) +{ + if (sa->ss_family == AF_INET) { + assert(len >= sizeof(sockaddr_in)); + const sockaddr_in *sin = (sockaddr_in*)sa; + _sin6w[0] = 0; + _sin6w[1] = 0; + _sin6w[2] = 0; + _sin6w[3] = 0; + _sin6w[4] = 0; + _sin6w[5] = 0xffff; + _sin4 = sin->sin_addr.s_addr; + _port = ntohs(sin->sin_port); + } else { + assert(len >= sizeof(sockaddr_in6)); + const sockaddr_in6 *sin6 = (sockaddr_in6*)sa; + _in._in6addr = sin6->sin6_addr; + _port = ntohs(sin6->sin6_port); + } +} + +PackedSockAddr::PackedSockAddr(const SOCKADDR_STORAGE* sa, socklen_t len) +{ + set(sa, len); +} + +PackedSockAddr::PackedSockAddr(void) +{ + SOCKADDR_STORAGE sa; + socklen_t len = sizeof(SOCKADDR_STORAGE); + memset(&sa, 0, len); + sa.ss_family = AF_INET; + set(&sa, len); +} + +SOCKADDR_STORAGE PackedSockAddr::get_sockaddr_storage(socklen_t *len = NULL) const +{ + SOCKADDR_STORAGE sa; + const byte family = get_family(); + if (family == AF_INET) { + sockaddr_in *sin = (sockaddr_in*)&sa; + if (len) *len = sizeof(sockaddr_in); + memset(sin, 0, sizeof(sockaddr_in)); + sin->sin_family = family; + sin->sin_port = htons(_port); + sin->sin_addr.s_addr = _sin4; + } else { + sockaddr_in6 *sin6 = (sockaddr_in6*)&sa; + memset(sin6, 0, sizeof(sockaddr_in6)); + if (len) *len = sizeof(sockaddr_in6); + sin6->sin6_family = family; + sin6->sin6_addr = _in._in6addr; + sin6->sin6_port = htons(_port); + } + return sa; +} + +// #define addrfmt(x, s) x.fmt(s, sizeof(s)) +cstr PackedSockAddr::fmt(str s, size_t len) const +{ + memset(s, 0, len); + const byte family = get_family(); + str i; + if (family == AF_INET) { + INET_NTOP(family, (uint32*)&_sin4, s, len); + i = s; + while (*++i) {} + } else { + i = s; + *i++ = '['; + INET_NTOP(family, (in6_addr*)&_in._in6addr, i, len-1); + while (*++i) {} + *i++ = ']'; + } + snprintf(i, len - (i-s), ":%u", _port); + return s; +} diff --git a/vendor/github.com/anacrolix/go-libutp/utp_packedsockaddr.h b/vendor/github.com/anacrolix/go-libutp/utp_packedsockaddr.h new file mode 100644 index 000000000..76e8accaa --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/utp_packedsockaddr.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2010-2013 BitTorrent, Inc. + * + * 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. + */ + +#ifndef __UTP_PACKEDSOCKADDR_H__ +#define __UTP_PACKEDSOCKADDR_H__ + +#include "utp_types.h" + +struct PACKED_ATTRIBUTE PackedSockAddr { + // The values are always stored here in network byte order + union { + byte _in6[16]; // IPv6 + uint16 _in6w[8]; // IPv6, word based (for convenience) + uint32 _in6d[4]; // Dword access + in6_addr _in6addr; // For convenience + } _in; + + // Host byte order + uint16 _port; + + #define _sin4 _in._in6d[3] // IPv4 is stored where it goes if mapped + + #define _sin6 _in._in6 + #define _sin6w _in._in6w + #define _sin6d _in._in6d + + byte get_family() const; + bool operator==(const PackedSockAddr& rhs) const; + bool operator!=(const PackedSockAddr& rhs) const; + void set(const SOCKADDR_STORAGE* sa, socklen_t len); + + PackedSockAddr(const SOCKADDR_STORAGE* sa, socklen_t len); + PackedSockAddr(void); + + SOCKADDR_STORAGE get_sockaddr_storage(socklen_t *len) const; + cstr fmt(str s, size_t len) const; + + uint32 compute_hash() const; +} ALIGNED_ATTRIBUTE(4); + +#endif //__UTP_PACKEDSOCKADDR_H__ diff --git a/vendor/github.com/anacrolix/go-libutp/utp_templates.h b/vendor/github.com/anacrolix/go-libutp/utp_templates.h new file mode 100644 index 000000000..8f88f5c7c --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/utp_templates.h @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2010-2013 BitTorrent, Inc. + * + * 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. + */ + +#ifndef __TEMPLATES_H__ +#define __TEMPLATES_H__ + +#include "utp_types.h" +#include + +#if defined(POSIX) +/* Allow over-writing FORCEINLINE from makefile because gcc 3.4.4 for buffalo + doesn't seem to support __attribute__((always_inline)) in -O0 build + (strangely, it works in -Os build) */ +#ifndef FORCEINLINE +// The always_inline attribute asks gcc to inline the function even if no optimization is being requested. +// This macro should be used exclusive-or with the inline directive (use one or the other but not both) +// since Microsoft uses __forceinline to also mean inline, +// and this code is following a Microsoft compatibility model. +// Just setting the attribute without also specifying the inline directive apparently won't inline the function, +// as evidenced by multiply-defined symbols found at link time. +#define FORCEINLINE inline __attribute__((always_inline)) +#endif +#endif + +// Utility templates +#undef min +#undef max + +template static inline T min(T a, T b) { if (a < b) return a; return b; } +template static inline T max(T a, T b) { if (a > b) return a; return b; } + +template static inline T min(T a, T b, T c) { return min(min(a,b),c); } +template static inline T max(T a, T b, T c) { return max(max(a,b),c); } +template static inline T clamp(T v, T mi, T ma) +{ + if (v > ma) v = ma; + if (v < mi) v = mi; + return v; +} + +#if (defined(__SVR4) && defined(__sun)) + #pragma pack(1) +#else + #pragma pack(push,1) +#endif + + +namespace aux +{ + FORCEINLINE uint16 host_to_network(uint16 i) { return htons(i); } + FORCEINLINE uint32 host_to_network(uint32 i) { return htonl(i); } + FORCEINLINE int32 host_to_network(int32 i) { return htonl(i); } + FORCEINLINE uint16 network_to_host(uint16 i) { return ntohs(i); } + FORCEINLINE uint32 network_to_host(uint32 i) { return ntohl(i); } + FORCEINLINE int32 network_to_host(int32 i) { return ntohl(i); } +} + +template +struct PACKED_ATTRIBUTE big_endian +{ + T operator=(T i) { m_integer = aux::host_to_network(i); return i; } + operator T() const { return aux::network_to_host(m_integer); } +private: + T m_integer; +}; + +typedef big_endian int32_big; +typedef big_endian uint32_big; +typedef big_endian uint16_big; + +#if (defined(__SVR4) && defined(__sun)) + #pragma pack(0) +#else + #pragma pack(pop) +#endif + +template static inline void zeromem(T *a, size_t count = 1) { memset(a, 0, count * sizeof(T)); } + +typedef int SortCompareProc(const void *, const void *); + +template static FORCEINLINE void QuickSortT(T *base, size_t num, int (*comp)(const T *, const T *)) { qsort(base, num, sizeof(T), (SortCompareProc*)comp); } + + +// WARNING: The template parameter MUST be a POD type! +template class Array { +protected: + T *mem; + size_t alloc,count; + +public: + Array(size_t init) { Init(init); } + Array() { Init(); } + ~Array() { Free(); } + + void inline Init() { mem = NULL; alloc = count = 0; } + void inline Init(size_t init) { Init(); if (init) Resize(init); } + size_t inline GetCount() const { return count; } + size_t inline GetAlloc() const { return alloc; } + void inline SetCount(size_t c) { count = c; } + + inline T& operator[](size_t offset) { assert(offset ==0 || offset(minsize, alloc * 2)); } + + inline size_t Append(const T &t) { + if (count >= alloc) Grow(); + size_t r=count++; + mem[r] = t; + return r; + } + + T inline &Append() { + if (count >= alloc) Grow(); + return mem[count++]; + } + + void inline Compact() { + Resize(count); + } + + void inline Free() { + free(mem); + Init(); + } + + void inline Clear() { + count = 0; + } + + bool inline MoveUpLast(size_t index) { + assert(index < count); + size_t c = --count; + if (index != c) { + mem[index] = mem[c]; + return true; + } + return false; + } + + bool inline MoveUpLastExist(const T &v) { + return MoveUpLast(LookupElementExist(v)); + } + + size_t inline LookupElement(const T &v) const { + for(size_t i = 0; i != count; i++) + if (mem[i] == v) + return i; + return (size_t) -1; + } + + bool inline HasElement(const T &v) const { + return LookupElement(v) != -1; + } + + typedef int SortCompareProc(const T *a, const T *b); + + void Sort(SortCompareProc* proc, size_t start, size_t end) { + QuickSortT(&mem[start], end - start, proc); + } + + void Sort(SortCompareProc* proc, size_t start) { + Sort(proc, start, count); + } + + void Sort(SortCompareProc* proc) { + Sort(proc, 0, count); + } +}; + +#endif //__TEMPLATES_H__ diff --git a/vendor/github.com/anacrolix/go-libutp/utp_types.h b/vendor/github.com/anacrolix/go-libutp/utp_types.h new file mode 100644 index 000000000..5a199cef2 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/utp_types.h @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2010-2013 BitTorrent, Inc. + * + * 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. + */ + +#ifndef __UTP_TYPES_H__ +#define __UTP_TYPES_H__ + +// Allow libutp consumers or prerequisites to override PACKED_ATTRIBUTE +#ifndef PACKED_ATTRIBUTE +#if defined BROKEN_GCC_STRUCTURE_PACKING && defined __GNUC__ + // Used for gcc tool chains accepting but not supporting pragma pack + // See http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html + #define PACKED_ATTRIBUTE __attribute__((__packed__)) +#else + #define PACKED_ATTRIBUTE +#endif // defined BROKEN_GCC_STRUCTURE_PACKING && defined __GNUC__ +#endif // ndef PACKED_ATTRIBUTE + +#ifdef __GNUC__ + #define ALIGNED_ATTRIBUTE(x) __attribute__((aligned (x))) +#else + #define ALIGNED_ATTRIBUTE(x) +#endif + +// hash.cpp needs socket definitions, which is why this networking specific +// code is inclued in utypes.h +#ifdef WIN32 + #define _CRT_SECURE_NO_DEPRECATE + #define WIN32_LEAN_AND_MEAN + #include + #include + #include + #define IP_OPT_DONTFRAG IP_DONTFRAGMENT +#else + #include + #include + #include + #include + + #ifdef IP_DONTFRAG + #define IP_OPT_DONTFRAG IP_DONTFRAG + #elif defined IP_DONTFRAGMENT + #define IP_OPT_DONTFRAG IP_DONTFRAGMENT + #else + //#warning "I don't know how to set DF bit on this system" + #endif +#endif + +#ifdef _MSC_VER + #include + typedef SSIZE_T ssize_t; +#endif + +#ifdef POSIX + typedef struct sockaddr_storage SOCKADDR_STORAGE; +#endif + +#ifdef WIN32 + #define I64u "%I64u" +#else + #define I64u "%Lu" +#endif + +// standard types +typedef unsigned char byte; +typedef unsigned char uint8; +typedef signed char int8; +typedef unsigned short uint16; +typedef signed short int16; +typedef unsigned int uint; +typedef unsigned int uint32; +typedef signed int int32; + +#ifdef _MSC_VER +typedef unsigned __int64 uint64; +typedef signed __int64 int64; +#else +typedef unsigned long long uint64; +typedef long long int64; +#endif + +/* compile-time assert */ +#ifndef CASSERT +#define CASSERT( exp, name ) typedef int is_not_##name [ (exp ) ? 1 : -1 ]; +#endif + +CASSERT(8 == sizeof(uint64), sizeof_uint64_is_8) +CASSERT(8 == sizeof(int64), sizeof_int64_is_8) + +#ifndef INT64_MAX +#define INT64_MAX 0x7fffffffffffffffLL +#endif + +// always ANSI +typedef const char * cstr; +typedef char * str; + +#ifndef __cplusplus +typedef uint8 bool; +#endif + +#endif //__UTP_TYPES_H__ diff --git a/vendor/github.com/anacrolix/go-libutp/utp_utils.cpp b/vendor/github.com/anacrolix/go-libutp/utp_utils.cpp new file mode 100644 index 000000000..f2c57abe4 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/utp_utils.cpp @@ -0,0 +1,254 @@ +/* + * Copyright (c) 2010-2013 BitTorrent, Inc. + * + * 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. + */ + +#include +#include +#include "utp.h" +#include "utp_types.h" + +#ifdef WIN32 + #define WIN32_LEAN_AND_MEAN + #include + #include + #include +#else //!WIN32 + #include + #include // Linux needs both time.h and sys/time.h +#endif + +#if defined(__APPLE__) + #include +#endif + +#include "utp_utils.h" + +#ifdef WIN32 + +typedef ULONGLONG (WINAPI GetTickCount64Proc)(void); +static GetTickCount64Proc *pt2GetTickCount64; +static GetTickCount64Proc *pt2RealGetTickCount; + +static uint64 startPerformanceCounter; +static uint64 startGetTickCount; +// MSVC 6 standard doesn't like division with uint64s +static double counterPerMicrosecond; + +static uint64 UTGetTickCount64() +{ + if (pt2GetTickCount64) { + return pt2GetTickCount64(); + } + if (pt2RealGetTickCount) { + uint64 v = pt2RealGetTickCount(); + // fix return value from GetTickCount + return (DWORD)v | ((v >> 0x18) & 0xFFFFFFFF00000000); + } + return (uint64)GetTickCount(); +} + +static void Time_Initialize() +{ + HMODULE kernel32 = GetModuleHandleA("kernel32.dll"); + pt2GetTickCount64 = (GetTickCount64Proc*)GetProcAddress(kernel32, "GetTickCount64"); + // not a typo. GetTickCount actually returns 64 bits + pt2RealGetTickCount = (GetTickCount64Proc*)GetProcAddress(kernel32, "GetTickCount"); + + uint64 frequency; + QueryPerformanceCounter((LARGE_INTEGER*)&startPerformanceCounter); + QueryPerformanceFrequency((LARGE_INTEGER*)&frequency); + counterPerMicrosecond = (double)frequency / 1000000.0f; + startGetTickCount = UTGetTickCount64(); +} + +static int64 abs64(int64 x) { return x < 0 ? -x : x; } + +static uint64 __GetMicroseconds() +{ + static bool time_init = false; + if (!time_init) { + time_init = true; + Time_Initialize(); + } + + uint64 counter; + uint64 tick; + + QueryPerformanceCounter((LARGE_INTEGER*) &counter); + tick = UTGetTickCount64(); + + // unfortunately, QueryPerformanceCounter is not guaranteed + // to be monotonic. Make it so. + int64 ret = (int64)(((int64)counter - (int64)startPerformanceCounter) / counterPerMicrosecond); + // if the QPC clock leaps more than one second off GetTickCount64() + // something is seriously fishy. Adjust QPC to stay monotonic + int64 tick_diff = tick - startGetTickCount; + if (abs64(ret / 100000 - tick_diff / 100) > 10) { + startPerformanceCounter -= (uint64)((int64)(tick_diff * 1000 - ret) * counterPerMicrosecond); + ret = (int64)((counter - startPerformanceCounter) / counterPerMicrosecond); + } + return ret; +} + +static inline uint64 UTP_GetMilliseconds() +{ + return GetTickCount(); +} + +#else //!WIN32 + +static inline uint64 UTP_GetMicroseconds(void); +static inline uint64 UTP_GetMilliseconds() +{ + return UTP_GetMicroseconds() / 1000; +} + +#if defined(__APPLE__) + +static uint64 __GetMicroseconds() +{ + // http://developer.apple.com/mac/library/qa/qa2004/qa1398.html + // http://www.macresearch.org/tutorial_performance_and_time + static mach_timebase_info_data_t sTimebaseInfo; + static uint64_t start_tick = 0; + uint64_t tick; + // Returns a counter in some fraction of a nanoseconds + tick = mach_absolute_time(); + if (sTimebaseInfo.denom == 0) { + // Get the timer ratio to convert mach_absolute_time to nanoseconds + mach_timebase_info(&sTimebaseInfo); + start_tick = tick; + } + // Calculate the elapsed time, convert it to microseconds and return it. + return ((tick - start_tick) * sTimebaseInfo.numer) / (sTimebaseInfo.denom * 1000); +} + +#else // !__APPLE__ + +#if ! (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(CLOCK_MONOTONIC)) + #warning "Using non-monotonic function gettimeofday() in UTP_GetMicroseconds()" +#endif + +/* Unfortunately, #ifdef CLOCK_MONOTONIC is not enough to make sure that + POSIX clocks work -- we could be running a recent libc with an ancient + kernel (think OpenWRT). -- jch */ + +static uint64_t __GetMicroseconds() +{ + struct timeval tv; + + #if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(CLOCK_MONOTONIC) + static int have_posix_clocks = -1; + int rc; + + if (have_posix_clocks < 0) { + struct timespec ts; + rc = clock_gettime(CLOCK_MONOTONIC, &ts); + if (rc < 0) { + have_posix_clocks = 0; + } else { + have_posix_clocks = 1; + } + } + + if (have_posix_clocks) { + struct timespec ts; + rc = clock_gettime(CLOCK_MONOTONIC, &ts); + return uint64(ts.tv_sec) * 1000000 + uint64(ts.tv_nsec) / 1000; + } + #endif + + gettimeofday(&tv, NULL); + return uint64(tv.tv_sec) * 1000000 + tv.tv_usec; +} + +#endif //!__APPLE__ + +#endif //!WIN32 + +/* + * Whew. Okay. After that #ifdef maze above, we now know we have a working + * __GetMicroseconds() implementation on all platforms. + * + * Because there are a number of assertions in libutp that will cause a crash + * if monotonic time isn't monotonic, now apply some safety checks. While in + * principle we're already protecting ourselves in cases where non-monotonic + * time is likely to happen, this protects all versions. + */ + +static inline uint64 UTP_GetMicroseconds() +{ + static uint64 offset = 0, previous = 0; + + uint64 now = __GetMicroseconds() + offset; + if (previous > now) { + /* Eek! */ + offset += previous - now; + now = previous; + } + previous = now; + return now; +} + +#define ETHERNET_MTU 1500 +#define IPV4_HEADER_SIZE 20 +#define IPV6_HEADER_SIZE 40 +#define UDP_HEADER_SIZE 8 +#define GRE_HEADER_SIZE 24 +#define PPPOE_HEADER_SIZE 8 +#define MPPE_HEADER_SIZE 2 +// packets have been observed in the wild that were fragmented +// with a payload of 1416 for the first fragment +// There are reports of routers that have MTU sizes as small as 1392 +#define FUDGE_HEADER_SIZE 36 +#define TEREDO_MTU 1280 + +#define UDP_IPV4_OVERHEAD (IPV4_HEADER_SIZE + UDP_HEADER_SIZE) +#define UDP_IPV6_OVERHEAD (IPV6_HEADER_SIZE + UDP_HEADER_SIZE) +#define UDP_TEREDO_OVERHEAD (UDP_IPV4_OVERHEAD + UDP_IPV6_OVERHEAD) + +#define UDP_IPV4_MTU (ETHERNET_MTU - IPV4_HEADER_SIZE - UDP_HEADER_SIZE - GRE_HEADER_SIZE - PPPOE_HEADER_SIZE - MPPE_HEADER_SIZE - FUDGE_HEADER_SIZE) +#define UDP_IPV6_MTU (ETHERNET_MTU - IPV6_HEADER_SIZE - UDP_HEADER_SIZE - GRE_HEADER_SIZE - PPPOE_HEADER_SIZE - MPPE_HEADER_SIZE - FUDGE_HEADER_SIZE) +#define UDP_TEREDO_MTU (TEREDO_MTU - IPV6_HEADER_SIZE - UDP_HEADER_SIZE) + +uint64 utp_default_get_udp_mtu(utp_callback_arguments *args) { + // Since we don't know the local address of the interface, + // be conservative and assume all IPv6 connections are Teredo. + return (args->address->sa_family == AF_INET6) ? UDP_TEREDO_MTU : UDP_IPV4_MTU; +} + +uint64 utp_default_get_udp_overhead(utp_callback_arguments *args) { + // Since we don't know the local address of the interface, + // be conservative and assume all IPv6 connections are Teredo. + return (args->address->sa_family == AF_INET6) ? UDP_TEREDO_OVERHEAD : UDP_IPV4_OVERHEAD; +} + +uint64 utp_default_get_random(utp_callback_arguments *args) { + return rand(); +} + +uint64 utp_default_get_milliseconds(utp_callback_arguments *args) { + return UTP_GetMilliseconds(); +} + +uint64 utp_default_get_microseconds(utp_callback_arguments *args) { + return UTP_GetMicroseconds(); +} diff --git a/vendor/github.com/anacrolix/go-libutp/utp_utils.h b/vendor/github.com/anacrolix/go-libutp/utp_utils.h new file mode 100644 index 000000000..7eb0c5562 --- /dev/null +++ b/vendor/github.com/anacrolix/go-libutp/utp_utils.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2010-2013 BitTorrent, Inc. + * + * 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. + */ + +uint64 utp_default_get_udp_mtu(utp_callback_arguments *args); +uint64 utp_default_get_udp_overhead(utp_callback_arguments *args); +uint64 utp_default_get_random(utp_callback_arguments *args); +uint64 utp_default_get_milliseconds(utp_callback_arguments *args); +uint64 utp_default_get_microseconds(utp_callback_arguments *args); diff --git a/vendor/github.com/anacrolix/missinggo/atime_test.go b/vendor/github.com/anacrolix/missinggo/atime_test.go deleted file mode 100644 index 94ec2c8cf..000000000 --- a/vendor/github.com/anacrolix/missinggo/atime_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package missinggo - -import ( - "io/ioutil" - "os" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestFileInfoAccessTime(t *testing.T) { - f, err := ioutil.TempFile("", "") - require.NoError(t, err) - assert.NoError(t, f.Close()) - name := f.Name() - t.Log(name) - defer func() { - err := os.Remove(name) - if err != nil { - t.Log(err) - } - }() - fi, err := os.Stat(name) - require.NoError(t, err) - t.Log(FileInfoAccessTime(fi)) -} diff --git a/vendor/github.com/anacrolix/missinggo/bitmap/bitmap.go b/vendor/github.com/anacrolix/missinggo/bitmap/bitmap.go index 54bd0dd8c..ec47a1929 100644 --- a/vendor/github.com/anacrolix/missinggo/bitmap/bitmap.go +++ b/vendor/github.com/anacrolix/missinggo/bitmap/bitmap.go @@ -7,6 +7,7 @@ import ( "math" "github.com/RoaringBitmap/roaring" + "github.com/anacrolix/missinggo/iter" ) const MaxInt = -1 @@ -42,9 +43,9 @@ func (me *Bitmap) lazyRB() *roaring.Bitmap { return me.rb } -func (me *Bitmap) Iter(f func(interface{}) bool) { +func (me Bitmap) Iter(cb iter.Callback) { me.IterTyped(func(i int) bool { - return f(i) + return cb(i) }) } @@ -101,34 +102,7 @@ func (me *Bitmap) Contains(i int) bool { return me.rb.Contains(uint32(i)) } -type Iter struct { - ii roaring.IntIterable -} - -func (me *Iter) Next() bool { - if me == nil { - return false - } - return me.ii.HasNext() -} - -func (me *Iter) Value() interface{} { - return me.ValueInt() -} - -func (me *Iter) ValueInt() int { - return int(me.ii.Next()) -} - -func (me *Iter) Stop() {} - -func Sub(left, right *Bitmap) *Bitmap { - return &Bitmap{ - rb: roaring.AndNot(left.lazyRB(), right.lazyRB()), - } -} - -func (me *Bitmap) Sub(other *Bitmap) { +func (me *Bitmap) Sub(other Bitmap) { if other.rb == nil { return } diff --git a/vendor/github.com/anacrolix/missinggo/bitmap/bitmap_test.go b/vendor/github.com/anacrolix/missinggo/bitmap/bitmap_test.go deleted file mode 100644 index 9b38af527..000000000 --- a/vendor/github.com/anacrolix/missinggo/bitmap/bitmap_test.go +++ /dev/null @@ -1,93 +0,0 @@ -package bitmap - -import ( - "math" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/anacrolix/missinggo/iter" - "github.com/anacrolix/missinggo/slices" -) - -func TestEmptyBitmap(t *testing.T) { - var bm Bitmap - assert.False(t, bm.Contains(0)) - bm.Remove(0) - it := iter.NewIterator(&bm) - assert.Panics(t, func() { it.Value() }) - assert.False(t, it.Next()) -} - -func bitmapSlice(bm *Bitmap) (ret []int) { - sl := iter.IterableAsSlice(bm) - slices.MakeInto(&ret, sl) - return -} - -func TestSimpleBitmap(t *testing.T) { - bm := new(Bitmap) - assert.EqualValues(t, []int(nil), bitmapSlice(bm)) - bm.Add(0) - assert.True(t, bm.Contains(0)) - assert.False(t, bm.Contains(1)) - assert.EqualValues(t, 1, bm.Len()) - bm.Add(3) - assert.True(t, bm.Contains(0)) - assert.True(t, bm.Contains(3)) - assert.EqualValues(t, []int{0, 3}, bitmapSlice(bm)) - assert.EqualValues(t, 2, bm.Len()) - bm.Remove(0) - assert.EqualValues(t, []int{3}, bitmapSlice(bm)) - assert.EqualValues(t, 1, bm.Len()) -} - -func TestSub(t *testing.T) { - var left, right Bitmap - left.Add(2, 5, 4) - right.Add(3, 2, 6) - assert.Equal(t, []int{4, 5}, Sub(&left, &right).ToSortedSlice()) - assert.Equal(t, []int{3, 6}, Sub(&right, &left).ToSortedSlice()) -} - -func TestSubUninited(t *testing.T) { - var left, right Bitmap - assert.EqualValues(t, []int(nil), Sub(&left, &right).ToSortedSlice()) -} - -func TestAddRange(t *testing.T) { - var bm Bitmap - bm.AddRange(21, 26) - bm.AddRange(9, 14) - bm.AddRange(11, 16) - bm.Remove(12) - assert.EqualValues(t, []int{9, 10, 11, 13, 14, 15, 21, 22, 23, 24, 25}, bm.ToSortedSlice()) - assert.EqualValues(t, 11, bm.Len()) - bm.Clear() - bm.AddRange(3, 7) - bm.AddRange(0, 3) - bm.AddRange(2, 4) - bm.Remove(3) - assert.EqualValues(t, []int{0, 1, 2, 4, 5, 6}, bm.ToSortedSlice()) - assert.EqualValues(t, 6, bm.Len()) -} - -func TestRemoveRange(t *testing.T) { - var bm Bitmap - bm.AddRange(3, 12) - assert.EqualValues(t, 9, bm.Len()) - bm.RemoveRange(14, -1) - assert.EqualValues(t, 9, bm.Len()) - bm.RemoveRange(2, 5) - assert.EqualValues(t, 7, bm.Len()) - bm.RemoveRange(10, -1) - assert.EqualValues(t, 5, bm.Len()) -} - -func TestLimits(t *testing.T) { - var bm Bitmap - assert.Panics(t, func() { bm.Add(math.MaxInt64) }) - bm.Add(-1) - assert.EqualValues(t, 1, bm.Len()) - assert.EqualValues(t, []int{MaxInt}, bm.ToSortedSlice()) -} diff --git a/vendor/github.com/anacrolix/missinggo/bitmap/global.go b/vendor/github.com/anacrolix/missinggo/bitmap/global.go new file mode 100644 index 000000000..7474d0389 --- /dev/null +++ b/vendor/github.com/anacrolix/missinggo/bitmap/global.go @@ -0,0 +1,15 @@ +package bitmap + +import "github.com/RoaringBitmap/roaring" + +func Sub(left, right Bitmap) Bitmap { + return Bitmap{ + rb: roaring.AndNot(left.lazyRB(), right.lazyRB()), + } +} + +func Flip(bm Bitmap, start, end int) Bitmap { + return Bitmap{ + rb: roaring.FlipInt(bm.lazyRB(), start, end), + } +} diff --git a/vendor/github.com/anacrolix/missinggo/bitmap/iter.go b/vendor/github.com/anacrolix/missinggo/bitmap/iter.go new file mode 100644 index 000000000..998f7a2dd --- /dev/null +++ b/vendor/github.com/anacrolix/missinggo/bitmap/iter.go @@ -0,0 +1,24 @@ +package bitmap + +import "github.com/RoaringBitmap/roaring" + +type Iter struct { + ii roaring.IntIterable +} + +func (me *Iter) Next() bool { + if me == nil { + return false + } + return me.ii.HasNext() +} + +func (me *Iter) Value() interface{} { + return me.ValueInt() +} + +func (me *Iter) ValueInt() int { + return int(me.ii.Next()) +} + +func (me *Iter) Stop() {} diff --git a/vendor/github.com/anacrolix/missinggo/chans/drain.go b/vendor/github.com/anacrolix/missinggo/chans/drain.go deleted file mode 100644 index 9827ba3ce..000000000 --- a/vendor/github.com/anacrolix/missinggo/chans/drain.go +++ /dev/null @@ -1,16 +0,0 @@ -package chans - -import ( - "reflect" -) - -// Receives from any channel until it's closed. -func Drain(ch interface{}) { - chValue := reflect.ValueOf(ch) - for { - _, ok := chValue.Recv() - if !ok { - break - } - } -} diff --git a/vendor/github.com/anacrolix/missinggo/cmd/filecache/main.go b/vendor/github.com/anacrolix/missinggo/cmd/filecache/main.go deleted file mode 100644 index c9a5bdec9..000000000 --- a/vendor/github.com/anacrolix/missinggo/cmd/filecache/main.go +++ /dev/null @@ -1,141 +0,0 @@ -package main - -import ( - "crypto/tls" - "fmt" - "io" - "log" - "net/http" - "os" - "regexp" - "strconv" - - _ "github.com/anacrolix/envpprof" - "github.com/anacrolix/tagflag" - "github.com/dustin/go-humanize" - - "github.com/anacrolix/missinggo" - "github.com/anacrolix/missinggo/filecache" -) - -var c *filecache.Cache - -func handleNewData(w http.ResponseWriter, path string, offset int64, r io.Reader) (served bool) { - f, err := c.OpenFile(path, os.O_CREATE|os.O_WRONLY) - if err != nil { - log.Print(err) - http.Error(w, "couldn't open file", http.StatusInternalServerError) - return true - } - defer f.Close() - f.Seek(offset, os.SEEK_SET) - _, err = io.Copy(f, r) - if err != nil { - log.Print(err) - f.Remove() - http.Error(w, "didn't complete", http.StatusInternalServerError) - return true - } - return -} - -// Parses out the first byte from a Content-Range header. Returns 0 if it -// isn't found, which is what is implied if there is no header. -func parseContentRangeFirstByte(s string) int64 { - matches := regexp.MustCompile(`(\d+)-`).FindStringSubmatch(s) - if matches == nil { - return 0 - } - ret, _ := strconv.ParseInt(matches[1], 0, 64) - return ret -} - -func handleDelete(w http.ResponseWriter, path string) { - err := c.Remove(path) - if err != nil { - log.Print(err) - http.Error(w, "didn't work", http.StatusInternalServerError) - return - } -} - -func main() { - log.SetFlags(log.Flags() | log.Lshortfile) - args := struct { - Capacity tagflag.Bytes `short:"c"` - Addr string - }{ - Capacity: -1, - Addr: "localhost:2076", - } - tagflag.Parse(&args) - root, err := os.Getwd() - if err != nil { - log.Fatal(err) - } - log.Printf("cache root at %q", root) - c, err = filecache.NewCache(root) - if err != nil { - log.Fatalf("error creating cache: %s", err) - } - if args.Capacity < 0 { - log.Printf("no capacity set, no evictions will occur") - } else { - c.SetCapacity(args.Capacity.Int64()) - log.Printf("setting capacity to %s bytes", humanize.Comma(args.Capacity.Int64())) - } - http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - p := r.URL.Path[1:] - switch r.Method { - case "DELETE": - log.Printf("%s %s", r.Method, r.RequestURI) - handleDelete(w, p) - return - case "PUT", "PATCH", "POST": - contentRange := r.Header.Get("Content-Range") - firstByte := parseContentRangeFirstByte(contentRange) - log.Printf("%s (%d-) %s", r.Method, firstByte, r.RequestURI) - handleNewData(w, p, firstByte, r.Body) - return - } - log.Printf("%s %s %s", r.Method, r.Header.Get("Range"), r.RequestURI) - f, err := c.OpenFile(p, os.O_RDONLY) - if os.IsNotExist(err) { - http.NotFound(w, r) - return - } - if err != nil { - log.Printf("couldn't open requested file: %s", err) - http.Error(w, "couldn't open file", http.StatusInternalServerError) - return - } - defer func() { - go f.Close() - }() - info, _ := f.Stat() - w.Header().Set("Content-Range", fmt.Sprintf("*/%d", info.Size())) - http.ServeContent(w, r, p, info.ModTime(), f) - }) - http.HandleFunc("/status", func(w http.ResponseWriter, r *http.Request) { - info := c.Info() - fmt.Fprintf(w, "Capacity: %d\n", info.Capacity) - fmt.Fprintf(w, "Current Size: %d\n", info.Filled) - fmt.Fprintf(w, "Item Count: %d\n", info.NumItems) - }) - http.HandleFunc("/lru", func(w http.ResponseWriter, r *http.Request) { - c.WalkItems(func(item filecache.ItemInfo) { - fmt.Fprintf(w, "%s\t%d\t%s\n", item.Accessed, item.Size, item.Path) - }) - }) - cert, err := missinggo.NewSelfSignedCertificate() - if err != nil { - log.Fatal(err) - } - srv := http.Server{ - Addr: args.Addr, - TLSConfig: &tls.Config{ - Certificates: []tls.Certificate{cert}, - }, - } - log.Fatal(srv.ListenAndServeTLS("", "")) -} diff --git a/vendor/github.com/anacrolix/missinggo/cmd/filecache/main_test.go b/vendor/github.com/anacrolix/missinggo/cmd/filecache/main_test.go deleted file mode 100644 index e296c2d58..000000000 --- a/vendor/github.com/anacrolix/missinggo/cmd/filecache/main_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package main - -import ( - "testing" -) - -func TestFailedPutDeletesFile(t *testing.T) { - // TODO -} diff --git a/vendor/github.com/anacrolix/missinggo/cmd/gd/main.go b/vendor/github.com/anacrolix/missinggo/cmd/gd/main.go deleted file mode 100644 index 4aa0a3645..000000000 --- a/vendor/github.com/anacrolix/missinggo/cmd/gd/main.go +++ /dev/null @@ -1,73 +0,0 @@ -package main - -import ( - "encoding/base32" - "encoding/hex" - "fmt" - "io" - "io/ioutil" - "net/url" - "os" - "strings" -) - -func escape(encoding string) { - switch { - case strings.HasPrefix("query", encoding): - b, err := ioutil.ReadAll(os.Stdin) - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - os.Stdout.Write([]byte(url.QueryEscape(string(b)))) - case strings.HasPrefix("hex", encoding): - b, err := ioutil.ReadAll(os.Stdin) - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - os.Stdout.Write([]byte(hex.EncodeToString(b))) - default: - fmt.Fprintf(os.Stderr, "unknown escape encoding: %q\n", encoding) - os.Exit(2) - } -} - -func unescape(encoding string) { - switch { - case strings.HasPrefix("query", encoding): - b, err := ioutil.ReadAll(os.Stdin) - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - s, err := url.QueryUnescape(string(b)) - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - os.Stdout.Write([]byte(s)) - case strings.HasPrefix("b32", encoding): - d := base32.NewDecoder(base32.StdEncoding, os.Stdin) - io.Copy(os.Stdout, d) - default: - fmt.Fprintf(os.Stderr, "unknown unescape encoding: %q\n", encoding) - } -} - -func main() { - if len(os.Args) != 3 { - fmt.Fprintf(os.Stderr, "expected two arguments: : got %d\n", len(os.Args)-1) - os.Exit(2) - } - mode := os.Args[1] - switch { - case strings.HasPrefix("escape", mode): - escape(os.Args[2]) - case strings.HasPrefix("unescape", mode) || strings.HasPrefix("decode", mode): - unescape(os.Args[2]) - default: - fmt.Fprintf(os.Stderr, "unknown mode: %q\n", mode) - os.Exit(2) - } -} diff --git a/vendor/github.com/anacrolix/missinggo/cmd/go-env/main.go b/vendor/github.com/anacrolix/missinggo/cmd/go-env/main.go deleted file mode 100644 index 66a736e00..000000000 --- a/vendor/github.com/anacrolix/missinggo/cmd/go-env/main.go +++ /dev/null @@ -1,12 +0,0 @@ -package main - -import ( - "fmt" - "os" -) - -func main() { - for _, v := range os.Environ() { - fmt.Printf("%s\n", v) - } -} diff --git a/vendor/github.com/anacrolix/missinggo/cmd/http-file-server/main.go b/vendor/github.com/anacrolix/missinggo/cmd/http-file-server/main.go deleted file mode 100644 index 46f718c03..000000000 --- a/vendor/github.com/anacrolix/missinggo/cmd/http-file-server/main.go +++ /dev/null @@ -1,52 +0,0 @@ -package main - -import ( - "log" - "net" - "net/http" - "os" - - "github.com/anacrolix/tagflag" -) - -func setIfGetHeader(w http.ResponseWriter, r *http.Request, set, get string) { - h := r.Header.Get(get) - if h == "" { - return - } - w.Header().Set(set, h) -} - -func allowCORS(h http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if origin := r.Header.Get("Origin"); origin != "" { - w.Header().Set("Access-Control-Allow-Origin", origin) - w.Header().Set("Access-Control-Allow-Credentials", "true") - setIfGetHeader(w, r, "Access-Control-Allow-Methods", "Access-Control-Request-Method") - setIfGetHeader(w, r, "Access-Control-Allow-Headers", "Access-Control-Request-Headers") - w.Header().Set("Access-Control-Expose-Headers", "Content-Type") - } - h.ServeHTTP(w, r) - }) -} - -func main() { - var flags = struct { - Addr string - }{ - Addr: "localhost:8080", - } - tagflag.Parse(&flags) - dir, err := os.Getwd() - if err != nil { - log.Fatal(err) - } - l, err := net.Listen("tcp", flags.Addr) - if err != nil { - log.Fatal(err) - } - defer l.Close() - addr := l.Addr() - log.Printf("serving %q at %s", dir, addr) - log.Fatal(http.Serve(l, allowCORS(http.FileServer(http.Dir(dir))))) -} diff --git a/vendor/github.com/anacrolix/missinggo/cmd/nop/main.go b/vendor/github.com/anacrolix/missinggo/cmd/nop/main.go deleted file mode 100644 index 38dd16da6..000000000 --- a/vendor/github.com/anacrolix/missinggo/cmd/nop/main.go +++ /dev/null @@ -1,3 +0,0 @@ -package main - -func main() {} diff --git a/vendor/github.com/anacrolix/missinggo/cmd/query-escape/main.go b/vendor/github.com/anacrolix/missinggo/cmd/query-escape/main.go deleted file mode 100644 index cddd9d93d..000000000 --- a/vendor/github.com/anacrolix/missinggo/cmd/query-escape/main.go +++ /dev/null @@ -1,11 +0,0 @@ -package main - -import ( - "fmt" - "net/url" - "os" -) - -func main() { - fmt.Println(url.QueryEscape(os.Args[1])) -} diff --git a/vendor/github.com/anacrolix/missinggo/cmd/query-unescape/main.go b/vendor/github.com/anacrolix/missinggo/cmd/query-unescape/main.go deleted file mode 100644 index 3099cc8df..000000000 --- a/vendor/github.com/anacrolix/missinggo/cmd/query-unescape/main.go +++ /dev/null @@ -1,11 +0,0 @@ -package main - -import ( - "fmt" - "net/url" - "os" -) - -func main() { - fmt.Println(url.QueryUnescape(os.Args[1])) -} diff --git a/vendor/github.com/anacrolix/missinggo/container/xheap/xheap.go b/vendor/github.com/anacrolix/missinggo/container/xheap/xheap.go deleted file mode 100644 index b60cec264..000000000 --- a/vendor/github.com/anacrolix/missinggo/container/xheap/xheap.go +++ /dev/null @@ -1,68 +0,0 @@ -package xheap - -import ( - "container/heap" - "sort" -) - -type pushPopper interface { - Push(interface{}) - Pop() interface{} -} - -func Flipped(h heap.Interface) heap.Interface { - return struct { - sort.Interface - pushPopper - }{ - sort.Reverse(h), - h, - } -} - -// type top struct { -// k int -// heap.Interface -// } - -// func (me top) Push(x interface{}) { -// heap.Push(me.Interface, x) -// if me.Len() > me.k { -// heap.Pop(me) -// } -// } - -// func Bounded(k int, h heap.Interface) heap.Interface { -// return top{k, Flipped(h)} -// } - -type slice struct { - Slice *[]interface{} - Lesser func(l, r interface{}) bool -} - -func (me slice) Len() int { return len(*me.Slice) } - -func (me slice) Less(i, j int) bool { - return me.Lesser((*me.Slice)[i], (*me.Slice)[j]) -} - -func (me slice) Pop() (ret interface{}) { - i := me.Len() - 1 - ret = (*me.Slice)[i] - *me.Slice = (*me.Slice)[:i] - return -} - -func (me slice) Push(x interface{}) { - *me.Slice = append(*me.Slice, x) -} - -func (me slice) Swap(i, j int) { - sl := *me.Slice - sl[i], sl[j] = sl[j], sl[i] -} - -func Slice(sl *[]interface{}, lesser func(l, r interface{}) bool) heap.Interface { - return slice{sl, lesser} -} diff --git a/vendor/github.com/anacrolix/missinggo/copy_test.go b/vendor/github.com/anacrolix/missinggo/copy_test.go deleted file mode 100644 index 190f2a10f..000000000 --- a/vendor/github.com/anacrolix/missinggo/copy_test.go +++ /dev/null @@ -1,89 +0,0 @@ -package missinggo - -import ( - "bytes" - "strings" - "testing" -) - -func TestCopyToArray(t *testing.T) { - var arr [3]byte - bb := []byte{1, 2, 3} - CopyExact(&arr, bb) - if !bytes.Equal(arr[:], bb) { - t.FailNow() - } -} - -func TestCopyToSlicedArray(t *testing.T) { - var arr [5]byte - CopyExact(arr[:], "hello") - if !bytes.Equal(arr[:], []byte("hello")) { - t.FailNow() - } -} - -func TestCopyDestNotAddr(t *testing.T) { - defer func() { - r := recover() - if r == nil { - t.FailNow() - } - t.Log(r) - }() - var arr [3]byte - CopyExact(arr, "nope") -} - -func TestCopyLenMismatch(t *testing.T) { - defer func() { - r := recover() - if r == nil { - t.FailNow() - } - t.Log(r) - }() - CopyExact(make([]byte, 2), "abc") -} - -func TestCopySrcString(t *testing.T) { - dest := make([]byte, 3) - CopyExact(dest, "lol") - if string(dest) != "lol" { - t.FailNow() - } - func() { - defer func() { - r := recover() - if r == nil { - t.FailNow() - } - }() - CopyExact(dest, "rofl") - }() - var arr [5]byte - CopyExact(&arr, interface{}("hello")) - if string(arr[:]) != "hello" { - t.FailNow() - } -} - -func TestCopySrcNilInterface(t *testing.T) { - var arr [3]byte - defer func() { - r := recover().(string) - if !strings.Contains(r, "invalid source") { - t.FailNow() - } - }() - CopyExact(&arr, nil) -} - -func TestCopySrcPtr(t *testing.T) { - var bigDst [1024]byte - var bigSrc [1024]byte = [1024]byte{'h', 'i'} - CopyExact(&bigDst, &bigSrc) - if !bytes.Equal(bigDst[:], bigSrc[:]) { - t.FailNow() - } -} diff --git a/vendor/github.com/anacrolix/missinggo/ctrlflow/ctrlflow.go b/vendor/github.com/anacrolix/missinggo/ctrlflow/ctrlflow.go deleted file mode 100644 index 1814f753f..000000000 --- a/vendor/github.com/anacrolix/missinggo/ctrlflow/ctrlflow.go +++ /dev/null @@ -1,30 +0,0 @@ -package ctrlflow - -import ( - "fmt" -) - -type valueWrapper struct { - value interface{} -} - -func (me valueWrapper) String() string { - return fmt.Sprint(me.value) -} - -func Panic(val interface{}) { - panic(valueWrapper{val}) -} - -func Recover(handler func(interface{}) bool) { - r := recover() - if r == nil { - return - } - if vw, ok := r.(valueWrapper); ok { - if handler(vw.value) { - return - } - } - panic(r) -} diff --git a/vendor/github.com/anacrolix/missinggo/docopt/docopt.go b/vendor/github.com/anacrolix/missinggo/docopt/docopt.go deleted file mode 100644 index b047bcbbe..000000000 --- a/vendor/github.com/anacrolix/missinggo/docopt/docopt.go +++ /dev/null @@ -1,23 +0,0 @@ -package docopt - -import ( - "fmt" - "os" - - "github.com/docopt/docopt-go" -) - -func Parse(doc string) (opts map[string]interface{}) { - opts, err := docopt.Parse(doc, nil, true, "1.2.3", false, false) - if ue, ok := err.(*docopt.UserError); ok { - if ue.Error() != "" { - fmt.Fprintf(os.Stderr, "\n%s\n", ue) - } - os.Exit(2) - } - if err != nil { - fmt.Fprintf(os.Stderr, "error parsing docopt: %#v\n", err) - os.Exit(1) - } - return -} diff --git a/vendor/github.com/anacrolix/missinggo/empty_value.go b/vendor/github.com/anacrolix/missinggo/empty_value.go index b30d717cc..bb59970c0 100644 --- a/vendor/github.com/anacrolix/missinggo/empty_value.go +++ b/vendor/github.com/anacrolix/missinggo/empty_value.go @@ -2,6 +2,10 @@ package missinggo import "reflect" +func IsZeroValue(i interface{}) bool { + return IsEmptyValue(reflect.ValueOf(i)) +} + // Returns whether the value represents the empty value for its type. Used for // example to determine if complex types satisfy the common "omitempty" tag // option for marshalling. Taken from diff --git a/vendor/github.com/anacrolix/missinggo/event_test.go b/vendor/github.com/anacrolix/missinggo/event_test.go deleted file mode 100644 index 8ef46d84b..000000000 --- a/vendor/github.com/anacrolix/missinggo/event_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package missinggo - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestSetEvent(t *testing.T) { - var e Event - e.Set() -} - -func TestEventIsSet(t *testing.T) { - var e Event - assert.False(t, e.IsSet()) - e.Set() - assert.True(t, e.IsSet()) -} diff --git a/vendor/github.com/anacrolix/missinggo/expvarIndentMap.go b/vendor/github.com/anacrolix/missinggo/expvarIndentMap.go index c99529956..c50f2ee43 100644 --- a/vendor/github.com/anacrolix/missinggo/expvarIndentMap.go +++ b/vendor/github.com/anacrolix/missinggo/expvarIndentMap.go @@ -10,7 +10,7 @@ type IndentMap struct { expvar.Map } -var _ expvar.Var = &IndentMap{} +var _ expvar.Var = (*IndentMap)(nil) func NewExpvarIndentMap(name string) *IndentMap { v := new(IndentMap) diff --git a/vendor/github.com/anacrolix/missinggo/filecache/cache.go b/vendor/github.com/anacrolix/missinggo/filecache/cache.go deleted file mode 100644 index 9c935313b..000000000 --- a/vendor/github.com/anacrolix/missinggo/filecache/cache.go +++ /dev/null @@ -1,309 +0,0 @@ -package filecache - -import ( - "errors" - "log" - "os" - "path" - "path/filepath" - "sync" - "time" - - "github.com/anacrolix/missinggo" - "github.com/anacrolix/missinggo/pproffd" - "github.com/anacrolix/missinggo/resource" -) - -const ( - dirPerm = 0755 - filePerm = 0644 -) - -type Cache struct { - mu sync.Mutex - capacity int64 - filled int64 - items *lruItems - paths map[string]ItemInfo - root string -} - -type CacheInfo struct { - Capacity int64 - Filled int64 - NumItems int -} - -type ItemInfo struct { - Accessed time.Time - Size int64 - Path string -} - -// Calls the function for every item known to the cache. The ItemInfo should -// not be modified. -func (me *Cache) WalkItems(cb func(ItemInfo)) { - me.mu.Lock() - defer me.mu.Unlock() - for e := me.items.Front(); e != nil; e = e.Next() { - cb(e.Value().(ItemInfo)) - } -} - -func (me *Cache) Info() (ret CacheInfo) { - me.mu.Lock() - defer me.mu.Unlock() - ret.Capacity = me.capacity - ret.Filled = me.filled - ret.NumItems = len(me.paths) - return -} - -// Setting a negative capacity means unlimited. -func (me *Cache) SetCapacity(capacity int64) { - me.mu.Lock() - defer me.mu.Unlock() - me.capacity = capacity -} - -func NewCache(root string) (ret *Cache, err error) { - root, err = filepath.Abs(root) - ret = &Cache{ - root: root, - capacity: -1, // unlimited - } - ret.mu.Lock() - go func() { - defer ret.mu.Unlock() - ret.rescan() - }() - return -} - -// An empty return path is an error. -func sanitizePath(p string) (ret string) { - if p == "" { - return - } - ret = path.Clean("/" + p) - if ret[0] == '/' { - ret = ret[1:] - } - return -} - -// Leaf is a descendent of root. -func pruneEmptyDirs(root string, leaf string) (err error) { - rootInfo, err := os.Stat(root) - if err != nil { - return - } - for { - var leafInfo os.FileInfo - leafInfo, err = os.Stat(leaf) - if os.IsNotExist(err) { - goto parent - } - if err != nil { - return - } - if !leafInfo.IsDir() { - return - } - if os.SameFile(rootInfo, leafInfo) { - return - } - if os.Remove(leaf) != nil { - return - } - parent: - leaf = filepath.Dir(leaf) - } -} - -func (me *Cache) Remove(path string) (err error) { - path = sanitizePath(path) - me.mu.Lock() - defer me.mu.Unlock() - err = me.remove(path) - return -} - -var ( - ErrBadPath = errors.New("bad path") - ErrIsDir = errors.New("is directory") -) - -func (me *Cache) StatFile(path string) (os.FileInfo, error) { - return os.Stat(me.realpath(sanitizePath(path))) -} - -func (me *Cache) OpenFile(path string, flag int) (ret *File, err error) { - path = sanitizePath(path) - if path == "" { - err = ErrIsDir - return - } - f, err := os.OpenFile(me.realpath(path), flag, filePerm) - if flag&os.O_CREATE != 0 && os.IsNotExist(err) { - os.MkdirAll(me.root, dirPerm) - os.MkdirAll(filepath.Dir(me.realpath(path)), dirPerm) - f, err = os.OpenFile(me.realpath(path), flag, filePerm) - if err != nil { - me.pruneEmptyDirs(path) - } - } - if err != nil { - return - } - ret = &File{ - c: me, - path: path, - f: pproffd.WrapOSFile(f), - } - me.mu.Lock() - go func() { - defer me.mu.Unlock() - me.statItem(path, time.Now()) - }() - return -} - -func (me *Cache) rescan() { - me.filled = 0 - me.items = newLRUItems() - me.paths = make(map[string]ItemInfo) - err := filepath.Walk(me.root, func(path string, info os.FileInfo, err error) error { - if os.IsNotExist(err) { - return nil - } - if err != nil { - return err - } - if info.IsDir() { - return nil - } - path, err = filepath.Rel(me.root, path) - if err != nil { - log.Print(err) - return nil - } - me.statItem(path, time.Time{}) - return nil - }) - if err != nil { - panic(err) - } -} - -func (me *Cache) insertItem(i ItemInfo) { - me.items.Insert(i) -} - -func (me *Cache) removeInfo(path string) (ret ItemInfo, ok bool) { - ret, ok = me.paths[path] - if !ok { - return - } - if !me.items.Remove(ret) { - panic(ret) - } - me.filled -= ret.Size - delete(me.paths, path) - return -} - -// Triggers the item for path to be updated. If access is non-zero, set the -// item's access time to that value, otherwise deduce it appropriately. -func (me *Cache) statItem(path string, access time.Time) { - info, ok := me.removeInfo(path) - fi, err := os.Stat(me.realpath(path)) - if os.IsNotExist(err) { - return - } - if err != nil { - panic(err) - } - if !ok { - info.Path = path - } - if !access.IsZero() { - info.Accessed = access - } - if info.Accessed.IsZero() { - info.Accessed = missinggo.Max( - func(left, right time.Time) bool { return left.Before(right) }, - missinggo.FileInfoAccessTime(fi), - fi.ModTime(), - ).(time.Time) - } - info.Size = fi.Size() - me.filled += info.Size - me.insertItem(info) - me.paths[path] = info -} - -func (me *Cache) realpath(path string) string { - return filepath.Join(me.root, filepath.FromSlash(sanitizePath(path))) -} - -func (me *Cache) TrimToCapacity() { - me.mu.Lock() - defer me.mu.Unlock() - me.trimToCapacity() -} - -func (me *Cache) pruneEmptyDirs(path string) { - pruneEmptyDirs(me.root, me.realpath(path)) -} - -func (me *Cache) remove(path string) (err error) { - err = os.Remove(me.realpath(path)) - if os.IsNotExist(err) { - err = nil - } - me.pruneEmptyDirs(path) - me.removeInfo(path) - return -} - -func (me *Cache) trimToCapacity() { - if me.capacity < 0 { - return - } - for me.filled > me.capacity { - item := me.items.LRU() - me.remove(item.Path) - } -} - -func (me *Cache) pathInfo(p string) ItemInfo { - return me.paths[p] -} - -func (me *Cache) Rename(from, to string) (err error) { - _from := sanitizePath(from) - _to := sanitizePath(to) - me.mu.Lock() - defer me.mu.Unlock() - err = os.MkdirAll(filepath.Dir(me.realpath(_to)), dirPerm) - if err != nil { - return - } - err = os.Rename(me.realpath(_from), me.realpath(_to)) - if err != nil { - return - } - me.removeInfo(_from) - me.pruneEmptyDirs(_from) - me.statItem(_to, time.Now()) - return -} - -func (me *Cache) Stat(path string) (os.FileInfo, error) { - return os.Stat(me.realpath(path)) -} - -func (me *Cache) AsResourceProvider() resource.Provider { - return &uniformResourceProvider{me} -} diff --git a/vendor/github.com/anacrolix/missinggo/filecache/cache_test.go b/vendor/github.com/anacrolix/missinggo/filecache/cache_test.go deleted file mode 100644 index 5f7c683c1..000000000 --- a/vendor/github.com/anacrolix/missinggo/filecache/cache_test.go +++ /dev/null @@ -1,84 +0,0 @@ -package filecache - -import ( - "io" - "io/ioutil" - "os" - "path/filepath" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/anacrolix/missinggo" -) - -func TestCache(t *testing.T) { - td, err := ioutil.TempDir("", "gotest") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(td) - c, err := NewCache(filepath.Join(td, "cache")) - if err != nil { - t.Fatal(err) - } - assert.EqualValues(t, 0, c.Info().Filled) - c.WalkItems(func(i ItemInfo) {}) - _, err = c.OpenFile("/", os.O_CREATE) - assert.NotNil(t, err) - _, err = c.OpenFile("", os.O_CREATE) - assert.NotNil(t, err) - c.WalkItems(func(i ItemInfo) {}) - require.Equal(t, 0, c.Info().NumItems) - _, err = c.OpenFile("notexist", 0) - assert.True(t, os.IsNotExist(err), err) - _, err = c.OpenFile("/notexist", 0) - assert.True(t, os.IsNotExist(err), err) - _, err = c.OpenFile("/dir/notexist", 0) - assert.True(t, os.IsNotExist(err), err) - f, err := c.OpenFile("dir/blah", os.O_CREATE) - require.NoError(t, err) - defer f.Close() - c.WalkItems(func(i ItemInfo) {}) - assert.True(t, missinggo.FilePathExists(filepath.Join(td, filepath.FromSlash("cache/dir/blah")))) - assert.True(t, missinggo.FilePathExists(filepath.Join(td, filepath.FromSlash("cache/dir/")))) - assert.Equal(t, 1, c.Info().NumItems) - f.Remove() - assert.False(t, missinggo.FilePathExists(filepath.Join(td, filepath.FromSlash("dir/blah")))) - assert.False(t, missinggo.FilePathExists(filepath.Join(td, filepath.FromSlash("dir/")))) - _, err = f.Read(nil) - assert.NotEqual(t, io.EOF, err) - a, err := c.OpenFile("/a", os.O_CREATE|os.O_WRONLY) - defer a.Close() - require.Nil(t, err) - b, err := c.OpenFile("b", os.O_CREATE|os.O_WRONLY) - defer b.Close() - require.Nil(t, err) - c.mu.Lock() - assert.False(t, c.pathInfo("a").Accessed.After(c.pathInfo("b").Accessed)) - c.mu.Unlock() - n, err := a.Write([]byte("hello")) - assert.Nil(t, err) - assert.EqualValues(t, 5, n) - assert.EqualValues(t, 5, c.Info().Filled) - assert.False(t, c.pathInfo("b").Accessed.After(c.pathInfo("a").Accessed)) - c.SetCapacity(5) - n, err = a.Write([]byte(" world")) - assert.NotNil(t, err) - _, err = b.Write([]byte("boom!")) - // "a" and "b" have been evicted. - assert.NotNil(t, err) - assert.EqualValues(t, 0, c.Info().Filled) - assert.EqualValues(t, 0, c.Info().NumItems) - _, err = a.Seek(0, os.SEEK_SET) - assert.NotNil(t, err) -} - -func TestSanitizePath(t *testing.T) { - assert.Equal(t, "", sanitizePath("////")) - assert.Equal(t, "", sanitizePath("/../..")) - assert.Equal(t, "a", sanitizePath("/a//b/..")) - assert.Equal(t, "a", sanitizePath("../a")) - assert.Equal(t, "a", sanitizePath("./a")) -} diff --git a/vendor/github.com/anacrolix/missinggo/filecache/file.go b/vendor/github.com/anacrolix/missinggo/filecache/file.go deleted file mode 100644 index cb872b30c..000000000 --- a/vendor/github.com/anacrolix/missinggo/filecache/file.go +++ /dev/null @@ -1,135 +0,0 @@ -package filecache - -import ( - "errors" - "math" - "os" - "sync" - "time" - - "github.com/anacrolix/missinggo/pproffd" -) - -type File struct { - mu sync.Mutex - c *Cache - path string - f pproffd.OSFile - gone bool -} - -func (me *File) Remove() (err error) { - return me.c.Remove(me.path) -} - -func (me *File) Seek(offset int64, whence int) (ret int64, err error) { - ret, err = me.f.Seek(offset, whence) - return -} - -func (me *File) maxWrite() (max int64, err error) { - if me.c.capacity < 0 { - max = math.MaxInt64 - return - } - pos, err := me.Seek(0, os.SEEK_CUR) - if err != nil { - return - } - max = me.c.capacity - pos - if max < 0 { - max = 0 - } - return -} - -var ( - ErrFileTooLarge = errors.New("file too large for cache") - ErrFileDisappeared = errors.New("file disappeared") -) - -func (me *File) checkGone() { - if me.gone { - return - } - ffi, _ := me.Stat() - fsfi, _ := os.Stat(me.c.realpath(me.path)) - me.gone = !os.SameFile(ffi, fsfi) -} - -func (me *File) goneErr() error { - me.mu.Lock() - defer me.mu.Unlock() - me.checkGone() - if me.gone { - me.f.Close() - return ErrFileDisappeared - } - return nil -} - -func (me *File) Write(b []byte) (n int, err error) { - err = me.goneErr() - if err != nil { - return - } - n, err = me.f.Write(b) - me.c.mu.Lock() - me.c.statItem(me.path, time.Now()) - me.c.trimToCapacity() - me.c.mu.Unlock() - if err == nil { - err = me.goneErr() - } - return -} - -func (me *File) WriteAt(b []byte, off int64) (n int, err error) { - err = me.goneErr() - if err != nil { - return - } - n, err = me.f.WriteAt(b, off) - me.c.mu.Lock() - me.c.statItem(me.path, time.Now()) - me.c.trimToCapacity() - me.c.mu.Unlock() - if err == nil { - err = me.goneErr() - } - return -} - -func (me *File) Close() error { - return me.f.Close() -} - -func (me *File) Stat() (os.FileInfo, error) { - return me.f.Stat() -} - -func (me *File) Read(b []byte) (n int, err error) { - err = me.goneErr() - if err != nil { - return - } - defer func() { - me.c.mu.Lock() - defer me.c.mu.Unlock() - me.c.statItem(me.path, time.Now()) - }() - return me.f.Read(b) -} - -func (me *File) ReadAt(b []byte, off int64) (n int, err error) { - err = me.goneErr() - if err != nil { - return - } - defer func() { - me.c.mu.Lock() - defer me.c.mu.Unlock() - me.c.statItem(me.path, time.Now()) - }() - return me.f.ReadAt(b, off) -} diff --git a/vendor/github.com/anacrolix/missinggo/filecache/lruitems.go b/vendor/github.com/anacrolix/missinggo/filecache/lruitems.go deleted file mode 100644 index cf1b50f08..000000000 --- a/vendor/github.com/anacrolix/missinggo/filecache/lruitems.go +++ /dev/null @@ -1,97 +0,0 @@ -package filecache - -// TODO: Dump this file for orderedmap. - -import ( - "container/list" - "io" - - "github.com/cznic/b" -) - -type Iterator interface { - Next() Iterator - Value() interface{} -} - -type listElementIterator struct { - le *list.Element -} - -func (me listElementIterator) Next() Iterator { - e := me.le.Next() - if e == nil { - return nil - } - return listElementIterator{e} -} - -func (me listElementIterator) Value() interface{} { - return me.le.Value -} - -func newLRUItems() *lruItems { - return &lruItems{b.TreeNew(func(_a, _b interface{}) int { - a := _a.(ItemInfo) - b := _b.(ItemInfo) - if a.Accessed != b.Accessed { - if a.Accessed.Before(b.Accessed) { - return -1 - } else { - return 1 - } - } - if a.Path == b.Path { - return 0 - } - if a.Path < b.Path { - return -1 - } - return 1 - })} -} - -// TODO: Dumps this for orderedmap. -type lruItems struct { - tree *b.Tree -} - -type bEnumeratorIterator struct { - e *b.Enumerator - v ItemInfo -} - -func (me bEnumeratorIterator) Next() Iterator { - _, v, err := me.e.Next() - if err == io.EOF { - return nil - } - return bEnumeratorIterator{me.e, v.(ItemInfo)} -} - -func (me bEnumeratorIterator) Value() interface{} { - return me.v -} - -func (me *lruItems) Front() Iterator { - e, _ := me.tree.SeekFirst() - if e == nil { - return nil - } - return bEnumeratorIterator{ - e: e, - }.Next() -} - -func (me *lruItems) LRU() ItemInfo { - _, v := me.tree.First() - return v.(ItemInfo) -} - -func (me *lruItems) Insert(ii ItemInfo) { - me.tree.Set(ii, ii) -} - -func (me *lruItems) Remove(ii ItemInfo) bool { - return me.tree.Delete(ii) -} diff --git a/vendor/github.com/anacrolix/missinggo/filecache/lruitems_test.go b/vendor/github.com/anacrolix/missinggo/filecache/lruitems_test.go deleted file mode 100644 index a791d0cc5..000000000 --- a/vendor/github.com/anacrolix/missinggo/filecache/lruitems_test.go +++ /dev/null @@ -1,22 +0,0 @@ -package filecache - -import ( - "math/rand" - "testing" - "time" - - "github.com/bradfitz/iter" -) - -func BenchmarkInsert(b *testing.B) { - for range iter.N(b.N) { - li := newLRUItems() - for range iter.N(10000) { - r := rand.Int63() - t := time.Unix(r/1e9, r%1e9) - li.Insert(ItemInfo{ - Accessed: t, - }) - } - } -} diff --git a/vendor/github.com/anacrolix/missinggo/filecache/uniform.go b/vendor/github.com/anacrolix/missinggo/filecache/uniform.go deleted file mode 100644 index ed5a0622c..000000000 --- a/vendor/github.com/anacrolix/missinggo/filecache/uniform.go +++ /dev/null @@ -1,63 +0,0 @@ -package filecache - -import ( - "io" - "os" - - "github.com/anacrolix/missinggo/resource" -) - -type uniformResourceProvider struct { - *Cache -} - -var _ resource.Provider = &uniformResourceProvider{} - -func (me *uniformResourceProvider) NewInstance(loc string) (resource.Instance, error) { - return &uniformResource{me.Cache, loc}, nil -} - -type uniformResource struct { - Cache *Cache - Location string -} - -func (me *uniformResource) Get() (io.ReadCloser, error) { - return me.Cache.OpenFile(me.Location, os.O_RDONLY) -} - -func (me *uniformResource) Put(r io.Reader) (err error) { - f, err := me.Cache.OpenFile(me.Location, os.O_WRONLY|os.O_CREATE|os.O_TRUNC) - if err != nil { - return - } - defer f.Close() - _, err = io.Copy(f, r) - return -} - -func (me *uniformResource) ReadAt(b []byte, off int64) (n int, err error) { - f, err := me.Cache.OpenFile(me.Location, os.O_RDONLY) - if err != nil { - return - } - defer f.Close() - return f.ReadAt(b, off) -} - -func (me *uniformResource) WriteAt(b []byte, off int64) (n int, err error) { - f, err := me.Cache.OpenFile(me.Location, os.O_CREATE|os.O_WRONLY) - if err != nil { - return - } - defer f.Close() - return f.WriteAt(b, off) -} - -func (me *uniformResource) Stat() (fi os.FileInfo, err error) { - return me.Cache.Stat(me.Location) -} - -func (me *uniformResource) Delete() error { - return me.Cache.Remove(me.Location) -} diff --git a/vendor/github.com/anacrolix/missinggo/futures/funcs.go b/vendor/github.com/anacrolix/missinggo/futures/funcs.go deleted file mode 100644 index 988de6129..000000000 --- a/vendor/github.com/anacrolix/missinggo/futures/funcs.go +++ /dev/null @@ -1,23 +0,0 @@ -package futures - -import ( - "sync" -) - -func AsCompleted(fs ...*F) <-chan *F { - ret := make(chan *F, len(fs)) - var wg sync.WaitGroup - for _, f := range fs { - wg.Add(1) - go func(f *F) { - defer wg.Done() - <-f.Done() - ret <- f - }(f) - } - go func() { - wg.Wait() - close(ret) - }() - return ret -} diff --git a/vendor/github.com/anacrolix/missinggo/futures/future.go b/vendor/github.com/anacrolix/missinggo/futures/future.go deleted file mode 100644 index b8b966e88..000000000 --- a/vendor/github.com/anacrolix/missinggo/futures/future.go +++ /dev/null @@ -1,38 +0,0 @@ -package futures - -import "sync" - -func Start(fn func() interface{}) *F { - f := &F{ - done: make(chan struct{}), - } - go func() { - result := fn() - f.setResult(result) - }() - return f -} - -type F struct { - mu sync.Mutex - result interface{} - done chan struct{} -} - -func (f *F) Result() interface{} { - <-f.done - f.mu.Lock() - defer f.mu.Unlock() - return f.result -} - -func (f *F) Done() <-chan struct{} { - return f.done -} - -func (f *F) setResult(result interface{}) { - f.mu.Lock() - defer f.mu.Unlock() - f.result = result - close(f.done) -} diff --git a/vendor/github.com/anacrolix/missinggo/goleaktest.go b/vendor/github.com/anacrolix/missinggo/goleaktest.go deleted file mode 100644 index b169b2344..000000000 --- a/vendor/github.com/anacrolix/missinggo/goleaktest.go +++ /dev/null @@ -1,37 +0,0 @@ -package missinggo - -import ( - "runtime" - "testing" - "time" - - "github.com/bradfitz/iter" -) - -// Put defer GoroutineLeakCheck(t)() at the top of your test. Make sure the -// goroutine count is steady before your test begins. -func GoroutineLeakCheck(t testing.TB) func() { - if !testing.Verbose() { - return func() {} - } - numStart := runtime.NumGoroutine() - return func() { - var numNow int - wait := time.Millisecond - started := time.Now() - for range iter.N(10) { // 1 second - numNow = runtime.NumGoroutine() - if numNow <= numStart { - break - } - t.Logf("%d excess goroutines after %s", numNow-numStart, time.Since(started)) - time.Sleep(wait) - wait *= 2 - } - // I'd print stacks, or treat this as fatal, but I think - // runtime.NumGoroutine is including system routines for which we are - // not provided the stacks, and are spawned unpredictably. - t.Logf("have %d goroutines, started with %d", numNow, numStart) - // select {} - } -} diff --git a/vendor/github.com/anacrolix/missinggo/hostmaybeport_test.go b/vendor/github.com/anacrolix/missinggo/hostmaybeport_test.go deleted file mode 100644 index 9ba611e89..000000000 --- a/vendor/github.com/anacrolix/missinggo/hostmaybeport_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package missinggo - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestSplitHostMaybePortNoPort(t *testing.T) { - hmp := SplitHostMaybePort("some.domain") - assert.Equal(t, "some.domain", hmp.Host) - assert.True(t, hmp.NoPort) - assert.NoError(t, hmp.Err) -} - -func TestSplitHostMaybePortPort(t *testing.T) { - hmp := SplitHostMaybePort("some.domain:123") - assert.Equal(t, "some.domain", hmp.Host) - assert.Equal(t, 123, hmp.Port) - assert.False(t, hmp.NoPort) - assert.NoError(t, hmp.Err) -} - -func TestSplitHostMaybePortBadPort(t *testing.T) { - hmp := SplitHostMaybePort("some.domain:wat") - assert.Equal(t, "some.domain", hmp.Host) - assert.Equal(t, -1, hmp.Port) - assert.False(t, hmp.NoPort) - assert.Error(t, hmp.Err) -} diff --git a/vendor/github.com/anacrolix/missinggo/httpfile/defaultfs.go b/vendor/github.com/anacrolix/missinggo/httpfile/defaultfs.go deleted file mode 100644 index d1e2adfe3..000000000 --- a/vendor/github.com/anacrolix/missinggo/httpfile/defaultfs.go +++ /dev/null @@ -1,14 +0,0 @@ -package httpfile - -import ( - "net/http" -) - -var DefaultFS = &FS{ - Client: http.DefaultClient, -} - -// Returns the length of the resource in bytes. -func GetLength(url string) (ret int64, err error) { - return DefaultFS.GetLength(url) -} diff --git a/vendor/github.com/anacrolix/missinggo/httpfile/file.go b/vendor/github.com/anacrolix/missinggo/httpfile/file.go deleted file mode 100644 index a4f646e4d..000000000 --- a/vendor/github.com/anacrolix/missinggo/httpfile/file.go +++ /dev/null @@ -1,167 +0,0 @@ -package httpfile - -import ( - "bytes" - "errors" - "fmt" - "io" - "net/http" - "os" - "strconv" - - "github.com/anacrolix/missinggo" - "github.com/anacrolix/missinggo/httptoo" -) - -type File struct { - off int64 - r io.ReadCloser - rOff int64 - length int64 - url string - flags int - fs *FS -} - -func (me *File) headLength() (err error) { - l, err := me.fs.GetLength(me.url) - if err != nil { - return - } - if l != -1 { - me.length = l - } - return -} - -func (me *File) prepareReader() (err error) { - if me.r != nil && me.off != me.rOff { - me.r.Close() - me.r = nil - } - if me.r != nil { - return nil - } - if me.flags&missinggo.O_ACCMODE == os.O_WRONLY { - err = errors.New("read flags missing") - return - } - req, err := http.NewRequest("GET", me.url, nil) - if err != nil { - return - } - if me.off != 0 { - req.Header.Set("Range", fmt.Sprintf("bytes=%d-", me.off)) - } - resp, err := me.fs.Client.Do(req) - if err != nil { - return - } - switch resp.StatusCode { - case http.StatusPartialContent: - cr, ok := httptoo.ParseBytesContentRange(resp.Header.Get("Content-Range")) - if !ok || cr.First != me.off { - err = errors.New("bad response") - resp.Body.Close() - return - } - me.length = cr.Length - case http.StatusOK: - if me.off != 0 { - err = errors.New("bad response") - resp.Body.Close() - return - } - if h := resp.Header.Get("Content-Length"); h != "" { - var cl uint64 - cl, err = strconv.ParseUint(h, 10, 64) - if err != nil { - resp.Body.Close() - return - } - me.length = int64(cl) - } - case http.StatusNotFound: - err = ErrNotFound - resp.Body.Close() - return - default: - err = errors.New(resp.Status) - resp.Body.Close() - return - } - me.r = resp.Body - me.rOff = me.off - return -} - -func (me *File) Read(b []byte) (n int, err error) { - err = me.prepareReader() - if err != nil { - return - } - n, err = me.r.Read(b) - me.off += int64(n) - me.rOff += int64(n) - return -} - -func (me *File) Seek(offset int64, whence int) (ret int64, err error) { - switch whence { - case os.SEEK_SET: - ret = offset - case os.SEEK_CUR: - ret = me.off + offset - case os.SEEK_END: - // Try to update the resource length. - err = me.headLength() - if err != nil { - if me.length == -1 { - // Don't even have an old value. - return - } - err = nil - } - ret = me.length + offset - default: - err = fmt.Errorf("unhandled whence: %d", whence) - return - } - me.off = ret - return -} - -func (me *File) Write(b []byte) (n int, err error) { - if me.flags&(os.O_WRONLY|os.O_RDWR) == 0 || me.flags&os.O_CREATE == 0 { - err = errors.New("cannot write without write and create flags") - return - } - req, err := http.NewRequest("PATCH", me.url, bytes.NewReader(b)) - if err != nil { - return - } - req.Header.Set("Content-Range", fmt.Sprintf("bytes=%d-", me.off)) - req.ContentLength = int64(len(b)) - resp, err := me.fs.Client.Do(req) - if err != nil { - return - } - resp.Body.Close() - if resp.StatusCode != http.StatusPartialContent { - err = errors.New(resp.Status) - return - } - n = len(b) - me.off += int64(n) - return -} - -func (me *File) Close() error { - me.url = "" - me.length = -1 - if me.r != nil { - me.r.Close() - me.r = nil - } - return nil -} diff --git a/vendor/github.com/anacrolix/missinggo/httpfile/fs.go b/vendor/github.com/anacrolix/missinggo/httpfile/fs.go deleted file mode 100644 index be6bec16a..000000000 --- a/vendor/github.com/anacrolix/missinggo/httpfile/fs.go +++ /dev/null @@ -1,82 +0,0 @@ -package httpfile - -import ( - "fmt" - "io" - "net/http" - "os" -) - -type FS struct { - Client *http.Client -} - -func (fs *FS) Delete(urlStr string) (err error) { - req, err := http.NewRequest("DELETE", urlStr, nil) - if err != nil { - return - } - resp, err := fs.Client.Do(req) - if err != nil { - return - } - resp.Body.Close() - if resp.StatusCode == http.StatusNotFound { - err = ErrNotFound - return - } - if resp.StatusCode != 200 { - err = fmt.Errorf("response: %s", resp.Status) - } - return -} - -func (fs *FS) GetLength(url string) (ret int64, err error) { - resp, err := fs.Client.Head(url) - if err != nil { - return - } - resp.Body.Close() - if resp.StatusCode == http.StatusNotFound { - err = ErrNotFound - return - } - return instanceLength(resp) -} - -func (fs *FS) OpenSectionReader(url string, off, n int64) (ret io.ReadCloser, err error) { - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return - } - req.Header.Set("Range", fmt.Sprintf("bytes=%d-%d", off, off+n-1)) - resp, err := fs.Client.Do(req) - if err != nil { - return - } - if resp.StatusCode == http.StatusNotFound { - err = ErrNotFound - resp.Body.Close() - return - } - if resp.StatusCode != http.StatusPartialContent { - err = fmt.Errorf("bad response status: %s", resp.Status) - resp.Body.Close() - return - } - ret = resp.Body - return -} - -func (fs *FS) Open(url string, flags int) (ret *File, err error) { - ret = &File{ - url: url, - flags: flags, - length: -1, - fs: fs, - } - if flags&os.O_CREATE == 0 { - err = ret.headLength() - } - return -} diff --git a/vendor/github.com/anacrolix/missinggo/httpfile/misc.go b/vendor/github.com/anacrolix/missinggo/httpfile/misc.go deleted file mode 100644 index 25ed2e44b..000000000 --- a/vendor/github.com/anacrolix/missinggo/httpfile/misc.go +++ /dev/null @@ -1,33 +0,0 @@ -package httpfile - -import ( - "errors" - "net/http" - "os" - "strconv" - - "github.com/anacrolix/missinggo/httptoo" -) - -var ( - ErrNotFound = os.ErrNotExist -) - -// ok is false if the response just doesn't specify anything we handle. -func instanceLength(r *http.Response) (l int64, err error) { - switch r.StatusCode { - case http.StatusOK: - l, err = strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64) - return - case http.StatusPartialContent: - cr, parseOk := httptoo.ParseBytesContentRange(r.Header.Get("Content-Range")) - l = cr.Length - if !parseOk { - err = errors.New("error parsing Content-Range") - } - return - default: - err = errors.New("unhandled status code") - return - } -} diff --git a/vendor/github.com/anacrolix/missinggo/httpmux/httpmux.go b/vendor/github.com/anacrolix/missinggo/httpmux/httpmux.go deleted file mode 100644 index e9d68f39d..000000000 --- a/vendor/github.com/anacrolix/missinggo/httpmux/httpmux.go +++ /dev/null @@ -1,119 +0,0 @@ -package httpmux - -import ( - "fmt" - "net/http" - "path" - "regexp" - "strings" - - "golang.org/x/net/context" -) - -var pathParamContextKey = &struct{}{} - -type Mux struct { - handlers []handler -} - -func New() *Mux { - return new(Mux) -} - -type handler struct { - path *regexp.Regexp - userHandler http.Handler -} - -func (me *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request) { - matches := me.matchingHandlers(r) - if len(matches) == 0 { - http.NotFound(w, r) - return - } - m := matches[0] - r = r.WithContext(context.WithValue(r.Context(), pathParamContextKey, &PathParams{m})) - m.handler.userHandler.ServeHTTP(w, r) -} - -type match struct { - handler handler - submatches []string -} - -func (me *Mux) matchingHandlers(r *http.Request) (ret []match) { - for _, h := range me.handlers { - subs := h.path.FindStringSubmatch(r.URL.Path) - if subs == nil { - continue - } - ret = append(ret, match{h, subs}) - } - return -} - -func (me *Mux) distinctHandlerRegexp(r *regexp.Regexp) bool { - for _, h := range me.handlers { - if h.path.String() == r.String() { - return false - } - } - return true -} - -func (me *Mux) Handle(path string, h http.Handler) { - expr := "^" + path - if !strings.HasSuffix(expr, "$") { - expr += "$" - } - re, err := regexp.Compile(expr) - if err != nil { - panic(err) - } - if !me.distinctHandlerRegexp(re) { - panic(fmt.Sprintf("path %q is not distinct", path)) - } - me.handlers = append(me.handlers, handler{re, h}) -} - -func (me *Mux) HandleFunc(path string, hf func(http.ResponseWriter, *http.Request)) { - me.Handle(path, http.HandlerFunc(hf)) -} - -func Path(parts ...string) string { - return path.Join(parts...) -} - -type PathParams struct { - match match -} - -func (me *PathParams) ByName(name string) string { - for i, sn := range me.match.handler.path.SubexpNames()[1:] { - if sn == name { - return me.match.submatches[i+1] - } - } - return "" -} - -func RequestPathParams(r *http.Request) *PathParams { - ctx := r.Context() - return ctx.Value(pathParamContextKey).(*PathParams) -} - -func PathRegexpParam(name string, re string) string { - return fmt.Sprintf("(?P<%s>%s)", name, re) -} - -func Param(name string) string { - return fmt.Sprintf("(?P<%s>[^/]+)", name) -} - -func RestParam(name string) string { - return fmt.Sprintf("(?P<%s>.*)$", name) -} - -func NonEmptyRestParam(name string) string { - return fmt.Sprintf("(?P<%s>.+)$", name) -} diff --git a/vendor/github.com/anacrolix/missinggo/httptoo/bytes_content_range_test.go b/vendor/github.com/anacrolix/missinggo/httptoo/bytes_content_range_test.go deleted file mode 100644 index 55eac2b8a..000000000 --- a/vendor/github.com/anacrolix/missinggo/httptoo/bytes_content_range_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package httptoo - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestParseHTTPContentRange(t *testing.T) { - for _, _case := range []struct { - h string - cr *BytesContentRange - }{ - {"", nil}, - {"1-2/*", nil}, - {"bytes=1-2/3", &BytesContentRange{1, 2, 3}}, - {"bytes=12-34/*", &BytesContentRange{12, 34, -1}}, - {" bytes=12-34/*", &BytesContentRange{12, 34, -1}}, - {" bytes 12-34/56", &BytesContentRange{12, 34, 56}}, - {" bytes=*/56", &BytesContentRange{-1, -1, 56}}, - } { - ret, ok := ParseBytesContentRange(_case.h) - assert.Equal(t, _case.cr != nil, ok) - if _case.cr != nil { - assert.Equal(t, *_case.cr, ret) - } - } -} diff --git a/vendor/github.com/anacrolix/missinggo/httptoo/closenotify.go b/vendor/github.com/anacrolix/missinggo/httptoo/closenotify.go deleted file mode 100644 index 95adfdbf3..000000000 --- a/vendor/github.com/anacrolix/missinggo/httptoo/closenotify.go +++ /dev/null @@ -1,29 +0,0 @@ -package httptoo - -import ( - "context" - "net/http" -) - -var closeNotifyContextKey = new(struct{}) - -func RequestWithCloseNotify(r *http.Request, w http.ResponseWriter) *http.Request { - if r.Context().Value(closeNotifyContextKey) != nil { - return r - } - v := make(chan struct{}) - r = r.WithContext(context.WithValue(r.Context(), closeNotifyContextKey, v)) - cn := w.(http.CloseNotifier).CloseNotify() - go func() { - select { - case <-cn: - close(v) - case <-r.Context().Done(): - } - }() - return r -} - -func RequestCloseNotifyValue(r *http.Request) <-chan struct{} { - return r.Context().Value(closeNotifyContextKey).(chan struct{}) -} diff --git a/vendor/github.com/anacrolix/missinggo/httptoo/gzip_test.go b/vendor/github.com/anacrolix/missinggo/httptoo/gzip_test.go deleted file mode 100644 index 448040945..000000000 --- a/vendor/github.com/anacrolix/missinggo/httptoo/gzip_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package httptoo - -import ( - "compress/gzip" - "io/ioutil" - "net/http" - "net/http/httptest" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -const helloWorld = "hello, world\n" - -func helloWorldHandler(w http.ResponseWriter, r *http.Request) { - // w.Header().Set("Content-Length", strconv.FormatInt(int64(len(helloWorld)), 10)) - w.Write([]byte(helloWorld)) -} - -func requestResponse(h http.Handler, r *http.Request) (*http.Response, error) { - s := httptest.NewServer(h) - defer s.Close() - return http.DefaultClient.Do(r) -} - -func TestGzipHandler(t *testing.T) { - rr := httptest.NewRecorder() - helloWorldHandler(rr, nil) - assert.EqualValues(t, helloWorld, rr.Body.String()) - - rr = httptest.NewRecorder() - GzipHandler(http.HandlerFunc(helloWorldHandler)).ServeHTTP(rr, new(http.Request)) - assert.EqualValues(t, helloWorld, rr.Body.String()) - - rr = httptest.NewRecorder() - r, err := http.NewRequest("GET", "/", nil) - require.NoError(t, err) - r.Header.Set("Accept-Encoding", "gzip") - GzipHandler(http.HandlerFunc(helloWorldHandler)).ServeHTTP(rr, r) - gr, err := gzip.NewReader(rr.Body) - require.NoError(t, err) - defer gr.Close() - b, err := ioutil.ReadAll(gr) - require.NoError(t, err) - assert.EqualValues(t, helloWorld, b) - - s := httptest.NewServer(nil) - s.Config.Handler = GzipHandler(http.HandlerFunc(helloWorldHandler)) - req, err := http.NewRequest("GET", s.URL, nil) - req.Header.Set("Accept-Encoding", "gzip") - resp, err := http.DefaultClient.Do(req) - require.NoError(t, err) - gr.Close() - gr, err = gzip.NewReader(resp.Body) - require.NoError(t, err) - defer gr.Close() - b, err = ioutil.ReadAll(gr) - require.NoError(t, err) - assert.EqualValues(t, helloWorld, b) - assert.EqualValues(t, "text/plain; charset=utf-8", resp.Header.Get("Content-Type")) - assert.EqualValues(t, "gzip", resp.Header.Get("Content-Encoding")) -} diff --git a/vendor/github.com/anacrolix/missinggo/httptoo/headers_test.go b/vendor/github.com/anacrolix/missinggo/httptoo/headers_test.go deleted file mode 100644 index 547d01d7e..000000000 --- a/vendor/github.com/anacrolix/missinggo/httptoo/headers_test.go +++ /dev/null @@ -1,15 +0,0 @@ -package httptoo - -import ( - "testing" - "time" - - "github.com/stretchr/testify/assert" -) - -func TestCacheControlHeaderString(t *testing.T) { - assert.Equal(t, "public, max-age=43200", CacheControlHeader{ - MaxAge: 12 * time.Hour, - Caching: Public, - }.String()) -} diff --git a/vendor/github.com/anacrolix/missinggo/httptoo/inproc_roundtrip.go b/vendor/github.com/anacrolix/missinggo/httptoo/inproc_roundtrip.go index 13b561e23..22b5f2e14 100644 --- a/vendor/github.com/anacrolix/missinggo/httptoo/inproc_roundtrip.go +++ b/vendor/github.com/anacrolix/missinggo/httptoo/inproc_roundtrip.go @@ -1,6 +1,7 @@ package httptoo import ( + "context" "io" "net/http" "sync" @@ -13,18 +14,20 @@ type responseWriter struct { r http.Response headerWritten missinggo.Event bodyWriter io.WriteCloser - closed missinggo.SynchronizedEvent + bodyClosed missinggo.SynchronizedEvent } var _ interface { http.ResponseWriter + // We're able to emulate this easily enough. http.CloseNotifier } = &responseWriter{} +// Use Request.Context.Done instead. func (me *responseWriter) CloseNotify() <-chan bool { ret := make(chan bool, 1) go func() { - <-me.closed.C() + <-me.bodyClosed.C() ret <- true }() return ret @@ -66,10 +69,20 @@ func (me *responseWriter) runHandler(h http.Handler, req *http.Request) { me.r.Body = struct { io.Reader io.Closer - }{pr, eventCloser{pr, &me.closed}} + }{pr, eventCloser{pr, &me.bodyClosed}} + // Shouldn't be writing to the response after the handler returns. defer me.bodyWriter.Close() + // Send a 200 if nothing was written yet. defer me.WriteHeader(200) - h.ServeHTTP(me, req) + // Wrap the context in the given Request with one that closes when either + // the handler returns, or the response body is closed. + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + go func() { + <-me.bodyClosed.C() + cancel() + }() + h.ServeHTTP(me, req.WithContext(ctx)) } type eventCloser struct { diff --git a/vendor/github.com/anacrolix/missinggo/httptoo/url.go b/vendor/github.com/anacrolix/missinggo/httptoo/url.go index ea618fe3b..3f90d4dda 100644 --- a/vendor/github.com/anacrolix/missinggo/httptoo/url.go +++ b/vendor/github.com/anacrolix/missinggo/httptoo/url.go @@ -3,10 +3,11 @@ package httptoo import ( "net/http" "net/url" - "path" ) -// Deep copies a URL. +// Deep copies a URL. I could call it DeepCopyURL, but what else would you be +// copying when you have a *url.URL? Of note is that the Userinfo is deep +// copied. The returned URL shares no references with the original. func CopyURL(u *url.URL) (ret *url.URL) { ret = new(url.URL) *ret = *u @@ -26,6 +27,9 @@ func RequestedURL(r *http.Request) (ret *url.URL) { return } +// The official URL struct parameters, for tracking changes and reference +// here. +// // Scheme string // Opaque string // encoded opaque data // User *Userinfo // username and password information @@ -35,15 +39,16 @@ func RequestedURL(r *http.Request) (ret *url.URL) { // ForceQuery bool // append a query ('?') even if RawQuery is empty // RawQuery string // encoded query values, without '?' // Fragment string // fragment for references, without '#' -// } // Return the first URL extended with elements of the second, in the manner -// that occurs throughout my projects. +// that occurs throughout my projects. Noteworthy difference from +// url.URL.ResolveReference is that if the reference has a scheme, the base is +// not completely ignored. func AppendURL(u, v *url.URL) *url.URL { u = CopyURL(u) clobberString(&u.Scheme, v.Scheme) clobberString(&u.Host, v.Host) - u.Path = path.Join(u.Path, v.Path) + u.Path += v.Path q := u.Query() for k, v := range v.Query() { q[k] = append(q[k], v...) diff --git a/vendor/github.com/anacrolix/missinggo/inproc/inproc.go b/vendor/github.com/anacrolix/missinggo/inproc/inproc.go index 601074afc..7c7427415 100644 --- a/vendor/github.com/anacrolix/missinggo/inproc/inproc.go +++ b/vendor/github.com/anacrolix/missinggo/inproc/inproc.go @@ -19,15 +19,15 @@ var ( conns = map[int]*packetConn{} ) -type addr struct { +type Addr struct { Port int } -func (addr) Network() string { +func (Addr) Network() string { return "inproc" } -func (me addr) String() string { +func (me Addr) String() string { return ":" + strconv.FormatInt(int64(me.Port), 10) } @@ -43,7 +43,7 @@ func ResolveAddr(network, str string) (net.Addr, error) { return ResolveInprocAddr(network, str) } -func ResolveInprocAddr(network, str string) (addr addr, err error) { +func ResolveInprocAddr(network, str string) (addr Addr, err error) { if str == "" { addr.Port = getPort() return @@ -86,12 +86,12 @@ func ListenPacket(network, addrStr string) (nc net.PacketConn, err error) { type packet struct { data []byte - addr addr + addr Addr } type packetConn struct { closed bool - addr addr + addr Addr reads []packet readDeadline *condDeadline writeDeadline *condDeadline diff --git a/vendor/github.com/anacrolix/missinggo/iter/chain.go b/vendor/github.com/anacrolix/missinggo/iter/chain.go new file mode 100644 index 000000000..6050a688d --- /dev/null +++ b/vendor/github.com/anacrolix/missinggo/iter/chain.go @@ -0,0 +1,11 @@ +package iter + +func Chain(fs ...Func) Func { + return func(cb Callback) { + for _, f := range fs { + if !All(cb, f) { + break + } + } + } +} diff --git a/vendor/github.com/anacrolix/missinggo/iter/func.go b/vendor/github.com/anacrolix/missinggo/iter/func.go new file mode 100644 index 000000000..8817abe78 --- /dev/null +++ b/vendor/github.com/anacrolix/missinggo/iter/func.go @@ -0,0 +1,19 @@ +package iter + +type Callback func(interface{}) bool + +type Func func(Callback) + +func All(cb Callback, fs ...Func) bool { + for _, f := range fs { + all := true + f(func(v interface{}) bool { + all = all && cb(v) + return all + }) + if !all { + return false + } + } + return true +} diff --git a/vendor/github.com/anacrolix/missinggo/iter/groupby_test.go b/vendor/github.com/anacrolix/missinggo/iter/groupby_test.go deleted file mode 100644 index 07191ed6e..000000000 --- a/vendor/github.com/anacrolix/missinggo/iter/groupby_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package iter - -import ( - "testing" - - "github.com/anacrolix/missinggo/slices" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestGroupByKey(t *testing.T) { - var ks []byte - gb := GroupBy(StringIterator("AAAABBBCCDAABBB"), nil) - for gb.Next() { - ks = append(ks, gb.Value().(Group).Key().(byte)) - } - t.Log(ks) - require.EqualValues(t, "ABCDAB", ks) -} - -func TestGroupByList(t *testing.T) { - var gs []string - gb := GroupBy(StringIterator("AAAABBBCCD"), nil) - for gb.Next() { - i := gb.Value().(Iterator) - var g string - for i.Next() { - g += string(i.Value().(byte)) - } - gs = append(gs, g) - } - t.Log(gs) -} - -func TestGroupByNiladicKey(t *testing.T) { - const s = "AAAABBBCCD" - gb := GroupBy(StringIterator(s), func(interface{}) interface{} { return nil }) - gb.Next() - var ss []byte - g := ToSlice(gb.Value().(Iterator)) - slices.MakeInto(&ss, g) - assert.Equal(t, s, string(ss)) -} - -func TestNilEqualsNil(t *testing.T) { - assert.False(t, nil == uniqueKey) -} diff --git a/vendor/github.com/anacrolix/missinggo/iter/head.go b/vendor/github.com/anacrolix/missinggo/iter/head.go new file mode 100644 index 000000000..0f76f6b72 --- /dev/null +++ b/vendor/github.com/anacrolix/missinggo/iter/head.go @@ -0,0 +1,16 @@ +package iter + +func Head(n int, f Func) Func { + return func(cb Callback) { + if n <= 0 { + return + } + f(func(v interface{}) bool { + n-- + if !cb(v) { + return false + } + return n > 0 + }) + } +} diff --git a/vendor/github.com/anacrolix/missinggo/iter/iterable.go b/vendor/github.com/anacrolix/missinggo/iter/iterable.go index f3c4ea079..d8d734c4b 100644 --- a/vendor/github.com/anacrolix/missinggo/iter/iterable.go +++ b/vendor/github.com/anacrolix/missinggo/iter/iterable.go @@ -7,7 +7,7 @@ import ( ) type Iterable interface { - Iter(func(value interface{}) (more bool)) + Iter(Callback) } type iterator struct { diff --git a/vendor/github.com/anacrolix/missinggo/iter/iterator.go b/vendor/github.com/anacrolix/missinggo/iter/iterator.go index acf2da3dd..db6107ffd 100644 --- a/vendor/github.com/anacrolix/missinggo/iter/iterator.go +++ b/vendor/github.com/anacrolix/missinggo/iter/iterator.go @@ -14,6 +14,17 @@ type Iterator interface { Stop() } +func ToFunc(it Iterator) Func { + return func(cb Callback) { + defer it.Stop() + for it.Next() { + if !cb(it.Value()) { + break + } + } + } +} + type sliceIterator struct { slice []interface{} value interface{} @@ -49,9 +60,10 @@ func StringIterator(a string) Iterator { return Slice(slices.ToEmptyInterface(a)) } -func ToSlice(it Iterator) (ret []interface{}) { - for it.Next() { - ret = append(ret, it.Value()) - } +func ToSlice(f Func) (ret []interface{}) { + f(func(v interface{}) bool { + ret = append(ret, v) + return true + }) return } diff --git a/vendor/github.com/anacrolix/missinggo/iter/iterator_test.go b/vendor/github.com/anacrolix/missinggo/iter/iterator_test.go deleted file mode 100644 index 2b9233412..000000000 --- a/vendor/github.com/anacrolix/missinggo/iter/iterator_test.go +++ /dev/null @@ -1,17 +0,0 @@ -package iter - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestIterator(t *testing.T) { - const s = "AAAABBBCCDAABBB" - si := StringIterator(s) - for i := range s { - require.True(t, si.Next()) - require.Equal(t, s[i], si.Value().(byte)) - } - require.False(t, si.Next()) -} diff --git a/vendor/github.com/anacrolix/missinggo/iter/map.go b/vendor/github.com/anacrolix/missinggo/iter/map.go deleted file mode 100644 index c28abbe8c..000000000 --- a/vendor/github.com/anacrolix/missinggo/iter/map.go +++ /dev/null @@ -1,14 +0,0 @@ -package iter - -type map_ struct { - Iterator - f func(interface{}) interface{} -} - -func (me map_) Value() interface{} { - return me.f(me.Iterator.Value()) -} - -func Map(i Iterator, f func(interface{}) interface{}) Iterator { - return map_{i, f} -} diff --git a/vendor/github.com/anacrolix/missinggo/jitter_test.go b/vendor/github.com/anacrolix/missinggo/jitter_test.go deleted file mode 100644 index 221c13dc9..000000000 --- a/vendor/github.com/anacrolix/missinggo/jitter_test.go +++ /dev/null @@ -1,12 +0,0 @@ -package missinggo - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestJitterDuration(t *testing.T) { - assert.Zero(t, JitterDuration(0, 0)) - assert.Panics(t, func() { JitterDuration(1, -1) }) -} diff --git a/vendor/github.com/anacrolix/missinggo/monotonic_test.go b/vendor/github.com/anacrolix/missinggo/monotonic_test.go deleted file mode 100644 index 988d9f137..000000000 --- a/vendor/github.com/anacrolix/missinggo/monotonic_test.go +++ /dev/null @@ -1,52 +0,0 @@ -package missinggo - -import ( - "testing" - "time" - - "github.com/stretchr/testify/assert" -) - -// Calls suite with the used time.Now function used by MonotonicNow replaced -// with stdNow for the duration of the call. -func withCustomStdNow(stdNow func() time.Time, suite func()) { - oldStdNow := stdNowFunc - oldSkew := monotonicSkew - defer func() { - stdNowFunc = oldStdNow - monotonicSkew = oldSkew - }() - stdNowFunc = stdNow - suite() -} - -// Returns a time.Now-like function that walks seq returning time.Unix(0, -// seq[i]) in successive calls. -func stdNowSeqFunc(seq []int64) func() time.Time { - var i int - return func() time.Time { - defer func() { i++ }() - return time.Unix(0, seq[i]) - } -} - -func TestMonotonicTime(t *testing.T) { - started := MonotonicNow() - withCustomStdNow(stdNowSeqFunc([]int64{2, 1, 3, 3, 2, 3}), func() { - i0 := MonotonicNow() // 0 - i1 := MonotonicNow() // 1 - assert.EqualValues(t, 0, i0.Sub(i1)) - assert.EqualValues(t, 2, MonotonicSince(i0)) // 2 - assert.EqualValues(t, 2, MonotonicSince(i1)) // 3 - i4 := MonotonicNow() - assert.EqualValues(t, 2, i4.Sub(i0)) - assert.EqualValues(t, 2, i4.Sub(i1)) - i5 := MonotonicNow() - assert.EqualValues(t, 3, i5.Sub(i0)) - assert.EqualValues(t, 3, i5.Sub(i1)) - assert.EqualValues(t, 1, i5.Sub(i4)) - }) - // Ensure that skew and time function are restored correctly and within - // reasonable bounds. - assert.True(t, MonotonicSince(started) >= 0 && MonotonicSince(started) < time.Second) -} diff --git a/vendor/github.com/anacrolix/missinggo/orderedmap/google_btree.go b/vendor/github.com/anacrolix/missinggo/orderedmap/google_btree.go index bc6988ba5..f34793767 100644 --- a/vendor/github.com/anacrolix/missinggo/orderedmap/google_btree.go +++ b/vendor/github.com/anacrolix/missinggo/orderedmap/google_btree.go @@ -1,6 +1,9 @@ package orderedmap -import "github.com/google/btree" +import ( + "github.com/anacrolix/missinggo/iter" + "github.com/google/btree" +) type GoogleBTree struct { bt *btree.BTree @@ -81,7 +84,7 @@ func (me *googleBTreeIter) Stop() { me.i = nil } -func (me *GoogleBTree) Iter(f func(value interface{}) bool) { +func (me *GoogleBTree) Iter(f iter.Callback) { me.bt.Ascend(func(i btree.Item) bool { return f(i.(*googleBTreeItem).value) }) diff --git a/vendor/github.com/anacrolix/missinggo/orderedmap/orderedmap_test.go b/vendor/github.com/anacrolix/missinggo/orderedmap/orderedmap_test.go deleted file mode 100644 index bc8da4e4e..000000000 --- a/vendor/github.com/anacrolix/missinggo/orderedmap/orderedmap_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package orderedmap - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/anacrolix/missinggo/iter" -) - -func slice(om OrderedMap) (ret []interface{}) { - om.Iter(func(i interface{}) bool { - ret = append(ret, i) - return true - }) - return -} - -func TestSimple(t *testing.T) { - om := New(func(l, r interface{}) bool { - return l.(int) < r.(int) - }) - om.Set(3, 1) - om.Set(2, 2) - om.Set(1, 3) - assert.EqualValues(t, []interface{}{3, 2, 1}, slice(om)) - om.Set(3, 2) - om.Unset(2) - assert.EqualValues(t, []interface{}{3, 2}, slice(om)) - om.Set(-1, 4) - assert.EqualValues(t, []interface{}{4, 3, 2}, slice(om)) -} - -func TestIterEmpty(t *testing.T) { - om := New(nil) - it := iter.NewIterator(om) - assert.Panics(t, func() { it.Value() }) - assert.False(t, it.Next()) - it.Stop() -} diff --git a/vendor/github.com/anacrolix/missinggo/path_test.go b/vendor/github.com/anacrolix/missinggo/path_test.go deleted file mode 100644 index a38aa2e3e..000000000 --- a/vendor/github.com/anacrolix/missinggo/path_test.go +++ /dev/null @@ -1,17 +0,0 @@ -package missinggo - -import ( - "fmt" -) - -func ExamplePathSplitExt() { - fmt.Printf("%q\n", PathSplitExt(".cshrc")) - fmt.Printf("%q\n", PathSplitExt("dir/a.ext")) - fmt.Printf("%q\n", PathSplitExt("dir/.rc")) - fmt.Printf("%q\n", PathSplitExt("home/.secret/file")) - // Output: - // {"" ".cshrc"} - // {"dir/a" ".ext"} - // {"dir/" ".rc"} - // {"home/.secret/file" ""} -} diff --git a/vendor/github.com/anacrolix/missinggo/perf/event.go b/vendor/github.com/anacrolix/missinggo/perf/event.go new file mode 100644 index 000000000..717c17345 --- /dev/null +++ b/vendor/github.com/anacrolix/missinggo/perf/event.go @@ -0,0 +1,31 @@ +package perf + +import ( + "sync" + "time" +) + +type event struct { + mu sync.RWMutex + count int64 + total time.Duration + min time.Duration + max time.Duration +} + +func (e *event) Add(t time.Duration) { + e.mu.Lock() + defer e.mu.Unlock() + if t > e.max { + e.max = t + } + if e.min == 0 || t < e.min { + e.min = t + } + e.count++ + e.total += t +} + +func (e *event) mean() time.Duration { + return e.total / time.Duration(e.count) +} diff --git a/vendor/github.com/anacrolix/missinggo/perf/events.go b/vendor/github.com/anacrolix/missinggo/perf/events.go new file mode 100644 index 000000000..8745fb585 --- /dev/null +++ b/vendor/github.com/anacrolix/missinggo/perf/events.go @@ -0,0 +1,47 @@ +package perf + +import ( + "fmt" + "io" + "net/http" + "sort" + "sync" + "text/tabwriter" +) + +var ( + mu sync.RWMutex + events = map[string]*event{} +) + +func init() { + http.HandleFunc("/debug/perf", func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/plain; charset=UTF-8") + WriteEventsTable(w) + }) +} + +func WriteEventsTable(w io.Writer) { + tw := tabwriter.NewWriter(w, 0, 0, 2, ' ', 0) + fmt.Fprint(tw, "description\tcount\tmin\tmean\tmax\n") + type t struct { + d string + e *event + } + mu.RLock() + es := make([]t, 0, len(events)) + for d, e := range events { + e.mu.RLock() + es = append(es, t{d, e}) + defer e.mu.RUnlock() + } + mu.RUnlock() + sort.Slice(es, func(i, j int) bool { + return es[i].e.mean() < es[j].e.mean() + }) + for _, el := range es { + e := el.e + fmt.Fprintf(tw, "%s\t%d\t%s\t%s\t%s\n", el.d, e.count, e.min, e.mean(), e.max) + } + tw.Flush() +} diff --git a/vendor/github.com/anacrolix/missinggo/perf/mutex.go b/vendor/github.com/anacrolix/missinggo/perf/mutex.go index 77d1ad8f2..c4ac0d994 100644 --- a/vendor/github.com/anacrolix/missinggo/perf/mutex.go +++ b/vendor/github.com/anacrolix/missinggo/perf/mutex.go @@ -14,7 +14,7 @@ type TimedLocker struct { func (me *TimedLocker) Lock() { tr := NewTimer() me.L.Lock() - tr.Stop(me.Desc) + tr.Mark(me.Desc) } func (me *TimedLocker) Unlock() { @@ -30,7 +30,7 @@ type TimedRWLocker struct { func (me *TimedRWLocker) Lock() { tr := NewTimer() me.RWL.Lock() - tr.Stop(me.WriteDesc) + tr.Mark(me.WriteDesc) } func (me *TimedRWLocker) Unlock() { @@ -40,7 +40,7 @@ func (me *TimedRWLocker) Unlock() { func (me *TimedRWLocker) RLock() { tr := NewTimer() me.RWL.RLock() - tr.Stop(me.ReadDesc) + tr.Mark(me.ReadDesc) } func (me *TimedRWLocker) RUnlock() { diff --git a/vendor/github.com/anacrolix/missinggo/perf/perf.go b/vendor/github.com/anacrolix/missinggo/perf/perf.go deleted file mode 100644 index 19f1c523a..000000000 --- a/vendor/github.com/anacrolix/missinggo/perf/perf.go +++ /dev/null @@ -1,103 +0,0 @@ -package perf - -import ( - "bytes" - "expvar" - "fmt" - "math" - "sync" - "time" - - "github.com/anacrolix/missinggo" -) - -var ( - em = missinggo.NewExpvarIndentMap("perfBuckets") - mu sync.RWMutex -) - -type Timer struct { - started time.Time -} - -func NewTimer() Timer { - return Timer{time.Now()} -} - -// The exponent is the upper bound of the duration in seconds. -func bucketExponent(d time.Duration) int { - e := -9 - for d != 0 { - d /= 10 - e++ - } - return e -} - -type buckets struct { - mu sync.Mutex - buckets []int64 -} - -func (me *buckets) Add(t time.Duration) { - e := bucketExponent(t) - me.mu.Lock() - for e+9 >= len(me.buckets) { - me.buckets = append(me.buckets, 0) - } - me.buckets[e+9]++ - me.mu.Unlock() -} - -func humanExponent(e int) string { - if e == -9 { - return "<1ns" - } - return ">" + time.Duration(math.Pow10(e-1)).String() -} - -func (me *buckets) String() string { - var b bytes.Buffer - fmt.Fprintf(&b, "{") - first := true - me.mu.Lock() - for i, count := range me.buckets { - if first { - if count == 0 { - continue - } - first = false - } else { - fmt.Fprintf(&b, ", ") - } - fmt.Fprintf(&b, "%q: %d", humanExponent(i), count) - } - me.mu.Unlock() - fmt.Fprintf(&b, "}") - return b.String() -} - -var _ expvar.Var = &buckets{} - -func (t *Timer) Stop(desc string) time.Duration { - d := time.Since(t.started) - t.addDuration(desc, d) - return d -} - -func (t *Timer) addDuration(desc string, d time.Duration) { - mu.RLock() - _m := em.Get(desc) - mu.RUnlock() - if _m == nil { - mu.Lock() - _m = em.Get(desc) - if _m == nil { - _m = new(buckets) - em.Set(desc, _m) - } - mu.Unlock() - } - m := _m.(*buckets) - m.Add(d) -} diff --git a/vendor/github.com/anacrolix/missinggo/perf/perf_test.go b/vendor/github.com/anacrolix/missinggo/perf/perf_test.go deleted file mode 100644 index 7d582a960..000000000 --- a/vendor/github.com/anacrolix/missinggo/perf/perf_test.go +++ /dev/null @@ -1,52 +0,0 @@ -package perf - -import ( - "fmt" - "strconv" - "testing" - "time" - - "github.com/bradfitz/iter" - "github.com/stretchr/testify/assert" -) - -func TestTimer(t *testing.T) { - tr := NewTimer() - tr.Stop("hiyo") - tr.Stop("hiyo") - t.Log(em.Get("hiyo").(*buckets)) -} - -func BenchmarkStopWarm(b *testing.B) { - tr := NewTimer() - for range iter.N(b.N) { - tr.Stop("a") - } -} - -func BenchmarkStopCold(b *testing.B) { - tr := NewTimer() - for i := range iter.N(b.N) { - tr.Stop(strconv.FormatInt(int64(i), 10)) - } -} - -func TestExponent(t *testing.T) { - for _, c := range []struct { - e int - d time.Duration - }{ - {-1, 10 * time.Millisecond}, - {-2, 5 * time.Millisecond}, - {-2, time.Millisecond}, - {-3, 500 * time.Microsecond}, - {-3, 100 * time.Microsecond}, - } { - tr := NewTimer() - tr.addDuration(fmt.Sprintf("%d", c.e), c.d) - assert.Equal(t, c.e, bucketExponent(c.d)) - } - assert.Equal(t, `{">10ms": 1}`, em.Get("-1").String()) - assert.Equal(t, `{">1ms": 2}`, em.Get("-2").String()) - assert.Equal(t, `{">100µs": 2}`, em.Get("-3").String()) -} diff --git a/vendor/github.com/anacrolix/missinggo/perf/scope.go b/vendor/github.com/anacrolix/missinggo/perf/scope.go new file mode 100644 index 000000000..9df016ef0 --- /dev/null +++ b/vendor/github.com/anacrolix/missinggo/perf/scope.go @@ -0,0 +1,18 @@ +package perf + +import ( + "runtime" +) + +func ScopeTimer(opts ...timerOpt) func() { + t := NewTimer(append([]timerOpt{Name(getCallerName())}, opts...)...) + return func() { t.Mark("returned") } +} + +func getCallerName() string { + var pc [1]uintptr + runtime.Callers(3, pc[:]) + fs := runtime.CallersFrames(pc[:]) + f, _ := fs.Next() + return f.Func.Name() +} diff --git a/vendor/github.com/anacrolix/missinggo/perf/timer.go b/vendor/github.com/anacrolix/missinggo/perf/timer.go new file mode 100644 index 000000000..ae034099f --- /dev/null +++ b/vendor/github.com/anacrolix/missinggo/perf/timer.go @@ -0,0 +1,69 @@ +package perf + +import ( + "log" + "time" +) + +type Timer struct { + started time.Time + log bool + name string +} + +func NewTimer(opts ...timerOpt) (t Timer) { + t.started = time.Now() + for _, o := range opts { + o(&t) + } + if t.log && t.name != "" { + log.Printf("starting timer %q", t.name) + } + return +} + +type timerOpt func(*Timer) + +func Log(t *Timer) { + t.log = true +} + +func Name(name string) func(*Timer) { + return func(t *Timer) { + t.name = name + } +} + +func (t *Timer) Mark(events ...string) time.Duration { + d := time.Since(t.started) + for _, e := range events { + if t.name != "" { + e = t.name + "/" + e + } + t.addDuration(e, d) + } + return d +} + +func (t *Timer) addDuration(desc string, d time.Duration) { + mu.RLock() + e := events[desc] + mu.RUnlock() + if e == nil { + mu.Lock() + e = events[desc] + if e == nil { + e = new(event) + events[desc] = e + } + mu.Unlock() + } + e.Add(d) + if t.log { + if t.name != "" { + log.Printf("timer %q got event %q after %s", t.name, desc, d) + } else { + log.Printf("marking event %q after %s", desc, d) + } + } +} diff --git a/vendor/github.com/anacrolix/missinggo/prioritybitmap/iter.go b/vendor/github.com/anacrolix/missinggo/prioritybitmap/iter.go deleted file mode 100644 index 84276ee78..000000000 --- a/vendor/github.com/anacrolix/missinggo/prioritybitmap/iter.go +++ /dev/null @@ -1,7 +0,0 @@ -package prioritybitmap - -import "github.com/anacrolix/missinggo/iter" - -type Iter struct { - it iter.Iterator -} diff --git a/vendor/github.com/anacrolix/missinggo/prioritybitmap/prioritybitmap.go b/vendor/github.com/anacrolix/missinggo/prioritybitmap/prioritybitmap.go index 525eb0a8c..8630b57aa 100644 --- a/vendor/github.com/anacrolix/missinggo/prioritybitmap/prioritybitmap.go +++ b/vendor/github.com/anacrolix/missinggo/prioritybitmap/prioritybitmap.go @@ -5,6 +5,7 @@ package prioritybitmap import ( "sync" + "github.com/anacrolix/missinggo/iter" "github.com/anacrolix/missinggo/orderedmap" ) @@ -16,9 +17,10 @@ var ( } ) +// Maintains set of ints ordered by priority. type PriorityBitmap struct { - // Protects against unsychronized modifications to bitsets and mu sync.Mutex + // From priority to singleton or set of bit indices. om orderedmap.OrderedMap // From bit index to priority priorities map[int]int @@ -29,24 +31,31 @@ func (me *PriorityBitmap) Clear() { me.priorities = nil } -func (me *PriorityBitmap) deleteBit(bit int) { - p, ok := me.priorities[bit] +func (me *PriorityBitmap) deleteBit(bit int) (priority int, ok bool) { + priority, ok = me.priorities[bit] if !ok { return } - switch v := me.om.Get(p).(type) { + switch v := me.om.Get(priority).(type) { case int: + if v != bit { + panic("invariant broken") + } case map[int]struct{}: + if _, ok := v[bit]; !ok { + panic("invariant broken") + } delete(v, bit) if len(v) != 0 { return } bitSets.Put(v) } - me.om.Unset(p) + me.om.Unset(priority) if me.om.Len() == 0 { me.om = nil } + return } func bitLess(l, r interface{}) bool { @@ -60,8 +69,14 @@ func (me *PriorityBitmap) lazyInit() { me.priorities = make(map[int]int) } -func (me *PriorityBitmap) Set(bit int, priority int) { - me.deleteBit(bit) +// return value if changed +func (me *PriorityBitmap) Set(bit int, priority int) bool { + if p, ok := me.priorities[bit]; ok && p == priority { + return false + } + if oldPriority, deleted := me.deleteBit(bit); deleted && oldPriority == priority { + panic("should have already returned") + } if me.priorities == nil { me.priorities = make(map[int]int) } @@ -71,8 +86,9 @@ func (me *PriorityBitmap) Set(bit int, priority int) { } _v, ok := me.om.GetOk(priority) if !ok { + // No other bits with this priority, set it to a lone int. me.om.Set(priority, bit) - return + return true } switch v := _v.(type) { case int: @@ -82,13 +98,18 @@ func (me *PriorityBitmap) Set(bit int, priority int) { me.om.Set(priority, newV) case map[int]struct{}: v[bit] = struct{}{} + default: + panic(v) } + return true } -func (me *PriorityBitmap) Remove(bit int) { +func (me *PriorityBitmap) Remove(bit int) bool { me.mu.Lock() defer me.mu.Unlock() - me.deleteBit(bit) + if _, ok := me.deleteBit(bit); !ok { + return false + } delete(me.priorities, bit) if len(me.priorities) == 0 { me.priorities = nil @@ -96,26 +117,27 @@ func (me *PriorityBitmap) Remove(bit int) { if me.om != nil && me.om.Len() == 0 { me.om = nil } + return true } -func (me *PriorityBitmap) Iter(f func(value interface{}) bool) { +func (me *PriorityBitmap) Iter(f iter.Callback) { me.IterTyped(func(i int) bool { return f(i) }) } -func (me *PriorityBitmap) IterTyped(_f func(i int) bool) { +func (me *PriorityBitmap) IterTyped(_f func(i int) bool) bool { me.mu.Lock() defer me.mu.Unlock() if me == nil || me.om == nil { - return + return true } f := func(i int) bool { me.mu.Unlock() defer me.mu.Lock() return _f(i) } - me.om.Iter(func(value interface{}) bool { + return iter.All(func(value interface{}) bool { switch v := value.(type) { case int: return f(v) @@ -127,7 +149,7 @@ func (me *PriorityBitmap) IterTyped(_f func(i int) bool) { } } return true - }) + }, me.om.Iter) } func (me *PriorityBitmap) IsEmpty() bool { diff --git a/vendor/github.com/anacrolix/missinggo/prioritybitmap/prioritybitmap_test.go b/vendor/github.com/anacrolix/missinggo/prioritybitmap/prioritybitmap_test.go deleted file mode 100644 index d2e956c5a..000000000 --- a/vendor/github.com/anacrolix/missinggo/prioritybitmap/prioritybitmap_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package prioritybitmap - -import ( - "math" - "testing" - "time" - - "github.com/stretchr/testify/assert" - - "github.com/anacrolix/missinggo/iter" -) - -func TestEmpty(t *testing.T) { - var pb PriorityBitmap - it := iter.NewIterator(&pb) - assert.Panics(t, func() { it.Value() }) - assert.False(t, it.Next()) -} - -func TestIntBounds(t *testing.T) { - var pb PriorityBitmap - pb.Set(math.MaxInt32, math.MinInt32) - pb.Set(math.MinInt32, math.MaxInt32) - assert.EqualValues(t, []interface{}{math.MaxInt32, math.MinInt32}, iter.IterableAsSlice(&pb)) -} - -func TestDistinct(t *testing.T) { - var pb PriorityBitmap - pb.Set(0, 0) - pb.Set(1, 1) - assert.EqualValues(t, []interface{}{0, 1}, iter.IterableAsSlice(&pb)) - pb.Set(0, -1) - assert.EqualValues(t, []interface{}{0, 1}, iter.IterableAsSlice(&pb)) - pb.Set(1, -2) - assert.EqualValues(t, []interface{}{1, 0}, iter.IterableAsSlice(&pb)) -} - -func TestNextAfterIterFinished(t *testing.T) { - var pb PriorityBitmap - pb.Set(0, 0) - it := iter.NewIterator(&pb) - assert.True(t, it.Next()) - assert.False(t, it.Next()) - assert.False(t, it.Next()) -} - -func TestRemoveWhileIterating(t *testing.T) { - var pb PriorityBitmap - pb.Set(0, 0) - pb.Set(1, 1) - it := iter.NewIterator(&pb) - go it.Stop() - pb.Remove(0) - time.Sleep(time.Millisecond) - // This should return an empty list, as the iterator was stopped before - // Next was called. - assert.EqualValues(t, []interface{}(nil), iter.ToSlice(it)) -} - -func TestDoubleRemove(t *testing.T) { - var pb PriorityBitmap - pb.Set(0, 0) - pb.Remove(0) - assert.NotPanics(t, func() { pb.Remove(0) }) -} diff --git a/vendor/github.com/anacrolix/missinggo/pubsub/pubsub_test.go b/vendor/github.com/anacrolix/missinggo/pubsub/pubsub_test.go deleted file mode 100644 index 762959922..000000000 --- a/vendor/github.com/anacrolix/missinggo/pubsub/pubsub_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package pubsub - -import ( - "sync" - "testing" - - "github.com/bradfitz/iter" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestDoubleClose(t *testing.T) { - ps := NewPubSub() - ps.Close() - ps.Close() -} - -func testBroadcast(t testing.TB, subs, vals int) { - ps := NewPubSub() - var wg sync.WaitGroup - for range iter.N(subs) { - wg.Add(1) - s := ps.Subscribe() - go func() { - defer wg.Done() - var e int - for i := range s.Values { - assert.Equal(t, e, i.(int)) - e++ - } - assert.Equal(t, vals, e) - }() - } - for i := range iter.N(vals) { - ps.Publish(i) - } - ps.Close() - wg.Wait() -} - -func TestBroadcast(t *testing.T) { - testBroadcast(t, 100, 10) -} - -func BenchmarkBroadcast(b *testing.B) { - for range iter.N(b.N) { - testBroadcast(b, 10, 1000) - } -} - -func TestCloseSubscription(t *testing.T) { - ps := NewPubSub() - ps.Publish(1) - s := ps.Subscribe() - select { - case <-s.Values: - t.FailNow() - default: - } - ps.Publish(2) - s2 := ps.Subscribe() - ps.Publish(3) - require.Equal(t, 2, <-s.Values) - require.EqualValues(t, 3, <-s.Values) - s.Close() - _, ok := <-s.Values - require.False(t, ok) - ps.Publish(4) - ps.Close() - require.Equal(t, 3, <-s2.Values) - require.Equal(t, 4, <-s2.Values) - require.Nil(t, <-s2.Values) - s2.Close() -} diff --git a/vendor/github.com/anacrolix/missinggo/reader_context.go b/vendor/github.com/anacrolix/missinggo/reader_context.go new file mode 100644 index 000000000..cb59d8944 --- /dev/null +++ b/vendor/github.com/anacrolix/missinggo/reader_context.go @@ -0,0 +1,16 @@ +package missinggo + +import "golang.org/x/net/context" + +type ContextedReader struct { + R ReadContexter + Ctx context.Context +} + +func (me ContextedReader) Read(b []byte) (int, error) { + return me.R.ReadContext(me.Ctx, b) +} + +type ReadContexter interface { + ReadContext(context.Context, []byte) (int, error) +} diff --git a/vendor/github.com/anacrolix/missinggo/refclose/refclose.go b/vendor/github.com/anacrolix/missinggo/refclose/refclose.go deleted file mode 100644 index a52361c79..000000000 --- a/vendor/github.com/anacrolix/missinggo/refclose/refclose.go +++ /dev/null @@ -1,93 +0,0 @@ -package refclose - -import ( - "runtime/pprof" - "sync" -) - -var profile = pprof.NewProfile("refs") - -type RefPool struct { - mu sync.Mutex - rs map[interface{}]*resource -} - -type Closer func() - -func (me *RefPool) inc(key interface{}) { - me.mu.Lock() - defer me.mu.Unlock() - r := me.rs[key] - if r == nil { - r = new(resource) - if me.rs == nil { - me.rs = make(map[interface{}]*resource) - } - me.rs[key] = r - } - r.numRefs++ -} - -func (me *RefPool) dec(key interface{}) { - me.mu.Lock() - defer me.mu.Unlock() - r := me.rs[key] - r.numRefs-- - if r.numRefs > 0 { - return - } - if r.numRefs < 0 { - panic(r.numRefs) - } - r.closer() - delete(me.rs, key) -} - -type resource struct { - closer Closer - numRefs int -} - -func (me *RefPool) NewRef(key interface{}) (ret *Ref) { - me.inc(key) - ret = &Ref{ - pool: me, - key: key, - } - profile.Add(ret, 0) - return -} - -type Ref struct { - mu sync.Mutex - pool *RefPool - key interface{} - closed bool -} - -func (me *Ref) SetCloser(closer Closer) { - me.pool.mu.Lock() - defer me.pool.mu.Unlock() - me.pool.rs[me.key].closer = closer -} - -func (me *Ref) panicIfClosed() { - if me.closed { - panic("ref is closed") - } -} - -func (me *Ref) Release() { - me.mu.Lock() - defer me.mu.Unlock() - me.panicIfClosed() - profile.Remove(me) - me.pool.dec(me.key) -} - -func (me *Ref) Key() interface{} { - me.mu.Lock() - defer me.mu.Unlock() - me.panicIfClosed() - return me.key -} diff --git a/vendor/github.com/anacrolix/missinggo/refclose/refclose_test.go b/vendor/github.com/anacrolix/missinggo/refclose/refclose_test.go deleted file mode 100644 index 775ad5d48..000000000 --- a/vendor/github.com/anacrolix/missinggo/refclose/refclose_test.go +++ /dev/null @@ -1,66 +0,0 @@ -package refclose - -import ( - "sync" - "testing" - - "github.com/bradfitz/iter" - "github.com/stretchr/testify/assert" -) - -type refTest struct { - pool RefPool - key interface{} - objs map[*object]struct{} - t *testing.T -} - -func (me refTest) run() { - me.objs = make(map[*object]struct{}) - var ( - mu sync.Mutex - curObj *object - wg sync.WaitGroup - ) - for range iter.N(1000) { - wg.Add(1) - go func() { - defer wg.Done() - ref := me.pool.NewRef(me.key) - mu.Lock() - if curObj == nil { - curObj = new(object) - me.objs[curObj] = struct{}{} - } - // obj := curObj - mu.Unlock() - ref.SetCloser(func() { - mu.Lock() - if curObj.closed { - panic("object already closed") - } - curObj.closed = true - curObj = nil - mu.Unlock() - }) - ref.Release() - }() - } - wg.Wait() - me.t.Logf("created %d objects", len(me.objs)) - assert.True(me.t, len(me.objs) >= 1) - for obj := range me.objs { - assert.True(me.t, obj.closed) - } -} - -type object struct { - closed bool -} - -func Test(t *testing.T) { - refTest{ - key: 3, - t: t, - }.run() -} diff --git a/vendor/github.com/anacrolix/missinggo/rle_test.go b/vendor/github.com/anacrolix/missinggo/rle_test.go deleted file mode 100644 index 960579e8d..000000000 --- a/vendor/github.com/anacrolix/missinggo/rle_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package missinggo_test - -import ( - "fmt" - - "github.com/anacrolix/missinggo" -) - -func ExampleNewRunLengthEncoder() { - var s string - rle := missinggo.NewRunLengthEncoder(func(e interface{}, count uint64) { - s += fmt.Sprintf("%d%c", count, e) - }) - for _, e := range "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" { - rle.Append(e, 1) - } - rle.Flush() - fmt.Println(s) - // Output: 12W1B12W3B24W1B14W -} diff --git a/vendor/github.com/anacrolix/missinggo/section_read_seeker_test.go b/vendor/github.com/anacrolix/missinggo/section_read_seeker_test.go deleted file mode 100644 index 67210fd02..000000000 --- a/vendor/github.com/anacrolix/missinggo/section_read_seeker_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package missinggo - -import ( - "bytes" - "io" - "os" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestSectionReadSeekerReadBeyondEnd(t *testing.T) { - base := bytes.NewReader([]byte{1, 2, 3}) - srs := NewSectionReadSeeker(base, 1, 1) - dest := new(bytes.Buffer) - n, err := io.Copy(dest, srs) - assert.EqualValues(t, 1, n) - assert.NoError(t, err) -} - -func TestSectionReadSeekerSeekEnd(t *testing.T) { - base := bytes.NewReader([]byte{1, 2, 3}) - srs := NewSectionReadSeeker(base, 1, 1) - off, err := srs.Seek(0, os.SEEK_END) - assert.NoError(t, err) - assert.EqualValues(t, 1, off) -} diff --git a/vendor/github.com/anacrolix/missinggo/slices/cast_test.go b/vendor/github.com/anacrolix/missinggo/slices/cast_test.go deleted file mode 100644 index f37156c11..000000000 --- a/vendor/github.com/anacrolix/missinggo/slices/cast_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package slices - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -type herp int - -func TestCastSliceInterface(t *testing.T) { - var dest []herp - MakeInto(&dest, []interface{}{herp(1), herp(2)}) - assert.Len(t, dest, 2) - assert.EqualValues(t, 1, dest[0]) - assert.EqualValues(t, 2, dest[1]) -} - -func TestCastSliceInts(t *testing.T) { - var dest []int - MakeInto(&dest, []uint32{1, 2}) - assert.Len(t, dest, 2) - assert.EqualValues(t, 1, dest[0]) - assert.EqualValues(t, 2, dest[1]) -} diff --git a/vendor/github.com/anacrolix/missinggo/slices/map_test.go b/vendor/github.com/anacrolix/missinggo/slices/map_test.go deleted file mode 100644 index ded24cf7e..000000000 --- a/vendor/github.com/anacrolix/missinggo/slices/map_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package slices - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestFromMap(t *testing.T) { - sl := FromMap(map[string]int{"two": 2, "one": 1}) - assert.Len(t, sl, 2) - Sort(sl, func(left, right MapItem) bool { - return left.Key.(string) < right.Key.(string) - }) - assert.EqualValues(t, []MapItem{{"one", 1}, {"two", 2}}, sl) -} diff --git a/vendor/github.com/anacrolix/missinggo/slices/sort_test.go b/vendor/github.com/anacrolix/missinggo/slices/sort_test.go deleted file mode 100644 index 0650fd23e..000000000 --- a/vendor/github.com/anacrolix/missinggo/slices/sort_test.go +++ /dev/null @@ -1,15 +0,0 @@ -package slices - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestSort(t *testing.T) { - a := []int{3, 2, 1} - Sort(a, func(left, right int) bool { - return left < right - }) - assert.EqualValues(t, []int{1, 2, 3}, a) -} diff --git a/vendor/github.com/anacrolix/missinggo/strbool_test.go b/vendor/github.com/anacrolix/missinggo/strbool_test.go deleted file mode 100644 index 94367a229..000000000 --- a/vendor/github.com/anacrolix/missinggo/strbool_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package missinggo - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestStringTruth(t *testing.T) { - for _, s := range []string{ - "", - " ", - "\n", - "\x00", - "0", - } { - t.Run(s, func(t *testing.T) { - assert.False(t, StringTruth(s)) - }) - } - for _, s := range []string{ - " 1", - "t", - } { - t.Run(s, func(t *testing.T) { - assert.True(t, StringTruth(s)) - }) - } -} diff --git a/vendor/github.com/anacrolix/missinggo/testing_test.go b/vendor/github.com/anacrolix/missinggo/testing_test.go deleted file mode 100644 index 2981e72bd..000000000 --- a/vendor/github.com/anacrolix/missinggo/testing_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package missinggo - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -// Since GetTestName panics if the test name isn't found, it'll be easy to -// expand the tests if we find weird cases. -func TestGetTestName(t *testing.T) { - assert.EqualValues(t, "TestGetTestName", GetTestName()) -} diff --git a/vendor/github.com/anacrolix/missinggo/timer_test.go b/vendor/github.com/anacrolix/missinggo/timer_test.go deleted file mode 100644 index 4cd2c191d..000000000 --- a/vendor/github.com/anacrolix/missinggo/timer_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package missinggo - -import ( - "testing" - "time" - - "github.com/bradfitz/iter" - "github.com/stretchr/testify/assert" -) - -func TestTimerDrain(t *testing.T) { - tr := time.NewTimer(0) - <-tr.C - select { - case <-tr.C: - assert.Fail(t, "shouldn't have received again on the the expired timer") - default: - } - tr.Reset(1) - select { - case <-tr.C: - assert.Fail(t, "received too soon") - default: - } - time.Sleep(1) - <-tr.C - // Stop() should return false, as it just fired. - assert.False(t, tr.Stop()) - tr.Reset(0) - // Check we receive again after a Reset(). - <-tr.C -} - -func TestTimerDoesNotFireAfterStop(t *testing.T) { - t.Skip("the standard library implementation is broken") - fail := make(chan struct{}) - done := make(chan struct{}) - defer close(done) - for range iter.N(1000) { - tr := time.NewTimer(0) - tr.Stop() - // There may or may not be a value in the channel now. But definitely - // one should not be added after we receive it. - select { - case <-tr.C: - default: - } - // Now set the timer to trigger in hour. It definitely shouldn't be - // receivable now for an hour. - tr.Reset(time.Hour) - go func() { - select { - case <-tr.C: - // As soon as the channel receives, notify failure. - fail <- struct{}{} - case <-done: - } - }() - } - select { - case <-fail: - t.FailNow() - case <-time.After(100 * time.Millisecond): - } -} diff --git a/vendor/github.com/anacrolix/missinggo/tls.go b/vendor/github.com/anacrolix/missinggo/tls.go new file mode 100644 index 000000000..0d36b7363 --- /dev/null +++ b/vendor/github.com/anacrolix/missinggo/tls.go @@ -0,0 +1,32 @@ +package missinggo + +import ( + "crypto/tls" + "strings" +) + +// Select the best named certificate per the usual behaviour if +// c.GetCertificate is nil, and c.NameToCertificate is not. +func BestNamedCertificate(c *tls.Config, clientHello *tls.ClientHelloInfo) (*tls.Certificate, bool) { + name := strings.ToLower(clientHello.ServerName) + for len(name) > 0 && name[len(name)-1] == '.' { + name = name[:len(name)-1] + } + + if cert, ok := c.NameToCertificate[name]; ok { + return cert, true + } + + // try replacing labels in the name with wildcards until we get a + // match. + labels := strings.Split(name, ".") + for i := range labels { + labels[i] = "*" + candidate := strings.Join(labels, ".") + if cert, ok := c.NameToCertificate[candidate]; ok { + return cert, true + } + } + + return nil, false +} diff --git a/vendor/github.com/anacrolix/missinggo/url_test.go b/vendor/github.com/anacrolix/missinggo/url_test.go deleted file mode 100644 index 40c5b68f0..000000000 --- a/vendor/github.com/anacrolix/missinggo/url_test.go +++ /dev/null @@ -1,21 +0,0 @@ -package missinggo - -import ( - "net/url" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestURLOpaquePath(t *testing.T) { - assert.Equal(t, "sqlite3://sqlite3.db", (&url.URL{Scheme: "sqlite3", Path: "sqlite3.db"}).String()) - u, err := url.Parse("sqlite3:sqlite3.db") - assert.NoError(t, err) - assert.Equal(t, "sqlite3.db", URLOpaquePath(u)) - assert.Equal(t, "sqlite3:sqlite3.db", (&url.URL{Scheme: "sqlite3", Opaque: "sqlite3.db"}).String()) - assert.Equal(t, "sqlite3:/sqlite3.db", (&url.URL{Scheme: "sqlite3", Opaque: "/sqlite3.db"}).String()) - u, err = url.Parse("sqlite3:/sqlite3.db") - assert.NoError(t, err) - assert.Equal(t, "/sqlite3.db", u.Path) - assert.Equal(t, "/sqlite3.db", URLOpaquePath(u)) -} diff --git a/vendor/github.com/anacrolix/missinggo/wolf_test.go b/vendor/github.com/anacrolix/missinggo/wolf_test.go deleted file mode 100644 index 3ee59ca79..000000000 --- a/vendor/github.com/anacrolix/missinggo/wolf_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package missinggo - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func cryHeard() bool { - return CryHeard() -} - -func TestCrySameLocation(t *testing.T) { - require.True(t, cryHeard()) - require.True(t, cryHeard()) - require.False(t, cryHeard()) - require.True(t, cryHeard()) - require.False(t, cryHeard()) - require.False(t, cryHeard()) - require.False(t, cryHeard()) - require.True(t, cryHeard()) -} - -func TestCryDifferentLocations(t *testing.T) { - require.True(t, CryHeard()) - require.True(t, CryHeard()) - require.True(t, CryHeard()) - require.True(t, CryHeard()) - require.True(t, CryHeard()) -} diff --git a/vendor/github.com/anacrolix/missinggo/x/panic.go b/vendor/github.com/anacrolix/missinggo/x/panic.go deleted file mode 100644 index ce11d87c7..000000000 --- a/vendor/github.com/anacrolix/missinggo/x/panic.go +++ /dev/null @@ -1,8 +0,0 @@ -package x - -// Panic if error. Just fucking add exceptions, please. -func Pie(err error) { - if err != nil { - panic(err) - } -} diff --git a/vendor/github.com/anacrolix/sync/sync_test.go b/vendor/github.com/anacrolix/sync/sync_test.go deleted file mode 100644 index 6c12ca7a0..000000000 --- a/vendor/github.com/anacrolix/sync/sync_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package sync - -import ( - "bytes" - "testing" -) - -func init() { - Enable() -} - -func TestLog(t *testing.T) { - var mu Mutex - mu.Lock() - mu.Unlock() -} - -func TestRWMutex(t *testing.T) { - var mu RWMutex - mu.RLock() - mu.RUnlock() -} - -func TestPointerCompare(t *testing.T) { - a, b := new(int), new(int) - if a == b { - t.FailNow() - } -} - -func TestLockTime(t *testing.T) { - var buf bytes.Buffer - PrintLockTimes(&buf) - t.Log(buf.String()) -} diff --git a/vendor/github.com/anacrolix/torrent/README.md b/vendor/github.com/anacrolix/torrent/README.md index 599ec0546..ecdbf039e 100644 --- a/vendor/github.com/anacrolix/torrent/README.md +++ b/vendor/github.com/anacrolix/torrent/README.md @@ -6,7 +6,7 @@ This repository implements BitTorrent-related packages and command-line utilities in Go. The emphasis is on use as a library from other projects. It's been used 24/7 in production by a downstream, private service since late 2014. -There is support for protocol encryption, [DHT](https://github.com/anacrolix/dht), PEX, [uTP](https://github.com/anacrolix/utp), and various extensions. See the package documentation for a more complete list. There are several data storage backends provided: blob, file, and mmap, and you can write your own, such as to store data on S3, or in a database. You can use the provided binaries in `./cmd`, or use `torrent` as a library for your own applications. +There is support for protocol encryption, [DHT](https://github.com/anacrolix/dht), PEX, [uTP](https://github.com/anacrolix/utp), and various extensions. See the package documentation for a more complete list. There are several data storage backends provided: blob, file, and mmap, and you can write your own, such as to store data on S3, or in a database. You can use the provided binaries in `./cmd`, or use package `torrent` as a library for your own applications. Many of the sub-packages can be used for other purposes: [bencode](https://godoc.org/github.com/anacrolix/torrent/bencode), and [tracker](https://godoc.org/github.com/anacrolix/torrent/tracker), in particular. @@ -27,10 +27,6 @@ There is a small example in the [package documentation](https://godoc.org/github * [Trickl - Torrent Client](https://play.google.com/store/apps/details?id=com.shwifty.tex) * [Confluence](https://github.com/anacrolix/confluence) -## Mobile - -There's a branch called `mobile` that supports binding to torrent with the [gomobile](https://github.com/golang/go/wiki/Mobile) tool. It has some API changes as required by `gomobile`. Checkout the [`mobile` branch](https://github.com/anacrolix/torrent/tree/mobile), and bind as usual. - ## Commands Here I'll describe what some of the provided commands in `./cmd` do. @@ -53,10 +49,10 @@ Downloads torrents from the command-line. This first example does not use `godo` ### torrentfs -torrentfs mounts a FUSE filesystem at `-mountDir`. The contents are the torrents described by the torrent files and magnet links at `-torrentPath`. Data for read requests is fetched only as required from the torrent network, and stored at `-downloadDir`. +torrentfs mounts a FUSE filesystem at `-mountDir`. The contents are the torrents described by the torrent files and magnet links at `-metainfoDir`. Data for read requests is fetched only as required from the torrent network, and stored at `-downloadDir`. $ mkdir mnt torrents - $ godo github.com/anacrolix/torrent/cmd/torrentfs -mountDir mnt -torrentPath torrents & + $ godo github.com/anacrolix/torrent/cmd/torrentfs -mountDir=mnt -metainfoDir=torrents & $ cd torrents $ wget http://releases.ubuntu.com/14.04.2/ubuntu-14.04.2-desktop-amd64.iso.torrent $ cd .. @@ -72,14 +68,3 @@ Creates a magnet link from a torrent file. Note the extracted trackers, display $ godo github.com/anacrolix/torrent/cmd/torrent-magnet < ubuntu-14.04.2-desktop-amd64.iso.torrent magnet:?xt=urn:btih:546cf15f724d19c4319cc17b179d7e035f89c1f4&dn=ubuntu-14.04.2-desktop-amd64.iso&tr=http%3A%2F%2Ftorrent.ubuntu.com%3A6969%2Fannounce&tr=http%3A%2F%2Fipv6.torrent.ubuntu.com%3A6969%2Fannounce - -### dht-ping - -Pings DHT nodes with the given network addresses. - - $ godo ./cmd/dht-ping router.bittorrent.com:6881 router.utorrent.com:6881 - 2015/04/01 17:21:23 main.go:33: dht server on [::]:60058 - 32f54e697351ff4aec29cdbaabf2fbe3467cc267 (router.bittorrent.com:6881): 648.218621ms - ebff36697351ff4aec29cdbaabf2fbe3467cc267 (router.utorrent.com:6881): 873.864706ms - 2/2 responses (100.000000%) - diff --git a/vendor/github.com/anacrolix/torrent/bencode/README b/vendor/github.com/anacrolix/torrent/bencode/README deleted file mode 100644 index 440bd5f74..000000000 --- a/vendor/github.com/anacrolix/torrent/bencode/README +++ /dev/null @@ -1 +0,0 @@ -Bencode encoding/decoding sub package. Uses similar API design to Go's json package. diff --git a/vendor/github.com/anacrolix/torrent/bencode/README.md b/vendor/github.com/anacrolix/torrent/bencode/README.md new file mode 100644 index 000000000..4dbc67beb --- /dev/null +++ b/vendor/github.com/anacrolix/torrent/bencode/README.md @@ -0,0 +1,38 @@ +Bencode encoding/decoding sub package. Uses similar API design to Go's json package. + +## Install + +```sh +go get github.com/anacrolix/torrent +``` + +## Usage + +```go +package demo + +import ( + bencode "github.com/anacrolix/torrent/bencode" +) + +type Message struct { + Query string `json:"q,omitempty" bencode:"q,omitempty"` +} + +var v Message + +func main(){ + // encode + data, err := bencode.Marshal(v) + if err != nil { + log.Fatal(err) + } + + //decode + err := bencode.Unmarshal(data, &v) + if err != nil { + log.Fatal(err) + } + fmt.Println(v) +} +``` diff --git a/vendor/github.com/anacrolix/torrent/bencode/both_test.go b/vendor/github.com/anacrolix/torrent/bencode/both_test.go deleted file mode 100644 index b0bb074d3..000000000 --- a/vendor/github.com/anacrolix/torrent/bencode/both_test.go +++ /dev/null @@ -1,76 +0,0 @@ -package bencode - -import ( - "bytes" - "io/ioutil" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func loadFile(name string, t *testing.T) []byte { - data, err := ioutil.ReadFile(name) - require.NoError(t, err) - return data -} - -func testFileInterface(t *testing.T, filename string) { - data1 := loadFile(filename, t) - - var iface interface{} - err := Unmarshal(data1, &iface) - require.NoError(t, err) - - data2, err := Marshal(iface) - require.NoError(t, err) - - assert.EqualValues(t, data1, data2) -} - -func TestBothInterface(t *testing.T) { - testFileInterface(t, "testdata/archlinux-2011.08.19-netinstall-i686.iso.torrent") - testFileInterface(t, "testdata/continuum.torrent") -} - -type torrentFile struct { - Info struct { - Name string `bencode:"name"` - Length int64 `bencode:"length"` - MD5Sum string `bencode:"md5sum,omitempty"` - PieceLength int64 `bencode:"piece length"` - Pieces string `bencode:"pieces"` - Private bool `bencode:"private,omitempty"` - } `bencode:"info"` - - Announce string `bencode:"announce"` - AnnounceList [][]string `bencode:"announce-list,omitempty"` - CreationDate int64 `bencode:"creation date,omitempty"` - Comment string `bencode:"comment,omitempty"` - CreatedBy string `bencode:"created by,omitempty"` - URLList interface{} `bencode:"url-list,omitempty"` -} - -func testFile(t *testing.T, filename string) { - data1 := loadFile(filename, t) - var f torrentFile - - err := Unmarshal(data1, &f) - if err != nil { - t.Fatal(err) - } - - data2, err := Marshal(&f) - if err != nil { - t.Fatal(err) - } - - if !bytes.Equal(data1, data2) { - println(string(data2)) - t.Fatalf("equality expected") - } -} - -func TestBoth(t *testing.T) { - testFile(t, "testdata/archlinux-2011.08.19-netinstall-i686.iso.torrent") -} diff --git a/vendor/github.com/anacrolix/torrent/bencode/decode_test.go b/vendor/github.com/anacrolix/torrent/bencode/decode_test.go deleted file mode 100644 index d519b8a6a..000000000 --- a/vendor/github.com/anacrolix/torrent/bencode/decode_test.go +++ /dev/null @@ -1,112 +0,0 @@ -package bencode - -import ( - "bytes" - "io" - "math/big" - "reflect" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -type random_decode_test struct { - data string - expected interface{} -} - -var random_decode_tests = []random_decode_test{ - {"i57e", int64(57)}, - {"i-9223372036854775808e", int64(-9223372036854775808)}, - {"5:hello", "hello"}, - {"29:unicode test проверка", "unicode test проверка"}, - {"d1:ai5e1:b5:helloe", map[string]interface{}{"a": int64(5), "b": "hello"}}, - {"li5ei10ei15ei20e7:bencodee", - []interface{}{int64(5), int64(10), int64(15), int64(20), "bencode"}}, - {"ldedee", []interface{}{map[string]interface{}{}, map[string]interface{}{}}}, - {"le", []interface{}{}}, - {"i604919719469385652980544193299329427705624352086e", func() *big.Int { - ret, _ := big.NewInt(-1).SetString("604919719469385652980544193299329427705624352086", 10) - return ret - }()}, - {"d1:rd6:\xd4/\xe2F\x00\x01e1:t3:\x9a\x87\x011:v4:TR%=1:y1:re", map[string]interface{}{ - "r": map[string]interface{}{}, - "t": "\x9a\x87\x01", - "v": "TR%=", - "y": "r", - }}, -} - -func TestRandomDecode(t *testing.T) { - for _, test := range random_decode_tests { - var value interface{} - err := Unmarshal([]byte(test.data), &value) - if err != nil { - t.Error(err, test.data) - continue - } - assert.EqualValues(t, test.expected, value) - } -} - -func TestLoneE(t *testing.T) { - var v int - err := Unmarshal([]byte("e"), &v) - se := err.(*SyntaxError) - require.EqualValues(t, 0, se.Offset) -} - -func TestDecoderConsecutive(t *testing.T) { - d := NewDecoder(bytes.NewReader([]byte("i1ei2e"))) - var i int - err := d.Decode(&i) - require.NoError(t, err) - require.EqualValues(t, 1, i) - err = d.Decode(&i) - require.NoError(t, err) - require.EqualValues(t, 2, i) - err = d.Decode(&i) - require.Equal(t, io.EOF, err) -} - -func check_error(t *testing.T, err error) { - if err != nil { - t.Error(err) - } -} - -func assert_equal(t *testing.T, x, y interface{}) { - if !reflect.DeepEqual(x, y) { - t.Errorf("got: %v (%T), expected: %v (%T)\n", x, x, y, y) - } -} - -type unmarshaler_int struct { - x int -} - -func (this *unmarshaler_int) UnmarshalBencode(data []byte) error { - return Unmarshal(data, &this.x) -} - -type unmarshaler_string struct { - x string -} - -func (this *unmarshaler_string) UnmarshalBencode(data []byte) error { - this.x = string(data) - return nil -} - -func TestUnmarshalerBencode(t *testing.T) { - var i unmarshaler_int - var ss []unmarshaler_string - check_error(t, Unmarshal([]byte("i71e"), &i)) - assert_equal(t, i.x, 71) - check_error(t, Unmarshal([]byte("l5:hello5:fruit3:waye"), &ss)) - assert_equal(t, ss[0].x, "5:hello") - assert_equal(t, ss[1].x, "5:fruit") - assert_equal(t, ss[2].x, "3:way") - -} diff --git a/vendor/github.com/anacrolix/torrent/bencode/encode_test.go b/vendor/github.com/anacrolix/torrent/bencode/encode_test.go deleted file mode 100644 index 86ecc06cf..000000000 --- a/vendor/github.com/anacrolix/torrent/bencode/encode_test.go +++ /dev/null @@ -1,79 +0,0 @@ -package bencode - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) -import "bytes" -import "fmt" - -type random_encode_test struct { - value interface{} - expected string -} - -type random_struct struct { - ABC int `bencode:"abc"` - SkipThisOne string `bencode:"-"` - CDE string -} - -type dummy struct { - a, b, c int -} - -func (d *dummy) MarshalBencode() ([]byte, error) { - var b bytes.Buffer - _, err := fmt.Fprintf(&b, "i%dei%dei%de", d.a+1, d.b+1, d.c+1) - if err != nil { - return nil, err - } - return b.Bytes(), nil -} - -var random_encode_tests = []random_encode_test{ - {int(10), "i10e"}, - {uint(10), "i10e"}, - {"hello, world", "12:hello, world"}, - {true, "i1e"}, - {false, "i0e"}, - {int8(-8), "i-8e"}, - {int16(-16), "i-16e"}, - {int32(32), "i32e"}, - {int64(-64), "i-64e"}, - {uint8(8), "i8e"}, - {uint16(16), "i16e"}, - {uint32(32), "i32e"}, - {uint64(64), "i64e"}, - {random_struct{123, "nono", "hello"}, "d3:CDE5:hello3:abci123ee"}, - {map[string]string{"a": "b", "c": "d"}, "d1:a1:b1:c1:de"}, - {[]byte{1, 2, 3, 4}, "4:\x01\x02\x03\x04"}, - {[4]byte{1, 2, 3, 4}, "li1ei2ei3ei4ee"}, - {nil, ""}, - {[]byte{}, "0:"}, - {"", "0:"}, - {[]int{}, "le"}, - {map[string]int{}, "de"}, - {&dummy{1, 2, 3}, "i2ei3ei4e"}, - {struct { - A *string - }{nil}, "d1:A0:e"}, - {struct { - A *string - }{new(string)}, "d1:A0:e"}, - {struct { - A *string `bencode:",omitempty"` - }{nil}, "de"}, - {struct { - A *string `bencode:",omitempty"` - }{new(string)}, "d1:A0:e"}, -} - -func TestRandomEncode(t *testing.T) { - for _, test := range random_encode_tests { - data, err := Marshal(test.value) - assert.NoError(t, err, "%s", test) - assert.EqualValues(t, test.expected, string(data)) - } -} diff --git a/vendor/github.com/anacrolix/torrent/bencode/testdata/archlinux-2011.08.19-netinstall-i686.iso.torrent b/vendor/github.com/anacrolix/torrent/bencode/testdata/archlinux-2011.08.19-netinstall-i686.iso.torrent deleted file mode 100644 index 9ce7748aa..000000000 Binary files a/vendor/github.com/anacrolix/torrent/bencode/testdata/archlinux-2011.08.19-netinstall-i686.iso.torrent and /dev/null differ diff --git a/vendor/github.com/anacrolix/torrent/bencode/testdata/continuum.torrent b/vendor/github.com/anacrolix/torrent/bencode/testdata/continuum.torrent deleted file mode 100644 index ac15b751a..000000000 Binary files a/vendor/github.com/anacrolix/torrent/bencode/testdata/continuum.torrent and /dev/null differ diff --git a/vendor/github.com/anacrolix/torrent/client.go b/vendor/github.com/anacrolix/torrent/client.go index e49f39bb5..74f8a0d53 100644 --- a/vendor/github.com/anacrolix/torrent/client.go +++ b/vendor/github.com/anacrolix/torrent/client.go @@ -3,9 +3,11 @@ package torrent import ( "bufio" "bytes" + "context" "crypto/rand" "encoding/hex" "errors" + "expvar" "fmt" "io" "log" @@ -22,7 +24,6 @@ import ( "github.com/anacrolix/missinggo/pubsub" "github.com/anacrolix/missinggo/slices" "github.com/anacrolix/sync" - "github.com/anacrolix/utp" "github.com/dustin/go-humanize" "golang.org/x/time/rate" @@ -46,8 +47,9 @@ type Client struct { halfOpenLimit int peerID [20]byte defaultStorage *storage.Client + onClose []func() tcpListener net.Listener - utpSock *utp.Socket + utpSock utpSocket dHT *dht.Server ipBlockList iplist.Ranger // Our BitTorrent protocol extension bytes, sent in our BT handshakes. @@ -140,8 +142,8 @@ func (cl *Client) WriteStatus(_w io.Writer) { fmt.Fprint(w, t.name()) } fmt.Fprint(w, "\n") - if t.Info() != nil { - fmt.Fprintf(w, "%f%% of %d bytes (%s)", 100*(1-float64(t.bytesMissingLocked())/float64(t.Info().TotalLength())), t.length, humanize.Bytes(uint64(t.Info().TotalLength()))) + if t.info != nil { + fmt.Fprintf(w, "%f%% of %d bytes (%s)", 100*(1-float64(t.bytesMissingLocked())/float64(t.info.TotalLength())), t.length, humanize.Bytes(uint64(t.info.TotalLength()))) } else { w.WriteString("") } @@ -151,15 +153,15 @@ func (cl *Client) WriteStatus(_w io.Writer) { } } -func listenUTP(networkSuffix, addr string) (*utp.Socket, error) { - return utp.NewSocket("udp"+networkSuffix, addr) +func listenUTP(networkSuffix, addr string) (utpSocket, error) { + return NewUtpSocket("udp"+networkSuffix, addr) } func listenTCP(networkSuffix, addr string) (net.Listener, error) { return net.Listen("tcp"+networkSuffix, addr) } -func listenBothSameDynamicPort(networkSuffix, host string) (tcpL net.Listener, utpSock *utp.Socket, listenedAddr string, err error) { +func listenBothSameDynamicPort(networkSuffix, host string) (tcpL net.Listener, utpSock utpSocket, listenedAddr string, err error) { for { tcpL, err = listenTCP(networkSuffix, net.JoinHostPort(host, "0")) if err != nil { @@ -178,7 +180,7 @@ func listenBothSameDynamicPort(networkSuffix, host string) (tcpL net.Listener, u } // Listen to enabled protocols, ensuring ports match. -func listen(tcp, utp bool, networkSuffix, addr string) (tcpL net.Listener, utpSock *utp.Socket, listenedAddr string, err error) { +func listen(tcp, utp bool, networkSuffix, addr string) (tcpL net.Listener, utpSock utpSocket, listenedAddr string, err error) { if addr == "" { addr = ":50007" } @@ -224,7 +226,11 @@ func listen(tcp, utp bool, networkSuffix, addr string) (tcpL net.Listener, utpSo // Creates a new client. func NewClient(cfg *Config) (cl *Client, err error) { if cfg == nil { - cfg = &Config{} + cfg = &Config{ + DHTConfig: dht.ServerConfig{ + StartingNodes: dht.GlobalBootstrapAddrs, + }, + } } defer func() { @@ -238,6 +244,12 @@ func NewClient(cfg *Config) (cl *Client, err error) { dopplegangerAddrs: make(map[string]struct{}), torrents: make(map[metainfo.Hash]*Torrent), } + defer func() { + if err == nil { + return + } + cl.Close() + }() if cfg.UploadRateLimiter == nil { cl.uploadLimit = rate.NewLimiter(rate.Inf, 0) } else { @@ -252,7 +264,13 @@ func NewClient(cfg *Config) (cl *Client, err error) { cl.event.L = &cl.mu storageImpl := cfg.DefaultStorage if storageImpl == nil { + // We'd use mmap but HFS+ doesn't support sparse files. storageImpl = storage.NewFile(cfg.DataDir) + cl.onClose = append(cl.onClose, func() { + if err := storageImpl.Close(); err != nil { + log.Printf("error closing default storage: %s", err) + } + }) } cl.defaultStorage = storage.NewClient(storageImpl) if cfg.IPBlocklist != nil { @@ -294,9 +312,15 @@ func NewClient(cfg *Config) (cl *Client, err error) { if dhtCfg.IPBlocklist == nil { dhtCfg.IPBlocklist = cl.ipBlockList } - dhtCfg.Addr = firstNonEmptyString(dhtCfg.Addr, cl.listenAddr, cl.config.ListenAddr) - if dhtCfg.Conn == nil && cl.utpSock != nil { - dhtCfg.Conn = cl.utpSock + if dhtCfg.Conn == nil { + if cl.utpSock != nil { + dhtCfg.Conn = cl.utpSock + } else { + dhtCfg.Conn, err = net.ListenPacket("udp", firstNonEmptyString(cl.listenAddr, cl.config.ListenAddr)) + if err != nil { + return + } + } } if dhtCfg.OnAnnouncePeer == nil { dhtCfg.OnAnnouncePeer = cl.onDHTAnnouncePeer @@ -305,6 +329,11 @@ func NewClient(cfg *Config) (cl *Client, err error) { if err != nil { return } + go func() { + if _, err := cl.dHT.Bootstrap(); err != nil { + log.Printf("error bootstrapping dht: %s", err) + } + }() } return @@ -329,7 +358,7 @@ func (cl *Client) Close() { cl.dHT.Close() } if cl.utpSock != nil { - cl.utpSock.CloseNow() + cl.utpSock.Close() } if cl.tcpListener != nil { cl.tcpListener.Close() @@ -337,6 +366,9 @@ func (cl *Client) Close() { for _, t := range cl.torrents { t.close() } + for _, f := range cl.onClose { + f() + } cl.event.Broadcast() } @@ -446,20 +478,12 @@ type dialResult struct { UTP bool } -func doDial(dial func(string, *Torrent) (net.Conn, error), ch chan dialResult, utp bool, addr string, t *Torrent) { - conn, err := dial(addr, t) - if err != nil { - if conn != nil { - conn.Close() - } - conn = nil // Pedantic - } - ch <- dialResult{conn, utp} +func countDialResult(err error) { if err == nil { successfulDials.Add(1) - return + } else { + unsuccessfulDials.Add(1) } - unsuccessfulDials.Add(1) } func reducedDialTimeout(max time.Duration, halfOpenLimit int, pendingPeers int) (ret time.Duration) { @@ -489,19 +513,16 @@ func (cl *Client) initiateConn(peer Peer, t *Torrent) { if t.addrActive(addr) { return } - t.halfOpen[addr] = struct{}{} + t.halfOpen[addr] = peer go cl.outgoingConnection(t, addr, peer.Source) } -func (cl *Client) dialTimeout(t *Torrent) time.Duration { - cl.mu.Lock() - pendingPeers := len(t.peers) - cl.mu.Unlock() - return reducedDialTimeout(nominalDialTimeout, cl.halfOpenLimit, pendingPeers) -} - -func (cl *Client) dialTCP(addr string, t *Torrent) (c net.Conn, err error) { - c, err = net.DialTimeout("tcp", addr, cl.dialTimeout(t)) +func (cl *Client) dialTCP(ctx context.Context, addr string) (c net.Conn, err error) { + d := net.Dialer{ + // LocalAddr: cl.tcpListener.Addr(), + } + c, err = d.DialContext(ctx, "tcp", addr) + countDialResult(err) if err == nil { c.(*net.TCPConn).SetLinger(0) } @@ -509,27 +530,37 @@ func (cl *Client) dialTCP(addr string, t *Torrent) (c net.Conn, err error) { return } -func (cl *Client) dialUTP(addr string, t *Torrent) (net.Conn, error) { - return cl.utpSock.DialTimeout(addr, cl.dialTimeout(t)) +func (cl *Client) dialUTP(ctx context.Context, addr string) (c net.Conn, err error) { + c, err = cl.utpSock.DialContext(ctx, addr) + countDialResult(err) + return } +var ( + dialledFirstUtp = expvar.NewInt("dialledFirstUtp") + dialledFirstNotUtp = expvar.NewInt("dialledFirstNotUtp") +) + // Returns a connection over UTP or TCP, whichever is first to connect. -func (cl *Client) dialFirst(addr string, t *Torrent) (conn net.Conn, utp bool) { - // Initiate connections via TCP and UTP simultaneously. Use the first one - // that succeeds. +func (cl *Client) dialFirst(ctx context.Context, addr string) (conn net.Conn, utp bool) { + ctx, cancel := context.WithCancel(ctx) + // As soon as we return one connection, cancel the others. + defer cancel() left := 0 + resCh := make(chan dialResult, left) if !cl.config.DisableUTP { left++ + go func() { + c, _ := cl.dialUTP(ctx, addr) + resCh <- dialResult{c, true} + }() } if !cl.config.DisableTCP { left++ - } - resCh := make(chan dialResult, left) - if !cl.config.DisableUTP { - go doDial(cl.dialUTP, resCh, true, addr, t) - } - if !cl.config.DisableTCP { - go doDial(cl.dialTCP, resCh, false, addr, t) + go func() { + c, _ := cl.dialTCP(ctx, addr) + resCh <- dialResult{c, false} + }() } var res dialResult // Wait for a successful connection. @@ -549,6 +580,13 @@ func (cl *Client) dialFirst(addr string, t *Torrent) (conn net.Conn, utp bool) { } conn = res.Conn utp = res.UTP + if conn != nil { + if utp { + dialledFirstUtp.Add(1) + } else { + dialledFirstNotUtp.Add(1) + } + } return } @@ -562,56 +600,78 @@ func (cl *Client) noLongerHalfOpen(t *Torrent, addr string) { // Performs initiator handshakes and returns a connection. Returns nil // *connection if no connection for valid reasons. -func (cl *Client) handshakesConnection(nc net.Conn, t *Torrent, encrypted, utp bool) (c *connection, err error) { +func (cl *Client) handshakesConnection(ctx context.Context, nc net.Conn, t *Torrent, encryptHeader, utp bool) (c *connection, err error) { c = cl.newConnection(nc) - c.encrypted = encrypted + c.headerEncrypted = encryptHeader c.uTP = utp - err = nc.SetDeadline(time.Now().Add(handshakesTimeout)) + ctx, cancel := context.WithTimeout(ctx, handshakesTimeout) + defer cancel() + dl, ok := ctx.Deadline() + if !ok { + panic(ctx) + } + err = nc.SetDeadline(dl) if err != nil { - return + panic(err) } - ok, err := cl.initiateHandshakes(c, t) + ok, err = cl.initiateHandshakes(c, t) if !ok { c = nil } return } +var ( + initiatedConnWithPreferredHeaderEncryption = expvar.NewInt("initiatedConnWithPreferredHeaderEncryption") + initiatedConnWithFallbackHeaderEncryption = expvar.NewInt("initiatedConnWithFallbackHeaderEncryption") +) + // Returns nil connection and nil error if no connection could be established // for valid reasons. func (cl *Client) establishOutgoingConn(t *Torrent, addr string) (c *connection, err error) { - nc, utp := cl.dialFirst(addr, t) + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + nc, utp := cl.dialFirst(ctx, addr) if nc == nil { return } - encryptFirst := !cl.config.DisableEncryption && !cl.config.PreferNoEncryption - c, err = cl.handshakesConnection(nc, t, encryptFirst, utp) + obfuscatedHeaderFirst := !cl.config.DisableEncryption && !cl.config.PreferNoEncryption + c, err = cl.handshakesConnection(ctx, nc, t, obfuscatedHeaderFirst, utp) if err != nil { + // log.Printf("error initiating connection handshakes: %s", err) nc.Close() return } else if c != nil { + initiatedConnWithPreferredHeaderEncryption.Add(1) return } nc.Close() - if cl.config.DisableEncryption || cl.config.ForceEncryption { - // There's no alternate encryption case to try. + if cl.config.ForceEncryption { + // We should have just tried with an obfuscated header. A plaintext + // header can't result in an encrypted connection, so we're done. + if !obfuscatedHeaderFirst { + panic(cl.config.EncryptionPolicy) + } return } // Try again with encryption if we didn't earlier, or without if we did, // using whichever protocol type worked last time. if utp { - nc, err = cl.dialUTP(addr, t) + nc, err = cl.dialUTP(ctx, addr) } else { - nc, err = cl.dialTCP(addr, t) + nc, err = cl.dialTCP(ctx, addr) } if err != nil { - err = fmt.Errorf("error dialing for unencrypted connection: %s", err) + err = fmt.Errorf("error dialing for header encryption fallback: %s", err) return } - c, err = cl.handshakesConnection(nc, t, !encryptFirst, utp) + c, err = cl.handshakesConnection(ctx, nc, t, !obfuscatedHeaderFirst, utp) if err != nil || c == nil { nc.Close() } + if err == nil && c != nil { + initiatedConnWithFallbackHeaderEncryption.Add(1) + } return } @@ -797,34 +857,74 @@ func (r deadlineReader) Read(b []byte) (n int, err error) { return } -func maybeReceiveEncryptedHandshake(rw io.ReadWriter, skeys mse.SecretKeyIter) (ret io.ReadWriter, encrypted bool, err error) { - var protocol [len(pp.Protocol)]byte - _, err = io.ReadFull(rw, protocol[:]) - if err != nil { - return - } - ret = struct { - io.Reader - io.Writer - }{ - io.MultiReader(bytes.NewReader(protocol[:]), rw), - rw, - } - if string(protocol[:]) == pp.Protocol { - return +func handleEncryption( + rw io.ReadWriter, + skeys mse.SecretKeyIter, + policy EncryptionPolicy, +) ( + ret io.ReadWriter, + headerEncrypted bool, + cryptoMethod uint32, + err error, +) { + if !policy.ForceEncryption { + var protocol [len(pp.Protocol)]byte + _, err = io.ReadFull(rw, protocol[:]) + if err != nil { + return + } + rw = struct { + io.Reader + io.Writer + }{ + io.MultiReader(bytes.NewReader(protocol[:]), rw), + rw, + } + if string(protocol[:]) == pp.Protocol { + ret = rw + return + } } - encrypted = true - ret, err = mse.ReceiveHandshakeLazy(ret, skeys) + headerEncrypted = true + ret, err = mse.ReceiveHandshake(rw, skeys, func(provides uint32) uint32 { + cryptoMethod = func() uint32 { + switch { + case policy.ForceEncryption: + return mse.CryptoMethodRC4 + case policy.DisableEncryption: + return mse.CryptoMethodPlaintext + case policy.PreferNoEncryption && provides&mse.CryptoMethodPlaintext != 0: + return mse.CryptoMethodPlaintext + default: + return mse.DefaultCryptoSelector(provides) + } + }() + return cryptoMethod + }) return } func (cl *Client) initiateHandshakes(c *connection, t *Torrent) (ok bool, err error) { - if c.encrypted { + if c.headerEncrypted { var rw io.ReadWriter - rw, err = mse.InitiateHandshake(struct { - io.Reader - io.Writer - }{c.r, c.w}, t.infoHash[:], nil) + rw, err = mse.InitiateHandshake( + struct { + io.Reader + io.Writer + }{c.r, c.w}, + t.infoHash[:], + nil, + func() uint32 { + switch { + case cl.config.ForceEncryption: + return mse.CryptoMethodRC4 + case cl.config.DisableEncryption: + return mse.CryptoMethodPlaintext + default: + return mse.AllSupportedCrypto + } + }(), + ) c.setRW(rw) if err != nil { return @@ -850,18 +950,16 @@ func (cl *Client) forSkeys(f func([]byte) bool) { // Do encryption and bittorrent handshakes as receiver. func (cl *Client) receiveHandshakes(c *connection) (t *Torrent, err error) { - if !cl.config.DisableEncryption { - var rw io.ReadWriter - rw, c.encrypted, err = maybeReceiveEncryptedHandshake(c.rw(), cl.forSkeys) - c.setRW(rw) - if err != nil { - if err == mse.ErrNoSecretKeyMatch { - err = nil - } - return + var rw io.ReadWriter + rw, c.headerEncrypted, c.cryptoMethod, err = handleEncryption(c.rw(), cl.forSkeys, cl.config.EncryptionPolicy) + c.setRW(rw) + if err != nil { + if err == mse.ErrNoSecretKeyMatch { + err = nil } + return } - if cl.config.ForceEncryption && !c.encrypted { + if cl.config.ForceEncryption && !c.headerEncrypted { err = errors.New("connection not encrypted") return } @@ -899,7 +997,7 @@ func (cl *Client) runInitiatedHandshookConn(c *connection, t *Torrent) { cl.dopplegangerAddrs[addr] = struct{}{} return } - cl.runHandshookConn(c, t) + cl.runHandshookConn(c, t, true) } func (cl *Client) runReceivedConn(c *connection) { @@ -926,14 +1024,14 @@ func (cl *Client) runReceivedConn(c *connection) { // doppleganger. return } - cl.runHandshookConn(c, t) + cl.runHandshookConn(c, t, false) } -func (cl *Client) runHandshookConn(c *connection, t *Torrent) { +func (cl *Client) runHandshookConn(c *connection, t *Torrent, outgoing bool) { c.conn.SetWriteDeadline(time.Time{}) c.r = deadlineReader{c.conn, c.r} completedHandshakeConnectionFlags.Add(c.connectionFlags(), 1) - if !t.addConnection(c) { + if !t.addConnection(c, outgoing) { return } defer t.dropConnection(c) @@ -1003,26 +1101,6 @@ func (cl *Client) sendInitialMessages(conn *connection, torrent *Torrent) { } } -func (cl *Client) peerUnchoked(torrent *Torrent, conn *connection) { - conn.updateRequests() -} - -func (cl *Client) connCancel(t *Torrent, cn *connection, r request) (ok bool) { - ok = cn.Cancel(r) - if ok { - postedCancels.Add(1) - } - return -} - -func (cl *Client) connDeleteRequest(t *Torrent, cn *connection, r request) bool { - if !cn.RequestPending(r) { - return false - } - delete(cn.Requests, r) - return true -} - // Process incoming ut_metadata message. func (cl *Client) gotMetadataExtensionMsg(payload []byte, t *Torrent, c *connection) error { var d map[string]int @@ -1064,7 +1142,7 @@ func (cl *Client) gotMetadataExtensionMsg(payload []byte, t *Torrent, c *connect } } -func (cl *Client) sendChunk(t *Torrent, c *connection, r request) error { +func (cl *Client) sendChunk(t *Torrent, c *connection, r request, msg func(pp.Message) bool) (more bool, err error) { // Count the chunk being sent, even if it isn't. b := make([]byte, r.Length) p := t.info.Piece(int(r.Index)) @@ -1073,9 +1151,9 @@ func (cl *Client) sendChunk(t *Torrent, c *connection, r request) error { if err == nil { panic("expected error") } - return err + return } - c.Post(pp.Message{ + more = msg(pp.Message{ Type: pp.Piece, Index: r.Index, Begin: r.Begin, @@ -1084,7 +1162,7 @@ func (cl *Client) sendChunk(t *Torrent, c *connection, r request) error { c.chunksSent++ uploadChunksPosted.Add(1) c.lastChunkSent = time.Now() - return nil + return } func (cl *Client) openNewConns(t *Torrent) { @@ -1138,11 +1216,14 @@ func (cl *Client) newTorrent(ih metainfo.Hash, specStorage storage.ClientImpl) ( peers: make(map[peersKey]Peer), conns: make(map[*connection]struct{}, 2*defaultEstablishedConnsPerTorrent), - halfOpen: make(map[string]struct{}), + halfOpen: make(map[string]Peer), pieceStateChanges: pubsub.NewPubSub(), storageOpener: storageClient, maxEstablishedConns: defaultEstablishedConnsPerTorrent, + + networkingEnabled: true, + requestStrategy: 2, } t.setChunkSize(defaultChunkSize) return @@ -1317,6 +1398,9 @@ func (cl *Client) DHT() *dht.Server { } func (cl *Client) AddDHTNodes(nodes []string) { + if cl.DHT() == nil { + return + } for _, n := range nodes { hmp := missinggo.SplitHostMaybePort(n) ip := net.ParseIP(hmp.Host) @@ -1349,6 +1433,7 @@ func (cl *Client) newConnection(nc net.Conn) (c *connection) { PeerChoked: true, PeerMaxRequests: 250, } + c.writerCond.L = &cl.mu c.setRW(connStatsReadWriter{nc, &cl.mu, c}) c.r = rateLimitedReader{cl.downloadLimit, c.r} return diff --git a/vendor/github.com/anacrolix/torrent/client_test.go b/vendor/github.com/anacrolix/torrent/client_test.go deleted file mode 100644 index b70e28975..000000000 --- a/vendor/github.com/anacrolix/torrent/client_test.go +++ /dev/null @@ -1,1101 +0,0 @@ -package torrent - -import ( - "encoding/binary" - "errors" - "fmt" - "io" - "io/ioutil" - "log" - "math/rand" - "net" - "os" - "path/filepath" - "strings" - "sync" - "testing" - "time" - - "github.com/anacrolix/dht" - _ "github.com/anacrolix/envpprof" - "github.com/anacrolix/missinggo" - "github.com/anacrolix/missinggo/filecache" - "github.com/anacrolix/missinggo/pubsub" - "github.com/anacrolix/utp" - "github.com/bradfitz/iter" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "golang.org/x/time/rate" - - "github.com/anacrolix/torrent/bencode" - "github.com/anacrolix/torrent/internal/testutil" - "github.com/anacrolix/torrent/iplist" - "github.com/anacrolix/torrent/metainfo" - "github.com/anacrolix/torrent/storage" -) - -func init() { - log.SetFlags(log.LstdFlags | log.Llongfile) -} - -var TestingConfig = Config{ - ListenAddr: "localhost:0", - NoDHT: true, - DisableTrackers: true, - DataDir: "/tmp/anacrolix", - DHTConfig: dht.ServerConfig{ - NoDefaultBootstrap: true, - }, - Debug: true, -} - -func TestClientDefault(t *testing.T) { - cl, err := NewClient(&TestingConfig) - require.NoError(t, err) - cl.Close() -} - -func TestAddDropTorrent(t *testing.T) { - cl, err := NewClient(&TestingConfig) - require.NoError(t, err) - defer cl.Close() - dir, mi := testutil.GreetingTestTorrent() - defer os.RemoveAll(dir) - tt, new, err := cl.AddTorrentSpec(TorrentSpecFromMetaInfo(mi)) - require.NoError(t, err) - assert.True(t, new) - tt.SetMaxEstablishedConns(0) - tt.SetMaxEstablishedConns(1) - tt.Drop() -} - -func TestAddTorrentNoSupportedTrackerSchemes(t *testing.T) { - t.SkipNow() -} - -func TestAddTorrentNoUsableURLs(t *testing.T) { - t.SkipNow() -} - -func TestAddPeersToUnknownTorrent(t *testing.T) { - t.SkipNow() -} - -func TestPieceHashSize(t *testing.T) { - if pieceHash.Size() != 20 { - t.FailNow() - } -} - -func TestTorrentInitialState(t *testing.T) { - dir, mi := testutil.GreetingTestTorrent() - defer os.RemoveAll(dir) - tor := &Torrent{ - infoHash: mi.HashInfoBytes(), - pieceStateChanges: pubsub.NewPubSub(), - } - tor.chunkSize = 2 - tor.storageOpener = storage.NewClient(storage.NewFile("/dev/null")) - // Needed to lock for asynchronous piece verification. - tor.cl = new(Client) - err := tor.setInfoBytes(mi.InfoBytes) - require.NoError(t, err) - require.Len(t, tor.pieces, 3) - tor.pendAllChunkSpecs(0) - tor.cl.mu.Lock() - assert.EqualValues(t, 3, tor.pieceNumPendingChunks(0)) - tor.cl.mu.Unlock() - assert.EqualValues(t, chunkSpec{4, 1}, chunkIndexSpec(2, tor.pieceLength(0), tor.chunkSize)) -} - -func TestUnmarshalPEXMsg(t *testing.T) { - var m peerExchangeMessage - if err := bencode.Unmarshal([]byte("d5:added12:\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0ce"), &m); err != nil { - t.Fatal(err) - } - if len(m.Added) != 2 { - t.FailNow() - } - if m.Added[0].Port != 0x506 { - t.FailNow() - } -} - -func TestReducedDialTimeout(t *testing.T) { - for _, _case := range []struct { - Max time.Duration - HalfOpenLimit int - PendingPeers int - ExpectedReduced time.Duration - }{ - {nominalDialTimeout, 40, 0, nominalDialTimeout}, - {nominalDialTimeout, 40, 1, nominalDialTimeout}, - {nominalDialTimeout, 40, 39, nominalDialTimeout}, - {nominalDialTimeout, 40, 40, nominalDialTimeout / 2}, - {nominalDialTimeout, 40, 80, nominalDialTimeout / 3}, - {nominalDialTimeout, 40, 4000, nominalDialTimeout / 101}, - } { - reduced := reducedDialTimeout(_case.Max, _case.HalfOpenLimit, _case.PendingPeers) - expected := _case.ExpectedReduced - if expected < minDialTimeout { - expected = minDialTimeout - } - if reduced != expected { - t.Fatalf("expected %s, got %s", _case.ExpectedReduced, reduced) - } - } -} - -func TestUTPRawConn(t *testing.T) { - l, err := utp.NewSocket("udp", "") - if err != nil { - t.Fatal(err) - } - defer l.Close() - go func() { - for { - _, err := l.Accept() - if err != nil { - break - } - } - }() - // Connect a UTP peer to see if the RawConn will still work. - s, _ := utp.NewSocket("udp", "") - defer s.Close() - utpPeer, err := s.Dial(fmt.Sprintf("localhost:%d", missinggo.AddrPort(l.Addr()))) - if err != nil { - t.Fatalf("error dialing utp listener: %s", err) - } - defer utpPeer.Close() - peer, err := net.ListenPacket("udp", ":0") - if err != nil { - t.Fatal(err) - } - defer peer.Close() - - msgsReceived := 0 - // How many messages to send. I've set this to double the channel buffer - // size in the raw packetConn. - const N = 200 - readerStopped := make(chan struct{}) - // The reader goroutine. - go func() { - defer close(readerStopped) - b := make([]byte, 500) - for i := 0; i < N; i++ { - n, _, err := l.ReadFrom(b) - if err != nil { - t.Fatalf("error reading from raw conn: %s", err) - } - msgsReceived++ - var d int - fmt.Sscan(string(b[:n]), &d) - if d != i { - log.Printf("got wrong number: expected %d, got %d", i, d) - } - } - }() - udpAddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("localhost:%d", missinggo.AddrPort(l.Addr()))) - if err != nil { - t.Fatal(err) - } - for i := 0; i < N; i++ { - _, err := peer.WriteTo([]byte(fmt.Sprintf("%d", i)), udpAddr) - if err != nil { - t.Fatal(err) - } - time.Sleep(time.Microsecond) - } - select { - case <-readerStopped: - case <-time.After(time.Second): - t.Fatal("reader timed out") - } - if msgsReceived != N { - t.Fatalf("messages received: %d", msgsReceived) - } -} - -func TestTwoClientsArbitraryPorts(t *testing.T) { - for i := 0; i < 2; i++ { - cl, err := NewClient(&TestingConfig) - if err != nil { - t.Fatal(err) - } - defer cl.Close() - } -} - -func TestAddDropManyTorrents(t *testing.T) { - cl, err := NewClient(&TestingConfig) - require.NoError(t, err) - defer cl.Close() - for i := range iter.N(1000) { - var spec TorrentSpec - binary.PutVarint(spec.InfoHash[:], int64(i)) - tt, new, err := cl.AddTorrentSpec(&spec) - assert.NoError(t, err) - assert.True(t, new) - defer tt.Drop() - } -} - -type FileCacheClientStorageFactoryParams struct { - Capacity int64 - SetCapacity bool - Wrapper func(*filecache.Cache) storage.ClientImpl -} - -func NewFileCacheClientStorageFactory(ps FileCacheClientStorageFactoryParams) storageFactory { - return func(dataDir string) storage.ClientImpl { - fc, err := filecache.NewCache(dataDir) - if err != nil { - panic(err) - } - if ps.SetCapacity { - fc.SetCapacity(ps.Capacity) - } - return ps.Wrapper(fc) - } -} - -type storageFactory func(string) storage.ClientImpl - -func TestClientTransferDefault(t *testing.T) { - testClientTransfer(t, testClientTransferParams{ - ExportClientStatus: true, - LeecherStorage: NewFileCacheClientStorageFactory(FileCacheClientStorageFactoryParams{ - Wrapper: fileCachePieceResourceStorage, - }), - }) -} - -func TestClientTransferRateLimitedUpload(t *testing.T) { - started := time.Now() - testClientTransfer(t, testClientTransferParams{ - // We are uploading 13 bytes (the length of the greeting torrent). The - // chunks are 2 bytes in length. Then the smallest burst we can run - // with is 2. Time taken is (13-burst)/rate. - SeederUploadRateLimiter: rate.NewLimiter(11, 2), - }) - require.True(t, time.Since(started) > time.Second) -} - -func TestClientTransferRateLimitedDownload(t *testing.T) { - testClientTransfer(t, testClientTransferParams{ - LeecherDownloadRateLimiter: rate.NewLimiter(512, 512), - }) -} - -func fileCachePieceResourceStorage(fc *filecache.Cache) storage.ClientImpl { - return storage.NewResourcePieces(fc.AsResourceProvider()) -} - -func TestClientTransferSmallCache(t *testing.T) { - testClientTransfer(t, testClientTransferParams{ - LeecherStorage: NewFileCacheClientStorageFactory(FileCacheClientStorageFactoryParams{ - SetCapacity: true, - // Going below the piece length means it can't complete a piece so - // that it can be hashed. - Capacity: 5, - Wrapper: fileCachePieceResourceStorage, - }), - SetReadahead: true, - // Can't readahead too far or the cache will thrash and drop data we - // thought we had. - Readahead: 0, - ExportClientStatus: true, - }) -} - -func TestClientTransferVarious(t *testing.T) { - // Leecher storage - for _, ls := range []storageFactory{ - NewFileCacheClientStorageFactory(FileCacheClientStorageFactoryParams{ - Wrapper: fileCachePieceResourceStorage, - }), - storage.NewBoltDB, - } { - // Seeder storage - for _, ss := range []func(string) storage.ClientImpl{ - storage.NewFile, - storage.NewMMap, - } { - for _, responsive := range []bool{false, true} { - testClientTransfer(t, testClientTransferParams{ - Responsive: responsive, - SeederStorage: ss, - LeecherStorage: ls, - }) - for _, readahead := range []int64{-1, 0, 1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, 20} { - testClientTransfer(t, testClientTransferParams{ - SeederStorage: ss, - Responsive: responsive, - SetReadahead: true, - Readahead: readahead, - LeecherStorage: ls, - }) - } - } - } - } -} - -type testClientTransferParams struct { - Responsive bool - Readahead int64 - SetReadahead bool - ExportClientStatus bool - LeecherStorage func(string) storage.ClientImpl - SeederStorage func(string) storage.ClientImpl - SeederUploadRateLimiter *rate.Limiter - LeecherDownloadRateLimiter *rate.Limiter -} - -// Creates a seeder and a leecher, and ensures the data transfers when a read -// is attempted on the leecher. -func testClientTransfer(t *testing.T, ps testClientTransferParams) { - greetingTempDir, mi := testutil.GreetingTestTorrent() - defer os.RemoveAll(greetingTempDir) - // Create seeder and a Torrent. - cfg := TestingConfig - cfg.Seed = true - cfg.UploadRateLimiter = ps.SeederUploadRateLimiter - // cfg.ListenAddr = "localhost:4000" - if ps.SeederStorage != nil { - cfg.DefaultStorage = ps.SeederStorage(greetingTempDir) - } else { - cfg.DataDir = greetingTempDir - } - seeder, err := NewClient(&cfg) - require.NoError(t, err) - defer seeder.Close() - if ps.ExportClientStatus { - testutil.ExportStatusWriter(seeder, "s") - } - // seederTorrent, new, err := seeder.AddTorrentSpec(TorrentSpecFromMetaInfo(mi)) - _, new, err := seeder.AddTorrentSpec(TorrentSpecFromMetaInfo(mi)) - require.NoError(t, err) - assert.True(t, new) - // Create leecher and a Torrent. - leecherDataDir, err := ioutil.TempDir("", "") - require.NoError(t, err) - defer os.RemoveAll(leecherDataDir) - if ps.LeecherStorage == nil { - cfg.DataDir = leecherDataDir - } else { - cfg.DefaultStorage = ps.LeecherStorage(leecherDataDir) - } - cfg.DownloadRateLimiter = ps.LeecherDownloadRateLimiter - // cfg.ListenAddr = "localhost:4001" - leecher, err := NewClient(&cfg) - require.NoError(t, err) - defer leecher.Close() - if ps.ExportClientStatus { - testutil.ExportStatusWriter(leecher, "l") - } - leecherGreeting, new, err := leecher.AddTorrentSpec(func() (ret *TorrentSpec) { - ret = TorrentSpecFromMetaInfo(mi) - ret.ChunkSize = 2 - ret.Storage = storage.NewFile(leecherDataDir) - return - }()) - require.NoError(t, err) - assert.True(t, new) - // Now do some things with leecher and seeder. - addClientPeer(leecherGreeting, seeder) - r := leecherGreeting.NewReader() - defer r.Close() - if ps.Responsive { - r.SetResponsive() - } - if ps.SetReadahead { - r.SetReadahead(ps.Readahead) - } - assertReadAllGreeting(t, r) - // After one read through, we can assume certain torrent statistics. - // These are not a strict requirement. It is however interesting to - // follow. - // t.Logf("%#v", seederTorrent.Stats()) - // assert.EqualValues(t, 13, seederTorrent.Stats().DataBytesWritten) - // assert.EqualValues(t, 8, seederTorrent.Stats().ChunksWritten) - // assert.EqualValues(t, 13, leecherGreeting.Stats().DataBytesRead) - // assert.EqualValues(t, 8, leecherGreeting.Stats().ChunksRead) - // Read through again for the cases where the torrent data size exceeds - // the size of the cache. - assertReadAllGreeting(t, r) -} - -func assertReadAllGreeting(t *testing.T, r io.ReadSeeker) { - pos, err := r.Seek(0, os.SEEK_SET) - assert.NoError(t, err) - assert.EqualValues(t, 0, pos) - _greeting, err := ioutil.ReadAll(r) - assert.NoError(t, err) - assert.EqualValues(t, testutil.GreetingFileContents, _greeting) -} - -// Check that after completing leeching, a leecher transitions to a seeding -// correctly. Connected in a chain like so: Seeder <-> Leecher <-> LeecherLeecher. -func TestSeedAfterDownloading(t *testing.T) { - greetingTempDir, mi := testutil.GreetingTestTorrent() - defer os.RemoveAll(greetingTempDir) - cfg := TestingConfig - cfg.Seed = true - cfg.DataDir = greetingTempDir - seeder, err := NewClient(&cfg) - require.NoError(t, err) - defer seeder.Close() - testutil.ExportStatusWriter(seeder, "s") - seeder.AddTorrentSpec(TorrentSpecFromMetaInfo(mi)) - cfg.DataDir, err = ioutil.TempDir("", "") - require.NoError(t, err) - defer os.RemoveAll(cfg.DataDir) - leecher, err := NewClient(&cfg) - require.NoError(t, err) - defer leecher.Close() - testutil.ExportStatusWriter(leecher, "l") - cfg.Seed = false - // cfg.TorrentDataOpener = nil - cfg.DataDir, err = ioutil.TempDir("", "") - require.NoError(t, err) - defer os.RemoveAll(cfg.DataDir) - leecherLeecher, _ := NewClient(&cfg) - defer leecherLeecher.Close() - testutil.ExportStatusWriter(leecherLeecher, "ll") - leecherGreeting, _, _ := leecher.AddTorrentSpec(func() (ret *TorrentSpec) { - ret = TorrentSpecFromMetaInfo(mi) - ret.ChunkSize = 2 - return - }()) - llg, _, _ := leecherLeecher.AddTorrentSpec(func() (ret *TorrentSpec) { - ret = TorrentSpecFromMetaInfo(mi) - ret.ChunkSize = 3 - return - }()) - // Simultaneously DownloadAll in Leecher, and read the contents - // consecutively in LeecherLeecher. This non-deterministically triggered a - // case where the leecher wouldn't unchoke the LeecherLeecher. - var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() - r := llg.NewReader() - defer r.Close() - b, err := ioutil.ReadAll(r) - require.NoError(t, err) - assert.EqualValues(t, testutil.GreetingFileContents, b) - }() - addClientPeer(leecherGreeting, seeder) - addClientPeer(leecherGreeting, leecherLeecher) - wg.Add(1) - go func() { - defer wg.Done() - leecherGreeting.DownloadAll() - leecher.WaitAll() - }() - wg.Wait() -} - -func TestMergingTrackersByAddingSpecs(t *testing.T) { - cl, err := NewClient(&TestingConfig) - require.NoError(t, err) - defer cl.Close() - spec := TorrentSpec{} - T, new, _ := cl.AddTorrentSpec(&spec) - if !new { - t.FailNow() - } - spec.Trackers = [][]string{{"http://a"}, {"udp://b"}} - _, new, _ = cl.AddTorrentSpec(&spec) - assert.False(t, new) - assert.EqualValues(t, [][]string{{"http://a"}, {"udp://b"}}, T.metainfo.AnnounceList) - // Because trackers are disabled in TestingConfig. - assert.EqualValues(t, 0, len(T.trackerAnnouncers)) -} - -type badStorage struct{} - -func (bs badStorage) OpenTorrent(*metainfo.Info, metainfo.Hash) (storage.TorrentImpl, error) { - return bs, nil -} - -func (bs badStorage) Close() error { - return nil -} - -func (bs badStorage) Piece(p metainfo.Piece) storage.PieceImpl { - return badStoragePiece{p} -} - -type badStoragePiece struct { - p metainfo.Piece -} - -func (p badStoragePiece) WriteAt(b []byte, off int64) (int, error) { - return 0, nil -} - -func (p badStoragePiece) GetIsComplete() bool { - return true -} - -func (p badStoragePiece) MarkComplete() error { - return errors.New("psyyyyyyyche") -} - -func (p badStoragePiece) MarkNotComplete() error { - return errors.New("psyyyyyyyche") -} - -func (p badStoragePiece) randomlyTruncatedDataString() string { - return "hello, world\n"[:rand.Intn(14)] -} - -func (p badStoragePiece) ReadAt(b []byte, off int64) (n int, err error) { - r := strings.NewReader(p.randomlyTruncatedDataString()) - return r.ReadAt(b, off+p.p.Offset()) -} - -// We read from a piece which is marked completed, but is missing data. -func TestCompletedPieceWrongSize(t *testing.T) { - cfg := TestingConfig - cfg.DefaultStorage = badStorage{} - cl, err := NewClient(&cfg) - require.NoError(t, err) - defer cl.Close() - info := metainfo.Info{ - PieceLength: 15, - Pieces: make([]byte, 20), - Files: []metainfo.FileInfo{ - {Path: []string{"greeting"}, Length: 13}, - }, - } - b, err := bencode.Marshal(info) - tt, new, err := cl.AddTorrentSpec(&TorrentSpec{ - InfoBytes: b, - InfoHash: metainfo.HashBytes(b), - }) - require.NoError(t, err) - defer tt.Drop() - assert.True(t, new) - r := tt.NewReader() - defer r.Close() - b, err = ioutil.ReadAll(r) - assert.Len(t, b, 13) - assert.NoError(t, err) -} - -func BenchmarkAddLargeTorrent(b *testing.B) { - cfg := TestingConfig - cfg.DisableTCP = true - cfg.DisableUTP = true - cfg.ListenAddr = "redonk" - cl, err := NewClient(&cfg) - require.NoError(b, err) - defer cl.Close() - for range iter.N(b.N) { - t, err := cl.AddTorrentFromFile("testdata/bootstrap.dat.torrent") - if err != nil { - b.Fatal(err) - } - t.Drop() - } -} - -func TestResponsive(t *testing.T) { - seederDataDir, mi := testutil.GreetingTestTorrent() - defer os.RemoveAll(seederDataDir) - cfg := TestingConfig - cfg.Seed = true - cfg.DataDir = seederDataDir - seeder, err := NewClient(&cfg) - require.Nil(t, err) - defer seeder.Close() - seeder.AddTorrentSpec(TorrentSpecFromMetaInfo(mi)) - leecherDataDir, err := ioutil.TempDir("", "") - require.Nil(t, err) - defer os.RemoveAll(leecherDataDir) - cfg = TestingConfig - cfg.DataDir = leecherDataDir - leecher, err := NewClient(&cfg) - require.Nil(t, err) - defer leecher.Close() - leecherTorrent, _, _ := leecher.AddTorrentSpec(func() (ret *TorrentSpec) { - ret = TorrentSpecFromMetaInfo(mi) - ret.ChunkSize = 2 - return - }()) - addClientPeer(leecherTorrent, seeder) - reader := leecherTorrent.NewReader() - defer reader.Close() - reader.SetReadahead(0) - reader.SetResponsive() - b := make([]byte, 2) - _, err = reader.Seek(3, os.SEEK_SET) - require.NoError(t, err) - _, err = io.ReadFull(reader, b) - assert.Nil(t, err) - assert.EqualValues(t, "lo", string(b)) - _, err = reader.Seek(11, os.SEEK_SET) - require.NoError(t, err) - n, err := io.ReadFull(reader, b) - assert.Nil(t, err) - assert.EqualValues(t, 2, n) - assert.EqualValues(t, "d\n", string(b)) -} - -func TestTorrentDroppedDuringResponsiveRead(t *testing.T) { - seederDataDir, mi := testutil.GreetingTestTorrent() - defer os.RemoveAll(seederDataDir) - cfg := TestingConfig - cfg.Seed = true - cfg.DataDir = seederDataDir - seeder, err := NewClient(&cfg) - require.Nil(t, err) - defer seeder.Close() - seeder.AddTorrentSpec(TorrentSpecFromMetaInfo(mi)) - leecherDataDir, err := ioutil.TempDir("", "") - require.Nil(t, err) - defer os.RemoveAll(leecherDataDir) - cfg = TestingConfig - cfg.DataDir = leecherDataDir - leecher, err := NewClient(&cfg) - require.Nil(t, err) - defer leecher.Close() - leecherTorrent, _, _ := leecher.AddTorrentSpec(func() (ret *TorrentSpec) { - ret = TorrentSpecFromMetaInfo(mi) - ret.ChunkSize = 2 - return - }()) - addClientPeer(leecherTorrent, seeder) - reader := leecherTorrent.NewReader() - defer reader.Close() - reader.SetReadahead(0) - reader.SetResponsive() - b := make([]byte, 2) - _, err = reader.Seek(3, os.SEEK_SET) - require.NoError(t, err) - _, err = io.ReadFull(reader, b) - assert.Nil(t, err) - assert.EqualValues(t, "lo", string(b)) - go leecherTorrent.Drop() - _, err = reader.Seek(11, os.SEEK_SET) - require.NoError(t, err) - n, err := reader.Read(b) - assert.EqualError(t, err, "torrent closed") - assert.EqualValues(t, 0, n) -} - -func TestDHTInheritBlocklist(t *testing.T) { - ipl := iplist.New(nil) - require.NotNil(t, ipl) - cfg := TestingConfig - cfg.IPBlocklist = ipl - cfg.NoDHT = false - cl, err := NewClient(&cfg) - require.NoError(t, err) - defer cl.Close() - require.Equal(t, ipl, cl.DHT().IPBlocklist()) -} - -// Check that stuff is merged in subsequent AddTorrentSpec for the same -// infohash. -func TestAddTorrentSpecMerging(t *testing.T) { - cl, err := NewClient(&TestingConfig) - require.NoError(t, err) - defer cl.Close() - dir, mi := testutil.GreetingTestTorrent() - defer os.RemoveAll(dir) - tt, new, err := cl.AddTorrentSpec(&TorrentSpec{ - InfoHash: mi.HashInfoBytes(), - }) - require.NoError(t, err) - require.True(t, new) - require.Nil(t, tt.Info()) - _, new, err = cl.AddTorrentSpec(TorrentSpecFromMetaInfo(mi)) - require.NoError(t, err) - require.False(t, new) - require.NotNil(t, tt.Info()) -} - -func TestTorrentDroppedBeforeGotInfo(t *testing.T) { - dir, mi := testutil.GreetingTestTorrent() - os.RemoveAll(dir) - cl, _ := NewClient(&TestingConfig) - defer cl.Close() - tt, _, _ := cl.AddTorrentSpec(&TorrentSpec{ - InfoHash: mi.HashInfoBytes(), - }) - tt.Drop() - assert.EqualValues(t, 0, len(cl.Torrents())) - select { - case <-tt.GotInfo(): - t.FailNow() - default: - } -} - -func writeTorrentData(ts *storage.Torrent, info metainfo.Info, b []byte) { - for i := range iter.N(info.NumPieces()) { - p := info.Piece(i) - ts.Piece(p).WriteAt(b[p.Offset():p.Offset()+p.Length()], 0) - } -} - -func testAddTorrentPriorPieceCompletion(t *testing.T, alreadyCompleted bool, csf func(*filecache.Cache) storage.ClientImpl) { - fileCacheDir, err := ioutil.TempDir("", "") - require.NoError(t, err) - defer os.RemoveAll(fileCacheDir) - fileCache, err := filecache.NewCache(fileCacheDir) - require.NoError(t, err) - greetingDataTempDir, greetingMetainfo := testutil.GreetingTestTorrent() - defer os.RemoveAll(greetingDataTempDir) - filePieceStore := csf(fileCache) - info, err := greetingMetainfo.UnmarshalInfo() - require.NoError(t, err) - ih := greetingMetainfo.HashInfoBytes() - greetingData, err := storage.NewClient(filePieceStore).OpenTorrent(&info, ih) - require.NoError(t, err) - writeTorrentData(greetingData, info, []byte(testutil.GreetingFileContents)) - // require.Equal(t, len(testutil.GreetingFileContents), written) - // require.NoError(t, err) - for i := 0; i < info.NumPieces(); i++ { - p := info.Piece(i) - if alreadyCompleted { - err := greetingData.Piece(p).MarkComplete() - assert.NoError(t, err) - } - } - cfg := TestingConfig - // TODO: Disable network option? - cfg.DisableTCP = true - cfg.DisableUTP = true - cfg.DefaultStorage = filePieceStore - cl, err := NewClient(&cfg) - require.NoError(t, err) - defer cl.Close() - tt, err := cl.AddTorrent(greetingMetainfo) - require.NoError(t, err) - psrs := tt.PieceStateRuns() - assert.Len(t, psrs, 1) - assert.EqualValues(t, 3, psrs[0].Length) - assert.Equal(t, alreadyCompleted, psrs[0].Complete) - if alreadyCompleted { - r := tt.NewReader() - b, err := ioutil.ReadAll(r) - assert.NoError(t, err) - assert.EqualValues(t, testutil.GreetingFileContents, b) - } -} - -func TestAddTorrentPiecesAlreadyCompleted(t *testing.T) { - testAddTorrentPriorPieceCompletion(t, true, fileCachePieceResourceStorage) -} - -func TestAddTorrentPiecesNotAlreadyCompleted(t *testing.T) { - testAddTorrentPriorPieceCompletion(t, false, fileCachePieceResourceStorage) -} - -func TestAddMetainfoWithNodes(t *testing.T) { - cfg := TestingConfig - cfg.NoDHT = false - // For now, we want to just jam the nodes into the table, without - // verifying them first. Also the DHT code doesn't support mixing secure - // and insecure nodes if security is enabled (yet). - cfg.DHTConfig.NoSecurity = true - cl, err := NewClient(&cfg) - require.NoError(t, err) - defer cl.Close() - assert.EqualValues(t, cl.DHT().NumNodes(), 0) - tt, err := cl.AddTorrentFromFile("metainfo/testdata/issue_65a.torrent") - require.NoError(t, err) - assert.Len(t, tt.metainfo.AnnounceList, 5) - assert.EqualValues(t, 6, cl.DHT().NumNodes()) -} - -type testDownloadCancelParams struct { - ExportClientStatus bool - SetLeecherStorageCapacity bool - LeecherStorageCapacity int64 - Cancel bool -} - -func testDownloadCancel(t *testing.T, ps testDownloadCancelParams) { - greetingTempDir, mi := testutil.GreetingTestTorrent() - defer os.RemoveAll(greetingTempDir) - cfg := TestingConfig - cfg.Seed = true - cfg.DataDir = greetingTempDir - seeder, err := NewClient(&cfg) - require.NoError(t, err) - defer seeder.Close() - if ps.ExportClientStatus { - testutil.ExportStatusWriter(seeder, "s") - } - seeder.AddTorrentSpec(TorrentSpecFromMetaInfo(mi)) - leecherDataDir, err := ioutil.TempDir("", "") - require.NoError(t, err) - defer os.RemoveAll(leecherDataDir) - fc, err := filecache.NewCache(leecherDataDir) - require.NoError(t, err) - if ps.SetLeecherStorageCapacity { - fc.SetCapacity(ps.LeecherStorageCapacity) - } - cfg.DefaultStorage = storage.NewResourcePieces(fc.AsResourceProvider()) - cfg.DataDir = leecherDataDir - leecher, _ := NewClient(&cfg) - defer leecher.Close() - if ps.ExportClientStatus { - testutil.ExportStatusWriter(leecher, "l") - } - leecherGreeting, new, err := leecher.AddTorrentSpec(func() (ret *TorrentSpec) { - ret = TorrentSpecFromMetaInfo(mi) - ret.ChunkSize = 2 - return - }()) - require.NoError(t, err) - assert.True(t, new) - psc := leecherGreeting.SubscribePieceStateChanges() - defer psc.Close() - leecherGreeting.DownloadAll() - if ps.Cancel { - leecherGreeting.CancelPieces(0, leecherGreeting.NumPieces()) - } - addClientPeer(leecherGreeting, seeder) - completes := make(map[int]bool, 3) -values: - for { - // started := time.Now() - select { - case _v := <-psc.Values: - // log.Print(time.Since(started)) - v := _v.(PieceStateChange) - completes[v.Index] = v.Complete - case <-time.After(100 * time.Millisecond): - break values - } - } - if ps.Cancel { - assert.EqualValues(t, map[int]bool{0: false, 1: false, 2: false}, completes) - } else { - assert.EqualValues(t, map[int]bool{0: true, 1: true, 2: true}, completes) - } - -} - -func TestTorrentDownloadAll(t *testing.T) { - testDownloadCancel(t, testDownloadCancelParams{}) -} - -func TestTorrentDownloadAllThenCancel(t *testing.T) { - testDownloadCancel(t, testDownloadCancelParams{ - Cancel: true, - }) -} - -// Ensure that it's an error for a peer to send an invalid have message. -func TestPeerInvalidHave(t *testing.T) { - cl, err := NewClient(&TestingConfig) - require.NoError(t, err) - defer cl.Close() - info := metainfo.Info{ - PieceLength: 1, - Pieces: make([]byte, 20), - Files: []metainfo.FileInfo{{Length: 1}}, - } - infoBytes, err := bencode.Marshal(info) - require.NoError(t, err) - tt, _new, err := cl.AddTorrentSpec(&TorrentSpec{ - InfoBytes: infoBytes, - InfoHash: metainfo.HashBytes(infoBytes), - }) - require.NoError(t, err) - assert.True(t, _new) - defer tt.Drop() - cn := &connection{ - t: tt, - } - assert.NoError(t, cn.peerSentHave(0)) - assert.Error(t, cn.peerSentHave(1)) -} - -func TestPieceCompletedInStorageButNotClient(t *testing.T) { - greetingTempDir, greetingMetainfo := testutil.GreetingTestTorrent() - defer os.RemoveAll(greetingTempDir) - cfg := TestingConfig - cfg.DataDir = greetingTempDir - seeder, err := NewClient(&TestingConfig) - require.NoError(t, err) - seeder.AddTorrentSpec(&TorrentSpec{ - InfoBytes: greetingMetainfo.InfoBytes, - }) -} - -func TestPrepareTrackerAnnounce(t *testing.T) { - cl := &Client{} - blocked, urlToUse, host, err := cl.prepareTrackerAnnounceUnlocked("http://localhost:1234/announce?herp") - require.NoError(t, err) - assert.False(t, blocked) - assert.EqualValues(t, "localhost:1234", host) - assert.EqualValues(t, "http://127.0.0.1:1234/announce?herp", urlToUse) -} - -// Check that when the listen port is 0, all the protocols listened on have -// the same port, and it isn't zero. -func TestClientDynamicListenPortAllProtocols(t *testing.T) { - cl, err := NewClient(&TestingConfig) - require.NoError(t, err) - defer cl.Close() - assert.NotEqual(t, 0, missinggo.AddrPort(cl.ListenAddr())) - assert.Equal(t, missinggo.AddrPort(cl.utpSock.Addr()), missinggo.AddrPort(cl.tcpListener.Addr())) -} - -func TestClientDynamicListenTCPOnly(t *testing.T) { - cfg := TestingConfig - cfg.DisableUTP = true - cl, err := NewClient(&cfg) - require.NoError(t, err) - defer cl.Close() - assert.NotEqual(t, 0, missinggo.AddrPort(cl.ListenAddr())) - assert.Nil(t, cl.utpSock) -} - -func TestClientDynamicListenUTPOnly(t *testing.T) { - cfg := TestingConfig - cfg.DisableTCP = true - cl, err := NewClient(&cfg) - require.NoError(t, err) - defer cl.Close() - assert.NotEqual(t, 0, missinggo.AddrPort(cl.ListenAddr())) - assert.Nil(t, cl.tcpListener) -} - -func TestClientDynamicListenPortNoProtocols(t *testing.T) { - cfg := TestingConfig - cfg.DisableTCP = true - cfg.DisableUTP = true - cl, err := NewClient(&cfg) - require.NoError(t, err) - defer cl.Close() - assert.Nil(t, cl.ListenAddr()) -} - -func addClientPeer(t *Torrent, cl *Client) { - t.AddPeers([]Peer{ - { - IP: missinggo.AddrIP(cl.ListenAddr()), - Port: missinggo.AddrPort(cl.ListenAddr()), - }, - }) -} - -func printConnPeerCounts(t *Torrent) { - t.cl.mu.Lock() - log.Println(len(t.conns), len(t.peers)) - t.cl.mu.Unlock() -} - -func totalConns(tts []*Torrent) (ret int) { - for _, tt := range tts { - tt.cl.mu.Lock() - ret += len(tt.conns) - tt.cl.mu.Unlock() - } - return -} - -func TestSetMaxEstablishedConn(t *testing.T) { - var tts []*Torrent - ih := testutil.GreetingMetaInfo().HashInfoBytes() - cfg := TestingConfig - for i := range iter.N(3) { - cl, err := NewClient(&cfg) - require.NoError(t, err) - defer cl.Close() - tt, _ := cl.AddTorrentInfoHash(ih) - tt.SetMaxEstablishedConns(2) - testutil.ExportStatusWriter(cl, fmt.Sprintf("%d", i)) - tts = append(tts, tt) - } - addPeers := func() { - for i, tt := range tts { - for _, _tt := range tts[:i] { - addClientPeer(tt, _tt.cl) - } - } - } - waitTotalConns := func(num int) { - for totalConns(tts) != num { - time.Sleep(time.Millisecond) - } - } - addPeers() - waitTotalConns(6) - tts[0].SetMaxEstablishedConns(1) - waitTotalConns(4) - tts[0].SetMaxEstablishedConns(0) - waitTotalConns(2) - tts[0].SetMaxEstablishedConns(1) - addPeers() - waitTotalConns(4) - tts[0].SetMaxEstablishedConns(2) - addPeers() - waitTotalConns(6) -} - -func makeMagnet(t *testing.T, cl *Client, dir string, name string) string { - os.MkdirAll(dir, 0770) - file, err := os.Create(filepath.Join(dir, name)) - require.NoError(t, err) - file.Write([]byte(name)) - file.Close() - mi := metainfo.MetaInfo{} - mi.SetDefaults() - info := metainfo.Info{PieceLength: 256 * 1024} - err = info.BuildFromFilePath(filepath.Join(dir, name)) - require.NoError(t, err) - mi.InfoBytes, err = bencode.Marshal(info) - require.NoError(t, err) - magnet := mi.Magnet(name, mi.HashInfoBytes()).String() - tr, err := cl.AddTorrent(&mi) - require.NoError(t, err) - assert.True(t, tr.Seeding()) - return magnet -} - -// https://github.com/anacrolix/torrent/issues/114 -func TestMultipleTorrentsWithEncryption(t *testing.T) { - cfg := TestingConfig - cfg.DisableUTP = true - cfg.Seed = true - cfg.DataDir = filepath.Join(cfg.DataDir, "server") - cfg.Debug = true - cfg.ForceEncryption = true - os.Mkdir(cfg.DataDir, 0755) - server, err := NewClient(&cfg) - require.NoError(t, err) - defer server.Close() - testutil.ExportStatusWriter(server, "s") - magnet1 := makeMagnet(t, server, cfg.DataDir, "test1") - makeMagnet(t, server, cfg.DataDir, "test2") - cfg = TestingConfig - cfg.DisableUTP = true - cfg.DataDir = filepath.Join(cfg.DataDir, "client") - cfg.Debug = true - cfg.ForceEncryption = true - client, err := NewClient(&cfg) - require.NoError(t, err) - defer client.Close() - testutil.ExportStatusWriter(client, "c") - tr, err := client.AddMagnet(magnet1) - require.NoError(t, err) - tr.AddPeers([]Peer{{ - IP: missinggo.AddrIP(server.ListenAddr()), - Port: missinggo.AddrPort(server.ListenAddr()), - }}) - <-tr.GotInfo() - tr.DownloadAll() - client.WaitAll() -} diff --git a/vendor/github.com/anacrolix/torrent/cmd/dht-get-peers/main.go b/vendor/github.com/anacrolix/torrent/cmd/dht-get-peers/main.go deleted file mode 100644 index d72c34e58..000000000 --- a/vendor/github.com/anacrolix/torrent/cmd/dht-get-peers/main.go +++ /dev/null @@ -1,165 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "io" - "log" - "net" - "os" - "os/signal" - - "github.com/anacrolix/dht" - "github.com/anacrolix/dht/krpc" - _ "github.com/anacrolix/envpprof" -) - -var ( - tableFileName = flag.String("tableFile", "", "name of file for storing node info") - serveAddr = flag.String("serveAddr", ":0", "local UDP address") - infoHash = flag.String("infoHash", "", "torrent infohash") - once = flag.Bool("once", false, "only do one scrape iteration") - - s *dht.Server - quitting = make(chan struct{}) -) - -func loadTable() error { - if *tableFileName == "" { - return nil - } - f, err := os.Open(*tableFileName) - if os.IsNotExist(err) { - return nil - } - if err != nil { - return fmt.Errorf("error opening table file: %s", err) - } - defer f.Close() - added := 0 - for { - b := make([]byte, krpc.CompactIPv4NodeInfoLen) - _, err := io.ReadFull(f, b) - if err == io.EOF { - break - } - if err != nil { - return fmt.Errorf("error reading table file: %s", err) - } - var ni krpc.NodeInfo - err = ni.UnmarshalCompactIPv4(b) - if err != nil { - return fmt.Errorf("error unmarshaling compact node info: %s", err) - } - s.AddNode(ni) - added++ - } - log.Printf("loaded %d nodes from table file", added) - return nil -} - -func init() { - log.SetFlags(log.LstdFlags | log.Lshortfile) - flag.Parse() - switch len(*infoHash) { - case 20: - case 40: - _, err := fmt.Sscanf(*infoHash, "%x", infoHash) - if err != nil { - log.Fatal(err) - } - default: - log.Fatal("require 20 byte infohash") - } - var err error - s, err = dht.NewServer(&dht.ServerConfig{ - Addr: *serveAddr, - }) - if err != nil { - log.Fatal(err) - } - err = loadTable() - if err != nil { - log.Fatalf("error loading table: %s", err) - } - log.Printf("dht server on %s, ID is %x", s.Addr(), s.ID()) - setupSignals() -} - -func saveTable() error { - goodNodes := s.Nodes() - if *tableFileName == "" { - if len(goodNodes) != 0 { - log.Print("good nodes were discarded because you didn't specify a table file") - } - return nil - } - f, err := os.OpenFile(*tableFileName, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666) - if err != nil { - return fmt.Errorf("error opening table file: %s", err) - } - defer f.Close() - for _, nodeInfo := range goodNodes { - var b [krpc.CompactIPv4NodeInfoLen]byte - err := nodeInfo.PutCompact(b[:]) - if err != nil { - return fmt.Errorf("error compacting node info: %s", err) - } - _, err = f.Write(b[:]) - if err != nil { - return fmt.Errorf("error writing compact node info: %s", err) - } - } - log.Printf("saved %d nodes to table file", len(goodNodes)) - return nil -} - -func setupSignals() { - ch := make(chan os.Signal) - signal.Notify(ch, os.Interrupt) - go func() { - <-ch - close(quitting) - }() -} - -func main() { - seen := make(map[string]struct{}) -getPeers: - for { - var ih [20]byte - copy(ih[:], *infoHash) - ps, err := s.Announce(ih, 0, false) - if err != nil { - log.Fatal(err) - } - values: - for { - select { - case v, ok := <-ps.Peers: - if !ok { - break values - } - log.Printf("received %d peers from %x", len(v.Peers), v.NodeInfo.ID) - for _, p := range v.Peers { - if _, ok := seen[p.String()]; ok { - continue - } - seen[p.String()] = struct{}{} - fmt.Println((&net.UDPAddr{ - IP: p.IP[:], - Port: int(p.Port), - }).String()) - } - case <-quitting: - break getPeers - } - } - if *once { - break - } - } - if err := saveTable(); err != nil { - log.Printf("error saving node table: %s", err) - } -} diff --git a/vendor/github.com/anacrolix/torrent/cmd/dht-ping/main.go b/vendor/github.com/anacrolix/torrent/cmd/dht-ping/main.go deleted file mode 100644 index fb12f8441..000000000 --- a/vendor/github.com/anacrolix/torrent/cmd/dht-ping/main.go +++ /dev/null @@ -1,93 +0,0 @@ -// Pings DHT nodes with the given network addresses. -package main - -import ( - "fmt" - "log" - "math" - "net" - "os" - "time" - - "github.com/anacrolix/dht" - "github.com/anacrolix/dht/krpc" - "github.com/anacrolix/tagflag" - "github.com/bradfitz/iter" -) - -func main() { - log.SetFlags(log.LstdFlags | log.Lshortfile) - var args = struct { - Timeout time.Duration - Nodes []string `type:"pos" arity:"+" help:"nodes to ping e.g. router.bittorrent.com:6881"` - }{ - Timeout: math.MaxInt64, - } - tagflag.Parse(&args) - s, err := dht.NewServer(nil) - if err != nil { - log.Fatal(err) - } - log.Printf("dht server on %s", s.Addr()) - timeout := time.After(args.Timeout) - pongChan := make(chan pong) - startPings(s, pongChan, args.Nodes) - numResp := receivePongs(pongChan, timeout, len(args.Nodes)) - fmt.Printf("%d/%d responses (%f%%)\n", numResp, len(args.Nodes), 100*float64(numResp)/float64(len(args.Nodes))) -} - -func receivePongs(pongChan chan pong, timeout <-chan time.Time, maxPongs int) (numResp int) { - for range iter.N(maxPongs) { - select { - case pong := <-pongChan: - if !pong.msgOk { - break - } - numResp++ - fmt.Printf("%-65s %s\n", fmt.Sprintf("%x (%s):", pong.krpc.SenderID(), pong.addr), pong.rtt) - case <-timeout: - fmt.Fprintf(os.Stderr, "timed out\n") - return - } - } - return -} - -func startPings(s *dht.Server, pongChan chan pong, nodes []string) { - for i, addr := range nodes { - if i != 0 { - // Put a small sleep between pings to avoid network issues. - time.Sleep(1 * time.Millisecond) - } - ping(addr, pongChan, s) - } -} - -type pong struct { - addr string - krpc krpc.Msg - msgOk bool - rtt time.Duration -} - -func ping(netloc string, pongChan chan pong, s *dht.Server) { - addr, err := net.ResolveUDPAddr("udp4", netloc) - if err != nil { - log.Fatal(err) - } - t, err := s.Ping(addr) - if err != nil { - log.Fatal(err) - } - start := time.Now() - t.SetResponseHandler(func(addr string) func(krpc.Msg, bool) { - return func(resp krpc.Msg, ok bool) { - pongChan <- pong{ - addr: addr, - krpc: resp, - rtt: time.Now().Sub(start), - msgOk: ok, - } - } - }(netloc)) -} diff --git a/vendor/github.com/anacrolix/torrent/cmd/dht-secure-id/main.go b/vendor/github.com/anacrolix/torrent/cmd/dht-secure-id/main.go deleted file mode 100644 index 7add97e28..000000000 --- a/vendor/github.com/anacrolix/torrent/cmd/dht-secure-id/main.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "encoding/hex" - "fmt" - "net" - "os" - - "github.com/anacrolix/dht" - "github.com/docopt/docopt-go" -) - -func main() { - args, _ := docopt.Parse(`dht-secure-id outputs the node ID secured with the IP. - -Usage: dht-secure-id `, nil, true, "", false) - id, err := hex.DecodeString(args[""].(string)) - if err != nil { - fmt.Fprintf(os.Stderr, "bad id: %s\n", err) - os.Exit(2) - } - if len(id) != 20 { - fmt.Fprintf(os.Stderr, "bad id: wrong length\n") - os.Exit(2) - } - ip := net.ParseIP(args[""].(string)) - if ip == nil { - fmt.Fprintf(os.Stderr, "bad ip\n") - os.Exit(2) - } - dht.SecureNodeId(id, ip) - fmt.Printf("%x\n", id) -} diff --git a/vendor/github.com/anacrolix/torrent/cmd/dht-server/main.go b/vendor/github.com/anacrolix/torrent/cmd/dht-server/main.go deleted file mode 100644 index c31bcd8e8..000000000 --- a/vendor/github.com/anacrolix/torrent/cmd/dht-server/main.go +++ /dev/null @@ -1,116 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "io" - "log" - "os" - "os/signal" - - "github.com/anacrolix/dht" - "github.com/anacrolix/dht/krpc" -) - -var ( - tableFileName = flag.String("tableFile", "", "name of file for storing node info") - serveAddr = flag.String("serveAddr", ":0", "local UDP address") - - s *dht.Server -) - -func loadTable() error { - if *tableFileName == "" { - return nil - } - f, err := os.Open(*tableFileName) - if os.IsNotExist(err) { - return nil - } - if err != nil { - return fmt.Errorf("error opening table file: %s", err) - } - defer f.Close() - added := 0 - for { - b := make([]byte, krpc.CompactIPv4NodeInfoLen) - _, err := io.ReadFull(f, b) - if err == io.EOF { - break - } - if err != nil { - return fmt.Errorf("error reading table file: %s", err) - } - var ni krpc.NodeInfo - err = ni.UnmarshalCompactIPv4(b) - if err != nil { - return fmt.Errorf("error unmarshaling compact node info: %s", err) - } - s.AddNode(ni) - added++ - } - log.Printf("loaded %d nodes from table file", added) - return nil -} - -func init() { - log.SetFlags(log.LstdFlags | log.Lshortfile) - flag.Parse() - var err error - s, err = dht.NewServer(&dht.ServerConfig{ - Addr: *serveAddr, - }) - if err != nil { - log.Fatal(err) - } - err = loadTable() - if err != nil { - log.Fatalf("error loading table: %s", err) - } - log.Printf("dht server on %s, ID is %x", s.Addr(), s.ID()) -} - -func saveTable() error { - goodNodes := s.Nodes() - if *tableFileName == "" { - if len(goodNodes) != 0 { - log.Printf("discarding %d good nodes!", len(goodNodes)) - } - return nil - } - f, err := os.OpenFile(*tableFileName, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666) - if err != nil { - return fmt.Errorf("error opening table file: %s", err) - } - defer f.Close() - for _, nodeInfo := range goodNodes { - var b [krpc.CompactIPv4NodeInfoLen]byte - err := nodeInfo.PutCompact(b[:]) - if err != nil { - return fmt.Errorf("error compacting node info: %s", err) - } - _, err = f.Write(b[:]) - if err != nil { - return fmt.Errorf("error writing compact node info: %s", err) - } - } - log.Printf("saved %d nodes to table file", len(goodNodes)) - return nil -} - -func setupSignals() { - ch := make(chan os.Signal) - signal.Notify(ch) - <-ch - s.Close() - - if *tableFileName != "" { - if err := saveTable(); err != nil { - log.Printf("error saving node table: %s", err) - } - } -} - -func main() { - setupSignals() -} diff --git a/vendor/github.com/anacrolix/torrent/cmd/magnet-metainfo/main.go b/vendor/github.com/anacrolix/torrent/cmd/magnet-metainfo/main.go deleted file mode 100644 index e231f1714..000000000 --- a/vendor/github.com/anacrolix/torrent/cmd/magnet-metainfo/main.go +++ /dev/null @@ -1,44 +0,0 @@ -// Converts magnet URIs and info hashes into torrent metainfo files. -package main - -import ( - "flag" - "log" - "os" - "sync" - - "github.com/anacrolix/torrent" - "github.com/anacrolix/torrent/bencode" -) - -func main() { - flag.Parse() - cl, err := torrent.NewClient(nil) - if err != nil { - log.Fatalf("error creating client: %s", err) - } - wg := sync.WaitGroup{} - for _, arg := range flag.Args() { - t, err := cl.AddMagnet(arg) - if err != nil { - log.Fatalf("error adding magnet to client: %s", err) - } - wg.Add(1) - go func() { - defer wg.Done() - <-t.GotInfo() - mi := t.Metainfo() - t.Drop() - f, err := os.Create(t.Info().Name + ".torrent") - if err != nil { - log.Fatalf("error creating torrent metainfo file: %s", err) - } - defer f.Close() - err = bencode.NewEncoder(f).Encode(mi) - if err != nil { - log.Fatalf("error writing torrent metainfo file: %s", err) - } - }() - } - wg.Wait() -} diff --git a/vendor/github.com/anacrolix/torrent/cmd/torrent-create/main.go b/vendor/github.com/anacrolix/torrent/cmd/torrent-create/main.go deleted file mode 100644 index 4a429e9bc..000000000 --- a/vendor/github.com/anacrolix/torrent/cmd/torrent-create/main.go +++ /dev/null @@ -1,51 +0,0 @@ -package main - -import ( - "log" - "os" - - "github.com/anacrolix/tagflag" - - "github.com/anacrolix/torrent/bencode" - "github.com/anacrolix/torrent/metainfo" -) - -var ( - builtinAnnounceList = [][]string{ - {"udp://tracker.openbittorrent.com:80"}, - {"udp://tracker.publicbt.com:80"}, - {"udp://tracker.istole.it:6969"}, - } -) - -func main() { - log.SetFlags(log.Flags() | log.Lshortfile) - var args struct { - AnnounceList []string `name:"a" help:"extra announce-list tier entry"` - tagflag.StartPos - Root string - } - tagflag.Parse(&args, tagflag.Description("Creates a torrent metainfo for the file system rooted at ROOT, and outputs it to stdout.")) - mi := metainfo.MetaInfo{ - AnnounceList: builtinAnnounceList, - } - for _, a := range args.AnnounceList { - mi.AnnounceList = append(mi.AnnounceList, []string{a}) - } - mi.SetDefaults() - info := metainfo.Info{ - PieceLength: 256 * 1024, - } - err := info.BuildFromFilePath(args.Root) - if err != nil { - log.Fatal(err) - } - mi.InfoBytes, err = bencode.Marshal(info) - if err != nil { - log.Fatal(err) - } - err = mi.Write(os.Stdout) - if err != nil { - log.Fatal(err) - } -} diff --git a/vendor/github.com/anacrolix/torrent/cmd/torrent-infohash/main.go b/vendor/github.com/anacrolix/torrent/cmd/torrent-infohash/main.go deleted file mode 100644 index 81319c99a..000000000 --- a/vendor/github.com/anacrolix/torrent/cmd/torrent-infohash/main.go +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "log" - - "github.com/anacrolix/tagflag" - - "github.com/anacrolix/torrent/metainfo" -) - -func main() { - var args struct { - tagflag.StartPos - Files []string `arity:"+" type:"pos"` - } - tagflag.Parse(&args) - for _, arg := range args.Files { - mi, err := metainfo.LoadFromFile(arg) - if err != nil { - log.Fatal(err) - } - fmt.Printf("%s: %s\n", mi.HashInfoBytes().HexString(), arg) - } -} diff --git a/vendor/github.com/anacrolix/torrent/cmd/torrent-magnet/main.go b/vendor/github.com/anacrolix/torrent/cmd/torrent-magnet/main.go deleted file mode 100644 index ee0ea2ec2..000000000 --- a/vendor/github.com/anacrolix/torrent/cmd/torrent-magnet/main.go +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import ( - "fmt" - "os" - - "github.com/anacrolix/tagflag" - - "github.com/anacrolix/torrent/metainfo" -) - -func main() { - tagflag.Parse(nil) - - mi, err := metainfo.Load(os.Stdin) - if err != nil { - fmt.Fprintf(os.Stderr, "error reading metainfo from stdin: %s", err) - os.Exit(1) - } - info, err := mi.UnmarshalInfo() - if err != nil { - fmt.Fprintf(os.Stderr, "error unmarshalling info: %s", err) - os.Exit(1) - } - - fmt.Fprintf(os.Stdout, "%s\n", mi.Magnet(info.Name, mi.HashInfoBytes()).String()) -} diff --git a/vendor/github.com/anacrolix/torrent/cmd/torrent-metainfo-pprint/main.go b/vendor/github.com/anacrolix/torrent/cmd/torrent-metainfo-pprint/main.go deleted file mode 100644 index 91e7c7aa1..000000000 --- a/vendor/github.com/anacrolix/torrent/cmd/torrent-metainfo-pprint/main.go +++ /dev/null @@ -1,68 +0,0 @@ -package main - -import ( - "encoding/hex" - "encoding/json" - "fmt" - "log" - "os" - - "github.com/anacrolix/tagflag" - "github.com/bradfitz/iter" - - "github.com/anacrolix/torrent/metainfo" -) - -var flags struct { - JustName bool - PieceHashes bool - Files bool - tagflag.StartPos - TorrentFiles []string -} - -func main() { - tagflag.Parse(&flags) - for _, filename := range flags.TorrentFiles { - metainfo, err := metainfo.LoadFromFile(filename) - if err != nil { - log.Print(err) - continue - } - info, err := metainfo.UnmarshalInfo() - if err != nil { - log.Printf("error unmarshalling info: %s", err) - continue - } - if flags.JustName { - fmt.Printf("%s\n", info.Name) - continue - } - d := map[string]interface{}{ - "Name": info.Name, - "NumPieces": info.NumPieces(), - "PieceLength": info.PieceLength, - "InfoHash": metainfo.HashInfoBytes().HexString(), - "NumFiles": len(info.UpvertedFiles()), - "TotalLength": info.TotalLength(), - "Announce": metainfo.Announce, - "AnnounceList": metainfo.AnnounceList, - } - if flags.Files { - d["Files"] = info.Files - } - if flags.PieceHashes { - d["PieceHashes"] = func() (ret []string) { - for i := range iter.N(info.NumPieces()) { - ret = append(ret, hex.EncodeToString(info.Pieces[i*20:(i+1)*20])) - } - return - }() - } - b, _ := json.MarshalIndent(d, "", " ") - os.Stdout.Write(b) - } - if !flags.JustName { - os.Stdout.WriteString("\n") - } -} diff --git a/vendor/github.com/anacrolix/torrent/cmd/torrent-pick/main.go b/vendor/github.com/anacrolix/torrent/cmd/torrent-pick/main.go deleted file mode 100644 index be590b8b4..000000000 --- a/vendor/github.com/anacrolix/torrent/cmd/torrent-pick/main.go +++ /dev/null @@ -1,187 +0,0 @@ -// Downloads torrents from the command-line. -package main - -import ( - "bufio" - "fmt" - "io" - "io/ioutil" - "log" - "net" - "net/http" - _ "net/http/pprof" - "os" - "strings" - "time" - - _ "github.com/anacrolix/envpprof" - "github.com/anacrolix/missinggo" - "github.com/dustin/go-humanize" - "github.com/jessevdk/go-flags" - - "github.com/anacrolix/torrent" - "github.com/anacrolix/torrent/metainfo" -) - -// fmt.Fprintf(os.Stderr, "Usage: %s \n", os.Args[0]) - -func resolvedPeerAddrs(ss []string) (ret []torrent.Peer, err error) { - for _, s := range ss { - var addr *net.TCPAddr - addr, err = net.ResolveTCPAddr("tcp", s) - if err != nil { - return - } - ret = append(ret, torrent.Peer{ - IP: addr.IP, - Port: addr.Port, - }) - } - return -} - -func bytesCompleted(tc *torrent.Client) (ret int64) { - for _, t := range tc.Torrents() { - if t.Info() != nil { - ret += t.BytesCompleted() - } - } - return -} - -// Returns an estimate of the total bytes for all torrents. -func totalBytesEstimate(tc *torrent.Client) (ret int64) { - var noInfo, hadInfo int64 - for _, t := range tc.Torrents() { - info := t.Info() - if info == nil { - noInfo++ - continue - } - ret += info.TotalLength() - hadInfo++ - } - if hadInfo != 0 { - // Treat each torrent without info as the average of those with, - // rounded up. - ret += (noInfo*ret + hadInfo - 1) / hadInfo - } - return -} - -func progressLine(tc *torrent.Client) string { - return fmt.Sprintf("\033[K%s / %s\r", humanize.Bytes(uint64(bytesCompleted(tc))), humanize.Bytes(uint64(totalBytesEstimate(tc)))) -} - -func dstFileName(picked string) string { - parts := strings.Split(picked, "/") - return parts[len(parts)-1] -} - -func main() { - log.SetFlags(log.LstdFlags | log.Lshortfile) - var rootGroup struct { - Client torrent.Config `group:"Client Options"` - TestPeers []string `long:"test-peer" description:"address of peer to inject to every torrent"` - Pick string `long:"pick" description:"filename to pick"` - } - // Don't pass flags.PrintError because it's inconsistent with printing. - // https://github.com/jessevdk/go-flags/issues/132 - parser := flags.NewParser(&rootGroup, flags.HelpFlag|flags.PassDoubleDash) - parser.Usage = "[OPTIONS] (magnet URI or .torrent file path)..." - posArgs, err := parser.Parse() - if err != nil { - fmt.Fprintf(os.Stderr, "%s", "Download from the BitTorrent network.\n\n") - fmt.Println(err) - os.Exit(2) - } - log.Printf("File to pick: %s", rootGroup.Pick) - - testPeers, err := resolvedPeerAddrs(rootGroup.TestPeers) - if err != nil { - log.Fatal(err) - } - - if len(posArgs) == 0 { - fmt.Fprintln(os.Stderr, "no torrents specified") - return - } - - tmpdir, err := ioutil.TempDir("", "torrent-pick-") - if err != nil { - log.Fatal(err) - } - - defer os.RemoveAll(tmpdir) - - rootGroup.Client.DataDir = tmpdir - - client, err := torrent.NewClient(&rootGroup.Client) - if err != nil { - log.Fatalf("error creating client: %s", err) - } - http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { - client.WriteStatus(w) - }) - defer client.Close() - - dstName := dstFileName(rootGroup.Pick) - - f, err := os.Create(dstName) - if err != nil { - log.Fatal(err) - } - dstWriter := bufio.NewWriter(f) - - done := make(chan struct{}) - for _, arg := range posArgs { - t := func() *torrent.Torrent { - if strings.HasPrefix(arg, "magnet:") { - t, err := client.AddMagnet(arg) - if err != nil { - log.Fatalf("error adding magnet: %s", err) - } - return t - } else { - metaInfo, err := metainfo.LoadFromFile(arg) - if err != nil { - log.Fatal(err) - } - t, err := client.AddTorrent(metaInfo) - if err != nil { - log.Fatal(err) - } - return t - } - }() - t.AddPeers(testPeers) - - go func() { - defer close(done) - <-t.GotInfo() - for _, file := range t.Files() { - if file.DisplayPath() != rootGroup.Pick { - continue - } - srcReader := missinggo.NewSectionReadSeeker(t.NewReader(), file.Offset(), file.Length()) - io.Copy(dstWriter, srcReader) - return - } - log.Print("file not found") - }() - } - - ticker := time.NewTicker(time.Second) -waitDone: - for { - select { - case <-done: - break waitDone - case <-ticker.C: - os.Stdout.WriteString(progressLine(client)) - } - } - if rootGroup.Client.Seed { - select {} - } -} diff --git a/vendor/github.com/anacrolix/torrent/cmd/torrent-verify/main.go b/vendor/github.com/anacrolix/torrent/cmd/torrent-verify/main.go deleted file mode 100644 index dfd14a740..000000000 --- a/vendor/github.com/anacrolix/torrent/cmd/torrent-verify/main.go +++ /dev/null @@ -1,85 +0,0 @@ -package main - -import ( - "bytes" - "crypto/sha1" - "fmt" - "io" - "log" - "os" - "path/filepath" - - "github.com/anacrolix/tagflag" - "github.com/bradfitz/iter" - "github.com/edsrzf/mmap-go" - - "github.com/anacrolix/torrent/metainfo" - "github.com/anacrolix/torrent/mmap_span" -) - -func mmapFile(name string) (mm mmap.MMap, err error) { - f, err := os.Open(name) - if err != nil { - return - } - defer f.Close() - fi, err := f.Stat() - if err != nil { - return - } - if fi.Size() == 0 { - return - } - return mmap.MapRegion(f, -1, mmap.RDONLY, mmap.COPY, 0) -} - -func verifyTorrent(info *metainfo.Info, root string) error { - span := new(mmap_span.MMapSpan) - for _, file := range info.UpvertedFiles() { - filename := filepath.Join(append([]string{root, info.Name}, file.Path...)...) - mm, err := mmapFile(filename) - if err != nil { - return err - } - if int64(len(mm)) != file.Length { - return fmt.Errorf("file %q has wrong length", filename) - } - span.Append(mm) - } - for i := range iter.N(info.NumPieces()) { - p := info.Piece(i) - hash := sha1.New() - _, err := io.Copy(hash, io.NewSectionReader(span, p.Offset(), p.Length())) - if err != nil { - return err - } - good := bytes.Equal(hash.Sum(nil), p.Hash().Bytes()) - if !good { - return fmt.Errorf("hash mismatch at piece %d", i) - } - fmt.Printf("%d: %x: %v\n", i, p.Hash(), good) - } - return nil -} - -func main() { - log.SetFlags(log.Flags() | log.Lshortfile) - var flags = struct { - DataDir string - tagflag.StartPos - TorrentFile string - }{} - tagflag.Parse(&flags) - metaInfo, err := metainfo.LoadFromFile(flags.TorrentFile) - if err != nil { - log.Fatal(err) - } - info, err := metaInfo.UnmarshalInfo() - if err != nil { - log.Fatalf("error unmarshalling info: %s", err) - } - err = verifyTorrent(&info, flags.DataDir) - if err != nil { - log.Fatalf("torrent failed verification: %s", err) - } -} diff --git a/vendor/github.com/anacrolix/torrent/cmd/torrent/main.go b/vendor/github.com/anacrolix/torrent/cmd/torrent/main.go deleted file mode 100644 index 3a35b7acc..000000000 --- a/vendor/github.com/anacrolix/torrent/cmd/torrent/main.go +++ /dev/null @@ -1,189 +0,0 @@ -// Downloads torrents from the command-line. -package main - -import ( - "fmt" - "log" - "net" - "net/http" - "os" - "strings" - "time" - - _ "github.com/anacrolix/envpprof" - "github.com/anacrolix/tagflag" - "github.com/dustin/go-humanize" - "github.com/gosuri/uiprogress" - "golang.org/x/time/rate" - - "github.com/anacrolix/torrent" - "github.com/anacrolix/torrent/metainfo" - "github.com/anacrolix/torrent/storage" -) - -func resolvedPeerAddrs(ss []string) (ret []torrent.Peer, err error) { - for _, s := range ss { - var addr *net.TCPAddr - addr, err = net.ResolveTCPAddr("tcp", s) - if err != nil { - return - } - ret = append(ret, torrent.Peer{ - IP: addr.IP, - Port: addr.Port, - }) - } - return -} - -func torrentBar(t *torrent.Torrent) { - bar := uiprogress.AddBar(1) - bar.AppendCompleted() - bar.AppendFunc(func(*uiprogress.Bar) (ret string) { - select { - case <-t.GotInfo(): - default: - return "getting info" - } - if t.Seeding() { - return "seeding" - } else if t.BytesCompleted() == t.Info().TotalLength() { - return "completed" - } else { - return fmt.Sprintf("downloading (%s/%s)", humanize.Bytes(uint64(t.BytesCompleted())), humanize.Bytes(uint64(t.Info().TotalLength()))) - } - }) - bar.PrependFunc(func(*uiprogress.Bar) string { - return t.Name() - }) - go func() { - <-t.GotInfo() - tl := int(t.Info().TotalLength()) - if tl == 0 { - bar.Set(1) - return - } - bar.Total = tl - for { - bc := t.BytesCompleted() - bar.Set(int(bc)) - time.Sleep(time.Second) - } - }() -} - -func addTorrents(client *torrent.Client) { - for _, arg := range flags.Torrent { - t := func() *torrent.Torrent { - if strings.HasPrefix(arg, "magnet:") { - t, err := client.AddMagnet(arg) - if err != nil { - log.Fatalf("error adding magnet: %s", err) - } - return t - } else if strings.HasPrefix(arg, "http://") || strings.HasPrefix(arg, "https://") { - response, err := http.Get(arg) - if err != nil { - log.Fatalf("Error downloading torrent file: %s", err) - } - - metaInfo, err := metainfo.Load(response.Body) - defer response.Body.Close() - if err != nil { - fmt.Fprintf(os.Stderr, "error loading torrent file %q: %s\n", arg, err) - os.Exit(1) - } - t, err := client.AddTorrent(metaInfo) - if err != nil { - log.Fatal(err) - } - return t - } else if strings.HasPrefix(arg, "infohash:") { - t, _ := client.AddTorrentInfoHash(metainfo.NewHashFromHex(strings.TrimPrefix(arg, "infohash:"))) - return t - } else { - metaInfo, err := metainfo.LoadFromFile(arg) - if err != nil { - fmt.Fprintf(os.Stderr, "error loading torrent file %q: %s\n", arg, err) - os.Exit(1) - } - t, err := client.AddTorrent(metaInfo) - if err != nil { - log.Fatal(err) - } - return t - } - }() - torrentBar(t) - t.AddPeers(func() (ret []torrent.Peer) { - for _, ta := range flags.TestPeer { - ret = append(ret, torrent.Peer{ - IP: ta.IP, - Port: ta.Port, - }) - } - return - }()) - go func() { - <-t.GotInfo() - t.DownloadAll() - }() - } -} - -var flags = struct { - Mmap bool `help:"memory-map torrent data"` - TestPeer []*net.TCPAddr `help:"addresses of some starting peers"` - Seed bool `help:"seed after download is complete"` - Addr *net.TCPAddr `help:"network listen addr"` - UploadRate tagflag.Bytes `help:"max piece bytes to send per second"` - DownloadRate tagflag.Bytes `help:"max bytes per second down from peers"` - tagflag.StartPos - Torrent []string `arity:"+" help:"torrent file path or magnet uri"` -}{ - UploadRate: -1, - DownloadRate: -1, -} - -func main() { - log.SetFlags(log.LstdFlags | log.Lshortfile) - tagflag.Parse(&flags) - var clientConfig torrent.Config - if flags.Mmap { - clientConfig.DefaultStorage = storage.NewMMap("") - } - if flags.Addr != nil { - clientConfig.ListenAddr = flags.Addr.String() - } - if flags.Seed { - clientConfig.Seed = true - } - if flags.UploadRate != -1 { - clientConfig.UploadRateLimiter = rate.NewLimiter(rate.Limit(flags.UploadRate), 256<<10) - } - if flags.DownloadRate != -1 { - clientConfig.DownloadRateLimiter = rate.NewLimiter(rate.Limit(flags.DownloadRate), 1<<20) - } - - client, err := torrent.NewClient(&clientConfig) - if err != nil { - log.Fatalf("error creating client: %s", err) - } - defer client.Close() - // Write status on the root path on the default HTTP muxer. This will be - // bound to localhost somewhere if GOPPROF is set, thanks to the envpprof - // import. - http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { - client.WriteStatus(w) - }) - uiprogress.Start() - addTorrents(client) - if client.WaitAll() { - log.Print("downloaded ALL the torrents") - } else { - log.Fatal("y u no complete torrents?!") - } - if flags.Seed { - select {} - } -} diff --git a/vendor/github.com/anacrolix/torrent/cmd/torrentfs/main.go b/vendor/github.com/anacrolix/torrent/cmd/torrentfs/main.go deleted file mode 100644 index 018e3885a..000000000 --- a/vendor/github.com/anacrolix/torrent/cmd/torrentfs/main.go +++ /dev/null @@ -1,164 +0,0 @@ -// Mounts a FUSE filesystem backed by torrents and magnet links. -package main - -import ( - "flag" - "log" - "net" - "net/http" - _ "net/http/pprof" - "os" - "os/signal" - "os/user" - "path/filepath" - "syscall" - "time" - - "bazil.org/fuse" - fusefs "bazil.org/fuse/fs" - _ "github.com/anacrolix/envpprof" - - "github.com/anacrolix/torrent" - "github.com/anacrolix/torrent/fs" - "github.com/anacrolix/torrent/util/dirwatch" -) - -var ( - torrentPath = flag.String("torrentPath", func() string { - _user, err := user.Current() - if err != nil { - log.Fatal(err) - } - return filepath.Join(_user.HomeDir, ".config/transmission/torrents") - }(), "torrent files in this location describe the contents of the mounted filesystem") - downloadDir = flag.String("downloadDir", "", "location to save torrent data") - mountDir = flag.String("mountDir", "", "location the torrent contents are made available") - - disableTrackers = flag.Bool("disableTrackers", false, "disables trackers") - testPeer = flag.String("testPeer", "", "the address for a test peer") - readaheadBytes = flag.Int64("readaheadBytes", 10*1024*1024, "bytes to readahead in each torrent from the last read piece") - listenAddr = flag.String("listenAddr", ":6882", "incoming connection address") - - testPeerAddr *net.TCPAddr -) - -func resolveTestPeerAddr() { - if *testPeer == "" { - return - } - var err error - testPeerAddr, err = net.ResolveTCPAddr("tcp4", *testPeer) - if err != nil { - log.Fatal(err) - } -} - -func exitSignalHandlers(fs *torrentfs.TorrentFS) { - c := make(chan os.Signal) - signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) - for { - <-c - fs.Destroy() - err := fuse.Unmount(*mountDir) - if err != nil { - log.Print(err) - } - } -} - -func addTestPeer(client *torrent.Client) { - for _, t := range client.Torrents() { - t.AddPeers([]torrent.Peer{{ - IP: testPeerAddr.IP, - Port: testPeerAddr.Port, - }}) - } -} - -func main() { - os.Exit(mainExitCode()) -} - -func mainExitCode() int { - flag.Parse() - if flag.NArg() != 0 { - os.Stderr.WriteString("one does not simply pass positional args\n") - return 2 - } - if *mountDir == "" { - os.Stderr.WriteString("y u no specify mountpoint?\n") - return 2 - } - log.SetFlags(log.LstdFlags | log.Lshortfile) - conn, err := fuse.Mount(*mountDir) - if err != nil { - log.Fatal(err) - } - defer fuse.Unmount(*mountDir) - // TODO: Think about the ramifications of exiting not due to a signal. - defer conn.Close() - client, err := torrent.NewClient(&torrent.Config{ - DataDir: *downloadDir, - DisableTrackers: *disableTrackers, - ListenAddr: *listenAddr, - NoUpload: true, // Ensure that downloads are responsive. - }) - if err != nil { - log.Print(err) - return 1 - } - // This is naturally exported via GOPPROF=http. - http.DefaultServeMux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { - client.WriteStatus(w) - }) - dw, err := dirwatch.New(*torrentPath) - if err != nil { - log.Printf("error watching torrent dir: %s", err) - return 1 - } - go func() { - for ev := range dw.Events { - switch ev.Change { - case dirwatch.Added: - if ev.TorrentFilePath != "" { - _, err := client.AddTorrentFromFile(ev.TorrentFilePath) - if err != nil { - log.Printf("error adding torrent to client: %s", err) - } - } else if ev.MagnetURI != "" { - _, err := client.AddMagnet(ev.MagnetURI) - if err != nil { - log.Printf("error adding magnet: %s", err) - } - } - case dirwatch.Removed: - T, ok := client.Torrent(ev.InfoHash) - if !ok { - break - } - T.Drop() - } - } - }() - resolveTestPeerAddr() - fs := torrentfs.New(client) - go exitSignalHandlers(fs) - - if testPeerAddr != nil { - go func() { - for { - addTestPeer(client) - time.Sleep(10 * time.Second) - } - }() - } - - if err := fusefs.Serve(conn, fs); err != nil { - log.Fatal(err) - } - <-conn.Ready - if err := conn.MountError; err != nil { - log.Fatal(err) - } - return 0 -} diff --git a/vendor/github.com/anacrolix/torrent/cmd/tracker-announce/main.go b/vendor/github.com/anacrolix/torrent/cmd/tracker-announce/main.go deleted file mode 100644 index 21d31a694..000000000 --- a/vendor/github.com/anacrolix/torrent/cmd/tracker-announce/main.go +++ /dev/null @@ -1,49 +0,0 @@ -package main - -import ( - "flag" - "log" - "math" - "strings" - - "github.com/anacrolix/torrent" - "github.com/anacrolix/torrent/metainfo" - "github.com/anacrolix/torrent/tracker" -) - -func argSpec(arg string) (ts *torrent.TorrentSpec, err error) { - if strings.HasPrefix(arg, "magnet:") { - return torrent.TorrentSpecFromMagnetURI(arg) - } - mi, err := metainfo.LoadFromFile(arg) - if err != nil { - return - } - ts = torrent.TorrentSpecFromMetaInfo(mi) - return -} - -func main() { - flag.Parse() - ar := tracker.AnnounceRequest{ - NumWant: -1, - Left: math.MaxUint64, - } - for _, arg := range flag.Args() { - ts, err := argSpec(arg) - if err != nil { - log.Fatal(err) - } - ar.InfoHash = ts.InfoHash - for _, tier := range ts.Trackers { - for _, tURI := range tier { - resp, err := tracker.Announce(tURI, &ar) - if err != nil { - log.Print(err) - continue - } - log.Printf("%q: %#v", tURI, resp) - } - } - } -} diff --git a/vendor/github.com/anacrolix/torrent/config.go b/vendor/github.com/anacrolix/torrent/config.go index 8ff15b60b..ea947de1e 100644 --- a/vendor/github.com/anacrolix/torrent/config.go +++ b/vendor/github.com/anacrolix/torrent/config.go @@ -51,12 +51,16 @@ type Config struct { // used. DefaultStorage storage.ClientImpl - DisableEncryption bool `long:"disable-encryption"` - ForceEncryption bool // Don't allow unobfuscated connections. - PreferNoEncryption bool + EncryptionPolicy IPBlocklist iplist.Ranger DisableIPv6 bool `long:"disable-ipv6"` // Perform logging and any other behaviour that will help debug. Debug bool `help:"enable debug logging"` } + +type EncryptionPolicy struct { + DisableEncryption bool + ForceEncryption bool // Don't allow unobfuscated connections. + PreferNoEncryption bool +} diff --git a/vendor/github.com/anacrolix/torrent/connection.go b/vendor/github.com/anacrolix/torrent/connection.go index 69e294d5c..ba1d1e1e7 100644 --- a/vendor/github.com/anacrolix/torrent/connection.go +++ b/vendor/github.com/anacrolix/torrent/connection.go @@ -3,9 +3,7 @@ package torrent import ( "bufio" "bytes" - "container/list" "errors" - "expvar" "fmt" "io" "log" @@ -16,6 +14,8 @@ import ( "sync" "time" + "github.com/anacrolix/torrent/mse" + "github.com/anacrolix/missinggo" "github.com/anacrolix/missinggo/bitmap" "github.com/anacrolix/missinggo/iter" @@ -25,8 +25,6 @@ import ( pp "github.com/anacrolix/torrent/peer_protocol" ) -var optimizedCancels = expvar.NewInt("optimizedCancels") - type peerSource string const ( @@ -47,10 +45,11 @@ type connection struct { w io.Writer r io.Reader // True if the connection is operating over MSE obfuscation. - encrypted bool - Discovery peerSource - uTP bool - closed missinggo.Event + headerEncrypted bool + cryptoMethod uint32 + Discovery peerSource + uTP bool + closed missinggo.Event stats ConnStats UnwantedChunksReceived int @@ -67,7 +66,7 @@ type connection struct { // Stuff controlled by the local peer. Interested bool Choked bool - Requests map[request]struct{} + requests map[request]struct{} requestsLowWater int // Indexed by metadata piece, set to true if posted and pending a // response. @@ -99,8 +98,9 @@ type connection struct { pieceInclination []int pieceRequestOrder prioritybitmap.PriorityBitmap - outgoingUnbufferedMessages *list.List - outgoingUnbufferedMessagesNotEmpty missinggo.Event + postedBuffer bytes.Buffer + uploadTimer *time.Timer + writerCond sync.Cond } func (cn *connection) mu() sync.Locker { @@ -152,8 +152,10 @@ func (cn *connection) connectionFlags() (ret string) { c := func(b byte) { ret += string([]byte{b}) } - if cn.encrypted { + if cn.cryptoMethod == mse.CryptoMethodRC4 { c('E') + } else if cn.headerEncrypted { + c('e') } ret += string(cn.Discovery) if cn.uTP { @@ -205,31 +207,37 @@ func (cn *connection) WriteStatus(w io.Writer, t *Torrent) { cn.UsefulChunksReceived, cn.UnwantedChunksReceived+cn.UsefulChunksReceived, cn.chunksSent, - len(cn.Requests), + cn.numLocalRequests(), len(cn.PeerRequests), cn.statusFlags(), ) - fmt.Fprintf(w, " next pieces: %v\n", priorityBitmapHeadAsSlice(&cn.pieceRequestOrder, 10)) -} - -func priorityBitmapHeadAsSlice(pb *prioritybitmap.PriorityBitmap, n int) (ret []int) { - pb.IterTyped(func(i int) bool { - if len(ret) >= n { - return false - } - ret = append(ret, i) - return true - }) - return + roi := cn.pieceRequestOrderIter() + fmt.Fprintf(w, " next pieces: %v%s\n", + iter.ToSlice(iter.Head(10, roi)), + func() string { + if cn.shouldRequestWithoutBias() { + return " (fastest)" + } else { + return "" + } + }()) } func (cn *connection) Close() { - cn.closed.Set() + if !cn.closed.Set() { + return + } cn.discardPieceInclination() cn.pieceRequestOrder.Clear() if cn.conn != nil { - // TODO: This call blocks sometimes, why? - go cn.conn.Close() + go func() { + // TODO: This call blocks sometimes, why? Maybe it was the Go utp + // implementation? + err := cn.conn.Close() + if err != nil { + log.Printf("error closing connection net.Conn: %s", err) + } + }() } } @@ -238,28 +246,9 @@ func (cn *connection) PeerHasPiece(piece int) bool { } func (cn *connection) Post(msg pp.Message) { - switch msg.Type { - case pp.Cancel: - for e := cn.outgoingUnbufferedMessages.Back(); e != nil; e = e.Prev() { - elemMsg := e.Value.(pp.Message) - if elemMsg.Type == pp.Request && elemMsg.Index == msg.Index && elemMsg.Begin == msg.Begin && elemMsg.Length == msg.Length { - cn.outgoingUnbufferedMessages.Remove(e) - optimizedCancels.Add(1) - return - } - } - } - if cn.outgoingUnbufferedMessages == nil { - cn.outgoingUnbufferedMessages = list.New() - } - cn.outgoingUnbufferedMessages.PushBack(msg) - cn.outgoingUnbufferedMessagesNotEmpty.Set() - postedMessageTypes.Add(strconv.FormatInt(int64(msg.Type), 10), 1) -} - -func (cn *connection) RequestPending(r request) bool { - _, ok := cn.Requests[r] - return ok + messageTypesPosted.Add(strconv.FormatInt(int64(msg.Type), 10), 1) + cn.postedBuffer.Write(msg.MustMarshalBinary()) + cn.tickleWriter() } func (cn *connection) requestMetadataPiece(index int) { @@ -303,50 +292,6 @@ func (cn *connection) nominalMaxRequests() (ret int) { return } -// Returns true if more requests can be sent. -func (cn *connection) Request(chunk request) bool { - if len(cn.Requests) >= cn.nominalMaxRequests() { - return false - } - if !cn.PeerHasPiece(int(chunk.Index)) { - return true - } - if cn.RequestPending(chunk) { - return true - } - cn.SetInterested(true) - if cn.PeerChoked { - return false - } - if cn.Requests == nil { - cn.Requests = make(map[request]struct{}, cn.PeerMaxRequests) - } - cn.Requests[chunk] = struct{}{} - cn.requestsLowWater = len(cn.Requests) / 2 - cn.Post(pp.Message{ - Type: pp.Request, - Index: chunk.Index, - Begin: chunk.Begin, - Length: chunk.Length, - }) - return true -} - -// Returns true if an unsatisfied request was canceled. -func (cn *connection) Cancel(r request) bool { - if !cn.RequestPending(r) { - return false - } - delete(cn.Requests, r) - cn.Post(pp.Message{ - Type: pp.Cancel, - Index: r.Index, - Begin: r.Begin, - Length: r.Length, - }) - return true -} - // Returns true if an unsatisfied request was canceled. func (cn *connection) PeerCancel(r request) bool { if cn.PeerRequests == nil { @@ -359,32 +304,34 @@ func (cn *connection) PeerCancel(r request) bool { return true } -func (cn *connection) Choke() { +func (cn *connection) Choke(msg func(pp.Message) bool) bool { if cn.Choked { - return + return true } - cn.Post(pp.Message{ - Type: pp.Choke, - }) cn.PeerRequests = nil cn.Choked = true + return msg(pp.Message{ + Type: pp.Choke, + }) } -func (cn *connection) Unchoke() { +func (cn *connection) Unchoke(msg func(pp.Message) bool) bool { if !cn.Choked { - return + return true } - cn.Post(pp.Message{ + cn.Choked = false + return msg(pp.Message{ Type: pp.Unchoke, }) - cn.Choked = false } -func (cn *connection) SetInterested(interested bool) { +func (cn *connection) SetInterested(interested bool, msg func(pp.Message) bool) bool { if cn.Interested == interested { - return + return true } - cn.Post(pp.Message{ + cn.Interested = interested + // log.Printf("%p: setting interest: %v", cn, interested) + return msg(pp.Message{ Type: func() pp.MessageType { if interested { return pp.Interested @@ -393,66 +340,101 @@ func (cn *connection) SetInterested(interested bool) { } }(), }) - cn.Interested = interested } -var ( - // Track connection writer buffer writes and flushes, to determine its - // efficiency. - connectionWriterFlush = expvar.NewInt("connectionWriterFlush") - connectionWriterWrite = expvar.NewInt("connectionWriterWrite") -) +func (cn *connection) fillWriteBuffer(msg func(pp.Message) bool) { + numFillBuffers.Add(1) + cancel, new, i := cn.desiredRequestState() + if !cn.SetInterested(i, msg) { + return + } + if cancel && len(cn.requests) != 0 { + fillBufferSentCancels.Add(1) + for r := range cn.requests { + cn.deleteRequest(r) + // log.Printf("%p: cancelling request: %v", cn, r) + if !msg(makeCancelMessage(r)) { + return + } + } + } + if len(new) != 0 { + fillBufferSentRequests.Add(1) + for _, r := range new { + if cn.requests == nil { + cn.requests = make(map[request]struct{}, cn.nominalMaxRequests()) + } + cn.requests[r] = struct{}{} + // log.Printf("%p: requesting %v", cn, r) + if !msg(pp.Message{ + Type: pp.Request, + Index: r.Index, + Begin: r.Begin, + Length: r.Length, + }) { + return + } + } + // If we didn't completely top up the requests, we shouldn't mark the + // low water, since we'll want to top up the requests as soon as we + // have more write buffer space. + cn.requestsLowWater = len(cn.requests) / 2 + } + cn.upload(msg) +} // Writes buffers to the socket from the write channel. func (cn *connection) writer(keepAliveTimeout time.Duration) { - defer func() { + var ( + buf bytes.Buffer + lastWrite time.Time = time.Now() + ) + var keepAliveTimer *time.Timer + keepAliveTimer = time.AfterFunc(keepAliveTimeout, func() { cn.mu().Lock() defer cn.mu().Unlock() - cn.Close() - }() - // Reduce write syscalls. - buf := bufio.NewWriter(cn.w) - keepAliveTimer := time.NewTimer(keepAliveTimeout) + if time.Since(lastWrite) >= keepAliveTimeout { + cn.tickleWriter() + } + keepAliveTimer.Reset(keepAliveTimeout) + }) + cn.mu().Lock() + defer cn.mu().Unlock() + defer cn.Close() + defer keepAliveTimer.Stop() for { - cn.mu().Lock() - for cn.outgoingUnbufferedMessages != nil && cn.outgoingUnbufferedMessages.Len() != 0 { - msg := cn.outgoingUnbufferedMessages.Remove(cn.outgoingUnbufferedMessages.Front()).(pp.Message) - cn.mu().Unlock() - b, err := msg.MarshalBinary() - if err != nil { - panic(err) - } - connectionWriterWrite.Add(1) - n, err := buf.Write(b) - if err != nil { - return - } - keepAliveTimer.Reset(keepAliveTimeout) - if n != len(b) { - panic("short write") - } - cn.mu().Lock() - cn.wroteMsg(&msg) + buf.Write(cn.postedBuffer.Bytes()) + cn.postedBuffer.Reset() + if buf.Len() == 0 { + cn.fillWriteBuffer(func(msg pp.Message) bool { + cn.wroteMsg(&msg) + buf.Write(msg.MustMarshalBinary()) + return buf.Len() < 1<<16 + }) + } + if buf.Len() == 0 && time.Since(lastWrite) >= keepAliveTimeout { + buf.Write(pp.Message{Keepalive: true}.MustMarshalBinary()) + postedKeepalives.Add(1) + } + if buf.Len() == 0 { + cn.writerCond.Wait() + continue } - cn.outgoingUnbufferedMessagesNotEmpty.Clear() cn.mu().Unlock() - connectionWriterFlush.Add(1) - if buf.Buffered() != 0 { - if buf.Flush() != nil { - return - } + // log.Printf("writing %d bytes", buf.Len()) + n, err := cn.w.Write(buf.Bytes()) + cn.mu().Lock() + if n != 0 { + lastWrite = time.Now() keepAliveTimer.Reset(keepAliveTimeout) } - select { - case <-cn.closed.LockedChan(cn.mu()): + if err != nil { return - case <-cn.outgoingUnbufferedMessagesNotEmpty.LockedChan(cn.mu()): - case <-keepAliveTimer.C: - cn.mu().Lock() - cn.Post(pp.Message{Keepalive: true}) - cn.mu().Unlock() - postedKeepalives.Add(1) } + if n != buf.Len() { + panic("short write") + } + buf.Reset() } } @@ -484,78 +466,152 @@ func (cn *connection) Bitfield(haves []bool) { cn.sentHaves = append([]bool(nil), haves...) } -func (cn *connection) updateRequests() { - if !cn.t.haveInfo() { - return - } - if cn.Interested { - if cn.PeerChoked { - return +func nextRequestState( + networkingEnabled bool, + currentRequests map[request]struct{}, + peerChoking bool, + requestPieces iter.Func, + pendingChunks func(piece int, f func(chunkSpec) bool) bool, + requestsLowWater int, + requestsHighWater int, +) ( + cancelExisting bool, // Cancel all our pending requests + newRequests []request, // Chunks to request that we currently aren't + interested bool, // Whether we should indicate interest, even if we don't request anything +) { + if !networkingEnabled { + return true, nil, false + } + if len(currentRequests) > requestsLowWater { + return false, nil, true + } + requestPieces(func(_piece interface{}) bool { + interested = true + if peerChoking { + return false } - if len(cn.Requests) > cn.requestsLowWater { - return + piece := _piece.(int) + return pendingChunks(piece, func(cs chunkSpec) bool { + r := request{pp.Integer(piece), cs} + if _, ok := currentRequests[r]; !ok { + if newRequests == nil { + newRequests = make([]request, 0, requestsHighWater-len(currentRequests)) + } + newRequests = append(newRequests, r) + } + return len(currentRequests)+len(newRequests) < requestsHighWater + }) + }) + return +} + +func (cn *connection) updateRequests() { + cn.tickleWriter() +} + +func iterBitmapsDistinct(skip bitmap.Bitmap, bms ...bitmap.Bitmap) iter.Func { + return func(cb iter.Callback) { + for _, bm := range bms { + if !iter.All(func(i interface{}) bool { + skip.Add(i.(int)) + return cb(i) + }, bitmap.Sub(bm, skip).Iter) { + return + } } } - cn.fillRequests() - if len(cn.Requests) == 0 && !cn.PeerChoked { - // So we're not choked, but we don't want anything right now. We may - // have completed readahead, and the readahead window has not rolled - // over to the next piece. Better to stay interested in case we're - // going to want data in the near future. - cn.SetInterested(!cn.t.haveAllPieces()) - } } -func (cn *connection) fillRequests() { - cn.pieceRequestOrder.IterTyped(func(piece int) (more bool) { - if cn.t.cl.config.Debug && cn.t.havePiece(piece) { - panic(piece) - } - return cn.requestPiecePendingChunks(piece) - }) +func (cn *connection) unbiasedPieceRequestOrder() iter.Func { + now, readahead := cn.t.readerPiecePriorities() + return iterBitmapsDistinct(cn.t.completedPieces.Copy(), now, readahead, cn.t.pendingPieces) } -func (c *connection) requestPiecePendingChunks(piece int) (again bool) { - if !c.PeerHasPiece(piece) { +// The connection should download highest priority pieces first, without any +// inclination toward avoiding wastage. Generally we might do this if there's +// a single connection, or this is the fastest connection, and we have active +// readers that signal an ordering preference. It's conceivable that the best +// connection should do this, since it's least likely to waste our time if +// assigned to the highest priority pieces, and assigning more than one this +// role would cause significant wasted bandwidth. +func (cn *connection) shouldRequestWithoutBias() bool { + if cn.t.requestStrategy != 2 { + return false + } + if len(cn.t.readers) == 0 { + return false + } + if len(cn.t.conns) == 1 { return true } - chunkIndices := c.t.pieces[piece].undirtiedChunkIndices().ToSortedSlice() + if cn == cn.t.fastestConn { + return true + } + return false +} + +func (cn *connection) pieceRequestOrderIter() iter.Func { + if cn.shouldRequestWithoutBias() { + return cn.unbiasedPieceRequestOrder() + } else { + return cn.pieceRequestOrder.Iter + } +} + +func (cn *connection) desiredRequestState() (bool, []request, bool) { + return nextRequestState( + cn.t.networkingEnabled, + cn.requests, + cn.PeerChoked, + cn.pieceRequestOrderIter(), + func(piece int, f func(chunkSpec) bool) bool { + return undirtiedChunks(piece, cn.t, f) + }, + cn.requestsLowWater, + cn.nominalMaxRequests(), + ) +} + +func undirtiedChunks(piece int, t *Torrent, f func(chunkSpec) bool) bool { + chunkIndices := t.pieces[piece].undirtiedChunkIndices().ToSortedSlice() return iter.ForPerm(len(chunkIndices), func(i int) bool { - req := request{pp.Integer(piece), c.t.chunkIndexSpec(chunkIndices[i], piece)} - return c.Request(req) + return f(t.chunkIndexSpec(chunkIndices[i], piece)) }) } -func (cn *connection) stopRequestingPiece(piece int) { - cn.pieceRequestOrder.Remove(piece) +// check callers updaterequests +func (cn *connection) stopRequestingPiece(piece int) bool { + return cn.pieceRequestOrder.Remove(piece) } // This is distinct from Torrent piece priority, which is the user's // preference. Connection piece priority is specific to a connection, // pseudorandomly avoids connections always requesting the same pieces and // thus wasting effort. -func (cn *connection) updatePiecePriority(piece int) { +func (cn *connection) updatePiecePriority(piece int) bool { tpp := cn.t.piecePriority(piece) if !cn.PeerHasPiece(piece) { tpp = PiecePriorityNone } if tpp == PiecePriorityNone { - cn.stopRequestingPiece(piece) - return + return cn.stopRequestingPiece(piece) } prio := cn.getPieceInclination()[piece] - switch tpp { - case PiecePriorityNormal: - case PiecePriorityReadahead: - prio -= cn.t.numPieces() - case PiecePriorityNext, PiecePriorityNow: - prio -= 2 * cn.t.numPieces() + switch cn.t.requestStrategy { + case 1: + switch tpp { + case PiecePriorityNormal: + case PiecePriorityReadahead: + prio -= cn.t.numPieces() + case PiecePriorityNext, PiecePriorityNow: + prio -= 2 * cn.t.numPieces() + default: + panic(tpp) + } + prio += piece / 3 default: - panic(tpp) } - prio += piece / 3 - cn.pieceRequestOrder.Set(piece, prio) - cn.updateRequests() + return cn.pieceRequestOrder.Set(piece, prio) } func (cn *connection) getPieceInclination() []int { @@ -573,14 +629,16 @@ func (cn *connection) discardPieceInclination() { cn.pieceInclination = nil } -func (cn *connection) peerHasPieceChanged(piece int) { - cn.updatePiecePriority(piece) -} - func (cn *connection) peerPiecesChanged() { if cn.t.haveInfo() { + prioritiesChanged := false for i := range iter.N(cn.t.numPieces()) { - cn.peerHasPieceChanged(i) + if cn.updatePiecePriority(i) { + prioritiesChanged = true + } + } + if prioritiesChanged { + cn.updateRequests() } } } @@ -600,7 +658,9 @@ func (cn *connection) peerSentHave(piece int) error { } cn.raisePeerMinPieces(piece + 1) cn.peerPieces.Set(piece, true) - cn.peerHasPieceChanged(piece) + if cn.updatePiecePriority(piece) { + cn.updateRequests() + } return nil } @@ -661,6 +721,7 @@ func (c *connection) requestPendingMetadata() { } func (cn *connection) wroteMsg(msg *pp.Message) { + messageTypesSent.Add(strconv.FormatInt(int64(msg.Type), 10), 1) cn.stats.wroteMsg(msg) cn.t.stats.wroteMsg(msg) } @@ -697,7 +758,7 @@ func (c *connection) useful() bool { if t.seeding() { return c.PeerInterested } - return t.connHasWantedPieces(c) + return c.peerHasWantedPieces() } func (c *connection) lastHelpful() (ret time.Time) { @@ -715,15 +776,20 @@ func (c *connection) mainReadLoop() error { cl := t.cl decoder := pp.Decoder{ - R: bufio.NewReader(c.r), + R: bufio.NewReaderSize(c.r, 1<<17), MaxLength: 256 * 1024, Pool: t.chunkPool, } for { - cl.mu.Unlock() - var msg pp.Message - err := decoder.Decode(&msg) - cl.mu.Lock() + var ( + msg pp.Message + err error + ) + func() { + cl.mu.Unlock() + defer cl.mu.Lock() + err = decoder.Decode(&msg) + }() if cl.closed.IsSet() || c.closed.IsSet() || err == io.EOF { return nil } @@ -736,48 +802,40 @@ func (c *connection) mainReadLoop() error { receivedKeepalives.Add(1) continue } - receivedMessageTypes.Add(strconv.FormatInt(int64(msg.Type), 10), 1) + messageTypesReceived.Add(strconv.FormatInt(int64(msg.Type), 10), 1) switch msg.Type { case pp.Choke: c.PeerChoked = true - c.Requests = nil + c.requests = nil // We can then reset our interest. c.updateRequests() case pp.Reject: - cl.connDeleteRequest(t, c, newRequest(msg.Index, msg.Begin, msg.Length)) - c.updateRequests() + if c.deleteRequest(newRequest(msg.Index, msg.Begin, msg.Length)) { + c.updateRequests() + } case pp.Unchoke: c.PeerChoked = false - cl.peerUnchoked(t, c) + c.tickleWriter() case pp.Interested: c.PeerInterested = true - c.upload() + c.tickleWriter() case pp.NotInterested: c.PeerInterested = false - c.Choke() + c.PeerRequests = nil case pp.Have: err = c.peerSentHave(int(msg.Index)) case pp.Request: if c.Choked { break } - if !c.PeerInterested { - err = errors.New("peer sent request but isn't interested") - break - } - if !t.havePiece(msg.Index.Int()) { - // This isn't necessarily them screwing up. We can drop pieces - // from our storage, and can't communicate this to peers - // except by reconnecting. - requestsReceivedForMissingPieces.Add(1) - err = errors.New("peer requested piece we don't have") + if len(c.PeerRequests) >= maxRequests { break } if c.PeerRequests == nil { c.PeerRequests = make(map[request]struct{}, maxRequests) } c.PeerRequests[newRequest(msg.Index, msg.Begin, msg.Length)] = struct{}{} - c.upload() + c.tickleWriter() case pp.Cancel: req := newRequest(msg.Index, msg.Begin, msg.Length) if !c.PeerCancel(req) { @@ -913,7 +971,7 @@ func (c *connection) mainReadLoop() error { if msg.Port != 0 { pingAddr.Port = int(msg.Port) } - go cl.dHT.Ping(pingAddr) + go cl.dHT.Ping(pingAddr, nil) default: err = fmt.Errorf("received unknown message type: %#v", msg.Type) } @@ -946,8 +1004,8 @@ func (c *connection) receiveChunk(msg *pp.Message) { req := newRequest(msg.Index, msg.Begin, pp.Integer(len(msg.Piece))) // Request has been satisfied. - if cl.connDeleteRequest(t, c, req) { - defer c.updateRequests() + if c.deleteRequest(req) { + c.updateRequests() } else { unexpectedChunksReceived.Add(1) } @@ -964,8 +1022,10 @@ func (c *connection) receiveChunk(msg *pp.Message) { c.UsefulChunksReceived++ c.lastUsefulChunkReceived = time.Now() - - c.upload() + if t.fastestConn != c { + // log.Printf("setting fastest connection %p", c) + } + t.fastestConn = c // Need to record that it hasn't been written yet, before we attempt to do // anything with it. @@ -975,9 +1035,7 @@ func (c *connection) receiveChunk(msg *pp.Message) { // Cancel pending requests for this chunk. for c := range t.conns { - if cl.connCancel(t, c, req) { - c.updateRequests() - } + c.postCancel(req) } cl.mu.Unlock() @@ -1012,40 +1070,45 @@ func (c *connection) receiveChunk(msg *pp.Message) { } // Also handles choking and unchoking of the remote peer. -func (c *connection) upload() { +func (c *connection) upload(msg func(pp.Message) bool) bool { t := c.t cl := t.cl if cl.config.NoUpload { - return + return true } if !c.PeerInterested { - return + return true } seeding := t.seeding() - if !seeding && !t.connHasWantedPieces(c) { + if !seeding && !c.peerHasWantedPieces() { // There's no reason to upload to this peer. - return + return true } // Breaking or completing this loop means we don't want to upload to the // peer anymore, and we choke them. another: for seeding || c.chunksSent < c.UsefulChunksReceived+6 { // We want to upload to the peer. - c.Unchoke() + if !c.Unchoke(msg) { + return false + } for r := range c.PeerRequests { res := cl.uploadLimit.ReserveN(time.Now(), int(r.Length)) + if !res.OK() { + panic(res) + } delay := res.Delay() if delay > 0 { res.Cancel() - go func() { - time.Sleep(delay) - cl.mu.Lock() - defer cl.mu.Unlock() - c.upload() - }() - return + if c.uploadTimer == nil { + c.uploadTimer = time.AfterFunc(delay, c.writerCond.Broadcast) + } else { + c.uploadTimer.Reset(delay) + } + // Hard to say what to return here. + return true } - err := cl.sendChunk(t, c, r) + more, err := cl.sendChunk(t, c, r, msg) if err != nil { i := int(r.Index) if t.pieceComplete(i) { @@ -1064,11 +1127,14 @@ another: break another } delete(c.PeerRequests, r) + if !more { + return false + } goto another } - return + return true } - c.Choke() + return c.Choke(msg) } func (cn *connection) Drop() { @@ -1078,3 +1144,30 @@ func (cn *connection) Drop() { func (cn *connection) netGoodPiecesDirtied() int { return cn.goodPiecesDirtied - cn.badPiecesDirtied } + +func (c *connection) peerHasWantedPieces() bool { + return !c.pieceRequestOrder.IsEmpty() +} + +func (c *connection) numLocalRequests() int { + return len(c.requests) +} + +func (c *connection) deleteRequest(r request) bool { + if _, ok := c.requests[r]; !ok { + return false + } + delete(c.requests, r) + return true +} +func (c *connection) tickleWriter() { + c.writerCond.Broadcast() +} + +func (c *connection) postCancel(r request) bool { + if !c.deleteRequest(r) { + return false + } + c.Post(makeCancelMessage(r)) + return true +} diff --git a/vendor/github.com/anacrolix/torrent/connection_test.go b/vendor/github.com/anacrolix/torrent/connection_test.go deleted file mode 100644 index 48fb4f5f9..000000000 --- a/vendor/github.com/anacrolix/torrent/connection_test.go +++ /dev/null @@ -1,191 +0,0 @@ -package torrent - -import ( - "container/list" - "io" - "io/ioutil" - "net" - "sync" - "testing" - "time" - - "github.com/anacrolix/missinggo/bitmap" - "github.com/anacrolix/missinggo/pubsub" - "github.com/bradfitz/iter" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/anacrolix/torrent/metainfo" - pp "github.com/anacrolix/torrent/peer_protocol" - "github.com/anacrolix/torrent/storage" -) - -func TestCancelRequestOptimized(t *testing.T) { - r, w := io.Pipe() - c := &connection{ - PeerMaxRequests: 1, - peerPieces: func() bitmap.Bitmap { - var bm bitmap.Bitmap - bm.Set(1, true) - return bm - }(), - w: w, - conn: new(net.TCPConn), - // For the locks - t: &Torrent{cl: &Client{}}, - } - assert.Len(t, c.Requests, 0) - c.Request(newRequest(1, 2, 3)) - require.Len(t, c.Requests, 1) - // Posting this message should removing the pending Request. - require.True(t, c.Cancel(newRequest(1, 2, 3))) - assert.Len(t, c.Requests, 0) - // Check that write optimization filters out the Request, due to the - // Cancel. We should have received an Interested, due to the initial - // request, and then keep-alives until we close the connection. - go c.writer(0) - b := make([]byte, 9) - n, err := io.ReadFull(r, b) - require.NoError(t, err) - require.EqualValues(t, len(b), n) - require.EqualValues(t, "\x00\x00\x00\x01\x02"+"\x00\x00\x00\x00", string(b)) - time.Sleep(time.Millisecond) - c.mu().Lock() - c.Close() - c.mu().Unlock() - w.Close() - b, err = ioutil.ReadAll(r) - require.NoError(t, err) - // A single keep-alive will have gone through, as writer would be stuck - // trying to flush it, and then promptly close. - require.EqualValues(t, "\x00\x00\x00\x00", string(b)) -} - -// Ensure that no race exists between sending a bitfield, and a subsequent -// Have that would potentially alter it. -func TestSendBitfieldThenHave(t *testing.T) { - r, w := io.Pipe() - c := &connection{ - t: &Torrent{ - cl: &Client{}, - }, - r: r, - w: w, - outgoingUnbufferedMessages: list.New(), - } - go c.writer(time.Minute) - c.mu().Lock() - c.Bitfield([]bool{false, true, false}) - c.mu().Unlock() - c.mu().Lock() - c.Have(2) - c.mu().Unlock() - b := make([]byte, 15) - n, err := io.ReadFull(r, b) - c.mu().Lock() - // This will cause connection.writer to terminate. - c.closed.Set() - c.mu().Unlock() - require.NoError(t, err) - require.EqualValues(t, 15, n) - // Here we see that the bitfield doesn't have piece 2 set, as that should - // arrive in the following Have message. - require.EqualValues(t, "\x00\x00\x00\x02\x05@\x00\x00\x00\x05\x04\x00\x00\x00\x02", string(b)) -} - -type torrentStorage struct { - writeSem sync.Mutex -} - -func (me *torrentStorage) Close() error { return nil } - -func (me *torrentStorage) Piece(mp metainfo.Piece) storage.PieceImpl { - return me -} - -func (me *torrentStorage) GetIsComplete() bool { - return false -} - -func (me *torrentStorage) MarkComplete() error { - return nil -} - -func (me *torrentStorage) MarkNotComplete() error { - return nil -} - -func (me *torrentStorage) ReadAt([]byte, int64) (int, error) { - panic("shouldn't be called") -} - -func (me *torrentStorage) WriteAt(b []byte, _ int64) (int, error) { - if len(b) != defaultChunkSize { - panic(len(b)) - } - me.writeSem.Unlock() - return len(b), nil -} - -func BenchmarkConnectionMainReadLoop(b *testing.B) { - cl := &Client{} - ts := &torrentStorage{} - t := &Torrent{ - cl: cl, - info: &metainfo.Info{ - Pieces: make([]byte, 20), - Length: 1 << 20, - PieceLength: 1 << 20, - }, - storage: &storage.Torrent{ts}, - pieceStateChanges: pubsub.NewPubSub(), - } - t.setChunkSize(defaultChunkSize) - t.makePieces() - t.pendingPieces.Add(0) - r, w := io.Pipe() - cn := &connection{ - t: t, - r: r, - } - mrlErr := make(chan error) - cl.mu.Lock() - go func() { - err := cn.mainReadLoop() - if err != nil { - mrlErr <- err - } - close(mrlErr) - }() - msg := pp.Message{ - Type: pp.Piece, - Piece: make([]byte, defaultChunkSize), - } - wb, err := msg.MarshalBinary() - require.NoError(b, err) - b.SetBytes(int64(len(msg.Piece))) - ts.writeSem.Lock() - for range iter.N(b.N) { - cl.mu.Lock() - t.pieces[0].DirtyChunks.Clear() - cl.mu.Unlock() - n, err := w.Write(wb) - require.NoError(b, err) - require.EqualValues(b, len(wb), n) - ts.writeSem.Lock() - } - w.Close() - require.NoError(b, <-mrlErr) - require.EqualValues(b, b.N, cn.UsefulChunksReceived) -} - -func TestConnectionReceiveBadChunkIndex(t *testing.T) { - cn := connection{ - t: &Torrent{}, - } - require.False(t, cn.t.haveInfo()) - assert.NotPanics(t, func() { cn.receiveChunk(&pp.Message{}) }) - cn.t.info = &metainfo.Info{} - require.True(t, cn.t.haveInfo()) - assert.NotPanics(t, func() { cn.receiveChunk(&pp.Message{}) }) -} diff --git a/vendor/github.com/anacrolix/torrent/example_test.go b/vendor/github.com/anacrolix/torrent/example_test.go deleted file mode 100644 index 5c58e4d93..000000000 --- a/vendor/github.com/anacrolix/torrent/example_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package torrent_test - -import ( - "log" - - "github.com/anacrolix/missinggo" - - "github.com/anacrolix/torrent" -) - -func Example() { - c, _ := torrent.NewClient(nil) - defer c.Close() - t, _ := c.AddMagnet("magnet:?xt=urn:btih:ZOCMZQIPFFW7OLLMIC5HUB6BPCSDEOQU") - <-t.GotInfo() - t.DownloadAll() - c.WaitAll() - log.Print("ermahgerd, torrent downloaded") -} - -func Example_fileReader() { - var ( - t *torrent.Torrent - f torrent.File - ) - r := t.NewReader() - defer r.Close() - // Access the parts of the torrent pertaining to f. Data will be - // downloaded as required, per the configuration of the torrent.Reader. - _ = missinggo.NewSectionReadSeeker(r, f.Offset(), f.Length()) -} diff --git a/vendor/github.com/anacrolix/torrent/file.go b/vendor/github.com/anacrolix/torrent/file.go index f57cd7af8..720e4fb51 100644 --- a/vendor/github.com/anacrolix/torrent/file.go +++ b/vendor/github.com/anacrolix/torrent/file.go @@ -54,6 +54,8 @@ type FilePieceState struct { // Returns the state of pieces in this file. func (f *File) State() (ret []FilePieceState) { + f.t.cl.mu.RLock() + defer f.t.cl.mu.RUnlock() pieceSize := int64(f.t.usualPieceSize()) off := f.offset % pieceSize remaining := f.length @@ -65,9 +67,7 @@ func (f *File) State() (ret []FilePieceState) { if len1 > remaining { len1 = remaining } - f.t.cl.mu.RLock() ps := f.t.pieceState(i) - f.t.cl.mu.RUnlock() ret = append(ret, FilePieceState{len1, ps}) off = 0 remaining -= len1 diff --git a/vendor/github.com/anacrolix/torrent/file_test.go b/vendor/github.com/anacrolix/torrent/file_test.go deleted file mode 100644 index b66d19852..000000000 --- a/vendor/github.com/anacrolix/torrent/file_test.go +++ /dev/null @@ -1,22 +0,0 @@ -package torrent - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestFileExclusivePieces(t *testing.T) { - for _, _case := range []struct { - off, size, pieceSize int64 - begin, end int - }{ - {0, 2, 2, 0, 1}, - {1, 2, 2, 1, 1}, - {1, 4, 2, 1, 2}, - } { - begin, end := byteRegionExclusivePieces(_case.off, _case.size, _case.pieceSize) - assert.EqualValues(t, _case.begin, begin) - assert.EqualValues(t, _case.end, end) - } -} diff --git a/vendor/github.com/anacrolix/torrent/fs/TODO b/vendor/github.com/anacrolix/torrent/fs/TODO deleted file mode 100644 index 9ab12b52b..000000000 --- a/vendor/github.com/anacrolix/torrent/fs/TODO +++ /dev/null @@ -1 +0,0 @@ - * Reinstate InitAsyncRead, or find out if it's worth it. Upstream made it a PITA to apply it automatically. diff --git a/vendor/github.com/anacrolix/torrent/fs/torrentfs.go b/vendor/github.com/anacrolix/torrent/fs/torrentfs.go deleted file mode 100644 index 06e05e008..000000000 --- a/vendor/github.com/anacrolix/torrent/fs/torrentfs.go +++ /dev/null @@ -1,308 +0,0 @@ -package torrentfs - -import ( - "expvar" - "fmt" - "io" - "os" - "path" - "strings" - "sync" - - "bazil.org/fuse" - fusefs "bazil.org/fuse/fs" - "golang.org/x/net/context" - - "github.com/anacrolix/torrent" - "github.com/anacrolix/torrent/metainfo" -) - -const ( - defaultMode = 0555 -) - -var ( - torrentfsReadRequests = expvar.NewInt("torrentfsReadRequests") - torrentfsDelayedReadRequests = expvar.NewInt("torrentfsDelayedReadRequests") - interruptedReads = expvar.NewInt("interruptedReads") -) - -type TorrentFS struct { - Client *torrent.Client - destroyed chan struct{} - mu sync.Mutex - blockedReads int - event sync.Cond -} - -var ( - _ fusefs.FSDestroyer = &TorrentFS{} - - _ fusefs.NodeForgetter = rootNode{} - _ fusefs.HandleReadDirAller = rootNode{} - _ fusefs.HandleReadDirAller = dirNode{} -) - -type rootNode struct { - fs *TorrentFS -} - -type node struct { - path string - metadata *metainfo.Info - FS *TorrentFS - t *torrent.Torrent -} - -type fileNode struct { - node - size uint64 - TorrentOffset int64 -} - -func (fn fileNode) Attr(ctx context.Context, attr *fuse.Attr) error { - attr.Size = fn.size - attr.Mode = defaultMode - return nil -} - -func (n *node) fsPath() string { - return "/" + n.metadata.Name + "/" + n.path -} - -func blockingRead(ctx context.Context, fs *TorrentFS, t *torrent.Torrent, off int64, p []byte) (n int, err error) { - fs.mu.Lock() - fs.blockedReads++ - fs.event.Broadcast() - fs.mu.Unlock() - var ( - _n int - _err error - ) - readDone := make(chan struct{}) - go func() { - defer close(readDone) - r := t.NewReader() - defer r.Close() - _, _err = r.Seek(off, os.SEEK_SET) - if _err != nil { - return - } - _n, _err = io.ReadFull(r, p) - }() - select { - case <-readDone: - n = _n - err = _err - case <-fs.destroyed: - err = fuse.EIO - case <-ctx.Done(): - err = fuse.EINTR - } - fs.mu.Lock() - fs.blockedReads-- - fs.event.Broadcast() - fs.mu.Unlock() - return -} - -func readFull(ctx context.Context, fs *TorrentFS, t *torrent.Torrent, off int64, p []byte) (n int, err error) { - for len(p) != 0 { - var nn int - nn, err = blockingRead(ctx, fs, t, off, p) - if err != nil { - break - } - n += nn - off += int64(nn) - p = p[nn:] - } - return -} - -func (fn fileNode) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error { - torrentfsReadRequests.Add(1) - if req.Dir { - panic("read on directory") - } - size := req.Size - fileLeft := int64(fn.size) - req.Offset - if fileLeft < 0 { - fileLeft = 0 - } - if fileLeft < int64(size) { - size = int(fileLeft) - } - resp.Data = resp.Data[:size] - if len(resp.Data) == 0 { - return nil - } - torrentOff := fn.TorrentOffset + req.Offset - n, err := readFull(ctx, fn.FS, fn.t, torrentOff, resp.Data) - if err != nil { - return err - } - if n != size { - panic(fmt.Sprintf("%d < %d", n, size)) - } - return nil -} - -type dirNode struct { - node -} - -var ( - _ fusefs.HandleReadDirAller = dirNode{} - _ fusefs.HandleReader = fileNode{} -) - -func isSubPath(parent, child string) bool { - if len(parent) == 0 { - return len(child) > 0 - } - if !strings.HasPrefix(child, parent) { - return false - } - s := child[len(parent):] - if len(s) == 0 { - return false - } - return s[0] == '/' -} - -func (dn dirNode) ReadDirAll(ctx context.Context) (des []fuse.Dirent, err error) { - names := map[string]bool{} - for _, fi := range dn.metadata.Files { - if !isSubPath(dn.path, strings.Join(fi.Path, "/")) { - continue - } - name := fi.Path[len(dn.path)] - if names[name] { - continue - } - names[name] = true - de := fuse.Dirent{ - Name: name, - } - if len(fi.Path) == len(dn.path)+1 { - de.Type = fuse.DT_File - } else { - de.Type = fuse.DT_Dir - } - des = append(des, de) - } - return -} - -func (dn dirNode) Lookup(ctx context.Context, name string) (_node fusefs.Node, err error) { - var torrentOffset int64 - for _, fi := range dn.metadata.Files { - if !isSubPath(dn.path, strings.Join(fi.Path, "/")) { - torrentOffset += fi.Length - continue - } - if fi.Path[len(dn.path)] != name { - torrentOffset += fi.Length - continue - } - __node := dn.node - __node.path = path.Join(__node.path, name) - if len(fi.Path) == len(dn.path)+1 { - _node = fileNode{ - node: __node, - size: uint64(fi.Length), - TorrentOffset: torrentOffset, - } - } else { - _node = dirNode{__node} - } - break - } - if _node == nil { - err = fuse.ENOENT - } - return -} - -func (dn dirNode) Attr(ctx context.Context, attr *fuse.Attr) error { - attr.Mode = os.ModeDir | defaultMode - return nil -} - -func (rn rootNode) Lookup(ctx context.Context, name string) (_node fusefs.Node, err error) { - for _, t := range rn.fs.Client.Torrents() { - info := t.Info() - if t.Name() != name || info == nil { - continue - } - __node := node{ - metadata: info, - FS: rn.fs, - t: t, - } - if !info.IsDir() { - _node = fileNode{__node, uint64(info.Length), 0} - } else { - _node = dirNode{__node} - } - break - } - if _node == nil { - err = fuse.ENOENT - } - return -} - -func (rn rootNode) ReadDirAll(ctx context.Context) (dirents []fuse.Dirent, err error) { - for _, t := range rn.fs.Client.Torrents() { - info := t.Info() - if info == nil { - continue - } - dirents = append(dirents, fuse.Dirent{ - Name: info.Name, - Type: func() fuse.DirentType { - if !info.IsDir() { - return fuse.DT_File - } else { - return fuse.DT_Dir - } - }(), - }) - } - return -} - -func (rn rootNode) Attr(ctx context.Context, attr *fuse.Attr) error { - attr.Mode = os.ModeDir - return nil -} - -// TODO(anacrolix): Why should rootNode implement this? -func (rn rootNode) Forget() { - rn.fs.Destroy() -} - -func (tfs *TorrentFS) Root() (fusefs.Node, error) { - return rootNode{tfs}, nil -} - -func (tfs *TorrentFS) Destroy() { - tfs.mu.Lock() - select { - case <-tfs.destroyed: - default: - close(tfs.destroyed) - } - tfs.mu.Unlock() -} - -func New(cl *torrent.Client) *TorrentFS { - fs := &TorrentFS{ - Client: cl, - destroyed: make(chan struct{}), - } - fs.event.L = &fs.mu - return fs -} diff --git a/vendor/github.com/anacrolix/torrent/fs/torrentfs_test.go b/vendor/github.com/anacrolix/torrent/fs/torrentfs_test.go deleted file mode 100644 index 53fcc400b..000000000 --- a/vendor/github.com/anacrolix/torrent/fs/torrentfs_test.go +++ /dev/null @@ -1,225 +0,0 @@ -package torrentfs - -import ( - "fmt" - "io/ioutil" - "log" - "net" - _ "net/http/pprof" - "os" - "path/filepath" - "strings" - "testing" - "time" - - "bazil.org/fuse" - fusefs "bazil.org/fuse/fs" - _ "github.com/anacrolix/envpprof" - "github.com/anacrolix/missinggo" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - netContext "golang.org/x/net/context" - - "github.com/anacrolix/torrent" - "github.com/anacrolix/torrent/internal/testutil" - "github.com/anacrolix/torrent/metainfo" - "github.com/anacrolix/torrent/storage" -) - -func init() { - log.SetFlags(log.Flags() | log.Lshortfile) -} - -func TestTCPAddrString(t *testing.T) { - l, err := net.Listen("tcp4", "localhost:0") - if err != nil { - t.Fatal(err) - } - defer l.Close() - c, err := net.Dial("tcp", l.Addr().String()) - if err != nil { - t.Fatal(err) - } - defer c.Close() - ras := c.RemoteAddr().String() - ta := &net.TCPAddr{ - IP: net.IPv4(127, 0, 0, 1), - Port: missinggo.AddrPort(l.Addr()), - } - s := ta.String() - if ras != s { - t.FailNow() - } -} - -type testLayout struct { - BaseDir string - MountDir string - Completed string - Metainfo *metainfo.MetaInfo -} - -func (tl *testLayout) Destroy() error { - return os.RemoveAll(tl.BaseDir) -} - -func newGreetingLayout() (tl testLayout, err error) { - tl.BaseDir, err = ioutil.TempDir("", "torrentfs") - if err != nil { - return - } - tl.Completed = filepath.Join(tl.BaseDir, "completed") - os.Mkdir(tl.Completed, 0777) - tl.MountDir = filepath.Join(tl.BaseDir, "mnt") - os.Mkdir(tl.MountDir, 0777) - testutil.CreateDummyTorrentData(tl.Completed) - tl.Metainfo = testutil.GreetingMetaInfo() - return -} - -// Unmount without first killing the FUSE connection while there are FUSE -// operations blocked inside the filesystem code. -func TestUnmountWedged(t *testing.T) { - layout, err := newGreetingLayout() - require.NoError(t, err) - defer func() { - err := layout.Destroy() - if err != nil { - t.Log(err) - } - }() - client, err := torrent.NewClient(&torrent.Config{ - DataDir: filepath.Join(layout.BaseDir, "incomplete"), - DisableTrackers: true, - NoDHT: true, - DisableTCP: true, - DisableUTP: true, - }) - require.NoError(t, err) - defer client.Close() - tt, err := client.AddTorrent(layout.Metainfo) - require.NoError(t, err) - fs := New(client) - fuseConn, err := fuse.Mount(layout.MountDir) - if err != nil { - msg := fmt.Sprintf("error mounting: %s", err) - if strings.Contains(err.Error(), "fuse") || err.Error() == "exit status 71" { - t.Skip(msg) - } - t.Fatal(msg) - } - go func() { - server := fusefs.New(fuseConn, &fusefs.Config{ - Debug: func(msg interface{}) { - t.Log(msg) - }, - }) - server.Serve(fs) - }() - <-fuseConn.Ready - if err := fuseConn.MountError; err != nil { - t.Fatalf("mount error: %s", err) - } - // Read the greeting file, though it will never be available. This should - // "wedge" FUSE, requiring the fs object to be forcibly destroyed. The - // read call will return with a FS error. - go func() { - _, err := ioutil.ReadFile(filepath.Join(layout.MountDir, tt.Info().Name)) - if err == nil { - t.Fatal("expected error reading greeting") - } - }() - - // Wait until the read has blocked inside the filesystem code. - fs.mu.Lock() - for fs.blockedReads != 1 { - fs.event.Wait() - } - fs.mu.Unlock() - - fs.Destroy() - - for { - err = fuse.Unmount(layout.MountDir) - if err != nil { - t.Logf("error unmounting: %s", err) - time.Sleep(time.Millisecond) - } else { - break - } - } - - err = fuseConn.Close() - if err != nil { - t.Fatalf("error closing fuse conn: %s", err) - } -} - -func TestDownloadOnDemand(t *testing.T) { - layout, err := newGreetingLayout() - require.NoError(t, err) - defer layout.Destroy() - seeder, err := torrent.NewClient(&torrent.Config{ - DataDir: layout.Completed, - DisableTrackers: true, - NoDHT: true, - ListenAddr: "localhost:0", - Seed: true, - }) - require.NoError(t, err) - defer seeder.Close() - testutil.ExportStatusWriter(seeder, "s") - _, err = seeder.AddMagnet(fmt.Sprintf("magnet:?xt=urn:btih:%s", layout.Metainfo.HashInfoBytes().HexString())) - require.NoError(t, err) - leecher, err := torrent.NewClient(&torrent.Config{ - DisableTrackers: true, - NoDHT: true, - ListenAddr: "localhost:0", - DisableTCP: true, - DefaultStorage: storage.NewMMap(filepath.Join(layout.BaseDir, "download")), - // This can be used to check if clients can connect to other clients - // with the same ID. - // PeerID: seeder.PeerID(), - }) - require.NoError(t, err) - testutil.ExportStatusWriter(leecher, "l") - defer leecher.Close() - leecherTorrent, _ := leecher.AddTorrent(layout.Metainfo) - leecherTorrent.AddPeers([]torrent.Peer{ - { - IP: missinggo.AddrIP(seeder.ListenAddr()), - Port: missinggo.AddrPort(seeder.ListenAddr()), - }, - }) - fs := New(leecher) - defer fs.Destroy() - root, _ := fs.Root() - node, _ := root.(fusefs.NodeStringLookuper).Lookup(netContext.Background(), "greeting") - var attr fuse.Attr - node.Attr(netContext.Background(), &attr) - size := attr.Size - resp := &fuse.ReadResponse{ - Data: make([]byte, size), - } - node.(fusefs.HandleReader).Read(netContext.Background(), &fuse.ReadRequest{ - Size: int(size), - }, resp) - assert.EqualValues(t, testutil.GreetingFileContents, resp.Data) -} - -func TestIsSubPath(t *testing.T) { - for _, case_ := range []struct { - parent, child string - is bool - }{ - {"", "", false}, - {"", "/", true}, - {"", "a", true}, - {"a/b", "a/bc", false}, - {"a/b", "a/b", false}, - {"a/b", "a/b/c", true}, - {"a/b", "a//b", false}, - } { - assert.Equal(t, case_.is, isSubPath(case_.parent, case_.child)) - } -} diff --git a/vendor/github.com/anacrolix/torrent/fs/unwedge-tests b/vendor/github.com/anacrolix/torrent/fs/unwedge-tests deleted file mode 100755 index 322a2802a..000000000 --- a/vendor/github.com/anacrolix/torrent/fs/unwedge-tests +++ /dev/null @@ -1,5 +0,0 @@ -shopt -s nullglob -for a in "${TMPDIR:-/tmp}"/torrentfs*; do - sudo umount -f "$a/mnt" - rm -r -- "$a" -done diff --git a/vendor/github.com/anacrolix/torrent/global.go b/vendor/github.com/anacrolix/torrent/global.go index 0d2411283..fe1901cbb 100644 --- a/vendor/github.com/anacrolix/torrent/global.go +++ b/vendor/github.com/anacrolix/torrent/global.go @@ -63,7 +63,6 @@ var ( uploadChunksPosted = expvar.NewInt("uploadChunksPosted") unexpectedCancels = expvar.NewInt("unexpectedCancels") - postedCancels = expvar.NewInt("postedCancels") pieceHashedCorrect = expvar.NewInt("pieceHashedCorrect") pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect") @@ -81,16 +80,22 @@ var ( connsToSelf = expvar.NewInt("connsToSelf") // Number of completed connections to a client we're already connected with. duplicateClientConns = expvar.NewInt("duplicateClientConns") - receivedMessageTypes = expvar.NewMap("receivedMessageTypes") receivedKeepalives = expvar.NewInt("receivedKeepalives") supportedExtensionMessages = expvar.NewMap("supportedExtensionMessages") - postedMessageTypes = expvar.NewMap("postedMessageTypes") postedKeepalives = expvar.NewInt("postedKeepalives") // Requests received for pieces we don't have. requestsReceivedForMissingPieces = expvar.NewInt("requestsReceivedForMissingPieces") + messageTypesReceived = expvar.NewMap("messageTypesReceived") + messageTypesSent = expvar.NewMap("messageTypesSent") + messageTypesPosted = expvar.NewMap("messageTypesPosted") + // Track the effectiveness of Torrent.connPieceInclinationPool. pieceInclinationsReused = expvar.NewInt("pieceInclinationsReused") pieceInclinationsNew = expvar.NewInt("pieceInclinationsNew") pieceInclinationsPut = expvar.NewInt("pieceInclinationsPut") + + fillBufferSentCancels = expvar.NewInt("fillBufferSentCancels") + fillBufferSentRequests = expvar.NewInt("fillBufferSentRequests") + numFillBuffers = expvar.NewInt("numFillBuffers") ) diff --git a/vendor/github.com/anacrolix/torrent/internal/cmd/bloom-estimate/main.go b/vendor/github.com/anacrolix/torrent/internal/cmd/bloom-estimate/main.go deleted file mode 100644 index 5cdb41c2a..000000000 --- a/vendor/github.com/anacrolix/torrent/internal/cmd/bloom-estimate/main.go +++ /dev/null @@ -1,16 +0,0 @@ -package main - -import ( - "flag" - "fmt" - - "github.com/willf/bloom" -) - -func main() { - n := flag.Int("n", 0, "expected number of items") - falsePositiveRate := flag.Float64("fpr", 0, "false positive rate") - flag.Parse() - filter := bloom.NewWithEstimates(uint(*n), *falsePositiveRate) - fmt.Printf("m: %d, k: %d\n", filter.Cap(), filter.K()) -} diff --git a/vendor/github.com/anacrolix/torrent/internal/cmd/bloom-false-positives/main.go b/vendor/github.com/anacrolix/torrent/internal/cmd/bloom-false-positives/main.go deleted file mode 100644 index 456e21066..000000000 --- a/vendor/github.com/anacrolix/torrent/internal/cmd/bloom-false-positives/main.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "bufio" - "fmt" - "os" - - "github.com/anacrolix/tagflag" - "github.com/willf/bloom" -) - -func main() { - var args struct { - M uint `help:"num bits"` - K uint `help:"num hashing functions"` - } - tagflag.Parse(&args, tagflag.Description("adds lines from stdin to a bloom filter with the given configuration, and gives collision stats at EOF")) - filter := bloom.New(args.M, args.K) - scanner := bufio.NewScanner(os.Stdin) - n := 0 - collisions := 0 - for scanner.Scan() { - if filter.TestAndAdd(scanner.Bytes()) { - collisions++ - } - n++ - } - if err := scanner.Err(); err != nil { - fmt.Fprintf(os.Stderr, "error reading stdin: %s", err) - os.Exit(1) - } - fmt.Printf("collisions %d/%d (%f)\n", collisions, n, float64(collisions)/float64(n)*100) -} diff --git a/vendor/github.com/anacrolix/torrent/internal/testutil/testutil.go b/vendor/github.com/anacrolix/torrent/internal/testutil/testutil.go deleted file mode 100644 index 6431a1f18..000000000 --- a/vendor/github.com/anacrolix/torrent/internal/testutil/testutil.go +++ /dev/null @@ -1,79 +0,0 @@ -// Package testutil contains stuff for testing torrent-related behaviour. -// -// "greeting" is a single-file torrent of a file called "greeting" that -// "contains "hello, world\n". - -package testutil - -import ( - "fmt" - "io" - "io/ioutil" - "net/http" - "os" - "path/filepath" - "strings" - - "github.com/anacrolix/missinggo" - - "github.com/anacrolix/torrent/bencode" - "github.com/anacrolix/torrent/metainfo" -) - -const ( - GreetingFileContents = "hello, world\n" - GreetingFileName = "greeting" -) - -func CreateDummyTorrentData(dirName string) string { - f, _ := os.Create(filepath.Join(dirName, "greeting")) - defer f.Close() - f.WriteString(GreetingFileContents) - return f.Name() -} - -func GreetingMetaInfo() *metainfo.MetaInfo { - info := metainfo.Info{ - Name: GreetingFileName, - Length: int64(len(GreetingFileContents)), - PieceLength: 5, - } - err := info.GeneratePieces(func(metainfo.FileInfo) (io.ReadCloser, error) { - return ioutil.NopCloser(strings.NewReader(GreetingFileContents)), nil - }) - if err != nil { - panic(err) - } - mi := &metainfo.MetaInfo{} - mi.InfoBytes, err = bencode.Marshal(info) - if err != nil { - panic(err) - } - return mi -} - -// Gives a temporary directory containing the completed "greeting" torrent, -// and a corresponding metainfo describing it. The temporary directory can be -// cleaned away with os.RemoveAll. -func GreetingTestTorrent() (tempDir string, metaInfo *metainfo.MetaInfo) { - tempDir, err := ioutil.TempDir(os.TempDir(), "") - if err != nil { - panic(err) - } - CreateDummyTorrentData(tempDir) - metaInfo = GreetingMetaInfo() - return -} - -type StatusWriter interface { - WriteStatus(io.Writer) -} - -func ExportStatusWriter(sw StatusWriter, path string) { - http.HandleFunc( - fmt.Sprintf("/%s/%s", missinggo.GetTestName(), path), - func(w http.ResponseWriter, r *http.Request) { - sw.WriteStatus(w) - }, - ) -} diff --git a/vendor/github.com/anacrolix/torrent/iplist/cidr_test.go b/vendor/github.com/anacrolix/torrent/iplist/cidr_test.go deleted file mode 100644 index ad904f52d..000000000 --- a/vendor/github.com/anacrolix/torrent/iplist/cidr_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package iplist - -import ( - "bytes" - "net" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestIPNetLast(t *testing.T) { - _, in, err := net.ParseCIDR("138.255.252.0/22") - require.NoError(t, err) - assert.EqualValues(t, []byte{138, 255, 252, 0}, in.IP) - assert.EqualValues(t, []byte{255, 255, 252, 0}, in.Mask) - assert.EqualValues(t, []byte{138, 255, 255, 255}, IPNetLast(in)) - _, in, err = net.ParseCIDR("2400:cb00::/31") - require.NoError(t, err) - assert.EqualValues(t, []byte{0x24, 0, 0xcb, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, in.IP) - assert.EqualValues(t, []byte{255, 255, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, in.Mask) - assert.EqualValues(t, []byte{0x24, 0, 0xcb, 1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, IPNetLast(in)) -} - -func TestParseCIDRList(t *testing.T) { - r := bytes.NewBufferString(`2400:cb00::/32 -2405:8100::/32 -2405:b500::/32 -2606:4700::/32 -2803:f800::/32 -2c0f:f248::/32 -2a06:98c0::/29 -`) - rs, err := ParseCIDRListReader(r) - require.NoError(t, err) - require.Len(t, rs, 7) - assert.EqualValues(t, Range{ - First: net.IP{0x28, 3, 0xf8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - Last: net.IP{0x28, 3, 0xf8, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, - }, rs[4]) -} diff --git a/vendor/github.com/anacrolix/torrent/iplist/cmd/pack-blocklist/main.go b/vendor/github.com/anacrolix/torrent/iplist/cmd/pack-blocklist/main.go deleted file mode 100644 index 037ceeba7..000000000 --- a/vendor/github.com/anacrolix/torrent/iplist/cmd/pack-blocklist/main.go +++ /dev/null @@ -1,27 +0,0 @@ -// Takes P2P blocklist text format in stdin, and outputs the packed format -// from the iplist package. -package main - -import ( - "bufio" - "os" - - "github.com/anacrolix/missinggo" - "github.com/anacrolix/tagflag" - - "github.com/anacrolix/torrent/iplist" -) - -func main() { - tagflag.Parse(nil) - l, err := iplist.NewFromReader(os.Stdin) - if err != nil { - missinggo.Fatal(err) - } - wb := bufio.NewWriter(os.Stdout) - defer wb.Flush() - err = l.WritePacked(wb) - if err != nil { - missinggo.Fatal(err) - } -} diff --git a/vendor/github.com/anacrolix/torrent/iplist/iplist_test.go b/vendor/github.com/anacrolix/torrent/iplist/iplist_test.go deleted file mode 100644 index e8d2cbe46..000000000 --- a/vendor/github.com/anacrolix/torrent/iplist/iplist_test.go +++ /dev/null @@ -1,149 +0,0 @@ -package iplist - -import ( - "bufio" - "bytes" - "fmt" - "net" - "strings" - "testing" - - "github.com/anacrolix/missinggo" - "github.com/bradfitz/iter" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -var ( - // Note the shared description "eff". The overlapping ranges at 1.2.8.2 - // will cause problems. Don't overlap your ranges. - sample = ` -# List distributed by iblocklist.com - -a:1.2.4.0-1.2.4.255 -b:1.2.8.0-1.2.8.255 -eff:1.2.8.2-1.2.8.2 -something:more detail:86.59.95.195-86.59.95.195 -eff:127.0.0.0-127.0.0.1` - packedSample []byte -) - -func init() { - var buf bytes.Buffer - list, err := NewFromReader(strings.NewReader(sample)) - if err != nil { - panic(err) - } - err = list.WritePacked(&buf) - if err != nil { - panic(err) - } - packedSample = buf.Bytes() -} - -func TestIPv4RangeLen(t *testing.T) { - ranges, _ := sampleRanges(t) - for i := range iter.N(3) { - if len(ranges[i].First) != 4 { - t.FailNow() - } - if len(ranges[i].Last) != 4 { - t.FailNow() - } - } -} - -func sampleRanges(tb testing.TB) (ranges []Range, err error) { - scanner := bufio.NewScanner(strings.NewReader(sample)) - for scanner.Scan() { - r, ok, err := ParseBlocklistP2PLine(scanner.Bytes()) - if err != nil { - tb.Fatal(err) - } - if ok { - ranges = append(ranges, r) - } - } - err = scanner.Err() - return -} - -func BenchmarkParseP2pBlocklist(b *testing.B) { - for i := 0; i < b.N; i++ { - sampleRanges(b) - } -} - -func connRemoteAddrIP(network, laddr string, dialHost string) net.IP { - l, err := net.Listen(network, laddr) - if err != nil { - panic(err) - } - go func() { - c, err := net.Dial(network, net.JoinHostPort(dialHost, fmt.Sprintf("%d", missinggo.AddrPort(l.Addr())))) - if err != nil { - panic(err) - } - defer c.Close() - }() - c, err := l.Accept() - if err != nil { - panic(err) - } - defer c.Close() - ret := missinggo.AddrIP(c.RemoteAddr()) - return ret -} - -func lookupOk(r Range, ok bool) bool { - return ok -} - -func TestBadIP(t *testing.T) { - for _, iplist := range []Ranger{ - New(nil), - NewFromPacked([]byte("\x00\x00\x00\x00\x00\x00\x00\x00")), - } { - assert.False(t, lookupOk(iplist.Lookup(net.IP(make([]byte, 4)))), "%v", iplist) - assert.False(t, lookupOk(iplist.Lookup(net.IP(make([]byte, 16))))) - r, ok := iplist.Lookup(nil) - assert.True(t, ok) - assert.Equal(t, r.Description, "bad IP") - assert.True(t, lookupOk(iplist.Lookup(net.IP(make([]byte, 5))))) - } -} - -func testLookuperSimple(t *testing.T, iplist Ranger) { - for _, _case := range []struct { - IP string - Hit bool - Desc string - }{ - {"1.2.3.255", false, ""}, - {"1.2.8.0", true, "b"}, - {"1.2.4.255", true, "a"}, - // Try to roll over to the next octet on the parse. Note the final - // octet is overbounds. In the next case. - {"1.2.7.256", true, "bad IP"}, - {"1.2.8.1", true, "b"}, - {"1.2.8.2", true, "eff"}, - } { - ip := net.ParseIP(_case.IP) - r, ok := iplist.Lookup(ip) - assert.Equal(t, _case.Hit, ok, "%s", _case) - if !_case.Hit { - continue - } - assert.Equal(t, _case.Desc, r.Description, "%T", iplist) - } -} - -func TestSimple(t *testing.T) { - ranges, err := sampleRanges(t) - require.NoError(t, err) - require.Len(t, ranges, 5) - iplist := New(ranges) - testLookuperSimple(t, iplist) - packed := NewFromPacked(packedSample) - testLookuperSimple(t, packed) -} diff --git a/vendor/github.com/anacrolix/torrent/iplist/packed.go b/vendor/github.com/anacrolix/torrent/iplist/packed.go index b5c0a5e34..427e55725 100644 --- a/vendor/github.com/anacrolix/torrent/iplist/packed.go +++ b/vendor/github.com/anacrolix/torrent/iplist/packed.go @@ -128,6 +128,7 @@ func MMapPacked(filename string) (ret Ranger, err error) { if err != nil { return } + // TODO: Need a destructor that unmaps this. ret = NewFromPacked(mm) return } diff --git a/vendor/github.com/anacrolix/torrent/iplist/packed_test.go b/vendor/github.com/anacrolix/torrent/iplist/packed_test.go deleted file mode 100644 index d6235dbbb..000000000 --- a/vendor/github.com/anacrolix/torrent/iplist/packed_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package iplist - -import ( - "bytes" - "strings" - "testing" - - "github.com/stretchr/testify/require" -) - -// The active ingredients in the sample P2P blocklist file contents `sample`, -// for reference: -// -// a:1.2.4.0-1.2.4.255 -// b:1.2.8.0-1.2.8.255 -// eff:1.2.8.2-1.2.8.2 -// something:more detail:86.59.95.195-86.59.95.195 -// eff:127.0.0.0-127.0.0.1` - -func TestWritePacked(t *testing.T) { - l, err := NewFromReader(strings.NewReader(sample)) - require.NoError(t, err) - var buf bytes.Buffer - err = l.WritePacked(&buf) - require.NoError(t, err) - require.Equal(t, - "\x05\x00\x00\x00\x00\x00\x00\x00"+ - "\x01\x02\x04\x00\x01\x02\x04\xff"+"\x00\x00\x00\x00\x00\x00\x00\x00"+"\x01\x00\x00\x00"+ - "\x01\x02\x08\x00\x01\x02\x08\xff"+"\x01\x00\x00\x00\x00\x00\x00\x00"+"\x01\x00\x00\x00"+ - "\x01\x02\x08\x02\x01\x02\x08\x02"+"\x02\x00\x00\x00\x00\x00\x00\x00"+"\x03\x00\x00\x00"+ - "\x56\x3b\x5f\xc3\x56\x3b\x5f\xc3"+"\x05\x00\x00\x00\x00\x00\x00\x00"+"\x15\x00\x00\x00"+ - "\x7f\x00\x00\x00\x7f\x00\x00\x01"+"\x02\x00\x00\x00\x00\x00\x00\x00"+"\x03\x00\x00\x00"+ - "abeffsomething:more detail", - buf.String()) -} diff --git a/vendor/github.com/anacrolix/torrent/issue97_test.go b/vendor/github.com/anacrolix/torrent/issue97_test.go deleted file mode 100644 index 5e1ab8f9f..000000000 --- a/vendor/github.com/anacrolix/torrent/issue97_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package torrent - -import ( - "io/ioutil" - "os" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/anacrolix/torrent/internal/testutil" - "github.com/anacrolix/torrent/storage" -) - -func TestHashPieceAfterStorageClosed(t *testing.T) { - td, err := ioutil.TempDir("", "") - require.NoError(t, err) - defer os.RemoveAll(td) - cs := storage.NewClient(storage.NewFile(td)) - tt := &Torrent{} - mi := testutil.GreetingMetaInfo() - info, err := mi.UnmarshalInfo() - require.NoError(t, err) - tt.info = &info - tt.makePieces() - tt.storage, err = cs.OpenTorrent(tt.info, mi.HashInfoBytes()) - require.NoError(t, err) - require.NoError(t, tt.storage.Close()) - tt.hashPiece(0) -} diff --git a/vendor/github.com/anacrolix/torrent/main_test.go b/vendor/github.com/anacrolix/torrent/main_test.go deleted file mode 100644 index b6e462309..000000000 --- a/vendor/github.com/anacrolix/torrent/main_test.go +++ /dev/null @@ -1,12 +0,0 @@ -package torrent - -import ( - "os" - "testing" -) - -func TestMain(m *testing.M) { - code := m.Run() - // select {} - os.Exit(code) -} diff --git a/vendor/github.com/anacrolix/torrent/metainfo/info.go b/vendor/github.com/anacrolix/torrent/metainfo/info.go index 7fbc88e95..a7e23a7f0 100644 --- a/vendor/github.com/anacrolix/torrent/metainfo/info.go +++ b/vendor/github.com/anacrolix/torrent/metainfo/info.go @@ -126,9 +126,6 @@ func (info *Info) TotalLength() (ret int64) { } func (info *Info) NumPieces() int { - if len(info.Pieces)%20 != 0 { - panic(len(info.Pieces)) - } return len(info.Pieces) / 20 } diff --git a/vendor/github.com/anacrolix/torrent/metainfo/info_test.go b/vendor/github.com/anacrolix/torrent/metainfo/info_test.go deleted file mode 100644 index cf1eaf8f0..000000000 --- a/vendor/github.com/anacrolix/torrent/metainfo/info_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package metainfo - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/anacrolix/torrent/bencode" -) - -func TestMarshalInfo(t *testing.T) { - var info Info - b, err := bencode.Marshal(info) - assert.NoError(t, err) - assert.EqualValues(t, "d4:name0:12:piece lengthi0e6:pieceslee", string(b)) -} diff --git a/vendor/github.com/anacrolix/torrent/metainfo/magnet_test.go b/vendor/github.com/anacrolix/torrent/metainfo/magnet_test.go deleted file mode 100644 index c90713f30..000000000 --- a/vendor/github.com/anacrolix/torrent/metainfo/magnet_test.go +++ /dev/null @@ -1,115 +0,0 @@ -package metainfo - -import ( - "encoding/hex" - "reflect" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -var ( - exampleMagnetURI = `magnet:?xt=urn:btih:51340689c960f0778a4387aef9b4b52fd08390cd&dn=Shit+Movie+%281985%29+1337p+-+Eru&tr=http%3A%2F%2Fhttp.was.great%21&tr=udp%3A%2F%2Fanti.piracy.honeypot%3A6969` - exampleMagnet = Magnet{ - DisplayName: "Shit Movie (1985) 1337p - Eru", - Trackers: []string{ - "http://http.was.great!", - "udp://anti.piracy.honeypot:6969", - }, - } -) - -// Converting from our Magnet type to URL string. -func TestMagnetString(t *testing.T) { - hex.Decode(exampleMagnet.InfoHash[:], []byte("51340689c960f0778a4387aef9b4b52fd08390cd")) - s := exampleMagnet.String() - if s != exampleMagnetURI { - t.Fatalf("\nexpected:\n\t%q\nactual\n\t%q", exampleMagnetURI, s) - } -} - -func TestParseMagnetURI(t *testing.T) { - var uri string - var m Magnet - var err error - - // parsing the legit Magnet URI with btih-formatted xt should not return errors - uri = "magnet:?xt=urn:btih:ZOCMZQIPFFW7OLLMIC5HUB6BPCSDEOQU" - _, err = ParseMagnetURI(uri) - if err != nil { - t.Errorf("Attempting parsing the proper Magnet btih URI:\"%v\" failed with err: %v", uri, err) - } - - // Checking if the magnet instance struct is built correctly from parsing - m, err = ParseMagnetURI(exampleMagnetURI) - if err != nil || !reflect.DeepEqual(exampleMagnet, m) { - t.Errorf("ParseMagnetURI(%s) returned %v, expected %v", uri, m, exampleMagnet) - } - - // empty string URI case - _, err = ParseMagnetURI("") - if err == nil { - t.Errorf("Parsing empty string as URI should have returned an error but didn't") - } - - // only BTIH (BitTorrent info hash)-formatted magnet links are currently supported - // must return error correctly when encountering other URN formats - uri = "magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C" - _, err = ParseMagnetURI(uri) - if err == nil { - t.Errorf("Magnet URI with non-BTIH URNs (like \"%v\") are not supported and should return an error", uri) - } - - // resilience to the broken hash - uri = "magnet:?xt=urn:btih:this hash is really broken" - _, err = ParseMagnetURI(uri) - if err == nil { - t.Errorf("Failed to detect broken Magnet URI: %v", uri) - } - -} - -func TestMagnetize(t *testing.T) { - mi, err := LoadFromFile("../testdata/bootstrap.dat.torrent") - require.NoError(t, err) - - info, err := mi.UnmarshalInfo() - require.NoError(t, err) - m := mi.Magnet(info.Name, mi.HashInfoBytes()) - - assert.EqualValues(t, "bootstrap.dat", m.DisplayName) - - ih := [20]byte{ - 54, 113, 155, 162, 206, 207, 159, 59, 215, 197, - 171, 251, 122, 136, 233, 57, 97, 27, 83, 108, - } - - if m.InfoHash != ih { - t.Errorf("Magnet infohash is incorrect") - } - - trackers := []string{ - "udp://tracker.openbittorrent.com:80", - "udp://tracker.openbittorrent.com:80", - "udp://tracker.publicbt.com:80", - "udp://coppersurfer.tk:6969/announce", - "udp://open.demonii.com:1337", - "http://bttracker.crunchbanglinux.org:6969/announce", - } - - for _, expected := range trackers { - if !contains(m.Trackers, expected) { - t.Errorf("Magnet does not contain expected tracker: %s", expected) - } - } -} - -func contains(haystack []string, needle string) bool { - for _, s := range haystack { - if s == needle { - return true - } - } - return false -} diff --git a/vendor/github.com/anacrolix/torrent/metainfo/metainfo.go b/vendor/github.com/anacrolix/torrent/metainfo/metainfo.go index 947bd7136..55624e99c 100644 --- a/vendor/github.com/anacrolix/torrent/metainfo/metainfo.go +++ b/vendor/github.com/anacrolix/torrent/metainfo/metainfo.go @@ -17,7 +17,7 @@ type MetaInfo struct { Comment string `bencode:"comment,omitempty"` CreatedBy string `bencode:"created by,omitempty"` Encoding string `bencode:"encoding,omitempty"` - URLList []string `bencode:"url-list,omitempty"` + UrlList UrlList `bencode:"url-list,omitempty"` } // Load a MetaInfo from an io.Reader. Returns a non-nil error in case of diff --git a/vendor/github.com/anacrolix/torrent/metainfo/metainfo_test.go b/vendor/github.com/anacrolix/torrent/metainfo/metainfo_test.go deleted file mode 100644 index 037f8825f..000000000 --- a/vendor/github.com/anacrolix/torrent/metainfo/metainfo_test.go +++ /dev/null @@ -1,118 +0,0 @@ -package metainfo - -import ( - "io" - "io/ioutil" - "os" - "path" - "path/filepath" - "testing" - - "github.com/anacrolix/missinggo" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/anacrolix/torrent/bencode" -) - -func testFile(t *testing.T, filename string) { - mi, err := LoadFromFile(filename) - require.NoError(t, err) - info, err := mi.UnmarshalInfo() - require.NoError(t, err) - - if len(info.Files) == 1 { - t.Logf("Single file: %s (length: %d)\n", info.Name, info.Files[0].Length) - } else { - t.Logf("Multiple files: %s\n", info.Name) - for _, f := range info.Files { - t.Logf(" - %s (length: %d)\n", path.Join(f.Path...), f.Length) - } - } - - for _, group := range mi.AnnounceList { - for _, tracker := range group { - t.Logf("Tracker: %s\n", tracker) - } - } - - b, err := bencode.Marshal(&info) - require.NoError(t, err) - assert.EqualValues(t, string(b), string(mi.InfoBytes)) -} - -func TestFile(t *testing.T) { - testFile(t, "testdata/archlinux-2011.08.19-netinstall-i686.iso.torrent") - testFile(t, "testdata/continuum.torrent") - testFile(t, "testdata/23516C72685E8DB0C8F15553382A927F185C4F01.torrent") - testFile(t, "testdata/trackerless.torrent") -} - -// Ensure that the correct number of pieces are generated when hashing files. -func TestNumPieces(t *testing.T) { - for _, _case := range []struct { - PieceLength int64 - Files []FileInfo - NumPieces int - }{ - {256 * 1024, []FileInfo{{Length: 1024*1024 + -1}}, 4}, - {256 * 1024, []FileInfo{{Length: 1024 * 1024}}, 4}, - {256 * 1024, []FileInfo{{Length: 1024*1024 + 1}}, 5}, - {5, []FileInfo{{Length: 1}, {Length: 12}}, 3}, - {5, []FileInfo{{Length: 4}, {Length: 12}}, 4}, - } { - info := Info{ - Files: _case.Files, - PieceLength: _case.PieceLength, - } - err := info.GeneratePieces(func(fi FileInfo) (io.ReadCloser, error) { - return ioutil.NopCloser(missinggo.ZeroReader), nil - }) - assert.NoError(t, err) - assert.EqualValues(t, _case.NumPieces, info.NumPieces()) - } -} - -func touchFile(path string) (err error) { - f, err := os.Create(path) - if err != nil { - return - } - err = f.Close() - return -} - -func TestBuildFromFilePathOrder(t *testing.T) { - td, err := ioutil.TempDir("", "anacrolix") - require.NoError(t, err) - defer os.RemoveAll(td) - require.NoError(t, touchFile(filepath.Join(td, "b"))) - require.NoError(t, touchFile(filepath.Join(td, "a"))) - info := Info{ - PieceLength: 1, - } - require.NoError(t, info.BuildFromFilePath(td)) - assert.EqualValues(t, []FileInfo{{ - Path: []string{"a"}, - }, { - Path: []string{"b"}, - }}, info.Files) -} - -func testUnmarshal(t *testing.T, input string, expected *MetaInfo) { - var actual MetaInfo - err := bencode.Unmarshal([]byte(input), &actual) - if expected == nil { - assert.Error(t, err) - return - } - assert.NoError(t, err) - assert.EqualValues(t, *expected, actual) -} - -func TestUnmarshal(t *testing.T) { - testUnmarshal(t, `de`, &MetaInfo{}) - testUnmarshal(t, `d4:infoe`, &MetaInfo{}) - testUnmarshal(t, `d4:infoabce`, nil) - testUnmarshal(t, `d4:infodee`, &MetaInfo{InfoBytes: []byte("de")}) -} diff --git a/vendor/github.com/anacrolix/torrent/metainfo/nodes_test.go b/vendor/github.com/anacrolix/torrent/metainfo/nodes_test.go deleted file mode 100644 index 69bb9e670..000000000 --- a/vendor/github.com/anacrolix/torrent/metainfo/nodes_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package metainfo - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/anacrolix/torrent/bencode" -) - -func testFileNodesMatch(t *testing.T, file string, nodes []Node) { - mi, err := LoadFromFile(file) - require.NoError(t, err) - assert.EqualValues(t, nodes, mi.Nodes) -} - -func TestNodesListStrings(t *testing.T) { - testFileNodesMatch(t, "testdata/trackerless.torrent", []Node{ - "udp://tracker.openbittorrent.com:80", - "udp://tracker.openbittorrent.com:80", - }) -} - -func TestNodesListPairsBEP5(t *testing.T) { - testFileNodesMatch(t, "testdata/issue_65a.torrent", []Node{ - "185.34.3.132:5680", - "185.34.3.103:12340", - "94.209.253.165:47232", - "78.46.103.11:34319", - "195.154.162.70:55011", - "185.34.3.137:3732", - }) - testFileNodesMatch(t, "testdata/issue_65b.torrent", []Node{ - "95.211.203.130:6881", - "84.72.116.169:6889", - "204.83.98.77:7000", - "101.187.175.163:19665", - "37.187.118.32:6881", - "83.128.223.71:23865", - }) -} - -func testMarshalMetainfo(t *testing.T, expected string, mi *MetaInfo) { - b, err := bencode.Marshal(*mi) - assert.NoError(t, err) - assert.EqualValues(t, expected, string(b)) -} - -func TestMarshalMetainfoNodes(t *testing.T) { - testMarshalMetainfo(t, "d4:infodee", &MetaInfo{InfoBytes: []byte("de")}) - testMarshalMetainfo(t, "d4:infod2:hi5:theree5:nodesl12:1.2.3.4:555514:not a hostportee", &MetaInfo{ - Nodes: []Node{"1.2.3.4:5555", "not a hostport"}, - InfoBytes: []byte("d2:hi5:theree"), - }) -} - -func TestUnmarshalBadMetainfoNodes(t *testing.T) { - var mi MetaInfo - // Should barf on the integer in the nodes list. - err := bencode.Unmarshal([]byte("d5:nodesl1:ai42eee"), &mi) - require.Error(t, err) -} diff --git a/vendor/github.com/anacrolix/torrent/metainfo/testdata/23516C72685E8DB0C8F15553382A927F185C4F01.torrent b/vendor/github.com/anacrolix/torrent/metainfo/testdata/23516C72685E8DB0C8F15553382A927F185C4F01.torrent deleted file mode 100644 index 492908cab..000000000 Binary files a/vendor/github.com/anacrolix/torrent/metainfo/testdata/23516C72685E8DB0C8F15553382A927F185C4F01.torrent and /dev/null differ diff --git a/vendor/github.com/anacrolix/torrent/metainfo/testdata/archlinux-2011.08.19-netinstall-i686.iso.torrent b/vendor/github.com/anacrolix/torrent/metainfo/testdata/archlinux-2011.08.19-netinstall-i686.iso.torrent deleted file mode 100644 index 9ce7748aa..000000000 Binary files a/vendor/github.com/anacrolix/torrent/metainfo/testdata/archlinux-2011.08.19-netinstall-i686.iso.torrent and /dev/null differ diff --git a/vendor/github.com/anacrolix/torrent/metainfo/testdata/continuum.torrent b/vendor/github.com/anacrolix/torrent/metainfo/testdata/continuum.torrent deleted file mode 100644 index ac15b751a..000000000 Binary files a/vendor/github.com/anacrolix/torrent/metainfo/testdata/continuum.torrent and /dev/null differ diff --git a/vendor/github.com/anacrolix/torrent/metainfo/testdata/issue_65a.torrent b/vendor/github.com/anacrolix/torrent/metainfo/testdata/issue_65a.torrent deleted file mode 100644 index 8fc13ecd6..000000000 Binary files a/vendor/github.com/anacrolix/torrent/metainfo/testdata/issue_65a.torrent and /dev/null differ diff --git a/vendor/github.com/anacrolix/torrent/metainfo/testdata/issue_65b.torrent b/vendor/github.com/anacrolix/torrent/metainfo/testdata/issue_65b.torrent deleted file mode 100644 index 47b4619ed..000000000 Binary files a/vendor/github.com/anacrolix/torrent/metainfo/testdata/issue_65b.torrent and /dev/null differ diff --git a/vendor/github.com/anacrolix/torrent/metainfo/testdata/trackerless.torrent b/vendor/github.com/anacrolix/torrent/metainfo/testdata/trackerless.torrent deleted file mode 100644 index 65372766f..000000000 --- a/vendor/github.com/anacrolix/torrent/metainfo/testdata/trackerless.torrent +++ /dev/null @@ -1 +0,0 @@ -d7:comment19:This is just a test10:created by12:Johnny Bravo13:creation datei1430648794e8:encoding5:UTF-84:infod6:lengthi1128e4:name12:testfile.bin12:piece lengthi32768e6:pieces20:Õˆë =‘UŒäiÎ^æ °Eâ?ÇÒe5:nodesl35:udp://tracker.openbittorrent.com:8035:udp://tracker.openbittorrent.com:80ee diff --git a/vendor/github.com/anacrolix/torrent/metainfo/urllist.go b/vendor/github.com/anacrolix/torrent/metainfo/urllist.go new file mode 100644 index 000000000..8171f1982 --- /dev/null +++ b/vendor/github.com/anacrolix/torrent/metainfo/urllist.go @@ -0,0 +1,27 @@ +package metainfo + +import ( + "github.com/anacrolix/torrent/bencode" +) + +type UrlList []string + +var ( + _ bencode.Unmarshaler = (*UrlList)(nil) +) + +func (me *UrlList) UnmarshalBencode(b []byte) error { + if len(b) == 0 { + return nil + } + if b[0] == 'l' { + var l []string + err := bencode.Unmarshal(b, &l) + *me = l + return err + } + var s string + err := bencode.Unmarshal(b, &s) + *me = []string{s} + return err +} diff --git a/vendor/github.com/anacrolix/torrent/misc_test.go b/vendor/github.com/anacrolix/torrent/misc_test.go deleted file mode 100644 index 17ee31338..000000000 --- a/vendor/github.com/anacrolix/torrent/misc_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package torrent - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestTorrentOffsetRequest(t *testing.T) { - check := func(tl, ps, off int64, expected request, ok bool) { - req, _ok := torrentOffsetRequest(tl, ps, defaultChunkSize, off) - assert.Equal(t, _ok, ok) - assert.Equal(t, req, expected) - } - check(13, 5, 0, newRequest(0, 0, 5), true) - check(13, 5, 3, newRequest(0, 0, 5), true) - check(13, 5, 11, newRequest(2, 0, 3), true) - check(13, 5, 13, request{}, false) -} diff --git a/vendor/github.com/anacrolix/torrent/mse/mse.go b/vendor/github.com/anacrolix/torrent/mse/mse.go index fbc3aa8e8..e257175b9 100644 --- a/vendor/github.com/anacrolix/torrent/mse/mse.go +++ b/vendor/github.com/anacrolix/torrent/mse/mse.go @@ -13,6 +13,7 @@ import ( "fmt" "io" "io/ioutil" + "math" "math/big" "strconv" "sync" @@ -23,8 +24,9 @@ import ( const ( maxPadLen = 512 - cryptoMethodPlaintext = 1 - cryptoMethodRC4 = 2 + CryptoMethodPlaintext = 1 + CryptoMethodRC4 = 2 + AllSupportedCrypto = CryptoMethodPlaintext | CryptoMethodRC4 ) var ( @@ -82,46 +84,63 @@ func newEncrypt(initer bool, s []byte, skey []byte) (c *rc4.Cipher) { } type cipherReader struct { - c *rc4.Cipher - r io.Reader + c *rc4.Cipher + r io.Reader + mu sync.Mutex + be []byte } func (cr *cipherReader) Read(b []byte) (n int, err error) { - // inefficient to allocate here - be := make([]byte, len(b)) - n, err = cr.r.Read(be) + var be []byte + cr.mu.Lock() + if len(cr.be) >= len(b) { + be = cr.be + cr.be = nil + cr.mu.Unlock() + } else { + cr.mu.Unlock() + be = make([]byte, len(b)) + } + n, err = cr.r.Read(be[:len(b)]) cr.c.XORKeyStream(b[:n], be[:n]) + cr.mu.Lock() + if len(be) > len(cr.be) { + cr.be = be + } + cr.mu.Unlock() return } func newCipherReader(c *rc4.Cipher, r io.Reader) io.Reader { - return &cipherReader{c, r} + return &cipherReader{c: c, r: r} } type cipherWriter struct { c *rc4.Cipher w io.Writer + b []byte } func (cr *cipherWriter) Write(b []byte) (n int, err error) { - be := make([]byte, len(b)) - cr.c.XORKeyStream(be, b) - n, err = cr.w.Write(be) - if n != len(be) { + be := func() []byte { + if len(cr.b) < len(b) { + return make([]byte, len(b)) + } else { + ret := cr.b + cr.b = nil + return ret + } + }() + cr.c.XORKeyStream(be[:], b) + n, err = cr.w.Write(be[:len(b)]) + if n != len(b) { // The cipher will have advanced beyond the callers stream position. // We can't use the cipher anymore. cr.c = nil } - return -} - -func readY(r io.Reader) (y big.Int, err error) { - var b [96]byte - _, err = io.ReadFull(r, b[:]) - if err != nil { - return + if len(be) > len(cr.b) { + cr.b = be } - y.SetBytes(b[:]) return } @@ -192,6 +211,10 @@ type handshake struct { skeys SecretKeyIter // Skeys we'll accept if receiving. skey []byte // Skey we're initiating with. ia []byte // Initial payload. Only used by the initiator. + // Return the bit for the crypto method the receiver wants to use. + chooseMethod func(supported uint32) uint32 + // Sent to the receiver. + cryptoProvides uint32 writeMu sync.Mutex writes [][]byte @@ -348,7 +371,11 @@ func (h *handshake) initerSteps() (ret io.ReadWriter, err error) { h.postWrite(xor(hash(req2, h.skey), hash(req3, h.s[:]))) buf := &bytes.Buffer{} padLen := uint16(newPadLen()) - err = marshal(buf, vc[:], uint32(cryptoMethodRC4), padLen, zeroPad[:padLen], uint16(len(h.ia)), h.ia) + if len(h.ia) > math.MaxUint16 { + err = errors.New("initial payload too large") + return + } + err = marshal(buf, vc[:], h.cryptoProvides, padLen, zeroPad[:padLen], uint16(len(h.ia)), h.ia) if err != nil { return } @@ -371,21 +398,24 @@ func (h *handshake) initerSteps() (ret io.ReadWriter, err error) { } return } - r := &cipherReader{bC, h.conn} + r := newCipherReader(bC, h.conn) var method uint32 err = unmarshal(r, &method, &padLen) if err != nil { return } - if method != cryptoMethodRC4 { - err = fmt.Errorf("receiver chose unsupported method: %x", method) - return - } _, err = io.CopyN(ioutil.Discard, r, int64(padLen)) if err != nil { return } - ret = readWriter{r, &cipherWriter{e, h.conn}} + switch method & h.cryptoProvides { + case CryptoMethodRC4: + ret = readWriter{r, &cipherWriter{e, h.conn, nil}} + case CryptoMethodPlaintext: + ret = h.conn + default: + err = fmt.Errorf("receiver chose unsupported method: %x", method) + } return } @@ -419,20 +449,17 @@ func (h *handshake) receiverSteps() (ret io.ReadWriter, err error) { } r := newCipherReader(newEncrypt(true, h.s[:], h.skey), h.conn) var ( - vc [8]byte - method uint32 - padLen uint16 + vc [8]byte + provides uint32 + padLen uint16 ) - err = unmarshal(r, vc[:], &method, &padLen) + err = unmarshal(r, vc[:], &provides, &padLen) if err != nil { return } - cryptoProvidesCount.Add(strconv.FormatUint(uint64(method), 16), 1) - if method&cryptoMethodRC4 == 0 { - err = errors.New("no supported crypto methods were provided") - return - } + cryptoProvidesCount.Add(strconv.FormatUint(uint64(provides), 16), 1) + chosen := h.chooseMethod(provides) _, err = io.CopyN(ioutil.Discard, r, int64(padLen)) if err != nil { return @@ -444,9 +471,9 @@ func (h *handshake) receiverSteps() (ret io.ReadWriter, err error) { unmarshal(r, h.ia) } buf := &bytes.Buffer{} - w := cipherWriter{h.newEncrypt(false), buf} + w := cipherWriter{h.newEncrypt(false), buf, nil} padLen = uint16(newPadLen()) - err = marshal(&w, &vc, uint32(cryptoMethodRC4), padLen, zeroPad[:padLen]) + err = marshal(&w, &vc, uint32(chosen), padLen, zeroPad[:padLen]) if err != nil { return } @@ -454,7 +481,20 @@ func (h *handshake) receiverSteps() (ret io.ReadWriter, err error) { if err != nil { return } - ret = readWriter{io.MultiReader(bytes.NewReader(h.ia), r), &cipherWriter{w.c, h.conn}} + switch chosen { + case CryptoMethodRC4: + ret = readWriter{ + io.MultiReader(bytes.NewReader(h.ia), r), + &cipherWriter{w.c, h.conn, nil}, + } + case CryptoMethodPlaintext: + ret = readWriter{ + io.MultiReader(bytes.NewReader(h.ia), h.conn), + h.conn, + } + default: + err = errors.New("chosen crypto method is not supported") + } return } @@ -487,21 +527,23 @@ func (h *handshake) Do() (ret io.ReadWriter, err error) { return } -func InitiateHandshake(rw io.ReadWriter, skey []byte, initialPayload []byte) (ret io.ReadWriter, err error) { +func InitiateHandshake(rw io.ReadWriter, skey []byte, initialPayload []byte, cryptoProvides uint32) (ret io.ReadWriter, err error) { h := handshake{ - conn: rw, - initer: true, - skey: skey, - ia: initialPayload, + conn: rw, + initer: true, + skey: skey, + ia: initialPayload, + cryptoProvides: cryptoProvides, } return h.Do() } -func ReceiveHandshake(rw io.ReadWriter, skeys [][]byte) (ret io.ReadWriter, err error) { +func ReceiveHandshake(rw io.ReadWriter, skeys SecretKeyIter, selectCrypto func(uint32) uint32) (ret io.ReadWriter, err error) { h := handshake{ - conn: rw, - initer: false, - skeys: sliceIter(skeys), + conn: rw, + initer: false, + skeys: skeys, + chooseMethod: selectCrypto, } return h.Do() } @@ -520,13 +562,11 @@ func sliceIter(skeys [][]byte) SecretKeyIter { // returns false or exhausted. type SecretKeyIter func(callback func(skey []byte) (more bool)) -// Doesn't unpack the secret keys until it needs to, and through the passed -// function. -func ReceiveHandshakeLazy(rw io.ReadWriter, skeys SecretKeyIter) (ret io.ReadWriter, err error) { - h := handshake{ - conn: rw, - initer: false, - skeys: skeys, +func DefaultCryptoSelector(provided uint32) uint32 { + if provided&CryptoMethodPlaintext != 0 { + return CryptoMethodPlaintext } - return h.Do() + return CryptoMethodRC4 } + +type CryptoSelector func(uint32) uint32 diff --git a/vendor/github.com/anacrolix/torrent/mse/mse_test.go b/vendor/github.com/anacrolix/torrent/mse/mse_test.go deleted file mode 100644 index 6c2799542..000000000 --- a/vendor/github.com/anacrolix/torrent/mse/mse_test.go +++ /dev/null @@ -1,127 +0,0 @@ -package mse - -import ( - "bytes" - "crypto/rand" - "io" - "io/ioutil" - "net" - "sync" - "testing" - - "github.com/bradfitz/iter" - "github.com/stretchr/testify/require" -) - -func TestReadUntil(t *testing.T) { - test := func(data, until string, leftover int, expectedErr error) { - r := bytes.NewReader([]byte(data)) - err := readUntil(r, []byte(until)) - if err != expectedErr { - t.Fatal(err) - } - if r.Len() != leftover { - t.Fatal(r.Len()) - } - } - test("feakjfeafeafegbaabc00", "abc", 2, nil) - test("feakjfeafeafegbaadc00", "abc", 0, io.EOF) -} - -func TestSuffixMatchLen(t *testing.T) { - test := func(a, b string, expected int) { - actual := suffixMatchLen([]byte(a), []byte(b)) - if actual != expected { - t.Fatalf("expected %d, got %d for %q and %q", expected, actual, a, b) - } - } - test("hello", "world", 0) - test("hello", "lo", 2) - test("hello", "llo", 3) - test("hello", "hell", 0) - test("hello", "helloooo!", 5) - test("hello", "lol!", 2) - test("hello", "mondo", 0) - test("mongo", "webscale", 0) - test("sup", "person", 1) -} - -func handshakeTest(t testing.TB, ia []byte, aData, bData string) { - a, b := net.Pipe() - wg := sync.WaitGroup{} - wg.Add(2) - go func() { - defer wg.Done() - a, err := InitiateHandshake(a, []byte("yep"), ia) - if err != nil { - t.Fatal(err) - return - } - go a.Write([]byte(aData)) - - var msg [20]byte - n, _ := a.Read(msg[:]) - if n != len(bData) { - t.FailNow() - } - // t.Log(string(msg[:n])) - }() - go func() { - defer wg.Done() - b, err := ReceiveHandshake(b, [][]byte{[]byte("nope"), []byte("yep"), []byte("maybe")}) - if err != nil { - t.Fatal(err) - return - } - go b.Write([]byte(bData)) - // Need to be exact here, as there are several reads, and net.Pipe is - // most synchronous. - msg := make([]byte, len(ia)+len(aData)) - n, _ := io.ReadFull(b, msg[:]) - if n != len(msg) { - t.FailNow() - } - // t.Log(string(msg[:n])) - }() - wg.Wait() - a.Close() - b.Close() -} - -func allHandshakeTests(t testing.TB) { - handshakeTest(t, []byte("jump the gun, "), "hello world", "yo dawg") - handshakeTest(t, nil, "hello world", "yo dawg") - handshakeTest(t, []byte{}, "hello world", "yo dawg") -} - -func TestHandshake(t *testing.T) { - allHandshakeTests(t) - t.Logf("crypto provides encountered: %s", cryptoProvidesCount) -} - -func BenchmarkHandshake(b *testing.B) { - for range iter.N(b.N) { - allHandshakeTests(b) - } -} - -type trackReader struct { - r io.Reader - n int64 -} - -func (tr *trackReader) Read(b []byte) (n int, err error) { - n, err = tr.r.Read(b) - tr.n += int64(n) - return -} - -func TestReceiveRandomData(t *testing.T) { - tr := trackReader{rand.Reader, 0} - _, err := ReceiveHandshake(readWriter{&tr, ioutil.Discard}, nil) - // No skey matches - require.Error(t, err) - // Establishing S, and then reading the maximum padding for giving up on - // synchronizing. - require.EqualValues(t, 96+532, tr.n) -} diff --git a/vendor/github.com/anacrolix/torrent/peer_protocol/protocol.go b/vendor/github.com/anacrolix/torrent/peer_protocol/protocol.go index f1f392f9a..8c309bcbf 100644 --- a/vendor/github.com/anacrolix/torrent/peer_protocol/protocol.go +++ b/vendor/github.com/anacrolix/torrent/peer_protocol/protocol.go @@ -68,6 +68,14 @@ type Message struct { Port uint16 } +func (msg Message) MustMarshalBinary() []byte { + b, err := msg.MarshalBinary() + if err != nil { + panic(err) + } + return b +} + func (msg Message) MarshalBinary() (data []byte, err error) { buf := &bytes.Buffer{} if !msg.Keepalive { @@ -253,3 +261,12 @@ func marshalBitfield(bf []bool) (b []byte) { } return } + +func MakeCancelMessage(piece, offset, length Integer) Message { + return Message{ + Type: Cancel, + Index: piece, + Begin: offset, + Length: length, + } +} diff --git a/vendor/github.com/anacrolix/torrent/peer_protocol/protocol_test.go b/vendor/github.com/anacrolix/torrent/peer_protocol/protocol_test.go deleted file mode 100644 index 580d26b2e..000000000 --- a/vendor/github.com/anacrolix/torrent/peer_protocol/protocol_test.go +++ /dev/null @@ -1,154 +0,0 @@ -package peer_protocol - -import ( - "bufio" - "bytes" - "strings" - "testing" -) - -func TestBinaryReadSliceOfPointers(t *testing.T) { - var msg Message - r := bytes.NewBufferString("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\x00") - if r.Len() != 12 { - t.Fatalf("expected 12 bytes left, but there %d", r.Len()) - } - for _, data := range []*Integer{&msg.Index, &msg.Begin, &msg.Length} { - err := data.Read(r) - if err != nil { - t.Fatal(err) - } - } - if r.Len() != 0 { - t.FailNow() - } -} - -func TestConstants(t *testing.T) { - // check that iota works as expected in the const block - if NotInterested != 3 { - t.FailNow() - } -} - -func TestBitfieldEncode(t *testing.T) { - bf := make([]bool, 37) - bf[2] = true - bf[7] = true - bf[32] = true - s := string(marshalBitfield(bf)) - const expected = "\x21\x00\x00\x00\x80" - if s != expected { - t.Fatalf("got %#v, expected %#v", s, expected) - } -} - -func TestBitfieldUnmarshal(t *testing.T) { - bf := unmarshalBitfield([]byte("\x81\x06")) - expected := make([]bool, 16) - expected[0] = true - expected[7] = true - expected[13] = true - expected[14] = true - if len(bf) != len(expected) { - t.FailNow() - } - for i := range expected { - if bf[i] != expected[i] { - t.FailNow() - } - } -} - -func TestHaveEncode(t *testing.T) { - actualBytes, err := Message{ - Type: Have, - Index: 42, - }.MarshalBinary() - if err != nil { - t.Fatal(err) - } - actualString := string(actualBytes) - expected := "\x00\x00\x00\x05\x04\x00\x00\x00\x2a" - if actualString != expected { - t.Fatalf("expected %#v, got %#v", expected, actualString) - } -} - -func TestShortRead(t *testing.T) { - dec := Decoder{ - R: bufio.NewReader(bytes.NewBufferString("\x00\x00\x00\x02\x00!")), - MaxLength: 2, - } - msg := new(Message) - err := dec.Decode(msg) - if !strings.Contains(err.Error(), "1 bytes unused in message type 0") { - t.Fatal(err) - } -} - -func TestUnexpectedEOF(t *testing.T) { - msg := new(Message) - for _, stream := range []string{ - "\x00\x00\x00", // Header truncated. - "\x00\x00\x00\x01", // Expecting 1 more byte. - // Request with wrong length, and too short anyway. - "\x00\x00\x00\x06\x06\x00\x00\x00\x00\x00", - // Request truncated. - "\x00\x00\x00\x0b\x06\x00\x00\x00\x00\x00", - } { - dec := Decoder{ - R: bufio.NewReader(bytes.NewBufferString(stream)), - MaxLength: 42, - } - err := dec.Decode(msg) - if err == nil { - t.Fatalf("expected an error decoding %q", stream) - } - } -} - -func TestMarshalKeepalive(t *testing.T) { - b, err := (Message{ - Keepalive: true, - }).MarshalBinary() - if err != nil { - t.Fatalf("error marshalling keepalive: %s", err) - } - bs := string(b) - const expected = "\x00\x00\x00\x00" - if bs != expected { - t.Fatalf("marshalled keepalive is %q, expected %q", bs, expected) - } -} - -func TestMarshalPortMsg(t *testing.T) { - b, err := (Message{ - Type: Port, - Port: 0xaabb, - }).MarshalBinary() - if err != nil { - t.Fatal(err) - } - if string(b) != "\x00\x00\x00\x03\x09\xaa\xbb" { - t.FailNow() - } -} - -func TestUnmarshalPortMsg(t *testing.T) { - var m Message - d := Decoder{ - R: bufio.NewReader(bytes.NewBufferString("\x00\x00\x00\x03\x09\xaa\xbb")), - MaxLength: 8, - } - err := d.Decode(&m) - if err != nil { - t.Fatal(err) - } - if m.Type != Port { - t.FailNow() - } - if m.Port != 0xaabb { - t.FailNow() - } -} diff --git a/vendor/github.com/anacrolix/torrent/pex_test.go b/vendor/github.com/anacrolix/torrent/pex_test.go deleted file mode 100644 index f73425fce..000000000 --- a/vendor/github.com/anacrolix/torrent/pex_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package torrent - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/anacrolix/torrent/bencode" -) - -func TestUnmarshalPex(t *testing.T) { - var pem peerExchangeMessage - err := bencode.Unmarshal([]byte("d5:added12:\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0ce"), &pem) - require.NoError(t, err) - require.EqualValues(t, 2, len(pem.Added)) - require.EqualValues(t, 1286, pem.Added[0].Port) - require.EqualValues(t, 0x100*0xb+0xc, pem.Added[1].Port) -} diff --git a/vendor/github.com/anacrolix/torrent/piece.go b/vendor/github.com/anacrolix/torrent/piece.go index ec24b7db1..e09e00c8d 100644 --- a/vendor/github.com/anacrolix/torrent/piece.go +++ b/vendor/github.com/anacrolix/torrent/piece.go @@ -29,18 +29,21 @@ const ( PiecePriorityNow // A Reader is reading in this piece. ) -type piece struct { +type Piece struct { // The completed piece SHA1 hash, from the metainfo "pieces" field. - Hash metainfo.Hash + hash metainfo.Hash t *Torrent index int // Chunks we've written to since the last check. The chunk offset and // length can be determined by the request chunkSize in use. - DirtyChunks bitmap.Bitmap - Hashing bool - QueuedForHash bool - EverHashed bool - PublicPieceState PieceState + dirtyChunks bitmap.Bitmap + + hashing bool + queuedForHash bool + everHashed bool + numVerifies int64 + + publicPieceState PieceState priority piecePriority pendingWritesMutex sync.Mutex @@ -48,55 +51,55 @@ type piece struct { noPendingWrites sync.Cond } -func (p *piece) Info() metainfo.Piece { +func (p *Piece) Info() metainfo.Piece { return p.t.info.Piece(p.index) } -func (p *piece) Storage() storage.Piece { +func (p *Piece) Storage() storage.Piece { return p.t.storage.Piece(p.Info()) } -func (p *piece) pendingChunkIndex(chunkIndex int) bool { - return !p.DirtyChunks.Contains(chunkIndex) +func (p *Piece) pendingChunkIndex(chunkIndex int) bool { + return !p.dirtyChunks.Contains(chunkIndex) } -func (p *piece) pendingChunk(cs chunkSpec, chunkSize pp.Integer) bool { +func (p *Piece) pendingChunk(cs chunkSpec, chunkSize pp.Integer) bool { return p.pendingChunkIndex(chunkIndex(cs, chunkSize)) } -func (p *piece) hasDirtyChunks() bool { - return p.DirtyChunks.Len() != 0 +func (p *Piece) hasDirtyChunks() bool { + return p.dirtyChunks.Len() != 0 } -func (p *piece) numDirtyChunks() (ret int) { - return p.DirtyChunks.Len() +func (p *Piece) numDirtyChunks() (ret int) { + return p.dirtyChunks.Len() } -func (p *piece) unpendChunkIndex(i int) { - p.DirtyChunks.Add(i) +func (p *Piece) unpendChunkIndex(i int) { + p.dirtyChunks.Add(i) } -func (p *piece) pendChunkIndex(i int) { - p.DirtyChunks.Remove(i) +func (p *Piece) pendChunkIndex(i int) { + p.dirtyChunks.Remove(i) } -func (p *piece) numChunks() int { +func (p *Piece) numChunks() int { return p.t.pieceNumChunks(p.index) } -func (p *piece) undirtiedChunkIndices() (ret bitmap.Bitmap) { - ret = p.DirtyChunks.Copy() +func (p *Piece) undirtiedChunkIndices() (ret bitmap.Bitmap) { + ret = p.dirtyChunks.Copy() ret.FlipRange(0, p.numChunks()) return } -func (p *piece) incrementPendingWrites() { +func (p *Piece) incrementPendingWrites() { p.pendingWritesMutex.Lock() p.pendingWrites++ p.pendingWritesMutex.Unlock() } -func (p *piece) decrementPendingWrites() { +func (p *Piece) decrementPendingWrites() { p.pendingWritesMutex.Lock() if p.pendingWrites == 0 { panic("assertion") @@ -108,7 +111,7 @@ func (p *piece) decrementPendingWrites() { p.pendingWritesMutex.Unlock() } -func (p *piece) waitNoPendingWrites() { +func (p *Piece) waitNoPendingWrites() { p.pendingWritesMutex.Lock() for p.pendingWrites != 0 { p.noPendingWrites.Wait() @@ -116,20 +119,20 @@ func (p *piece) waitNoPendingWrites() { p.pendingWritesMutex.Unlock() } -func (p *piece) chunkIndexDirty(chunk int) bool { - return p.DirtyChunks.Contains(chunk) +func (p *Piece) chunkIndexDirty(chunk int) bool { + return p.dirtyChunks.Contains(chunk) } -func (p *piece) chunkIndexSpec(chunk int) chunkSpec { +func (p *Piece) chunkIndexSpec(chunk int) chunkSpec { return chunkIndexSpec(chunk, p.length(), p.chunkSize()) } -func (p *piece) numDirtyBytes() (ret pp.Integer) { - defer func() { - if ret > p.length() { - panic("too many dirty bytes") - } - }() +func (p *Piece) numDirtyBytes() (ret pp.Integer) { + // defer func() { + // if ret > p.length() { + // panic("too many dirty bytes") + // } + // }() numRegularDirtyChunks := p.numDirtyChunks() if p.chunkIndexDirty(p.numChunks() - 1) { numRegularDirtyChunks-- @@ -139,21 +142,34 @@ func (p *piece) numDirtyBytes() (ret pp.Integer) { return } -func (p *piece) length() pp.Integer { +func (p *Piece) length() pp.Integer { return p.t.pieceLength(p.index) } -func (p *piece) chunkSize() pp.Integer { +func (p *Piece) chunkSize() pp.Integer { return p.t.chunkSize } -func (p *piece) lastChunkIndex() int { +func (p *Piece) lastChunkIndex() int { return p.numChunks() - 1 } -func (p *piece) bytesLeft() (ret pp.Integer) { +func (p *Piece) bytesLeft() (ret pp.Integer) { if p.t.pieceComplete(p.index) { return 0 } return p.length() - p.numDirtyBytes() } + +func (p *Piece) VerifyData() { + p.t.cl.mu.Lock() + defer p.t.cl.mu.Unlock() + target := p.numVerifies + 1 + if p.hashing { + target++ + } + p.t.queuePieceCheck(p.index) + for p.numVerifies < target { + p.t.cl.event.Wait() + } +} diff --git a/vendor/github.com/anacrolix/torrent/protocol.go b/vendor/github.com/anacrolix/torrent/protocol.go new file mode 100644 index 000000000..3faeb6ecc --- /dev/null +++ b/vendor/github.com/anacrolix/torrent/protocol.go @@ -0,0 +1,9 @@ +package torrent + +import ( + pp "github.com/anacrolix/torrent/peer_protocol" +) + +func makeCancelMessage(r request) pp.Message { + return pp.MakeCancelMessage(r.Index, r.Begin, r.Length) +} diff --git a/vendor/github.com/anacrolix/torrent/ratelimitreader.go b/vendor/github.com/anacrolix/torrent/ratelimitreader.go index a8e3483b1..d7939a3d3 100644 --- a/vendor/github.com/anacrolix/torrent/ratelimitreader.go +++ b/vendor/github.com/anacrolix/torrent/ratelimitreader.go @@ -1,6 +1,7 @@ package torrent import ( + "fmt" "io" "time" @@ -14,12 +15,18 @@ type rateLimitedReader struct { } func (me rateLimitedReader) Read(b []byte) (n int, err error) { + // Wait until we can read at all. if err := me.l.WaitN(context.Background(), 1); err != nil { panic(err) } + // Limit the read to within the burst. + if me.l.Limit() != rate.Inf && len(b) > me.l.Burst() { + b = b[:me.l.Burst()] + } n, err = me.r.Read(b) + // Pay the piper. if !me.l.ReserveN(time.Now(), n-1).OK() { - panic(n - 1) + panic(fmt.Sprintf("burst exceeded?: %d", n-1)) } return } diff --git a/vendor/github.com/anacrolix/torrent/reader.go b/vendor/github.com/anacrolix/torrent/reader.go index b73b8bad4..5afab9aa9 100644 --- a/vendor/github.com/anacrolix/torrent/reader.go +++ b/vendor/github.com/anacrolix/torrent/reader.go @@ -44,6 +44,11 @@ func (r *Reader) SetResponsive() { r.responsive = true } +// Disable responsive mode. +func (r *Reader) SetNonResponsive() { + r.responsive = false +} + // Configure the number of bytes ahead of a read that should also be // prioritized in preparation for further reads. func (r *Reader) SetReadahead(readahead int64) { @@ -55,6 +60,11 @@ func (r *Reader) SetReadahead(readahead int64) { r.posChanged() } +// Return reader's current position. +func (r *Reader) CurrentPos() int64 { + return r.pos +} + func (r *Reader) readable(off int64) (ret bool) { if r.t.closed.IsSet() { return true @@ -91,10 +101,6 @@ func (r *Reader) available(off, max int64) (ret int64) { return } -func (r *Reader) tickleClient() { - r.t.readersChanged() -} - func (r *Reader) waitReadable(off int64) { // We may have been sent back here because we were told we could read but // it failed. @@ -113,10 +119,10 @@ func (r *Reader) piecesUncached() (ret pieceRange) { } func (r *Reader) Read(b []byte) (n int, err error) { - return r.ReadContext(b, context.Background()) + return r.ReadContext(context.Background(), b) } -func (r *Reader) ReadContext(b []byte, ctx context.Context) (n int, err error) { +func (r *Reader) ReadContext(ctx context.Context, b []byte) (n int, err error) { // This is set under the Client lock if the Context is canceled. var ctxErr error if ctx.Done() != nil { @@ -189,17 +195,17 @@ func (r *Reader) readOnceAt(b []byte, pos int64, ctxErr *error) (n int, err erro } } b1 := b[:avail] - pi := int(pos / r.t.Info().PieceLength) - ip := r.t.Info().Piece(pi) - po := pos % r.t.Info().PieceLength + pi := int(pos / r.t.info.PieceLength) + ip := r.t.info.Piece(pi) + po := pos % r.t.info.PieceLength missinggo.LimitLen(&b1, ip.Length()-po) n, err = r.t.readAt(b1, pos) if n != 0 { err = nil return } - log.Printf("error reading torrent %q piece %d offset %d, %d bytes: %s", r.t, pi, po, len(b1), err) r.t.cl.mu.Lock() + log.Printf("error reading torrent %q piece %d offset %d, %d bytes: %s", r.t, pi, po, len(b1), err) r.t.updateAllPieceCompletions() r.t.updateAllPiecePriorities() r.t.cl.mu.Unlock() diff --git a/vendor/github.com/anacrolix/torrent/reader_test.go b/vendor/github.com/anacrolix/torrent/reader_test.go deleted file mode 100644 index 6bde870a1..000000000 --- a/vendor/github.com/anacrolix/torrent/reader_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package torrent - -import ( - "testing" - "time" - - "github.com/stretchr/testify/require" - "golang.org/x/net/context" - - "github.com/anacrolix/torrent/internal/testutil" -) - -func TestReaderReadContext(t *testing.T) { - cl, err := NewClient(&TestingConfig) - require.NoError(t, err) - defer cl.Close() - tt, err := cl.AddTorrent(testutil.GreetingMetaInfo()) - require.NoError(t, err) - defer tt.Drop() - ctx, _ := context.WithDeadline(context.Background(), time.Now().Add(time.Millisecond)) - r := tt.NewReader() - defer r.Close() - _, err = r.ReadContext(make([]byte, 1), ctx) - require.EqualValues(t, context.DeadlineExceeded, err) -} diff --git a/vendor/github.com/anacrolix/torrent/storage/boltPieceCompletion.go b/vendor/github.com/anacrolix/torrent/storage/boltPieceCompletion.go index 1b5e18a19..52e38f6a6 100644 --- a/vendor/github.com/anacrolix/torrent/storage/boltPieceCompletion.go +++ b/vendor/github.com/anacrolix/torrent/storage/boltPieceCompletion.go @@ -2,6 +2,7 @@ package storage import ( "encoding/binary" + "os" "path/filepath" "time" @@ -18,7 +19,8 @@ type boltPieceCompletion struct { db *bolt.DB } -func newBoltPieceCompletion(dir string) (ret *boltPieceCompletion, err error) { +func NewBoltPieceCompletion(dir string) (ret PieceCompletion, err error) { + os.MkdirAll(dir, 0770) p := filepath.Join(dir, ".torrent.bolt.db") db, err := bolt.Open(p, 0660, &bolt.Options{ Timeout: time.Second, diff --git a/vendor/github.com/anacrolix/torrent/storage/boltpc_test.go b/vendor/github.com/anacrolix/torrent/storage/boltpc_test.go deleted file mode 100644 index e1be2579b..000000000 --- a/vendor/github.com/anacrolix/torrent/storage/boltpc_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package storage - -import ( - "io/ioutil" - "os" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/anacrolix/torrent/metainfo" -) - -func TestBoltPieceCompletion(t *testing.T) { - td, err := ioutil.TempDir("", "") - require.NoError(t, err) - defer os.RemoveAll(td) - - pc, err := newBoltPieceCompletion(td) - require.NoError(t, err) - defer pc.Close() - - pk := metainfo.PieceKey{} - - b, err := pc.Get(pk) - require.NoError(t, err) - assert.False(t, b) - - require.NoError(t, pc.Set(pk, false)) - - b, err = pc.Get(pk) - require.NoError(t, err) - assert.False(t, b) - - require.NoError(t, pc.Set(pk, true)) - - b, err = pc.Get(pk) - require.NoError(t, err) - assert.True(t, b) -} diff --git a/vendor/github.com/anacrolix/torrent/storage/completion.go b/vendor/github.com/anacrolix/torrent/storage/completion.go index 780435103..c464a0a7b 100644 --- a/vendor/github.com/anacrolix/torrent/storage/completion.go +++ b/vendor/github.com/anacrolix/torrent/storage/completion.go @@ -7,17 +7,17 @@ import ( ) // Implementations track the completion of pieces. It must be concurrent-safe. -type pieceCompletion interface { +type PieceCompletion interface { Get(metainfo.PieceKey) (bool, error) Set(metainfo.PieceKey, bool) error Close() error } -func pieceCompletionForDir(dir string) (ret pieceCompletion) { - ret, err := newBoltPieceCompletion(dir) +func pieceCompletionForDir(dir string) (ret PieceCompletion) { + ret, err := NewBoltPieceCompletion(dir) if err != nil { log.Printf("couldn't open piece completion db in %q: %s", dir, err) - ret = new(mapPieceCompletion) + ret = NewMapPieceCompletion() } return } diff --git a/vendor/github.com/anacrolix/torrent/storage/completion_piece_map.go b/vendor/github.com/anacrolix/torrent/storage/completion_piece_map.go index f4b4e2858..ebd98259e 100644 --- a/vendor/github.com/anacrolix/torrent/storage/completion_piece_map.go +++ b/vendor/github.com/anacrolix/torrent/storage/completion_piece_map.go @@ -11,7 +11,11 @@ type mapPieceCompletion struct { m map[metainfo.PieceKey]struct{} } -func (mapPieceCompletion) Close() error { return nil } +func NewMapPieceCompletion() PieceCompletion { + return &mapPieceCompletion{m: make(map[metainfo.PieceKey]struct{})} +} + +func (*mapPieceCompletion) Close() error { return nil } func (me *mapPieceCompletion) Get(pk metainfo.PieceKey) (bool, error) { me.mu.Lock() diff --git a/vendor/github.com/anacrolix/torrent/storage/file.go b/vendor/github.com/anacrolix/torrent/storage/file.go index b0a9ca103..e6645ee7f 100644 --- a/vendor/github.com/anacrolix/torrent/storage/file.go +++ b/vendor/github.com/anacrolix/torrent/storage/file.go @@ -15,7 +15,7 @@ import ( type fileClientImpl struct { baseDir string pathMaker func(baseDir string, info *metainfo.Info, infoHash metainfo.Hash) string - pc pieceCompletion + pc PieceCompletion } // The Default path maker just returns the current path @@ -29,7 +29,11 @@ func infoHashPathMaker(baseDir string, info *metainfo.Info, infoHash metainfo.Ha // All Torrent data stored in this baseDir func NewFile(baseDir string) ClientImpl { - return NewFileWithCustomPathMaker(baseDir, nil) + return NewFileWithCompletion(baseDir, pieceCompletionForDir(baseDir)) +} + +func NewFileWithCompletion(baseDir string, completion PieceCompletion) ClientImpl { + return newFileWithCustomPathMakerAndCompletion(baseDir, nil, completion) } // All Torrent data stored in subdirectorys by infohash @@ -39,13 +43,17 @@ func NewFileByInfoHash(baseDir string) ClientImpl { // Allows passing a function to determine the path for storing torrent data func NewFileWithCustomPathMaker(baseDir string, pathMaker func(baseDir string, info *metainfo.Info, infoHash metainfo.Hash) string) ClientImpl { + return newFileWithCustomPathMakerAndCompletion(baseDir, pathMaker, pieceCompletionForDir(baseDir)) +} + +func newFileWithCustomPathMakerAndCompletion(baseDir string, pathMaker func(baseDir string, info *metainfo.Info, infoHash metainfo.Hash) string, completion PieceCompletion) ClientImpl { if pathMaker == nil { pathMaker = defaultPathMaker } return &fileClientImpl{ baseDir: baseDir, pathMaker: pathMaker, - pc: pieceCompletionForDir(baseDir), + pc: completion, } } @@ -67,12 +75,11 @@ func (fs *fileClientImpl) OpenTorrent(info *metainfo.Info, infoHash metainfo.Has }, nil } -// File-based torrent storage, not yet bound to a Torrent. type fileTorrentImpl struct { dir string info *metainfo.Info infoHash metainfo.Hash - completion pieceCompletion + completion PieceCompletion } func (fts *fileTorrentImpl) Piece(p metainfo.Piece) PieceImpl { @@ -192,6 +199,7 @@ func (fst fileTorrentImplIO) WriteAt(p []byte, off int64) (n int, err error) { return } n1, err = f.WriteAt(p[:n1], off) + // TODO: On some systems, write errors can be delayed until the Close. f.Close() if err != nil { return diff --git a/vendor/github.com/anacrolix/torrent/storage/file_misc_test.go b/vendor/github.com/anacrolix/torrent/storage/file_misc_test.go deleted file mode 100644 index 8b453045c..000000000 --- a/vendor/github.com/anacrolix/torrent/storage/file_misc_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package storage - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/anacrolix/torrent/metainfo" -) - -func TestExtentCompleteRequiredLengths(t *testing.T) { - info := &metainfo.Info{ - Files: []metainfo.FileInfo{ - {Path: []string{"a"}, Length: 2}, - {Path: []string{"b"}, Length: 3}, - }, - } - assert.Empty(t, extentCompleteRequiredLengths(info, 0, 0)) - assert.EqualValues(t, []metainfo.FileInfo{ - {Path: []string{"a"}, Length: 1}, - }, extentCompleteRequiredLengths(info, 0, 1)) - assert.EqualValues(t, []metainfo.FileInfo{ - {Path: []string{"a"}, Length: 2}, - }, extentCompleteRequiredLengths(info, 0, 2)) - assert.EqualValues(t, []metainfo.FileInfo{ - {Path: []string{"a"}, Length: 2}, - {Path: []string{"b"}, Length: 1}, - }, extentCompleteRequiredLengths(info, 0, 3)) - assert.EqualValues(t, []metainfo.FileInfo{ - {Path: []string{"b"}, Length: 2}, - }, extentCompleteRequiredLengths(info, 2, 2)) - assert.EqualValues(t, []metainfo.FileInfo{ - {Path: []string{"b"}, Length: 3}, - }, extentCompleteRequiredLengths(info, 4, 1)) - assert.Len(t, extentCompleteRequiredLengths(info, 5, 0), 0) - assert.Panics(t, func() { extentCompleteRequiredLengths(info, 6, 1) }) -} diff --git a/vendor/github.com/anacrolix/torrent/storage/file_test.go b/vendor/github.com/anacrolix/torrent/storage/file_test.go deleted file mode 100644 index 5c63c94ce..000000000 --- a/vendor/github.com/anacrolix/torrent/storage/file_test.go +++ /dev/null @@ -1,38 +0,0 @@ -package storage - -import ( - "bytes" - "io" - "io/ioutil" - "os" - "path/filepath" - "testing" - - "github.com/anacrolix/missinggo" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/anacrolix/torrent/metainfo" -) - -func TestShortFile(t *testing.T) { - td, err := ioutil.TempDir("", "") - require.NoError(t, err) - defer os.RemoveAll(td) - s := NewFile(td) - info := &metainfo.Info{ - Name: "a", - Length: 2, - PieceLength: missinggo.MiB, - } - ts, err := s.OpenTorrent(info, metainfo.Hash{}) - assert.NoError(t, err) - f, err := os.Create(filepath.Join(td, "a")) - err = f.Truncate(1) - f.Close() - var buf bytes.Buffer - p := info.Piece(0) - n, err := io.Copy(&buf, io.NewSectionReader(ts.Piece(p), 0, p.Length())) - assert.EqualValues(t, 1, n) - assert.Equal(t, io.ErrUnexpectedEOF, err) -} diff --git a/vendor/github.com/anacrolix/torrent/storage/issue95_test.go b/vendor/github.com/anacrolix/torrent/storage/issue95_test.go deleted file mode 100644 index bb2c2fe9a..000000000 --- a/vendor/github.com/anacrolix/torrent/storage/issue95_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package storage - -import ( - "io/ioutil" - "os" - "testing" - - "github.com/anacrolix/missinggo/resource" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/anacrolix/torrent/metainfo" -) - -// Two different torrents opened from the same storage. Closing one should not -// break the piece completion on the other. -func testIssue95(t *testing.T, c ClientImpl) { - i1 := &metainfo.Info{ - Files: []metainfo.FileInfo{{Path: []string{"a"}}}, - Pieces: make([]byte, 20), - } - t1, err := c.OpenTorrent(i1, metainfo.HashBytes([]byte("a"))) - require.NoError(t, err) - i2 := &metainfo.Info{ - Files: []metainfo.FileInfo{{Path: []string{"a"}}}, - Pieces: make([]byte, 20), - } - t2, err := c.OpenTorrent(i2, metainfo.HashBytes([]byte("b"))) - require.NoError(t, err) - t2p := t2.Piece(i2.Piece(0)) - assert.NoError(t, t1.Close()) - assert.NotPanics(t, func() { t2p.GetIsComplete() }) -} - -func TestIssue95File(t *testing.T) { - td, err := ioutil.TempDir("", "") - require.NoError(t, err) - defer os.RemoveAll(td) - testIssue95(t, NewFile(td)) -} - -func TestIssue95MMap(t *testing.T) { - td, err := ioutil.TempDir("", "") - require.NoError(t, err) - defer os.RemoveAll(td) - testIssue95(t, NewMMap(td)) -} - -func TestIssue95ResourcePieces(t *testing.T) { - td, err := ioutil.TempDir("", "") - require.NoError(t, err) - defer os.RemoveAll(td) - testIssue95(t, NewResourcePieces(resource.OSFileProvider{})) -} diff --git a/vendor/github.com/anacrolix/torrent/storage/issue96_test.go b/vendor/github.com/anacrolix/torrent/storage/issue96_test.go deleted file mode 100644 index b7267ba4c..000000000 --- a/vendor/github.com/anacrolix/torrent/storage/issue96_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package storage - -import ( - "io/ioutil" - "os" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/anacrolix/torrent/metainfo" -) - -func testMarkedCompleteMissingOnRead(t *testing.T, csf func(string) ClientImpl) { - td, err := ioutil.TempDir("", "") - require.NoError(t, err) - defer os.RemoveAll(td) - cs := NewClient(csf(td)) - info := &metainfo.Info{ - PieceLength: 1, - Files: []metainfo.FileInfo{{Path: []string{"a"}, Length: 1}}, - } - ts, err := cs.OpenTorrent(info, metainfo.Hash{}) - require.NoError(t, err) - p := ts.Piece(info.Piece(0)) - require.NoError(t, p.MarkComplete()) - // require.False(t, p.GetIsComplete()) - n, err := p.ReadAt(make([]byte, 1), 0) - require.Error(t, err) - require.EqualValues(t, 0, n) - require.False(t, p.GetIsComplete()) -} - -func TestMarkedCompleteMissingOnReadFile(t *testing.T) { - testMarkedCompleteMissingOnRead(t, NewFile) -} - -func TestMarkedCompleteMissingOnReadFileBoltDB(t *testing.T) { - testMarkedCompleteMissingOnRead(t, NewBoltDB) -} diff --git a/vendor/github.com/anacrolix/torrent/storage/mmap.go b/vendor/github.com/anacrolix/torrent/storage/mmap.go index 8cc5a7d57..fec9d1174 100644 --- a/vendor/github.com/anacrolix/torrent/storage/mmap.go +++ b/vendor/github.com/anacrolix/torrent/storage/mmap.go @@ -15,21 +15,26 @@ import ( type mmapStorage struct { baseDir string - pc pieceCompletion + pc PieceCompletion } func NewMMap(baseDir string) ClientImpl { + return NewMMapWithCompletion(baseDir, pieceCompletionForDir(baseDir)) +} + +func NewMMapWithCompletion(baseDir string, completion PieceCompletion) ClientImpl { return &mmapStorage{ baseDir: baseDir, - pc: pieceCompletionForDir(baseDir), + pc: completion, } } func (s *mmapStorage) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (t TorrentImpl, err error) { span, err := mMapTorrent(info, s.baseDir) t = &mmapTorrentStorage{ - span: span, - pc: s.pc, + infoHash: infoHash, + span: span, + pc: s.pc, } return } @@ -39,14 +44,16 @@ func (s *mmapStorage) Close() error { } type mmapTorrentStorage struct { - span mmap_span.MMapSpan - pc pieceCompletion + infoHash metainfo.Hash + span mmap_span.MMapSpan + pc PieceCompletion } func (ts *mmapTorrentStorage) Piece(p metainfo.Piece) PieceImpl { return mmapStoragePiece{ pc: ts.pc, p: p, + ih: ts.infoHash, ReaderAt: io.NewSectionReader(ts.span, p.Offset(), p.Length()), WriterAt: missinggo.NewSectionWriter(ts.span, p.Offset(), p.Length()), } @@ -58,7 +65,7 @@ func (ts *mmapTorrentStorage) Close() error { } type mmapStoragePiece struct { - pc pieceCompletion + pc PieceCompletion p metainfo.Piece ih metainfo.Hash io.ReaderAt @@ -92,49 +99,58 @@ func mMapTorrent(md *metainfo.Info, location string) (mms mmap_span.MMapSpan, er }() for _, miFile := range md.UpvertedFiles() { fileName := filepath.Join(append([]string{location, md.Name}, miFile.Path...)...) - err = os.MkdirAll(filepath.Dir(fileName), 0777) + var mm mmap.MMap + mm, err = mmapFile(fileName, miFile.Length) if err != nil { - err = fmt.Errorf("error creating data directory %q: %s", filepath.Dir(fileName), err) + err = fmt.Errorf("file %q: %s", miFile.DisplayPath(md), err) return } - var file *os.File - file, err = os.OpenFile(fileName, os.O_CREATE|os.O_RDWR, 0666) - if err != nil { - return + if mm != nil { + mms.Append(mm) } - func() { - defer file.Close() - var fi os.FileInfo - fi, err = file.Stat() - if err != nil { - return - } - if fi.Size() < miFile.Length { - err = file.Truncate(miFile.Length) - if err != nil { - return - } - } - if miFile.Length == 0 { - // Can't mmap() regions with length 0. - return - } - var mMap mmap.MMap - mMap, err = mmap.MapRegion(file, - int(miFile.Length), // Probably not great on <64 bit systems. - mmap.RDWR, 0, 0) - if err != nil { - err = fmt.Errorf("error mapping file %q, length %d: %s", file.Name(), miFile.Length, err) - return - } - if int64(len(mMap)) != miFile.Length { - panic("mmap has wrong length") - } - mms.Append(mMap) - }() + } + return +} + +func mmapFile(name string, size int64) (ret mmap.MMap, err error) { + dir := filepath.Dir(name) + err = os.MkdirAll(dir, 0777) + if err != nil { + err = fmt.Errorf("making directory %q: %s", dir, err) + return + } + var file *os.File + file, err = os.OpenFile(name, os.O_CREATE|os.O_RDWR, 0666) + if err != nil { + return + } + defer file.Close() + var fi os.FileInfo + fi, err = file.Stat() + if err != nil { + return + } + if fi.Size() < size { + // I think this is necessary on HFS+. Maybe Linux will SIGBUS too if + // you overmap a file but I'm not sure. + err = file.Truncate(size) if err != nil { return } } + if size == 0 { + // Can't mmap() regions with length 0. + return + } + ret, err = mmap.MapRegion(file, + int(size), // Probably not great on <64 bit systems. + mmap.RDWR, 0, 0) + if err != nil { + err = fmt.Errorf("mapping file %q, length %d: %s", file.Name(), size, err) + return + } + if int64(len(ret)) != size { + panic("mmap has wrong length") + } return } diff --git a/vendor/github.com/anacrolix/torrent/storage/storage_test.go b/vendor/github.com/anacrolix/torrent/storage/storage_test.go deleted file mode 100644 index 8eee16086..000000000 --- a/vendor/github.com/anacrolix/torrent/storage/storage_test.go +++ /dev/null @@ -1,5 +0,0 @@ -package storage - -import ( - _ "github.com/anacrolix/envpprof" -) diff --git a/vendor/github.com/anacrolix/torrent/storage/wrappers.go b/vendor/github.com/anacrolix/torrent/storage/wrappers.go index 8e90f0f08..b4137e5be 100644 --- a/vendor/github.com/anacrolix/torrent/storage/wrappers.go +++ b/vendor/github.com/anacrolix/torrent/storage/wrappers.go @@ -11,7 +11,7 @@ import ( ) type Client struct { - ClientImpl + ci ClientImpl } func NewClient(cl ClientImpl) *Client { @@ -19,7 +19,7 @@ func NewClient(cl ClientImpl) *Client { } func (cl Client) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (*Torrent, error) { - t, err := cl.ClientImpl.OpenTorrent(info, infoHash) + t, err := cl.ci.OpenTorrent(info, infoHash) return &Torrent{t}, err } diff --git a/vendor/github.com/anacrolix/torrent/t.go b/vendor/github.com/anacrolix/torrent/t.go index ed810a5fd..cc69d8e3c 100644 --- a/vendor/github.com/anacrolix/torrent/t.go +++ b/vendor/github.com/anacrolix/torrent/t.go @@ -1,7 +1,6 @@ package torrent import ( - "fmt" "strings" "github.com/anacrolix/missinggo/pubsub" @@ -25,6 +24,8 @@ func (t *Torrent) GotInfo() <-chan struct{} { // Returns the metainfo info dictionary, or nil if it's not yet available. func (t *Torrent) Info() *metainfo.Info { + t.cl.mu.Lock() + defer t.cl.mu.Unlock() return t.info } @@ -61,6 +62,14 @@ func (t *Torrent) NumPieces() int { return t.numPieces() } +// Get missing bytes count for specific piece. +func (t *Torrent) PieceBytesMissing(piece int) int64 { + t.cl.mu.Lock() + defer t.cl.mu.Unlock() + + return int64(t.pieces[piece].bytesLeft()) +} + // Drop the torrent from the client, and close it. It's always safe to do // this. No data corruption can, or should occur to either the torrent's data, // or connected peers. @@ -154,9 +163,7 @@ func (t *Torrent) CancelPieces(begin, end int) { // Returns handles to the files in the torrent. This requires the metainfo is // available first. func (t *Torrent) Files() (ret []File) { - t.cl.mu.Lock() info := t.Info() - t.cl.mu.Unlock() if info == nil { return } @@ -192,7 +199,7 @@ func (t *Torrent) DownloadAll() { func (t *Torrent) String() string { s := t.name() if s == "" { - s = fmt.Sprintf("%x", t.infoHash) + s = t.infoHash.HexString() } return s } @@ -202,3 +209,9 @@ func (t *Torrent) AddTrackers(announceList [][]string) { defer t.cl.mu.Unlock() t.addTrackers(announceList) } + +func (t *Torrent) Piece(i int) *Piece { + t.cl.mu.Lock() + defer t.cl.mu.Unlock() + return &t.pieces[i] +} diff --git a/vendor/github.com/anacrolix/torrent/testdata/bootstrap.dat.torrent b/vendor/github.com/anacrolix/torrent/testdata/bootstrap.dat.torrent deleted file mode 100644 index e5cdeb7cc..000000000 Binary files a/vendor/github.com/anacrolix/torrent/testdata/bootstrap.dat.torrent and /dev/null differ diff --git a/vendor/github.com/anacrolix/torrent/torrent.go b/vendor/github.com/anacrolix/torrent/torrent.go index 4d36209c5..3374778b2 100644 --- a/vendor/github.com/anacrolix/torrent/torrent.go +++ b/vendor/github.com/anacrolix/torrent/torrent.go @@ -11,6 +11,7 @@ import ( "math/rand" "net" "os" + "strconv" "sync" "text/tabwriter" "time" @@ -43,9 +44,12 @@ type peersKey struct { type Torrent struct { cl *Client + networkingEnabled bool + requestStrategy int + closed missinggo.Event infoHash metainfo.Hash - pieces []piece + pieces []Piece // Values are the piece indices that changed. pieceStateChanges *pubsub.PubSub // The size of chunks to request from peers over the wire. This is @@ -65,12 +69,14 @@ type Torrent struct { // The info dict. nil if we don't have it (yet). info *metainfo.Info + // Active peer connections, running message stream loops. conns map[*connection]struct{} maxEstablishedConns int // Set of addrs to which we're attempting to connect. Connections are // half-open until all handshakes are completed. - halfOpen map[string]struct{} + halfOpen map[string]Peer + fastestConn *connection // Reserve of peers to connect to. A peer can be both here and in the // active connections if were told about the peer after connecting with @@ -120,6 +126,50 @@ func (t *Torrent) Closed() <-chan struct{} { return t.closed.LockedChan(&t.cl.mu) } +// KnownSwarm returns the known subset of the peers in the Torrent's swarm, including active, +// pending, and half-open peers. +func (t *Torrent) KnownSwarm() (ks []Peer) { + // Add pending peers to the list + for _, peer := range t.peers { + ks = append(ks, peer) + } + + // Add half-open peers to the list + for _, peer := range t.halfOpen { + ks = append(ks, peer) + } + + // Add active peers to the list + for conn := range t.conns { + host, portString, err := net.SplitHostPort(conn.remoteAddr().String()) + if err != nil { + panic(err) + } + + ip := net.ParseIP(host) + port, err := strconv.Atoi(portString) + if err != nil { + panic(err) + } + + ks = append(ks, Peer{ + Id: conn.PeerID, + IP: ip, + Port: port, + Source: conn.Discovery, + // > If the connection is encrypted, that's certainly enough to set SupportsEncryption. + // > But if we're not connected to them with an encrypted connection, I couldn't say + // > what's appropriate. We can carry forward the SupportsEncryption value as we + // > received it from trackers/DHT/PEX, or just use the encryption state for the + // > connection. It's probably easiest to do the latter for now. + // https://github.com/anacrolix/torrent/pull/188 + SupportsEncryption: conn.headerEncrypted, + }) + } + + return +} + func (t *Torrent) setChunkSize(size pp.Integer) { t.chunkSize = size t.chunkPool = &sync.Pool{ @@ -157,7 +207,7 @@ func (t *Torrent) addrActive(addr string) bool { return false } -func (t *Torrent) worstUnclosedConns() (ret []*connection) { +func (t *Torrent) unclosedConnsAsSlice() (ret []*connection) { ret = make([]*connection, 0, len(t.conns)) for c := range t.conns { if !c.closed.IsSet() { @@ -231,13 +281,13 @@ func infoPieceHashes(info *metainfo.Info) (ret []string) { func (t *Torrent) makePieces() { hashes := infoPieceHashes(t.info) - t.pieces = make([]piece, len(hashes)) + t.pieces = make([]Piece, len(hashes)) for i, hash := range hashes { piece := &t.pieces[i] piece.t = t piece.index = i piece.noPendingWrites.L = &piece.pendingWritesMutex - missinggo.CopyExact(piece.Hash[:], hash) + missinggo.CopyExact(piece.hash[:], hash) } } @@ -282,13 +332,13 @@ func (t *Torrent) setInfoBytes(b []byte) error { } for i := range t.pieces { t.updatePieceCompletion(i) - t.pieces[i].QueuedForHash = true + // t.pieces[i].QueuedForHash = true } - go func() { - for i := range t.pieces { - t.verifyPiece(i) - } - }() + // go func() { + // for i := range t.pieces { + // t.verifyPiece(i) + // } + // }() return nil } @@ -342,7 +392,7 @@ func (t *Torrent) pieceState(index int) (ret PieceState) { if t.pieceComplete(index) { ret.Complete = true } - if p.QueuedForHash || p.Hashing { + if p.queuedForHash || p.hashing { ret.Checking = true } if !ret.Complete && t.piecePartiallyDownloaded(index) { @@ -440,7 +490,7 @@ func (t *Torrent) writeStatus(w io.Writer) { return "?" } }()) - if t.Info() != nil { + if t.info != nil { fmt.Fprintf(w, "Num Pieces: %d\n", t.numPieces()) fmt.Fprint(w, "Piece States:") for _, psr := range t.pieceStateRuns() { @@ -508,9 +558,11 @@ func (t *Torrent) bytesMissingLocked() int64 { } func (t *Torrent) bytesLeft() (left int64) { - for i := 0; i < t.numPieces(); i++ { - left += int64(t.pieces[i].bytesLeft()) - } + bitmap.Flip(t.completedPieces, 0, t.numPieces()).IterTyped(func(piece int) bool { + p := t.pieces[piece] + left += int64(p.length() - p.numDirtyBytes()) + return true + }) return } @@ -553,6 +605,7 @@ func (t *Torrent) close() (err error) { for conn := range t.conns { conn.Close() } + t.cl.event.Broadcast() t.pieceStateChanges.Close() t.updateWantPeersEvent() return @@ -576,7 +629,7 @@ func (t *Torrent) writeChunk(piece int, begin int64, data []byte) (err error) { err = io.ErrShortWrite } if err == nil { - tr.Stop("write chunk") + tr.Mark("write chunk") } return } @@ -595,7 +648,7 @@ func (t *Torrent) pieceNumChunks(piece int) int { } func (t *Torrent) pendAllChunkSpecs(pieceIndex int) { - t.pieces[pieceIndex].DirtyChunks.Clear() + t.pieces[pieceIndex].dirtyChunks.Clear() } type Peer struct { @@ -607,17 +660,14 @@ type Peer struct { SupportsEncryption bool } -func (t *Torrent) pieceLength(piece int) (len_ pp.Integer) { - if piece < 0 || piece >= t.info.NumPieces() { - return - } +func (t *Torrent) pieceLength(piece int) pp.Integer { if piece == t.numPieces()-1 { - len_ = pp.Integer(t.length % t.info.PieceLength) - } - if len_ == 0 { - len_ = pp.Integer(t.info.PieceLength) + ret := pp.Integer(t.length % t.info.PieceLength) + if ret != 0 { + return ret + } } - return + return pp.Integer(t.info.PieceLength) } func (t *Torrent) hashPiece(piece int) (ret metainfo.Hash) { @@ -637,13 +687,6 @@ func (t *Torrent) hashPiece(piece int) (ret metainfo.Hash) { return } -func (t *Torrent) haveAllPieces() bool { - if !t.haveInfo() { - return false - } - return t.completedPieces.Len() == t.numPieces() -} - func (t *Torrent) haveAnyPieces() bool { for i := range t.pieces { if t.pieceComplete(i) { @@ -695,10 +738,10 @@ func (t *Torrent) wantPieceIndex(index int) bool { return false } p := &t.pieces[index] - if p.QueuedForHash { + if p.queuedForHash { return false } - if p.Hashing { + if p.hashing { return false } if t.pieceComplete(index) { @@ -712,16 +755,13 @@ func (t *Torrent) wantPieceIndex(index int) bool { }) } -func (t *Torrent) connHasWantedPieces(c *connection) bool { - return !c.pieceRequestOrder.IsEmpty() -} - // The worst connection is one that hasn't been sent, or sent anything useful // for the longest. A bad connection is one that usually sends us unwanted // pieces, or has been in worser half of the established connections for more // than a minute. func (t *Torrent) worstBadConn() *connection { - wcs := worseConnSlice{t.worstUnclosedConns()} + wcs := worseConnSlice{t.unclosedConnsAsSlice()} + heap.Init(&wcs) for wcs.Len() != 0 { c := heap.Pop(&wcs).(*connection) if c.UnwantedChunksReceived >= 6 && c.UnwantedChunksReceived > c.UsefulChunksReceived { @@ -745,8 +785,8 @@ type PieceStateChange struct { func (t *Torrent) publishPieceChange(piece int) { cur := t.pieceState(piece) p := &t.pieces[piece] - if cur != p.PublicPieceState { - p.PublicPieceState = cur + if cur != p.publicPieceState { + p.publicPieceState = cur t.pieceStateChanges.Publish(PieceStateChange{ piece, cur, @@ -762,7 +802,7 @@ func (t *Torrent) pieceNumPendingChunks(piece int) int { } func (t *Torrent) pieceAllDirty(piece int) bool { - return t.pieces[piece].DirtyChunks.Len() == t.pieceNumChunks(piece) + return t.pieces[piece].dirtyChunks.Len() == t.pieceNumChunks(piece) } func (t *Torrent) readersChanged() { @@ -806,7 +846,9 @@ func (t *Torrent) maybeNewConns() { func (t *Torrent) piecePriorityChanged(piece int) { for c := range t.conns { - c.updatePiecePriority(piece) + if c.updatePiecePriority(piece) { + c.updateRequests() + } } t.maybeNewConns() t.publishPieceChange(piece) @@ -907,7 +949,7 @@ func (t *Torrent) pendPiece(piece int) { t.updatePiecePriority(piece) } -func (t *Torrent) unpendPieces(unpend *bitmap.Bitmap) { +func (t *Torrent) unpendPieces(unpend bitmap.Bitmap) { t.pendingPieces.Sub(unpend) unpend.IterTyped(func(piece int) (again bool) { t.updatePiecePriority(piece) @@ -924,7 +966,7 @@ func (t *Torrent) pendPieceRange(begin, end int) { func (t *Torrent) unpendPieceRange(begin, end int) { var bm bitmap.Bitmap bm.AddRange(begin, end) - t.unpendPieces(&bm) + t.unpendPieces(bm) } func (t *Torrent) pendRequest(req request) { @@ -1244,13 +1286,15 @@ func (t *Torrent) dhtAnnouncer() { return } err := t.announceDHT(true) - if err == nil { + func() { cl.mu.Lock() - t.numDHTAnnounces++ - cl.mu.Unlock() - } else { - log.Printf("error announcing %q to DHT: %s", t, err) - } + defer cl.mu.Unlock() + if err == nil { + t.numDHTAnnounces++ + } else { + log.Printf("error announcing %q to DHT: %s", t, err) + } + }() select { case <-t.closed.LockedChan(&cl.mu): return @@ -1296,7 +1340,7 @@ func (t *Torrent) numTotalPeers() int { } // Returns true if the connection is added. -func (t *Torrent) addConnection(c *connection) bool { +func (t *Torrent) addConnection(c *connection, outgoing bool) bool { if t.cl.closed.IsSet() { return false } @@ -1307,7 +1351,19 @@ func (t *Torrent) addConnection(c *connection) bool { if c.PeerID == c0.PeerID { // Already connected to a client with that ID. duplicateClientConns.Add(1) - return false + lower := string(t.cl.peerID[:]) < string(c.PeerID[:]) + // Retain the connection from initiated from lower peer ID to + // higher. + if outgoing == lower { + // Close the other one. + c0.Close() + // Is it safe to delete from the map while we're iterating + // over it? + t.deleteConnection(c0) + } else { + // Abandon this one. + return false + } } } if len(t.conns) >= t.maxEstablishedConns { @@ -1337,6 +1393,9 @@ func (t *Torrent) addConnection(c *connection) bool { } func (t *Torrent) wantConns() bool { + if !t.networkingEnabled { + return false + } if t.closed.IsSet() { return false } @@ -1372,17 +1431,17 @@ func (t *Torrent) pieceHashed(piece int, correct bool) { } p := &t.pieces[piece] touchers := t.reapPieceTouchers(piece) - if p.EverHashed { + if p.everHashed { // Don't score the first time a piece is hashed, it could be an // initial check. if correct { pieceHashedCorrect.Add(1) } else { - log.Printf("%s: piece %d (%s) failed hash: %d connections contributed", t, piece, p.Hash, len(touchers)) + log.Printf("%s: piece %d (%s) failed hash: %d connections contributed", t, piece, p.hash, len(touchers)) pieceHashedNotCorrect.Add(1) } } - p.EverHashed = true + p.everHashed = true if correct { for _, c := range touchers { c.goodPiecesDirtied++ @@ -1413,19 +1472,18 @@ func (t *Torrent) pieceHashed(piece int, correct bool) { } } +func (t *Torrent) cancelRequestsForPiece(piece int) { + for cn := range t.conns { + cn.tickleWriter() + } +} + func (t *Torrent) onPieceCompleted(piece int) { t.pendingPieces.Remove(piece) t.pendAllChunkSpecs(piece) + t.cancelRequestsForPiece(piece) for conn := range t.conns { conn.Have(piece) - for r := range conn.Requests { - if int(r.Index) == piece { - conn.Cancel(r) - } - } - // Could check here if peer doesn't have piece, but due to caching - // some peers may have said they have a piece but they don't. - conn.upload() } } @@ -1459,21 +1517,22 @@ func (t *Torrent) verifyPiece(piece int) { cl.mu.Lock() defer cl.mu.Unlock() p := &t.pieces[piece] - for p.Hashing || t.storage == nil { + for p.hashing || t.storage == nil { cl.event.Wait() } - p.QueuedForHash = false + p.queuedForHash = false if t.closed.IsSet() || t.pieceComplete(piece) { t.updatePiecePriority(piece) return } - p.Hashing = true + p.hashing = true t.publishPieceChange(piece) cl.mu.Unlock() sum := t.hashPiece(piece) cl.mu.Lock() - p.Hashing = false - t.pieceHashed(piece, sum == p.Hash) + p.numVerifies++ + p.hashing = false + t.pieceHashed(piece, sum == p.hash) } // Return the connections that touched a piece, and clear the entry while @@ -1498,10 +1557,16 @@ func (t *Torrent) connsAsSlice() (ret []*connection) { // Currently doesn't really queue, but should in the future. func (t *Torrent) queuePieceCheck(pieceIndex int) { piece := &t.pieces[pieceIndex] - if piece.QueuedForHash { + if piece.queuedForHash { return } - piece.QueuedForHash = true + piece.queuedForHash = true t.publishPieceChange(pieceIndex) go t.verifyPiece(pieceIndex) } + +func (t *Torrent) VerifyData() { + for i := range iter.N(t.NumPieces()) { + t.Piece(i).VerifyData() + } +} diff --git a/vendor/github.com/anacrolix/torrent/torrent_test.go b/vendor/github.com/anacrolix/torrent/torrent_test.go deleted file mode 100644 index 5811b3595..000000000 --- a/vendor/github.com/anacrolix/torrent/torrent_test.go +++ /dev/null @@ -1,152 +0,0 @@ -package torrent - -import ( - "os" - "path/filepath" - "testing" - - "github.com/anacrolix/missinggo" - "github.com/bradfitz/iter" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/anacrolix/torrent/bencode" - "github.com/anacrolix/torrent/internal/testutil" - "github.com/anacrolix/torrent/metainfo" - "github.com/anacrolix/torrent/peer_protocol" - "github.com/anacrolix/torrent/storage" -) - -func r(i, b, l peer_protocol.Integer) request { - return request{i, chunkSpec{b, l}} -} - -// Check the given Request is correct for various torrent offsets. -func TestTorrentRequest(t *testing.T) { - const s = 472183431 // Length of torrent. - for _, _case := range []struct { - off int64 // An offset into the torrent. - req request // The expected Request. The zero value means !ok. - }{ - // Invalid offset. - {-1, request{}}, - {0, r(0, 0, 16384)}, - // One before the end of a piece. - {1<<18 - 1, r(0, 1<<18-16384, 16384)}, - // Offset beyond torrent length. - {472 * 1 << 20, request{}}, - // One before the end of the torrent. Complicates the chunk length. - {s - 1, r((s-1)/(1<<18), (s-1)%(1<<18)/(16384)*(16384), 12935)}, - {1, r(0, 0, 16384)}, - // One before end of chunk. - {16383, r(0, 0, 16384)}, - // Second chunk. - {16384, r(0, 16384, 16384)}, - } { - req, ok := torrentOffsetRequest(472183431, 1<<18, 16384, _case.off) - if (_case.req == request{}) == ok { - t.Fatalf("expected %v, got %v", _case.req, req) - } - if req != _case.req { - t.Fatalf("expected %v, got %v", _case.req, req) - } - } -} - -func TestAppendToCopySlice(t *testing.T) { - orig := []int{1, 2, 3} - dupe := append([]int{}, orig...) - dupe[0] = 4 - if orig[0] != 1 { - t.FailNow() - } -} - -func TestTorrentString(t *testing.T) { - tor := &Torrent{} - s := tor.InfoHash().HexString() - if s != "0000000000000000000000000000000000000000" { - t.FailNow() - } -} - -// This benchmark is from the observation that a lot of overlapping Readers on -// a large torrent with small pieces had a lot of overhead in recalculating -// piece priorities everytime a reader (possibly in another Torrent) changed. -func BenchmarkUpdatePiecePriorities(b *testing.B) { - cl := &Client{} - t := cl.newTorrent(metainfo.Hash{}, nil) - t.info = &metainfo.Info{ - Pieces: make([]byte, 20*13410), - PieceLength: 256 << 10, - } - t.makePieces() - assert.EqualValues(b, 13410, t.numPieces()) - for range iter.N(7) { - r := t.NewReader() - r.SetReadahead(32 << 20) - r.Seek(3500000, 0) - } - assert.Len(b, t.readers, 7) - t.pendPieceRange(0, t.numPieces()) - for i := 0; i < t.numPieces(); i += 3 { - t.completedPieces.Set(i, true) - } - for range iter.N(b.N) { - t.updateAllPiecePriorities() - } -} - -// Check that a torrent containing zero-length file(s) will start, and that -// they're created in the filesystem. The client storage is assumed to be -// file-based on the native filesystem based. -func testEmptyFilesAndZeroPieceLength(t *testing.T, cs storage.ClientImpl) { - cfg := TestingConfig - cfg.DefaultStorage = cs - cl, err := NewClient(&TestingConfig) - require.NoError(t, err) - defer cl.Close() - ib, err := bencode.Marshal(metainfo.Info{ - Name: "empty", - Length: 0, - PieceLength: 0, - }) - require.NoError(t, err) - fp := filepath.Join(TestingConfig.DataDir, "empty") - os.Remove(fp) - assert.False(t, missinggo.FilePathExists(fp)) - tt, err := cl.AddTorrent(&metainfo.MetaInfo{ - InfoBytes: ib, - }) - require.NoError(t, err) - defer tt.Drop() - tt.DownloadAll() - require.True(t, cl.WaitAll()) - assert.True(t, missinggo.FilePathExists(fp)) -} - -func TestEmptyFilesAndZeroPieceLengthWithFileStorage(t *testing.T) { - testEmptyFilesAndZeroPieceLength(t, storage.NewFile(TestingConfig.DataDir)) -} - -func TestEmptyFilesAndZeroPieceLengthWithMMapStorage(t *testing.T) { - testEmptyFilesAndZeroPieceLength(t, storage.NewMMap(TestingConfig.DataDir)) -} - -func TestPieceHashFailed(t *testing.T) { - mi := testutil.GreetingMetaInfo() - tt := Torrent{ - cl: new(Client), - infoHash: mi.HashInfoBytes(), - storageOpener: storage.NewClient(badStorage{}), - chunkSize: 2, - } - require.NoError(t, tt.setInfoBytes(mi.InfoBytes)) - tt.cl.mu.Lock() - tt.pieces[1].DirtyChunks.AddRange(0, 3) - require.True(t, tt.pieceAllDirty(1)) - tt.pieceHashed(1, false) - // Dirty chunks should be cleared so we can try again. - require.False(t, tt.pieceAllDirty(1)) - tt.cl.mu.Unlock() -} diff --git a/vendor/github.com/anacrolix/torrent/tracker/http_test.go b/vendor/github.com/anacrolix/torrent/tracker/http_test.go deleted file mode 100644 index e081f6391..000000000 --- a/vendor/github.com/anacrolix/torrent/tracker/http_test.go +++ /dev/null @@ -1,26 +0,0 @@ -package tracker - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/anacrolix/torrent/bencode" -) - -func TestUnmarshalHTTPResponsePeerDicts(t *testing.T) { - var hr httpResponse - require.NoError(t, bencode.Unmarshal([]byte("d5:peersl"+ - "d2:ip7:1.2.3.47:peer id20:thisisthe20bytepeeri4:porti9999ee"+ - "d7:peer id20:thisisthe20bytepeeri2:ip39:2001:0db8:85a3:0000:0000:8a2e:0370:73344:porti9998ee"+ - "ee"), &hr)) - ps, err := hr.UnmarshalPeers() - require.NoError(t, err) - require.Len(t, ps, 2) - assert.Equal(t, []byte("thisisthe20bytepeeri"), ps[0].ID) - assert.EqualValues(t, 9999, ps[0].Port) - assert.EqualValues(t, 9998, ps[1].Port) - assert.NotNil(t, ps[0].IP) - assert.NotNil(t, ps[1].IP) -} diff --git a/vendor/github.com/anacrolix/torrent/tracker/tracker_test.go b/vendor/github.com/anacrolix/torrent/tracker/tracker_test.go deleted file mode 100644 index d095af5a7..000000000 --- a/vendor/github.com/anacrolix/torrent/tracker/tracker_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package tracker - -import ( - "testing" -) - -func TestUnsupportedTrackerScheme(t *testing.T) { - t.Parallel() - _, err := Announce("lol://tracker.openbittorrent.com:80/announce", nil) - if err != ErrBadScheme { - t.Fatal(err) - } -} diff --git a/vendor/github.com/anacrolix/torrent/tracker/udp_test.go b/vendor/github.com/anacrolix/torrent/tracker/udp_test.go deleted file mode 100644 index 4bff2f85d..000000000 --- a/vendor/github.com/anacrolix/torrent/tracker/udp_test.go +++ /dev/null @@ -1,240 +0,0 @@ -package tracker - -import ( - "bytes" - "crypto/rand" - "encoding/binary" - "fmt" - "io" - "io/ioutil" - "net" - "net/url" - "sync" - "testing" - - _ "github.com/anacrolix/envpprof" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/anacrolix/torrent/util" -) - -// Ensure net.IPs are stored big-endian, to match the way they're read from -// the wire. -func TestNetIPv4Bytes(t *testing.T) { - ip := net.IP([]byte{127, 0, 0, 1}) - if ip.String() != "127.0.0.1" { - t.FailNow() - } - if string(ip) != "\x7f\x00\x00\x01" { - t.Fatal([]byte(ip)) - } -} - -func TestMarshalAnnounceResponse(t *testing.T) { - peers := util.CompactIPv4Peers{ - {[]byte{127, 0, 0, 1}, 2}, - {[]byte{255, 0, 0, 3}, 4}, - } - b, err := peers.MarshalBinary() - require.NoError(t, err) - require.EqualValues(t, - "\x7f\x00\x00\x01\x00\x02\xff\x00\x00\x03\x00\x04", - b) - require.EqualValues(t, 12, binary.Size(AnnounceResponseHeader{})) -} - -// Failure to write an entire packet to UDP is expected to given an error. -func TestLongWriteUDP(t *testing.T) { - t.Parallel() - l, err := net.ListenUDP("udp", nil) - defer l.Close() - if err != nil { - t.Fatal(err) - } - c, err := net.DialUDP("udp", nil, l.LocalAddr().(*net.UDPAddr)) - if err != nil { - t.Fatal(err) - } - defer c.Close() - for msgLen := 1; ; msgLen *= 2 { - n, err := c.Write(make([]byte, msgLen)) - if err != nil { - require.Contains(t, err.Error(), "message too long") - return - } - if n < msgLen { - t.FailNow() - } - } -} - -func TestShortBinaryRead(t *testing.T) { - var data ResponseHeader - err := binary.Read(bytes.NewBufferString("\x00\x00\x00\x01"), binary.BigEndian, &data) - if err != io.ErrUnexpectedEOF { - t.FailNow() - } -} - -func TestConvertInt16ToInt(t *testing.T) { - i := 50000 - if int(uint16(int16(i))) != 50000 { - t.FailNow() - } -} - -func TestAnnounceLocalhost(t *testing.T) { - t.Parallel() - srv := server{ - t: map[[20]byte]torrent{ - {0xa3, 0x56, 0x41, 0x43, 0x74, 0x23, 0xe6, 0x26, 0xd9, 0x38, 0x25, 0x4a, 0x6b, 0x80, 0x49, 0x10, 0xa6, 0x67, 0xa, 0xc1}: { - Seeders: 1, - Leechers: 2, - Peers: []util.CompactPeer{ - {[]byte{1, 2, 3, 4}, 5}, - {[]byte{6, 7, 8, 9}, 10}, - }, - }, - }, - } - var err error - srv.pc, err = net.ListenPacket("udp", ":0") - require.NoError(t, err) - defer srv.pc.Close() - go func() { - require.NoError(t, srv.serveOne()) - }() - req := AnnounceRequest{ - NumWant: -1, - Event: Started, - } - rand.Read(req.PeerId[:]) - copy(req.InfoHash[:], []uint8{0xa3, 0x56, 0x41, 0x43, 0x74, 0x23, 0xe6, 0x26, 0xd9, 0x38, 0x25, 0x4a, 0x6b, 0x80, 0x49, 0x10, 0xa6, 0x67, 0xa, 0xc1}) - go func() { - require.NoError(t, srv.serveOne()) - }() - ar, err := Announce(fmt.Sprintf("udp://%s/announce", srv.pc.LocalAddr().String()), &req) - require.NoError(t, err) - assert.EqualValues(t, 1, ar.Seeders) - assert.EqualValues(t, 2, len(ar.Peers)) -} - -func TestUDPTracker(t *testing.T) { - t.Parallel() - if testing.Short() { - t.SkipNow() - } - req := AnnounceRequest{ - NumWant: -1, - } - rand.Read(req.PeerId[:]) - copy(req.InfoHash[:], []uint8{0xa3, 0x56, 0x41, 0x43, 0x74, 0x23, 0xe6, 0x26, 0xd9, 0x38, 0x25, 0x4a, 0x6b, 0x80, 0x49, 0x10, 0xa6, 0x67, 0xa, 0xc1}) - ar, err := Announce("udp://tracker.openbittorrent.com:80/announce", &req) - // Skip any net errors as we don't control the server. - if _, ok := err.(net.Error); ok { - t.Skip(err) - } - require.NoError(t, err) - t.Log(ar) -} - -func TestAnnounceRandomInfoHashThirdParty(t *testing.T) { - t.Parallel() - if testing.Short() { - // This test involves contacting third party servers that may have - // unpreditable results. - t.SkipNow() - } - req := AnnounceRequest{ - Event: Stopped, - } - rand.Read(req.PeerId[:]) - rand.Read(req.InfoHash[:]) - wg := sync.WaitGroup{} - success := make(chan bool) - fail := make(chan struct{}) - for _, url := range []string{ - "udp://tracker.openbittorrent.com:80/announce", - "udp://tracker.publicbt.com:80", - "udp://tracker.istole.it:6969", - "udp://tracker.ccc.de:80", - "udp://tracker.open.demonii.com:1337", - "udp://open.demonii.com:1337", - "udp://exodus.desync.com:6969", - } { - wg.Add(1) - go func(url string) { - defer wg.Done() - resp, err := Announce(url, &req) - if err != nil { - t.Logf("error announcing to %s: %s", url, err) - return - } - if resp.Leechers != 0 || resp.Seeders != 0 || len(resp.Peers) != 0 { - // The info hash we generated was random in 2^160 space. If we - // get a hit, something is weird. - t.Fatal(resp) - } - t.Logf("announced to %s", url) - // TODO: Can probably get stuck here, but it's just a throwaway - // test. - success <- true - }(url) - } - go func() { - wg.Wait() - close(fail) - }() - select { - case <-fail: - // It doesn't matter if they all fail, the servers could just be down. - case <-success: - // Bail as quickly as we can. One success is enough. - } -} - -// Check that URLPath option is done correctly. -func TestURLPathOption(t *testing.T) { - conn, err := net.ListenUDP("udp", nil) - if err != nil { - panic(err) - } - defer conn.Close() - go func() { - _, err := Announce((&url.URL{ - Scheme: "udp", - Host: conn.LocalAddr().String(), - Path: "/announce", - }).String(), &AnnounceRequest{}) - if err != nil { - defer conn.Close() - } - require.NoError(t, err) - }() - var b [512]byte - _, addr, _ := conn.ReadFrom(b[:]) - r := bytes.NewReader(b[:]) - var h RequestHeader - read(r, &h) - w := &bytes.Buffer{} - write(w, ResponseHeader{ - TransactionId: h.TransactionId, - }) - write(w, ConnectionResponse{42}) - conn.WriteTo(w.Bytes(), addr) - n, _, _ := conn.ReadFrom(b[:]) - r = bytes.NewReader(b[:n]) - read(r, &h) - read(r, &AnnounceRequest{}) - all, _ := ioutil.ReadAll(r) - if string(all) != "\x02\x09/announce" { - t.FailNow() - } - w = &bytes.Buffer{} - write(w, ResponseHeader{ - TransactionId: h.TransactionId, - }) - write(w, AnnounceResponseHeader{}) - conn.WriteTo(w.Bytes(), addr) -} diff --git a/vendor/github.com/anacrolix/torrent/tracker_scraper.go b/vendor/github.com/anacrolix/torrent/tracker_scraper.go index cf8f99fe8..1ddbf9ae9 100644 --- a/vendor/github.com/anacrolix/torrent/tracker_scraper.go +++ b/vendor/github.com/anacrolix/torrent/tracker_scraper.go @@ -26,11 +26,10 @@ func (ts *trackerScraper) statusLine() string { fmt.Fprintf(&w, "%q\t%s\t%s", ts.url, func() string { - // return ts.lastAnnounce.Completed.Add(ts.lastAnnounce.Interval).Format("2006-01-02 15:04:05 -0700 MST") - na := ts.lastAnnounce.Completed.Add(ts.lastAnnounce.Interval).Sub(time.Now()) - na /= time.Second - na *= time.Second + na := time.Until(ts.lastAnnounce.Completed.Add(ts.lastAnnounce.Interval)) if na > 0 { + na /= time.Second + na *= time.Second return na.String() } else { return "anytime" diff --git a/vendor/github.com/anacrolix/torrent/util/dirwatch/dirwatch.go b/vendor/github.com/anacrolix/torrent/util/dirwatch/dirwatch.go deleted file mode 100644 index 4b71a2a60..000000000 --- a/vendor/github.com/anacrolix/torrent/util/dirwatch/dirwatch.go +++ /dev/null @@ -1,213 +0,0 @@ -// Package dirwatch provides filesystem-notification based tracking of torrent -// info files and magnet URIs in a directory. -package dirwatch - -import ( - "bufio" - "log" - "os" - "path/filepath" - "strings" - - "github.com/anacrolix/missinggo" - "github.com/go-fsnotify/fsnotify" - - "github.com/anacrolix/torrent/metainfo" -) - -type Change uint - -const ( - Added Change = iota - Removed -) - -type Event struct { - MagnetURI string - Change - TorrentFilePath string - InfoHash metainfo.Hash -} - -type entity struct { - metainfo.Hash - MagnetURI string - TorrentFilePath string -} - -type Instance struct { - w *fsnotify.Watcher - dirName string - Events chan Event - dirState map[metainfo.Hash]entity -} - -func (i *Instance) Close() { - i.w.Close() -} - -func (i *Instance) handleEvents() { - defer close(i.Events) - for e := range i.w.Events { - log.Printf("event: %s", e) - if e.Op == fsnotify.Write { - // TODO: Special treatment as an existing torrent may have changed. - } else { - i.refresh() - } - } -} - -func (i *Instance) handleErrors() { - for err := range i.w.Errors { - log.Printf("error in torrent directory watcher: %s", err) - } -} - -func torrentFileInfoHash(fileName string) (ih metainfo.Hash, ok bool) { - mi, _ := metainfo.LoadFromFile(fileName) - if mi == nil { - return - } - ih = mi.HashInfoBytes() - ok = true - return -} - -func scanDir(dirName string) (ee map[metainfo.Hash]entity) { - d, err := os.Open(dirName) - if err != nil { - log.Print(err) - return - } - defer d.Close() - names, err := d.Readdirnames(-1) - if err != nil { - log.Print(err) - return - } - ee = make(map[metainfo.Hash]entity, len(names)) - addEntity := func(e entity) { - e0, ok := ee[e.Hash] - if ok { - if e0.MagnetURI == "" || len(e.MagnetURI) < len(e0.MagnetURI) { - return - } - } - ee[e.Hash] = e - } - for _, n := range names { - fullName := filepath.Join(dirName, n) - switch filepath.Ext(n) { - case ".torrent": - ih, ok := torrentFileInfoHash(fullName) - if !ok { - break - } - e := entity{ - TorrentFilePath: fullName, - } - missinggo.CopyExact(&e.Hash, ih) - addEntity(e) - case ".magnet": - uris, err := magnetFileURIs(fullName) - if err != nil { - log.Print(err) - break - } - for _, uri := range uris { - m, err := metainfo.ParseMagnetURI(uri) - if err != nil { - log.Printf("error parsing %q in file %q: %s", uri, fullName, err) - continue - } - addEntity(entity{ - Hash: m.InfoHash, - MagnetURI: uri, - }) - } - } - } - return -} - -func magnetFileURIs(name string) (uris []string, err error) { - f, err := os.Open(name) - if err != nil { - return - } - defer f.Close() - scanner := bufio.NewScanner(f) - scanner.Split(bufio.ScanWords) - for scanner.Scan() { - // Allow magnet URIs to be "commented" out. - if strings.HasPrefix(scanner.Text(), "#") { - continue - } - uris = append(uris, scanner.Text()) - } - err = scanner.Err() - return -} - -func (i *Instance) torrentRemoved(ih metainfo.Hash) { - i.Events <- Event{ - InfoHash: ih, - Change: Removed, - } -} - -func (i *Instance) torrentAdded(e entity) { - i.Events <- Event{ - InfoHash: e.Hash, - Change: Added, - MagnetURI: e.MagnetURI, - TorrentFilePath: e.TorrentFilePath, - } -} - -func (i *Instance) refresh() { - _new := scanDir(i.dirName) - old := i.dirState - for ih := range old { - _, ok := _new[ih] - if !ok { - i.torrentRemoved(ih) - } - } - for ih, newE := range _new { - oldE, ok := old[ih] - if ok { - if newE == oldE { - continue - } - i.torrentRemoved(ih) - } - i.torrentAdded(newE) - } - i.dirState = _new -} - -func New(dirName string) (i *Instance, err error) { - w, err := fsnotify.NewWatcher() - if err != nil { - return - } - err = w.Add(dirName) - if err != nil { - w.Close() - return - } - i = &Instance{ - w: w, - dirName: dirName, - Events: make(chan Event), - dirState: make(map[metainfo.Hash]entity, 0), - } - go func() { - i.refresh() - go i.handleEvents() - go i.handleErrors() - }() - return -} diff --git a/vendor/github.com/anacrolix/torrent/util/dirwatch/dirwatch_test.go b/vendor/github.com/anacrolix/torrent/util/dirwatch/dirwatch_test.go deleted file mode 100644 index 40d68ff77..000000000 --- a/vendor/github.com/anacrolix/torrent/util/dirwatch/dirwatch_test.go +++ /dev/null @@ -1,21 +0,0 @@ -package dirwatch - -import ( - "io/ioutil" - "os" - "testing" -) - -func TestDirwatch(t *testing.T) { - tempDirName, err := ioutil.TempDir("", "") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(tempDirName) - t.Logf("tempdir: %q", tempDirName) - dw, err := New(tempDirName) - defer dw.Close() - if err != nil { - t.Fatal(err) - } -} diff --git a/vendor/github.com/anacrolix/torrent/utp.go b/vendor/github.com/anacrolix/torrent/utp.go new file mode 100644 index 000000000..1d395e806 --- /dev/null +++ b/vendor/github.com/anacrolix/torrent/utp.go @@ -0,0 +1,23 @@ +package torrent + +import ( + "context" + "net" + "time" +) + +// Abstracts the utp Socket, so the implementation can be selected from +// different packages. +type utpSocket interface { + Accept() (net.Conn, error) + Addr() net.Addr + Close() error + LocalAddr() net.Addr + ReadFrom([]byte) (int, net.Addr, error) + SetDeadline(time.Time) error + SetWriteDeadline(time.Time) error + SetReadDeadline(time.Time) error + WriteTo([]byte, net.Addr) (int, error) + DialContext(ctx context.Context, addr string) (net.Conn, error) + Dial(addr string) (net.Conn, error) +} diff --git a/vendor/github.com/anacrolix/torrent/utp_go.go b/vendor/github.com/anacrolix/torrent/utp_go.go new file mode 100644 index 000000000..849c17ba8 --- /dev/null +++ b/vendor/github.com/anacrolix/torrent/utp_go.go @@ -0,0 +1,16 @@ +// +build !cgo + +package torrent + +import ( + "github.com/anacrolix/utp" +) + +func NewUtpSocket(network, addr string) (utpSocket, error) { + s, err := utp.NewSocket(network, addr) + if s == nil { + return nil, err + } else { + return s, err + } +} diff --git a/vendor/github.com/anacrolix/torrent/utp_libutp.go b/vendor/github.com/anacrolix/torrent/utp_libutp.go new file mode 100644 index 000000000..73770123f --- /dev/null +++ b/vendor/github.com/anacrolix/torrent/utp_libutp.go @@ -0,0 +1,16 @@ +// +build cgo + +package torrent + +import ( + "github.com/anacrolix/go-libutp" +) + +func NewUtpSocket(network, addr string) (utpSocket, error) { + s, err := utp.NewSocket(network, addr) + if s == nil { + return nil, err + } else { + return s, err + } +} diff --git a/vendor/github.com/anacrolix/utp/cmd/ucat/ucat.go b/vendor/github.com/anacrolix/utp/cmd/ucat/ucat.go deleted file mode 100644 index f1ca10ed2..000000000 --- a/vendor/github.com/anacrolix/utp/cmd/ucat/ucat.go +++ /dev/null @@ -1,76 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "io" - "log" - "net" - "os" - "os/signal" - - "github.com/anacrolix/envpprof" - - "github.com/anacrolix/utp" -) - -func main() { - defer envpprof.Stop() - listen := flag.Bool("l", false, "listen") - port := flag.Int("p", 0, "port to listen on") - flag.Parse() - var ( - conn net.Conn - err error - ) - if *listen { - s, err := utp.NewSocket("udp", fmt.Sprintf(":%d", *port)) - if err != nil { - log.Fatal(err) - } - defer s.Close() - conn, err = s.Accept() - if err != nil { - log.Fatal(err) - } - } else { - conn, err = utp.Dial(net.JoinHostPort(flag.Arg(0), flag.Arg(1))) - if err != nil { - log.Fatal(err) - } - } - defer conn.Close() - go func() { - sig := make(chan os.Signal, 1) - signal.Notify(sig, os.Interrupt) - <-sig - conn.Close() - }() - writerDone := make(chan struct{}) - readerDone := make(chan struct{}) - go func() { - defer close(writerDone) - written, err := io.Copy(conn, os.Stdin) - if err != nil { - conn.Close() - log.Fatalf("error after writing %d bytes: %s", written, err) - } - log.Printf("wrote %d bytes", written) - conn.Close() - }() - go func() { - defer close(readerDone) - n, err := io.Copy(os.Stdout, conn) - if err != nil { - log.Fatal(err) - } - log.Printf("received %d bytes", n) - }() - // Technically we should wait until both reading and writing are done. But - // ucat-style binaries terminate abrubtly when read or write is completed, - // and no state remains to clean-up the peer neatly. - select { - case <-writerDone: - case <-readerDone: - } -} diff --git a/vendor/github.com/anacrolix/utp/header_test.go b/vendor/github.com/anacrolix/utp/header_test.go deleted file mode 100644 index 4b5c9c12a..000000000 --- a/vendor/github.com/anacrolix/utp/header_test.go +++ /dev/null @@ -1,22 +0,0 @@ -package utp - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestSelectiveAckBitmaskBytesLen(t *testing.T) { - for _, _case := range []struct { - BitIndex int - ExpectedLen int - }{ - {0, 4}, - {31, 4}, - {32, 8}, - } { - var selAck selectiveAckBitmask - selAck.SetBit(_case.BitIndex) - assert.EqualValues(t, _case.ExpectedLen, len(selAck.Bytes)) - } -} diff --git a/vendor/github.com/anacrolix/utp/socket_test.go b/vendor/github.com/anacrolix/utp/socket_test.go deleted file mode 100644 index 45c67116e..000000000 --- a/vendor/github.com/anacrolix/utp/socket_test.go +++ /dev/null @@ -1,171 +0,0 @@ -package utp - -import ( - "fmt" - "io" - "log" - "net" - "testing" - "time" - - "github.com/anacrolix/missinggo" - "github.com/anacrolix/missinggo/inproc" - "github.com/bradfitz/iter" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestAcceptOnDestroyedSocket(t *testing.T) { - pc, err := net.ListenPacket("udp", "localhost:0") - require.NoError(t, err) - s, err := NewSocketFromPacketConn(pc) - require.NoError(t, err) - go pc.Close() - _, err = s.Accept() - require.Error(t, err) - t.Log(err.Error()) -} - -func TestSocketDeadlines(t *testing.T) { - s, err := NewSocket("udp", "localhost:0") - require.NoError(t, err) - defer s.Close() - assert.NoError(t, s.SetReadDeadline(time.Now())) - _, _, err = s.ReadFrom(nil) - assert.Equal(t, errTimeout, err) - assert.NoError(t, s.SetWriteDeadline(time.Now())) - _, err = s.WriteTo(nil, nil) - assert.Equal(t, errTimeout, err) - assert.NoError(t, s.SetDeadline(time.Time{})) - assert.NoError(t, s.Close()) -} - -func TestSaturateSocketConnIDs(t *testing.T) { - s, err := NewSocket("inproc", "") - require.NoError(t, err) - defer s.Close() - var acceptedConns, dialedConns []net.Conn - for range iter.N(500) { - accepted := make(chan struct{}) - go func() { - c, err := s.Accept() - if err != nil { - t.Log(err) - return - } - acceptedConns = append(acceptedConns, c) - close(accepted) - }() - c, err := s.Dial(s.Addr().String()) - require.NoError(t, err) - dialedConns = append(dialedConns, c) - <-accepted - } - t.Logf("%d dialed conns, %d accepted", len(dialedConns), len(acceptedConns)) - for i := range iter.N(len(dialedConns)) { - data := []byte(fmt.Sprintf("%7d", i)) - dc := dialedConns[i] - n, err := dc.Write(data) - require.NoError(t, err) - require.EqualValues(t, 7, n) - require.NoError(t, dc.Close()) - var b [8]byte - ac := acceptedConns[i] - n, err = ac.Read(b[:]) - require.NoError(t, err) - require.EqualValues(t, 7, n) - require.EqualValues(t, data, b[:n]) - n, err = ac.Read(b[:]) - require.EqualValues(t, 0, n) - require.EqualValues(t, io.EOF, err) - ac.Close() - } -} - -func TestUTPRawConn(t *testing.T) { - l, err := NewSocket("inproc", "") - require.NoError(t, err) - defer l.Close() - go func() { - for { - _, err := l.Accept() - if err != nil { - break - } - } - }() - // Connect a UTP peer to see if the RawConn will still work. - utpPeer := func() net.Conn { - s, _ := NewSocket("inproc", "") - defer s.Close() - ret, err := s.Dial(fmt.Sprintf("localhost:%d", missinggo.AddrPort(l.Addr()))) - require.NoError(t, err) - return ret - }() - if err != nil { - t.Fatalf("error dialing utp listener: %s", err) - } - defer utpPeer.Close() - peer, err := inproc.ListenPacket("inproc", ":0") - if err != nil { - t.Fatal(err) - } - defer peer.Close() - - msgsReceived := 0 - const N = 500 // How many messages to send. - readerStopped := make(chan struct{}) - // The reader goroutine. - go func() { - defer close(readerStopped) - b := make([]byte, 500) - for i := 0; i < N; i++ { - n, _, err := l.ReadFrom(b) - if err != nil { - t.Fatalf("error reading from raw conn: %s", err) - } - msgsReceived++ - var d int - fmt.Sscan(string(b[:n]), &d) - if d != i { - log.Printf("got wrong number: expected %d, got %d", i, d) - } - } - }() - udpAddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("localhost:%d", missinggo.AddrPort(l.Addr()))) - if err != nil { - t.Fatal(err) - } - for i := 0; i < N; i++ { - _, err := peer.WriteTo([]byte(fmt.Sprintf("%d", i)), udpAddr) - if err != nil { - t.Fatal(err) - } - time.Sleep(100 * time.Microsecond) - } - select { - case <-readerStopped: - case <-time.After(time.Second): - t.Fatal("reader timed out") - } - if msgsReceived != N { - t.Fatalf("messages received: %d", msgsReceived) - } -} - -func TestAcceptGone(t *testing.T) { - s, err := NewSocket("udp", "localhost:0") - require.NoError(t, err) - defer s.Close() - _, err = DialTimeout(s.Addr().String(), time.Millisecond) - require.Error(t, err) - // Will succeed because we don't signal that we give up dialing, or check - // that the handshake is completed before returning the new Conn. - c, err := s.Accept() - require.NoError(t, err) - defer c.Close() - err = c.SetReadDeadline(time.Now().Add(time.Millisecond)) - require.NoError(t, err) - _, err = c.Read(nil) - require.EqualError(t, err, "i/o timeout") -} diff --git a/vendor/github.com/anacrolix/utp/syncthing_test.go b/vendor/github.com/anacrolix/utp/syncthing_test.go deleted file mode 100644 index 4f520b160..000000000 --- a/vendor/github.com/anacrolix/utp/syncthing_test.go +++ /dev/null @@ -1,139 +0,0 @@ -package utp - -import ( - "io" - "net" - "sync" - "testing" - - "github.com/stretchr/testify/require" -) - -func getTCPConnectionPair() (net.Conn, net.Conn, error) { - lst, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - return nil, nil, err - } - - var conn0 net.Conn - var err0 error - done := make(chan struct{}) - go func() { - conn0, err0 = lst.Accept() - close(done) - }() - - conn1, err := net.Dial("tcp", lst.Addr().String()) - if err != nil { - return nil, nil, err - } - - <-done - if err0 != nil { - return nil, nil, err0 - } - return conn0, conn1, nil -} - -func getUTPConnectionPair() (net.Conn, net.Conn, error) { - lst, err := NewSocket("udp", "127.0.0.1:0") - if err != nil { - return nil, nil, err - } - defer lst.Close() - - var conn0 net.Conn - var err0 error - done := make(chan struct{}) - go func() { - conn0, err0 = lst.Accept() - close(done) - }() - - conn1, err := Dial(lst.Addr().String()) - if err != nil { - return nil, nil, err - } - - <-done - if err0 != nil { - return nil, nil, err0 - } - - return conn0, conn1, nil -} - -func requireWriteAll(t testing.TB, b []byte, w io.Writer) { - n, err := w.Write(b) - require.NoError(t, err) - require.EqualValues(t, len(b), n) -} - -func requireReadExactly(t testing.TB, b []byte, r io.Reader) { - n, err := io.ReadFull(r, b) - require.NoError(t, err) - require.EqualValues(t, len(b), n) -} - -func benchConnPair(b *testing.B, c0, c1 net.Conn) { - b.ReportAllocs() - request := make([]byte, 52) - response := make([]byte, (128<<10)+8) - b.SetBytes(int64(len(request) + len(response))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - c, s := func() (net.Conn, net.Conn) { - if i%2 == 0 { - return c0, c1 - } else { - return c1, c0 - } - }() - var wg sync.WaitGroup - wg.Add(2) - go func() { - defer wg.Done() - requireWriteAll(b, request, c) - requireReadExactly(b, response[:8], c) - requireReadExactly(b, response[8:], c) - }() - go func() { - defer wg.Done() - requireReadExactly(b, request[:8], s) - requireReadExactly(b, request[8:], s) - requireWriteAll(b, response, s) - }() - wg.Wait() - } -} - -func BenchmarkSyncthingTCP(b *testing.B) { - conn0, conn1, err := getTCPConnectionPair() - if err != nil { - b.Fatal(err) - } - - defer conn0.Close() - defer conn1.Close() - - benchConnPair(b, conn0, conn1) -} - -func BenchmarkSyncthingUDPUTP(b *testing.B) { - conn0, conn1, err := getUTPConnectionPair() - if err != nil { - b.Fatal(err) - } - - defer conn0.Close() - defer conn1.Close() - - benchConnPair(b, conn0, conn1) -} - -func BenchmarkSyncthingInprocUTP(b *testing.B) { - c0, c1 := connPair() - defer c0.Close() - defer c1.Close() - benchConnPair(b, c0, c1) -} diff --git a/vendor/github.com/anacrolix/utp/utp_test.go b/vendor/github.com/anacrolix/utp/utp_test.go deleted file mode 100644 index 8fa2441b3..000000000 --- a/vendor/github.com/anacrolix/utp/utp_test.go +++ /dev/null @@ -1,723 +0,0 @@ -package utp - -import ( - "bytes" - "crypto/rand" - "fmt" - "io" - "io/ioutil" - "log" - "net" - "net/http" - "os" - "sync" - "testing" - "time" - - _ "github.com/anacrolix/envpprof" - "github.com/anacrolix/missinggo" - "github.com/bradfitz/iter" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "golang.org/x/net/nettest" -) - -func init() { - log.SetFlags(log.Flags() | log.Lshortfile) -} - -func setDefaultTestingDurations() { - writeTimeout = 1 * time.Second - initialLatency = 10 * time.Millisecond - packetReadTimeout = 2 * time.Second -} - -func TestUTPPingPong(t *testing.T) { - defer missinggo.GoroutineLeakCheck(t)() - s, err := NewSocket("udp", "localhost:0") - require.NoError(t, err) - defer s.Close() - pingerClosed := make(chan struct{}) - go func() { - defer close(pingerClosed) - b, err := Dial(s.Addr().String()) - require.NoError(t, err) - defer b.Close() - n, err := b.Write([]byte("ping")) - require.NoError(t, err) - require.EqualValues(t, 4, n) - buf := make([]byte, 4) - b.Read(buf) - require.EqualValues(t, "pong", buf) - }() - a, err := s.Accept() - require.NoError(t, err) - defer a.Close() - buf := make([]byte, 42) - n, err := a.Read(buf) - require.NoError(t, err) - require.EqualValues(t, "ping", buf[:n]) - n, err = a.Write([]byte("pong")) - require.NoError(t, err) - require.Equal(t, 4, n) - <-pingerClosed -} - -func TestDialTimeout(t *testing.T) { - defer missinggo.GoroutineLeakCheck(t)() - s, _ := NewSocket("udp", "localhost:0") - defer s.Close() - conn, err := DialTimeout(s.Addr().String(), 10*time.Millisecond) - if err == nil { - conn.Close() - t.Fatal("expected timeout") - } - t.Log(err) -} - -func TestListen(t *testing.T) { - defer missinggo.GoroutineLeakCheck(t)() - ln, err := NewSocket("udp", "localhost:0") - if err != nil { - t.Fatal(err) - } - ln.Close() -} - -func TestMinMaxHeaderType(t *testing.T) { - require.Equal(t, stSyn, stMax) -} - -func TestConnReadDeadline(t *testing.T) { - t.Parallel() - ls, _ := NewSocket("udp", "localhost:0") - defer ls.Close() - ds, _ := NewSocket("udp", "localhost:0") - defer ds.Close() - dcReadErr := make(chan error) - go func() { - c, _ := ds.Dial(ls.Addr().String()) - defer c.Close() - _, err := c.Read(nil) - dcReadErr <- err - }() - c, _ := ls.Accept() - dl := time.Now().Add(time.Millisecond) - c.SetReadDeadline(dl) - _, err := c.Read(nil) - require.Equal(t, errTimeout, err) - // The deadline has passed. - if time.Now().Before(dl) { - t.Fatal("deadline hasn't passed") - } - // Returns timeout on subsequent read. - _, err = c.Read(nil) - require.Equal(t, errTimeout, err) - // Disable the deadline. - c.SetReadDeadline(time.Time{}) - readReturned := make(chan struct{}) - go func() { - c.Read(nil) - close(readReturned) - }() - select { - case <-readReturned: - // Read returned but shouldn't have. - t.Fatal("read returned") - case <-time.After(time.Millisecond): - } - c.Close() - if err := <-dcReadErr; err != io.EOF { - t.Fatalf("dial conn read returned %s", err) - } - select { - case <-readReturned: - case <-time.After(time.Millisecond): - t.Fatal("read should return after Conn is closed") - } -} - -func connectSelfLots(n int, t testing.TB) { - defer missinggo.GoroutineLeakCheck(t)() - s, err := NewSocket("udp", "localhost:0") - require.NoError(t, err) - go func() { - for range iter.N(n) { - c, err := s.Accept() - if err != nil { - log.Fatal(err) - } - defer c.Close() - } - }() - dialErr := make(chan error) - connCh := make(chan net.Conn) - dialSema := make(chan struct{}, backlog) - for range iter.N(n) { - go func() { - dialSema <- struct{}{} - c, err := s.Dial(s.Addr().String()) - <-dialSema - if err != nil { - dialErr <- err - return - } - connCh <- c - }() - } - conns := make([]net.Conn, 0, n) - for range iter.N(n) { - select { - case c := <-connCh: - conns = append(conns, c) - case err := <-dialErr: - t.Fatal(err) - } - } - for _, c := range conns { - if c != nil { - c.Close() - } - } - sleepWhile(&mu, func() bool { return len(s.conns) != 0 }) - s.Close() -} - -// Connect to ourself heaps. -func TestConnectSelf(t *testing.T) { - // A rough guess says that at worst, I can only have 0x10000/3 connections - // to the same socket, due to fragmentation in the assigned connection - // IDs. - connectSelfLots(0x100, t) -} - -func BenchmarkConnectSelf(b *testing.B) { - for range iter.N(b.N) { - connectSelfLots(2, b) - } -} - -func BenchmarkNewCloseSocket(b *testing.B) { - for range iter.N(b.N) { - s, err := NewSocket("udp", "localhost:0") - if err != nil { - b.Fatal(err) - } - err = s.Close() - if err != nil { - b.Fatal(err) - } - } -} - -func TestRejectDialBacklogFilled(t *testing.T) { - s, err := NewSocket("udp", "localhost:0") - if err != nil { - t.Fatal(err) - } - errChan := make(chan error) - dial := func() { - _, err := s.Dial(s.Addr().String()) - require.Error(t, err) - errChan <- err - } - // Fill the backlog. - for range iter.N(backlog) { - go dial() - } - sleepWhile(&mu, func() bool { return len(s.backlog) < backlog }) - select { - case err := <-errChan: - t.Fatalf("got premature error: %s", err) - default: - } - // One more connection should cause a dial attempt to get reset. - go dial() - err = <-errChan - assert.EqualError(t, err, "peer reset") - s.Close() - for range iter.N(backlog) { - <-errChan - } -} - -// Make sure that we can reset AfterFunc timers, so we don't have to create -// brand new ones everytime they fire. Specifically for the Conn resend timer. -func TestResetAfterFuncTimer(t *testing.T) { - t.Parallel() - fired := make(chan struct{}) - timer := time.AfterFunc(time.Millisecond, func() { - fired <- struct{}{} - }) - <-fired - if timer.Reset(time.Millisecond) { - // The timer should have expired - t.FailNow() - } - <-fired -} - -func connPairSocket(s *Socket) (initer, accepted net.Conn) { - var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() - var err error - initer, err = s.Dial(s.Addr().String()) - if err != nil { - panic(err) - } - }() - accepted, err := s.Accept() - if err != nil { - panic(err) - } - wg.Wait() - return -} - -func connPair() (initer, accepted net.Conn) { - s, err := NewSocket("inproc", ":0") - if err != nil { - panic(err) - } - defer s.Close() - return connPairSocket(s) -} - -// Check that peer sending FIN doesn't cause unread data to be dropped in a -// receiver. -func TestReadFinishedConn(t *testing.T) { - a, b := connPair() - defer a.Close() - defer b.Close() - mu.Lock() - originalAPDC := artificialPacketDropChance - artificialPacketDropChance = 1 - mu.Unlock() - n, err := a.Write([]byte("hello")) - require.Equal(t, 5, n) - require.NoError(t, err) - n, err = a.Write([]byte("world")) - require.Equal(t, 5, n) - require.NoError(t, err) - mu.Lock() - artificialPacketDropChance = originalAPDC - mu.Unlock() - a.Close() - all, err := ioutil.ReadAll(b) - require.NoError(t, err) - require.EqualValues(t, "helloworld", all) -} - -func TestCloseDetachesQuickly(t *testing.T) { - t.Parallel() - s, _ := NewSocket("udp", "localhost:0") - defer s.Close() - go func() { - a, _ := s.Dial(s.Addr().String()) - a.Close() - }() - b, _ := s.Accept() - b.Close() - sleepWhile(&mu, func() bool { return len(s.conns) != 0 }) -} - -// Check that closing, and resulting detach of a Conn doesn't close the parent -// Socket. We Accept, then close the connection and ensure it's detached. Then -// Accept again to check the Socket is still functional and unclosed. -func TestConnCloseUnclosedSocket(t *testing.T) { - t.Parallel() - s, err := NewSocket("udp", "localhost:0") - require.NoError(t, err) - defer func() { - assert.NoError(t, s.Close()) - }() - // Prevents the dialing goroutine from closing its end of the Conn before - // we can check that it has been registered in the listener. - dialerSync := make(chan struct{}) - - go func() { - for range iter.N(2) { - c, err := Dial(s.Addr().String()) - require.NoError(t, err) - <-dialerSync - err = c.Close() - require.NoError(t, err) - } - }() - for range iter.N(2) { - a, err := s.Accept() - require.NoError(t, err) - // We do this in a closure because we need to unlock Server.mu if the - // test failure exception is thrown. "Do as we say, not as we do" -Go - // team. - func() { - mu.Lock() - defer mu.Unlock() - require.Len(t, s.conns, 1) - }() - dialerSync <- struct{}{} - require.NoError(t, a.Close()) - sleepWhile(&mu, func() bool { return len(s.conns) != 0 }) - } -} - -func TestPacketReadTimeout(t *testing.T) { - t.Parallel() - a, b := connPair() - _, err := a.Read(nil) - require.Contains(t, err.Error(), "timeout") - t.Log(err) - t.Log(a.Close()) - t.Log(b.Close()) -} - -func sleepWhile(l sync.Locker, cond func() bool) { - sleepWhileTimeout(l, cond, -1) - for { - l.Lock() - val := cond() - l.Unlock() - if !val { - break - } - time.Sleep(time.Millisecond) - } -} - -func sleepWhileTimeout(l sync.Locker, cond func() bool, timeout time.Duration) { - var deadline time.Time - if timeout >= 0 { - deadline = time.Now().Add(timeout) - } - for { - l.Lock() - val := cond() - l.Unlock() - if !val { - break - } - if !deadline.IsZero() && time.Now().After(deadline) { - break - } - time.Sleep(time.Millisecond) - } -} - -func TestMain(m *testing.M) { - http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - WriteStatus(w) - }) - setDefaultTestingDurations() - code := m.Run() - sleepWhileTimeout(&mu, func() bool { - return len(sockets) != 0 - }, time.Second) - mu.Lock() - numSockets := len(sockets) - mu.Unlock() - if numSockets != 0 { - code = 1 - WriteStatus(os.Stderr) - } - os.Exit(code) -} - -func TestAcceptReturnsAfterClose(t *testing.T) { - s, err := NewSocket("", "") - require.NoError(t, err) - go s.Close() - _, err = s.Accept() - t.Log(err) -} - -func TestWriteClose(t *testing.T) { - a, b := connPair() - defer a.Close() - defer b.Close() - a.Write([]byte("hiho")) - a.Close() - c, err := ioutil.ReadAll(b) - require.NoError(t, err) - require.EqualValues(t, "hiho", c) - b.Close() -} - -// Check that Conn.Write fails when the PacketConn that Socket wraps is -// closed. -func TestWriteUnderlyingPacketConnClosed(t *testing.T) { - pc, err := listenPacket("inproc", "localhost:0") - require.NoError(t, err) - defer pc.Close() - s, err := NewSocketFromPacketConn(pc) - require.NoError(t, err) - defer s.Close() - dc, ac := connPairSocket(s) - defer dc.Close() - defer ac.Close() - pc.Close() - n, err := ac.Write([]byte("hello")) - assert.Equal(t, 0, n) - // It has to fail. I think it's a race between us writing to the real - // PacketConn and getting "closed", and the Socket destroying itself, and - // we get it's destroy error. - assert.Error(t, err) - _, err = dc.Read(nil) - assert.EqualError(t, err, "Socket destroyed") -} - -func TestFillBuffers(t *testing.T) { - a, b := connPair() - defer b.Close() - var sent []byte - for { - buf := make([]byte, 100000) - io.ReadFull(rand.Reader, buf) - a.SetWriteDeadline(time.Now().Add(5 * time.Second)) - n, err := a.Write(buf) - sent = append(sent, buf[:n]...) - if err != nil { - // Receiver will stop processing packets, packets will be dropped, - // and thus not acked. - assert.Equal(t, errAckTimeout, err) - break - } - require.NotEqual(t, 0, n) - } - t.Logf("buffered %d bytes", len(sent)) - a.Close() - all, err := ioutil.ReadAll(b) - assert.NoError(t, err) - assert.EqualValues(t, len(sent), len(all)) - assert.EqualValues(t, sent, all) -} - -func TestConnLocalRemoteAddr(t *testing.T) { - a, b := connPair() - assert.EqualValues(t, "utp/inproc", a.LocalAddr().Network()) - assert.EqualValues(t, "utp/inproc", a.RemoteAddr().Network()) - assert.EqualValues(t, "utp/inproc", b.LocalAddr().Network()) - assert.EqualValues(t, "utp/inproc", b.RemoteAddr().Network()) - assert.EqualValues(t, a.LocalAddr().String(), b.RemoteAddr().String()) - assert.EqualValues(t, b.LocalAddr().String(), a.RemoteAddr().String()) - a.Close() - b.Close() - udpConn, err := net.ListenPacket("udp", "localhost:0") - require.NoError(t, err) - udpSock, err := NewSocketFromPacketConn(udpConn) - require.NoError(t, err) - a, b = connPairSocket(udpSock) - udpSock.Close() - assert.EqualValues(t, "utp/udp", a.LocalAddr().Network()) - assert.EqualValues(t, "utp/udp", a.RemoteAddr().Network()) - assert.EqualValues(t, "utp/udp", b.LocalAddr().Network()) - assert.EqualValues(t, "utp/udp", b.RemoteAddr().Network()) - assert.EqualValues(t, a.LocalAddr().String(), b.RemoteAddr().String()) - assert.EqualValues(t, b.LocalAddr().String(), a.RemoteAddr().String()) - a.Close() - b.Close() -} - -func BenchmarkEchoLongBuffer(tb *testing.B) { - pristine := make([]byte, 3000000) - n, err := io.ReadFull(rand.Reader, pristine) - require.EqualValues(tb, len(pristine), n) - require.NoError(tb, err) - tb.SetBytes(int64(len(pristine))) - tb.ResetTimer() - for range iter.N(tb.N) { - func() { - a, b := connPair() - defer a.Close() - defer b.Close() - go func() { - n, err := io.Copy(b, b) - require.NoError(tb, err) - require.EqualValues(tb, len(pristine), n) - b.Close() - }() - go func() { - n, err := a.Write(pristine) - require.NoError(tb, err) - require.EqualValues(tb, len(pristine), n) - }() - echo := make([]byte, len(pristine)) - n, err := io.ReadFull(a, echo) - a.Close() - assert.NoError(tb, err) - require.EqualValues(tb, len(echo), n) - require.True(tb, bytes.Equal(pristine, echo)) - }() - } -} - -// Create a utp.Conn between two Sockets. Then axe one before it can cry for -// help. Check that the other still destroys its underlying UDP PacketConn -// when the Socket and Conn are closed. -func TestSocketDestroyedConnsClosedTimeout(t *testing.T) { - s1pc, err := net.ListenPacket("udp", "localhost:0") - require.NoError(t, err) - s1, err := NewSocketFromPacketConnNoClose(s1pc) - require.NoError(t, err) - s2, err := NewSocket("", "localhost:0") - require.NoError(t, err) - accepted := make(chan struct{}) - var s1c net.Conn - go func() { - var err error - s1c, err = s1.Accept() - close(accepted) - require.NoError(t, err) - }() - s2c, err := s2.Dial(s1.Addr().String()) - require.NoError(t, err) - <-accepted - // Axe Socket 1's PacketConn. - s1pc.Close() - // Now its wrappers, that may be confused right now. - s1.Close() - // s1 should have been destroyed. - <-s1.destroyed.LockedChan(&mu) - s1c.Close() - // Check that we can now listen in Socket 1's place. - for { - pc, err := net.ListenPacket("udp", s1pc.LocalAddr().String()) - if err == nil { - pc.Close() - break - } - time.Sleep(time.Millisecond) - } - // Maybe bump up the unacked sends a bit. - s2c.Write([]byte("ping")) - s2c.Write([]byte("pong")) - s2c.Close() - s2.Close() - // s2 should be destroyed when the write timeout on s2c occurs. - <-s2.destroyed.LockedChan(&mu) -} - -// Make sure that creating two connecting sockets repeatedly will successfully -// close the sockets after calling CloseNow(). New sockets can be created with -// the same address without a "bind: address already in use" error. -func TestCloseNow(t *testing.T) { - s1Addr := "localhost:0" - s2Addr := "localhost:0" - for i := 0; i < 100; i++ { - s1, err := NewSocket("udp", s1Addr) - assert.NoError(t, err) - s2, err := NewSocket("udp", s2Addr) - assert.NoError(t, err) - s1Addr = s1.Addr().String() - s2Addr = s2.Addr().String() - go func() { - c, err := s1.Dial(s2.Addr().String()) - assert.NoError(t, err) - _, err = c.Write([]byte("ping")) - assert.NoError(t, err) - _, err = c.Read(nil) - assert.Equal(t, err.Error(), "EOF") - }() - c, _ := s2.Accept() - buf := make([]byte, 4) - _, err = c.Read(buf) - assert.NoError(t, err) - s1.CloseNow() - s2.CloseNow() - _, err = c.Read(nil) - assert.Equal(t, err.Error(), "EOF") - } -} - -// Test dial 0.0.0.0 -func TestZerosIPV4(t *testing.T) { - //if runtime.GOOS == "windows" { - // t.Skip("dialling 0.0.0.0 not working on windows before go1.8?") - //} - - testSimpleRead(t, "0.0.0.0", "0.0.0.0") -} - -// Test dial [::] -func TestZerosIPV6(t *testing.T) { - //if runtime.GOOS == "windows" { - // t.Skip("dialling 0.0.0.0 not working on windows before go1.8?") - //} - - testSimpleRead(t, "[::]", "[::]") -} - -// tests a simple server accept/write/close with client dial/read. -func testSimpleRead(t *testing.T, serverBindIP string, clientDialIP string) { - l, err := NewSocket("udp", fmt.Sprintf("%s:0", serverBindIP)) - if err != nil { - t.Fatal(err) - } - sport := l.pc.(*net.UDPConn).LocalAddr().(*net.UDPAddr).Port - - defer func() { - err = l.Close() - if err != nil { - t.Fatal(err) - } - }() - - serr := make(chan error, 1) - go func() { - con, err := l.Accept() - if err != nil { - serr <- err - return - } - io.WriteString(con, "hello") - serr <- con.Close() - }() - - client, err := Dial(fmt.Sprintf("%s:%d", clientDialIP, sport)) - if err != nil { - t.Fatal(err) - } - - response, err := ioutil.ReadAll(client) - if err != nil { - t.Fatal(err) - } - - if string(response) != "hello" { - t.Fatalf("unexpected response %s", response) - } - - err = client.Close() - if err != nil { - t.Fatal(err) - } -} - -func TestNettestInprocSocket(t *testing.T) { - nettest.TestConn(t, func() (c1, c2 net.Conn, stop func(), err error) { - s, err := NewSocket("inproc", ":0") - if err != nil { - return - } - c1, c2 = connPairSocket(s) - stop = func() { - s.CloseNow() - } - return - }) -} - -func TestNettestLocalhostUDP(t *testing.T) { - nettest.TestConn(t, func() (c1, c2 net.Conn, stop func(), err error) { - s, err := NewSocket("udp", "localhost:0") - if err != nil { - return - } - c1, c2 = connPairSocket(s) - stop = func() { - s.CloseNow() - } - return - }) -} diff --git a/vendor/github.com/andybalholm/cascadia/benchmark_test.go b/vendor/github.com/andybalholm/cascadia/benchmark_test.go deleted file mode 100644 index 42bf50006..000000000 --- a/vendor/github.com/andybalholm/cascadia/benchmark_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package cascadia - -import ( - "strings" - "testing" - - "golang.org/x/net/html" -) - -func MustParseHTML(doc string) *html.Node { - dom, err := html.Parse(strings.NewReader(doc)) - if err != nil { - panic(err) - } - return dom -} - -var selector = MustCompile(`div.matched`) -var doc = ` - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - -` -var dom = MustParseHTML(doc) - -func BenchmarkMatchAll(b *testing.B) { - var matches []*html.Node - for i := 0; i < b.N; i++ { - matches = selector.MatchAll(dom) - } - _ = matches -} diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test0 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test0 deleted file mode 100644 index 83a6561a7..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test0 +++ /dev/null @@ -1 +0,0 @@ -address \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test1 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test1 deleted file mode 100644 index f59ec20aa..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test1 +++ /dev/null @@ -1 +0,0 @@ -* \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test10 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test10 deleted file mode 100644 index 0ee70eb00..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test10 +++ /dev/null @@ -1 +0,0 @@ -p[title] \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test11 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test11 deleted file mode 100644 index 66340c4af..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test11 +++ /dev/null @@ -1 +0,0 @@ -address[title="foo"] \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test12 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test12 deleted file mode 100644 index 6303f0869..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test12 +++ /dev/null @@ -1 +0,0 @@ -[ title ~= foo ] \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test13 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test13 deleted file mode 100644 index 45d91eb63..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test13 +++ /dev/null @@ -1 +0,0 @@ -[title~="hello world"] \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test14 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test14 deleted file mode 100644 index 62e7d68a8..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test14 +++ /dev/null @@ -1 +0,0 @@ -[lang|="en"] \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test15 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test15 deleted file mode 100644 index fe9ab530e..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test15 +++ /dev/null @@ -1 +0,0 @@ -[title^="foo"] \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test16 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test16 deleted file mode 100644 index dbee7332c..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test16 +++ /dev/null @@ -1 +0,0 @@ -[title$="bar"] \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test17 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test17 deleted file mode 100644 index e4fb4032c..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test17 +++ /dev/null @@ -1 +0,0 @@ -[title*="bar"] \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test18 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test18 deleted file mode 100644 index 607501436..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test18 +++ /dev/null @@ -1 +0,0 @@ -.t1:not(.t2) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test19 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test19 deleted file mode 100644 index f04dfafd4..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test19 +++ /dev/null @@ -1 +0,0 @@ -div:not(.t1) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test2 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test2 deleted file mode 100644 index 5529b9b4c..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test2 +++ /dev/null @@ -1 +0,0 @@ -#foo \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test20 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test20 deleted file mode 100644 index a1c883497..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test20 +++ /dev/null @@ -1 +0,0 @@ -li:nth-child(odd) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test21 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test21 deleted file mode 100644 index b99fcb6ac..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test21 +++ /dev/null @@ -1 +0,0 @@ -li:nth-child(even) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test22 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test22 deleted file mode 100644 index a9ee21795..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test22 +++ /dev/null @@ -1 +0,0 @@ -li:nth-child(-n+2) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test23 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test23 deleted file mode 100644 index aad519d55..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test23 +++ /dev/null @@ -1 +0,0 @@ -li:nth-child(3n+1) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test24 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test24 deleted file mode 100644 index 436a2191c..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test24 +++ /dev/null @@ -1 +0,0 @@ -li:nth-last-child(odd) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test25 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test25 deleted file mode 100644 index 46f6cbc27..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test25 +++ /dev/null @@ -1 +0,0 @@ -li:nth-last-child(even) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test26 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test26 deleted file mode 100644 index d18bf3b45..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test26 +++ /dev/null @@ -1 +0,0 @@ -li:nth-last-child(-n+2) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test27 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test27 deleted file mode 100644 index d1d6eb317..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test27 +++ /dev/null @@ -1 +0,0 @@ -li:nth-last-child(3n+1) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test28 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test28 deleted file mode 100644 index 9a0c94931..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test28 +++ /dev/null @@ -1 +0,0 @@ -span:first-child \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test29 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test29 deleted file mode 100644 index 7058608ec..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test29 +++ /dev/null @@ -1 +0,0 @@ -span:last-child \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test3 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test3 deleted file mode 100644 index ee024825f..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test3 +++ /dev/null @@ -1 +0,0 @@ -li#t1 \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test30 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test30 deleted file mode 100644 index 536e6ffb3..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test30 +++ /dev/null @@ -1 +0,0 @@ -p:nth-of-type(2) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test31 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test31 deleted file mode 100644 index 61c1fc758..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test31 +++ /dev/null @@ -1 +0,0 @@ -p:nth-last-of-type(2) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test32 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test32 deleted file mode 100644 index d9a9dc54b..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test32 +++ /dev/null @@ -1 +0,0 @@ -p:last-of-type \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test33 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test33 deleted file mode 100644 index 9052c4194..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test33 +++ /dev/null @@ -1 +0,0 @@ -p:first-of-type \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test34 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test34 deleted file mode 100644 index 60bd12471..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test34 +++ /dev/null @@ -1 +0,0 @@ -p:only-child \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test35 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test35 deleted file mode 100644 index 87d9dbc65..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test35 +++ /dev/null @@ -1 +0,0 @@ -p:only-of-type \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test36 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test36 deleted file mode 100644 index 8e9295421..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test36 +++ /dev/null @@ -1 +0,0 @@ -:empty \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test37 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test37 deleted file mode 100644 index ba3455f5b..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test37 +++ /dev/null @@ -1 +0,0 @@ -div p \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test38 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test38 deleted file mode 100644 index d6f24c0af..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test38 +++ /dev/null @@ -1 +0,0 @@ -div table p \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test39 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test39 deleted file mode 100644 index a72a605cf..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test39 +++ /dev/null @@ -1 +0,0 @@ -div > p \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test4 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test4 deleted file mode 100644 index 7b253d3ee..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test4 +++ /dev/null @@ -1 +0,0 @@ -*#t4 \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test40 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test40 deleted file mode 100644 index 407ea3c42..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test40 +++ /dev/null @@ -1 +0,0 @@ -p ~ p \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test41 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test41 deleted file mode 100644 index e36e0942f..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test41 +++ /dev/null @@ -1 +0,0 @@ -p + p \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test42 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test42 deleted file mode 100644 index fa59ada06..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test42 +++ /dev/null @@ -1 +0,0 @@ -li, p \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test43 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test43 deleted file mode 100644 index e946ff3aa..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test43 +++ /dev/null @@ -1 +0,0 @@ -p +/*This is a comment*/ p \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test44 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test44 deleted file mode 100644 index df68954ae..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test44 +++ /dev/null @@ -1 +0,0 @@ -p:contains("that wraps") \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test45 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test45 deleted file mode 100644 index 5c479a9a1..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test45 +++ /dev/null @@ -1 +0,0 @@ -p:containsOwn("that wraps") \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test46 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test46 deleted file mode 100644 index a189d03cb..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test46 +++ /dev/null @@ -1 +0,0 @@ -:containsOwn("inner") \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test47 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test47 deleted file mode 100644 index bfba3689e..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test47 +++ /dev/null @@ -1 +0,0 @@ -p:containsOwn("block") \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test48 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test48 deleted file mode 100644 index 4a6abb3ce..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test48 +++ /dev/null @@ -1 +0,0 @@ -div:has(#p1) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test49 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test49 deleted file mode 100644 index 2048a0cd8..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test49 +++ /dev/null @@ -1 +0,0 @@ -div:has(:containsOwn("2")) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test5 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test5 deleted file mode 100644 index 702c0f1e5..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test5 +++ /dev/null @@ -1 +0,0 @@ -.t1 \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test50 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test50 deleted file mode 100644 index c062e4c1b..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test50 +++ /dev/null @@ -1 +0,0 @@ -body :has(:containsOwn("2")) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test51 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test51 deleted file mode 100644 index 151226047..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test51 +++ /dev/null @@ -1 +0,0 @@ -body :haschild(:containsOwn("2")) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test52 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test52 deleted file mode 100644 index c3dee62a8..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test52 +++ /dev/null @@ -1 +0,0 @@ -p:matches([\d]) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test53 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test53 deleted file mode 100644 index 90f71d782..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test53 +++ /dev/null @@ -1 +0,0 @@ -p:matches([a-z]) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test54 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test54 deleted file mode 100644 index 88b4c2830..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test54 +++ /dev/null @@ -1 +0,0 @@ -p:matches([a-zA-Z]) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test55 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test55 deleted file mode 100644 index 699b41ffd..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test55 +++ /dev/null @@ -1 +0,0 @@ -p:matches([^\d]) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test56 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test56 deleted file mode 100644 index 83d4c474b..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test56 +++ /dev/null @@ -1 +0,0 @@ -p:matches(^(0|a)) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test57 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test57 deleted file mode 100644 index e8507ba67..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test57 +++ /dev/null @@ -1 +0,0 @@ -p:matches(^\d+$) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test58 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test58 deleted file mode 100644 index e29dba9b3..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test58 +++ /dev/null @@ -1 +0,0 @@ -p:not(:matches(^\d+$)) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test59 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test59 deleted file mode 100644 index b5f72069a..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test59 +++ /dev/null @@ -1 +0,0 @@ -div :matchesOwn(^\d+$) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test6 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test6 deleted file mode 100644 index cf58afccd..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test6 +++ /dev/null @@ -1 +0,0 @@ -p.t1 \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test60 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test60 deleted file mode 100644 index 2154ba88b..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test60 +++ /dev/null @@ -1 +0,0 @@ -[href#=(fina)]:not([href#=(\/\/[^\/]+untrusted)]) \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test61 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test61 deleted file mode 100644 index 1c8f5258e..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test61 +++ /dev/null @@ -1 +0,0 @@ -[href#=(^https:\/\/[^\/]*\/?news)] \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test7 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test7 deleted file mode 100644 index 9ad6c2093..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test7 +++ /dev/null @@ -1 +0,0 @@ -div.teST \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test8 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test8 deleted file mode 100644 index 2ed128422..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test8 +++ /dev/null @@ -1 +0,0 @@ -.t1.fail \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test9 b/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test9 deleted file mode 100644 index 8c1c2a272..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/corpus/test9 +++ /dev/null @@ -1 +0,0 @@ -p.t1.t2 \ No newline at end of file diff --git a/vendor/github.com/andybalholm/cascadia/fuzz/fuzz.go b/vendor/github.com/andybalholm/cascadia/fuzz/fuzz.go deleted file mode 100644 index f6c202e22..000000000 --- a/vendor/github.com/andybalholm/cascadia/fuzz/fuzz.go +++ /dev/null @@ -1,14 +0,0 @@ -package fuzz - -import "github.com/andybalholm/cascadia" - -func Fuzz(data []byte) int { - sel, err := cascadia.Compile(string(data)) - if err != nil { - if sel != nil { - panic("sel != nil on error") - } - return 0 - } - return 1 -} diff --git a/vendor/github.com/andybalholm/cascadia/parser_test.go b/vendor/github.com/andybalholm/cascadia/parser_test.go deleted file mode 100644 index 47dd4a692..000000000 --- a/vendor/github.com/andybalholm/cascadia/parser_test.go +++ /dev/null @@ -1,86 +0,0 @@ -package cascadia - -import ( - "testing" -) - -var identifierTests = map[string]string{ - "x": "x", - "96": "", - "-x": "-x", - `r\e9 sumé`: "résumé", - `a\"b`: `a"b`, -} - -func TestParseIdentifier(t *testing.T) { - for source, want := range identifierTests { - p := &parser{s: source} - got, err := p.parseIdentifier() - - if err != nil { - if want == "" { - // It was supposed to be an error. - continue - } - t.Errorf("parsing %q: got error (%s), want %q", source, err, want) - continue - } - - if want == "" { - if err == nil { - t.Errorf("parsing %q: got %q, want error", source, got) - } - continue - } - - if p.i < len(source) { - t.Errorf("parsing %q: %d bytes left over", source, len(source)-p.i) - continue - } - - if got != want { - t.Errorf("parsing %q: got %q, want %q", source, got, want) - } - } -} - -var stringTests = map[string]string{ - `"x"`: "x", - `'x'`: "x", - `'x`: "", - "'x\\\r\nx'": "xx", - `"r\e9 sumé"`: "résumé", - `"a\"b"`: `a"b`, -} - -func TestParseString(t *testing.T) { - for source, want := range stringTests { - p := &parser{s: source} - got, err := p.parseString() - - if err != nil { - if want == "" { - // It was supposed to be an error. - continue - } - t.Errorf("parsing %q: got error (%s), want %q", source, err, want) - continue - } - - if want == "" { - if err == nil { - t.Errorf("parsing %q: got %q, want error", source, got) - } - continue - } - - if p.i < len(source) { - t.Errorf("parsing %q: %d bytes left over", source, len(source)-p.i) - continue - } - - if got != want { - t.Errorf("parsing %q: got %q, want %q", source, got, want) - } - } -} diff --git a/vendor/github.com/andybalholm/cascadia/selector_test.go b/vendor/github.com/andybalholm/cascadia/selector_test.go deleted file mode 100644 index d352b6566..000000000 --- a/vendor/github.com/andybalholm/cascadia/selector_test.go +++ /dev/null @@ -1,575 +0,0 @@ -package cascadia - -import ( - "strings" - "testing" - - "golang.org/x/net/html" -) - -type selectorTest struct { - HTML, selector string - results []string -} - -func nodeString(n *html.Node) string { - switch n.Type { - case html.TextNode: - return n.Data - case html.ElementNode: - return html.Token{ - Type: html.StartTagToken, - Data: n.Data, - Attr: n.Attr, - }.String() - } - return "" -} - -var selectorTests = []selectorTest{ - { - `
This address...
`, - "address", - []string{ - "
", - }, - }, - { - ``, - "*", - []string{ - "", - "", - "", - "", - }, - }, - { - `

`, - "#foo", - []string{ - `

`, - }, - }, - { - `

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

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

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

baz

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

-| "baz" - -#data -
foobar

baz

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

-| "baz" - -#data -
foobar

baz

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

-| "baz" -|

-| "quux" - -#data -
foobarbaz

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

-| "quux" - -#data -foobar

baz

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

-| "baz" -| -| -|

-| "quux" - -#data -

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

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

-| "quux" - -#data -foobar

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

-| "baz" - -#data -foobar

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

-| "baz" - -#data -

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

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

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

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

-| -| -| -|

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

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

          -| -| -|

          - -#data -

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

          -| -| -|

          - -#data -

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

          -| -| -| -|

          -|

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

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

foobazeggs

spam

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

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

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

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

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

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

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

-| "X" - -#data -

-

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

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

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

-#errors -#document -| -| -| -| -| -| ddd -#errors -#document -| -| -| -#errors -#document -| -| -| -| -|
  • -| -| ", - " -
    << Back to Go HTTP/2 demo server`) - }) -} - -func httpsHost() string { - if *hostHTTPS != "" { - return *hostHTTPS - } - if v := *httpsAddr; strings.HasPrefix(v, ":") { - return "localhost" + v - } else { - return v - } -} - -func httpHost() string { - if *hostHTTP != "" { - return *hostHTTP - } - if v := *httpAddr; strings.HasPrefix(v, ":") { - return "localhost" + v - } else { - return v - } -} - -func serveProdTLS() error { - const cacheDir = "/var/cache/autocert" - if err := os.MkdirAll(cacheDir, 0700); err != nil { - return err - } - m := autocert.Manager{ - Cache: autocert.DirCache(cacheDir), - Prompt: autocert.AcceptTOS, - HostPolicy: autocert.HostWhitelist("http2.golang.org"), - } - srv := &http.Server{ - TLSConfig: &tls.Config{ - GetCertificate: m.GetCertificate, - }, - } - http2.ConfigureServer(srv, &http2.Server{ - NewWriteScheduler: func() http2.WriteScheduler { - return http2.NewPriorityWriteScheduler(nil) - }, - }) - ln, err := net.Listen("tcp", ":443") - if err != nil { - return err - } - return srv.Serve(tls.NewListener(tcpKeepAliveListener{ln.(*net.TCPListener)}, srv.TLSConfig)) -} - -type tcpKeepAliveListener struct { - *net.TCPListener -} - -func (ln tcpKeepAliveListener) Accept() (c net.Conn, err error) { - tc, err := ln.AcceptTCP() - if err != nil { - return - } - tc.SetKeepAlive(true) - tc.SetKeepAlivePeriod(3 * time.Minute) - return tc, nil -} - -func serveProd() error { - errc := make(chan error, 2) - go func() { errc <- http.ListenAndServe(":80", nil) }() - go func() { errc <- serveProdTLS() }() - return <-errc -} - -const idleTimeout = 5 * time.Minute -const activeTimeout = 10 * time.Minute - -// TODO: put this into the standard library and actually send -// PING frames and GOAWAY, etc: golang.org/issue/14204 -func idleTimeoutHook() func(net.Conn, http.ConnState) { - var mu sync.Mutex - m := map[net.Conn]*time.Timer{} - return func(c net.Conn, cs http.ConnState) { - mu.Lock() - defer mu.Unlock() - if t, ok := m[c]; ok { - delete(m, c) - t.Stop() - } - var d time.Duration - switch cs { - case http.StateNew, http.StateIdle: - d = idleTimeout - case http.StateActive: - d = activeTimeout - default: - return - } - m[c] = time.AfterFunc(d, func() { - log.Printf("closing idle conn %v after %v", c.RemoteAddr(), d) - go c.Close() - }) - } -} - -func main() { - var srv http.Server - flag.BoolVar(&http2.VerboseLogs, "verbose", false, "Verbose HTTP/2 debugging.") - flag.Parse() - srv.Addr = *httpsAddr - srv.ConnState = idleTimeoutHook() - - registerHandlers() - - if *prod { - *hostHTTP = "http2.golang.org" - *hostHTTPS = "http2.golang.org" - log.Fatal(serveProd()) - } - - url := "https://" + httpsHost() + "/" - log.Printf("Listening on " + url) - http2.ConfigureServer(&srv, &http2.Server{}) - - if *httpAddr != "" { - go func() { - log.Printf("Listening on http://" + httpHost() + "/ (for unencrypted HTTP/1)") - log.Fatal(http.ListenAndServe(*httpAddr, nil)) - }() - } - - go func() { - log.Fatal(srv.ListenAndServeTLS("server.crt", "server.key")) - }() - select {} -} diff --git a/vendor/golang.org/x/net/http2/h2demo/launch.go b/vendor/golang.org/x/net/http2/h2demo/launch.go deleted file mode 100644 index df0866a30..000000000 --- a/vendor/golang.org/x/net/http2/h2demo/launch.go +++ /dev/null @@ -1,302 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package main - -import ( - "bufio" - "bytes" - "encoding/json" - "flag" - "fmt" - "io" - "io/ioutil" - "log" - "net/http" - "os" - "strings" - "time" - - "golang.org/x/oauth2" - "golang.org/x/oauth2/google" - compute "google.golang.org/api/compute/v1" -) - -var ( - proj = flag.String("project", "symbolic-datum-552", "name of Project") - zone = flag.String("zone", "us-central1-a", "GCE zone") - mach = flag.String("machinetype", "n1-standard-1", "Machine type") - instName = flag.String("instance_name", "http2-demo", "Name of VM instance.") - sshPub = flag.String("ssh_public_key", "", "ssh public key file to authorize. Can modify later in Google's web UI anyway.") - staticIP = flag.String("static_ip", "130.211.116.44", "Static IP to use. If empty, automatic.") - - writeObject = flag.String("write_object", "", "If non-empty, a VM isn't created and the flag value is Google Cloud Storage bucket/object to write. The contents from stdin.") - publicObject = flag.Bool("write_object_is_public", false, "Whether the object created by --write_object should be public.") -) - -func readFile(v string) string { - slurp, err := ioutil.ReadFile(v) - if err != nil { - log.Fatalf("Error reading %s: %v", v, err) - } - return strings.TrimSpace(string(slurp)) -} - -var config = &oauth2.Config{ - // The client-id and secret should be for an "Installed Application" when using - // the CLI. Later we'll use a web application with a callback. - ClientID: readFile("client-id.dat"), - ClientSecret: readFile("client-secret.dat"), - Endpoint: google.Endpoint, - Scopes: []string{ - compute.DevstorageFullControlScope, - compute.ComputeScope, - "https://www.googleapis.com/auth/sqlservice", - "https://www.googleapis.com/auth/sqlservice.admin", - }, - RedirectURL: "urn:ietf:wg:oauth:2.0:oob", -} - -const baseConfig = `#cloud-config -coreos: - units: - - name: h2demo.service - command: start - content: | - [Unit] - Description=HTTP2 Demo - - [Service] - ExecStartPre=/bin/bash -c 'mkdir -p /opt/bin && curl -s -o /opt/bin/h2demo http://storage.googleapis.com/http2-demo-server-tls/h2demo && chmod +x /opt/bin/h2demo' - ExecStart=/opt/bin/h2demo --prod - RestartSec=5s - Restart=always - Type=simple - - [Install] - WantedBy=multi-user.target -` - -func main() { - flag.Parse() - if *proj == "" { - log.Fatalf("Missing --project flag") - } - prefix := "https://www.googleapis.com/compute/v1/projects/" + *proj - machType := prefix + "/zones/" + *zone + "/machineTypes/" + *mach - - const tokenFileName = "token.dat" - tokenFile := tokenCacheFile(tokenFileName) - tokenSource := oauth2.ReuseTokenSource(nil, tokenFile) - token, err := tokenSource.Token() - if err != nil { - if *writeObject != "" { - log.Fatalf("Can't use --write_object without a valid token.dat file already cached.") - } - log.Printf("Error getting token from %s: %v", tokenFileName, err) - log.Printf("Get auth code from %v", config.AuthCodeURL("my-state")) - fmt.Print("\nEnter auth code: ") - sc := bufio.NewScanner(os.Stdin) - sc.Scan() - authCode := strings.TrimSpace(sc.Text()) - token, err = config.Exchange(oauth2.NoContext, authCode) - if err != nil { - log.Fatalf("Error exchanging auth code for a token: %v", err) - } - if err := tokenFile.WriteToken(token); err != nil { - log.Fatalf("Error writing to %s: %v", tokenFileName, err) - } - tokenSource = oauth2.ReuseTokenSource(token, nil) - } - - oauthClient := oauth2.NewClient(oauth2.NoContext, tokenSource) - - if *writeObject != "" { - writeCloudStorageObject(oauthClient) - return - } - - computeService, _ := compute.New(oauthClient) - - natIP := *staticIP - if natIP == "" { - // Try to find it by name. - aggAddrList, err := computeService.Addresses.AggregatedList(*proj).Do() - if err != nil { - log.Fatal(err) - } - // http://godoc.org/code.google.com/p/google-api-go-client/compute/v1#AddressAggregatedList - IPLoop: - for _, asl := range aggAddrList.Items { - for _, addr := range asl.Addresses { - if addr.Name == *instName+"-ip" && addr.Status == "RESERVED" { - natIP = addr.Address - break IPLoop - } - } - } - } - - cloudConfig := baseConfig - if *sshPub != "" { - key := strings.TrimSpace(readFile(*sshPub)) - cloudConfig += fmt.Sprintf("\nssh_authorized_keys:\n - %s\n", key) - } - if os.Getenv("USER") == "bradfitz" { - cloudConfig += fmt.Sprintf("\nssh_authorized_keys:\n - %s\n", "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAwks9dwWKlRC+73gRbvYtVg0vdCwDSuIlyt4z6xa/YU/jTDynM4R4W10hm2tPjy8iR1k8XhDv4/qdxe6m07NjG/By1tkmGpm1mGwho4Pr5kbAAy/Qg+NLCSdAYnnE00FQEcFOC15GFVMOW2AzDGKisReohwH9eIzHPzdYQNPRWXE= bradfitz@papag.bradfitz.com") - } - const maxCloudConfig = 32 << 10 // per compute API docs - if len(cloudConfig) > maxCloudConfig { - log.Fatalf("cloud config length of %d bytes is over %d byte limit", len(cloudConfig), maxCloudConfig) - } - - instance := &compute.Instance{ - Name: *instName, - Description: "Go Builder", - MachineType: machType, - Disks: []*compute.AttachedDisk{instanceDisk(computeService)}, - Tags: &compute.Tags{ - Items: []string{"http-server", "https-server"}, - }, - Metadata: &compute.Metadata{ - Items: []*compute.MetadataItems{ - { - Key: "user-data", - Value: &cloudConfig, - }, - }, - }, - NetworkInterfaces: []*compute.NetworkInterface{ - { - AccessConfigs: []*compute.AccessConfig{ - { - Type: "ONE_TO_ONE_NAT", - Name: "External NAT", - NatIP: natIP, - }, - }, - Network: prefix + "/global/networks/default", - }, - }, - ServiceAccounts: []*compute.ServiceAccount{ - { - Email: "default", - Scopes: []string{ - compute.DevstorageFullControlScope, - compute.ComputeScope, - }, - }, - }, - } - - log.Printf("Creating instance...") - op, err := computeService.Instances.Insert(*proj, *zone, instance).Do() - if err != nil { - log.Fatalf("Failed to create instance: %v", err) - } - opName := op.Name - log.Printf("Created. Waiting on operation %v", opName) -OpLoop: - for { - time.Sleep(2 * time.Second) - op, err := computeService.ZoneOperations.Get(*proj, *zone, opName).Do() - if err != nil { - log.Fatalf("Failed to get op %s: %v", opName, err) - } - switch op.Status { - case "PENDING", "RUNNING": - log.Printf("Waiting on operation %v", opName) - continue - case "DONE": - if op.Error != nil { - for _, operr := range op.Error.Errors { - log.Printf("Error: %+v", operr) - } - log.Fatalf("Failed to start.") - } - log.Printf("Success. %+v", op) - break OpLoop - default: - log.Fatalf("Unknown status %q: %+v", op.Status, op) - } - } - - inst, err := computeService.Instances.Get(*proj, *zone, *instName).Do() - if err != nil { - log.Fatalf("Error getting instance after creation: %v", err) - } - ij, _ := json.MarshalIndent(inst, "", " ") - log.Printf("Instance: %s", ij) -} - -func instanceDisk(svc *compute.Service) *compute.AttachedDisk { - const imageURL = "https://www.googleapis.com/compute/v1/projects/coreos-cloud/global/images/coreos-stable-444-5-0-v20141016" - diskName := *instName + "-disk" - - return &compute.AttachedDisk{ - AutoDelete: true, - Boot: true, - Type: "PERSISTENT", - InitializeParams: &compute.AttachedDiskInitializeParams{ - DiskName: diskName, - SourceImage: imageURL, - DiskSizeGb: 50, - }, - } -} - -func writeCloudStorageObject(httpClient *http.Client) { - content := os.Stdin - const maxSlurp = 1 << 20 - var buf bytes.Buffer - n, err := io.CopyN(&buf, content, maxSlurp) - if err != nil && err != io.EOF { - log.Fatalf("Error reading from stdin: %v, %v", n, err) - } - contentType := http.DetectContentType(buf.Bytes()) - - req, err := http.NewRequest("PUT", "https://storage.googleapis.com/"+*writeObject, io.MultiReader(&buf, content)) - if err != nil { - log.Fatal(err) - } - req.Header.Set("x-goog-api-version", "2") - if *publicObject { - req.Header.Set("x-goog-acl", "public-read") - } - req.Header.Set("Content-Type", contentType) - res, err := httpClient.Do(req) - if err != nil { - log.Fatal(err) - } - if res.StatusCode != 200 { - res.Write(os.Stderr) - log.Fatalf("Failed.") - } - log.Printf("Success.") - os.Exit(0) -} - -type tokenCacheFile string - -func (f tokenCacheFile) Token() (*oauth2.Token, error) { - slurp, err := ioutil.ReadFile(string(f)) - if err != nil { - return nil, err - } - t := new(oauth2.Token) - if err := json.Unmarshal(slurp, t); err != nil { - return nil, err - } - return t, nil -} - -func (f tokenCacheFile) WriteToken(t *oauth2.Token) error { - jt, err := json.Marshal(t) - if err != nil { - return err - } - return ioutil.WriteFile(string(f), jt, 0600) -} diff --git a/vendor/golang.org/x/net/http2/h2demo/rootCA.key b/vendor/golang.org/x/net/http2/h2demo/rootCA.key deleted file mode 100644 index a15a6abaf..000000000 --- a/vendor/golang.org/x/net/http2/h2demo/rootCA.key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEAt5fAjp4fTcekWUTfzsp0kyih1OYbsGL0KX1eRbSSR8Od0+9Q -62Hyny+GFwMTb4A/KU8mssoHvcceSAAbwfbxFK/+s51TobqUnORZrOoTZjkUygby -XDSK99YBbcR1Pip8vwMTm4XKuLtCigeBBdjjAQdgUO28LENGlsMnmeYkJfODVGnV -mr5Ltb9ANA8IKyTfsnHJ4iOCS/PlPbUj2q7YnoVLposUBMlgUb/CykX3mOoLb4yJ -JQyA/iST6ZxiIEj36D4yWZ5lg7YJl+UiiBQHGCnPdGyipqV06ex0heYWcaiW8LWZ -SUQ93jQ+WVCH8hT7DQO1dmsvUmXlq/JeAlwQ/QIDAQABAoIBAFFHV7JMAqPWnMYA -nezY6J81v9+XN+7xABNWM2Q8uv4WdksbigGLTXR3/680Z2hXqJ7LMeC5XJACFT/e -/Gr0vmpgOCygnCPfjGehGKpavtfksXV3edikUlnCXsOP1C//c1bFL+sMYmFCVgTx -qYdDK8yKzXNGrKYT6q5YG7IglyRNV1rsQa8lM/5taFYiD1Ck/3tQi3YIq8Lcuser -hrxsMABcQ6mi+EIvG6Xr4mfJug0dGJMHG4RG1UGFQn6RXrQq2+q53fC8ZbVUSi0j -NQ918aKFzktwv+DouKU0ME4I9toks03gM860bAL7zCbKGmwR3hfgX/TqzVCWpG9E -LDVfvekCgYEA8fk9N53jbBRmULUGEf4qWypcLGiZnNU0OeXWpbPV9aa3H0VDytA7 -8fCN2dPAVDPqlthMDdVe983NCNwp2Yo8ZimDgowyIAKhdC25s1kejuaiH9OAPj3c -0f8KbriYX4n8zNHxFwK6Ae3pQ6EqOLJVCUsziUaZX9nyKY5aZlyX6xcCgYEAwjws -K62PjC64U5wYddNLp+kNdJ4edx+a7qBb3mEgPvSFT2RO3/xafJyG8kQB30Mfstjd -bRxyUV6N0vtX1zA7VQtRUAvfGCecpMo+VQZzcHXKzoRTnQ7eZg4Lmj5fQ9tOAKAo -QCVBoSW/DI4PZL26CAMDcAba4Pa22ooLapoRIQsCgYA6pIfkkbxLNkpxpt2YwLtt -Kr/590O7UaR9n6k8sW/aQBRDXNsILR1KDl2ifAIxpf9lnXgZJiwE7HiTfCAcW7c1 -nzwDCI0hWuHcMTS/NYsFYPnLsstyyjVZI3FY0h4DkYKV9Q9z3zJLQ2hz/nwoD3gy -b2pHC7giFcTts1VPV4Nt8wKBgHeFn4ihHJweg76vZz3Z78w7VNRWGFklUalVdDK7 -gaQ7w2y/ROn/146mo0OhJaXFIFRlrpvdzVrU3GDf2YXJYDlM5ZRkObwbZADjksev -WInzcgDy3KDg7WnPasRXbTfMU4t/AkW2p1QKbi3DnSVYuokDkbH2Beo45vxDxhKr -C69RAoGBAIyo3+OJenoZmoNzNJl2WPW5MeBUzSh8T/bgyjFTdqFHF5WiYRD/lfHj -x9Glyw2nutuT4hlOqHvKhgTYdDMsF2oQ72fe3v8Q5FU7FuKndNPEAyvKNXZaShVA -hnlhv5DjXKb0wFWnt5PCCiQLtzG0yyHaITrrEme7FikkIcTxaX/Y ------END RSA PRIVATE KEY----- diff --git a/vendor/golang.org/x/net/http2/h2demo/rootCA.pem b/vendor/golang.org/x/net/http2/h2demo/rootCA.pem deleted file mode 100644 index 3a323e774..000000000 --- a/vendor/golang.org/x/net/http2/h2demo/rootCA.pem +++ /dev/null @@ -1,26 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIEWjCCA0KgAwIBAgIJALfRlWsI8YQHMA0GCSqGSIb3DQEBBQUAMHsxCzAJBgNV -BAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEUMBIG -A1UEChMLQnJhZGZpdHppbmMxEjAQBgNVBAMTCWxvY2FsaG9zdDEdMBsGCSqGSIb3 -DQEJARYOYnJhZEBkYW5nYS5jb20wHhcNMTQwNzE1MjA0NjA1WhcNMTcwNTA0MjA0 -NjA1WjB7MQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDVNhbiBG -cmFuY2lzY28xFDASBgNVBAoTC0JyYWRmaXR6aW5jMRIwEAYDVQQDEwlsb2NhbGhv -c3QxHTAbBgkqhkiG9w0BCQEWDmJyYWRAZGFuZ2EuY29tMIIBIjANBgkqhkiG9w0B -AQEFAAOCAQ8AMIIBCgKCAQEAt5fAjp4fTcekWUTfzsp0kyih1OYbsGL0KX1eRbSS -R8Od0+9Q62Hyny+GFwMTb4A/KU8mssoHvcceSAAbwfbxFK/+s51TobqUnORZrOoT -ZjkUygbyXDSK99YBbcR1Pip8vwMTm4XKuLtCigeBBdjjAQdgUO28LENGlsMnmeYk -JfODVGnVmr5Ltb9ANA8IKyTfsnHJ4iOCS/PlPbUj2q7YnoVLposUBMlgUb/CykX3 -mOoLb4yJJQyA/iST6ZxiIEj36D4yWZ5lg7YJl+UiiBQHGCnPdGyipqV06ex0heYW -caiW8LWZSUQ93jQ+WVCH8hT7DQO1dmsvUmXlq/JeAlwQ/QIDAQABo4HgMIHdMB0G -A1UdDgQWBBRcAROthS4P4U7vTfjByC569R7E6DCBrQYDVR0jBIGlMIGigBRcAROt -hS4P4U7vTfjByC569R7E6KF/pH0wezELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNB -MRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMRQwEgYDVQQKEwtCcmFkZml0emluYzES -MBAGA1UEAxMJbG9jYWxob3N0MR0wGwYJKoZIhvcNAQkBFg5icmFkQGRhbmdhLmNv -bYIJALfRlWsI8YQHMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAG6h -U9f9sNH0/6oBbGGy2EVU0UgITUQIrFWo9rFkrW5k/XkDjQm+3lzjT0iGR4IxE/Ao -eU6sQhua7wrWeFEn47GL98lnCsJdD7oZNhFmQ95Tb/LnDUjs5Yj9brP0NWzXfYU4 -UK2ZnINJRcJpB8iRCaCxE8DdcUF0XqIEq6pA272snoLmiXLMvNl3kYEdm+je6voD -58SNVEUsztzQyXmJEhCpwVI0A6QCjzXj+qvpmw3ZZHi8JwXei8ZZBLTSFBki8Z7n -sH9BBH38/SzUmAN4QHSPy1gjqm00OAE8NaYDkh/bzE4d7mLGGMWp/WE3KPSu82HF -kPe6XoSbiLm/kxk32T0= ------END CERTIFICATE----- diff --git a/vendor/golang.org/x/net/http2/h2demo/rootCA.srl b/vendor/golang.org/x/net/http2/h2demo/rootCA.srl deleted file mode 100644 index 6db389188..000000000 --- a/vendor/golang.org/x/net/http2/h2demo/rootCA.srl +++ /dev/null @@ -1 +0,0 @@ -E2CE26BF3285059C diff --git a/vendor/golang.org/x/net/http2/h2demo/server.crt b/vendor/golang.org/x/net/http2/h2demo/server.crt deleted file mode 100644 index c59059bd6..000000000 --- a/vendor/golang.org/x/net/http2/h2demo/server.crt +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDPjCCAiYCCQDizia/MoUFnDANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJV -UzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28xFDASBgNVBAoT -C0JyYWRmaXR6aW5jMRIwEAYDVQQDEwlsb2NhbGhvc3QxHTAbBgkqhkiG9w0BCQEW -DmJyYWRAZGFuZ2EuY29tMB4XDTE0MDcxNTIwNTAyN1oXDTE1MTEyNzIwNTAyN1ow -RzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMQswCQYDVQQHEwJTRjEeMBwGA1UE -ChMVYnJhZGZpdHogaHR0cDIgc2VydmVyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A -MIIBCgKCAQEAs1Y9CyLFrdL8VQWN1WaifDqaZFnoqjHhCMlc1TfG2zA+InDifx2l -gZD3o8FeNnAcfM2sPlk3+ZleOYw9P/CklFVDlvqmpCv9ss/BEp/dDaWvy1LmJ4c2 -dbQJfmTxn7CV1H3TsVJvKdwFmdoABb41NoBp6+NNO7OtDyhbIMiCI0pL3Nefb3HL -A7hIMo3DYbORTtJLTIH9W8YKrEWL0lwHLrYFx/UdutZnv+HjdmO6vCN4na55mjws -/vjKQUmc7xeY7Xe20xDEG2oDKVkL2eD7FfyrYMS3rO1ExP2KSqlXYG/1S9I/fz88 -F0GK7HX55b5WjZCl2J3ERVdnv/0MQv+sYQIDAQABMA0GCSqGSIb3DQEBBQUAA4IB -AQC0zL+n/YpRZOdulSu9tS8FxrstXqGWoxfe+vIUgqfMZ5+0MkjJ/vW0FqlLDl2R -rn4XaR3e7FmWkwdDVbq/UB6lPmoAaFkCgh9/5oapMaclNVNnfF3fjCJfRr+qj/iD -EmJStTIN0ZuUjAlpiACmfnpEU55PafT5Zx+i1yE4FGjw8bJpFoyD4Hnm54nGjX19 -KeCuvcYFUPnBm3lcL0FalF2AjqV02WTHYNQk7YF/oeO7NKBoEgvGvKG3x+xaOeBI -dwvdq175ZsGul30h+QjrRlXhH/twcuaT3GSdoysDl9cCYE8f1Mk8PD6gan3uBCJU -90p6/CbU71bGbfpM2PHot2fm ------END CERTIFICATE----- diff --git a/vendor/golang.org/x/net/http2/h2demo/server.key b/vendor/golang.org/x/net/http2/h2demo/server.key deleted file mode 100644 index f329c1421..000000000 --- a/vendor/golang.org/x/net/http2/h2demo/server.key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEAs1Y9CyLFrdL8VQWN1WaifDqaZFnoqjHhCMlc1TfG2zA+InDi -fx2lgZD3o8FeNnAcfM2sPlk3+ZleOYw9P/CklFVDlvqmpCv9ss/BEp/dDaWvy1Lm -J4c2dbQJfmTxn7CV1H3TsVJvKdwFmdoABb41NoBp6+NNO7OtDyhbIMiCI0pL3Nef -b3HLA7hIMo3DYbORTtJLTIH9W8YKrEWL0lwHLrYFx/UdutZnv+HjdmO6vCN4na55 -mjws/vjKQUmc7xeY7Xe20xDEG2oDKVkL2eD7FfyrYMS3rO1ExP2KSqlXYG/1S9I/ -fz88F0GK7HX55b5WjZCl2J3ERVdnv/0MQv+sYQIDAQABAoIBADQ2spUwbY+bcz4p -3M66ECrNQTBggP40gYl2XyHxGGOu2xhZ94f9ELf1hjRWU2DUKWco1rJcdZClV6q3 -qwmXvcM2Q/SMS8JW0ImkNVl/0/NqPxGatEnj8zY30d/L8hGFb0orzFu/XYA5gCP4 -NbN2WrXgk3ZLeqwcNxHHtSiJWGJ/fPyeDWAu/apy75u9Xf2GlzBZmV6HYD9EfK80 -LTlI60f5FO487CrJnboL7ovPJrIHn+k05xRQqwma4orpz932rTXnTjs9Lg6KtbQN -a7PrqfAntIISgr11a66Mng3IYH1lYqJsWJJwX/xHT4WLEy0EH4/0+PfYemJekz2+ -Co62drECgYEA6O9zVJZXrLSDsIi54cfxA7nEZWm5CAtkYWeAHa4EJ+IlZ7gIf9sL -W8oFcEfFGpvwVqWZ+AsQ70dsjXAv3zXaG0tmg9FtqWp7pzRSMPidifZcQwWkKeTO -gJnFmnVyed8h6GfjTEu4gxo1/S5U0V+mYSha01z5NTnN6ltKx1Or3b0CgYEAxRgm -S30nZxnyg/V7ys61AZhst1DG2tkZXEMcA7dYhabMoXPJAP/EfhlWwpWYYUs/u0gS -Wwmf5IivX5TlYScgmkvb/NYz0u4ZmOXkLTnLPtdKKFXhjXJcHjUP67jYmOxNlJLp -V4vLRnFxTpffAV+OszzRxsXX6fvruwZBANYJeXUCgYBVouLFsFgfWGYp2rpr9XP4 -KK25kvrBqF6JKOIDB1zjxNJ3pUMKrl8oqccCFoCyXa4oTM2kUX0yWxHfleUjrMq4 -yimwQKiOZmV7fVLSSjSw6e/VfBd0h3gb82ygcplZkN0IclkwTY5SNKqwn/3y07V5 -drqdhkrgdJXtmQ6O5YYECQKBgATERcDToQ1USlI4sKrB/wyv1AlG8dg/IebiVJ4e -ZAyvcQmClFzq0qS+FiQUnB/WQw9TeeYrwGs1hxBHuJh16srwhLyDrbMvQP06qh8R -48F8UXXSRec22dV9MQphaROhu2qZdv1AC0WD3tqov6L33aqmEOi+xi8JgbT/PLk5 -c/c1AoGBAI1A/02ryksW6/wc7/6SP2M2rTy4m1sD/GnrTc67EHnRcVBdKO6qH2RY -nqC8YcveC2ZghgPTDsA3VGuzuBXpwY6wTyV99q6jxQJ6/xcrD9/NUG6Uwv/xfCxl -IJLeBYEqQundSSny3VtaAUK8Ul1nxpTvVRNwtcyWTo8RHAAyNPWd ------END RSA PRIVATE KEY----- diff --git a/vendor/golang.org/x/net/http2/h2demo/tmpl.go b/vendor/golang.org/x/net/http2/h2demo/tmpl.go deleted file mode 100644 index 504d6a78a..000000000 --- a/vendor/golang.org/x/net/http2/h2demo/tmpl.go +++ /dev/null @@ -1,1991 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build h2demo - -package main - -import "html/template" - -var pushTmpl = template.Must(template.New("serverpush").Parse(` - - - - - - - - - HTTP/2 Server Push Demo - - - - - - - - - -
    -Note: This page exists for demonstration purposes. For the actual cmd/go docs, go to golang.org/cmd/go. -
    - - - -
    -... -
    - - - - -
    -
    -
    -
    - Run - Format - - - -
    -
    - - -
    -
    - - -

    Command go

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

    -Go is a tool for managing Go source code. -

    -

    -Usage: -

    -
    go command [arguments]
    -
    -

    -The commands are: -

    -
    build       compile packages and dependencies
    -clean       remove object files
    -doc         show documentation for package or symbol
    -env         print Go environment information
    -bug         start a bug report
    -fix         run go tool fix on packages
    -fmt         run gofmt on package sources
    -generate    generate Go files by processing source
    -get         download and install packages and dependencies
    -install     compile and install packages and dependencies
    -list        list packages
    -run         compile and run Go program
    -test        test packages
    -tool        run specified go tool
    -version     print Go version
    -vet         run go tool vet on packages
    -
    -

    -Use "go help [command]" for more information about a command. -

    -

    -Additional help topics: -

    -
    c           calling between Go and C
    -buildmode   description of build modes
    -filetype    file types
    -gopath      GOPATH environment variable
    -environment environment variables
    -importpath  import path syntax
    -packages    description of package lists
    -testflag    description of testing flags
    -testfunc    description of testing functions
    -
    -

    -Use "go help [topic]" for more information about that topic. -

    -

    Compile packages and dependencies

    -

    -Usage: -

    -
    go build [-o output] [-i] [build flags] [packages]
    -
    -

    -Build compiles the packages named by the import paths, -along with their dependencies, but it does not install the results. -

    -

    -If the arguments to build are a list of .go files, build treats -them as a list of source files specifying a single package. -

    -

    -When compiling a single main package, build writes -the resulting executable to an output file named after -the first source file ('go build ed.go rx.go' writes 'ed' or 'ed.exe') -or the source code directory ('go build unix/sam' writes 'sam' or 'sam.exe'). -The '.exe' suffix is added when writing a Windows executable. -

    -

    -When compiling multiple packages or a single non-main package, -build compiles the packages but discards the resulting object, -serving only as a check that the packages can be built. -

    -

    -When compiling packages, build ignores files that end in '_test.go'. -

    -

    -The -o flag, only allowed when compiling a single package, -forces build to write the resulting executable or object -to the named output file, instead of the default behavior described -in the last two paragraphs. -

    -

    -The -i flag installs the packages that are dependencies of the target. -

    -

    -The build flags are shared by the build, clean, get, install, list, run, -and test commands: -

    -
    -a
    -	force rebuilding of packages that are already up-to-date.
    --n
    -	print the commands but do not run them.
    --p n
    -	the number of programs, such as build commands or
    -	test binaries, that can be run in parallel.
    -	The default is the number of CPUs available.
    --race
    -	enable data race detection.
    -	Supported only on linux/amd64, freebsd/amd64, darwin/amd64 and windows/amd64.
    --msan
    -	enable interoperation with memory sanitizer.
    -	Supported only on linux/amd64,
    -	and only with Clang/LLVM as the host C compiler.
    --v
    -	print the names of packages as they are compiled.
    --work
    -	print the name of the temporary work directory and
    -	do not delete it when exiting.
    --x
    -	print the commands.
    -
    --asmflags 'flag list'
    -	arguments to pass on each go tool asm invocation.
    --buildmode mode
    -	build mode to use. See 'go help buildmode' for more.
    --compiler name
    -	name of compiler to use, as in runtime.Compiler (gccgo or gc).
    --gccgoflags 'arg list'
    -	arguments to pass on each gccgo compiler/linker invocation.
    --gcflags 'arg list'
    -	arguments to pass on each go tool compile invocation.
    --installsuffix suffix
    -	a suffix to use in the name of the package installation directory,
    -	in order to keep output separate from default builds.
    -	If using the -race flag, the install suffix is automatically set to race
    -	or, if set explicitly, has _race appended to it.  Likewise for the -msan
    -	flag.  Using a -buildmode option that requires non-default compile flags
    -	has a similar effect.
    --ldflags 'flag list'
    -	arguments to pass on each go tool link invocation.
    --linkshared
    -	link against shared libraries previously created with
    -	-buildmode=shared.
    --pkgdir dir
    -	install and load all packages from dir instead of the usual locations.
    -	For example, when building with a non-standard configuration,
    -	use -pkgdir to keep generated packages in a separate location.
    --tags 'tag list'
    -	a list of build tags to consider satisfied during the build.
    -	For more information about build tags, see the description of
    -	build constraints in the documentation for the go/build package.
    --toolexec 'cmd args'
    -	a program to use to invoke toolchain programs like vet and asm.
    -	For example, instead of running asm, the go command will run
    -	'cmd args /path/to/asm <arguments for asm>'.
    -
    -

    -The list flags accept a space-separated list of strings. To embed spaces -in an element in the list, surround it with either single or double quotes. -

    -

    -For more about specifying packages, see 'go help packages'. -For more about where packages and binaries are installed, -run 'go help gopath'. -For more about calling between Go and C/C++, run 'go help c'. -

    -

    -Note: Build adheres to certain conventions such as those described -by 'go help gopath'. Not all projects can follow these conventions, -however. Installations that have their own conventions or that use -a separate software build system may choose to use lower-level -invocations such as 'go tool compile' and 'go tool link' to avoid -some of the overheads and design decisions of the build tool. -

    -

    -See also: go install, go get, go clean. -

    -

    Remove object files

    -

    -Usage: -

    -
    go clean [-i] [-r] [-n] [-x] [build flags] [packages]
    -
    -

    -Clean removes object files from package source directories. -The go command builds most objects in a temporary directory, -so go clean is mainly concerned with object files left by other -tools or by manual invocations of go build. -

    -

    -Specifically, clean removes the following files from each of the -source directories corresponding to the import paths: -

    -
    _obj/            old object directory, left from Makefiles
    -_test/           old test directory, left from Makefiles
    -_testmain.go     old gotest file, left from Makefiles
    -test.out         old test log, left from Makefiles
    -build.out        old test log, left from Makefiles
    -*.[568ao]        object files, left from Makefiles
    -
    -DIR(.exe)        from go build
    -DIR.test(.exe)   from go test -c
    -MAINFILE(.exe)   from go build MAINFILE.go
    -*.so             from SWIG
    -
    -

    -In the list, DIR represents the final path element of the -directory, and MAINFILE is the base name of any Go source -file in the directory that is not included when building -the package. -

    -

    -The -i flag causes clean to remove the corresponding installed -archive or binary (what 'go install' would create). -

    -

    -The -n flag causes clean to print the remove commands it would execute, -but not run them. -

    -

    -The -r flag causes clean to be applied recursively to all the -dependencies of the packages named by the import paths. -

    -

    -The -x flag causes clean to print remove commands as it executes them. -

    -

    -For more about build flags, see 'go help build'. -

    -

    -For more about specifying packages, see 'go help packages'. -

    -

    Show documentation for package or symbol

    -

    -Usage: -

    -
    go doc [-u] [-c] [package|[package.]symbol[.method]]
    -
    -

    -Doc prints the documentation comments associated with the item identified by its -arguments (a package, const, func, type, var, or method) followed by a one-line -summary of each of the first-level items "under" that item (package-level -declarations for a package, methods for a type, etc.). -

    -

    -Doc accepts zero, one, or two arguments. -

    -

    -Given no arguments, that is, when run as -

    -
    go doc
    -
    -

    -it prints the package documentation for the package in the current directory. -If the package is a command (package main), the exported symbols of the package -are elided from the presentation unless the -cmd flag is provided. -

    -

    -When run with one argument, the argument is treated as a Go-syntax-like -representation of the item to be documented. What the argument selects depends -on what is installed in GOROOT and GOPATH, as well as the form of the argument, -which is schematically one of these: -

    -
    go doc <pkg>
    -go doc <sym>[.<method>]
    -go doc [<pkg>.]<sym>[.<method>]
    -go doc [<pkg>.][<sym>.]<method>
    -
    -

    -The first item in this list matched by the argument is the one whose documentation -is printed. (See the examples below.) However, if the argument starts with a capital -letter it is assumed to identify a symbol or method in the current directory. -

    -

    -For packages, the order of scanning is determined lexically in breadth-first order. -That is, the package presented is the one that matches the search and is nearest -the root and lexically first at its level of the hierarchy. The GOROOT tree is -always scanned in its entirety before GOPATH. -

    -

    -If there is no package specified or matched, the package in the current -directory is selected, so "go doc Foo" shows the documentation for symbol Foo in -the current package. -

    -

    -The package path must be either a qualified path or a proper suffix of a -path. The go tool's usual package mechanism does not apply: package path -elements like . and ... are not implemented by go doc. -

    -

    -When run with two arguments, the first must be a full package path (not just a -suffix), and the second is a symbol or symbol and method; this is similar to the -syntax accepted by godoc: -

    -
    go doc <pkg> <sym>[.<method>]
    -
    -

    -In all forms, when matching symbols, lower-case letters in the argument match -either case but upper-case letters match exactly. This means that there may be -multiple matches of a lower-case argument in a package if different symbols have -different cases. If this occurs, documentation for all matches is printed. -

    -

    -Examples: -

    -
    go doc
    -	Show documentation for current package.
    -go doc Foo
    -	Show documentation for Foo in the current package.
    -	(Foo starts with a capital letter so it cannot match
    -	a package path.)
    -go doc encoding/json
    -	Show documentation for the encoding/json package.
    -go doc json
    -	Shorthand for encoding/json.
    -go doc json.Number (or go doc json.number)
    -	Show documentation and method summary for json.Number.
    -go doc json.Number.Int64 (or go doc json.number.int64)
    -	Show documentation for json.Number's Int64 method.
    -go doc cmd/doc
    -	Show package docs for the doc command.
    -go doc -cmd cmd/doc
    -	Show package docs and exported symbols within the doc command.
    -go doc template.new
    -	Show documentation for html/template's New function.
    -	(html/template is lexically before text/template)
    -go doc text/template.new # One argument
    -	Show documentation for text/template's New function.
    -go doc text/template new # Two arguments
    -	Show documentation for text/template's New function.
    -
    -At least in the current tree, these invocations all print the
    -documentation for json.Decoder's Decode method:
    -
    -go doc json.Decoder.Decode
    -go doc json.decoder.decode
    -go doc json.decode
    -cd go/src/encoding/json; go doc decode
    -
    -

    -Flags: -

    -
    -c
    -	Respect case when matching symbols.
    --cmd
    -	Treat a command (package main) like a regular package.
    -	Otherwise package main's exported symbols are hidden
    -	when showing the package's top-level documentation.
    --u
    -	Show documentation for unexported as well as exported
    -	symbols and methods.
    -
    -

    Print Go environment information

    -

    -Usage: -

    -
    go env [var ...]
    -
    -

    -Env prints Go environment information. -

    -

    -By default env prints information as a shell script -(on Windows, a batch file). If one or more variable -names is given as arguments, env prints the value of -each named variable on its own line. -

    -

    Start a bug report

    -

    -Usage: -

    -
    go bug
    -
    -

    -Bug opens the default browser and starts a new bug report. -The report includes useful system information. -

    -

    Run go tool fix on packages

    -

    -Usage: -

    -
    go fix [packages]
    -
    -

    -Fix runs the Go fix command on the packages named by the import paths. -

    -

    -For more about fix, see 'go doc cmd/fix'. -For more about specifying packages, see 'go help packages'. -

    -

    -To run fix with specific options, run 'go tool fix'. -

    -

    -See also: go fmt, go vet. -

    -

    Run gofmt on package sources

    -

    -Usage: -

    -
    go fmt [-n] [-x] [packages]
    -
    -

    -Fmt runs the command 'gofmt -l -w' on the packages named -by the import paths. It prints the names of the files that are modified. -

    -

    -For more about gofmt, see 'go doc cmd/gofmt'. -For more about specifying packages, see 'go help packages'. -

    -

    -The -n flag prints commands that would be executed. -The -x flag prints commands as they are executed. -

    -

    -To run gofmt with specific options, run gofmt itself. -

    -

    -See also: go fix, go vet. -

    -

    Generate Go files by processing source

    -

    -Usage: -

    -
    go generate [-run regexp] [-n] [-v] [-x] [build flags] [file.go... | packages]
    -
    -

    -Generate runs commands described by directives within existing -files. Those commands can run any process but the intent is to -create or update Go source files. -

    -

    -Go generate is never run automatically by go build, go get, go test, -and so on. It must be run explicitly. -

    -

    -Go generate scans the file for directives, which are lines of -the form, -

    -
    //go:generate command argument...
    -
    -

    -(note: no leading spaces and no space in "//go") where command -is the generator to be run, corresponding to an executable file -that can be run locally. It must either be in the shell path -(gofmt), a fully qualified path (/usr/you/bin/mytool), or a -command alias, described below. -

    -

    -Note that go generate does not parse the file, so lines that look -like directives in comments or multiline strings will be treated -as directives. -

    -

    -The arguments to the directive are space-separated tokens or -double-quoted strings passed to the generator as individual -arguments when it is run. -

    -

    -Quoted strings use Go syntax and are evaluated before execution; a -quoted string appears as a single argument to the generator. -

    -

    -Go generate sets several variables when it runs the generator: -

    -
    $GOARCH
    -	The execution architecture (arm, amd64, etc.)
    -$GOOS
    -	The execution operating system (linux, windows, etc.)
    -$GOFILE
    -	The base name of the file.
    -$GOLINE
    -	The line number of the directive in the source file.
    -$GOPACKAGE
    -	The name of the package of the file containing the directive.
    -$DOLLAR
    -	A dollar sign.
    -
    -

    -Other than variable substitution and quoted-string evaluation, no -special processing such as "globbing" is performed on the command -line. -

    -

    -As a last step before running the command, any invocations of any -environment variables with alphanumeric names, such as $GOFILE or -$HOME, are expanded throughout the command line. The syntax for -variable expansion is $NAME on all operating systems. Due to the -order of evaluation, variables are expanded even inside quoted -strings. If the variable NAME is not set, $NAME expands to the -empty string. -

    -

    -A directive of the form, -

    -
    //go:generate -command xxx args...
    -
    -

    -specifies, for the remainder of this source file only, that the -string xxx represents the command identified by the arguments. This -can be used to create aliases or to handle multiword generators. -For example, -

    -
    //go:generate -command foo go tool foo
    -
    -

    -specifies that the command "foo" represents the generator -"go tool foo". -

    -

    -Generate processes packages in the order given on the command line, -one at a time. If the command line lists .go files, they are treated -as a single package. Within a package, generate processes the -source files in a package in file name order, one at a time. Within -a source file, generate runs generators in the order they appear -in the file, one at a time. -

    -

    -If any generator returns an error exit status, "go generate" skips -all further processing for that package. -

    -

    -The generator is run in the package's source directory. -

    -

    -Go generate accepts one specific flag: -

    -
    -run=""
    -	if non-empty, specifies a regular expression to select
    -	directives whose full original source text (excluding
    -	any trailing spaces and final newline) matches the
    -	expression.
    -
    -

    -It also accepts the standard build flags including -v, -n, and -x. -The -v flag prints the names of packages and files as they are -processed. -The -n flag prints commands that would be executed. -The -x flag prints commands as they are executed. -

    -

    -For more about build flags, see 'go help build'. -

    -

    -For more about specifying packages, see 'go help packages'. -

    -

    Download and install packages and dependencies

    -

    -Usage: -

    -
    go get [-d] [-f] [-fix] [-insecure] [-t] [-u] [build flags] [packages]
    -
    -

    -Get downloads the packages named by the import paths, along with their -dependencies. It then installs the named packages, like 'go install'. -

    -

    -The -d flag instructs get to stop after downloading the packages; that is, -it instructs get not to install the packages. -

    -

    -The -f flag, valid only when -u is set, forces get -u not to verify that -each package has been checked out from the source control repository -implied by its import path. This can be useful if the source is a local fork -of the original. -

    -

    -The -fix flag instructs get to run the fix tool on the downloaded packages -before resolving dependencies or building the code. -

    -

    -The -insecure flag permits fetching from repositories and resolving -custom domains using insecure schemes such as HTTP. Use with caution. -

    -

    -The -t flag instructs get to also download the packages required to build -the tests for the specified packages. -

    -

    -The -u flag instructs get to use the network to update the named packages -and their dependencies. By default, get uses the network to check out -missing packages but does not use it to look for updates to existing packages. -

    -

    -The -v flag enables verbose progress and debug output. -

    -

    -Get also accepts build flags to control the installation. See 'go help build'. -

    -

    -When checking out a new package, get creates the target directory -GOPATH/src/<import-path>. If the GOPATH contains multiple entries, -get uses the first one. For more details see: 'go help gopath'. -

    -

    -When checking out or updating a package, get looks for a branch or tag -that matches the locally installed version of Go. The most important -rule is that if the local installation is running version "go1", get -searches for a branch or tag named "go1". If no such version exists it -retrieves the most recent version of the package. -

    -

    -When go get checks out or updates a Git repository, -it also updates any git submodules referenced by the repository. -

    -

    -Get never checks out or updates code stored in vendor directories. -

    -

    -For more about specifying packages, see 'go help packages'. -

    -

    -For more about how 'go get' finds source code to -download, see 'go help importpath'. -

    -

    -See also: go build, go install, go clean. -

    -

    Compile and install packages and dependencies

    -

    -Usage: -

    -
    go install [build flags] [packages]
    -
    -

    -Install compiles and installs the packages named by the import paths, -along with their dependencies. -

    -

    -For more about the build flags, see 'go help build'. -For more about specifying packages, see 'go help packages'. -

    -

    -See also: go build, go get, go clean. -

    -

    List packages

    -

    -Usage: -

    -
    go list [-e] [-f format] [-json] [build flags] [packages]
    -
    -

    -List lists the packages named by the import paths, one per line. -

    -

    -The default output shows the package import path: -

    -
    bytes
    -encoding/json
    -github.com/gorilla/mux
    -golang.org/x/net/html
    -
    -

    -The -f flag specifies an alternate format for the list, using the -syntax of package template. The default output is equivalent to -f -''. The struct being passed to the template is: -

    -
    type Package struct {
    -    Dir           string // directory containing package sources
    -    ImportPath    string // import path of package in dir
    -    ImportComment string // path in import comment on package statement
    -    Name          string // package name
    -    Doc           string // package documentation string
    -    Target        string // install path
    -    Shlib         string // the shared library that contains this package (only set when -linkshared)
    -    Goroot        bool   // is this package in the Go root?
    -    Standard      bool   // is this package part of the standard Go library?
    -    Stale         bool   // would 'go install' do anything for this package?
    -    StaleReason   string // explanation for Stale==true
    -    Root          string // Go root or Go path dir containing this package
    -    ConflictDir   string // this directory shadows Dir in $GOPATH
    -    BinaryOnly    bool   // binary-only package: cannot be recompiled from sources
    -
    -    // Source files
    -    GoFiles        []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
    -    CgoFiles       []string // .go sources files that import "C"
    -    IgnoredGoFiles []string // .go sources ignored due to build constraints
    -    CFiles         []string // .c source files
    -    CXXFiles       []string // .cc, .cxx and .cpp source files
    -    MFiles         []string // .m source files
    -    HFiles         []string // .h, .hh, .hpp and .hxx source files
    -    FFiles         []string // .f, .F, .for and .f90 Fortran source files
    -    SFiles         []string // .s source files
    -    SwigFiles      []string // .swig files
    -    SwigCXXFiles   []string // .swigcxx files
    -    SysoFiles      []string // .syso object files to add to archive
    -    TestGoFiles    []string // _test.go files in package
    -    XTestGoFiles   []string // _test.go files outside package
    -
    -    // Cgo directives
    -    CgoCFLAGS    []string // cgo: flags for C compiler
    -    CgoCPPFLAGS  []string // cgo: flags for C preprocessor
    -    CgoCXXFLAGS  []string // cgo: flags for C++ compiler
    -    CgoFFLAGS    []string // cgo: flags for Fortran compiler
    -    CgoLDFLAGS   []string // cgo: flags for linker
    -    CgoPkgConfig []string // cgo: pkg-config names
    -
    -    // Dependency information
    -    Imports      []string // import paths used by this package
    -    Deps         []string // all (recursively) imported dependencies
    -    TestImports  []string // imports from TestGoFiles
    -    XTestImports []string // imports from XTestGoFiles
    -
    -    // Error information
    -    Incomplete bool            // this package or a dependency has an error
    -    Error      *PackageError   // error loading package
    -    DepsErrors []*PackageError // errors loading dependencies
    -}
    -
    -

    -Packages stored in vendor directories report an ImportPath that includes the -path to the vendor directory (for example, "d/vendor/p" instead of "p"), -so that the ImportPath uniquely identifies a given copy of a package. -The Imports, Deps, TestImports, and XTestImports lists also contain these -expanded imports paths. See golang.org/s/go15vendor for more about vendoring. -

    -

    -The error information, if any, is -

    -
    type PackageError struct {
    -    ImportStack   []string // shortest path from package named on command line to this one
    -    Pos           string   // position of error (if present, file:line:col)
    -    Err           string   // the error itself
    -}
    -
    -

    -The template function "join" calls strings.Join. -

    -

    -The template function "context" returns the build context, defined as: -

    -
    type Context struct {
    -	GOARCH        string   // target architecture
    -	GOOS          string   // target operating system
    -	GOROOT        string   // Go root
    -	GOPATH        string   // Go path
    -	CgoEnabled    bool     // whether cgo can be used
    -	UseAllFiles   bool     // use files regardless of +build lines, file names
    -	Compiler      string   // compiler to assume when computing target paths
    -	BuildTags     []string // build constraints to match in +build lines
    -	ReleaseTags   []string // releases the current release is compatible with
    -	InstallSuffix string   // suffix to use in the name of the install dir
    -}
    -
    -

    -For more information about the meaning of these fields see the documentation -for the go/build package's Context type. -

    -

    -The -json flag causes the package data to be printed in JSON format -instead of using the template format. -

    -

    -The -e flag changes the handling of erroneous packages, those that -cannot be found or are malformed. By default, the list command -prints an error to standard error for each erroneous package and -omits the packages from consideration during the usual printing. -With the -e flag, the list command never prints errors to standard -error and instead processes the erroneous packages with the usual -printing. Erroneous packages will have a non-empty ImportPath and -a non-nil Error field; other information may or may not be missing -(zeroed). -

    -

    -For more about build flags, see 'go help build'. -

    -

    -For more about specifying packages, see 'go help packages'. -

    -

    Compile and run Go program

    -

    -Usage: -

    -
    go run [build flags] [-exec xprog] gofiles... [arguments...]
    -
    -

    -Run compiles and runs the main package comprising the named Go source files. -A Go source file is defined to be a file ending in a literal ".go" suffix. -

    -

    -By default, 'go run' runs the compiled binary directly: 'a.out arguments...'. -If the -exec flag is given, 'go run' invokes the binary using xprog: -

    -
    'xprog a.out arguments...'.
    -
    -

    -If the -exec flag is not given, GOOS or GOARCH is different from the system -default, and a program named go_$GOOS_$GOARCH_exec can be found -on the current search path, 'go run' invokes the binary using that program, -for example 'go_nacl_386_exec a.out arguments...'. This allows execution of -cross-compiled programs when a simulator or other execution method is -available. -

    -

    -For more about build flags, see 'go help build'. -

    -

    -See also: go build. -

    -

    Test packages

    -

    -Usage: -

    -
    go test [build/test flags] [packages] [build/test flags & test binary flags]
    -
    -

    -'Go test' automates testing the packages named by the import paths. -It prints a summary of the test results in the format: -

    -
    ok   archive/tar   0.011s
    -FAIL archive/zip   0.022s
    -ok   compress/gzip 0.033s
    -...
    -
    -

    -followed by detailed output for each failed package. -

    -

    -'Go test' recompiles each package along with any files with names matching -the file pattern "*_test.go". -Files whose names begin with "_" (including "_test.go") or "." are ignored. -These additional files can contain test functions, benchmark functions, and -example functions. See 'go help testfunc' for more. -Each listed package causes the execution of a separate test binary. -

    -

    -Test files that declare a package with the suffix "_test" will be compiled as a -separate package, and then linked and run with the main test binary. -

    -

    -The go tool will ignore a directory named "testdata", making it available -to hold ancillary data needed by the tests. -

    -

    -By default, go test needs no arguments. It compiles and tests the package -with source in the current directory, including tests, and runs the tests. -

    -

    -The package is built in a temporary directory so it does not interfere with the -non-test installation. -

    -

    -In addition to the build flags, the flags handled by 'go test' itself are: -

    -
    -args
    -    Pass the remainder of the command line (everything after -args)
    -    to the test binary, uninterpreted and unchanged.
    -    Because this flag consumes the remainder of the command line,
    -    the package list (if present) must appear before this flag.
    -
    --c
    -    Compile the test binary to pkg.test but do not run it
    -    (where pkg is the last element of the package's import path).
    -    The file name can be changed with the -o flag.
    -
    --exec xprog
    -    Run the test binary using xprog. The behavior is the same as
    -    in 'go run'. See 'go help run' for details.
    -
    --i
    -    Install packages that are dependencies of the test.
    -    Do not run the test.
    -
    --o file
    -    Compile the test binary to the named file.
    -    The test still runs (unless -c or -i is specified).
    -
    -

    -The test binary also accepts flags that control execution of the test; these -flags are also accessible by 'go test'. See 'go help testflag' for details. -

    -

    -For more about build flags, see 'go help build'. -For more about specifying packages, see 'go help packages'. -

    -

    -See also: go build, go vet. -

    -

    Run specified go tool

    -

    -Usage: -

    -
    go tool [-n] command [args...]
    -
    -

    -Tool runs the go tool command identified by the arguments. -With no arguments it prints the list of known tools. -

    -

    -The -n flag causes tool to print the command that would be -executed but not execute it. -

    -

    -For more about each tool command, see 'go tool command -h'. -

    -

    Print Go version

    -

    -Usage: -

    -
    go version
    -
    -

    -Version prints the Go version, as reported by runtime.Version. -

    -

    Run go tool vet on packages

    -

    -Usage: -

    -
    go vet [-n] [-x] [build flags] [packages]
    -
    -

    -Vet runs the Go vet command on the packages named by the import paths. -

    -

    -For more about vet, see 'go doc cmd/vet'. -For more about specifying packages, see 'go help packages'. -

    -

    -To run the vet tool with specific options, run 'go tool vet'. -

    -

    -The -n flag prints commands that would be executed. -The -x flag prints commands as they are executed. -

    -

    -For more about build flags, see 'go help build'. -

    -

    -See also: go fmt, go fix. -

    -

    Calling between Go and C

    -

    -There are two different ways to call between Go and C/C++ code. -

    -

    -The first is the cgo tool, which is part of the Go distribution. For -information on how to use it see the cgo documentation (go doc cmd/cgo). -

    -

    -The second is the SWIG program, which is a general tool for -interfacing between languages. For information on SWIG see -http://swig.org/. When running go build, any file with a .swig -extension will be passed to SWIG. Any file with a .swigcxx extension -will be passed to SWIG with the -c++ option. -

    -

    -When either cgo or SWIG is used, go build will pass any .c, .m, .s, -or .S files to the C compiler, and any .cc, .cpp, .cxx files to the C++ -compiler. The CC or CXX environment variables may be set to determine -the C or C++ compiler, respectively, to use. -

    -

    Description of build modes

    -

    -The 'go build' and 'go install' commands take a -buildmode argument which -indicates which kind of object file is to be built. Currently supported values -are: -

    -
    -buildmode=archive
    -	Build the listed non-main packages into .a files. Packages named
    -	main are ignored.
    -
    --buildmode=c-archive
    -	Build the listed main package, plus all packages it imports,
    -	into a C archive file. The only callable symbols will be those
    -	functions exported using a cgo //export comment. Requires
    -	exactly one main package to be listed.
    -
    --buildmode=c-shared
    -	Build the listed main packages, plus all packages that they
    -	import, into C shared libraries. The only callable symbols will
    -	be those functions exported using a cgo //export comment.
    -	Non-main packages are ignored.
    -
    --buildmode=default
    -	Listed main packages are built into executables and listed
    -	non-main packages are built into .a files (the default
    -	behavior).
    -
    --buildmode=shared
    -	Combine all the listed non-main packages into a single shared
    -	library that will be used when building with the -linkshared
    -	option. Packages named main are ignored.
    -
    --buildmode=exe
    -	Build the listed main packages and everything they import into
    -	executables. Packages not named main are ignored.
    -
    --buildmode=pie
    -	Build the listed main packages and everything they import into
    -	position independent executables (PIE). Packages not named
    -	main are ignored.
    -
    --buildmode=plugin
    -	Build the listed main packages, plus all packages that they
    -	import, into a Go plugin. Packages not named main are ignored.
    -
    -

    File types

    -

    -The go command examines the contents of a restricted set of files -in each directory. It identifies which files to examine based on -the extension of the file name. These extensions are: -

    -
    .go
    -	Go source files.
    -.c, .h
    -	C source files.
    -	If the package uses cgo or SWIG, these will be compiled with the
    -	OS-native compiler (typically gcc); otherwise they will
    -	trigger an error.
    -.cc, .cpp, .cxx, .hh, .hpp, .hxx
    -	C++ source files. Only useful with cgo or SWIG, and always
    -	compiled with the OS-native compiler.
    -.m
    -	Objective-C source files. Only useful with cgo, and always
    -	compiled with the OS-native compiler.
    -.s, .S
    -	Assembler source files.
    -	If the package uses cgo or SWIG, these will be assembled with the
    -	OS-native assembler (typically gcc (sic)); otherwise they
    -	will be assembled with the Go assembler.
    -.swig, .swigcxx
    -	SWIG definition files.
    -.syso
    -	System object files.
    -
    -

    -Files of each of these types except .syso may contain build -constraints, but the go command stops scanning for build constraints -at the first item in the file that is not a blank line or //-style -line comment. See the go/build package documentation for -more details. -

    -

    -Non-test Go source files can also include a //go:binary-only-package -comment, indicating that the package sources are included -for documentation only and must not be used to build the -package binary. This enables distribution of Go packages in -their compiled form alone. See the go/build package documentation -for more details. -

    -

    GOPATH environment variable

    -

    -The Go path is used to resolve import statements. -It is implemented by and documented in the go/build package. -

    -

    -The GOPATH environment variable lists places to look for Go code. -On Unix, the value is a colon-separated string. -On Windows, the value is a semicolon-separated string. -On Plan 9, the value is a list. -

    -

    -If the environment variable is unset, GOPATH defaults -to a subdirectory named "go" in the user's home directory -($HOME/go on Unix, %USERPROFILE%\go on Windows), -unless that directory holds a Go distribution. -Run "go env GOPATH" to see the current GOPATH. -

    -

    -See https://golang.org/wiki/SettingGOPATH to set a custom GOPATH. -

    -

    -Each directory listed in GOPATH must have a prescribed structure: -

    -

    -The src directory holds source code. The path below src -determines the import path or executable name. -

    -

    -The pkg directory holds installed package objects. -As in the Go tree, each target operating system and -architecture pair has its own subdirectory of pkg -(pkg/GOOS_GOARCH). -

    -

    -If DIR is a directory listed in the GOPATH, a package with -source in DIR/src/foo/bar can be imported as "foo/bar" and -has its compiled form installed to "DIR/pkg/GOOS_GOARCH/foo/bar.a". -

    -

    -The bin directory holds compiled commands. -Each command is named for its source directory, but only -the final element, not the entire path. That is, the -command with source in DIR/src/foo/quux is installed into -DIR/bin/quux, not DIR/bin/foo/quux. The "foo/" prefix is stripped -so that you can add DIR/bin to your PATH to get at the -installed commands. If the GOBIN environment variable is -set, commands are installed to the directory it names instead -of DIR/bin. GOBIN must be an absolute path. -

    -

    -Here's an example directory layout: -

    -
    GOPATH=/home/user/go
    -
    -/home/user/go/
    -    src/
    -        foo/
    -            bar/               (go code in package bar)
    -                x.go
    -            quux/              (go code in package main)
    -                y.go
    -    bin/
    -        quux                   (installed command)
    -    pkg/
    -        linux_amd64/
    -            foo/
    -                bar.a          (installed package object)
    -
    -

    -Go searches each directory listed in GOPATH to find source code, -but new packages are always downloaded into the first directory -in the list. -

    -

    -See https://golang.org/doc/code.html for an example. -

    -

    Internal Directories

    -

    -Code in or below a directory named "internal" is importable only -by code in the directory tree rooted at the parent of "internal". -Here's an extended version of the directory layout above: -

    -
    /home/user/go/
    -    src/
    -        crash/
    -            bang/              (go code in package bang)
    -                b.go
    -        foo/                   (go code in package foo)
    -            f.go
    -            bar/               (go code in package bar)
    -                x.go
    -            internal/
    -                baz/           (go code in package baz)
    -                    z.go
    -            quux/              (go code in package main)
    -                y.go
    -
    -

    -The code in z.go is imported as "foo/internal/baz", but that -import statement can only appear in source files in the subtree -rooted at foo. The source files foo/f.go, foo/bar/x.go, and -foo/quux/y.go can all import "foo/internal/baz", but the source file -crash/bang/b.go cannot. -

    -

    -See https://golang.org/s/go14internal for details. -

    -

    Vendor Directories

    -

    -Go 1.6 includes support for using local copies of external dependencies -to satisfy imports of those dependencies, often referred to as vendoring. -

    -

    -Code below a directory named "vendor" is importable only -by code in the directory tree rooted at the parent of "vendor", -and only using an import path that omits the prefix up to and -including the vendor element. -

    -

    -Here's the example from the previous section, -but with the "internal" directory renamed to "vendor" -and a new foo/vendor/crash/bang directory added: -

    -
    /home/user/go/
    -    src/
    -        crash/
    -            bang/              (go code in package bang)
    -                b.go
    -        foo/                   (go code in package foo)
    -            f.go
    -            bar/               (go code in package bar)
    -                x.go
    -            vendor/
    -                crash/
    -                    bang/      (go code in package bang)
    -                        b.go
    -                baz/           (go code in package baz)
    -                    z.go
    -            quux/              (go code in package main)
    -                y.go
    -
    -

    -The same visibility rules apply as for internal, but the code -in z.go is imported as "baz", not as "foo/vendor/baz". -

    -

    -Code in vendor directories deeper in the source tree shadows -code in higher directories. Within the subtree rooted at foo, an import -of "crash/bang" resolves to "foo/vendor/crash/bang", not the -top-level "crash/bang". -

    -

    -Code in vendor directories is not subject to import path -checking (see 'go help importpath'). -

    -

    -When 'go get' checks out or updates a git repository, it now also -updates submodules. -

    -

    -Vendor directories do not affect the placement of new repositories -being checked out for the first time by 'go get': those are always -placed in the main GOPATH, never in a vendor subtree. -

    -

    -See https://golang.org/s/go15vendor for details. -

    -

    Environment variables

    -

    -The go command, and the tools it invokes, examine a few different -environment variables. For many of these, you can see the default -value of on your system by running 'go env NAME', where NAME is the -name of the variable. -

    -

    -General-purpose environment variables: -

    -
    GCCGO
    -	The gccgo command to run for 'go build -compiler=gccgo'.
    -GOARCH
    -	The architecture, or processor, for which to compile code.
    -	Examples are amd64, 386, arm, ppc64.
    -GOBIN
    -	The directory where 'go install' will install a command.
    -GOOS
    -	The operating system for which to compile code.
    -	Examples are linux, darwin, windows, netbsd.
    -GOPATH
    -	For more details see: 'go help gopath'.
    -GORACE
    -	Options for the race detector.
    -	See https://golang.org/doc/articles/race_detector.html.
    -GOROOT
    -	The root of the go tree.
    -
    -

    -Environment variables for use with cgo: -

    -
    CC
    -	The command to use to compile C code.
    -CGO_ENABLED
    -	Whether the cgo command is supported.  Either 0 or 1.
    -CGO_CFLAGS
    -	Flags that cgo will pass to the compiler when compiling
    -	C code.
    -CGO_CPPFLAGS
    -	Flags that cgo will pass to the compiler when compiling
    -	C or C++ code.
    -CGO_CXXFLAGS
    -	Flags that cgo will pass to the compiler when compiling
    -	C++ code.
    -CGO_FFLAGS
    -	Flags that cgo will pass to the compiler when compiling
    -	Fortran code.
    -CGO_LDFLAGS
    -	Flags that cgo will pass to the compiler when linking.
    -CXX
    -	The command to use to compile C++ code.
    -PKG_CONFIG
    -	Path to pkg-config tool.
    -
    -

    -Architecture-specific environment variables: -

    -
    GOARM
    -	For GOARCH=arm, the ARM architecture for which to compile.
    -	Valid values are 5, 6, 7.
    -GO386
    -	For GOARCH=386, the floating point instruction set.
    -	Valid values are 387, sse2.
    -
    -

    -Special-purpose environment variables: -

    -
    GOROOT_FINAL
    -	The root of the installed Go tree, when it is
    -	installed in a location other than where it is built.
    -	File names in stack traces are rewritten from GOROOT to
    -	GOROOT_FINAL.
    -GO_EXTLINK_ENABLED
    -	Whether the linker should use external linking mode
    -	when using -linkmode=auto with code that uses cgo.
    -	Set to 0 to disable external linking mode, 1 to enable it.
    -GIT_ALLOW_PROTOCOL
    -	Defined by Git. A colon-separated list of schemes that are allowed to be used
    -	with git fetch/clone. If set, any scheme not explicitly mentioned will be
    -	considered insecure by 'go get'.
    -
    -

    Import path syntax

    -

    -An import path (see 'go help packages') denotes a package stored in the local -file system. In general, an import path denotes either a standard package (such -as "unicode/utf8") or a package found in one of the work spaces (For more -details see: 'go help gopath'). -

    -

    Relative import paths

    -

    -An import path beginning with ./ or ../ is called a relative path. -The toolchain supports relative import paths as a shortcut in two ways. -

    -

    -First, a relative path can be used as a shorthand on the command line. -If you are working in the directory containing the code imported as -"unicode" and want to run the tests for "unicode/utf8", you can type -"go test ./utf8" instead of needing to specify the full path. -Similarly, in the reverse situation, "go test .." will test "unicode" from -the "unicode/utf8" directory. Relative patterns are also allowed, like -"go test ./..." to test all subdirectories. See 'go help packages' for details -on the pattern syntax. -

    -

    -Second, if you are compiling a Go program not in a work space, -you can use a relative path in an import statement in that program -to refer to nearby code also not in a work space. -This makes it easy to experiment with small multipackage programs -outside of the usual work spaces, but such programs cannot be -installed with "go install" (there is no work space in which to install them), -so they are rebuilt from scratch each time they are built. -To avoid ambiguity, Go programs cannot use relative import paths -within a work space. -

    -

    Remote import paths

    -

    -Certain import paths also -describe how to obtain the source code for the package using -a revision control system. -

    -

    -A few common code hosting sites have special syntax: -

    -
    Bitbucket (Git, Mercurial)
    -
    -	import "bitbucket.org/user/project"
    -	import "bitbucket.org/user/project/sub/directory"
    -
    -GitHub (Git)
    -
    -	import "github.com/user/project"
    -	import "github.com/user/project/sub/directory"
    -
    -Launchpad (Bazaar)
    -
    -	import "launchpad.net/project"
    -	import "launchpad.net/project/series"
    -	import "launchpad.net/project/series/sub/directory"
    -
    -	import "launchpad.net/~user/project/branch"
    -	import "launchpad.net/~user/project/branch/sub/directory"
    -
    -IBM DevOps Services (Git)
    -
    -	import "hub.jazz.net/git/user/project"
    -	import "hub.jazz.net/git/user/project/sub/directory"
    -
    -

    -For code hosted on other servers, import paths may either be qualified -with the version control type, or the go tool can dynamically fetch -the import path over https/http and discover where the code resides -from a <meta> tag in the HTML. -

    -

    -To declare the code location, an import path of the form -

    -
    repository.vcs/path
    -
    -

    -specifies the given repository, with or without the .vcs suffix, -using the named version control system, and then the path inside -that repository. The supported version control systems are: -

    -
    Bazaar      .bzr
    -Git         .git
    -Mercurial   .hg
    -Subversion  .svn
    -
    -

    -For example, -

    -
    import "example.org/user/foo.hg"
    -
    -

    -denotes the root directory of the Mercurial repository at -example.org/user/foo or foo.hg, and -

    -
    import "example.org/repo.git/foo/bar"
    -
    -

    -denotes the foo/bar directory of the Git repository at -example.org/repo or repo.git. -

    -

    -When a version control system supports multiple protocols, -each is tried in turn when downloading. For example, a Git -download tries https://, then git+ssh://. -

    -

    -By default, downloads are restricted to known secure protocols -(e.g. https, ssh). To override this setting for Git downloads, the -GIT_ALLOW_PROTOCOL environment variable can be set (For more details see: -'go help environment'). -

    -

    -If the import path is not a known code hosting site and also lacks a -version control qualifier, the go tool attempts to fetch the import -over https/http and looks for a <meta> tag in the document's HTML -<head>. -

    -

    -The meta tag has the form: -

    -
    <meta name="go-import" content="import-prefix vcs repo-root">
    -
    -

    -The import-prefix is the import path corresponding to the repository -root. It must be a prefix or an exact match of the package being -fetched with "go get". If it's not an exact match, another http -request is made at the prefix to verify the <meta> tags match. -

    -

    -The meta tag should appear as early in the file as possible. -In particular, it should appear before any raw JavaScript or CSS, -to avoid confusing the go command's restricted parser. -

    -

    -The vcs is one of "git", "hg", "svn", etc, -

    -

    -The repo-root is the root of the version control system -containing a scheme and not containing a .vcs qualifier. -

    -

    -For example, -

    -
    import "example.org/pkg/foo"
    -
    -

    -will result in the following requests: -

    -
    https://example.org/pkg/foo?go-get=1 (preferred)
    -http://example.org/pkg/foo?go-get=1  (fallback, only with -insecure)
    -
    -

    -If that page contains the meta tag -

    -
    <meta name="go-import" content="example.org git https://code.org/r/p/exproj">
    -
    -

    -the go tool will verify that https://example.org/?go-get=1 contains the -same meta tag and then git clone https://code.org/r/p/exproj into -GOPATH/src/example.org. -

    -

    -New downloaded packages are written to the first directory listed in the GOPATH -environment variable (For more details see: 'go help gopath'). -

    -

    -The go command attempts to download the version of the -package appropriate for the Go release being used. -Run 'go help get' for more. -

    -

    Import path checking

    -

    -When the custom import path feature described above redirects to a -known code hosting site, each of the resulting packages has two possible -import paths, using the custom domain or the known hosting site. -

    -

    -A package statement is said to have an "import comment" if it is immediately -followed (before the next newline) by a comment of one of these two forms: -

    -
    package math // import "path"
    -package math /* import "path" */
    -
    -

    -The go command will refuse to install a package with an import comment -unless it is being referred to by that import path. In this way, import comments -let package authors make sure the custom import path is used and not a -direct path to the underlying code hosting site. -

    -

    -Import path checking is disabled for code found within vendor trees. -This makes it possible to copy code into alternate locations in vendor trees -without needing to update import comments. -

    -

    -See https://golang.org/s/go14customimport for details. -

    -

    Description of package lists

    -

    -Many commands apply to a set of packages: -

    -
    go action [packages]
    -
    -

    -Usually, [packages] is a list of import paths. -

    -

    -An import path that is a rooted path or that begins with -a . or .. element is interpreted as a file system path and -denotes the package in that directory. -

    -

    -Otherwise, the import path P denotes the package found in -the directory DIR/src/P for some DIR listed in the GOPATH -environment variable (For more details see: 'go help gopath'). -

    -

    -If no import paths are given, the action applies to the -package in the current directory. -

    -

    -There are four reserved names for paths that should not be used -for packages to be built with the go tool: -

    -

    -- "main" denotes the top-level package in a stand-alone executable. -

    -

    -- "all" expands to all package directories found in all the GOPATH -trees. For example, 'go list all' lists all the packages on the local -system. -

    -

    -- "std" is like all but expands to just the packages in the standard -Go library. -

    -

    -- "cmd" expands to the Go repository's commands and their -internal libraries. -

    -

    -Import paths beginning with "cmd/" only match source code in -the Go repository. -

    -

    -An import path is a pattern if it includes one or more "..." wildcards, -each of which can match any string, including the empty string and -strings containing slashes. Such a pattern expands to all package -directories found in the GOPATH trees with names matching the -patterns. As a special case, x/... matches x as well as x's subdirectories. -For example, net/... expands to net and packages in its subdirectories. -

    -

    -An import path can also name a package to be downloaded from -a remote repository. Run 'go help importpath' for details. -

    -

    -Every package in a program must have a unique import path. -By convention, this is arranged by starting each path with a -unique prefix that belongs to you. For example, paths used -internally at Google all begin with 'google', and paths -denoting remote repositories begin with the path to the code, -such as 'github.com/user/repo'. -

    -

    -Packages in a program need not have unique package names, -but there are two reserved package names with special meaning. -The name main indicates a command, not a library. -Commands are built into binaries and cannot be imported. -The name documentation indicates documentation for -a non-Go program in the directory. Files in package documentation -are ignored by the go command. -

    -

    -As a special case, if the package list is a list of .go files from a -single directory, the command is applied to a single synthesized -package made up of exactly those files, ignoring any build constraints -in those files and ignoring any other files in the directory. -

    -

    -Directory and file names that begin with "." or "_" are ignored -by the go tool, as are directories named "testdata". -

    -

    Description of testing flags

    -

    -The 'go test' command takes both flags that apply to 'go test' itself -and flags that apply to the resulting test binary. -

    -

    -Several of the flags control profiling and write an execution profile -suitable for "go tool pprof"; run "go tool pprof -h" for more -information. The --alloc_space, --alloc_objects, and --show_bytes -options of pprof control how the information is presented. -

    -

    -The following flags are recognized by the 'go test' command and -control the execution of any test: -

    -
    -bench regexp
    -    Run (sub)benchmarks matching a regular expression.
    -    The given regular expression is split into smaller ones by
    -    top-level '/', where each must match the corresponding part of a
    -    benchmark's identifier.
    -    By default, no benchmarks run. To run all benchmarks,
    -    use '-bench .' or '-bench=.'.
    -
    --benchtime t
    -    Run enough iterations of each benchmark to take t, specified
    -    as a time.Duration (for example, -benchtime 1h30s).
    -    The default is 1 second (1s).
    -
    --count n
    -    Run each test and benchmark n times (default 1).
    -    If -cpu is set, run n times for each GOMAXPROCS value.
    -    Examples are always run once.
    -
    --cover
    -    Enable coverage analysis.
    -
    --covermode set,count,atomic
    -    Set the mode for coverage analysis for the package[s]
    -    being tested. The default is "set" unless -race is enabled,
    -    in which case it is "atomic".
    -    The values:
    -	set: bool: does this statement run?
    -	count: int: how many times does this statement run?
    -	atomic: int: count, but correct in multithreaded tests;
    -		significantly more expensive.
    -    Sets -cover.
    -
    --coverpkg pkg1,pkg2,pkg3
    -    Apply coverage analysis in each test to the given list of packages.
    -    The default is for each test to analyze only the package being tested.
    -    Packages are specified as import paths.
    -    Sets -cover.
    -
    --cpu 1,2,4
    -    Specify a list of GOMAXPROCS values for which the tests or
    -    benchmarks should be executed.  The default is the current value
    -    of GOMAXPROCS.
    -
    --parallel n
    -    Allow parallel execution of test functions that call t.Parallel.
    -    The value of this flag is the maximum number of tests to run
    -    simultaneously; by default, it is set to the value of GOMAXPROCS.
    -    Note that -parallel only applies within a single test binary.
    -    The 'go test' command may run tests for different packages
    -    in parallel as well, according to the setting of the -p flag
    -    (see 'go help build').
    -
    --run regexp
    -    Run only those tests and examples matching the regular expression.
    -    For tests the regular expression is split into smaller ones by
    -    top-level '/', where each must match the corresponding part of a
    -    test's identifier.
    -
    --short
    -    Tell long-running tests to shorten their run time.
    -    It is off by default but set during all.bash so that installing
    -    the Go tree can run a sanity check but not spend time running
    -    exhaustive tests.
    -
    --timeout t
    -    If a test runs longer than t, panic.
    -    The default is 10 minutes (10m).
    -
    --v
    -    Verbose output: log all tests as they are run. Also print all
    -    text from Log and Logf calls even if the test succeeds.
    -
    -

    -The following flags are also recognized by 'go test' and can be used to -profile the tests during execution: -

    -
    -benchmem
    -    Print memory allocation statistics for benchmarks.
    -
    --blockprofile block.out
    -    Write a goroutine blocking profile to the specified file
    -    when all tests are complete.
    -    Writes test binary as -c would.
    -
    --blockprofilerate n
    -    Control the detail provided in goroutine blocking profiles by
    -    calling runtime.SetBlockProfileRate with n.
    -    See 'go doc runtime.SetBlockProfileRate'.
    -    The profiler aims to sample, on average, one blocking event every
    -    n nanoseconds the program spends blocked.  By default,
    -    if -test.blockprofile is set without this flag, all blocking events
    -    are recorded, equivalent to -test.blockprofilerate=1.
    -
    --coverprofile cover.out
    -    Write a coverage profile to the file after all tests have passed.
    -    Sets -cover.
    -
    --cpuprofile cpu.out
    -    Write a CPU profile to the specified file before exiting.
    -    Writes test binary as -c would.
    -
    --memprofile mem.out
    -    Write a memory profile to the file after all tests have passed.
    -    Writes test binary as -c would.
    -
    --memprofilerate n
    -    Enable more precise (and expensive) memory profiles by setting
    -    runtime.MemProfileRate.  See 'go doc runtime.MemProfileRate'.
    -    To profile all memory allocations, use -test.memprofilerate=1
    -    and pass --alloc_space flag to the pprof tool.
    -
    --mutexprofile mutex.out
    -    Write a mutex contention profile to the specified file
    -    when all tests are complete.
    -    Writes test binary as -c would.
    -
    --mutexprofilefraction n
    -    Sample 1 in n stack traces of goroutines holding a
    -    contended mutex.
    -
    --outputdir directory
    -    Place output files from profiling in the specified directory,
    -    by default the directory in which "go test" is running.
    -
    --trace trace.out
    -    Write an execution trace to the specified file before exiting.
    -
    -

    -Each of these flags is also recognized with an optional 'test.' prefix, -as in -test.v. When invoking the generated test binary (the result of -'go test -c') directly, however, the prefix is mandatory. -

    -

    -The 'go test' command rewrites or removes recognized flags, -as appropriate, both before and after the optional package list, -before invoking the test binary. -

    -

    -For instance, the command -

    -
    go test -v -myflag testdata -cpuprofile=prof.out -x
    -
    -

    -will compile the test binary and then run it as -

    -
    pkg.test -test.v -myflag testdata -test.cpuprofile=prof.out
    -
    -

    -(The -x flag is removed because it applies only to the go command's -execution, not to the test itself.) -

    -

    -The test flags that generate profiles (other than for coverage) also -leave the test binary in pkg.test for use when analyzing the profiles. -

    -

    -When 'go test' runs a test binary, it does so from within the -corresponding package's source code directory. Depending on the test, -it may be necessary to do the same when invoking a generated test -binary directly. -

    -

    -The command-line package list, if present, must appear before any -flag not known to the go test command. Continuing the example above, -the package list would have to appear before -myflag, but could appear -on either side of -v. -

    -

    -To keep an argument for a test binary from being interpreted as a -known flag or a package name, use -args (see 'go help test') which -passes the remainder of the command line through to the test binary -uninterpreted and unaltered. -

    -

    -For instance, the command -

    -
    go test -v -args -x -v
    -
    -

    -will compile the test binary and then run it as -

    -
    pkg.test -test.v -x -v
    -
    -

    -Similarly, -

    -
    go test -args math
    -
    -

    -will compile the test binary and then run it as -

    -
    pkg.test math
    -
    -

    -In the first example, the -x and the second -v are passed through to the -test binary unchanged and with no effect on the go command itself. -In the second example, the argument math is passed through to the test -binary, instead of being interpreted as the package list. -

    -

    Description of testing functions

    -

    -The 'go test' command expects to find test, benchmark, and example functions -in the "*_test.go" files corresponding to the package under test. -

    -

    -A test function is one named TestXXX (where XXX is any alphanumeric string -not starting with a lower case letter) and should have the signature, -

    -
    func TestXXX(t *testing.T) { ... }
    -
    -

    -A benchmark function is one named BenchmarkXXX and should have the signature, -

    -
    func BenchmarkXXX(b *testing.B) { ... }
    -
    -

    -An example function is similar to a test function but, instead of using -*testing.T to report success or failure, prints output to os.Stdout. -If the last comment in the function starts with "Output:" then the output -is compared exactly against the comment (see examples below). If the last -comment begins with "Unordered output:" then the output is compared to the -comment, however the order of the lines is ignored. An example with no such -comment is compiled but not executed. An example with no text after -"Output:" is compiled, executed, and expected to produce no output. -

    -

    -Godoc displays the body of ExampleXXX to demonstrate the use -of the function, constant, or variable XXX. An example of a method M with -receiver type T or *T is named ExampleT_M. There may be multiple examples -for a given function, constant, or variable, distinguished by a trailing _xxx, -where xxx is a suffix not beginning with an upper case letter. -

    -

    -Here is an example of an example: -

    -
    func ExamplePrintln() {
    -	Println("The output of\nthis example.")
    -	// Output: The output of
    -	// this example.
    -}
    -
    -

    -Here is another example where the ordering of the output is ignored: -

    -
    func ExamplePerm() {
    -	for _, value := range Perm(4) {
    -		fmt.Println(value)
    -	}
    -
    -	// Unordered output: 4
    -	// 2
    -	// 1
    -	// 3
    -	// 0
    -}
    -
    -

    -The entire test file is presented as the example when it contains a single -example function, at least one other function, type, variable, or constant -declaration, and no test or benchmark functions. -

    -

    -See the documentation of the testing package for more information. -

    - - - -
    -
    - - - - - - - - -`)) diff --git a/vendor/golang.org/x/net/http2/h2i/README.md b/vendor/golang.org/x/net/http2/h2i/README.md deleted file mode 100644 index fb5c5efb0..000000000 --- a/vendor/golang.org/x/net/http2/h2i/README.md +++ /dev/null @@ -1,97 +0,0 @@ -# h2i - -**h2i** is an interactive HTTP/2 ("h2") console debugger. Miss the good ol' -days of telnetting to your HTTP/1.n servers? We're bringing you -back. - -Features: -- send raw HTTP/2 frames - - PING - - SETTINGS - - HEADERS - - etc -- type in HTTP/1.n and have it auto-HPACK/frame-ify it for HTTP/2 -- pretty print all received HTTP/2 frames from the peer (including HPACK decoding) -- tab completion of commands, options - -Not yet features, but soon: -- unnecessary CONTINUATION frames on short boundaries, to test peer implementations -- request bodies (DATA frames) -- send invalid frames for testing server implementations (supported by underlying Framer) - -Later: -- act like a server - -## Installation - -``` -$ go get golang.org/x/net/http2/h2i -$ h2i -``` - -## Demo - -``` -$ h2i -Usage: h2i - - -insecure - Whether to skip TLS cert validation - -nextproto string - Comma-separated list of NPN/ALPN protocol names to negotiate. (default "h2,h2-14") - -$ h2i google.com -Connecting to google.com:443 ... -Connected to 74.125.224.41:443 -Negotiated protocol "h2-14" -[FrameHeader SETTINGS len=18] - [MAX_CONCURRENT_STREAMS = 100] - [INITIAL_WINDOW_SIZE = 1048576] - [MAX_FRAME_SIZE = 16384] -[FrameHeader WINDOW_UPDATE len=4] - Window-Increment = 983041 - -h2i> PING h2iSayHI -[FrameHeader PING flags=ACK len=8] - Data = "h2iSayHI" -h2i> headers -(as HTTP/1.1)> GET / HTTP/1.1 -(as HTTP/1.1)> Host: ip.appspot.com -(as HTTP/1.1)> User-Agent: h2i/brad-n-blake -(as HTTP/1.1)> -Opening Stream-ID 1: - :authority = ip.appspot.com - :method = GET - :path = / - :scheme = https - user-agent = h2i/brad-n-blake -[FrameHeader HEADERS flags=END_HEADERS stream=1 len=77] - :status = "200" - alternate-protocol = "443:quic,p=1" - content-length = "15" - content-type = "text/html" - date = "Fri, 01 May 2015 23:06:56 GMT" - server = "Google Frontend" -[FrameHeader DATA flags=END_STREAM stream=1 len=15] - "173.164.155.78\n" -[FrameHeader PING len=8] - Data = "\x00\x00\x00\x00\x00\x00\x00\x00" -h2i> ping -[FrameHeader PING flags=ACK len=8] - Data = "h2i_ping" -h2i> ping -[FrameHeader PING flags=ACK len=8] - Data = "h2i_ping" -h2i> ping -[FrameHeader GOAWAY len=22] - Last-Stream-ID = 1; Error-Code = PROTOCOL_ERROR (1) - -ReadFrame: EOF -``` - -## Status - -Quick few hour hack. So much yet to do. Feel free to file issues for -bugs or wishlist items, but [@bmizerany](https://github.com/bmizerany/) -and I aren't yet accepting pull requests until things settle down. - diff --git a/vendor/golang.org/x/net/http2/h2i/h2i.go b/vendor/golang.org/x/net/http2/h2i/h2i.go deleted file mode 100644 index 76c778711..000000000 --- a/vendor/golang.org/x/net/http2/h2i/h2i.go +++ /dev/null @@ -1,509 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !plan9,!solaris - -/* -The h2i command is an interactive HTTP/2 console. - -Usage: - $ h2i [flags] - -Interactive commands in the console: (all parts case-insensitive) - - ping [data] - settings ack - settings FOO=n BAR=z - headers (open a new stream by typing HTTP/1.1) -*/ -package main - -import ( - "bufio" - "bytes" - "crypto/tls" - "errors" - "flag" - "fmt" - "io" - "log" - "net" - "net/http" - "os" - "regexp" - "strconv" - "strings" - - "golang.org/x/crypto/ssh/terminal" - "golang.org/x/net/http2" - "golang.org/x/net/http2/hpack" -) - -// Flags -var ( - flagNextProto = flag.String("nextproto", "h2,h2-14", "Comma-separated list of NPN/ALPN protocol names to negotiate.") - flagInsecure = flag.Bool("insecure", false, "Whether to skip TLS cert validation") - flagSettings = flag.String("settings", "empty", "comma-separated list of KEY=value settings for the initial SETTINGS frame. The magic value 'empty' sends an empty initial settings frame, and the magic value 'omit' causes no initial settings frame to be sent.") -) - -type command struct { - run func(*h2i, []string) error // required - - // complete optionally specifies tokens (case-insensitive) which are - // valid for this subcommand. - complete func() []string -} - -var commands = map[string]command{ - "ping": {run: (*h2i).cmdPing}, - "settings": { - run: (*h2i).cmdSettings, - complete: func() []string { - return []string{ - "ACK", - http2.SettingHeaderTableSize.String(), - http2.SettingEnablePush.String(), - http2.SettingMaxConcurrentStreams.String(), - http2.SettingInitialWindowSize.String(), - http2.SettingMaxFrameSize.String(), - http2.SettingMaxHeaderListSize.String(), - } - }, - }, - "quit": {run: (*h2i).cmdQuit}, - "headers": {run: (*h2i).cmdHeaders}, -} - -func usage() { - fmt.Fprintf(os.Stderr, "Usage: h2i \n\n") - flag.PrintDefaults() -} - -// withPort adds ":443" if another port isn't already present. -func withPort(host string) string { - if _, _, err := net.SplitHostPort(host); err != nil { - return net.JoinHostPort(host, "443") - } - return host -} - -// withoutPort strips the port from addr if present. -func withoutPort(addr string) string { - if h, _, err := net.SplitHostPort(addr); err == nil { - return h - } - return addr -} - -// h2i is the app's state. -type h2i struct { - host string - tc *tls.Conn - framer *http2.Framer - term *terminal.Terminal - - // owned by the command loop: - streamID uint32 - hbuf bytes.Buffer - henc *hpack.Encoder - - // owned by the readFrames loop: - peerSetting map[http2.SettingID]uint32 - hdec *hpack.Decoder -} - -func main() { - flag.Usage = usage - flag.Parse() - if flag.NArg() != 1 { - usage() - os.Exit(2) - } - log.SetFlags(0) - - host := flag.Arg(0) - app := &h2i{ - host: host, - peerSetting: make(map[http2.SettingID]uint32), - } - app.henc = hpack.NewEncoder(&app.hbuf) - - if err := app.Main(); err != nil { - if app.term != nil { - app.logf("%v\n", err) - } else { - fmt.Fprintf(os.Stderr, "%v\n", err) - } - os.Exit(1) - } - fmt.Fprintf(os.Stdout, "\n") -} - -func (app *h2i) Main() error { - cfg := &tls.Config{ - ServerName: withoutPort(app.host), - NextProtos: strings.Split(*flagNextProto, ","), - InsecureSkipVerify: *flagInsecure, - } - - hostAndPort := withPort(app.host) - log.Printf("Connecting to %s ...", hostAndPort) - tc, err := tls.Dial("tcp", hostAndPort, cfg) - if err != nil { - return fmt.Errorf("Error dialing %s: %v", withPort(app.host), err) - } - log.Printf("Connected to %v", tc.RemoteAddr()) - defer tc.Close() - - if err := tc.Handshake(); err != nil { - return fmt.Errorf("TLS handshake: %v", err) - } - if !*flagInsecure { - if err := tc.VerifyHostname(app.host); err != nil { - return fmt.Errorf("VerifyHostname: %v", err) - } - } - state := tc.ConnectionState() - log.Printf("Negotiated protocol %q", state.NegotiatedProtocol) - if !state.NegotiatedProtocolIsMutual || state.NegotiatedProtocol == "" { - return fmt.Errorf("Could not negotiate protocol mutually") - } - - if _, err := io.WriteString(tc, http2.ClientPreface); err != nil { - return err - } - - app.framer = http2.NewFramer(tc, tc) - - oldState, err := terminal.MakeRaw(int(os.Stdin.Fd())) - if err != nil { - return err - } - defer terminal.Restore(0, oldState) - - var screen = struct { - io.Reader - io.Writer - }{os.Stdin, os.Stdout} - - app.term = terminal.NewTerminal(screen, "h2i> ") - lastWord := regexp.MustCompile(`.+\W(\w+)$`) - app.term.AutoCompleteCallback = func(line string, pos int, key rune) (newLine string, newPos int, ok bool) { - if key != '\t' { - return - } - if pos != len(line) { - // TODO: we're being lazy for now, only supporting tab completion at the end. - return - } - // Auto-complete for the command itself. - if !strings.Contains(line, " ") { - var name string - name, _, ok = lookupCommand(line) - if !ok { - return - } - return name, len(name), true - } - _, c, ok := lookupCommand(line[:strings.IndexByte(line, ' ')]) - if !ok || c.complete == nil { - return - } - if strings.HasSuffix(line, " ") { - app.logf("%s", strings.Join(c.complete(), " ")) - return line, pos, true - } - m := lastWord.FindStringSubmatch(line) - if m == nil { - return line, len(line), true - } - soFar := m[1] - var match []string - for _, cand := range c.complete() { - if len(soFar) > len(cand) || !strings.EqualFold(cand[:len(soFar)], soFar) { - continue - } - match = append(match, cand) - } - if len(match) == 0 { - return - } - if len(match) > 1 { - // TODO: auto-complete any common prefix - app.logf("%s", strings.Join(match, " ")) - return line, pos, true - } - newLine = line[:len(line)-len(soFar)] + match[0] - return newLine, len(newLine), true - - } - - errc := make(chan error, 2) - go func() { errc <- app.readFrames() }() - go func() { errc <- app.readConsole() }() - return <-errc -} - -func (app *h2i) logf(format string, args ...interface{}) { - fmt.Fprintf(app.term, format+"\r\n", args...) -} - -func (app *h2i) readConsole() error { - if s := *flagSettings; s != "omit" { - var args []string - if s != "empty" { - args = strings.Split(s, ",") - } - _, c, ok := lookupCommand("settings") - if !ok { - panic("settings command not found") - } - c.run(app, args) - } - - for { - line, err := app.term.ReadLine() - if err == io.EOF { - return nil - } - if err != nil { - return fmt.Errorf("terminal.ReadLine: %v", err) - } - f := strings.Fields(line) - if len(f) == 0 { - continue - } - cmd, args := f[0], f[1:] - if _, c, ok := lookupCommand(cmd); ok { - err = c.run(app, args) - } else { - app.logf("Unknown command %q", line) - } - if err == errExitApp { - return nil - } - if err != nil { - return err - } - } -} - -func lookupCommand(prefix string) (name string, c command, ok bool) { - prefix = strings.ToLower(prefix) - if c, ok = commands[prefix]; ok { - return prefix, c, ok - } - - for full, candidate := range commands { - if strings.HasPrefix(full, prefix) { - if c.run != nil { - return "", command{}, false // ambiguous - } - c = candidate - name = full - } - } - return name, c, c.run != nil -} - -var errExitApp = errors.New("internal sentinel error value to quit the console reading loop") - -func (a *h2i) cmdQuit(args []string) error { - if len(args) > 0 { - a.logf("the QUIT command takes no argument") - return nil - } - return errExitApp -} - -func (a *h2i) cmdSettings(args []string) error { - if len(args) == 1 && strings.EqualFold(args[0], "ACK") { - return a.framer.WriteSettingsAck() - } - var settings []http2.Setting - for _, arg := range args { - if strings.EqualFold(arg, "ACK") { - a.logf("Error: ACK must be only argument with the SETTINGS command") - return nil - } - eq := strings.Index(arg, "=") - if eq == -1 { - a.logf("Error: invalid argument %q (expected SETTING_NAME=nnnn)", arg) - return nil - } - sid, ok := settingByName(arg[:eq]) - if !ok { - a.logf("Error: unknown setting name %q", arg[:eq]) - return nil - } - val, err := strconv.ParseUint(arg[eq+1:], 10, 32) - if err != nil { - a.logf("Error: invalid argument %q (expected SETTING_NAME=nnnn)", arg) - return nil - } - settings = append(settings, http2.Setting{ - ID: sid, - Val: uint32(val), - }) - } - a.logf("Sending: %v", settings) - return a.framer.WriteSettings(settings...) -} - -func settingByName(name string) (http2.SettingID, bool) { - for _, sid := range [...]http2.SettingID{ - http2.SettingHeaderTableSize, - http2.SettingEnablePush, - http2.SettingMaxConcurrentStreams, - http2.SettingInitialWindowSize, - http2.SettingMaxFrameSize, - http2.SettingMaxHeaderListSize, - } { - if strings.EqualFold(sid.String(), name) { - return sid, true - } - } - return 0, false -} - -func (app *h2i) cmdPing(args []string) error { - if len(args) > 1 { - app.logf("invalid PING usage: only accepts 0 or 1 args") - return nil // nil means don't end the program - } - var data [8]byte - if len(args) == 1 { - copy(data[:], args[0]) - } else { - copy(data[:], "h2i_ping") - } - return app.framer.WritePing(false, data) -} - -func (app *h2i) cmdHeaders(args []string) error { - if len(args) > 0 { - app.logf("Error: HEADERS doesn't yet take arguments.") - // TODO: flags for restricting window size, to force CONTINUATION - // frames. - return nil - } - var h1req bytes.Buffer - app.term.SetPrompt("(as HTTP/1.1)> ") - defer app.term.SetPrompt("h2i> ") - for { - line, err := app.term.ReadLine() - if err != nil { - return err - } - h1req.WriteString(line) - h1req.WriteString("\r\n") - if line == "" { - break - } - } - req, err := http.ReadRequest(bufio.NewReader(&h1req)) - if err != nil { - app.logf("Invalid HTTP/1.1 request: %v", err) - return nil - } - if app.streamID == 0 { - app.streamID = 1 - } else { - app.streamID += 2 - } - app.logf("Opening Stream-ID %d:", app.streamID) - hbf := app.encodeHeaders(req) - if len(hbf) > 16<<10 { - app.logf("TODO: h2i doesn't yet write CONTINUATION frames. Copy it from transport.go") - return nil - } - return app.framer.WriteHeaders(http2.HeadersFrameParam{ - StreamID: app.streamID, - BlockFragment: hbf, - EndStream: req.Method == "GET" || req.Method == "HEAD", // good enough for now - EndHeaders: true, // for now - }) -} - -func (app *h2i) readFrames() error { - for { - f, err := app.framer.ReadFrame() - if err != nil { - return fmt.Errorf("ReadFrame: %v", err) - } - app.logf("%v", f) - switch f := f.(type) { - case *http2.PingFrame: - app.logf(" Data = %q", f.Data) - case *http2.SettingsFrame: - f.ForeachSetting(func(s http2.Setting) error { - app.logf(" %v", s) - app.peerSetting[s.ID] = s.Val - return nil - }) - case *http2.WindowUpdateFrame: - app.logf(" Window-Increment = %v", f.Increment) - case *http2.GoAwayFrame: - app.logf(" Last-Stream-ID = %d; Error-Code = %v (%d)", f.LastStreamID, f.ErrCode, f.ErrCode) - case *http2.DataFrame: - app.logf(" %q", f.Data()) - case *http2.HeadersFrame: - if f.HasPriority() { - app.logf(" PRIORITY = %v", f.Priority) - } - if app.hdec == nil { - // TODO: if the user uses h2i to send a SETTINGS frame advertising - // something larger, we'll need to respect SETTINGS_HEADER_TABLE_SIZE - // and stuff here instead of using the 4k default. But for now: - tableSize := uint32(4 << 10) - app.hdec = hpack.NewDecoder(tableSize, app.onNewHeaderField) - } - app.hdec.Write(f.HeaderBlockFragment()) - } - } -} - -// called from readLoop -func (app *h2i) onNewHeaderField(f hpack.HeaderField) { - if f.Sensitive { - app.logf(" %s = %q (SENSITIVE)", f.Name, f.Value) - } - app.logf(" %s = %q", f.Name, f.Value) -} - -func (app *h2i) encodeHeaders(req *http.Request) []byte { - app.hbuf.Reset() - - // TODO(bradfitz): figure out :authority-vs-Host stuff between http2 and Go - host := req.Host - if host == "" { - host = req.URL.Host - } - - path := req.RequestURI - if path == "" { - path = "/" - } - - app.writeHeader(":authority", host) // probably not right for all sites - app.writeHeader(":method", req.Method) - app.writeHeader(":path", path) - app.writeHeader(":scheme", "https") - - for k, vv := range req.Header { - lowKey := strings.ToLower(k) - if lowKey == "host" { - continue - } - for _, v := range vv { - app.writeHeader(lowKey, v) - } - } - return app.hbuf.Bytes() -} - -func (app *h2i) writeHeader(name, value string) { - app.henc.WriteField(hpack.HeaderField{Name: name, Value: value}) - app.logf(" %s = %s", name, value) -} diff --git a/vendor/golang.org/x/net/http2/headermap.go b/vendor/golang.org/x/net/http2/headermap.go deleted file mode 100644 index c2805f6ac..000000000 --- a/vendor/golang.org/x/net/http2/headermap.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "net/http" - "strings" -) - -var ( - commonLowerHeader = map[string]string{} // Go-Canonical-Case -> lower-case - commonCanonHeader = map[string]string{} // lower-case -> Go-Canonical-Case -) - -func init() { - for _, v := range []string{ - "accept", - "accept-charset", - "accept-encoding", - "accept-language", - "accept-ranges", - "age", - "access-control-allow-origin", - "allow", - "authorization", - "cache-control", - "content-disposition", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-range", - "content-type", - "cookie", - "date", - "etag", - "expect", - "expires", - "from", - "host", - "if-match", - "if-modified-since", - "if-none-match", - "if-unmodified-since", - "last-modified", - "link", - "location", - "max-forwards", - "proxy-authenticate", - "proxy-authorization", - "range", - "referer", - "refresh", - "retry-after", - "server", - "set-cookie", - "strict-transport-security", - "trailer", - "transfer-encoding", - "user-agent", - "vary", - "via", - "www-authenticate", - } { - chk := http.CanonicalHeaderKey(v) - commonLowerHeader[chk] = v - commonCanonHeader[v] = chk - } -} - -func lowerHeader(v string) string { - if s, ok := commonLowerHeader[v]; ok { - return s - } - return strings.ToLower(v) -} diff --git a/vendor/golang.org/x/net/http2/hpack/encode.go b/vendor/golang.org/x/net/http2/hpack/encode.go deleted file mode 100644 index 54726c2a3..000000000 --- a/vendor/golang.org/x/net/http2/hpack/encode.go +++ /dev/null @@ -1,240 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package hpack - -import ( - "io" -) - -const ( - uint32Max = ^uint32(0) - initialHeaderTableSize = 4096 -) - -type Encoder struct { - dynTab dynamicTable - // minSize is the minimum table size set by - // SetMaxDynamicTableSize after the previous Header Table Size - // Update. - minSize uint32 - // maxSizeLimit is the maximum table size this encoder - // supports. This will protect the encoder from too large - // size. - maxSizeLimit uint32 - // tableSizeUpdate indicates whether "Header Table Size - // Update" is required. - tableSizeUpdate bool - w io.Writer - buf []byte -} - -// NewEncoder returns a new Encoder which performs HPACK encoding. An -// encoded data is written to w. -func NewEncoder(w io.Writer) *Encoder { - e := &Encoder{ - minSize: uint32Max, - maxSizeLimit: initialHeaderTableSize, - tableSizeUpdate: false, - w: w, - } - e.dynTab.table.init() - e.dynTab.setMaxSize(initialHeaderTableSize) - return e -} - -// WriteField encodes f into a single Write to e's underlying Writer. -// This function may also produce bytes for "Header Table Size Update" -// if necessary. If produced, it is done before encoding f. -func (e *Encoder) WriteField(f HeaderField) error { - e.buf = e.buf[:0] - - if e.tableSizeUpdate { - e.tableSizeUpdate = false - if e.minSize < e.dynTab.maxSize { - e.buf = appendTableSize(e.buf, e.minSize) - } - e.minSize = uint32Max - e.buf = appendTableSize(e.buf, e.dynTab.maxSize) - } - - idx, nameValueMatch := e.searchTable(f) - if nameValueMatch { - e.buf = appendIndexed(e.buf, idx) - } else { - indexing := e.shouldIndex(f) - if indexing { - e.dynTab.add(f) - } - - if idx == 0 { - e.buf = appendNewName(e.buf, f, indexing) - } else { - e.buf = appendIndexedName(e.buf, f, idx, indexing) - } - } - n, err := e.w.Write(e.buf) - if err == nil && n != len(e.buf) { - err = io.ErrShortWrite - } - return err -} - -// searchTable searches f in both stable and dynamic header tables. -// The static header table is searched first. Only when there is no -// exact match for both name and value, the dynamic header table is -// then searched. If there is no match, i is 0. If both name and value -// match, i is the matched index and nameValueMatch becomes true. If -// only name matches, i points to that index and nameValueMatch -// becomes false. -func (e *Encoder) searchTable(f HeaderField) (i uint64, nameValueMatch bool) { - i, nameValueMatch = staticTable.search(f) - if nameValueMatch { - return i, true - } - - j, nameValueMatch := e.dynTab.table.search(f) - if nameValueMatch || (i == 0 && j != 0) { - return j + uint64(staticTable.len()), nameValueMatch - } - - return i, false -} - -// SetMaxDynamicTableSize changes the dynamic header table size to v. -// The actual size is bounded by the value passed to -// SetMaxDynamicTableSizeLimit. -func (e *Encoder) SetMaxDynamicTableSize(v uint32) { - if v > e.maxSizeLimit { - v = e.maxSizeLimit - } - if v < e.minSize { - e.minSize = v - } - e.tableSizeUpdate = true - e.dynTab.setMaxSize(v) -} - -// SetMaxDynamicTableSizeLimit changes the maximum value that can be -// specified in SetMaxDynamicTableSize to v. By default, it is set to -// 4096, which is the same size of the default dynamic header table -// size described in HPACK specification. If the current maximum -// dynamic header table size is strictly greater than v, "Header Table -// Size Update" will be done in the next WriteField call and the -// maximum dynamic header table size is truncated to v. -func (e *Encoder) SetMaxDynamicTableSizeLimit(v uint32) { - e.maxSizeLimit = v - if e.dynTab.maxSize > v { - e.tableSizeUpdate = true - e.dynTab.setMaxSize(v) - } -} - -// shouldIndex reports whether f should be indexed. -func (e *Encoder) shouldIndex(f HeaderField) bool { - return !f.Sensitive && f.Size() <= e.dynTab.maxSize -} - -// appendIndexed appends index i, as encoded in "Indexed Header Field" -// representation, to dst and returns the extended buffer. -func appendIndexed(dst []byte, i uint64) []byte { - first := len(dst) - dst = appendVarInt(dst, 7, i) - dst[first] |= 0x80 - return dst -} - -// appendNewName appends f, as encoded in one of "Literal Header field -// - New Name" representation variants, to dst and returns the -// extended buffer. -// -// If f.Sensitive is true, "Never Indexed" representation is used. If -// f.Sensitive is false and indexing is true, "Inremental Indexing" -// representation is used. -func appendNewName(dst []byte, f HeaderField, indexing bool) []byte { - dst = append(dst, encodeTypeByte(indexing, f.Sensitive)) - dst = appendHpackString(dst, f.Name) - return appendHpackString(dst, f.Value) -} - -// appendIndexedName appends f and index i referring indexed name -// entry, as encoded in one of "Literal Header field - Indexed Name" -// representation variants, to dst and returns the extended buffer. -// -// If f.Sensitive is true, "Never Indexed" representation is used. If -// f.Sensitive is false and indexing is true, "Incremental Indexing" -// representation is used. -func appendIndexedName(dst []byte, f HeaderField, i uint64, indexing bool) []byte { - first := len(dst) - var n byte - if indexing { - n = 6 - } else { - n = 4 - } - dst = appendVarInt(dst, n, i) - dst[first] |= encodeTypeByte(indexing, f.Sensitive) - return appendHpackString(dst, f.Value) -} - -// appendTableSize appends v, as encoded in "Header Table Size Update" -// representation, to dst and returns the extended buffer. -func appendTableSize(dst []byte, v uint32) []byte { - first := len(dst) - dst = appendVarInt(dst, 5, uint64(v)) - dst[first] |= 0x20 - return dst -} - -// appendVarInt appends i, as encoded in variable integer form using n -// bit prefix, to dst and returns the extended buffer. -// -// See -// http://http2.github.io/http2-spec/compression.html#integer.representation -func appendVarInt(dst []byte, n byte, i uint64) []byte { - k := uint64((1 << n) - 1) - if i < k { - return append(dst, byte(i)) - } - dst = append(dst, byte(k)) - i -= k - for ; i >= 128; i >>= 7 { - dst = append(dst, byte(0x80|(i&0x7f))) - } - return append(dst, byte(i)) -} - -// appendHpackString appends s, as encoded in "String Literal" -// representation, to dst and returns the the extended buffer. -// -// s will be encoded in Huffman codes only when it produces strictly -// shorter byte string. -func appendHpackString(dst []byte, s string) []byte { - huffmanLength := HuffmanEncodeLength(s) - if huffmanLength < uint64(len(s)) { - first := len(dst) - dst = appendVarInt(dst, 7, huffmanLength) - dst = AppendHuffmanString(dst, s) - dst[first] |= 0x80 - } else { - dst = appendVarInt(dst, 7, uint64(len(s))) - dst = append(dst, s...) - } - return dst -} - -// encodeTypeByte returns type byte. If sensitive is true, type byte -// for "Never Indexed" representation is returned. If sensitive is -// false and indexing is true, type byte for "Incremental Indexing" -// representation is returned. Otherwise, type byte for "Without -// Indexing" is returned. -func encodeTypeByte(indexing, sensitive bool) byte { - if sensitive { - return 0x10 - } - if indexing { - return 0x40 - } - return 0 -} diff --git a/vendor/golang.org/x/net/http2/hpack/encode_test.go b/vendor/golang.org/x/net/http2/hpack/encode_test.go deleted file mode 100644 index 05f12db9c..000000000 --- a/vendor/golang.org/x/net/http2/hpack/encode_test.go +++ /dev/null @@ -1,386 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package hpack - -import ( - "bytes" - "encoding/hex" - "fmt" - "math/rand" - "reflect" - "strings" - "testing" -) - -func TestEncoderTableSizeUpdate(t *testing.T) { - tests := []struct { - size1, size2 uint32 - wantHex string - }{ - // Should emit 2 table size updates (2048 and 4096) - {2048, 4096, "3fe10f 3fe11f 82"}, - - // Should emit 1 table size update (2048) - {16384, 2048, "3fe10f 82"}, - } - for _, tt := range tests { - var buf bytes.Buffer - e := NewEncoder(&buf) - e.SetMaxDynamicTableSize(tt.size1) - e.SetMaxDynamicTableSize(tt.size2) - if err := e.WriteField(pair(":method", "GET")); err != nil { - t.Fatal(err) - } - want := removeSpace(tt.wantHex) - if got := hex.EncodeToString(buf.Bytes()); got != want { - t.Errorf("e.SetDynamicTableSize %v, %v = %q; want %q", tt.size1, tt.size2, got, want) - } - } -} - -func TestEncoderWriteField(t *testing.T) { - var buf bytes.Buffer - e := NewEncoder(&buf) - var got []HeaderField - d := NewDecoder(4<<10, func(f HeaderField) { - got = append(got, f) - }) - - tests := []struct { - hdrs []HeaderField - }{ - {[]HeaderField{ - pair(":method", "GET"), - pair(":scheme", "http"), - pair(":path", "/"), - pair(":authority", "www.example.com"), - }}, - {[]HeaderField{ - pair(":method", "GET"), - pair(":scheme", "http"), - pair(":path", "/"), - pair(":authority", "www.example.com"), - pair("cache-control", "no-cache"), - }}, - {[]HeaderField{ - pair(":method", "GET"), - pair(":scheme", "https"), - pair(":path", "/index.html"), - pair(":authority", "www.example.com"), - pair("custom-key", "custom-value"), - }}, - } - for i, tt := range tests { - buf.Reset() - got = got[:0] - for _, hf := range tt.hdrs { - if err := e.WriteField(hf); err != nil { - t.Fatal(err) - } - } - _, err := d.Write(buf.Bytes()) - if err != nil { - t.Errorf("%d. Decoder Write = %v", i, err) - } - if !reflect.DeepEqual(got, tt.hdrs) { - t.Errorf("%d. Decoded %+v; want %+v", i, got, tt.hdrs) - } - } -} - -func TestEncoderSearchTable(t *testing.T) { - e := NewEncoder(nil) - - e.dynTab.add(pair("foo", "bar")) - e.dynTab.add(pair("blake", "miz")) - e.dynTab.add(pair(":method", "GET")) - - tests := []struct { - hf HeaderField - wantI uint64 - wantMatch bool - }{ - // Name and Value match - {pair("foo", "bar"), uint64(staticTable.len()) + 3, true}, - {pair("blake", "miz"), uint64(staticTable.len()) + 2, true}, - {pair(":method", "GET"), 2, true}, - - // Only name match because Sensitive == true. This is allowed to match - // any ":method" entry. The current implementation uses the last entry - // added in newStaticTable. - {HeaderField{":method", "GET", true}, 3, false}, - - // Only Name matches - {pair("foo", "..."), uint64(staticTable.len()) + 3, false}, - {pair("blake", "..."), uint64(staticTable.len()) + 2, false}, - // As before, this is allowed to match any ":method" entry. - {pair(":method", "..."), 3, false}, - - // None match - {pair("foo-", "bar"), 0, false}, - } - for _, tt := range tests { - if gotI, gotMatch := e.searchTable(tt.hf); gotI != tt.wantI || gotMatch != tt.wantMatch { - t.Errorf("d.search(%+v) = %v, %v; want %v, %v", tt.hf, gotI, gotMatch, tt.wantI, tt.wantMatch) - } - } -} - -func TestAppendVarInt(t *testing.T) { - tests := []struct { - n byte - i uint64 - want []byte - }{ - // Fits in a byte: - {1, 0, []byte{0}}, - {2, 2, []byte{2}}, - {3, 6, []byte{6}}, - {4, 14, []byte{14}}, - {5, 30, []byte{30}}, - {6, 62, []byte{62}}, - {7, 126, []byte{126}}, - {8, 254, []byte{254}}, - - // Multiple bytes: - {5, 1337, []byte{31, 154, 10}}, - } - for _, tt := range tests { - got := appendVarInt(nil, tt.n, tt.i) - if !bytes.Equal(got, tt.want) { - t.Errorf("appendVarInt(nil, %v, %v) = %v; want %v", tt.n, tt.i, got, tt.want) - } - } -} - -func TestAppendHpackString(t *testing.T) { - tests := []struct { - s, wantHex string - }{ - // Huffman encoded - {"www.example.com", "8c f1e3 c2e5 f23a 6ba0 ab90 f4ff"}, - - // Not Huffman encoded - {"a", "01 61"}, - - // zero length - {"", "00"}, - } - for _, tt := range tests { - want := removeSpace(tt.wantHex) - buf := appendHpackString(nil, tt.s) - if got := hex.EncodeToString(buf); want != got { - t.Errorf("appendHpackString(nil, %q) = %q; want %q", tt.s, got, want) - } - } -} - -func TestAppendIndexed(t *testing.T) { - tests := []struct { - i uint64 - wantHex string - }{ - // 1 byte - {1, "81"}, - {126, "fe"}, - - // 2 bytes - {127, "ff00"}, - {128, "ff01"}, - } - for _, tt := range tests { - want := removeSpace(tt.wantHex) - buf := appendIndexed(nil, tt.i) - if got := hex.EncodeToString(buf); want != got { - t.Errorf("appendIndex(nil, %v) = %q; want %q", tt.i, got, want) - } - } -} - -func TestAppendNewName(t *testing.T) { - tests := []struct { - f HeaderField - indexing bool - wantHex string - }{ - // Incremental indexing - {HeaderField{"custom-key", "custom-value", false}, true, "40 88 25a8 49e9 5ba9 7d7f 89 25a8 49e9 5bb8 e8b4 bf"}, - - // Without indexing - {HeaderField{"custom-key", "custom-value", false}, false, "00 88 25a8 49e9 5ba9 7d7f 89 25a8 49e9 5bb8 e8b4 bf"}, - - // Never indexed - {HeaderField{"custom-key", "custom-value", true}, true, "10 88 25a8 49e9 5ba9 7d7f 89 25a8 49e9 5bb8 e8b4 bf"}, - {HeaderField{"custom-key", "custom-value", true}, false, "10 88 25a8 49e9 5ba9 7d7f 89 25a8 49e9 5bb8 e8b4 bf"}, - } - for _, tt := range tests { - want := removeSpace(tt.wantHex) - buf := appendNewName(nil, tt.f, tt.indexing) - if got := hex.EncodeToString(buf); want != got { - t.Errorf("appendNewName(nil, %+v, %v) = %q; want %q", tt.f, tt.indexing, got, want) - } - } -} - -func TestAppendIndexedName(t *testing.T) { - tests := []struct { - f HeaderField - i uint64 - indexing bool - wantHex string - }{ - // Incremental indexing - {HeaderField{":status", "302", false}, 8, true, "48 82 6402"}, - - // Without indexing - {HeaderField{":status", "302", false}, 8, false, "08 82 6402"}, - - // Never indexed - {HeaderField{":status", "302", true}, 8, true, "18 82 6402"}, - {HeaderField{":status", "302", true}, 8, false, "18 82 6402"}, - } - for _, tt := range tests { - want := removeSpace(tt.wantHex) - buf := appendIndexedName(nil, tt.f, tt.i, tt.indexing) - if got := hex.EncodeToString(buf); want != got { - t.Errorf("appendIndexedName(nil, %+v, %v) = %q; want %q", tt.f, tt.indexing, got, want) - } - } -} - -func TestAppendTableSize(t *testing.T) { - tests := []struct { - i uint32 - wantHex string - }{ - // Fits into 1 byte - {30, "3e"}, - - // Extra byte - {31, "3f00"}, - {32, "3f01"}, - } - for _, tt := range tests { - want := removeSpace(tt.wantHex) - buf := appendTableSize(nil, tt.i) - if got := hex.EncodeToString(buf); want != got { - t.Errorf("appendTableSize(nil, %v) = %q; want %q", tt.i, got, want) - } - } -} - -func TestEncoderSetMaxDynamicTableSize(t *testing.T) { - var buf bytes.Buffer - e := NewEncoder(&buf) - tests := []struct { - v uint32 - wantUpdate bool - wantMinSize uint32 - wantMaxSize uint32 - }{ - // Set new table size to 2048 - {2048, true, 2048, 2048}, - - // Set new table size to 16384, but still limited to - // 4096 - {16384, true, 2048, 4096}, - } - for _, tt := range tests { - e.SetMaxDynamicTableSize(tt.v) - if got := e.tableSizeUpdate; tt.wantUpdate != got { - t.Errorf("e.tableSizeUpdate = %v; want %v", got, tt.wantUpdate) - } - if got := e.minSize; tt.wantMinSize != got { - t.Errorf("e.minSize = %v; want %v", got, tt.wantMinSize) - } - if got := e.dynTab.maxSize; tt.wantMaxSize != got { - t.Errorf("e.maxSize = %v; want %v", got, tt.wantMaxSize) - } - } -} - -func TestEncoderSetMaxDynamicTableSizeLimit(t *testing.T) { - e := NewEncoder(nil) - // 4095 < initialHeaderTableSize means maxSize is truncated to - // 4095. - e.SetMaxDynamicTableSizeLimit(4095) - if got, want := e.dynTab.maxSize, uint32(4095); got != want { - t.Errorf("e.dynTab.maxSize = %v; want %v", got, want) - } - if got, want := e.maxSizeLimit, uint32(4095); got != want { - t.Errorf("e.maxSizeLimit = %v; want %v", got, want) - } - if got, want := e.tableSizeUpdate, true; got != want { - t.Errorf("e.tableSizeUpdate = %v; want %v", got, want) - } - // maxSize will be truncated to maxSizeLimit - e.SetMaxDynamicTableSize(16384) - if got, want := e.dynTab.maxSize, uint32(4095); got != want { - t.Errorf("e.dynTab.maxSize = %v; want %v", got, want) - } - // 8192 > current maxSizeLimit, so maxSize does not change. - e.SetMaxDynamicTableSizeLimit(8192) - if got, want := e.dynTab.maxSize, uint32(4095); got != want { - t.Errorf("e.dynTab.maxSize = %v; want %v", got, want) - } - if got, want := e.maxSizeLimit, uint32(8192); got != want { - t.Errorf("e.maxSizeLimit = %v; want %v", got, want) - } -} - -func removeSpace(s string) string { - return strings.Replace(s, " ", "", -1) -} - -func BenchmarkEncoderSearchTable(b *testing.B) { - e := NewEncoder(nil) - - // A sample of possible header fields. - // This is not based on any actual data from HTTP/2 traces. - var possible []HeaderField - for _, f := range staticTable.ents { - if f.Value == "" { - possible = append(possible, f) - continue - } - // Generate 5 random values, except for cookie and set-cookie, - // which we know can have many values in practice. - num := 5 - if f.Name == "cookie" || f.Name == "set-cookie" { - num = 25 - } - for i := 0; i < num; i++ { - f.Value = fmt.Sprintf("%s-%d", f.Name, i) - possible = append(possible, f) - } - } - for k := 0; k < 10; k++ { - f := HeaderField{ - Name: fmt.Sprintf("x-header-%d", k), - Sensitive: rand.Int()%2 == 0, - } - for i := 0; i < 5; i++ { - f.Value = fmt.Sprintf("%s-%d", f.Name, i) - possible = append(possible, f) - } - } - - // Add a random sample to the dynamic table. This very loosely simulates - // a history of 100 requests with 20 header fields per request. - for r := 0; r < 100*20; r++ { - f := possible[rand.Int31n(int32(len(possible)))] - // Skip if this is in the staticTable verbatim. - if _, has := staticTable.search(f); !has { - e.dynTab.add(f) - } - } - - b.ResetTimer() - for n := 0; n < b.N; n++ { - for _, f := range possible { - e.searchTable(f) - } - } -} diff --git a/vendor/golang.org/x/net/http2/hpack/hpack.go b/vendor/golang.org/x/net/http2/hpack/hpack.go deleted file mode 100644 index 176644acd..000000000 --- a/vendor/golang.org/x/net/http2/hpack/hpack.go +++ /dev/null @@ -1,490 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package hpack implements HPACK, a compression format for -// efficiently representing HTTP header fields in the context of HTTP/2. -// -// See http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-09 -package hpack - -import ( - "bytes" - "errors" - "fmt" -) - -// A DecodingError is something the spec defines as a decoding error. -type DecodingError struct { - Err error -} - -func (de DecodingError) Error() string { - return fmt.Sprintf("decoding error: %v", de.Err) -} - -// An InvalidIndexError is returned when an encoder references a table -// entry before the static table or after the end of the dynamic table. -type InvalidIndexError int - -func (e InvalidIndexError) Error() string { - return fmt.Sprintf("invalid indexed representation index %d", int(e)) -} - -// A HeaderField is a name-value pair. Both the name and value are -// treated as opaque sequences of octets. -type HeaderField struct { - Name, Value string - - // Sensitive means that this header field should never be - // indexed. - Sensitive bool -} - -// IsPseudo reports whether the header field is an http2 pseudo header. -// That is, it reports whether it starts with a colon. -// It is not otherwise guaranteed to be a valid pseudo header field, -// though. -func (hf HeaderField) IsPseudo() bool { - return len(hf.Name) != 0 && hf.Name[0] == ':' -} - -func (hf HeaderField) String() string { - var suffix string - if hf.Sensitive { - suffix = " (sensitive)" - } - return fmt.Sprintf("header field %q = %q%s", hf.Name, hf.Value, suffix) -} - -// Size returns the size of an entry per RFC 7541 section 4.1. -func (hf HeaderField) Size() uint32 { - // http://http2.github.io/http2-spec/compression.html#rfc.section.4.1 - // "The size of the dynamic table is the sum of the size of - // its entries. The size of an entry is the sum of its name's - // length in octets (as defined in Section 5.2), its value's - // length in octets (see Section 5.2), plus 32. The size of - // an entry is calculated using the length of the name and - // value without any Huffman encoding applied." - - // This can overflow if somebody makes a large HeaderField - // Name and/or Value by hand, but we don't care, because that - // won't happen on the wire because the encoding doesn't allow - // it. - return uint32(len(hf.Name) + len(hf.Value) + 32) -} - -// A Decoder is the decoding context for incremental processing of -// header blocks. -type Decoder struct { - dynTab dynamicTable - emit func(f HeaderField) - - emitEnabled bool // whether calls to emit are enabled - maxStrLen int // 0 means unlimited - - // buf is the unparsed buffer. It's only written to - // saveBuf if it was truncated in the middle of a header - // block. Because it's usually not owned, we can only - // process it under Write. - buf []byte // not owned; only valid during Write - - // saveBuf is previous data passed to Write which we weren't able - // to fully parse before. Unlike buf, we own this data. - saveBuf bytes.Buffer -} - -// NewDecoder returns a new decoder with the provided maximum dynamic -// table size. The emitFunc will be called for each valid field -// parsed, in the same goroutine as calls to Write, before Write returns. -func NewDecoder(maxDynamicTableSize uint32, emitFunc func(f HeaderField)) *Decoder { - d := &Decoder{ - emit: emitFunc, - emitEnabled: true, - } - d.dynTab.table.init() - d.dynTab.allowedMaxSize = maxDynamicTableSize - d.dynTab.setMaxSize(maxDynamicTableSize) - return d -} - -// ErrStringLength is returned by Decoder.Write when the max string length -// (as configured by Decoder.SetMaxStringLength) would be violated. -var ErrStringLength = errors.New("hpack: string too long") - -// SetMaxStringLength sets the maximum size of a HeaderField name or -// value string. If a string exceeds this length (even after any -// decompression), Write will return ErrStringLength. -// A value of 0 means unlimited and is the default from NewDecoder. -func (d *Decoder) SetMaxStringLength(n int) { - d.maxStrLen = n -} - -// SetEmitFunc changes the callback used when new header fields -// are decoded. -// It must be non-nil. It does not affect EmitEnabled. -func (d *Decoder) SetEmitFunc(emitFunc func(f HeaderField)) { - d.emit = emitFunc -} - -// SetEmitEnabled controls whether the emitFunc provided to NewDecoder -// should be called. The default is true. -// -// This facility exists to let servers enforce MAX_HEADER_LIST_SIZE -// while still decoding and keeping in-sync with decoder state, but -// without doing unnecessary decompression or generating unnecessary -// garbage for header fields past the limit. -func (d *Decoder) SetEmitEnabled(v bool) { d.emitEnabled = v } - -// EmitEnabled reports whether calls to the emitFunc provided to NewDecoder -// are currently enabled. The default is true. -func (d *Decoder) EmitEnabled() bool { return d.emitEnabled } - -// TODO: add method *Decoder.Reset(maxSize, emitFunc) to let callers re-use Decoders and their -// underlying buffers for garbage reasons. - -func (d *Decoder) SetMaxDynamicTableSize(v uint32) { - d.dynTab.setMaxSize(v) -} - -// SetAllowedMaxDynamicTableSize sets the upper bound that the encoded -// stream (via dynamic table size updates) may set the maximum size -// to. -func (d *Decoder) SetAllowedMaxDynamicTableSize(v uint32) { - d.dynTab.allowedMaxSize = v -} - -type dynamicTable struct { - // http://http2.github.io/http2-spec/compression.html#rfc.section.2.3.2 - table headerFieldTable - size uint32 // in bytes - maxSize uint32 // current maxSize - allowedMaxSize uint32 // maxSize may go up to this, inclusive -} - -func (dt *dynamicTable) setMaxSize(v uint32) { - dt.maxSize = v - dt.evict() -} - -func (dt *dynamicTable) add(f HeaderField) { - dt.table.addEntry(f) - dt.size += f.Size() - dt.evict() -} - -// If we're too big, evict old stuff. -func (dt *dynamicTable) evict() { - var n int - for dt.size > dt.maxSize && n < dt.table.len() { - dt.size -= dt.table.ents[n].Size() - n++ - } - dt.table.evictOldest(n) -} - -func (d *Decoder) maxTableIndex() int { - // This should never overflow. RFC 7540 Section 6.5.2 limits the size of - // the dynamic table to 2^32 bytes, where each entry will occupy more than - // one byte. Further, the staticTable has a fixed, small length. - return d.dynTab.table.len() + staticTable.len() -} - -func (d *Decoder) at(i uint64) (hf HeaderField, ok bool) { - // See Section 2.3.3. - if i == 0 { - return - } - if i <= uint64(staticTable.len()) { - return staticTable.ents[i-1], true - } - if i > uint64(d.maxTableIndex()) { - return - } - // In the dynamic table, newer entries have lower indices. - // However, dt.ents[0] is the oldest entry. Hence, dt.ents is - // the reversed dynamic table. - dt := d.dynTab.table - return dt.ents[dt.len()-(int(i)-staticTable.len())], true -} - -// Decode decodes an entire block. -// -// TODO: remove this method and make it incremental later? This is -// easier for debugging now. -func (d *Decoder) DecodeFull(p []byte) ([]HeaderField, error) { - var hf []HeaderField - saveFunc := d.emit - defer func() { d.emit = saveFunc }() - d.emit = func(f HeaderField) { hf = append(hf, f) } - if _, err := d.Write(p); err != nil { - return nil, err - } - if err := d.Close(); err != nil { - return nil, err - } - return hf, nil -} - -func (d *Decoder) Close() error { - if d.saveBuf.Len() > 0 { - d.saveBuf.Reset() - return DecodingError{errors.New("truncated headers")} - } - return nil -} - -func (d *Decoder) Write(p []byte) (n int, err error) { - if len(p) == 0 { - // Prevent state machine CPU attacks (making us redo - // work up to the point of finding out we don't have - // enough data) - return - } - // Only copy the data if we have to. Optimistically assume - // that p will contain a complete header block. - if d.saveBuf.Len() == 0 { - d.buf = p - } else { - d.saveBuf.Write(p) - d.buf = d.saveBuf.Bytes() - d.saveBuf.Reset() - } - - for len(d.buf) > 0 { - err = d.parseHeaderFieldRepr() - if err == errNeedMore { - // Extra paranoia, making sure saveBuf won't - // get too large. All the varint and string - // reading code earlier should already catch - // overlong things and return ErrStringLength, - // but keep this as a last resort. - const varIntOverhead = 8 // conservative - if d.maxStrLen != 0 && int64(len(d.buf)) > 2*(int64(d.maxStrLen)+varIntOverhead) { - return 0, ErrStringLength - } - d.saveBuf.Write(d.buf) - return len(p), nil - } - if err != nil { - break - } - } - return len(p), err -} - -// errNeedMore is an internal sentinel error value that means the -// buffer is truncated and we need to read more data before we can -// continue parsing. -var errNeedMore = errors.New("need more data") - -type indexType int - -const ( - indexedTrue indexType = iota - indexedFalse - indexedNever -) - -func (v indexType) indexed() bool { return v == indexedTrue } -func (v indexType) sensitive() bool { return v == indexedNever } - -// returns errNeedMore if there isn't enough data available. -// any other error is fatal. -// consumes d.buf iff it returns nil. -// precondition: must be called with len(d.buf) > 0 -func (d *Decoder) parseHeaderFieldRepr() error { - b := d.buf[0] - switch { - case b&128 != 0: - // Indexed representation. - // High bit set? - // http://http2.github.io/http2-spec/compression.html#rfc.section.6.1 - return d.parseFieldIndexed() - case b&192 == 64: - // 6.2.1 Literal Header Field with Incremental Indexing - // 0b10xxxxxx: top two bits are 10 - // http://http2.github.io/http2-spec/compression.html#rfc.section.6.2.1 - return d.parseFieldLiteral(6, indexedTrue) - case b&240 == 0: - // 6.2.2 Literal Header Field without Indexing - // 0b0000xxxx: top four bits are 0000 - // http://http2.github.io/http2-spec/compression.html#rfc.section.6.2.2 - return d.parseFieldLiteral(4, indexedFalse) - case b&240 == 16: - // 6.2.3 Literal Header Field never Indexed - // 0b0001xxxx: top four bits are 0001 - // http://http2.github.io/http2-spec/compression.html#rfc.section.6.2.3 - return d.parseFieldLiteral(4, indexedNever) - case b&224 == 32: - // 6.3 Dynamic Table Size Update - // Top three bits are '001'. - // http://http2.github.io/http2-spec/compression.html#rfc.section.6.3 - return d.parseDynamicTableSizeUpdate() - } - - return DecodingError{errors.New("invalid encoding")} -} - -// (same invariants and behavior as parseHeaderFieldRepr) -func (d *Decoder) parseFieldIndexed() error { - buf := d.buf - idx, buf, err := readVarInt(7, buf) - if err != nil { - return err - } - hf, ok := d.at(idx) - if !ok { - return DecodingError{InvalidIndexError(idx)} - } - d.buf = buf - return d.callEmit(HeaderField{Name: hf.Name, Value: hf.Value}) -} - -// (same invariants and behavior as parseHeaderFieldRepr) -func (d *Decoder) parseFieldLiteral(n uint8, it indexType) error { - buf := d.buf - nameIdx, buf, err := readVarInt(n, buf) - if err != nil { - return err - } - - var hf HeaderField - wantStr := d.emitEnabled || it.indexed() - if nameIdx > 0 { - ihf, ok := d.at(nameIdx) - if !ok { - return DecodingError{InvalidIndexError(nameIdx)} - } - hf.Name = ihf.Name - } else { - hf.Name, buf, err = d.readString(buf, wantStr) - if err != nil { - return err - } - } - hf.Value, buf, err = d.readString(buf, wantStr) - if err != nil { - return err - } - d.buf = buf - if it.indexed() { - d.dynTab.add(hf) - } - hf.Sensitive = it.sensitive() - return d.callEmit(hf) -} - -func (d *Decoder) callEmit(hf HeaderField) error { - if d.maxStrLen != 0 { - if len(hf.Name) > d.maxStrLen || len(hf.Value) > d.maxStrLen { - return ErrStringLength - } - } - if d.emitEnabled { - d.emit(hf) - } - return nil -} - -// (same invariants and behavior as parseHeaderFieldRepr) -func (d *Decoder) parseDynamicTableSizeUpdate() error { - buf := d.buf - size, buf, err := readVarInt(5, buf) - if err != nil { - return err - } - if size > uint64(d.dynTab.allowedMaxSize) { - return DecodingError{errors.New("dynamic table size update too large")} - } - d.dynTab.setMaxSize(uint32(size)) - d.buf = buf - return nil -} - -var errVarintOverflow = DecodingError{errors.New("varint integer overflow")} - -// readVarInt reads an unsigned variable length integer off the -// beginning of p. n is the parameter as described in -// http://http2.github.io/http2-spec/compression.html#rfc.section.5.1. -// -// n must always be between 1 and 8. -// -// The returned remain buffer is either a smaller suffix of p, or err != nil. -// The error is errNeedMore if p doesn't contain a complete integer. -func readVarInt(n byte, p []byte) (i uint64, remain []byte, err error) { - if n < 1 || n > 8 { - panic("bad n") - } - if len(p) == 0 { - return 0, p, errNeedMore - } - i = uint64(p[0]) - if n < 8 { - i &= (1 << uint64(n)) - 1 - } - if i < (1< 0 { - b := p[0] - p = p[1:] - i += uint64(b&127) << m - if b&128 == 0 { - return i, p, nil - } - m += 7 - if m >= 63 { // TODO: proper overflow check. making this up. - return 0, origP, errVarintOverflow - } - } - return 0, origP, errNeedMore -} - -// readString decodes an hpack string from p. -// -// wantStr is whether s will be used. If false, decompression and -// []byte->string garbage are skipped if s will be ignored -// anyway. This does mean that huffman decoding errors for non-indexed -// strings past the MAX_HEADER_LIST_SIZE are ignored, but the server -// is returning an error anyway, and because they're not indexed, the error -// won't affect the decoding state. -func (d *Decoder) readString(p []byte, wantStr bool) (s string, remain []byte, err error) { - if len(p) == 0 { - return "", p, errNeedMore - } - isHuff := p[0]&128 != 0 - strLen, p, err := readVarInt(7, p) - if err != nil { - return "", p, err - } - if d.maxStrLen != 0 && strLen > uint64(d.maxStrLen) { - return "", nil, ErrStringLength - } - if uint64(len(p)) < strLen { - return "", p, errNeedMore - } - if !isHuff { - if wantStr { - s = string(p[:strLen]) - } - return s, p[strLen:], nil - } - - if wantStr { - buf := bufPool.Get().(*bytes.Buffer) - buf.Reset() // don't trust others - defer bufPool.Put(buf) - if err := huffmanDecode(buf, d.maxStrLen, p[:strLen]); err != nil { - buf.Reset() - return "", nil, err - } - s = buf.String() - buf.Reset() // be nice to GC - } - return s, p[strLen:], nil -} diff --git a/vendor/golang.org/x/net/http2/hpack/hpack_test.go b/vendor/golang.org/x/net/http2/hpack/hpack_test.go deleted file mode 100644 index c2f8fd102..000000000 --- a/vendor/golang.org/x/net/http2/hpack/hpack_test.go +++ /dev/null @@ -1,718 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package hpack - -import ( - "bytes" - "encoding/hex" - "fmt" - "math/rand" - "reflect" - "strings" - "testing" - "time" -) - -func (d *Decoder) mustAt(idx int) HeaderField { - if hf, ok := d.at(uint64(idx)); !ok { - panic(fmt.Sprintf("bogus index %d", idx)) - } else { - return hf - } -} - -func TestDynamicTableAt(t *testing.T) { - d := NewDecoder(4096, nil) - at := d.mustAt - if got, want := at(2), (pair(":method", "GET")); got != want { - t.Errorf("at(2) = %v; want %v", got, want) - } - d.dynTab.add(pair("foo", "bar")) - d.dynTab.add(pair("blake", "miz")) - if got, want := at(staticTable.len()+1), (pair("blake", "miz")); got != want { - t.Errorf("at(dyn 1) = %v; want %v", got, want) - } - if got, want := at(staticTable.len()+2), (pair("foo", "bar")); got != want { - t.Errorf("at(dyn 2) = %v; want %v", got, want) - } - if got, want := at(3), (pair(":method", "POST")); got != want { - t.Errorf("at(3) = %v; want %v", got, want) - } -} - -func TestDynamicTableSizeEvict(t *testing.T) { - d := NewDecoder(4096, nil) - if want := uint32(0); d.dynTab.size != want { - t.Fatalf("size = %d; want %d", d.dynTab.size, want) - } - add := d.dynTab.add - add(pair("blake", "eats pizza")) - if want := uint32(15 + 32); d.dynTab.size != want { - t.Fatalf("after pizza, size = %d; want %d", d.dynTab.size, want) - } - add(pair("foo", "bar")) - if want := uint32(15 + 32 + 6 + 32); d.dynTab.size != want { - t.Fatalf("after foo bar, size = %d; want %d", d.dynTab.size, want) - } - d.dynTab.setMaxSize(15 + 32 + 1 /* slop */) - if want := uint32(6 + 32); d.dynTab.size != want { - t.Fatalf("after setMaxSize, size = %d; want %d", d.dynTab.size, want) - } - if got, want := d.mustAt(staticTable.len()+1), (pair("foo", "bar")); got != want { - t.Errorf("at(dyn 1) = %v; want %v", got, want) - } - add(pair("long", strings.Repeat("x", 500))) - if want := uint32(0); d.dynTab.size != want { - t.Fatalf("after big one, size = %d; want %d", d.dynTab.size, want) - } -} - -func TestDecoderDecode(t *testing.T) { - tests := []struct { - name string - in []byte - want []HeaderField - wantDynTab []HeaderField // newest entry first - }{ - // C.2.1 Literal Header Field with Indexing - // http://http2.github.io/http2-spec/compression.html#rfc.section.C.2.1 - {"C.2.1", dehex("400a 6375 7374 6f6d 2d6b 6579 0d63 7573 746f 6d2d 6865 6164 6572"), - []HeaderField{pair("custom-key", "custom-header")}, - []HeaderField{pair("custom-key", "custom-header")}, - }, - - // C.2.2 Literal Header Field without Indexing - // http://http2.github.io/http2-spec/compression.html#rfc.section.C.2.2 - {"C.2.2", dehex("040c 2f73 616d 706c 652f 7061 7468"), - []HeaderField{pair(":path", "/sample/path")}, - []HeaderField{}}, - - // C.2.3 Literal Header Field never Indexed - // http://http2.github.io/http2-spec/compression.html#rfc.section.C.2.3 - {"C.2.3", dehex("1008 7061 7373 776f 7264 0673 6563 7265 74"), - []HeaderField{{"password", "secret", true}}, - []HeaderField{}}, - - // C.2.4 Indexed Header Field - // http://http2.github.io/http2-spec/compression.html#rfc.section.C.2.4 - {"C.2.4", []byte("\x82"), - []HeaderField{pair(":method", "GET")}, - []HeaderField{}}, - } - for _, tt := range tests { - d := NewDecoder(4096, nil) - hf, err := d.DecodeFull(tt.in) - if err != nil { - t.Errorf("%s: %v", tt.name, err) - continue - } - if !reflect.DeepEqual(hf, tt.want) { - t.Errorf("%s: Got %v; want %v", tt.name, hf, tt.want) - } - gotDynTab := d.dynTab.reverseCopy() - if !reflect.DeepEqual(gotDynTab, tt.wantDynTab) { - t.Errorf("%s: dynamic table after = %v; want %v", tt.name, gotDynTab, tt.wantDynTab) - } - } -} - -func (dt *dynamicTable) reverseCopy() (hf []HeaderField) { - hf = make([]HeaderField, len(dt.table.ents)) - for i := range hf { - hf[i] = dt.table.ents[len(dt.table.ents)-1-i] - } - return -} - -type encAndWant struct { - enc []byte - want []HeaderField - wantDynTab []HeaderField - wantDynSize uint32 -} - -// C.3 Request Examples without Huffman Coding -// http://http2.github.io/http2-spec/compression.html#rfc.section.C.3 -func TestDecodeC3_NoHuffman(t *testing.T) { - testDecodeSeries(t, 4096, []encAndWant{ - {dehex("8286 8441 0f77 7777 2e65 7861 6d70 6c65 2e63 6f6d"), - []HeaderField{ - pair(":method", "GET"), - pair(":scheme", "http"), - pair(":path", "/"), - pair(":authority", "www.example.com"), - }, - []HeaderField{ - pair(":authority", "www.example.com"), - }, - 57, - }, - {dehex("8286 84be 5808 6e6f 2d63 6163 6865"), - []HeaderField{ - pair(":method", "GET"), - pair(":scheme", "http"), - pair(":path", "/"), - pair(":authority", "www.example.com"), - pair("cache-control", "no-cache"), - }, - []HeaderField{ - pair("cache-control", "no-cache"), - pair(":authority", "www.example.com"), - }, - 110, - }, - {dehex("8287 85bf 400a 6375 7374 6f6d 2d6b 6579 0c63 7573 746f 6d2d 7661 6c75 65"), - []HeaderField{ - pair(":method", "GET"), - pair(":scheme", "https"), - pair(":path", "/index.html"), - pair(":authority", "www.example.com"), - pair("custom-key", "custom-value"), - }, - []HeaderField{ - pair("custom-key", "custom-value"), - pair("cache-control", "no-cache"), - pair(":authority", "www.example.com"), - }, - 164, - }, - }) -} - -// C.4 Request Examples with Huffman Coding -// http://http2.github.io/http2-spec/compression.html#rfc.section.C.4 -func TestDecodeC4_Huffman(t *testing.T) { - testDecodeSeries(t, 4096, []encAndWant{ - {dehex("8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4 ff"), - []HeaderField{ - pair(":method", "GET"), - pair(":scheme", "http"), - pair(":path", "/"), - pair(":authority", "www.example.com"), - }, - []HeaderField{ - pair(":authority", "www.example.com"), - }, - 57, - }, - {dehex("8286 84be 5886 a8eb 1064 9cbf"), - []HeaderField{ - pair(":method", "GET"), - pair(":scheme", "http"), - pair(":path", "/"), - pair(":authority", "www.example.com"), - pair("cache-control", "no-cache"), - }, - []HeaderField{ - pair("cache-control", "no-cache"), - pair(":authority", "www.example.com"), - }, - 110, - }, - {dehex("8287 85bf 4088 25a8 49e9 5ba9 7d7f 8925 a849 e95b b8e8 b4bf"), - []HeaderField{ - pair(":method", "GET"), - pair(":scheme", "https"), - pair(":path", "/index.html"), - pair(":authority", "www.example.com"), - pair("custom-key", "custom-value"), - }, - []HeaderField{ - pair("custom-key", "custom-value"), - pair("cache-control", "no-cache"), - pair(":authority", "www.example.com"), - }, - 164, - }, - }) -} - -// http://http2.github.io/http2-spec/compression.html#rfc.section.C.5 -// "This section shows several consecutive header lists, corresponding -// to HTTP responses, on the same connection. The HTTP/2 setting -// parameter SETTINGS_HEADER_TABLE_SIZE is set to the value of 256 -// octets, causing some evictions to occur." -func TestDecodeC5_ResponsesNoHuff(t *testing.T) { - testDecodeSeries(t, 256, []encAndWant{ - {dehex(` -4803 3330 3258 0770 7269 7661 7465 611d -4d6f 6e2c 2032 3120 4f63 7420 3230 3133 -2032 303a 3133 3a32 3120 474d 546e 1768 -7474 7073 3a2f 2f77 7777 2e65 7861 6d70 -6c65 2e63 6f6d -`), - []HeaderField{ - pair(":status", "302"), - pair("cache-control", "private"), - pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - pair("location", "https://www.example.com"), - }, - []HeaderField{ - pair("location", "https://www.example.com"), - pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - pair("cache-control", "private"), - pair(":status", "302"), - }, - 222, - }, - {dehex("4803 3330 37c1 c0bf"), - []HeaderField{ - pair(":status", "307"), - pair("cache-control", "private"), - pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - pair("location", "https://www.example.com"), - }, - []HeaderField{ - pair(":status", "307"), - pair("location", "https://www.example.com"), - pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - pair("cache-control", "private"), - }, - 222, - }, - {dehex(` -88c1 611d 4d6f 6e2c 2032 3120 4f63 7420 -3230 3133 2032 303a 3133 3a32 3220 474d -54c0 5a04 677a 6970 7738 666f 6f3d 4153 -444a 4b48 514b 425a 584f 5157 454f 5049 -5541 5851 5745 4f49 553b 206d 6178 2d61 -6765 3d33 3630 303b 2076 6572 7369 6f6e -3d31 -`), - []HeaderField{ - pair(":status", "200"), - pair("cache-control", "private"), - pair("date", "Mon, 21 Oct 2013 20:13:22 GMT"), - pair("location", "https://www.example.com"), - pair("content-encoding", "gzip"), - pair("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"), - }, - []HeaderField{ - pair("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"), - pair("content-encoding", "gzip"), - pair("date", "Mon, 21 Oct 2013 20:13:22 GMT"), - }, - 215, - }, - }) -} - -// http://http2.github.io/http2-spec/compression.html#rfc.section.C.6 -// "This section shows the same examples as the previous section, but -// using Huffman encoding for the literal values. The HTTP/2 setting -// parameter SETTINGS_HEADER_TABLE_SIZE is set to the value of 256 -// octets, causing some evictions to occur. The eviction mechanism -// uses the length of the decoded literal values, so the same -// evictions occurs as in the previous section." -func TestDecodeC6_ResponsesHuffman(t *testing.T) { - testDecodeSeries(t, 256, []encAndWant{ - {dehex(` -4882 6402 5885 aec3 771a 4b61 96d0 7abe -9410 54d4 44a8 2005 9504 0b81 66e0 82a6 -2d1b ff6e 919d 29ad 1718 63c7 8f0b 97c8 -e9ae 82ae 43d3 -`), - []HeaderField{ - pair(":status", "302"), - pair("cache-control", "private"), - pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - pair("location", "https://www.example.com"), - }, - []HeaderField{ - pair("location", "https://www.example.com"), - pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - pair("cache-control", "private"), - pair(":status", "302"), - }, - 222, - }, - {dehex("4883 640e ffc1 c0bf"), - []HeaderField{ - pair(":status", "307"), - pair("cache-control", "private"), - pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - pair("location", "https://www.example.com"), - }, - []HeaderField{ - pair(":status", "307"), - pair("location", "https://www.example.com"), - pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - pair("cache-control", "private"), - }, - 222, - }, - {dehex(` -88c1 6196 d07a be94 1054 d444 a820 0595 -040b 8166 e084 a62d 1bff c05a 839b d9ab -77ad 94e7 821d d7f2 e6c7 b335 dfdf cd5b -3960 d5af 2708 7f36 72c1 ab27 0fb5 291f -9587 3160 65c0 03ed 4ee5 b106 3d50 07 -`), - []HeaderField{ - pair(":status", "200"), - pair("cache-control", "private"), - pair("date", "Mon, 21 Oct 2013 20:13:22 GMT"), - pair("location", "https://www.example.com"), - pair("content-encoding", "gzip"), - pair("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"), - }, - []HeaderField{ - pair("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"), - pair("content-encoding", "gzip"), - pair("date", "Mon, 21 Oct 2013 20:13:22 GMT"), - }, - 215, - }, - }) -} - -func testDecodeSeries(t *testing.T, size uint32, steps []encAndWant) { - d := NewDecoder(size, nil) - for i, step := range steps { - hf, err := d.DecodeFull(step.enc) - if err != nil { - t.Fatalf("Error at step index %d: %v", i, err) - } - if !reflect.DeepEqual(hf, step.want) { - t.Fatalf("At step index %d: Got headers %v; want %v", i, hf, step.want) - } - gotDynTab := d.dynTab.reverseCopy() - if !reflect.DeepEqual(gotDynTab, step.wantDynTab) { - t.Errorf("After step index %d, dynamic table = %v; want %v", i, gotDynTab, step.wantDynTab) - } - if d.dynTab.size != step.wantDynSize { - t.Errorf("After step index %d, dynamic table size = %v; want %v", i, d.dynTab.size, step.wantDynSize) - } - } -} - -func TestHuffmanDecodeExcessPadding(t *testing.T) { - tests := [][]byte{ - {0xff}, // Padding Exceeds 7 bits - {0x1f, 0xff}, // {"a", 1 byte excess padding} - {0x1f, 0xff, 0xff}, // {"a", 2 byte excess padding} - {0x1f, 0xff, 0xff, 0xff}, // {"a", 3 byte excess padding} - {0xff, 0x9f, 0xff, 0xff, 0xff}, // {"a", 29 bit excess padding} - {'R', 0xbc, '0', 0xff, 0xff, 0xff, 0xff}, // Padding ends on partial symbol. - } - for i, in := range tests { - var buf bytes.Buffer - if _, err := HuffmanDecode(&buf, in); err != ErrInvalidHuffman { - t.Errorf("test-%d: decode(%q) = %v; want ErrInvalidHuffman", i, in, err) - } - } -} - -func TestHuffmanDecodeEOS(t *testing.T) { - in := []byte{0xff, 0xff, 0xff, 0xff, 0xfc} // {EOS, "?"} - var buf bytes.Buffer - if _, err := HuffmanDecode(&buf, in); err != ErrInvalidHuffman { - t.Errorf("error = %v; want ErrInvalidHuffman", err) - } -} - -func TestHuffmanDecodeMaxLengthOnTrailingByte(t *testing.T) { - in := []byte{0x00, 0x01} // {"0", "0", "0"} - var buf bytes.Buffer - if err := huffmanDecode(&buf, 2, in); err != ErrStringLength { - t.Errorf("error = %v; want ErrStringLength", err) - } -} - -func TestHuffmanDecodeCorruptPadding(t *testing.T) { - in := []byte{0x00} - var buf bytes.Buffer - if _, err := HuffmanDecode(&buf, in); err != ErrInvalidHuffman { - t.Errorf("error = %v; want ErrInvalidHuffman", err) - } -} - -func TestHuffmanDecode(t *testing.T) { - tests := []struct { - inHex, want string - }{ - {"f1e3 c2e5 f23a 6ba0 ab90 f4ff", "www.example.com"}, - {"a8eb 1064 9cbf", "no-cache"}, - {"25a8 49e9 5ba9 7d7f", "custom-key"}, - {"25a8 49e9 5bb8 e8b4 bf", "custom-value"}, - {"6402", "302"}, - {"aec3 771a 4b", "private"}, - {"d07a be94 1054 d444 a820 0595 040b 8166 e082 a62d 1bff", "Mon, 21 Oct 2013 20:13:21 GMT"}, - {"9d29 ad17 1863 c78f 0b97 c8e9 ae82 ae43 d3", "https://www.example.com"}, - {"9bd9 ab", "gzip"}, - {"94e7 821d d7f2 e6c7 b335 dfdf cd5b 3960 d5af 2708 7f36 72c1 ab27 0fb5 291f 9587 3160 65c0 03ed 4ee5 b106 3d50 07", - "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"}, - } - for i, tt := range tests { - var buf bytes.Buffer - in, err := hex.DecodeString(strings.Replace(tt.inHex, " ", "", -1)) - if err != nil { - t.Errorf("%d. hex input error: %v", i, err) - continue - } - if _, err := HuffmanDecode(&buf, in); err != nil { - t.Errorf("%d. decode error: %v", i, err) - continue - } - if got := buf.String(); tt.want != got { - t.Errorf("%d. decode = %q; want %q", i, got, tt.want) - } - } -} - -func TestAppendHuffmanString(t *testing.T) { - tests := []struct { - in, want string - }{ - {"www.example.com", "f1e3 c2e5 f23a 6ba0 ab90 f4ff"}, - {"no-cache", "a8eb 1064 9cbf"}, - {"custom-key", "25a8 49e9 5ba9 7d7f"}, - {"custom-value", "25a8 49e9 5bb8 e8b4 bf"}, - {"302", "6402"}, - {"private", "aec3 771a 4b"}, - {"Mon, 21 Oct 2013 20:13:21 GMT", "d07a be94 1054 d444 a820 0595 040b 8166 e082 a62d 1bff"}, - {"https://www.example.com", "9d29 ad17 1863 c78f 0b97 c8e9 ae82 ae43 d3"}, - {"gzip", "9bd9 ab"}, - {"foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", - "94e7 821d d7f2 e6c7 b335 dfdf cd5b 3960 d5af 2708 7f36 72c1 ab27 0fb5 291f 9587 3160 65c0 03ed 4ee5 b106 3d50 07"}, - } - for i, tt := range tests { - buf := []byte{} - want := strings.Replace(tt.want, " ", "", -1) - buf = AppendHuffmanString(buf, tt.in) - if got := hex.EncodeToString(buf); want != got { - t.Errorf("%d. encode = %q; want %q", i, got, want) - } - } -} - -func TestHuffmanMaxStrLen(t *testing.T) { - const msg = "Some string" - huff := AppendHuffmanString(nil, msg) - - testGood := func(max int) { - var out bytes.Buffer - if err := huffmanDecode(&out, max, huff); err != nil { - t.Errorf("For maxLen=%d, unexpected error: %v", max, err) - } - if out.String() != msg { - t.Errorf("For maxLen=%d, out = %q; want %q", max, out.String(), msg) - } - } - testGood(0) - testGood(len(msg)) - testGood(len(msg) + 1) - - var out bytes.Buffer - if err := huffmanDecode(&out, len(msg)-1, huff); err != ErrStringLength { - t.Errorf("err = %v; want ErrStringLength", err) - } -} - -func TestHuffmanRoundtripStress(t *testing.T) { - const Len = 50 // of uncompressed string - input := make([]byte, Len) - var output bytes.Buffer - var huff []byte - - n := 5000 - if testing.Short() { - n = 100 - } - seed := time.Now().UnixNano() - t.Logf("Seed = %v", seed) - src := rand.New(rand.NewSource(seed)) - var encSize int64 - for i := 0; i < n; i++ { - for l := range input { - input[l] = byte(src.Intn(256)) - } - huff = AppendHuffmanString(huff[:0], string(input)) - encSize += int64(len(huff)) - output.Reset() - if err := huffmanDecode(&output, 0, huff); err != nil { - t.Errorf("Failed to decode %q -> %q -> error %v", input, huff, err) - continue - } - if !bytes.Equal(output.Bytes(), input) { - t.Errorf("Roundtrip failure on %q -> %q -> %q", input, huff, output.Bytes()) - } - } - t.Logf("Compressed size of original: %0.02f%% (%v -> %v)", 100*(float64(encSize)/(Len*float64(n))), Len*n, encSize) -} - -func TestHuffmanDecodeFuzz(t *testing.T) { - const Len = 50 // of compressed - var buf, zbuf bytes.Buffer - - n := 5000 - if testing.Short() { - n = 100 - } - seed := time.Now().UnixNano() - t.Logf("Seed = %v", seed) - src := rand.New(rand.NewSource(seed)) - numFail := 0 - for i := 0; i < n; i++ { - zbuf.Reset() - if i == 0 { - // Start with at least one invalid one. - zbuf.WriteString("00\x91\xff\xff\xff\xff\xc8") - } else { - for l := 0; l < Len; l++ { - zbuf.WriteByte(byte(src.Intn(256))) - } - } - - buf.Reset() - if err := huffmanDecode(&buf, 0, zbuf.Bytes()); err != nil { - if err == ErrInvalidHuffman { - numFail++ - continue - } - t.Errorf("Failed to decode %q: %v", zbuf.Bytes(), err) - continue - } - } - t.Logf("%0.02f%% are invalid (%d / %d)", 100*float64(numFail)/float64(n), numFail, n) - if numFail < 1 { - t.Error("expected at least one invalid huffman encoding (test starts with one)") - } -} - -func TestReadVarInt(t *testing.T) { - type res struct { - i uint64 - consumed int - err error - } - tests := []struct { - n byte - p []byte - want res - }{ - // Fits in a byte: - {1, []byte{0}, res{0, 1, nil}}, - {2, []byte{2}, res{2, 1, nil}}, - {3, []byte{6}, res{6, 1, nil}}, - {4, []byte{14}, res{14, 1, nil}}, - {5, []byte{30}, res{30, 1, nil}}, - {6, []byte{62}, res{62, 1, nil}}, - {7, []byte{126}, res{126, 1, nil}}, - {8, []byte{254}, res{254, 1, nil}}, - - // Doesn't fit in a byte: - {1, []byte{1}, res{0, 0, errNeedMore}}, - {2, []byte{3}, res{0, 0, errNeedMore}}, - {3, []byte{7}, res{0, 0, errNeedMore}}, - {4, []byte{15}, res{0, 0, errNeedMore}}, - {5, []byte{31}, res{0, 0, errNeedMore}}, - {6, []byte{63}, res{0, 0, errNeedMore}}, - {7, []byte{127}, res{0, 0, errNeedMore}}, - {8, []byte{255}, res{0, 0, errNeedMore}}, - - // Ignoring top bits: - {5, []byte{255, 154, 10}, res{1337, 3, nil}}, // high dummy three bits: 111 - {5, []byte{159, 154, 10}, res{1337, 3, nil}}, // high dummy three bits: 100 - {5, []byte{191, 154, 10}, res{1337, 3, nil}}, // high dummy three bits: 101 - - // Extra byte: - {5, []byte{191, 154, 10, 2}, res{1337, 3, nil}}, // extra byte - - // Short a byte: - {5, []byte{191, 154}, res{0, 0, errNeedMore}}, - - // integer overflow: - {1, []byte{255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}, res{0, 0, errVarintOverflow}}, - } - for _, tt := range tests { - i, remain, err := readVarInt(tt.n, tt.p) - consumed := len(tt.p) - len(remain) - got := res{i, consumed, err} - if got != tt.want { - t.Errorf("readVarInt(%d, %v ~ %x) = %+v; want %+v", tt.n, tt.p, tt.p, got, tt.want) - } - } -} - -// Fuzz crash, originally reported at https://github.com/bradfitz/http2/issues/56 -func TestHuffmanFuzzCrash(t *testing.T) { - got, err := HuffmanDecodeToString([]byte("00\x91\xff\xff\xff\xff\xc8")) - if got != "" { - t.Errorf("Got %q; want empty string", got) - } - if err != ErrInvalidHuffman { - t.Errorf("Err = %v; want ErrInvalidHuffman", err) - } -} - -func dehex(s string) []byte { - s = strings.Replace(s, " ", "", -1) - s = strings.Replace(s, "\n", "", -1) - b, err := hex.DecodeString(s) - if err != nil { - panic(err) - } - return b -} - -func TestEmitEnabled(t *testing.T) { - var buf bytes.Buffer - enc := NewEncoder(&buf) - enc.WriteField(HeaderField{Name: "foo", Value: "bar"}) - enc.WriteField(HeaderField{Name: "foo", Value: "bar"}) - - numCallback := 0 - var dec *Decoder - dec = NewDecoder(8<<20, func(HeaderField) { - numCallback++ - dec.SetEmitEnabled(false) - }) - if !dec.EmitEnabled() { - t.Errorf("initial emit enabled = false; want true") - } - if _, err := dec.Write(buf.Bytes()); err != nil { - t.Error(err) - } - if numCallback != 1 { - t.Errorf("num callbacks = %d; want 1", numCallback) - } - if dec.EmitEnabled() { - t.Errorf("emit enabled = true; want false") - } -} - -func TestSaveBufLimit(t *testing.T) { - const maxStr = 1 << 10 - var got []HeaderField - dec := NewDecoder(initialHeaderTableSize, func(hf HeaderField) { - got = append(got, hf) - }) - dec.SetMaxStringLength(maxStr) - var frag []byte - frag = append(frag[:0], encodeTypeByte(false, false)) - frag = appendVarInt(frag, 7, 3) - frag = append(frag, "foo"...) - frag = appendVarInt(frag, 7, 3) - frag = append(frag, "bar"...) - - if _, err := dec.Write(frag); err != nil { - t.Fatal(err) - } - - want := []HeaderField{{Name: "foo", Value: "bar"}} - if !reflect.DeepEqual(got, want) { - t.Errorf("After small writes, got %v; want %v", got, want) - } - - frag = append(frag[:0], encodeTypeByte(false, false)) - frag = appendVarInt(frag, 7, maxStr*3) - frag = append(frag, make([]byte, maxStr*3)...) - - _, err := dec.Write(frag) - if err != ErrStringLength { - t.Fatalf("Write error = %v; want ErrStringLength", err) - } -} diff --git a/vendor/golang.org/x/net/http2/hpack/huffman.go b/vendor/golang.org/x/net/http2/hpack/huffman.go deleted file mode 100644 index 8850e3946..000000000 --- a/vendor/golang.org/x/net/http2/hpack/huffman.go +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package hpack - -import ( - "bytes" - "errors" - "io" - "sync" -) - -var bufPool = sync.Pool{ - New: func() interface{} { return new(bytes.Buffer) }, -} - -// HuffmanDecode decodes the string in v and writes the expanded -// result to w, returning the number of bytes written to w and the -// Write call's return value. At most one Write call is made. -func HuffmanDecode(w io.Writer, v []byte) (int, error) { - buf := bufPool.Get().(*bytes.Buffer) - buf.Reset() - defer bufPool.Put(buf) - if err := huffmanDecode(buf, 0, v); err != nil { - return 0, err - } - return w.Write(buf.Bytes()) -} - -// HuffmanDecodeToString decodes the string in v. -func HuffmanDecodeToString(v []byte) (string, error) { - buf := bufPool.Get().(*bytes.Buffer) - buf.Reset() - defer bufPool.Put(buf) - if err := huffmanDecode(buf, 0, v); err != nil { - return "", err - } - return buf.String(), nil -} - -// ErrInvalidHuffman is returned for errors found decoding -// Huffman-encoded strings. -var ErrInvalidHuffman = errors.New("hpack: invalid Huffman-encoded data") - -// huffmanDecode decodes v to buf. -// If maxLen is greater than 0, attempts to write more to buf than -// maxLen bytes will return ErrStringLength. -func huffmanDecode(buf *bytes.Buffer, maxLen int, v []byte) error { - n := rootHuffmanNode - // cur is the bit buffer that has not been fed into n. - // cbits is the number of low order bits in cur that are valid. - // sbits is the number of bits of the symbol prefix being decoded. - cur, cbits, sbits := uint(0), uint8(0), uint8(0) - for _, b := range v { - cur = cur<<8 | uint(b) - cbits += 8 - sbits += 8 - for cbits >= 8 { - idx := byte(cur >> (cbits - 8)) - n = n.children[idx] - if n == nil { - return ErrInvalidHuffman - } - if n.children == nil { - if maxLen != 0 && buf.Len() == maxLen { - return ErrStringLength - } - buf.WriteByte(n.sym) - cbits -= n.codeLen - n = rootHuffmanNode - sbits = cbits - } else { - cbits -= 8 - } - } - } - for cbits > 0 { - n = n.children[byte(cur<<(8-cbits))] - if n == nil { - return ErrInvalidHuffman - } - if n.children != nil || n.codeLen > cbits { - break - } - if maxLen != 0 && buf.Len() == maxLen { - return ErrStringLength - } - buf.WriteByte(n.sym) - cbits -= n.codeLen - n = rootHuffmanNode - sbits = cbits - } - if sbits > 7 { - // Either there was an incomplete symbol, or overlong padding. - // Both are decoding errors per RFC 7541 section 5.2. - return ErrInvalidHuffman - } - if mask := uint(1< 8 { - codeLen -= 8 - i := uint8(code >> codeLen) - if cur.children[i] == nil { - cur.children[i] = newInternalNode() - } - cur = cur.children[i] - } - shift := 8 - codeLen - start, end := int(uint8(code<> (nbits - rembits)) - dst[len(dst)-1] |= t - } - - return dst -} - -// HuffmanEncodeLength returns the number of bytes required to encode -// s in Huffman codes. The result is round up to byte boundary. -func HuffmanEncodeLength(s string) uint64 { - n := uint64(0) - for i := 0; i < len(s); i++ { - n += uint64(huffmanCodeLen[s[i]]) - } - return (n + 7) / 8 -} - -// appendByteToHuffmanCode appends Huffman code for c to dst and -// returns the extended buffer and the remaining bits in the last -// element. The appending is not byte aligned and the remaining bits -// in the last element of dst is given in rembits. -func appendByteToHuffmanCode(dst []byte, rembits uint8, c byte) ([]byte, uint8) { - code := huffmanCodes[c] - nbits := huffmanCodeLen[c] - - for { - if rembits > nbits { - t := uint8(code << (rembits - nbits)) - dst[len(dst)-1] |= t - rembits -= nbits - break - } - - t := uint8(code >> (nbits - rembits)) - dst[len(dst)-1] |= t - - nbits -= rembits - rembits = 8 - - if nbits == 0 { - break - } - - dst = append(dst, 0) - } - - return dst, rembits -} diff --git a/vendor/golang.org/x/net/http2/hpack/tables.go b/vendor/golang.org/x/net/http2/hpack/tables.go deleted file mode 100644 index 31bd5a553..000000000 --- a/vendor/golang.org/x/net/http2/hpack/tables.go +++ /dev/null @@ -1,478 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package hpack - -import ( - "fmt" -) - -// headerFieldTable implements a list of HeaderFields. -// This is used to implement the static and dynamic tables. -type headerFieldTable struct { - // For static tables, entries are never evicted. - // - // For dynamic tables, entries are evicted from ents[0] and added to the end. - // Each entry has a unique id that starts at one and increments for each - // entry that is added. This unique id is stable across evictions, meaning - // it can be used as a pointer to a specific entry. As in hpack, unique ids - // are 1-based. The unique id for ents[k] is k + evictCount + 1. - // - // Zero is not a valid unique id. - // - // evictCount should not overflow in any remotely practical situation. In - // practice, we will have one dynamic table per HTTP/2 connection. If we - // assume a very powerful server that handles 1M QPS per connection and each - // request adds (then evicts) 100 entries from the table, it would still take - // 2M years for evictCount to overflow. - ents []HeaderField - evictCount uint64 - - // byName maps a HeaderField name to the unique id of the newest entry with - // the same name. See above for a definition of "unique id". - byName map[string]uint64 - - // byNameValue maps a HeaderField name/value pair to the unique id of the newest - // entry with the same name and value. See above for a definition of "unique id". - byNameValue map[pairNameValue]uint64 -} - -type pairNameValue struct { - name, value string -} - -func (t *headerFieldTable) init() { - t.byName = make(map[string]uint64) - t.byNameValue = make(map[pairNameValue]uint64) -} - -// len reports the number of entries in the table. -func (t *headerFieldTable) len() int { - return len(t.ents) -} - -// addEntry adds a new entry. -func (t *headerFieldTable) addEntry(f HeaderField) { - id := uint64(t.len()) + t.evictCount + 1 - t.byName[f.Name] = id - t.byNameValue[pairNameValue{f.Name, f.Value}] = id - t.ents = append(t.ents, f) -} - -// evictOldest evicts the n oldest entries in the table. -func (t *headerFieldTable) evictOldest(n int) { - if n > t.len() { - panic(fmt.Sprintf("evictOldest(%v) on table with %v entries", n, t.len())) - } - for k := 0; k < n; k++ { - f := t.ents[k] - id := t.evictCount + uint64(k) + 1 - if t.byName[f.Name] == id { - delete(t.byName, f.Name) - } - if p := (pairNameValue{f.Name, f.Value}); t.byNameValue[p] == id { - delete(t.byNameValue, p) - } - } - copy(t.ents, t.ents[n:]) - for k := t.len() - n; k < t.len(); k++ { - t.ents[k] = HeaderField{} // so strings can be garbage collected - } - t.ents = t.ents[:t.len()-n] - if t.evictCount+uint64(n) < t.evictCount { - panic("evictCount overflow") - } - t.evictCount += uint64(n) -} - -// search finds f in the table. If there is no match, i is 0. -// If both name and value match, i is the matched index and nameValueMatch -// becomes true. If only name matches, i points to that index and -// nameValueMatch becomes false. -// -// The returned index is a 1-based HPACK index. For dynamic tables, HPACK says -// that index 1 should be the newest entry, but t.ents[0] is the oldest entry, -// meaning t.ents is reversed for dynamic tables. Hence, when t is a dynamic -// table, the return value i actually refers to the entry t.ents[t.len()-i]. -// -// All tables are assumed to be a dynamic tables except for the global -// staticTable pointer. -// -// See Section 2.3.3. -func (t *headerFieldTable) search(f HeaderField) (i uint64, nameValueMatch bool) { - if !f.Sensitive { - if id := t.byNameValue[pairNameValue{f.Name, f.Value}]; id != 0 { - return t.idToIndex(id), true - } - } - if id := t.byName[f.Name]; id != 0 { - return t.idToIndex(id), false - } - return 0, false -} - -// idToIndex converts a unique id to an HPACK index. -// See Section 2.3.3. -func (t *headerFieldTable) idToIndex(id uint64) uint64 { - if id <= t.evictCount { - panic(fmt.Sprintf("id (%v) <= evictCount (%v)", id, t.evictCount)) - } - k := id - t.evictCount - 1 // convert id to an index t.ents[k] - if t != staticTable { - return uint64(t.len()) - k // dynamic table - } - return k + 1 -} - -func pair(name, value string) HeaderField { - return HeaderField{Name: name, Value: value} -} - -// http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07#appendix-B -var staticTable = newStaticTable() - -func newStaticTable() *headerFieldTable { - t := &headerFieldTable{} - t.init() - t.addEntry(pair(":authority", "")) - t.addEntry(pair(":method", "GET")) - t.addEntry(pair(":method", "POST")) - t.addEntry(pair(":path", "/")) - t.addEntry(pair(":path", "/index.html")) - t.addEntry(pair(":scheme", "http")) - t.addEntry(pair(":scheme", "https")) - t.addEntry(pair(":status", "200")) - t.addEntry(pair(":status", "204")) - t.addEntry(pair(":status", "206")) - t.addEntry(pair(":status", "304")) - t.addEntry(pair(":status", "400")) - t.addEntry(pair(":status", "404")) - t.addEntry(pair(":status", "500")) - t.addEntry(pair("accept-charset", "")) - t.addEntry(pair("accept-encoding", "gzip, deflate")) - t.addEntry(pair("accept-language", "")) - t.addEntry(pair("accept-ranges", "")) - t.addEntry(pair("accept", "")) - t.addEntry(pair("access-control-allow-origin", "")) - t.addEntry(pair("age", "")) - t.addEntry(pair("allow", "")) - t.addEntry(pair("authorization", "")) - t.addEntry(pair("cache-control", "")) - t.addEntry(pair("content-disposition", "")) - t.addEntry(pair("content-encoding", "")) - t.addEntry(pair("content-language", "")) - t.addEntry(pair("content-length", "")) - t.addEntry(pair("content-location", "")) - t.addEntry(pair("content-range", "")) - t.addEntry(pair("content-type", "")) - t.addEntry(pair("cookie", "")) - t.addEntry(pair("date", "")) - t.addEntry(pair("etag", "")) - t.addEntry(pair("expect", "")) - t.addEntry(pair("expires", "")) - t.addEntry(pair("from", "")) - t.addEntry(pair("host", "")) - t.addEntry(pair("if-match", "")) - t.addEntry(pair("if-modified-since", "")) - t.addEntry(pair("if-none-match", "")) - t.addEntry(pair("if-range", "")) - t.addEntry(pair("if-unmodified-since", "")) - t.addEntry(pair("last-modified", "")) - t.addEntry(pair("link", "")) - t.addEntry(pair("location", "")) - t.addEntry(pair("max-forwards", "")) - t.addEntry(pair("proxy-authenticate", "")) - t.addEntry(pair("proxy-authorization", "")) - t.addEntry(pair("range", "")) - t.addEntry(pair("referer", "")) - t.addEntry(pair("refresh", "")) - t.addEntry(pair("retry-after", "")) - t.addEntry(pair("server", "")) - t.addEntry(pair("set-cookie", "")) - t.addEntry(pair("strict-transport-security", "")) - t.addEntry(pair("transfer-encoding", "")) - t.addEntry(pair("user-agent", "")) - t.addEntry(pair("vary", "")) - t.addEntry(pair("via", "")) - t.addEntry(pair("www-authenticate", "")) - return t -} - -var huffmanCodes = [256]uint32{ - 0x1ff8, - 0x7fffd8, - 0xfffffe2, - 0xfffffe3, - 0xfffffe4, - 0xfffffe5, - 0xfffffe6, - 0xfffffe7, - 0xfffffe8, - 0xffffea, - 0x3ffffffc, - 0xfffffe9, - 0xfffffea, - 0x3ffffffd, - 0xfffffeb, - 0xfffffec, - 0xfffffed, - 0xfffffee, - 0xfffffef, - 0xffffff0, - 0xffffff1, - 0xffffff2, - 0x3ffffffe, - 0xffffff3, - 0xffffff4, - 0xffffff5, - 0xffffff6, - 0xffffff7, - 0xffffff8, - 0xffffff9, - 0xffffffa, - 0xffffffb, - 0x14, - 0x3f8, - 0x3f9, - 0xffa, - 0x1ff9, - 0x15, - 0xf8, - 0x7fa, - 0x3fa, - 0x3fb, - 0xf9, - 0x7fb, - 0xfa, - 0x16, - 0x17, - 0x18, - 0x0, - 0x1, - 0x2, - 0x19, - 0x1a, - 0x1b, - 0x1c, - 0x1d, - 0x1e, - 0x1f, - 0x5c, - 0xfb, - 0x7ffc, - 0x20, - 0xffb, - 0x3fc, - 0x1ffa, - 0x21, - 0x5d, - 0x5e, - 0x5f, - 0x60, - 0x61, - 0x62, - 0x63, - 0x64, - 0x65, - 0x66, - 0x67, - 0x68, - 0x69, - 0x6a, - 0x6b, - 0x6c, - 0x6d, - 0x6e, - 0x6f, - 0x70, - 0x71, - 0x72, - 0xfc, - 0x73, - 0xfd, - 0x1ffb, - 0x7fff0, - 0x1ffc, - 0x3ffc, - 0x22, - 0x7ffd, - 0x3, - 0x23, - 0x4, - 0x24, - 0x5, - 0x25, - 0x26, - 0x27, - 0x6, - 0x74, - 0x75, - 0x28, - 0x29, - 0x2a, - 0x7, - 0x2b, - 0x76, - 0x2c, - 0x8, - 0x9, - 0x2d, - 0x77, - 0x78, - 0x79, - 0x7a, - 0x7b, - 0x7ffe, - 0x7fc, - 0x3ffd, - 0x1ffd, - 0xffffffc, - 0xfffe6, - 0x3fffd2, - 0xfffe7, - 0xfffe8, - 0x3fffd3, - 0x3fffd4, - 0x3fffd5, - 0x7fffd9, - 0x3fffd6, - 0x7fffda, - 0x7fffdb, - 0x7fffdc, - 0x7fffdd, - 0x7fffde, - 0xffffeb, - 0x7fffdf, - 0xffffec, - 0xffffed, - 0x3fffd7, - 0x7fffe0, - 0xffffee, - 0x7fffe1, - 0x7fffe2, - 0x7fffe3, - 0x7fffe4, - 0x1fffdc, - 0x3fffd8, - 0x7fffe5, - 0x3fffd9, - 0x7fffe6, - 0x7fffe7, - 0xffffef, - 0x3fffda, - 0x1fffdd, - 0xfffe9, - 0x3fffdb, - 0x3fffdc, - 0x7fffe8, - 0x7fffe9, - 0x1fffde, - 0x7fffea, - 0x3fffdd, - 0x3fffde, - 0xfffff0, - 0x1fffdf, - 0x3fffdf, - 0x7fffeb, - 0x7fffec, - 0x1fffe0, - 0x1fffe1, - 0x3fffe0, - 0x1fffe2, - 0x7fffed, - 0x3fffe1, - 0x7fffee, - 0x7fffef, - 0xfffea, - 0x3fffe2, - 0x3fffe3, - 0x3fffe4, - 0x7ffff0, - 0x3fffe5, - 0x3fffe6, - 0x7ffff1, - 0x3ffffe0, - 0x3ffffe1, - 0xfffeb, - 0x7fff1, - 0x3fffe7, - 0x7ffff2, - 0x3fffe8, - 0x1ffffec, - 0x3ffffe2, - 0x3ffffe3, - 0x3ffffe4, - 0x7ffffde, - 0x7ffffdf, - 0x3ffffe5, - 0xfffff1, - 0x1ffffed, - 0x7fff2, - 0x1fffe3, - 0x3ffffe6, - 0x7ffffe0, - 0x7ffffe1, - 0x3ffffe7, - 0x7ffffe2, - 0xfffff2, - 0x1fffe4, - 0x1fffe5, - 0x3ffffe8, - 0x3ffffe9, - 0xffffffd, - 0x7ffffe3, - 0x7ffffe4, - 0x7ffffe5, - 0xfffec, - 0xfffff3, - 0xfffed, - 0x1fffe6, - 0x3fffe9, - 0x1fffe7, - 0x1fffe8, - 0x7ffff3, - 0x3fffea, - 0x3fffeb, - 0x1ffffee, - 0x1ffffef, - 0xfffff4, - 0xfffff5, - 0x3ffffea, - 0x7ffff4, - 0x3ffffeb, - 0x7ffffe6, - 0x3ffffec, - 0x3ffffed, - 0x7ffffe7, - 0x7ffffe8, - 0x7ffffe9, - 0x7ffffea, - 0x7ffffeb, - 0xffffffe, - 0x7ffffec, - 0x7ffffed, - 0x7ffffee, - 0x7ffffef, - 0x7fffff0, - 0x3ffffee, -} - -var huffmanCodeLen = [256]uint8{ - 13, 23, 28, 28, 28, 28, 28, 28, 28, 24, 30, 28, 28, 30, 28, 28, - 28, 28, 28, 28, 28, 28, 30, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 6, 10, 10, 12, 13, 6, 8, 11, 10, 10, 8, 11, 8, 6, 6, 6, - 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 8, 15, 6, 12, 10, - 13, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, 8, 13, 19, 13, 14, 6, - 15, 5, 6, 5, 6, 5, 6, 6, 6, 5, 7, 7, 6, 6, 6, 5, - 6, 7, 6, 5, 5, 6, 7, 7, 7, 7, 7, 15, 11, 14, 13, 28, - 20, 22, 20, 20, 22, 22, 22, 23, 22, 23, 23, 23, 23, 23, 24, 23, - 24, 24, 22, 23, 24, 23, 23, 23, 23, 21, 22, 23, 22, 23, 23, 24, - 22, 21, 20, 22, 22, 23, 23, 21, 23, 22, 22, 24, 21, 22, 23, 23, - 21, 21, 22, 21, 23, 22, 23, 23, 20, 22, 22, 22, 23, 22, 22, 23, - 26, 26, 20, 19, 22, 23, 22, 25, 26, 26, 26, 27, 27, 26, 24, 25, - 19, 21, 26, 27, 27, 26, 27, 24, 21, 21, 26, 26, 28, 27, 27, 27, - 20, 24, 20, 21, 22, 21, 21, 23, 22, 22, 25, 25, 24, 24, 26, 23, - 26, 27, 26, 26, 27, 27, 27, 27, 27, 28, 27, 27, 27, 27, 27, 26, -} diff --git a/vendor/golang.org/x/net/http2/hpack/tables_test.go b/vendor/golang.org/x/net/http2/hpack/tables_test.go deleted file mode 100644 index d963f3635..000000000 --- a/vendor/golang.org/x/net/http2/hpack/tables_test.go +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package hpack - -import ( - "bufio" - "regexp" - "strconv" - "strings" - "testing" -) - -func TestHeaderFieldTable(t *testing.T) { - table := &headerFieldTable{} - table.init() - table.addEntry(pair("key1", "value1-1")) - table.addEntry(pair("key2", "value2-1")) - table.addEntry(pair("key1", "value1-2")) - table.addEntry(pair("key3", "value3-1")) - table.addEntry(pair("key4", "value4-1")) - table.addEntry(pair("key2", "value2-2")) - - // Tests will be run twice: once before evicting anything, and - // again after evicting the three oldest entries. - tests := []struct { - f HeaderField - beforeWantStaticI uint64 - beforeWantMatch bool - afterWantStaticI uint64 - afterWantMatch bool - }{ - {HeaderField{"key1", "value1-1", false}, 1, true, 0, false}, - {HeaderField{"key1", "value1-2", false}, 3, true, 0, false}, - {HeaderField{"key1", "value1-3", false}, 3, false, 0, false}, - {HeaderField{"key2", "value2-1", false}, 2, true, 3, false}, - {HeaderField{"key2", "value2-2", false}, 6, true, 3, true}, - {HeaderField{"key2", "value2-3", false}, 6, false, 3, false}, - {HeaderField{"key4", "value4-1", false}, 5, true, 2, true}, - // Name match only, because sensitive. - {HeaderField{"key4", "value4-1", true}, 5, false, 2, false}, - // Key not found. - {HeaderField{"key5", "value5-x", false}, 0, false, 0, false}, - } - - staticToDynamic := func(i uint64) uint64 { - if i == 0 { - return 0 - } - return uint64(table.len()) - i + 1 // dynamic is the reversed table - } - - searchStatic := func(f HeaderField) (uint64, bool) { - old := staticTable - staticTable = table - defer func() { staticTable = old }() - return staticTable.search(f) - } - - searchDynamic := func(f HeaderField) (uint64, bool) { - return table.search(f) - } - - for _, test := range tests { - gotI, gotMatch := searchStatic(test.f) - if wantI, wantMatch := test.beforeWantStaticI, test.beforeWantMatch; gotI != wantI || gotMatch != wantMatch { - t.Errorf("before evictions: searchStatic(%+v)=%v,%v want %v,%v", test.f, gotI, gotMatch, wantI, wantMatch) - } - gotI, gotMatch = searchDynamic(test.f) - wantDynamicI := staticToDynamic(test.beforeWantStaticI) - if wantI, wantMatch := wantDynamicI, test.beforeWantMatch; gotI != wantI || gotMatch != wantMatch { - t.Errorf("before evictions: searchDynamic(%+v)=%v,%v want %v,%v", test.f, gotI, gotMatch, wantI, wantMatch) - } - } - - table.evictOldest(3) - - for _, test := range tests { - gotI, gotMatch := searchStatic(test.f) - if wantI, wantMatch := test.afterWantStaticI, test.afterWantMatch; gotI != wantI || gotMatch != wantMatch { - t.Errorf("after evictions: searchStatic(%+v)=%v,%v want %v,%v", test.f, gotI, gotMatch, wantI, wantMatch) - } - gotI, gotMatch = searchDynamic(test.f) - wantDynamicI := staticToDynamic(test.afterWantStaticI) - if wantI, wantMatch := wantDynamicI, test.afterWantMatch; gotI != wantI || gotMatch != wantMatch { - t.Errorf("after evictions: searchDynamic(%+v)=%v,%v want %v,%v", test.f, gotI, gotMatch, wantI, wantMatch) - } - } -} - -func TestHeaderFieldTable_LookupMapEviction(t *testing.T) { - table := &headerFieldTable{} - table.init() - table.addEntry(pair("key1", "value1-1")) - table.addEntry(pair("key2", "value2-1")) - table.addEntry(pair("key1", "value1-2")) - table.addEntry(pair("key3", "value3-1")) - table.addEntry(pair("key4", "value4-1")) - table.addEntry(pair("key2", "value2-2")) - - // evict all pairs - table.evictOldest(table.len()) - - if l := table.len(); l > 0 { - t.Errorf("table.len() = %d, want 0", l) - } - - if l := len(table.byName); l > 0 { - t.Errorf("len(table.byName) = %d, want 0", l) - } - - if l := len(table.byNameValue); l > 0 { - t.Errorf("len(table.byNameValue) = %d, want 0", l) - } -} - -func TestStaticTable(t *testing.T) { - fromSpec := ` - +-------+-----------------------------+---------------+ - | 1 | :authority | | - | 2 | :method | GET | - | 3 | :method | POST | - | 4 | :path | / | - | 5 | :path | /index.html | - | 6 | :scheme | http | - | 7 | :scheme | https | - | 8 | :status | 200 | - | 9 | :status | 204 | - | 10 | :status | 206 | - | 11 | :status | 304 | - | 12 | :status | 400 | - | 13 | :status | 404 | - | 14 | :status | 500 | - | 15 | accept-charset | | - | 16 | accept-encoding | gzip, deflate | - | 17 | accept-language | | - | 18 | accept-ranges | | - | 19 | accept | | - | 20 | access-control-allow-origin | | - | 21 | age | | - | 22 | allow | | - | 23 | authorization | | - | 24 | cache-control | | - | 25 | content-disposition | | - | 26 | content-encoding | | - | 27 | content-language | | - | 28 | content-length | | - | 29 | content-location | | - | 30 | content-range | | - | 31 | content-type | | - | 32 | cookie | | - | 33 | date | | - | 34 | etag | | - | 35 | expect | | - | 36 | expires | | - | 37 | from | | - | 38 | host | | - | 39 | if-match | | - | 40 | if-modified-since | | - | 41 | if-none-match | | - | 42 | if-range | | - | 43 | if-unmodified-since | | - | 44 | last-modified | | - | 45 | link | | - | 46 | location | | - | 47 | max-forwards | | - | 48 | proxy-authenticate | | - | 49 | proxy-authorization | | - | 50 | range | | - | 51 | referer | | - | 52 | refresh | | - | 53 | retry-after | | - | 54 | server | | - | 55 | set-cookie | | - | 56 | strict-transport-security | | - | 57 | transfer-encoding | | - | 58 | user-agent | | - | 59 | vary | | - | 60 | via | | - | 61 | www-authenticate | | - +-------+-----------------------------+---------------+ -` - bs := bufio.NewScanner(strings.NewReader(fromSpec)) - re := regexp.MustCompile(`\| (\d+)\s+\| (\S+)\s*\| (\S(.*\S)?)?\s+\|`) - for bs.Scan() { - l := bs.Text() - if !strings.Contains(l, "|") { - continue - } - m := re.FindStringSubmatch(l) - if m == nil { - continue - } - i, err := strconv.Atoi(m[1]) - if err != nil { - t.Errorf("Bogus integer on line %q", l) - continue - } - if i < 1 || i > staticTable.len() { - t.Errorf("Bogus index %d on line %q", i, l) - continue - } - if got, want := staticTable.ents[i-1].Name, m[2]; got != want { - t.Errorf("header index %d name = %q; want %q", i, got, want) - } - if got, want := staticTable.ents[i-1].Value, m[3]; got != want { - t.Errorf("header index %d value = %q; want %q", i, got, want) - } - } - if err := bs.Err(); err != nil { - t.Error(err) - } -} diff --git a/vendor/golang.org/x/net/http2/http2.go b/vendor/golang.org/x/net/http2/http2.go deleted file mode 100644 index b6b0f9ad1..000000000 --- a/vendor/golang.org/x/net/http2/http2.go +++ /dev/null @@ -1,387 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package http2 implements the HTTP/2 protocol. -// -// This package is low-level and intended to be used directly by very -// few people. Most users will use it indirectly through the automatic -// use by the net/http package (from Go 1.6 and later). -// For use in earlier Go versions see ConfigureServer. (Transport support -// requires Go 1.6 or later) -// -// See https://http2.github.io/ for more information on HTTP/2. -// -// See https://http2.golang.org/ for a test server running this code. -// -package http2 // import "golang.org/x/net/http2" - -import ( - "bufio" - "crypto/tls" - "errors" - "fmt" - "io" - "net/http" - "os" - "sort" - "strconv" - "strings" - "sync" - - "golang.org/x/net/lex/httplex" -) - -var ( - VerboseLogs bool - logFrameWrites bool - logFrameReads bool - inTests bool -) - -func init() { - e := os.Getenv("GODEBUG") - if strings.Contains(e, "http2debug=1") { - VerboseLogs = true - } - if strings.Contains(e, "http2debug=2") { - VerboseLogs = true - logFrameWrites = true - logFrameReads = true - } -} - -const ( - // ClientPreface is the string that must be sent by new - // connections from clients. - ClientPreface = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" - - // SETTINGS_MAX_FRAME_SIZE default - // http://http2.github.io/http2-spec/#rfc.section.6.5.2 - initialMaxFrameSize = 16384 - - // NextProtoTLS is the NPN/ALPN protocol negotiated during - // HTTP/2's TLS setup. - NextProtoTLS = "h2" - - // http://http2.github.io/http2-spec/#SettingValues - initialHeaderTableSize = 4096 - - initialWindowSize = 65535 // 6.9.2 Initial Flow Control Window Size - - defaultMaxReadFrameSize = 1 << 20 -) - -var ( - clientPreface = []byte(ClientPreface) -) - -type streamState int - -// HTTP/2 stream states. -// -// See http://tools.ietf.org/html/rfc7540#section-5.1. -// -// For simplicity, the server code merges "reserved (local)" into -// "half-closed (remote)". This is one less state transition to track. -// The only downside is that we send PUSH_PROMISEs slightly less -// liberally than allowable. More discussion here: -// https://lists.w3.org/Archives/Public/ietf-http-wg/2016JulSep/0599.html -// -// "reserved (remote)" is omitted since the client code does not -// support server push. -const ( - stateIdle streamState = iota - stateOpen - stateHalfClosedLocal - stateHalfClosedRemote - stateClosed -) - -var stateName = [...]string{ - stateIdle: "Idle", - stateOpen: "Open", - stateHalfClosedLocal: "HalfClosedLocal", - stateHalfClosedRemote: "HalfClosedRemote", - stateClosed: "Closed", -} - -func (st streamState) String() string { - return stateName[st] -} - -// Setting is a setting parameter: which setting it is, and its value. -type Setting struct { - // ID is which setting is being set. - // See http://http2.github.io/http2-spec/#SettingValues - ID SettingID - - // Val is the value. - Val uint32 -} - -func (s Setting) String() string { - return fmt.Sprintf("[%v = %d]", s.ID, s.Val) -} - -// Valid reports whether the setting is valid. -func (s Setting) Valid() error { - // Limits and error codes from 6.5.2 Defined SETTINGS Parameters - switch s.ID { - case SettingEnablePush: - if s.Val != 1 && s.Val != 0 { - return ConnectionError(ErrCodeProtocol) - } - case SettingInitialWindowSize: - if s.Val > 1<<31-1 { - return ConnectionError(ErrCodeFlowControl) - } - case SettingMaxFrameSize: - if s.Val < 16384 || s.Val > 1<<24-1 { - return ConnectionError(ErrCodeProtocol) - } - } - return nil -} - -// A SettingID is an HTTP/2 setting as defined in -// http://http2.github.io/http2-spec/#iana-settings -type SettingID uint16 - -const ( - SettingHeaderTableSize SettingID = 0x1 - SettingEnablePush SettingID = 0x2 - SettingMaxConcurrentStreams SettingID = 0x3 - SettingInitialWindowSize SettingID = 0x4 - SettingMaxFrameSize SettingID = 0x5 - SettingMaxHeaderListSize SettingID = 0x6 -) - -var settingName = map[SettingID]string{ - SettingHeaderTableSize: "HEADER_TABLE_SIZE", - SettingEnablePush: "ENABLE_PUSH", - SettingMaxConcurrentStreams: "MAX_CONCURRENT_STREAMS", - SettingInitialWindowSize: "INITIAL_WINDOW_SIZE", - SettingMaxFrameSize: "MAX_FRAME_SIZE", - SettingMaxHeaderListSize: "MAX_HEADER_LIST_SIZE", -} - -func (s SettingID) String() string { - if v, ok := settingName[s]; ok { - return v - } - return fmt.Sprintf("UNKNOWN_SETTING_%d", uint16(s)) -} - -var ( - errInvalidHeaderFieldName = errors.New("http2: invalid header field name") - errInvalidHeaderFieldValue = errors.New("http2: invalid header field value") -) - -// validWireHeaderFieldName reports whether v is a valid header field -// name (key). See httplex.ValidHeaderName for the base rules. -// -// Further, http2 says: -// "Just as in HTTP/1.x, header field names are strings of ASCII -// characters that are compared in a case-insensitive -// fashion. However, header field names MUST be converted to -// lowercase prior to their encoding in HTTP/2. " -func validWireHeaderFieldName(v string) bool { - if len(v) == 0 { - return false - } - for _, r := range v { - if !httplex.IsTokenRune(r) { - return false - } - if 'A' <= r && r <= 'Z' { - return false - } - } - return true -} - -var httpCodeStringCommon = map[int]string{} // n -> strconv.Itoa(n) - -func init() { - for i := 100; i <= 999; i++ { - if v := http.StatusText(i); v != "" { - httpCodeStringCommon[i] = strconv.Itoa(i) - } - } -} - -func httpCodeString(code int) string { - if s, ok := httpCodeStringCommon[code]; ok { - return s - } - return strconv.Itoa(code) -} - -// from pkg io -type stringWriter interface { - WriteString(s string) (n int, err error) -} - -// A gate lets two goroutines coordinate their activities. -type gate chan struct{} - -func (g gate) Done() { g <- struct{}{} } -func (g gate) Wait() { <-g } - -// A closeWaiter is like a sync.WaitGroup but only goes 1 to 0 (open to closed). -type closeWaiter chan struct{} - -// Init makes a closeWaiter usable. -// It exists because so a closeWaiter value can be placed inside a -// larger struct and have the Mutex and Cond's memory in the same -// allocation. -func (cw *closeWaiter) Init() { - *cw = make(chan struct{}) -} - -// Close marks the closeWaiter as closed and unblocks any waiters. -func (cw closeWaiter) Close() { - close(cw) -} - -// Wait waits for the closeWaiter to become closed. -func (cw closeWaiter) Wait() { - <-cw -} - -// bufferedWriter is a buffered writer that writes to w. -// Its buffered writer is lazily allocated as needed, to minimize -// idle memory usage with many connections. -type bufferedWriter struct { - w io.Writer // immutable - bw *bufio.Writer // non-nil when data is buffered -} - -func newBufferedWriter(w io.Writer) *bufferedWriter { - return &bufferedWriter{w: w} -} - -// bufWriterPoolBufferSize is the size of bufio.Writer's -// buffers created using bufWriterPool. -// -// TODO: pick a less arbitrary value? this is a bit under -// (3 x typical 1500 byte MTU) at least. Other than that, -// not much thought went into it. -const bufWriterPoolBufferSize = 4 << 10 - -var bufWriterPool = sync.Pool{ - New: func() interface{} { - return bufio.NewWriterSize(nil, bufWriterPoolBufferSize) - }, -} - -func (w *bufferedWriter) Available() int { - if w.bw == nil { - return bufWriterPoolBufferSize - } - return w.bw.Available() -} - -func (w *bufferedWriter) Write(p []byte) (n int, err error) { - if w.bw == nil { - bw := bufWriterPool.Get().(*bufio.Writer) - bw.Reset(w.w) - w.bw = bw - } - return w.bw.Write(p) -} - -func (w *bufferedWriter) Flush() error { - bw := w.bw - if bw == nil { - return nil - } - err := bw.Flush() - bw.Reset(nil) - bufWriterPool.Put(bw) - w.bw = nil - return err -} - -func mustUint31(v int32) uint32 { - if v < 0 || v > 2147483647 { - panic("out of range") - } - return uint32(v) -} - -// bodyAllowedForStatus reports whether a given response status code -// permits a body. See RFC 2616, section 4.4. -func bodyAllowedForStatus(status int) bool { - switch { - case status >= 100 && status <= 199: - return false - case status == 204: - return false - case status == 304: - return false - } - return true -} - -type httpError struct { - msg string - timeout bool -} - -func (e *httpError) Error() string { return e.msg } -func (e *httpError) Timeout() bool { return e.timeout } -func (e *httpError) Temporary() bool { return true } - -var errTimeout error = &httpError{msg: "http2: timeout awaiting response headers", timeout: true} - -type connectionStater interface { - ConnectionState() tls.ConnectionState -} - -var sorterPool = sync.Pool{New: func() interface{} { return new(sorter) }} - -type sorter struct { - v []string // owned by sorter -} - -func (s *sorter) Len() int { return len(s.v) } -func (s *sorter) Swap(i, j int) { s.v[i], s.v[j] = s.v[j], s.v[i] } -func (s *sorter) Less(i, j int) bool { return s.v[i] < s.v[j] } - -// Keys returns the sorted keys of h. -// -// The returned slice is only valid until s used again or returned to -// its pool. -func (s *sorter) Keys(h http.Header) []string { - keys := s.v[:0] - for k := range h { - keys = append(keys, k) - } - s.v = keys - sort.Sort(s) - return keys -} - -func (s *sorter) SortStrings(ss []string) { - // Our sorter works on s.v, which sorter owns, so - // stash it away while we sort the user's buffer. - save := s.v - s.v = ss - sort.Sort(s) - s.v = save -} - -// validPseudoPath reports whether v is a valid :path pseudo-header -// value. It must be either: -// -// *) a non-empty string starting with '/', but not with with "//", -// *) the string '*', for OPTIONS requests. -// -// For now this is only used a quick check for deciding when to clean -// up Opaque URLs before sending requests from the Transport. -// See golang.org/issue/16847 -func validPseudoPath(v string) bool { - return (len(v) > 0 && v[0] == '/' && (len(v) == 1 || v[1] != '/')) || v == "*" -} diff --git a/vendor/golang.org/x/net/http2/http2_test.go b/vendor/golang.org/x/net/http2/http2_test.go deleted file mode 100644 index 524877647..000000000 --- a/vendor/golang.org/x/net/http2/http2_test.go +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "bytes" - "errors" - "flag" - "fmt" - "net/http" - "os/exec" - "strconv" - "strings" - "testing" - - "golang.org/x/net/http2/hpack" -) - -var knownFailing = flag.Bool("known_failing", false, "Run known-failing tests.") - -func condSkipFailingTest(t *testing.T) { - if !*knownFailing { - t.Skip("Skipping known-failing test without --known_failing") - } -} - -func init() { - inTests = true - DebugGoroutines = true - flag.BoolVar(&VerboseLogs, "verboseh2", VerboseLogs, "Verbose HTTP/2 debug logging") -} - -func TestSettingString(t *testing.T) { - tests := []struct { - s Setting - want string - }{ - {Setting{SettingMaxFrameSize, 123}, "[MAX_FRAME_SIZE = 123]"}, - {Setting{1<<16 - 1, 123}, "[UNKNOWN_SETTING_65535 = 123]"}, - } - for i, tt := range tests { - got := fmt.Sprint(tt.s) - if got != tt.want { - t.Errorf("%d. for %#v, string = %q; want %q", i, tt.s, got, tt.want) - } - } -} - -type twriter struct { - t testing.TB - st *serverTester // optional -} - -func (w twriter) Write(p []byte) (n int, err error) { - if w.st != nil { - ps := string(p) - for _, phrase := range w.st.logFilter { - if strings.Contains(ps, phrase) { - return len(p), nil // no logging - } - } - } - w.t.Logf("%s", p) - return len(p), nil -} - -// like encodeHeader, but don't add implicit pseudo headers. -func encodeHeaderNoImplicit(t *testing.T, headers ...string) []byte { - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - for len(headers) > 0 { - k, v := headers[0], headers[1] - headers = headers[2:] - if err := enc.WriteField(hpack.HeaderField{Name: k, Value: v}); err != nil { - t.Fatalf("HPACK encoding error for %q/%q: %v", k, v, err) - } - } - return buf.Bytes() -} - -// Verify that curl has http2. -func requireCurl(t *testing.T) { - out, err := dockerLogs(curl(t, "--version")) - if err != nil { - t.Skipf("failed to determine curl features; skipping test") - } - if !strings.Contains(string(out), "HTTP2") { - t.Skip("curl doesn't support HTTP2; skipping test") - } -} - -func curl(t *testing.T, args ...string) (container string) { - out, err := exec.Command("docker", append([]string{"run", "-d", "--net=host", "gohttp2/curl"}, args...)...).Output() - if err != nil { - t.Skipf("Failed to run curl in docker: %v, %s", err, out) - } - return strings.TrimSpace(string(out)) -} - -// Verify that h2load exists. -func requireH2load(t *testing.T) { - out, err := dockerLogs(h2load(t, "--version")) - if err != nil { - t.Skipf("failed to probe h2load; skipping test: %s", out) - } - if !strings.Contains(string(out), "h2load nghttp2/") { - t.Skipf("h2load not present; skipping test. (Output=%q)", out) - } -} - -func h2load(t *testing.T, args ...string) (container string) { - out, err := exec.Command("docker", append([]string{"run", "-d", "--net=host", "--entrypoint=/usr/local/bin/h2load", "gohttp2/curl"}, args...)...).Output() - if err != nil { - t.Skipf("Failed to run h2load in docker: %v, %s", err, out) - } - return strings.TrimSpace(string(out)) -} - -type puppetCommand struct { - fn func(w http.ResponseWriter, r *http.Request) - done chan<- bool -} - -type handlerPuppet struct { - ch chan puppetCommand -} - -func newHandlerPuppet() *handlerPuppet { - return &handlerPuppet{ - ch: make(chan puppetCommand), - } -} - -func (p *handlerPuppet) act(w http.ResponseWriter, r *http.Request) { - for cmd := range p.ch { - cmd.fn(w, r) - cmd.done <- true - } -} - -func (p *handlerPuppet) done() { close(p.ch) } -func (p *handlerPuppet) do(fn func(http.ResponseWriter, *http.Request)) { - done := make(chan bool) - p.ch <- puppetCommand{fn, done} - <-done -} -func dockerLogs(container string) ([]byte, error) { - out, err := exec.Command("docker", "wait", container).CombinedOutput() - if err != nil { - return out, err - } - exitStatus, err := strconv.Atoi(strings.TrimSpace(string(out))) - if err != nil { - return out, errors.New("unexpected exit status from docker wait") - } - out, err = exec.Command("docker", "logs", container).CombinedOutput() - exec.Command("docker", "rm", container).Run() - if err == nil && exitStatus != 0 { - err = fmt.Errorf("exit status %d: %s", exitStatus, out) - } - return out, err -} - -func kill(container string) { - exec.Command("docker", "kill", container).Run() - exec.Command("docker", "rm", container).Run() -} - -func cleanDate(res *http.Response) { - if d := res.Header["Date"]; len(d) == 1 { - d[0] = "XXX" - } -} - -func TestSorterPoolAllocs(t *testing.T) { - ss := []string{"a", "b", "c"} - h := http.Header{ - "a": nil, - "b": nil, - "c": nil, - } - sorter := new(sorter) - - if allocs := testing.AllocsPerRun(100, func() { - sorter.SortStrings(ss) - }); allocs >= 1 { - t.Logf("SortStrings allocs = %v; want <1", allocs) - } - - if allocs := testing.AllocsPerRun(5, func() { - if len(sorter.Keys(h)) != 3 { - t.Fatal("wrong result") - } - }); allocs > 0 { - t.Logf("Keys allocs = %v; want <1", allocs) - } -} diff --git a/vendor/golang.org/x/net/http2/not_go16.go b/vendor/golang.org/x/net/http2/not_go16.go deleted file mode 100644 index efd2e1282..000000000 --- a/vendor/golang.org/x/net/http2/not_go16.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.6 - -package http2 - -import ( - "crypto/tls" - "net/http" - "time" -) - -func configureTransport(t1 *http.Transport) (*Transport, error) { - return nil, errTransportVersion -} - -func transportExpectContinueTimeout(t1 *http.Transport) time.Duration { - return 0 - -} - -// isBadCipher reports whether the cipher is blacklisted by the HTTP/2 spec. -func isBadCipher(cipher uint16) bool { - switch cipher { - case tls.TLS_RSA_WITH_RC4_128_SHA, - tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, - tls.TLS_RSA_WITH_AES_128_CBC_SHA, - tls.TLS_RSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, - tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: - // Reject cipher suites from Appendix A. - // "This list includes those cipher suites that do not - // offer an ephemeral key exchange and those that are - // based on the TLS null, stream or block cipher type" - return true - default: - return false - } -} diff --git a/vendor/golang.org/x/net/http2/not_go17.go b/vendor/golang.org/x/net/http2/not_go17.go deleted file mode 100644 index 140434a79..000000000 --- a/vendor/golang.org/x/net/http2/not_go17.go +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.7 - -package http2 - -import ( - "crypto/tls" - "net" - "net/http" - "time" -) - -type contextContext interface { - Done() <-chan struct{} - Err() error -} - -type fakeContext struct{} - -func (fakeContext) Done() <-chan struct{} { return nil } -func (fakeContext) Err() error { panic("should not be called") } - -func reqContext(r *http.Request) fakeContext { - return fakeContext{} -} - -func setResponseUncompressed(res *http.Response) { - // Nothing. -} - -type clientTrace struct{} - -func requestTrace(*http.Request) *clientTrace { return nil } -func traceGotConn(*http.Request, *ClientConn) {} -func traceFirstResponseByte(*clientTrace) {} -func traceWroteHeaders(*clientTrace) {} -func traceWroteRequest(*clientTrace, error) {} -func traceGot100Continue(trace *clientTrace) {} -func traceWait100Continue(trace *clientTrace) {} - -func nop() {} - -func serverConnBaseContext(c net.Conn, opts *ServeConnOpts) (ctx contextContext, cancel func()) { - return nil, nop -} - -func contextWithCancel(ctx contextContext) (_ contextContext, cancel func()) { - return ctx, nop -} - -func requestWithContext(req *http.Request, ctx contextContext) *http.Request { - return req -} - -// temporary copy of Go 1.6's private tls.Config.clone: -func cloneTLSConfig(c *tls.Config) *tls.Config { - return &tls.Config{ - Rand: c.Rand, - Time: c.Time, - Certificates: c.Certificates, - NameToCertificate: c.NameToCertificate, - GetCertificate: c.GetCertificate, - RootCAs: c.RootCAs, - NextProtos: c.NextProtos, - ServerName: c.ServerName, - ClientAuth: c.ClientAuth, - ClientCAs: c.ClientCAs, - InsecureSkipVerify: c.InsecureSkipVerify, - CipherSuites: c.CipherSuites, - PreferServerCipherSuites: c.PreferServerCipherSuites, - SessionTicketsDisabled: c.SessionTicketsDisabled, - SessionTicketKey: c.SessionTicketKey, - ClientSessionCache: c.ClientSessionCache, - MinVersion: c.MinVersion, - MaxVersion: c.MaxVersion, - CurvePreferences: c.CurvePreferences, - } -} - -func (cc *ClientConn) Ping(ctx contextContext) error { - return cc.ping(ctx) -} - -func (t *Transport) idleConnTimeout() time.Duration { return 0 } diff --git a/vendor/golang.org/x/net/http2/not_go18.go b/vendor/golang.org/x/net/http2/not_go18.go deleted file mode 100644 index efbf83c32..000000000 --- a/vendor/golang.org/x/net/http2/not_go18.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.8 - -package http2 - -import ( - "io" - "net/http" -) - -func configureServer18(h1 *http.Server, h2 *Server) error { - // No IdleTimeout to sync prior to Go 1.8. - return nil -} - -func shouldLogPanic(panicValue interface{}) bool { - return panicValue != nil -} - -func reqGetBody(req *http.Request) func() (io.ReadCloser, error) { - return nil -} - -func reqBodyIsNoBody(io.ReadCloser) bool { return false } diff --git a/vendor/golang.org/x/net/http2/pipe.go b/vendor/golang.org/x/net/http2/pipe.go deleted file mode 100644 index 914aaf8a7..000000000 --- a/vendor/golang.org/x/net/http2/pipe.go +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "errors" - "io" - "sync" -) - -// pipe is a goroutine-safe io.Reader/io.Writer pair. It's like -// io.Pipe except there are no PipeReader/PipeWriter halves, and the -// underlying buffer is an interface. (io.Pipe is always unbuffered) -type pipe struct { - mu sync.Mutex - c sync.Cond // c.L lazily initialized to &p.mu - b pipeBuffer - err error // read error once empty. non-nil means closed. - breakErr error // immediate read error (caller doesn't see rest of b) - donec chan struct{} // closed on error - readFn func() // optional code to run in Read before error -} - -type pipeBuffer interface { - Len() int - io.Writer - io.Reader -} - -func (p *pipe) Len() int { - p.mu.Lock() - defer p.mu.Unlock() - return p.b.Len() -} - -// Read waits until data is available and copies bytes -// from the buffer into p. -func (p *pipe) Read(d []byte) (n int, err error) { - p.mu.Lock() - defer p.mu.Unlock() - if p.c.L == nil { - p.c.L = &p.mu - } - for { - if p.breakErr != nil { - return 0, p.breakErr - } - if p.b.Len() > 0 { - return p.b.Read(d) - } - if p.err != nil { - if p.readFn != nil { - p.readFn() // e.g. copy trailers - p.readFn = nil // not sticky like p.err - } - return 0, p.err - } - p.c.Wait() - } -} - -var errClosedPipeWrite = errors.New("write on closed buffer") - -// Write copies bytes from p into the buffer and wakes a reader. -// It is an error to write more data than the buffer can hold. -func (p *pipe) Write(d []byte) (n int, err error) { - p.mu.Lock() - defer p.mu.Unlock() - if p.c.L == nil { - p.c.L = &p.mu - } - defer p.c.Signal() - if p.err != nil { - return 0, errClosedPipeWrite - } - return p.b.Write(d) -} - -// CloseWithError causes the next Read (waking up a current blocked -// Read if needed) to return the provided err after all data has been -// read. -// -// The error must be non-nil. -func (p *pipe) CloseWithError(err error) { p.closeWithError(&p.err, err, nil) } - -// BreakWithError causes the next Read (waking up a current blocked -// Read if needed) to return the provided err immediately, without -// waiting for unread data. -func (p *pipe) BreakWithError(err error) { p.closeWithError(&p.breakErr, err, nil) } - -// closeWithErrorAndCode is like CloseWithError but also sets some code to run -// in the caller's goroutine before returning the error. -func (p *pipe) closeWithErrorAndCode(err error, fn func()) { p.closeWithError(&p.err, err, fn) } - -func (p *pipe) closeWithError(dst *error, err error, fn func()) { - if err == nil { - panic("err must be non-nil") - } - p.mu.Lock() - defer p.mu.Unlock() - if p.c.L == nil { - p.c.L = &p.mu - } - defer p.c.Signal() - if *dst != nil { - // Already been done. - return - } - p.readFn = fn - *dst = err - p.closeDoneLocked() -} - -// requires p.mu be held. -func (p *pipe) closeDoneLocked() { - if p.donec == nil { - return - } - // Close if unclosed. This isn't racy since we always - // hold p.mu while closing. - select { - case <-p.donec: - default: - close(p.donec) - } -} - -// Err returns the error (if any) first set by BreakWithError or CloseWithError. -func (p *pipe) Err() error { - p.mu.Lock() - defer p.mu.Unlock() - if p.breakErr != nil { - return p.breakErr - } - return p.err -} - -// Done returns a channel which is closed if and when this pipe is closed -// with CloseWithError. -func (p *pipe) Done() <-chan struct{} { - p.mu.Lock() - defer p.mu.Unlock() - if p.donec == nil { - p.donec = make(chan struct{}) - if p.err != nil || p.breakErr != nil { - // Already hit an error. - p.closeDoneLocked() - } - } - return p.donec -} diff --git a/vendor/golang.org/x/net/http2/pipe_test.go b/vendor/golang.org/x/net/http2/pipe_test.go deleted file mode 100644 index 763229999..000000000 --- a/vendor/golang.org/x/net/http2/pipe_test.go +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "bytes" - "errors" - "io" - "io/ioutil" - "testing" -) - -func TestPipeClose(t *testing.T) { - var p pipe - p.b = new(bytes.Buffer) - a := errors.New("a") - b := errors.New("b") - p.CloseWithError(a) - p.CloseWithError(b) - _, err := p.Read(make([]byte, 1)) - if err != a { - t.Errorf("err = %v want %v", err, a) - } -} - -func TestPipeDoneChan(t *testing.T) { - var p pipe - done := p.Done() - select { - case <-done: - t.Fatal("done too soon") - default: - } - p.CloseWithError(io.EOF) - select { - case <-done: - default: - t.Fatal("should be done") - } -} - -func TestPipeDoneChan_ErrFirst(t *testing.T) { - var p pipe - p.CloseWithError(io.EOF) - done := p.Done() - select { - case <-done: - default: - t.Fatal("should be done") - } -} - -func TestPipeDoneChan_Break(t *testing.T) { - var p pipe - done := p.Done() - select { - case <-done: - t.Fatal("done too soon") - default: - } - p.BreakWithError(io.EOF) - select { - case <-done: - default: - t.Fatal("should be done") - } -} - -func TestPipeDoneChan_Break_ErrFirst(t *testing.T) { - var p pipe - p.BreakWithError(io.EOF) - done := p.Done() - select { - case <-done: - default: - t.Fatal("should be done") - } -} - -func TestPipeCloseWithError(t *testing.T) { - p := &pipe{b: new(bytes.Buffer)} - const body = "foo" - io.WriteString(p, body) - a := errors.New("test error") - p.CloseWithError(a) - all, err := ioutil.ReadAll(p) - if string(all) != body { - t.Errorf("read bytes = %q; want %q", all, body) - } - if err != a { - t.Logf("read error = %v, %v", err, a) - } -} - -func TestPipeBreakWithError(t *testing.T) { - p := &pipe{b: new(bytes.Buffer)} - io.WriteString(p, "foo") - a := errors.New("test err") - p.BreakWithError(a) - all, err := ioutil.ReadAll(p) - if string(all) != "" { - t.Errorf("read bytes = %q; want empty string", all) - } - if err != a { - t.Logf("read error = %v, %v", err, a) - } -} diff --git a/vendor/golang.org/x/net/http2/server.go b/vendor/golang.org/x/net/http2/server.go deleted file mode 100644 index 029ed958a..000000000 --- a/vendor/golang.org/x/net/http2/server.go +++ /dev/null @@ -1,2778 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// TODO: turn off the serve goroutine when idle, so -// an idle conn only has the readFrames goroutine active. (which could -// also be optimized probably to pin less memory in crypto/tls). This -// would involve tracking when the serve goroutine is active (atomic -// int32 read/CAS probably?) and starting it up when frames arrive, -// and shutting it down when all handlers exit. the occasional PING -// packets could use time.AfterFunc to call sc.wakeStartServeLoop() -// (which is a no-op if already running) and then queue the PING write -// as normal. The serve loop would then exit in most cases (if no -// Handlers running) and not be woken up again until the PING packet -// returns. - -// TODO (maybe): add a mechanism for Handlers to going into -// half-closed-local mode (rw.(io.Closer) test?) but not exit their -// handler, and continue to be able to read from the -// Request.Body. This would be a somewhat semantic change from HTTP/1 -// (or at least what we expose in net/http), so I'd probably want to -// add it there too. For now, this package says that returning from -// the Handler ServeHTTP function means you're both done reading and -// done writing, without a way to stop just one or the other. - -package http2 - -import ( - "bufio" - "bytes" - "crypto/tls" - "errors" - "fmt" - "io" - "log" - "math" - "net" - "net/http" - "net/textproto" - "net/url" - "os" - "reflect" - "runtime" - "strconv" - "strings" - "sync" - "time" - - "golang.org/x/net/http2/hpack" -) - -const ( - prefaceTimeout = 10 * time.Second - firstSettingsTimeout = 2 * time.Second // should be in-flight with preface anyway - handlerChunkWriteSize = 4 << 10 - defaultMaxStreams = 250 // TODO: make this 100 as the GFE seems to? -) - -var ( - errClientDisconnected = errors.New("client disconnected") - errClosedBody = errors.New("body closed by handler") - errHandlerComplete = errors.New("http2: request body closed due to handler exiting") - errStreamClosed = errors.New("http2: stream closed") -) - -var responseWriterStatePool = sync.Pool{ - New: func() interface{} { - rws := &responseWriterState{} - rws.bw = bufio.NewWriterSize(chunkWriter{rws}, handlerChunkWriteSize) - return rws - }, -} - -// Test hooks. -var ( - testHookOnConn func() - testHookGetServerConn func(*serverConn) - testHookOnPanicMu *sync.Mutex // nil except in tests - testHookOnPanic func(sc *serverConn, panicVal interface{}) (rePanic bool) -) - -// Server is an HTTP/2 server. -type Server struct { - // MaxHandlers limits the number of http.Handler ServeHTTP goroutines - // which may run at a time over all connections. - // Negative or zero no limit. - // TODO: implement - MaxHandlers int - - // MaxConcurrentStreams optionally specifies the number of - // concurrent streams that each client may have open at a - // time. This is unrelated to the number of http.Handler goroutines - // which may be active globally, which is MaxHandlers. - // If zero, MaxConcurrentStreams defaults to at least 100, per - // the HTTP/2 spec's recommendations. - MaxConcurrentStreams uint32 - - // MaxReadFrameSize optionally specifies the largest frame - // this server is willing to read. A valid value is between - // 16k and 16M, inclusive. If zero or otherwise invalid, a - // default value is used. - MaxReadFrameSize uint32 - - // PermitProhibitedCipherSuites, if true, permits the use of - // cipher suites prohibited by the HTTP/2 spec. - PermitProhibitedCipherSuites bool - - // IdleTimeout specifies how long until idle clients should be - // closed with a GOAWAY frame. PING frames are not considered - // activity for the purposes of IdleTimeout. - IdleTimeout time.Duration - - // MaxUploadBufferPerConnection is the size of the initial flow - // control window for each connections. The HTTP/2 spec does not - // allow this to be smaller than 65535 or larger than 2^32-1. - // If the value is outside this range, a default value will be - // used instead. - MaxUploadBufferPerConnection int32 - - // MaxUploadBufferPerStream is the size of the initial flow control - // window for each stream. The HTTP/2 spec does not allow this to - // be larger than 2^32-1. If the value is zero or larger than the - // maximum, a default value will be used instead. - MaxUploadBufferPerStream int32 - - // NewWriteScheduler constructs a write scheduler for a connection. - // If nil, a default scheduler is chosen. - NewWriteScheduler func() WriteScheduler -} - -func (s *Server) initialConnRecvWindowSize() int32 { - if s.MaxUploadBufferPerConnection > initialWindowSize { - return s.MaxUploadBufferPerConnection - } - return 1 << 20 -} - -func (s *Server) initialStreamRecvWindowSize() int32 { - if s.MaxUploadBufferPerStream > 0 { - return s.MaxUploadBufferPerStream - } - return 1 << 20 -} - -func (s *Server) maxReadFrameSize() uint32 { - if v := s.MaxReadFrameSize; v >= minMaxFrameSize && v <= maxFrameSize { - return v - } - return defaultMaxReadFrameSize -} - -func (s *Server) maxConcurrentStreams() uint32 { - if v := s.MaxConcurrentStreams; v > 0 { - return v - } - return defaultMaxStreams -} - -// ConfigureServer adds HTTP/2 support to a net/http Server. -// -// The configuration conf may be nil. -// -// ConfigureServer must be called before s begins serving. -func ConfigureServer(s *http.Server, conf *Server) error { - if s == nil { - panic("nil *http.Server") - } - if conf == nil { - conf = new(Server) - } - if err := configureServer18(s, conf); err != nil { - return err - } - - if s.TLSConfig == nil { - s.TLSConfig = new(tls.Config) - } else if s.TLSConfig.CipherSuites != nil { - // If they already provided a CipherSuite list, return - // an error if it has a bad order or is missing - // ECDHE_RSA_WITH_AES_128_GCM_SHA256. - const requiredCipher = tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 - haveRequired := false - sawBad := false - for i, cs := range s.TLSConfig.CipherSuites { - if cs == requiredCipher { - haveRequired = true - } - if isBadCipher(cs) { - sawBad = true - } else if sawBad { - return fmt.Errorf("http2: TLSConfig.CipherSuites index %d contains an HTTP/2-approved cipher suite (%#04x), but it comes after unapproved cipher suites. With this configuration, clients that don't support previous, approved cipher suites may be given an unapproved one and reject the connection.", i, cs) - } - } - if !haveRequired { - return fmt.Errorf("http2: TLSConfig.CipherSuites is missing HTTP/2-required TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256") - } - } - - // Note: not setting MinVersion to tls.VersionTLS12, - // as we don't want to interfere with HTTP/1.1 traffic - // on the user's server. We enforce TLS 1.2 later once - // we accept a connection. Ideally this should be done - // during next-proto selection, but using TLS <1.2 with - // HTTP/2 is still the client's bug. - - s.TLSConfig.PreferServerCipherSuites = true - - haveNPN := false - for _, p := range s.TLSConfig.NextProtos { - if p == NextProtoTLS { - haveNPN = true - break - } - } - if !haveNPN { - s.TLSConfig.NextProtos = append(s.TLSConfig.NextProtos, NextProtoTLS) - } - - if s.TLSNextProto == nil { - s.TLSNextProto = map[string]func(*http.Server, *tls.Conn, http.Handler){} - } - protoHandler := func(hs *http.Server, c *tls.Conn, h http.Handler) { - if testHookOnConn != nil { - testHookOnConn() - } - conf.ServeConn(c, &ServeConnOpts{ - Handler: h, - BaseConfig: hs, - }) - } - s.TLSNextProto[NextProtoTLS] = protoHandler - return nil -} - -// ServeConnOpts are options for the Server.ServeConn method. -type ServeConnOpts struct { - // BaseConfig optionally sets the base configuration - // for values. If nil, defaults are used. - BaseConfig *http.Server - - // Handler specifies which handler to use for processing - // requests. If nil, BaseConfig.Handler is used. If BaseConfig - // or BaseConfig.Handler is nil, http.DefaultServeMux is used. - Handler http.Handler -} - -func (o *ServeConnOpts) baseConfig() *http.Server { - if o != nil && o.BaseConfig != nil { - return o.BaseConfig - } - return new(http.Server) -} - -func (o *ServeConnOpts) handler() http.Handler { - if o != nil { - if o.Handler != nil { - return o.Handler - } - if o.BaseConfig != nil && o.BaseConfig.Handler != nil { - return o.BaseConfig.Handler - } - } - return http.DefaultServeMux -} - -// ServeConn serves HTTP/2 requests on the provided connection and -// blocks until the connection is no longer readable. -// -// ServeConn starts speaking HTTP/2 assuming that c has not had any -// reads or writes. It writes its initial settings frame and expects -// to be able to read the preface and settings frame from the -// client. If c has a ConnectionState method like a *tls.Conn, the -// ConnectionState is used to verify the TLS ciphersuite and to set -// the Request.TLS field in Handlers. -// -// ServeConn does not support h2c by itself. Any h2c support must be -// implemented in terms of providing a suitably-behaving net.Conn. -// -// The opts parameter is optional. If nil, default values are used. -func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts) { - baseCtx, cancel := serverConnBaseContext(c, opts) - defer cancel() - - sc := &serverConn{ - srv: s, - hs: opts.baseConfig(), - conn: c, - baseCtx: baseCtx, - remoteAddrStr: c.RemoteAddr().String(), - bw: newBufferedWriter(c), - handler: opts.handler(), - streams: make(map[uint32]*stream), - readFrameCh: make(chan readFrameResult), - wantWriteFrameCh: make(chan FrameWriteRequest, 8), - wantStartPushCh: make(chan startPushRequest, 8), - wroteFrameCh: make(chan frameWriteResult, 1), // buffered; one send in writeFrameAsync - bodyReadCh: make(chan bodyReadMsg), // buffering doesn't matter either way - doneServing: make(chan struct{}), - clientMaxStreams: math.MaxUint32, // Section 6.5.2: "Initially, there is no limit to this value" - advMaxStreams: s.maxConcurrentStreams(), - initialStreamSendWindowSize: initialWindowSize, - maxFrameSize: initialMaxFrameSize, - headerTableSize: initialHeaderTableSize, - serveG: newGoroutineLock(), - pushEnabled: true, - } - - // The net/http package sets the write deadline from the - // http.Server.WriteTimeout during the TLS handshake, but then - // passes the connection off to us with the deadline already set. - // Write deadlines are set per stream in serverConn.newStream. - // Disarm the net.Conn write deadline here. - if sc.hs.WriteTimeout != 0 { - sc.conn.SetWriteDeadline(time.Time{}) - } - - if s.NewWriteScheduler != nil { - sc.writeSched = s.NewWriteScheduler() - } else { - sc.writeSched = NewRandomWriteScheduler() - } - - // These start at the RFC-specified defaults. If there is a higher - // configured value for inflow, that will be updated when we send a - // WINDOW_UPDATE shortly after sending SETTINGS. - sc.flow.add(initialWindowSize) - sc.inflow.add(initialWindowSize) - sc.hpackEncoder = hpack.NewEncoder(&sc.headerWriteBuf) - - fr := NewFramer(sc.bw, c) - fr.ReadMetaHeaders = hpack.NewDecoder(initialHeaderTableSize, nil) - fr.MaxHeaderListSize = sc.maxHeaderListSize() - fr.SetMaxReadFrameSize(s.maxReadFrameSize()) - sc.framer = fr - - if tc, ok := c.(connectionStater); ok { - sc.tlsState = new(tls.ConnectionState) - *sc.tlsState = tc.ConnectionState() - // 9.2 Use of TLS Features - // An implementation of HTTP/2 over TLS MUST use TLS - // 1.2 or higher with the restrictions on feature set - // and cipher suite described in this section. Due to - // implementation limitations, it might not be - // possible to fail TLS negotiation. An endpoint MUST - // immediately terminate an HTTP/2 connection that - // does not meet the TLS requirements described in - // this section with a connection error (Section - // 5.4.1) of type INADEQUATE_SECURITY. - if sc.tlsState.Version < tls.VersionTLS12 { - sc.rejectConn(ErrCodeInadequateSecurity, "TLS version too low") - return - } - - if sc.tlsState.ServerName == "" { - // Client must use SNI, but we don't enforce that anymore, - // since it was causing problems when connecting to bare IP - // addresses during development. - // - // TODO: optionally enforce? Or enforce at the time we receive - // a new request, and verify the the ServerName matches the :authority? - // But that precludes proxy situations, perhaps. - // - // So for now, do nothing here again. - } - - if !s.PermitProhibitedCipherSuites && isBadCipher(sc.tlsState.CipherSuite) { - // "Endpoints MAY choose to generate a connection error - // (Section 5.4.1) of type INADEQUATE_SECURITY if one of - // the prohibited cipher suites are negotiated." - // - // We choose that. In my opinion, the spec is weak - // here. It also says both parties must support at least - // TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 so there's no - // excuses here. If we really must, we could allow an - // "AllowInsecureWeakCiphers" option on the server later. - // Let's see how it plays out first. - sc.rejectConn(ErrCodeInadequateSecurity, fmt.Sprintf("Prohibited TLS 1.2 Cipher Suite: %x", sc.tlsState.CipherSuite)) - return - } - } - - if hook := testHookGetServerConn; hook != nil { - hook(sc) - } - sc.serve() -} - -func (sc *serverConn) rejectConn(err ErrCode, debug string) { - sc.vlogf("http2: server rejecting conn: %v, %s", err, debug) - // ignoring errors. hanging up anyway. - sc.framer.WriteGoAway(0, err, []byte(debug)) - sc.bw.Flush() - sc.conn.Close() -} - -type serverConn struct { - // Immutable: - srv *Server - hs *http.Server - conn net.Conn - bw *bufferedWriter // writing to conn - handler http.Handler - baseCtx contextContext - framer *Framer - doneServing chan struct{} // closed when serverConn.serve ends - readFrameCh chan readFrameResult // written by serverConn.readFrames - wantWriteFrameCh chan FrameWriteRequest // from handlers -> serve - wantStartPushCh chan startPushRequest // from handlers -> serve - wroteFrameCh chan frameWriteResult // from writeFrameAsync -> serve, tickles more frame writes - bodyReadCh chan bodyReadMsg // from handlers -> serve - testHookCh chan func(int) // code to run on the serve loop - flow flow // conn-wide (not stream-specific) outbound flow control - inflow flow // conn-wide inbound flow control - tlsState *tls.ConnectionState // shared by all handlers, like net/http - remoteAddrStr string - writeSched WriteScheduler - - // Everything following is owned by the serve loop; use serveG.check(): - serveG goroutineLock // used to verify funcs are on serve() - pushEnabled bool - sawFirstSettings bool // got the initial SETTINGS frame after the preface - needToSendSettingsAck bool - unackedSettings int // how many SETTINGS have we sent without ACKs? - clientMaxStreams uint32 // SETTINGS_MAX_CONCURRENT_STREAMS from client (our PUSH_PROMISE limit) - advMaxStreams uint32 // our SETTINGS_MAX_CONCURRENT_STREAMS advertised the client - curClientStreams uint32 // number of open streams initiated by the client - curPushedStreams uint32 // number of open streams initiated by server push - maxClientStreamID uint32 // max ever seen from client (odd), or 0 if there have been no client requests - maxPushPromiseID uint32 // ID of the last push promise (even), or 0 if there have been no pushes - streams map[uint32]*stream - initialStreamSendWindowSize int32 - maxFrameSize int32 - headerTableSize uint32 - peerMaxHeaderListSize uint32 // zero means unknown (default) - canonHeader map[string]string // http2-lower-case -> Go-Canonical-Case - writingFrame bool // started writing a frame (on serve goroutine or separate) - writingFrameAsync bool // started a frame on its own goroutine but haven't heard back on wroteFrameCh - needsFrameFlush bool // last frame write wasn't a flush - inGoAway bool // we've started to or sent GOAWAY - inFrameScheduleLoop bool // whether we're in the scheduleFrameWrite loop - needToSendGoAway bool // we need to schedule a GOAWAY frame write - goAwayCode ErrCode - shutdownTimerCh <-chan time.Time // nil until used - shutdownTimer *time.Timer // nil until used - idleTimer *time.Timer // nil if unused - idleTimerCh <-chan time.Time // nil if unused - - // Owned by the writeFrameAsync goroutine: - headerWriteBuf bytes.Buffer - hpackEncoder *hpack.Encoder -} - -func (sc *serverConn) maxHeaderListSize() uint32 { - n := sc.hs.MaxHeaderBytes - if n <= 0 { - n = http.DefaultMaxHeaderBytes - } - // http2's count is in a slightly different unit and includes 32 bytes per pair. - // So, take the net/http.Server value and pad it up a bit, assuming 10 headers. - const perFieldOverhead = 32 // per http2 spec - const typicalHeaders = 10 // conservative - return uint32(n + typicalHeaders*perFieldOverhead) -} - -func (sc *serverConn) curOpenStreams() uint32 { - sc.serveG.check() - return sc.curClientStreams + sc.curPushedStreams -} - -// stream represents a stream. This is the minimal metadata needed by -// the serve goroutine. Most of the actual stream state is owned by -// the http.Handler's goroutine in the responseWriter. Because the -// responseWriter's responseWriterState is recycled at the end of a -// handler, this struct intentionally has no pointer to the -// *responseWriter{,State} itself, as the Handler ending nils out the -// responseWriter's state field. -type stream struct { - // immutable: - sc *serverConn - id uint32 - body *pipe // non-nil if expecting DATA frames - cw closeWaiter // closed wait stream transitions to closed state - ctx contextContext - cancelCtx func() - - // owned by serverConn's serve loop: - bodyBytes int64 // body bytes seen so far - declBodyBytes int64 // or -1 if undeclared - flow flow // limits writing from Handler to client - inflow flow // what the client is allowed to POST/etc to us - parent *stream // or nil - numTrailerValues int64 - weight uint8 - state streamState - resetQueued bool // RST_STREAM queued for write; set by sc.resetStream - gotTrailerHeader bool // HEADER frame for trailers was seen - wroteHeaders bool // whether we wrote headers (not status 100) - writeDeadline *time.Timer // nil if unused - - trailer http.Header // accumulated trailers - reqTrailer http.Header // handler's Request.Trailer -} - -func (sc *serverConn) Framer() *Framer { return sc.framer } -func (sc *serverConn) CloseConn() error { return sc.conn.Close() } -func (sc *serverConn) Flush() error { return sc.bw.Flush() } -func (sc *serverConn) HeaderEncoder() (*hpack.Encoder, *bytes.Buffer) { - return sc.hpackEncoder, &sc.headerWriteBuf -} - -func (sc *serverConn) state(streamID uint32) (streamState, *stream) { - sc.serveG.check() - // http://tools.ietf.org/html/rfc7540#section-5.1 - if st, ok := sc.streams[streamID]; ok { - return st.state, st - } - // "The first use of a new stream identifier implicitly closes all - // streams in the "idle" state that might have been initiated by - // that peer with a lower-valued stream identifier. For example, if - // a client sends a HEADERS frame on stream 7 without ever sending a - // frame on stream 5, then stream 5 transitions to the "closed" - // state when the first frame for stream 7 is sent or received." - if streamID%2 == 1 { - if streamID <= sc.maxClientStreamID { - return stateClosed, nil - } - } else { - if streamID <= sc.maxPushPromiseID { - return stateClosed, nil - } - } - return stateIdle, nil -} - -// setConnState calls the net/http ConnState hook for this connection, if configured. -// Note that the net/http package does StateNew and StateClosed for us. -// There is currently no plan for StateHijacked or hijacking HTTP/2 connections. -func (sc *serverConn) setConnState(state http.ConnState) { - if sc.hs.ConnState != nil { - sc.hs.ConnState(sc.conn, state) - } -} - -func (sc *serverConn) vlogf(format string, args ...interface{}) { - if VerboseLogs { - sc.logf(format, args...) - } -} - -func (sc *serverConn) logf(format string, args ...interface{}) { - if lg := sc.hs.ErrorLog; lg != nil { - lg.Printf(format, args...) - } else { - log.Printf(format, args...) - } -} - -// errno returns v's underlying uintptr, else 0. -// -// TODO: remove this helper function once http2 can use build -// tags. See comment in isClosedConnError. -func errno(v error) uintptr { - if rv := reflect.ValueOf(v); rv.Kind() == reflect.Uintptr { - return uintptr(rv.Uint()) - } - return 0 -} - -// isClosedConnError reports whether err is an error from use of a closed -// network connection. -func isClosedConnError(err error) bool { - if err == nil { - return false - } - - // TODO: remove this string search and be more like the Windows - // case below. That might involve modifying the standard library - // to return better error types. - str := err.Error() - if strings.Contains(str, "use of closed network connection") { - return true - } - - // TODO(bradfitz): x/tools/cmd/bundle doesn't really support - // build tags, so I can't make an http2_windows.go file with - // Windows-specific stuff. Fix that and move this, once we - // have a way to bundle this into std's net/http somehow. - if runtime.GOOS == "windows" { - if oe, ok := err.(*net.OpError); ok && oe.Op == "read" { - if se, ok := oe.Err.(*os.SyscallError); ok && se.Syscall == "wsarecv" { - const WSAECONNABORTED = 10053 - const WSAECONNRESET = 10054 - if n := errno(se.Err); n == WSAECONNRESET || n == WSAECONNABORTED { - return true - } - } - } - } - return false -} - -func (sc *serverConn) condlogf(err error, format string, args ...interface{}) { - if err == nil { - return - } - if err == io.EOF || err == io.ErrUnexpectedEOF || isClosedConnError(err) { - // Boring, expected errors. - sc.vlogf(format, args...) - } else { - sc.logf(format, args...) - } -} - -func (sc *serverConn) canonicalHeader(v string) string { - sc.serveG.check() - cv, ok := commonCanonHeader[v] - if ok { - return cv - } - cv, ok = sc.canonHeader[v] - if ok { - return cv - } - if sc.canonHeader == nil { - sc.canonHeader = make(map[string]string) - } - cv = http.CanonicalHeaderKey(v) - sc.canonHeader[v] = cv - return cv -} - -type readFrameResult struct { - f Frame // valid until readMore is called - err error - - // readMore should be called once the consumer no longer needs or - // retains f. After readMore, f is invalid and more frames can be - // read. - readMore func() -} - -// readFrames is the loop that reads incoming frames. -// It takes care to only read one frame at a time, blocking until the -// consumer is done with the frame. -// It's run on its own goroutine. -func (sc *serverConn) readFrames() { - gate := make(gate) - gateDone := gate.Done - for { - f, err := sc.framer.ReadFrame() - select { - case sc.readFrameCh <- readFrameResult{f, err, gateDone}: - case <-sc.doneServing: - return - } - select { - case <-gate: - case <-sc.doneServing: - return - } - if terminalReadFrameError(err) { - return - } - } -} - -// frameWriteResult is the message passed from writeFrameAsync to the serve goroutine. -type frameWriteResult struct { - wr FrameWriteRequest // what was written (or attempted) - err error // result of the writeFrame call -} - -// writeFrameAsync runs in its own goroutine and writes a single frame -// and then reports when it's done. -// At most one goroutine can be running writeFrameAsync at a time per -// serverConn. -func (sc *serverConn) writeFrameAsync(wr FrameWriteRequest) { - err := wr.write.writeFrame(sc) - sc.wroteFrameCh <- frameWriteResult{wr, err} -} - -func (sc *serverConn) closeAllStreamsOnConnClose() { - sc.serveG.check() - for _, st := range sc.streams { - sc.closeStream(st, errClientDisconnected) - } -} - -func (sc *serverConn) stopShutdownTimer() { - sc.serveG.check() - if t := sc.shutdownTimer; t != nil { - t.Stop() - } -} - -func (sc *serverConn) notePanic() { - // Note: this is for serverConn.serve panicking, not http.Handler code. - if testHookOnPanicMu != nil { - testHookOnPanicMu.Lock() - defer testHookOnPanicMu.Unlock() - } - if testHookOnPanic != nil { - if e := recover(); e != nil { - if testHookOnPanic(sc, e) { - panic(e) - } - } - } -} - -func (sc *serverConn) serve() { - sc.serveG.check() - defer sc.notePanic() - defer sc.conn.Close() - defer sc.closeAllStreamsOnConnClose() - defer sc.stopShutdownTimer() - defer close(sc.doneServing) // unblocks handlers trying to send - - if VerboseLogs { - sc.vlogf("http2: server connection from %v on %p", sc.conn.RemoteAddr(), sc.hs) - } - - sc.writeFrame(FrameWriteRequest{ - write: writeSettings{ - {SettingMaxFrameSize, sc.srv.maxReadFrameSize()}, - {SettingMaxConcurrentStreams, sc.advMaxStreams}, - {SettingMaxHeaderListSize, sc.maxHeaderListSize()}, - {SettingInitialWindowSize, uint32(sc.srv.initialStreamRecvWindowSize())}, - }, - }) - sc.unackedSettings++ - - // Each connection starts with intialWindowSize inflow tokens. - // If a higher value is configured, we add more tokens. - if diff := sc.srv.initialConnRecvWindowSize() - initialWindowSize; diff > 0 { - sc.sendWindowUpdate(nil, int(diff)) - } - - if err := sc.readPreface(); err != nil { - sc.condlogf(err, "http2: server: error reading preface from client %v: %v", sc.conn.RemoteAddr(), err) - return - } - // Now that we've got the preface, get us out of the - // "StateNew" state. We can't go directly to idle, though. - // Active means we read some data and anticipate a request. We'll - // do another Active when we get a HEADERS frame. - sc.setConnState(http.StateActive) - sc.setConnState(http.StateIdle) - - if sc.srv.IdleTimeout != 0 { - sc.idleTimer = time.NewTimer(sc.srv.IdleTimeout) - defer sc.idleTimer.Stop() - sc.idleTimerCh = sc.idleTimer.C - } - - var gracefulShutdownCh <-chan struct{} - if sc.hs != nil { - gracefulShutdownCh = h1ServerShutdownChan(sc.hs) - } - - go sc.readFrames() // closed by defer sc.conn.Close above - - settingsTimer := time.NewTimer(firstSettingsTimeout) - loopNum := 0 - for { - loopNum++ - select { - case wr := <-sc.wantWriteFrameCh: - if se, ok := wr.write.(StreamError); ok { - sc.resetStream(se) - break - } - sc.writeFrame(wr) - case spr := <-sc.wantStartPushCh: - sc.startPush(spr) - case res := <-sc.wroteFrameCh: - sc.wroteFrame(res) - case res := <-sc.readFrameCh: - if !sc.processFrameFromReader(res) { - return - } - res.readMore() - if settingsTimer.C != nil { - settingsTimer.Stop() - settingsTimer.C = nil - } - case m := <-sc.bodyReadCh: - sc.noteBodyRead(m.st, m.n) - case <-settingsTimer.C: - sc.logf("timeout waiting for SETTINGS frames from %v", sc.conn.RemoteAddr()) - return - case <-gracefulShutdownCh: - gracefulShutdownCh = nil - sc.startGracefulShutdown() - case <-sc.shutdownTimerCh: - sc.vlogf("GOAWAY close timer fired; closing conn from %v", sc.conn.RemoteAddr()) - return - case <-sc.idleTimerCh: - sc.vlogf("connection is idle") - sc.goAway(ErrCodeNo) - case fn := <-sc.testHookCh: - fn(loopNum) - } - - if sc.inGoAway && sc.curOpenStreams() == 0 && !sc.needToSendGoAway && !sc.writingFrame { - return - } - } -} - -// readPreface reads the ClientPreface greeting from the peer -// or returns an error on timeout or an invalid greeting. -func (sc *serverConn) readPreface() error { - errc := make(chan error, 1) - go func() { - // Read the client preface - buf := make([]byte, len(ClientPreface)) - if _, err := io.ReadFull(sc.conn, buf); err != nil { - errc <- err - } else if !bytes.Equal(buf, clientPreface) { - errc <- fmt.Errorf("bogus greeting %q", buf) - } else { - errc <- nil - } - }() - timer := time.NewTimer(prefaceTimeout) // TODO: configurable on *Server? - defer timer.Stop() - select { - case <-timer.C: - return errors.New("timeout waiting for client preface") - case err := <-errc: - if err == nil { - if VerboseLogs { - sc.vlogf("http2: server: client %v said hello", sc.conn.RemoteAddr()) - } - } - return err - } -} - -var errChanPool = sync.Pool{ - New: func() interface{} { return make(chan error, 1) }, -} - -var writeDataPool = sync.Pool{ - New: func() interface{} { return new(writeData) }, -} - -// writeDataFromHandler writes DATA response frames from a handler on -// the given stream. -func (sc *serverConn) writeDataFromHandler(stream *stream, data []byte, endStream bool) error { - ch := errChanPool.Get().(chan error) - writeArg := writeDataPool.Get().(*writeData) - *writeArg = writeData{stream.id, data, endStream} - err := sc.writeFrameFromHandler(FrameWriteRequest{ - write: writeArg, - stream: stream, - done: ch, - }) - if err != nil { - return err - } - var frameWriteDone bool // the frame write is done (successfully or not) - select { - case err = <-ch: - frameWriteDone = true - case <-sc.doneServing: - return errClientDisconnected - case <-stream.cw: - // If both ch and stream.cw were ready (as might - // happen on the final Write after an http.Handler - // ends), prefer the write result. Otherwise this - // might just be us successfully closing the stream. - // The writeFrameAsync and serve goroutines guarantee - // that the ch send will happen before the stream.cw - // close. - select { - case err = <-ch: - frameWriteDone = true - default: - return errStreamClosed - } - } - errChanPool.Put(ch) - if frameWriteDone { - writeDataPool.Put(writeArg) - } - return err -} - -// writeFrameFromHandler sends wr to sc.wantWriteFrameCh, but aborts -// if the connection has gone away. -// -// This must not be run from the serve goroutine itself, else it might -// deadlock writing to sc.wantWriteFrameCh (which is only mildly -// buffered and is read by serve itself). If you're on the serve -// goroutine, call writeFrame instead. -func (sc *serverConn) writeFrameFromHandler(wr FrameWriteRequest) error { - sc.serveG.checkNotOn() // NOT - select { - case sc.wantWriteFrameCh <- wr: - return nil - case <-sc.doneServing: - // Serve loop is gone. - // Client has closed their connection to the server. - return errClientDisconnected - } -} - -// writeFrame schedules a frame to write and sends it if there's nothing -// already being written. -// -// There is no pushback here (the serve goroutine never blocks). It's -// the http.Handlers that block, waiting for their previous frames to -// make it onto the wire -// -// If you're not on the serve goroutine, use writeFrameFromHandler instead. -func (sc *serverConn) writeFrame(wr FrameWriteRequest) { - sc.serveG.check() - - // If true, wr will not be written and wr.done will not be signaled. - var ignoreWrite bool - - // We are not allowed to write frames on closed streams. RFC 7540 Section - // 5.1.1 says: "An endpoint MUST NOT send frames other than PRIORITY on - // a closed stream." Our server never sends PRIORITY, so that exception - // does not apply. - // - // The serverConn might close an open stream while the stream's handler - // is still running. For example, the server might close a stream when it - // receives bad data from the client. If this happens, the handler might - // attempt to write a frame after the stream has been closed (since the - // handler hasn't yet been notified of the close). In this case, we simply - // ignore the frame. The handler will notice that the stream is closed when - // it waits for the frame to be written. - // - // As an exception to this rule, we allow sending RST_STREAM after close. - // This allows us to immediately reject new streams without tracking any - // state for those streams (except for the queued RST_STREAM frame). This - // may result in duplicate RST_STREAMs in some cases, but the client should - // ignore those. - if wr.StreamID() != 0 { - _, isReset := wr.write.(StreamError) - if state, _ := sc.state(wr.StreamID()); state == stateClosed && !isReset { - ignoreWrite = true - } - } - - // Don't send a 100-continue response if we've already sent headers. - // See golang.org/issue/14030. - switch wr.write.(type) { - case *writeResHeaders: - wr.stream.wroteHeaders = true - case write100ContinueHeadersFrame: - if wr.stream.wroteHeaders { - // We do not need to notify wr.done because this frame is - // never written with wr.done != nil. - if wr.done != nil { - panic("wr.done != nil for write100ContinueHeadersFrame") - } - ignoreWrite = true - } - } - - if !ignoreWrite { - sc.writeSched.Push(wr) - } - sc.scheduleFrameWrite() -} - -// startFrameWrite starts a goroutine to write wr (in a separate -// goroutine since that might block on the network), and updates the -// serve goroutine's state about the world, updated from info in wr. -func (sc *serverConn) startFrameWrite(wr FrameWriteRequest) { - sc.serveG.check() - if sc.writingFrame { - panic("internal error: can only be writing one frame at a time") - } - - st := wr.stream - if st != nil { - switch st.state { - case stateHalfClosedLocal: - switch wr.write.(type) { - case StreamError, handlerPanicRST, writeWindowUpdate: - // RFC 7540 Section 5.1 allows sending RST_STREAM, PRIORITY, and WINDOW_UPDATE - // in this state. (We never send PRIORITY from the server, so that is not checked.) - default: - panic(fmt.Sprintf("internal error: attempt to send frame on a half-closed-local stream: %v", wr)) - } - case stateClosed: - panic(fmt.Sprintf("internal error: attempt to send frame on a closed stream: %v", wr)) - } - } - if wpp, ok := wr.write.(*writePushPromise); ok { - var err error - wpp.promisedID, err = wpp.allocatePromisedID() - if err != nil { - sc.writingFrameAsync = false - wr.replyToWriter(err) - return - } - } - - sc.writingFrame = true - sc.needsFrameFlush = true - if wr.write.staysWithinBuffer(sc.bw.Available()) { - sc.writingFrameAsync = false - err := wr.write.writeFrame(sc) - sc.wroteFrame(frameWriteResult{wr, err}) - } else { - sc.writingFrameAsync = true - go sc.writeFrameAsync(wr) - } -} - -// errHandlerPanicked is the error given to any callers blocked in a read from -// Request.Body when the main goroutine panics. Since most handlers read in the -// the main ServeHTTP goroutine, this will show up rarely. -var errHandlerPanicked = errors.New("http2: handler panicked") - -// wroteFrame is called on the serve goroutine with the result of -// whatever happened on writeFrameAsync. -func (sc *serverConn) wroteFrame(res frameWriteResult) { - sc.serveG.check() - if !sc.writingFrame { - panic("internal error: expected to be already writing a frame") - } - sc.writingFrame = false - sc.writingFrameAsync = false - - wr := res.wr - - if writeEndsStream(wr.write) { - st := wr.stream - if st == nil { - panic("internal error: expecting non-nil stream") - } - switch st.state { - case stateOpen: - // Here we would go to stateHalfClosedLocal in - // theory, but since our handler is done and - // the net/http package provides no mechanism - // for closing a ResponseWriter while still - // reading data (see possible TODO at top of - // this file), we go into closed state here - // anyway, after telling the peer we're - // hanging up on them. We'll transition to - // stateClosed after the RST_STREAM frame is - // written. - st.state = stateHalfClosedLocal - // Section 8.1: a server MAY request that the client abort - // transmission of a request without error by sending a - // RST_STREAM with an error code of NO_ERROR after sending - // a complete response. - sc.resetStream(streamError(st.id, ErrCodeNo)) - case stateHalfClosedRemote: - sc.closeStream(st, errHandlerComplete) - } - } else { - switch v := wr.write.(type) { - case StreamError: - // st may be unknown if the RST_STREAM was generated to reject bad input. - if st, ok := sc.streams[v.StreamID]; ok { - sc.closeStream(st, v) - } - case handlerPanicRST: - sc.closeStream(wr.stream, errHandlerPanicked) - } - } - - // Reply (if requested) to unblock the ServeHTTP goroutine. - wr.replyToWriter(res.err) - - sc.scheduleFrameWrite() -} - -// scheduleFrameWrite tickles the frame writing scheduler. -// -// If a frame is already being written, nothing happens. This will be called again -// when the frame is done being written. -// -// If a frame isn't being written we need to send one, the best frame -// to send is selected, preferring first things that aren't -// stream-specific (e.g. ACKing settings), and then finding the -// highest priority stream. -// -// If a frame isn't being written and there's nothing else to send, we -// flush the write buffer. -func (sc *serverConn) scheduleFrameWrite() { - sc.serveG.check() - if sc.writingFrame || sc.inFrameScheduleLoop { - return - } - sc.inFrameScheduleLoop = true - for !sc.writingFrameAsync { - if sc.needToSendGoAway { - sc.needToSendGoAway = false - sc.startFrameWrite(FrameWriteRequest{ - write: &writeGoAway{ - maxStreamID: sc.maxClientStreamID, - code: sc.goAwayCode, - }, - }) - continue - } - if sc.needToSendSettingsAck { - sc.needToSendSettingsAck = false - sc.startFrameWrite(FrameWriteRequest{write: writeSettingsAck{}}) - continue - } - if !sc.inGoAway || sc.goAwayCode == ErrCodeNo { - if wr, ok := sc.writeSched.Pop(); ok { - sc.startFrameWrite(wr) - continue - } - } - if sc.needsFrameFlush { - sc.startFrameWrite(FrameWriteRequest{write: flushFrameWriter{}}) - sc.needsFrameFlush = false // after startFrameWrite, since it sets this true - continue - } - break - } - sc.inFrameScheduleLoop = false -} - -// startGracefulShutdown sends a GOAWAY with ErrCodeNo to tell the -// client we're gracefully shutting down. The connection isn't closed -// until all current streams are done. -func (sc *serverConn) startGracefulShutdown() { - sc.goAwayIn(ErrCodeNo, 0) -} - -func (sc *serverConn) goAway(code ErrCode) { - sc.serveG.check() - var forceCloseIn time.Duration - if code != ErrCodeNo { - forceCloseIn = 250 * time.Millisecond - } else { - // TODO: configurable - forceCloseIn = 1 * time.Second - } - sc.goAwayIn(code, forceCloseIn) -} - -func (sc *serverConn) goAwayIn(code ErrCode, forceCloseIn time.Duration) { - sc.serveG.check() - if sc.inGoAway { - return - } - if forceCloseIn != 0 { - sc.shutDownIn(forceCloseIn) - } - sc.inGoAway = true - sc.needToSendGoAway = true - sc.goAwayCode = code - sc.scheduleFrameWrite() -} - -func (sc *serverConn) shutDownIn(d time.Duration) { - sc.serveG.check() - sc.shutdownTimer = time.NewTimer(d) - sc.shutdownTimerCh = sc.shutdownTimer.C -} - -func (sc *serverConn) resetStream(se StreamError) { - sc.serveG.check() - sc.writeFrame(FrameWriteRequest{write: se}) - if st, ok := sc.streams[se.StreamID]; ok { - st.resetQueued = true - } -} - -// processFrameFromReader processes the serve loop's read from readFrameCh from the -// frame-reading goroutine. -// processFrameFromReader returns whether the connection should be kept open. -func (sc *serverConn) processFrameFromReader(res readFrameResult) bool { - sc.serveG.check() - err := res.err - if err != nil { - if err == ErrFrameTooLarge { - sc.goAway(ErrCodeFrameSize) - return true // goAway will close the loop - } - clientGone := err == io.EOF || err == io.ErrUnexpectedEOF || isClosedConnError(err) - if clientGone { - // TODO: could we also get into this state if - // the peer does a half close - // (e.g. CloseWrite) because they're done - // sending frames but they're still wanting - // our open replies? Investigate. - // TODO: add CloseWrite to crypto/tls.Conn first - // so we have a way to test this? I suppose - // just for testing we could have a non-TLS mode. - return false - } - } else { - f := res.f - if VerboseLogs { - sc.vlogf("http2: server read frame %v", summarizeFrame(f)) - } - err = sc.processFrame(f) - if err == nil { - return true - } - } - - switch ev := err.(type) { - case StreamError: - sc.resetStream(ev) - return true - case goAwayFlowError: - sc.goAway(ErrCodeFlowControl) - return true - case ConnectionError: - sc.logf("http2: server connection error from %v: %v", sc.conn.RemoteAddr(), ev) - sc.goAway(ErrCode(ev)) - return true // goAway will handle shutdown - default: - if res.err != nil { - sc.vlogf("http2: server closing client connection; error reading frame from client %s: %v", sc.conn.RemoteAddr(), err) - } else { - sc.logf("http2: server closing client connection: %v", err) - } - return false - } -} - -func (sc *serverConn) processFrame(f Frame) error { - sc.serveG.check() - - // First frame received must be SETTINGS. - if !sc.sawFirstSettings { - if _, ok := f.(*SettingsFrame); !ok { - return ConnectionError(ErrCodeProtocol) - } - sc.sawFirstSettings = true - } - - switch f := f.(type) { - case *SettingsFrame: - return sc.processSettings(f) - case *MetaHeadersFrame: - return sc.processHeaders(f) - case *WindowUpdateFrame: - return sc.processWindowUpdate(f) - case *PingFrame: - return sc.processPing(f) - case *DataFrame: - return sc.processData(f) - case *RSTStreamFrame: - return sc.processResetStream(f) - case *PriorityFrame: - return sc.processPriority(f) - case *GoAwayFrame: - return sc.processGoAway(f) - case *PushPromiseFrame: - // A client cannot push. Thus, servers MUST treat the receipt of a PUSH_PROMISE - // frame as a connection error (Section 5.4.1) of type PROTOCOL_ERROR. - return ConnectionError(ErrCodeProtocol) - default: - sc.vlogf("http2: server ignoring frame: %v", f.Header()) - return nil - } -} - -func (sc *serverConn) processPing(f *PingFrame) error { - sc.serveG.check() - if f.IsAck() { - // 6.7 PING: " An endpoint MUST NOT respond to PING frames - // containing this flag." - return nil - } - if f.StreamID != 0 { - // "PING frames are not associated with any individual - // stream. If a PING frame is received with a stream - // identifier field value other than 0x0, the recipient MUST - // respond with a connection error (Section 5.4.1) of type - // PROTOCOL_ERROR." - return ConnectionError(ErrCodeProtocol) - } - if sc.inGoAway && sc.goAwayCode != ErrCodeNo { - return nil - } - sc.writeFrame(FrameWriteRequest{write: writePingAck{f}}) - return nil -} - -func (sc *serverConn) processWindowUpdate(f *WindowUpdateFrame) error { - sc.serveG.check() - switch { - case f.StreamID != 0: // stream-level flow control - state, st := sc.state(f.StreamID) - if state == stateIdle { - // Section 5.1: "Receiving any frame other than HEADERS - // or PRIORITY on a stream in this state MUST be - // treated as a connection error (Section 5.4.1) of - // type PROTOCOL_ERROR." - return ConnectionError(ErrCodeProtocol) - } - if st == nil { - // "WINDOW_UPDATE can be sent by a peer that has sent a - // frame bearing the END_STREAM flag. This means that a - // receiver could receive a WINDOW_UPDATE frame on a "half - // closed (remote)" or "closed" stream. A receiver MUST - // NOT treat this as an error, see Section 5.1." - return nil - } - if !st.flow.add(int32(f.Increment)) { - return streamError(f.StreamID, ErrCodeFlowControl) - } - default: // connection-level flow control - if !sc.flow.add(int32(f.Increment)) { - return goAwayFlowError{} - } - } - sc.scheduleFrameWrite() - return nil -} - -func (sc *serverConn) processResetStream(f *RSTStreamFrame) error { - sc.serveG.check() - - state, st := sc.state(f.StreamID) - if state == stateIdle { - // 6.4 "RST_STREAM frames MUST NOT be sent for a - // stream in the "idle" state. If a RST_STREAM frame - // identifying an idle stream is received, the - // recipient MUST treat this as a connection error - // (Section 5.4.1) of type PROTOCOL_ERROR. - return ConnectionError(ErrCodeProtocol) - } - if st != nil { - st.cancelCtx() - sc.closeStream(st, streamError(f.StreamID, f.ErrCode)) - } - return nil -} - -func (sc *serverConn) closeStream(st *stream, err error) { - sc.serveG.check() - if st.state == stateIdle || st.state == stateClosed { - panic(fmt.Sprintf("invariant; can't close stream in state %v", st.state)) - } - st.state = stateClosed - if st.writeDeadline != nil { - st.writeDeadline.Stop() - } - if st.isPushed() { - sc.curPushedStreams-- - } else { - sc.curClientStreams-- - } - delete(sc.streams, st.id) - if len(sc.streams) == 0 { - sc.setConnState(http.StateIdle) - if sc.srv.IdleTimeout != 0 { - sc.idleTimer.Reset(sc.srv.IdleTimeout) - } - if h1ServerKeepAlivesDisabled(sc.hs) { - sc.startGracefulShutdown() - } - } - 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 - sc.writeSched.CloseStream(st.id) -} - -func (sc *serverConn) processSettings(f *SettingsFrame) error { - sc.serveG.check() - if f.IsAck() { - sc.unackedSettings-- - if sc.unackedSettings < 0 { - // Why is the peer ACKing settings we never sent? - // The spec doesn't mention this case, but - // hang up on them anyway. - return ConnectionError(ErrCodeProtocol) - } - return nil - } - if err := f.ForeachSetting(sc.processSetting); err != nil { - return err - } - sc.needToSendSettingsAck = true - sc.scheduleFrameWrite() - return nil -} - -func (sc *serverConn) processSetting(s Setting) error { - sc.serveG.check() - if err := s.Valid(); err != nil { - return err - } - if VerboseLogs { - sc.vlogf("http2: server processing setting %v", s) - } - switch s.ID { - case SettingHeaderTableSize: - sc.headerTableSize = s.Val - sc.hpackEncoder.SetMaxDynamicTableSize(s.Val) - case SettingEnablePush: - sc.pushEnabled = s.Val != 0 - case SettingMaxConcurrentStreams: - sc.clientMaxStreams = s.Val - case SettingInitialWindowSize: - return sc.processSettingInitialWindowSize(s.Val) - case SettingMaxFrameSize: - sc.maxFrameSize = int32(s.Val) // the maximum valid s.Val is < 2^31 - case SettingMaxHeaderListSize: - sc.peerMaxHeaderListSize = s.Val - default: - // Unknown setting: "An endpoint that receives a SETTINGS - // frame with any unknown or unsupported identifier MUST - // ignore that setting." - if VerboseLogs { - sc.vlogf("http2: server ignoring unknown setting %v", s) - } - } - return nil -} - -func (sc *serverConn) processSettingInitialWindowSize(val uint32) error { - sc.serveG.check() - // Note: val already validated to be within range by - // processSetting's Valid call. - - // "A SETTINGS frame can alter the initial flow control window - // size for all current streams. When the value of - // SETTINGS_INITIAL_WINDOW_SIZE changes, a receiver MUST - // adjust the size of all stream flow control windows that it - // maintains by the difference between the new value and the - // old value." - old := sc.initialStreamSendWindowSize - sc.initialStreamSendWindowSize = int32(val) - growth := int32(val) - old // may be negative - for _, st := range sc.streams { - if !st.flow.add(growth) { - // 6.9.2 Initial Flow Control Window Size - // "An endpoint MUST treat a change to - // SETTINGS_INITIAL_WINDOW_SIZE that causes any flow - // control window to exceed the maximum size as a - // connection error (Section 5.4.1) of type - // FLOW_CONTROL_ERROR." - return ConnectionError(ErrCodeFlowControl) - } - } - return nil -} - -func (sc *serverConn) processData(f *DataFrame) error { - sc.serveG.check() - if sc.inGoAway && sc.goAwayCode != ErrCodeNo { - return nil - } - 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." - id := f.Header().StreamID - state, st := sc.state(id) - if id == 0 || state == stateIdle { - // Section 5.1: "Receiving any frame other than HEADERS - // or PRIORITY on a stream in this state MUST be - // treated as a connection error (Section 5.4.1) of - // type PROTOCOL_ERROR." - return ConnectionError(ErrCodeProtocol) - } - if st == nil || state != stateOpen || st.gotTrailerHeader || st.resetQueued { - // This includes sending a RST_STREAM if the stream is - // in stateHalfClosedLocal (which currently means that - // the http.Handler returned, so it's done reading & - // done writing). Try to stop the client from sending - // more DATA. - - // 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 - - if st != nil && st.resetQueued { - // Already have a stream error in flight. Don't send another. - return nil - } - return streamError(id, ErrCodeStreamClosed) - } - if st.body == nil { - panic("internal error: should have a body in this state") - } - - // Sender sending more than they'd declared? - if st.declBodyBytes != -1 && st.bodyBytes+int64(len(data)) > st.declBodyBytes { - st.body.CloseWithError(fmt.Errorf("sender tried to send more than declared Content-Length of %d bytes", st.declBodyBytes)) - return streamError(id, ErrCodeStreamClosed) - } - if f.Length > 0 { - // Check whether the client has flow control quota. - if st.inflow.available() < int32(f.Length) { - return streamError(id, ErrCodeFlowControl) - } - 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)) - } - - // 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) - } - } - if f.StreamEnded() { - st.endStream() - } - return nil -} - -func (sc *serverConn) processGoAway(f *GoAwayFrame) error { - sc.serveG.check() - if f.ErrCode != ErrCodeNo { - sc.logf("http2: received GOAWAY %+v, starting graceful shutdown", f) - } else { - sc.vlogf("http2: received GOAWAY %+v, starting graceful shutdown", f) - } - sc.startGracefulShutdown() - // http://tools.ietf.org/html/rfc7540#section-6.8 - // We should not create any new streams, which means we should disable push. - sc.pushEnabled = false - return nil -} - -// isPushed reports whether the stream is server-initiated. -func (st *stream) isPushed() bool { - return st.id%2 == 0 -} - -// endStream closes a Request.Body's pipe. It is called when a DATA -// frame says a request body is over (or after trailers). -func (st *stream) endStream() { - sc := st.sc - sc.serveG.check() - - if st.declBodyBytes != -1 && st.declBodyBytes != st.bodyBytes { - st.body.CloseWithError(fmt.Errorf("request declared a Content-Length of %d but only wrote %d bytes", - st.declBodyBytes, st.bodyBytes)) - } else { - st.body.closeWithErrorAndCode(io.EOF, st.copyTrailersToHandlerRequest) - st.body.CloseWithError(io.EOF) - } - st.state = stateHalfClosedRemote -} - -// copyTrailersToHandlerRequest is run in the Handler's goroutine in -// its Request.Body.Read just before it gets io.EOF. -func (st *stream) copyTrailersToHandlerRequest() { - for k, vv := range st.trailer { - if _, ok := st.reqTrailer[k]; ok { - // Only copy it over it was pre-declared. - st.reqTrailer[k] = vv - } - } -} - -// onWriteTimeout is run on its own goroutine (from time.AfterFunc) -// when the stream's WriteTimeout has fired. -func (st *stream) onWriteTimeout() { - st.sc.writeFrameFromHandler(FrameWriteRequest{write: streamError(st.id, ErrCodeInternal)}) -} - -func (sc *serverConn) processHeaders(f *MetaHeadersFrame) error { - sc.serveG.check() - id := f.StreamID - if sc.inGoAway { - // Ignore. - return nil - } - // http://tools.ietf.org/html/rfc7540#section-5.1.1 - // Streams initiated by a client MUST use odd-numbered stream - // identifiers. [...] An endpoint that receives an unexpected - // stream identifier MUST respond with a connection error - // (Section 5.4.1) of type PROTOCOL_ERROR. - if id%2 != 1 { - return ConnectionError(ErrCodeProtocol) - } - // A HEADERS frame can be used to create a new stream or - // send a trailer for an open one. If we already have a stream - // open, let it process its own HEADERS frame (trailers at this - // point, if it's valid). - if st := sc.streams[f.StreamID]; st != nil { - if st.resetQueued { - // We're sending RST_STREAM to close the stream, so don't bother - // processing this frame. - return nil - } - return st.processTrailerHeaders(f) - } - - // [...] The identifier of a newly established stream MUST be - // numerically greater than all streams that the initiating - // endpoint has opened or reserved. [...] An endpoint that - // receives an unexpected stream identifier MUST respond with - // a connection error (Section 5.4.1) of type PROTOCOL_ERROR. - if id <= sc.maxClientStreamID { - return ConnectionError(ErrCodeProtocol) - } - sc.maxClientStreamID = id - - if sc.idleTimer != nil { - sc.idleTimer.Stop() - } - - // http://tools.ietf.org/html/rfc7540#section-5.1.2 - // [...] Endpoints MUST NOT exceed the limit set by their peer. An - // endpoint that receives a HEADERS frame that causes their - // advertised concurrent stream limit to be exceeded MUST treat - // this as a stream error (Section 5.4.2) of type PROTOCOL_ERROR - // or REFUSED_STREAM. - if sc.curClientStreams+1 > sc.advMaxStreams { - if sc.unackedSettings == 0 { - // They should know better. - return streamError(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(id, ErrCodeRefusedStream) - } - - initialState := stateOpen - if f.StreamEnded() { - initialState = stateHalfClosedRemote - } - st := sc.newStream(id, 0, initialState) - - if f.HasPriority() { - if err := checkPriority(f.StreamID, f.Priority); err != nil { - return err - } - sc.writeSched.AdjustStream(st.id, f.Priority) - } - - rw, req, err := sc.newWriterAndRequest(st, f) - if err != nil { - return err - } - st.reqTrailer = req.Trailer - if st.reqTrailer != nil { - st.trailer = make(http.Header) - } - st.body = req.Body.(*requestBody).pipe // may be nil - st.declBodyBytes = req.ContentLength - - handler := sc.handler.ServeHTTP - if f.Truncated { - // Their header list was too long. Send a 431 error. - handler = handleHeaderListTooLong - } else if err := checkValidHTTP2RequestHeaders(req.Header); err != nil { - handler = new400Handler(err) - } - - // The net/http package sets the read deadline from the - // http.Server.ReadTimeout during the TLS handshake, but then - // passes the connection off to us with the deadline already - // set. Disarm it here after the request headers are read, - // similar to how the http1 server works. Here it's - // technically more like the http1 Server's ReadHeaderTimeout - // (in Go 1.8), though. That's a more sane option anyway. - if sc.hs.ReadTimeout != 0 { - sc.conn.SetReadDeadline(time.Time{}) - } - - go sc.runHandler(rw, req, handler) - return nil -} - -func (st *stream) processTrailerHeaders(f *MetaHeadersFrame) error { - sc := st.sc - sc.serveG.check() - if st.gotTrailerHeader { - return ConnectionError(ErrCodeProtocol) - } - st.gotTrailerHeader = true - if !f.StreamEnded() { - return streamError(st.id, ErrCodeProtocol) - } - - if len(f.PseudoFields()) > 0 { - return streamError(st.id, ErrCodeProtocol) - } - if st.trailer != nil { - for _, hf := range f.RegularFields() { - key := sc.canonicalHeader(hf.Name) - if !ValidTrailerHeader(key) { - // TODO: send more details to the peer somehow. But http2 has - // no way to send debug data at a stream level. Discuss with - // HTTP folk. - return streamError(st.id, ErrCodeProtocol) - } - st.trailer[key] = append(st.trailer[key], hf.Value) - } - } - st.endStream() - return nil -} - -func checkPriority(streamID uint32, p PriorityParam) error { - if streamID == p.StreamDep { - // Section 5.3.1: "A stream cannot depend on itself. An endpoint MUST treat - // this as a stream error (Section 5.4.2) of type PROTOCOL_ERROR." - // Section 5.3.3 says that a stream can depend on one of its dependencies, - // so it's only self-dependencies that are forbidden. - return streamError(streamID, ErrCodeProtocol) - } - return nil -} - -func (sc *serverConn) processPriority(f *PriorityFrame) error { - if sc.inGoAway { - return nil - } - if err := checkPriority(f.StreamID, f.PriorityParam); err != nil { - return err - } - sc.writeSched.AdjustStream(f.StreamID, f.PriorityParam) - return nil -} - -func (sc *serverConn) newStream(id, pusherID uint32, state streamState) *stream { - sc.serveG.check() - if id == 0 { - panic("internal error: cannot create stream with id 0") - } - - ctx, cancelCtx := contextWithCancel(sc.baseCtx) - st := &stream{ - sc: sc, - id: id, - state: state, - ctx: ctx, - cancelCtx: cancelCtx, - } - st.cw.Init() - st.flow.conn = &sc.flow // link to conn-level counter - st.flow.add(sc.initialStreamSendWindowSize) - st.inflow.conn = &sc.inflow // link to conn-level counter - st.inflow.add(sc.srv.initialStreamRecvWindowSize()) - if sc.hs.WriteTimeout != 0 { - st.writeDeadline = time.AfterFunc(sc.hs.WriteTimeout, st.onWriteTimeout) - } - - sc.streams[id] = st - sc.writeSched.OpenStream(st.id, OpenStreamOptions{PusherID: pusherID}) - if st.isPushed() { - sc.curPushedStreams++ - } else { - sc.curClientStreams++ - } - if sc.curOpenStreams() == 1 { - sc.setConnState(http.StateActive) - } - - return st -} - -func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*responseWriter, *http.Request, error) { - sc.serveG.check() - - rp := requestParam{ - method: f.PseudoValue("method"), - scheme: f.PseudoValue("scheme"), - authority: f.PseudoValue("authority"), - path: f.PseudoValue("path"), - } - - isConnect := rp.method == "CONNECT" - if isConnect { - if rp.path != "" || rp.scheme != "" || rp.authority == "" { - return nil, nil, streamError(f.StreamID, ErrCodeProtocol) - } - } else if rp.method == "" || rp.path == "" || (rp.scheme != "https" && rp.scheme != "http") { - // See 8.1.2.6 Malformed Requests and Responses: - // - // Malformed requests or responses that are detected - // MUST be treated as a stream error (Section 5.4.2) - // of type PROTOCOL_ERROR." - // - // 8.1.2.3 Request Pseudo-Header Fields - // "All HTTP/2 requests MUST include exactly one valid - // value for the :method, :scheme, and :path - // pseudo-header fields" - return nil, nil, streamError(f.StreamID, ErrCodeProtocol) - } - - bodyOpen := !f.StreamEnded() - if rp.method == "HEAD" && bodyOpen { - // HEAD requests can't have bodies - return nil, nil, streamError(f.StreamID, ErrCodeProtocol) - } - - rp.header = make(http.Header) - for _, hf := range f.RegularFields() { - rp.header.Add(sc.canonicalHeader(hf.Name), hf.Value) - } - if rp.authority == "" { - rp.authority = rp.header.Get("Host") - } - - rw, req, err := sc.newWriterAndRequestNoBody(st, rp) - if err != nil { - return nil, nil, err - } - if bodyOpen { - if vv, ok := rp.header["Content-Length"]; ok { - req.ContentLength, _ = strconv.ParseInt(vv[0], 10, 64) - } else { - req.ContentLength = -1 - } - req.Body.(*requestBody).pipe = &pipe{ - b: &dataBuffer{expected: req.ContentLength}, - } - } - return rw, req, nil -} - -type requestParam struct { - method string - scheme, authority, path string - header http.Header -} - -func (sc *serverConn) newWriterAndRequestNoBody(st *stream, rp requestParam) (*responseWriter, *http.Request, error) { - sc.serveG.check() - - var tlsState *tls.ConnectionState // nil if not scheme https - if rp.scheme == "https" { - tlsState = sc.tlsState - } - - needsContinue := rp.header.Get("Expect") == "100-continue" - if needsContinue { - rp.header.Del("Expect") - } - // Merge Cookie headers into one "; "-delimited value. - if cookies := rp.header["Cookie"]; len(cookies) > 1 { - rp.header.Set("Cookie", strings.Join(cookies, "; ")) - } - - // Setup Trailers - var trailer http.Header - for _, v := range rp.header["Trailer"] { - for _, key := range strings.Split(v, ",") { - key = http.CanonicalHeaderKey(strings.TrimSpace(key)) - switch key { - case "Transfer-Encoding", "Trailer", "Content-Length": - // Bogus. (copy of http1 rules) - // Ignore. - default: - if trailer == nil { - trailer = make(http.Header) - } - trailer[key] = nil - } - } - } - delete(rp.header, "Trailer") - - var url_ *url.URL - var requestURI string - if rp.method == "CONNECT" { - url_ = &url.URL{Host: rp.authority} - requestURI = rp.authority // mimic HTTP/1 server behavior - } else { - var err error - url_, err = url.ParseRequestURI(rp.path) - if err != nil { - return nil, nil, streamError(st.id, ErrCodeProtocol) - } - requestURI = rp.path - } - - body := &requestBody{ - conn: sc, - stream: st, - needsContinue: needsContinue, - } - req := &http.Request{ - Method: rp.method, - URL: url_, - RemoteAddr: sc.remoteAddrStr, - Header: rp.header, - RequestURI: requestURI, - Proto: "HTTP/2.0", - ProtoMajor: 2, - ProtoMinor: 0, - TLS: tlsState, - Host: rp.authority, - Body: body, - Trailer: trailer, - } - req = requestWithContext(req, st.ctx) - - rws := responseWriterStatePool.Get().(*responseWriterState) - bwSave := rws.bw - *rws = responseWriterState{} // zero all the fields - rws.conn = sc - rws.bw = bwSave - rws.bw.Reset(chunkWriter{rws}) - rws.stream = st - rws.req = req - rws.body = body - - rw := &responseWriter{rws: rws} - return rw, req, nil -} - -// Run on its own goroutine. -func (sc *serverConn) runHandler(rw *responseWriter, req *http.Request, handler func(http.ResponseWriter, *http.Request)) { - didPanic := true - defer func() { - rw.rws.stream.cancelCtx() - if didPanic { - e := recover() - sc.writeFrameFromHandler(FrameWriteRequest{ - write: handlerPanicRST{rw.rws.stream.id}, - stream: rw.rws.stream, - }) - // Same as net/http: - if shouldLogPanic(e) { - const size = 64 << 10 - buf := make([]byte, size) - buf = buf[:runtime.Stack(buf, false)] - sc.logf("http2: panic serving %v: %v\n%s", sc.conn.RemoteAddr(), e, buf) - } - return - } - rw.handlerDone() - }() - handler(rw, req) - didPanic = false -} - -func handleHeaderListTooLong(w http.ResponseWriter, r *http.Request) { - // 10.5.1 Limits on Header Block Size: - // .. "A server that receives a larger header block than it is - // willing to handle can send an HTTP 431 (Request Header Fields Too - // Large) status code" - const statusRequestHeaderFieldsTooLarge = 431 // only in Go 1.6+ - w.WriteHeader(statusRequestHeaderFieldsTooLarge) - io.WriteString(w, "

    HTTP Error 431

    Request Header Field(s) Too Large

    ") -} - -// called from handler goroutines. -// h may be nil. -func (sc *serverConn) writeHeaders(st *stream, headerData *writeResHeaders) error { - sc.serveG.checkNotOn() // NOT on - var errc chan error - if headerData.h != nil { - // If there's a header map (which we don't own), so we have to block on - // waiting for this frame to be written, so an http.Flush mid-handler - // writes out the correct value of keys, before a handler later potentially - // mutates it. - errc = errChanPool.Get().(chan error) - } - if err := sc.writeFrameFromHandler(FrameWriteRequest{ - write: headerData, - stream: st, - done: errc, - }); err != nil { - return err - } - if errc != nil { - select { - case err := <-errc: - errChanPool.Put(errc) - return err - case <-sc.doneServing: - return errClientDisconnected - case <-st.cw: - return errStreamClosed - } - } - return nil -} - -// called from handler goroutines. -func (sc *serverConn) write100ContinueHeaders(st *stream) { - sc.writeFrameFromHandler(FrameWriteRequest{ - write: write100ContinueHeadersFrame{st.id}, - stream: st, - }) -} - -// A bodyReadMsg tells the server loop that the http.Handler read n -// bytes of the DATA from the client on the given stream. -type bodyReadMsg struct { - st *stream - n int -} - -// called from handler goroutines. -// Notes that the handler for the given stream ID read n bytes of its body -// and schedules flow control tokens to be sent. -func (sc *serverConn) noteBodyReadFromHandler(st *stream, n int, err error) { - sc.serveG.checkNotOn() // NOT on - if n > 0 { - select { - case sc.bodyReadCh <- bodyReadMsg{st, n}: - case <-sc.doneServing: - } - } -} - -func (sc *serverConn) noteBodyRead(st *stream, n int) { - sc.serveG.check() - sc.sendWindowUpdate(nil, n) // conn-level - if st.state != stateHalfClosedRemote && st.state != stateClosed { - // Don't send this WINDOW_UPDATE if the stream is closed - // remotely. - sc.sendWindowUpdate(st, n) - } -} - -// st may be nil for conn-level -func (sc *serverConn) sendWindowUpdate(st *stream, n int) { - sc.serveG.check() - // "The legal range for the increment to the flow control - // window is 1 to 2^31-1 (2,147,483,647) octets." - // A Go Read call on 64-bit machines could in theory read - // a larger Read than this. Very unlikely, but we handle it here - // rather than elsewhere for now. - const maxUint31 = 1<<31 - 1 - for n >= maxUint31 { - sc.sendWindowUpdate32(st, maxUint31) - n -= maxUint31 - } - sc.sendWindowUpdate32(st, int32(n)) -} - -// st may be nil for conn-level -func (sc *serverConn) sendWindowUpdate32(st *stream, n int32) { - sc.serveG.check() - if n == 0 { - return - } - if n < 0 { - panic("negative update") - } - var streamID uint32 - if st != nil { - streamID = st.id - } - sc.writeFrame(FrameWriteRequest{ - write: writeWindowUpdate{streamID: streamID, n: uint32(n)}, - stream: st, - }) - var ok bool - if st == nil { - ok = sc.inflow.add(n) - } else { - ok = st.inflow.add(n) - } - if !ok { - panic("internal error; sent too many window updates without decrements?") - } -} - -// requestBody is the Handler's Request.Body type. -// Read and Close may be called concurrently. -type requestBody struct { - stream *stream - conn *serverConn - closed bool // for use by Close only - sawEOF bool // for use by Read only - pipe *pipe // non-nil if we have a HTTP entity message body - needsContinue bool // need to send a 100-continue -} - -func (b *requestBody) Close() error { - if b.pipe != nil && !b.closed { - b.pipe.BreakWithError(errClosedBody) - } - b.closed = true - return nil -} - -func (b *requestBody) Read(p []byte) (n int, err error) { - if b.needsContinue { - b.needsContinue = false - b.conn.write100ContinueHeaders(b.stream) - } - if b.pipe == nil || b.sawEOF { - return 0, io.EOF - } - n, err = b.pipe.Read(p) - if err == io.EOF { - b.sawEOF = true - } - if b.conn == nil && inTests { - return - } - b.conn.noteBodyReadFromHandler(b.stream, n, err) - return -} - -// responseWriter is the http.ResponseWriter implementation. It's -// intentionally small (1 pointer wide) to minimize garbage. The -// responseWriterState pointer inside is zeroed at the end of a -// request (in handlerDone) and calls on the responseWriter thereafter -// simply crash (caller's mistake), but the much larger responseWriterState -// and buffers are reused between multiple requests. -type responseWriter struct { - rws *responseWriterState -} - -// Optional http.ResponseWriter interfaces implemented. -var ( - _ http.CloseNotifier = (*responseWriter)(nil) - _ http.Flusher = (*responseWriter)(nil) - _ stringWriter = (*responseWriter)(nil) -) - -type responseWriterState struct { - // immutable within a request: - stream *stream - req *http.Request - body *requestBody // to close at end of request, if DATA frames didn't - conn *serverConn - - // TODO: adjust buffer writing sizes based on server config, frame size updates from peer, etc - bw *bufio.Writer // writing to a chunkWriter{this *responseWriterState} - - // mutated by http.Handler goroutine: - handlerHeader http.Header // nil until called - snapHeader http.Header // snapshot of handlerHeader at WriteHeader time - trailers []string // set in writeChunk - status int // status code passed to WriteHeader - wroteHeader bool // WriteHeader called (explicitly or implicitly). Not necessarily sent to user yet. - sentHeader bool // have we sent the header frame? - handlerDone bool // handler has finished - - sentContentLen int64 // non-zero if handler set a Content-Length header - wroteBytes int64 - - closeNotifierMu sync.Mutex // guards closeNotifierCh - closeNotifierCh chan bool // nil until first used -} - -type chunkWriter struct{ rws *responseWriterState } - -func (cw chunkWriter) Write(p []byte) (n int, err error) { return cw.rws.writeChunk(p) } - -func (rws *responseWriterState) hasTrailers() bool { return len(rws.trailers) != 0 } - -// declareTrailer is called for each Trailer header when the -// response header is written. It notes that a header will need to be -// written in the trailers at the end of the response. -func (rws *responseWriterState) declareTrailer(k string) { - k = http.CanonicalHeaderKey(k) - if !ValidTrailerHeader(k) { - // Forbidden by RFC 2616 14.40. - rws.conn.logf("ignoring invalid trailer %q", k) - return - } - if !strSliceContains(rws.trailers, k) { - rws.trailers = append(rws.trailers, k) - } -} - -// writeChunk writes chunks from the bufio.Writer. But because -// bufio.Writer may bypass its chunking, sometimes p may be -// arbitrarily large. -// -// writeChunk is also responsible (on the first chunk) for sending the -// HEADER response. -func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) { - if !rws.wroteHeader { - rws.writeHeader(200) - } - - isHeadResp := rws.req.Method == "HEAD" - if !rws.sentHeader { - rws.sentHeader = true - var ctype, clen string - if clen = rws.snapHeader.Get("Content-Length"); clen != "" { - rws.snapHeader.Del("Content-Length") - clen64, err := strconv.ParseInt(clen, 10, 64) - if err == nil && clen64 >= 0 { - rws.sentContentLen = clen64 - } else { - clen = "" - } - } - if clen == "" && rws.handlerDone && bodyAllowedForStatus(rws.status) && (len(p) > 0 || !isHeadResp) { - clen = strconv.Itoa(len(p)) - } - _, hasContentType := rws.snapHeader["Content-Type"] - if !hasContentType && bodyAllowedForStatus(rws.status) { - ctype = http.DetectContentType(p) - } - var date string - if _, ok := rws.snapHeader["Date"]; !ok { - // TODO(bradfitz): be faster here, like net/http? measure. - date = time.Now().UTC().Format(http.TimeFormat) - } - - for _, v := range rws.snapHeader["Trailer"] { - foreachHeaderElement(v, rws.declareTrailer) - } - - endStream := (rws.handlerDone && !rws.hasTrailers() && len(p) == 0) || isHeadResp - err = rws.conn.writeHeaders(rws.stream, &writeResHeaders{ - streamID: rws.stream.id, - httpResCode: rws.status, - h: rws.snapHeader, - endStream: endStream, - contentType: ctype, - contentLength: clen, - date: date, - }) - if err != nil { - return 0, err - } - if endStream { - return 0, nil - } - } - if isHeadResp { - return len(p), nil - } - if len(p) == 0 && !rws.handlerDone { - return 0, nil - } - - if rws.handlerDone { - rws.promoteUndeclaredTrailers() - } - - endStream := rws.handlerDone && !rws.hasTrailers() - if len(p) > 0 || endStream { - // only send a 0 byte DATA frame if we're ending the stream. - if err := rws.conn.writeDataFromHandler(rws.stream, p, endStream); err != nil { - return 0, err - } - } - - if rws.handlerDone && rws.hasTrailers() { - err = rws.conn.writeHeaders(rws.stream, &writeResHeaders{ - streamID: rws.stream.id, - h: rws.handlerHeader, - trailers: rws.trailers, - endStream: true, - }) - return len(p), err - } - return len(p), nil -} - -// TrailerPrefix is a magic prefix for ResponseWriter.Header map keys -// that, if present, signals that the map entry is actually for -// the response trailers, and not the response headers. The prefix -// is stripped after the ServeHTTP call finishes and the values are -// sent in the trailers. -// -// This mechanism is intended only for trailers that are not known -// prior to the headers being written. If the set of trailers is fixed -// or known before the header is written, the normal Go trailers mechanism -// is preferred: -// https://golang.org/pkg/net/http/#ResponseWriter -// https://golang.org/pkg/net/http/#example_ResponseWriter_trailers -const TrailerPrefix = "Trailer:" - -// promoteUndeclaredTrailers permits http.Handlers to set trailers -// after the header has already been flushed. Because the Go -// ResponseWriter interface has no way to set Trailers (only the -// Header), and because we didn't want to expand the ResponseWriter -// interface, and because nobody used trailers, and because RFC 2616 -// says you SHOULD (but not must) predeclare any trailers in the -// header, the official ResponseWriter rules said trailers in Go must -// be predeclared, and then we reuse the same ResponseWriter.Header() -// map to mean both Headers and Trailers. When it's time to write the -// Trailers, we pick out the fields of Headers that were declared as -// trailers. That worked for a while, until we found the first major -// user of Trailers in the wild: gRPC (using them only over http2), -// and gRPC libraries permit setting trailers mid-stream without -// predeclarnig them. So: change of plans. We still permit the old -// way, but we also permit this hack: if a Header() key begins with -// "Trailer:", the suffix of that key is a Trailer. Because ':' is an -// invalid token byte anyway, there is no ambiguity. (And it's already -// filtered out) It's mildly hacky, but not terrible. -// -// This method runs after the Handler is done and promotes any Header -// fields to be trailers. -func (rws *responseWriterState) promoteUndeclaredTrailers() { - for k, vv := range rws.handlerHeader { - if !strings.HasPrefix(k, TrailerPrefix) { - continue - } - trailerKey := strings.TrimPrefix(k, TrailerPrefix) - rws.declareTrailer(trailerKey) - rws.handlerHeader[http.CanonicalHeaderKey(trailerKey)] = vv - } - - if len(rws.trailers) > 1 { - sorter := sorterPool.Get().(*sorter) - sorter.SortStrings(rws.trailers) - sorterPool.Put(sorter) - } -} - -func (w *responseWriter) Flush() { - rws := w.rws - if rws == nil { - panic("Header called after Handler finished") - } - if rws.bw.Buffered() > 0 { - if err := rws.bw.Flush(); err != nil { - // Ignore the error. The frame writer already knows. - return - } - } else { - // The bufio.Writer won't call chunkWriter.Write - // (writeChunk with zero bytes, so we have to do it - // ourselves to force the HTTP response header and/or - // final DATA frame (with END_STREAM) to be sent. - rws.writeChunk(nil) - } -} - -func (w *responseWriter) CloseNotify() <-chan bool { - rws := w.rws - if rws == nil { - panic("CloseNotify called after Handler finished") - } - rws.closeNotifierMu.Lock() - ch := rws.closeNotifierCh - if ch == nil { - ch = make(chan bool, 1) - rws.closeNotifierCh = ch - cw := rws.stream.cw - go func() { - cw.Wait() // wait for close - ch <- true - }() - } - rws.closeNotifierMu.Unlock() - return ch -} - -func (w *responseWriter) Header() http.Header { - rws := w.rws - if rws == nil { - panic("Header called after Handler finished") - } - if rws.handlerHeader == nil { - rws.handlerHeader = make(http.Header) - } - return rws.handlerHeader -} - -func (w *responseWriter) WriteHeader(code int) { - rws := w.rws - if rws == nil { - panic("WriteHeader called after Handler finished") - } - rws.writeHeader(code) -} - -func (rws *responseWriterState) writeHeader(code int) { - if !rws.wroteHeader { - rws.wroteHeader = true - rws.status = code - if len(rws.handlerHeader) > 0 { - rws.snapHeader = cloneHeader(rws.handlerHeader) - } - } -} - -func cloneHeader(h http.Header) http.Header { - h2 := make(http.Header, len(h)) - for k, vv := range h { - vv2 := make([]string, len(vv)) - copy(vv2, vv) - h2[k] = vv2 - } - return h2 -} - -// The Life Of A Write is like this: -// -// * Handler calls w.Write or w.WriteString -> -// * -> rws.bw (*bufio.Writer) -> -// * (Handler migth call Flush) -// * -> chunkWriter{rws} -// * -> responseWriterState.writeChunk(p []byte) -// * -> responseWriterState.writeChunk (most of the magic; see comment there) -func (w *responseWriter) Write(p []byte) (n int, err error) { - return w.write(len(p), p, "") -} - -func (w *responseWriter) WriteString(s string) (n int, err error) { - return w.write(len(s), nil, s) -} - -// either dataB or dataS is non-zero. -func (w *responseWriter) write(lenData int, dataB []byte, dataS string) (n int, err error) { - rws := w.rws - if rws == nil { - panic("Write called after Handler finished") - } - if !rws.wroteHeader { - w.WriteHeader(200) - } - if !bodyAllowedForStatus(rws.status) { - return 0, http.ErrBodyNotAllowed - } - rws.wroteBytes += int64(len(dataB)) + int64(len(dataS)) // only one can be set - if rws.sentContentLen != 0 && rws.wroteBytes > rws.sentContentLen { - // TODO: send a RST_STREAM - return 0, errors.New("http2: handler wrote more than declared Content-Length") - } - - if dataB != nil { - return rws.bw.Write(dataB) - } else { - return rws.bw.WriteString(dataS) - } -} - -func (w *responseWriter) handlerDone() { - rws := w.rws - rws.handlerDone = true - w.Flush() - w.rws = nil - responseWriterStatePool.Put(rws) -} - -// Push errors. -var ( - ErrRecursivePush = errors.New("http2: recursive push not allowed") - ErrPushLimitReached = errors.New("http2: push would exceed peer's SETTINGS_MAX_CONCURRENT_STREAMS") -) - -// pushOptions is the internal version of http.PushOptions, which we -// cannot include here because it's only defined in Go 1.8 and later. -type pushOptions struct { - Method string - Header http.Header -} - -func (w *responseWriter) push(target string, opts pushOptions) error { - st := w.rws.stream - sc := st.sc - sc.serveG.checkNotOn() - - // No recursive pushes: "PUSH_PROMISE frames MUST only be sent on a peer-initiated stream." - // http://tools.ietf.org/html/rfc7540#section-6.6 - if st.isPushed() { - return ErrRecursivePush - } - - // Default options. - if opts.Method == "" { - opts.Method = "GET" - } - if opts.Header == nil { - opts.Header = http.Header{} - } - wantScheme := "http" - if w.rws.req.TLS != nil { - wantScheme = "https" - } - - // Validate the request. - u, err := url.Parse(target) - if err != nil { - return err - } - if u.Scheme == "" { - if !strings.HasPrefix(target, "/") { - return fmt.Errorf("target must be an absolute URL or an absolute path: %q", target) - } - u.Scheme = wantScheme - u.Host = w.rws.req.Host - } else { - if u.Scheme != wantScheme { - return fmt.Errorf("cannot push URL with scheme %q from request with scheme %q", u.Scheme, wantScheme) - } - if u.Host == "" { - return errors.New("URL must have a host") - } - } - for k := range opts.Header { - if strings.HasPrefix(k, ":") { - return fmt.Errorf("promised request headers cannot include pseudo header %q", k) - } - // These headers are meaningful only if the request has a body, - // but PUSH_PROMISE requests cannot have a body. - // http://tools.ietf.org/html/rfc7540#section-8.2 - // Also disallow Host, since the promised URL must be absolute. - switch strings.ToLower(k) { - case "content-length", "content-encoding", "trailer", "te", "expect", "host": - return fmt.Errorf("promised request headers cannot include %q", k) - } - } - if err := checkValidHTTP2RequestHeaders(opts.Header); err != nil { - return err - } - - // The RFC effectively limits promised requests to GET and HEAD: - // "Promised requests MUST be cacheable [GET, HEAD, or POST], and MUST be safe [GET or HEAD]" - // http://tools.ietf.org/html/rfc7540#section-8.2 - if opts.Method != "GET" && opts.Method != "HEAD" { - return fmt.Errorf("method %q must be GET or HEAD", opts.Method) - } - - msg := startPushRequest{ - parent: st, - method: opts.Method, - url: u, - header: cloneHeader(opts.Header), - done: errChanPool.Get().(chan error), - } - - select { - case <-sc.doneServing: - return errClientDisconnected - case <-st.cw: - return errStreamClosed - case sc.wantStartPushCh <- msg: - } - - select { - case <-sc.doneServing: - return errClientDisconnected - case <-st.cw: - return errStreamClosed - case err := <-msg.done: - errChanPool.Put(msg.done) - return err - } -} - -type startPushRequest struct { - parent *stream - method string - url *url.URL - header http.Header - done chan error -} - -func (sc *serverConn) startPush(msg startPushRequest) { - sc.serveG.check() - - // http://tools.ietf.org/html/rfc7540#section-6.6. - // PUSH_PROMISE frames MUST only be sent on a peer-initiated stream that - // is in either the "open" or "half-closed (remote)" state. - if msg.parent.state != stateOpen && msg.parent.state != stateHalfClosedRemote { - // responseWriter.Push checks that the stream is peer-initiaed. - msg.done <- errStreamClosed - return - } - - // http://tools.ietf.org/html/rfc7540#section-6.6. - if !sc.pushEnabled { - msg.done <- http.ErrNotSupported - return - } - - // PUSH_PROMISE frames must be sent in increasing order by stream ID, so - // we allocate an ID for the promised stream lazily, when the PUSH_PROMISE - // is written. Once the ID is allocated, we start the request handler. - allocatePromisedID := func() (uint32, error) { - sc.serveG.check() - - // Check this again, just in case. Technically, we might have received - // an updated SETTINGS by the time we got around to writing this frame. - if !sc.pushEnabled { - return 0, http.ErrNotSupported - } - // http://tools.ietf.org/html/rfc7540#section-6.5.2. - if sc.curPushedStreams+1 > sc.clientMaxStreams { - return 0, ErrPushLimitReached - } - - // http://tools.ietf.org/html/rfc7540#section-5.1.1. - // Streams initiated by the server MUST use even-numbered identifiers. - // A server that is unable to establish a new stream identifier can send a GOAWAY - // frame so that the client is forced to open a new connection for new streams. - if sc.maxPushPromiseID+2 >= 1<<31 { - sc.startGracefulShutdown() - return 0, ErrPushLimitReached - } - sc.maxPushPromiseID += 2 - promisedID := sc.maxPushPromiseID - - // http://tools.ietf.org/html/rfc7540#section-8.2. - // Strictly speaking, the new stream should start in "reserved (local)", then - // transition to "half closed (remote)" after sending the initial HEADERS, but - // we start in "half closed (remote)" for simplicity. - // See further comments at the definition of stateHalfClosedRemote. - promised := sc.newStream(promisedID, msg.parent.id, stateHalfClosedRemote) - rw, req, err := sc.newWriterAndRequestNoBody(promised, requestParam{ - method: msg.method, - scheme: msg.url.Scheme, - authority: msg.url.Host, - path: msg.url.RequestURI(), - header: cloneHeader(msg.header), // clone since handler runs concurrently with writing the PUSH_PROMISE - }) - if err != nil { - // Should not happen, since we've already validated msg.url. - panic(fmt.Sprintf("newWriterAndRequestNoBody(%+v): %v", msg.url, err)) - } - - go sc.runHandler(rw, req, sc.handler.ServeHTTP) - return promisedID, nil - } - - sc.writeFrame(FrameWriteRequest{ - write: &writePushPromise{ - streamID: msg.parent.id, - method: msg.method, - url: msg.url, - h: msg.header, - allocatePromisedID: allocatePromisedID, - }, - stream: msg.parent, - done: msg.done, - }) -} - -// foreachHeaderElement splits v according to the "#rule" construction -// in RFC 2616 section 2.1 and calls fn for each non-empty element. -func foreachHeaderElement(v string, fn func(string)) { - v = textproto.TrimString(v) - if v == "" { - return - } - if !strings.Contains(v, ",") { - fn(v) - return - } - for _, f := range strings.Split(v, ",") { - if f = textproto.TrimString(f); f != "" { - fn(f) - } - } -} - -// From http://httpwg.org/specs/rfc7540.html#rfc.section.8.1.2.2 -var connHeaders = []string{ - "Connection", - "Keep-Alive", - "Proxy-Connection", - "Transfer-Encoding", - "Upgrade", -} - -// checkValidHTTP2RequestHeaders checks whether h is a valid HTTP/2 request, -// per RFC 7540 Section 8.1.2.2. -// The returned error is reported to users. -func checkValidHTTP2RequestHeaders(h http.Header) error { - for _, k := range connHeaders { - if _, ok := h[k]; ok { - return fmt.Errorf("request header %q is not valid in HTTP/2", k) - } - } - te := h["Te"] - if len(te) > 0 && (len(te) > 1 || (te[0] != "trailers" && te[0] != "")) { - return errors.New(`request header "TE" may only be "trailers" in HTTP/2`) - } - return nil -} - -func new400Handler(err error) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - http.Error(w, err.Error(), http.StatusBadRequest) - } -} - -// ValidTrailerHeader reports whether name is a valid header field name to appear -// in trailers. -// See: http://tools.ietf.org/html/rfc7230#section-4.1.2 -func ValidTrailerHeader(name string) bool { - name = http.CanonicalHeaderKey(name) - if strings.HasPrefix(name, "If-") || badTrailer[name] { - return false - } - return true -} - -var badTrailer = map[string]bool{ - "Authorization": true, - "Cache-Control": true, - "Connection": true, - "Content-Encoding": true, - "Content-Length": true, - "Content-Range": true, - "Content-Type": true, - "Expect": true, - "Host": true, - "Keep-Alive": true, - "Max-Forwards": true, - "Pragma": true, - "Proxy-Authenticate": true, - "Proxy-Authorization": true, - "Proxy-Connection": true, - "Range": true, - "Realm": true, - "Te": true, - "Trailer": true, - "Transfer-Encoding": true, - "Www-Authenticate": true, -} - -// h1ServerShutdownChan returns a channel that will be closed when the -// provided *http.Server wants to shut down. -// -// This is a somewhat hacky way to get at http1 innards. It works -// when the http2 code is bundled into the net/http package in the -// standard library. The alternatives ended up making the cmd/go tool -// depend on http Servers. This is the lightest option for now. -// This is tested via the TestServeShutdown* tests in net/http. -func h1ServerShutdownChan(hs *http.Server) <-chan struct{} { - if fn := testh1ServerShutdownChan; fn != nil { - return fn(hs) - } - var x interface{} = hs - type I interface { - getDoneChan() <-chan struct{} - } - if hs, ok := x.(I); ok { - return hs.getDoneChan() - } - return nil -} - -// optional test hook for h1ServerShutdownChan. -var testh1ServerShutdownChan func(hs *http.Server) <-chan struct{} - -// h1ServerKeepAlivesDisabled reports whether hs has its keep-alives -// disabled. See comments on h1ServerShutdownChan above for why -// the code is written this way. -func h1ServerKeepAlivesDisabled(hs *http.Server) bool { - var x interface{} = hs - type I interface { - doKeepAlives() bool - } - if hs, ok := x.(I); ok { - return !hs.doKeepAlives() - } - return false -} diff --git a/vendor/golang.org/x/net/http2/server_push_test.go b/vendor/golang.org/x/net/http2/server_push_test.go deleted file mode 100644 index f70edd3c7..000000000 --- a/vendor/golang.org/x/net/http2/server_push_test.go +++ /dev/null @@ -1,521 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.8 - -package http2 - -import ( - "errors" - "fmt" - "io" - "io/ioutil" - "net/http" - "reflect" - "strconv" - "sync" - "testing" - "time" -) - -func TestServer_Push_Success(t *testing.T) { - const ( - mainBody = "index page" - pushedBody = "pushed page" - userAgent = "testagent" - cookie = "testcookie" - ) - - var stURL string - checkPromisedReq := func(r *http.Request, wantMethod string, wantH http.Header) error { - if got, want := r.Method, wantMethod; got != want { - return fmt.Errorf("promised Req.Method=%q, want %q", got, want) - } - if got, want := r.Header, wantH; !reflect.DeepEqual(got, want) { - return fmt.Errorf("promised Req.Header=%q, want %q", got, want) - } - if got, want := "https://"+r.Host, stURL; got != want { - return fmt.Errorf("promised Req.Host=%q, want %q", got, want) - } - if r.Body == nil { - return fmt.Errorf("nil Body") - } - if buf, err := ioutil.ReadAll(r.Body); err != nil || len(buf) != 0 { - return fmt.Errorf("ReadAll(Body)=%q,%v, want '',nil", buf, err) - } - return nil - } - - errc := make(chan error, 3) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - switch r.URL.RequestURI() { - case "/": - // Push "/pushed?get" as a GET request, using an absolute URL. - opt := &http.PushOptions{ - Header: http.Header{ - "User-Agent": {userAgent}, - }, - } - if err := w.(http.Pusher).Push(stURL+"/pushed?get", opt); err != nil { - errc <- fmt.Errorf("error pushing /pushed?get: %v", err) - return - } - // Push "/pushed?head" as a HEAD request, using a path. - opt = &http.PushOptions{ - Method: "HEAD", - Header: http.Header{ - "User-Agent": {userAgent}, - "Cookie": {cookie}, - }, - } - if err := w.(http.Pusher).Push("/pushed?head", opt); err != nil { - errc <- fmt.Errorf("error pushing /pushed?head: %v", err) - return - } - w.Header().Set("Content-Type", "text/html") - w.Header().Set("Content-Length", strconv.Itoa(len(mainBody))) - w.WriteHeader(200) - io.WriteString(w, mainBody) - errc <- nil - - case "/pushed?get": - wantH := http.Header{} - wantH.Set("User-Agent", userAgent) - if err := checkPromisedReq(r, "GET", wantH); err != nil { - errc <- fmt.Errorf("/pushed?get: %v", err) - return - } - w.Header().Set("Content-Type", "text/html") - w.Header().Set("Content-Length", strconv.Itoa(len(pushedBody))) - w.WriteHeader(200) - io.WriteString(w, pushedBody) - errc <- nil - - case "/pushed?head": - wantH := http.Header{} - wantH.Set("User-Agent", userAgent) - wantH.Set("Cookie", cookie) - if err := checkPromisedReq(r, "HEAD", wantH); err != nil { - errc <- fmt.Errorf("/pushed?head: %v", err) - return - } - w.WriteHeader(204) - errc <- nil - - default: - errc <- fmt.Errorf("unknown RequestURL %q", r.URL.RequestURI()) - } - }) - stURL = st.ts.URL - - // Send one request, which should push two responses. - st.greet() - getSlash(st) - for k := 0; k < 3; k++ { - select { - case <-time.After(2 * time.Second): - t.Errorf("timeout waiting for handler %d to finish", k) - case err := <-errc: - if err != nil { - t.Fatal(err) - } - } - } - - checkPushPromise := func(f Frame, promiseID uint32, wantH [][2]string) error { - pp, ok := f.(*PushPromiseFrame) - if !ok { - return fmt.Errorf("got a %T; want *PushPromiseFrame", f) - } - if !pp.HeadersEnded() { - return fmt.Errorf("want END_HEADERS flag in PushPromiseFrame") - } - if got, want := pp.PromiseID, promiseID; got != want { - return fmt.Errorf("got PromiseID %v; want %v", got, want) - } - gotH := st.decodeHeader(pp.HeaderBlockFragment()) - if !reflect.DeepEqual(gotH, wantH) { - return fmt.Errorf("got promised headers %v; want %v", gotH, wantH) - } - return nil - } - checkHeaders := func(f Frame, wantH [][2]string) error { - hf, ok := f.(*HeadersFrame) - if !ok { - return fmt.Errorf("got a %T; want *HeadersFrame", f) - } - gotH := st.decodeHeader(hf.HeaderBlockFragment()) - if !reflect.DeepEqual(gotH, wantH) { - return fmt.Errorf("got response headers %v; want %v", gotH, wantH) - } - return nil - } - checkData := func(f Frame, wantData string) error { - df, ok := f.(*DataFrame) - if !ok { - return fmt.Errorf("got a %T; want *DataFrame", f) - } - if gotData := string(df.Data()); gotData != wantData { - return fmt.Errorf("got response data %q; want %q", gotData, wantData) - } - return nil - } - - // Stream 1 has 2 PUSH_PROMISE + HEADERS + DATA - // Stream 2 has HEADERS + DATA - // Stream 4 has HEADERS - expected := map[uint32][]func(Frame) error{ - 1: { - func(f Frame) error { - return checkPushPromise(f, 2, [][2]string{ - {":method", "GET"}, - {":scheme", "https"}, - {":authority", st.ts.Listener.Addr().String()}, - {":path", "/pushed?get"}, - {"user-agent", userAgent}, - }) - }, - func(f Frame) error { - return checkPushPromise(f, 4, [][2]string{ - {":method", "HEAD"}, - {":scheme", "https"}, - {":authority", st.ts.Listener.Addr().String()}, - {":path", "/pushed?head"}, - {"cookie", cookie}, - {"user-agent", userAgent}, - }) - }, - func(f Frame) error { - return checkHeaders(f, [][2]string{ - {":status", "200"}, - {"content-type", "text/html"}, - {"content-length", strconv.Itoa(len(mainBody))}, - }) - }, - func(f Frame) error { - return checkData(f, mainBody) - }, - }, - 2: { - func(f Frame) error { - return checkHeaders(f, [][2]string{ - {":status", "200"}, - {"content-type", "text/html"}, - {"content-length", strconv.Itoa(len(pushedBody))}, - }) - }, - func(f Frame) error { - return checkData(f, pushedBody) - }, - }, - 4: { - func(f Frame) error { - return checkHeaders(f, [][2]string{ - {":status", "204"}, - }) - }, - }, - } - - consumed := map[uint32]int{} - for k := 0; len(expected) > 0; k++ { - f, err := st.readFrame() - if err != nil { - for id, left := range expected { - t.Errorf("stream %d: missing %d frames", id, len(left)) - } - t.Fatalf("readFrame %d: %v", k, err) - } - id := f.Header().StreamID - label := fmt.Sprintf("stream %d, frame %d", id, consumed[id]) - if len(expected[id]) == 0 { - t.Fatalf("%s: unexpected frame %#+v", label, f) - } - check := expected[id][0] - expected[id] = expected[id][1:] - if len(expected[id]) == 0 { - delete(expected, id) - } - if err := check(f); err != nil { - t.Fatalf("%s: %v", label, err) - } - consumed[id]++ - } -} - -func TestServer_Push_SuccessNoRace(t *testing.T) { - // Regression test for issue #18326. Ensure the request handler can mutate - // pushed request headers without racing with the PUSH_PROMISE write. - errc := make(chan error, 2) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - switch r.URL.RequestURI() { - case "/": - opt := &http.PushOptions{ - Header: http.Header{"User-Agent": {"testagent"}}, - } - if err := w.(http.Pusher).Push("/pushed", opt); err != nil { - errc <- fmt.Errorf("error pushing: %v", err) - return - } - w.WriteHeader(200) - errc <- nil - - case "/pushed": - // Update request header, ensure there is no race. - r.Header.Set("User-Agent", "newagent") - r.Header.Set("Cookie", "cookie") - w.WriteHeader(200) - errc <- nil - - default: - errc <- fmt.Errorf("unknown RequestURL %q", r.URL.RequestURI()) - } - }) - - // Send one request, which should push one response. - st.greet() - getSlash(st) - for k := 0; k < 2; k++ { - select { - case <-time.After(2 * time.Second): - t.Errorf("timeout waiting for handler %d to finish", k) - case err := <-errc: - if err != nil { - t.Fatal(err) - } - } - } -} - -func TestServer_Push_RejectRecursivePush(t *testing.T) { - // Expect two requests, but might get three if there's a bug and the second push succeeds. - errc := make(chan error, 3) - handler := func(w http.ResponseWriter, r *http.Request) error { - baseURL := "https://" + r.Host - switch r.URL.Path { - case "/": - if err := w.(http.Pusher).Push(baseURL+"/push1", nil); err != nil { - return fmt.Errorf("first Push()=%v, want nil", err) - } - return nil - - case "/push1": - if got, want := w.(http.Pusher).Push(baseURL+"/push2", nil), ErrRecursivePush; got != want { - return fmt.Errorf("Push()=%v, want %v", got, want) - } - return nil - - default: - return fmt.Errorf("unexpected path: %q", r.URL.Path) - } - } - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - errc <- handler(w, r) - }) - defer st.Close() - st.greet() - getSlash(st) - if err := <-errc; err != nil { - t.Errorf("First request failed: %v", err) - } - if err := <-errc; err != nil { - t.Errorf("Second request failed: %v", err) - } -} - -func testServer_Push_RejectSingleRequest(t *testing.T, doPush func(http.Pusher, *http.Request) error, settings ...Setting) { - // Expect one request, but might get two if there's a bug and the push succeeds. - errc := make(chan error, 2) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - errc <- doPush(w.(http.Pusher), r) - }) - defer st.Close() - st.greet() - if err := st.fr.WriteSettings(settings...); err != nil { - st.t.Fatalf("WriteSettings: %v", err) - } - st.wantSettingsAck() - getSlash(st) - if err := <-errc; err != nil { - t.Error(err) - } - // Should not get a PUSH_PROMISE frame. - hf := st.wantHeaders() - if !hf.StreamEnded() { - t.Error("stream should end after headers") - } -} - -func TestServer_Push_RejectIfDisabled(t *testing.T) { - testServer_Push_RejectSingleRequest(t, - func(p http.Pusher, r *http.Request) error { - if got, want := p.Push("https://"+r.Host+"/pushed", nil), http.ErrNotSupported; got != want { - return fmt.Errorf("Push()=%v, want %v", got, want) - } - return nil - }, - Setting{SettingEnablePush, 0}) -} - -func TestServer_Push_RejectWhenNoConcurrentStreams(t *testing.T) { - testServer_Push_RejectSingleRequest(t, - func(p http.Pusher, r *http.Request) error { - if got, want := p.Push("https://"+r.Host+"/pushed", nil), ErrPushLimitReached; got != want { - return fmt.Errorf("Push()=%v, want %v", got, want) - } - return nil - }, - Setting{SettingMaxConcurrentStreams, 0}) -} - -func TestServer_Push_RejectWrongScheme(t *testing.T) { - testServer_Push_RejectSingleRequest(t, - func(p http.Pusher, r *http.Request) error { - if err := p.Push("http://"+r.Host+"/pushed", nil); err == nil { - return errors.New("Push() should have failed (push target URL is http)") - } - return nil - }) -} - -func TestServer_Push_RejectMissingHost(t *testing.T) { - testServer_Push_RejectSingleRequest(t, - func(p http.Pusher, r *http.Request) error { - if err := p.Push("https:pushed", nil); err == nil { - return errors.New("Push() should have failed (push target URL missing host)") - } - return nil - }) -} - -func TestServer_Push_RejectRelativePath(t *testing.T) { - testServer_Push_RejectSingleRequest(t, - func(p http.Pusher, r *http.Request) error { - if err := p.Push("../test", nil); err == nil { - return errors.New("Push() should have failed (push target is a relative path)") - } - return nil - }) -} - -func TestServer_Push_RejectForbiddenMethod(t *testing.T) { - testServer_Push_RejectSingleRequest(t, - func(p http.Pusher, r *http.Request) error { - if err := p.Push("https://"+r.Host+"/pushed", &http.PushOptions{Method: "POST"}); err == nil { - return errors.New("Push() should have failed (cannot promise a POST)") - } - return nil - }) -} - -func TestServer_Push_RejectForbiddenHeader(t *testing.T) { - testServer_Push_RejectSingleRequest(t, - func(p http.Pusher, r *http.Request) error { - header := http.Header{ - "Content-Length": {"10"}, - "Content-Encoding": {"gzip"}, - "Trailer": {"Foo"}, - "Te": {"trailers"}, - "Host": {"test.com"}, - ":authority": {"test.com"}, - } - if err := p.Push("https://"+r.Host+"/pushed", &http.PushOptions{Header: header}); err == nil { - return errors.New("Push() should have failed (forbidden headers)") - } - return nil - }) -} - -func TestServer_Push_StateTransitions(t *testing.T) { - const body = "foo" - - gotPromise := make(chan bool) - finishedPush := make(chan bool) - - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - switch r.URL.RequestURI() { - case "/": - if err := w.(http.Pusher).Push("/pushed", nil); err != nil { - t.Errorf("Push error: %v", err) - } - // Don't finish this request until the push finishes so we don't - // nondeterministically interleave output frames with the push. - <-finishedPush - case "/pushed": - <-gotPromise - } - w.Header().Set("Content-Type", "text/html") - w.Header().Set("Content-Length", strconv.Itoa(len(body))) - w.WriteHeader(200) - io.WriteString(w, body) - }) - defer st.Close() - - st.greet() - if st.stream(2) != nil { - t.Fatal("stream 2 should be empty") - } - if got, want := st.streamState(2), stateIdle; got != want { - t.Fatalf("streamState(2)=%v, want %v", got, want) - } - getSlash(st) - // After the PUSH_PROMISE is sent, the stream should be stateHalfClosedRemote. - st.wantPushPromise() - if got, want := st.streamState(2), stateHalfClosedRemote; got != want { - t.Fatalf("streamState(2)=%v, want %v", got, want) - } - // We stall the HTTP handler for "/pushed" until the above check. If we don't - // stall the handler, then the handler might write HEADERS and DATA and finish - // the stream before we check st.streamState(2) -- should that happen, we'll - // see stateClosed and fail the above check. - close(gotPromise) - st.wantHeaders() - if df := st.wantData(); !df.StreamEnded() { - t.Fatal("expected END_STREAM flag on DATA") - } - if got, want := st.streamState(2), stateClosed; got != want { - t.Fatalf("streamState(2)=%v, want %v", got, want) - } - close(finishedPush) -} - -func TestServer_Push_RejectAfterGoAway(t *testing.T) { - var readyOnce sync.Once - ready := make(chan struct{}) - errc := make(chan error, 2) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - select { - case <-ready: - case <-time.After(5 * time.Second): - errc <- fmt.Errorf("timeout waiting for GOAWAY to be processed") - } - if got, want := w.(http.Pusher).Push("https://"+r.Host+"/pushed", nil), http.ErrNotSupported; got != want { - errc <- fmt.Errorf("Push()=%v, want %v", got, want) - } - errc <- nil - }) - defer st.Close() - st.greet() - getSlash(st) - - // Send GOAWAY and wait for it to be processed. - st.fr.WriteGoAway(1, ErrCodeNo, nil) - go func() { - for { - select { - case <-ready: - return - default: - } - st.sc.testHookCh <- func(loopNum int) { - if !st.sc.pushEnabled { - readyOnce.Do(func() { close(ready) }) - } - } - } - }() - if err := <-errc; err != nil { - t.Error(err) - } -} diff --git a/vendor/golang.org/x/net/http2/server_test.go b/vendor/golang.org/x/net/http2/server_test.go deleted file mode 100644 index 591a0c2e6..000000000 --- a/vendor/golang.org/x/net/http2/server_test.go +++ /dev/null @@ -1,3731 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "bytes" - "crypto/tls" - "errors" - "flag" - "fmt" - "io" - "io/ioutil" - "log" - "net" - "net/http" - "net/http/httptest" - "os" - "os/exec" - "reflect" - "runtime" - "strconv" - "strings" - "sync" - "sync/atomic" - "testing" - "time" - - "golang.org/x/net/http2/hpack" -) - -var stderrVerbose = flag.Bool("stderr_verbose", false, "Mirror verbosity to stderr, unbuffered") - -func stderrv() io.Writer { - if *stderrVerbose { - return os.Stderr - } - - return ioutil.Discard -} - -type serverTester struct { - cc net.Conn // client conn - t testing.TB - ts *httptest.Server - fr *Framer - serverLogBuf bytes.Buffer // logger for httptest.Server - logFilter []string // substrings to filter out - scMu sync.Mutex // guards sc - sc *serverConn - hpackDec *hpack.Decoder - decodedHeaders [][2]string - - // If http2debug!=2, then we capture Frame debug logs that will be written - // to t.Log after a test fails. The read and write logs use separate locks - // and buffers so we don't accidentally introduce synchronization between - // the read and write goroutines, which may hide data races. - frameReadLogMu sync.Mutex - frameReadLogBuf bytes.Buffer - frameWriteLogMu sync.Mutex - frameWriteLogBuf bytes.Buffer - - // writing headers: - headerBuf bytes.Buffer - hpackEnc *hpack.Encoder -} - -func init() { - testHookOnPanicMu = new(sync.Mutex) -} - -func resetHooks() { - testHookOnPanicMu.Lock() - testHookOnPanic = nil - testHookOnPanicMu.Unlock() -} - -type serverTesterOpt string - -var optOnlyServer = serverTesterOpt("only_server") -var optQuiet = serverTesterOpt("quiet_logging") -var optFramerReuseFrames = serverTesterOpt("frame_reuse_frames") - -func newServerTester(t testing.TB, handler http.HandlerFunc, opts ...interface{}) *serverTester { - resetHooks() - - ts := httptest.NewUnstartedServer(handler) - - tlsConfig := &tls.Config{ - InsecureSkipVerify: true, - NextProtos: []string{NextProtoTLS}, - } - - var onlyServer, quiet, framerReuseFrames bool - h2server := new(Server) - for _, opt := range opts { - switch v := opt.(type) { - case func(*tls.Config): - v(tlsConfig) - case func(*httptest.Server): - v(ts) - case func(*Server): - v(h2server) - case serverTesterOpt: - switch v { - case optOnlyServer: - onlyServer = true - case optQuiet: - quiet = true - case optFramerReuseFrames: - framerReuseFrames = true - } - case func(net.Conn, http.ConnState): - ts.Config.ConnState = v - default: - t.Fatalf("unknown newServerTester option type %T", v) - } - } - - ConfigureServer(ts.Config, h2server) - - st := &serverTester{ - t: t, - ts: ts, - } - st.hpackEnc = hpack.NewEncoder(&st.headerBuf) - st.hpackDec = hpack.NewDecoder(initialHeaderTableSize, st.onHeaderField) - - ts.TLS = ts.Config.TLSConfig // the httptest.Server has its own copy of this TLS config - if quiet { - ts.Config.ErrorLog = log.New(ioutil.Discard, "", 0) - } else { - ts.Config.ErrorLog = log.New(io.MultiWriter(stderrv(), twriter{t: t, st: st}, &st.serverLogBuf), "", log.LstdFlags) - } - ts.StartTLS() - - if VerboseLogs { - t.Logf("Running test server at: %s", ts.URL) - } - testHookGetServerConn = func(v *serverConn) { - st.scMu.Lock() - defer st.scMu.Unlock() - st.sc = v - st.sc.testHookCh = make(chan func(int)) - } - log.SetOutput(io.MultiWriter(stderrv(), twriter{t: t, st: st})) - if !onlyServer { - cc, err := tls.Dial("tcp", ts.Listener.Addr().String(), tlsConfig) - if err != nil { - t.Fatal(err) - } - st.cc = cc - st.fr = NewFramer(cc, cc) - if framerReuseFrames { - st.fr.SetReuseFrames() - } - if !logFrameReads && !logFrameWrites { - st.fr.debugReadLoggerf = func(m string, v ...interface{}) { - m = time.Now().Format("2006-01-02 15:04:05.999999999 ") + strings.TrimPrefix(m, "http2: ") + "\n" - st.frameReadLogMu.Lock() - fmt.Fprintf(&st.frameReadLogBuf, m, v...) - st.frameReadLogMu.Unlock() - } - st.fr.debugWriteLoggerf = func(m string, v ...interface{}) { - m = time.Now().Format("2006-01-02 15:04:05.999999999 ") + strings.TrimPrefix(m, "http2: ") + "\n" - st.frameWriteLogMu.Lock() - fmt.Fprintf(&st.frameWriteLogBuf, m, v...) - st.frameWriteLogMu.Unlock() - } - st.fr.logReads = true - st.fr.logWrites = true - } - } - return st -} - -func (st *serverTester) closeConn() { - st.scMu.Lock() - defer st.scMu.Unlock() - st.sc.conn.Close() -} - -func (st *serverTester) addLogFilter(phrase string) { - st.logFilter = append(st.logFilter, phrase) -} - -func (st *serverTester) stream(id uint32) *stream { - ch := make(chan *stream, 1) - st.sc.testHookCh <- func(int) { - ch <- st.sc.streams[id] - } - return <-ch -} - -func (st *serverTester) streamState(id uint32) streamState { - ch := make(chan streamState, 1) - st.sc.testHookCh <- func(int) { - state, _ := st.sc.state(id) - ch <- state - } - return <-ch -} - -// loopNum reports how many times this conn's select loop has gone around. -func (st *serverTester) loopNum() int { - lastc := make(chan int, 1) - st.sc.testHookCh <- func(loopNum int) { - lastc <- loopNum - } - return <-lastc -} - -// awaitIdle heuristically awaits for the server conn's select loop to be idle. -// The heuristic is that the server connection's serve loop must schedule -// 50 times in a row without any channel sends or receives occurring. -func (st *serverTester) awaitIdle() { - remain := 50 - last := st.loopNum() - for remain > 0 { - n := st.loopNum() - if n == last+1 { - remain-- - } else { - remain = 50 - } - last = n - } -} - -func (st *serverTester) Close() { - if st.t.Failed() { - st.frameReadLogMu.Lock() - if st.frameReadLogBuf.Len() > 0 { - st.t.Logf("Framer read log:\n%s", st.frameReadLogBuf.String()) - } - st.frameReadLogMu.Unlock() - - st.frameWriteLogMu.Lock() - if st.frameWriteLogBuf.Len() > 0 { - st.t.Logf("Framer write log:\n%s", st.frameWriteLogBuf.String()) - } - st.frameWriteLogMu.Unlock() - - // If we failed already (and are likely in a Fatal, - // unwindowing), force close the connection, so the - // httptest.Server doesn't wait forever for the conn - // to close. - if st.cc != nil { - st.cc.Close() - } - } - st.ts.Close() - if st.cc != nil { - st.cc.Close() - } - log.SetOutput(os.Stderr) -} - -// greet initiates the client's HTTP/2 connection into a state where -// frames may be sent. -func (st *serverTester) greet() { - st.greetAndCheckSettings(func(Setting) error { return nil }) -} - -func (st *serverTester) greetAndCheckSettings(checkSetting func(s Setting) error) { - st.writePreface() - st.writeInitialSettings() - st.wantSettings().ForeachSetting(checkSetting) - st.writeSettingsAck() - - // The initial WINDOW_UPDATE and SETTINGS ACK can come in any order. - var gotSettingsAck bool - var gotWindowUpdate bool - - for i := 0; i < 2; i++ { - f, err := st.readFrame() - if err != nil { - st.t.Fatal(err) - } - switch f := f.(type) { - case *SettingsFrame: - if !f.Header().Flags.Has(FlagSettingsAck) { - st.t.Fatal("Settings Frame didn't have ACK set") - } - gotSettingsAck = true - - case *WindowUpdateFrame: - if f.FrameHeader.StreamID != 0 { - st.t.Fatalf("WindowUpdate StreamID = %d; want 0", f.FrameHeader.StreamID, 0) - } - incr := uint32((&Server{}).initialConnRecvWindowSize() - initialWindowSize) - if f.Increment != incr { - st.t.Fatalf("WindowUpdate increment = %d; want %d", f.Increment, incr) - } - gotWindowUpdate = true - - default: - st.t.Fatalf("Wanting a settings ACK or window update, received a %T", f) - } - } - - if !gotSettingsAck { - st.t.Fatalf("Didn't get a settings ACK") - } - if !gotWindowUpdate { - st.t.Fatalf("Didn't get a window update") - } -} - -func (st *serverTester) writePreface() { - n, err := st.cc.Write(clientPreface) - if err != nil { - st.t.Fatalf("Error writing client preface: %v", err) - } - if n != len(clientPreface) { - st.t.Fatalf("Writing client preface, wrote %d bytes; want %d", n, len(clientPreface)) - } -} - -func (st *serverTester) writeInitialSettings() { - if err := st.fr.WriteSettings(); err != nil { - st.t.Fatalf("Error writing initial SETTINGS frame from client to server: %v", err) - } -} - -func (st *serverTester) writeSettingsAck() { - if err := st.fr.WriteSettingsAck(); err != nil { - st.t.Fatalf("Error writing ACK of server's SETTINGS: %v", err) - } -} - -func (st *serverTester) writeHeaders(p HeadersFrameParam) { - if err := st.fr.WriteHeaders(p); err != nil { - st.t.Fatalf("Error writing HEADERS: %v", err) - } -} - -func (st *serverTester) writePriority(id uint32, p PriorityParam) { - if err := st.fr.WritePriority(id, p); err != nil { - st.t.Fatalf("Error writing PRIORITY: %v", err) - } -} - -func (st *serverTester) encodeHeaderField(k, v string) { - err := st.hpackEnc.WriteField(hpack.HeaderField{Name: k, Value: v}) - if err != nil { - st.t.Fatalf("HPACK encoding error for %q/%q: %v", k, v, err) - } -} - -// encodeHeaderRaw is the magic-free version of encodeHeader. -// It takes 0 or more (k, v) pairs and encodes them. -func (st *serverTester) encodeHeaderRaw(headers ...string) []byte { - if len(headers)%2 == 1 { - panic("odd number of kv args") - } - st.headerBuf.Reset() - for len(headers) > 0 { - k, v := headers[0], headers[1] - st.encodeHeaderField(k, v) - headers = headers[2:] - } - return st.headerBuf.Bytes() -} - -// encodeHeader encodes headers and returns their HPACK bytes. headers -// must contain an even number of key/value pairs. There may be -// multiple pairs for keys (e.g. "cookie"). The :method, :path, and -// :scheme headers default to GET, / and https. The :authority header -// defaults to st.ts.Listener.Addr(). -func (st *serverTester) encodeHeader(headers ...string) []byte { - if len(headers)%2 == 1 { - panic("odd number of kv args") - } - - st.headerBuf.Reset() - defaultAuthority := st.ts.Listener.Addr().String() - - if len(headers) == 0 { - // Fast path, mostly for benchmarks, so test code doesn't pollute - // profiles when we're looking to improve server allocations. - st.encodeHeaderField(":method", "GET") - st.encodeHeaderField(":scheme", "https") - st.encodeHeaderField(":authority", defaultAuthority) - st.encodeHeaderField(":path", "/") - return st.headerBuf.Bytes() - } - - if len(headers) == 2 && headers[0] == ":method" { - // Another fast path for benchmarks. - st.encodeHeaderField(":method", headers[1]) - st.encodeHeaderField(":scheme", "https") - st.encodeHeaderField(":authority", defaultAuthority) - st.encodeHeaderField(":path", "/") - return st.headerBuf.Bytes() - } - - pseudoCount := map[string]int{} - keys := []string{":method", ":scheme", ":authority", ":path"} - vals := map[string][]string{ - ":method": {"GET"}, - ":scheme": {"https"}, - ":authority": {defaultAuthority}, - ":path": {"/"}, - } - for len(headers) > 0 { - k, v := headers[0], headers[1] - headers = headers[2:] - if _, ok := vals[k]; !ok { - keys = append(keys, k) - } - if strings.HasPrefix(k, ":") { - pseudoCount[k]++ - if pseudoCount[k] == 1 { - vals[k] = []string{v} - } else { - // Allows testing of invalid headers w/ dup pseudo fields. - vals[k] = append(vals[k], v) - } - } else { - vals[k] = append(vals[k], v) - } - } - for _, k := range keys { - for _, v := range vals[k] { - st.encodeHeaderField(k, v) - } - } - return st.headerBuf.Bytes() -} - -// bodylessReq1 writes a HEADERS frames with StreamID 1 and EndStream and EndHeaders set. -func (st *serverTester) bodylessReq1(headers ...string) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(headers...), - EndStream: true, - EndHeaders: true, - }) -} - -func (st *serverTester) writeData(streamID uint32, endStream bool, data []byte) { - if err := st.fr.WriteData(streamID, endStream, data); err != nil { - st.t.Fatalf("Error writing DATA: %v", err) - } -} - -func (st *serverTester) 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 := fr.ReadFrame() - if err != nil { - ch <- err - } else { - ch <- fr - } - }() - t := time.NewTimer(wait) - select { - 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 { - st.t.Fatalf("Error while expecting a HEADERS frame: %v", err) - } - hf, ok := f.(*HeadersFrame) - if !ok { - st.t.Fatalf("got a %T; want *HeadersFrame", f) - } - return hf -} - -func (st *serverTester) wantContinuation() *ContinuationFrame { - f, err := st.readFrame() - if err != nil { - st.t.Fatalf("Error while expecting a CONTINUATION frame: %v", err) - } - cf, ok := f.(*ContinuationFrame) - if !ok { - st.t.Fatalf("got a %T; want *ContinuationFrame", f) - } - return cf -} - -func (st *serverTester) wantData() *DataFrame { - f, err := st.readFrame() - if err != nil { - st.t.Fatalf("Error while expecting a DATA frame: %v", err) - } - df, ok := f.(*DataFrame) - if !ok { - st.t.Fatalf("got a %T; want *DataFrame", f) - } - return df -} - -func (st *serverTester) wantSettings() *SettingsFrame { - f, err := st.readFrame() - if err != nil { - st.t.Fatalf("Error while expecting a SETTINGS frame: %v", err) - } - sf, ok := f.(*SettingsFrame) - if !ok { - st.t.Fatalf("got a %T; want *SettingsFrame", f) - } - return sf -} - -func (st *serverTester) wantPing() *PingFrame { - f, err := st.readFrame() - if err != nil { - st.t.Fatalf("Error while expecting a PING frame: %v", err) - } - pf, ok := f.(*PingFrame) - if !ok { - st.t.Fatalf("got a %T; want *PingFrame", f) - } - return pf -} - -func (st *serverTester) wantGoAway() *GoAwayFrame { - f, err := st.readFrame() - if err != nil { - st.t.Fatalf("Error while expecting a GOAWAY frame: %v", err) - } - gf, ok := f.(*GoAwayFrame) - if !ok { - st.t.Fatalf("got a %T; want *GoAwayFrame", f) - } - return gf -} - -func (st *serverTester) wantRSTStream(streamID uint32, errCode ErrCode) { - f, err := st.readFrame() - if err != nil { - st.t.Fatalf("Error while expecting an RSTStream frame: %v", err) - } - rs, ok := f.(*RSTStreamFrame) - if !ok { - st.t.Fatalf("got a %T; want *RSTStreamFrame", f) - } - if rs.FrameHeader.StreamID != streamID { - st.t.Fatalf("RSTStream StreamID = %d; want %d", rs.FrameHeader.StreamID, streamID) - } - if rs.ErrCode != errCode { - st.t.Fatalf("RSTStream ErrCode = %d (%s); want %d (%s)", rs.ErrCode, rs.ErrCode, errCode, errCode) - } -} - -func (st *serverTester) wantWindowUpdate(streamID, incr uint32) { - f, err := st.readFrame() - if err != nil { - st.t.Fatalf("Error while expecting a WINDOW_UPDATE frame: %v", err) - } - wu, ok := f.(*WindowUpdateFrame) - if !ok { - st.t.Fatalf("got a %T; want *WindowUpdateFrame", f) - } - if wu.FrameHeader.StreamID != streamID { - st.t.Fatalf("WindowUpdate StreamID = %d; want %d", wu.FrameHeader.StreamID, streamID) - } - if wu.Increment != incr { - st.t.Fatalf("WindowUpdate increment = %d; want %d", wu.Increment, incr) - } -} - -func (st *serverTester) wantSettingsAck() { - f, err := st.readFrame() - if err != nil { - st.t.Fatal(err) - } - sf, ok := f.(*SettingsFrame) - if !ok { - st.t.Fatalf("Wanting a settings ACK, received a %T", f) - } - if !sf.Header().Flags.Has(FlagSettingsAck) { - st.t.Fatal("Settings Frame didn't have ACK set") - } -} - -func (st *serverTester) wantPushPromise() *PushPromiseFrame { - f, err := st.readFrame() - if err != nil { - st.t.Fatal(err) - } - ppf, ok := f.(*PushPromiseFrame) - if !ok { - st.t.Fatalf("Wanted PushPromise, received %T", ppf) - } - return ppf -} - -func TestServer(t *testing.T) { - gotReq := make(chan bool, 1) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Foo", "Bar") - gotReq <- true - }) - defer st.Close() - - covers("3.5", ` - The server connection preface consists of a potentially empty - SETTINGS frame ([SETTINGS]) that MUST be the first frame the - server sends in the HTTP/2 connection. - `) - - st.greet() - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(), - EndStream: true, // no DATA frames - EndHeaders: true, - }) - - select { - case <-gotReq: - case <-time.After(2 * time.Second): - t.Error("timeout waiting for request") - } -} - -func TestServer_Request_Get(t *testing.T) { - testServerRequest(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader("foo-bar", "some-value"), - EndStream: true, // no DATA frames - EndHeaders: true, - }) - }, func(r *http.Request) { - if r.Method != "GET" { - t.Errorf("Method = %q; want GET", r.Method) - } - if r.URL.Path != "/" { - t.Errorf("URL.Path = %q; want /", r.URL.Path) - } - if r.ContentLength != 0 { - t.Errorf("ContentLength = %v; want 0", r.ContentLength) - } - if r.Close { - t.Error("Close = true; want false") - } - if !strings.Contains(r.RemoteAddr, ":") { - t.Errorf("RemoteAddr = %q; want something with a colon", r.RemoteAddr) - } - if r.Proto != "HTTP/2.0" || r.ProtoMajor != 2 || r.ProtoMinor != 0 { - t.Errorf("Proto = %q Major=%v,Minor=%v; want HTTP/2.0", r.Proto, r.ProtoMajor, r.ProtoMinor) - } - wantHeader := http.Header{ - "Foo-Bar": []string{"some-value"}, - } - if !reflect.DeepEqual(r.Header, wantHeader) { - t.Errorf("Header = %#v; want %#v", r.Header, wantHeader) - } - if n, err := r.Body.Read([]byte(" ")); err != io.EOF || n != 0 { - t.Errorf("Read = %d, %v; want 0, EOF", n, err) - } - }) -} - -func TestServer_Request_Get_PathSlashes(t *testing.T) { - testServerRequest(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":path", "/%2f/"), - EndStream: true, // no DATA frames - EndHeaders: true, - }) - }, func(r *http.Request) { - if r.RequestURI != "/%2f/" { - t.Errorf("RequestURI = %q; want /%%2f/", r.RequestURI) - } - if r.URL.Path != "///" { - t.Errorf("URL.Path = %q; want ///", r.URL.Path) - } - }) -} - -// TODO: add a test with EndStream=true on the HEADERS but setting a -// Content-Length anyway. Should we just omit it and force it to -// zero? - -func TestServer_Request_Post_NoContentLength_EndStream(t *testing.T) { - testServerRequest(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: true, - EndHeaders: true, - }) - }, func(r *http.Request) { - if r.Method != "POST" { - t.Errorf("Method = %q; want POST", r.Method) - } - if r.ContentLength != 0 { - t.Errorf("ContentLength = %v; want 0", r.ContentLength) - } - if n, err := r.Body.Read([]byte(" ")); err != io.EOF || n != 0 { - t.Errorf("Read = %d, %v; want 0, EOF", n, err) - } - }) -} - -func TestServer_Request_Post_Body_ImmediateEOF(t *testing.T) { - testBodyContents(t, -1, "", func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: false, // to say DATA frames are coming - EndHeaders: true, - }) - st.writeData(1, true, nil) // just kidding. empty body. - }) -} - -func TestServer_Request_Post_Body_OneData(t *testing.T) { - const content = "Some content" - testBodyContents(t, -1, content, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: false, // to say DATA frames are coming - EndHeaders: true, - }) - st.writeData(1, true, []byte(content)) - }) -} - -func TestServer_Request_Post_Body_TwoData(t *testing.T) { - const content = "Some content" - testBodyContents(t, -1, content, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: false, // to say DATA frames are coming - EndHeaders: true, - }) - st.writeData(1, false, []byte(content[:5])) - st.writeData(1, true, []byte(content[5:])) - }) -} - -func TestServer_Request_Post_Body_ContentLength_Correct(t *testing.T) { - const content = "Some content" - testBodyContents(t, int64(len(content)), content, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader( - ":method", "POST", - "content-length", strconv.Itoa(len(content)), - ), - EndStream: false, // to say DATA frames are coming - EndHeaders: true, - }) - st.writeData(1, true, []byte(content)) - }) -} - -func TestServer_Request_Post_Body_ContentLength_TooLarge(t *testing.T) { - testBodyContentsFail(t, 3, "request declared a Content-Length of 3 but only wrote 2 bytes", - func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader( - ":method", "POST", - "content-length", "3", - ), - EndStream: false, // to say DATA frames are coming - EndHeaders: true, - }) - st.writeData(1, true, []byte("12")) - }) -} - -func TestServer_Request_Post_Body_ContentLength_TooSmall(t *testing.T) { - testBodyContentsFail(t, 4, "sender tried to send more than declared Content-Length of 4 bytes", - func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader( - ":method", "POST", - "content-length", "4", - ), - EndStream: false, // to say DATA frames are coming - EndHeaders: true, - }) - st.writeData(1, true, []byte("12345")) - }) -} - -func testBodyContents(t *testing.T, wantContentLength int64, wantBody string, write func(st *serverTester)) { - testServerRequest(t, write, func(r *http.Request) { - if r.Method != "POST" { - t.Errorf("Method = %q; want POST", r.Method) - } - if r.ContentLength != wantContentLength { - t.Errorf("ContentLength = %v; want %d", r.ContentLength, wantContentLength) - } - all, err := ioutil.ReadAll(r.Body) - if err != nil { - t.Fatal(err) - } - if string(all) != wantBody { - t.Errorf("Read = %q; want %q", all, wantBody) - } - if err := r.Body.Close(); err != nil { - t.Fatalf("Close: %v", err) - } - }) -} - -func testBodyContentsFail(t *testing.T, wantContentLength int64, wantReadError string, write func(st *serverTester)) { - testServerRequest(t, write, func(r *http.Request) { - if r.Method != "POST" { - t.Errorf("Method = %q; want POST", r.Method) - } - if r.ContentLength != wantContentLength { - t.Errorf("ContentLength = %v; want %d", r.ContentLength, wantContentLength) - } - all, err := ioutil.ReadAll(r.Body) - if err == nil { - t.Fatalf("expected an error (%q) reading from the body. Successfully read %q instead.", - wantReadError, all) - } - if !strings.Contains(err.Error(), wantReadError) { - t.Fatalf("Body.Read = %v; want substring %q", err, wantReadError) - } - if err := r.Body.Close(); err != nil { - t.Fatalf("Close: %v", err) - } - }) -} - -// Using a Host header, instead of :authority -func TestServer_Request_Get_Host(t *testing.T) { - const host = "example.com" - testServerRequest(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":authority", "", "host", host), - EndStream: true, - EndHeaders: true, - }) - }, func(r *http.Request) { - if r.Host != host { - t.Errorf("Host = %q; want %q", r.Host, host) - } - }) -} - -// Using an :authority pseudo-header, instead of Host -func TestServer_Request_Get_Authority(t *testing.T) { - const host = "example.com" - testServerRequest(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":authority", host), - EndStream: true, - EndHeaders: true, - }) - }, func(r *http.Request) { - if r.Host != host { - t.Errorf("Host = %q; want %q", r.Host, host) - } - }) -} - -func TestServer_Request_WithContinuation(t *testing.T) { - wantHeader := http.Header{ - "Foo-One": []string{"value-one"}, - "Foo-Two": []string{"value-two"}, - "Foo-Three": []string{"value-three"}, - } - testServerRequest(t, func(st *serverTester) { - fullHeaders := st.encodeHeader( - "foo-one", "value-one", - "foo-two", "value-two", - "foo-three", "value-three", - ) - remain := fullHeaders - chunks := 0 - for len(remain) > 0 { - const maxChunkSize = 5 - chunk := remain - if len(chunk) > maxChunkSize { - chunk = chunk[:maxChunkSize] - } - remain = remain[len(chunk):] - - if chunks == 0 { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: chunk, - EndStream: true, // no DATA frames - EndHeaders: false, // we'll have continuation frames - }) - } else { - err := st.fr.WriteContinuation(1, len(remain) == 0, chunk) - if err != nil { - t.Fatal(err) - } - } - chunks++ - } - if chunks < 2 { - t.Fatal("too few chunks") - } - }, func(r *http.Request) { - if !reflect.DeepEqual(r.Header, wantHeader) { - t.Errorf("Header = %#v; want %#v", r.Header, wantHeader) - } - }) -} - -// Concatenated cookie headers. ("8.1.2.5 Compressing the Cookie Header Field") -func TestServer_Request_CookieConcat(t *testing.T) { - const host = "example.com" - testServerRequest(t, func(st *serverTester) { - st.bodylessReq1( - ":authority", host, - "cookie", "a=b", - "cookie", "c=d", - "cookie", "e=f", - ) - }, func(r *http.Request) { - const want = "a=b; c=d; e=f" - if got := r.Header.Get("Cookie"); got != want { - t.Errorf("Cookie = %q; want %q", got, want) - } - }) -} - -func TestServer_Request_Reject_CapitalHeader(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1("UPPER", "v") }) -} - -func TestServer_Request_Reject_HeaderFieldNameColon(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1("has:colon", "v") }) -} - -func TestServer_Request_Reject_HeaderFieldNameNULL(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1("has\x00null", "v") }) -} - -func TestServer_Request_Reject_HeaderFieldNameEmpty(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1("", "v") }) -} - -func TestServer_Request_Reject_HeaderFieldValueNewline(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1("foo", "has\nnewline") }) -} - -func TestServer_Request_Reject_HeaderFieldValueCR(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1("foo", "has\rcarriage") }) -} - -func TestServer_Request_Reject_HeaderFieldValueDEL(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1("foo", "has\x7fdel") }) -} - -func TestServer_Request_Reject_Pseudo_Missing_method(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1(":method", "") }) -} - -func TestServer_Request_Reject_Pseudo_ExactlyOne(t *testing.T) { - // 8.1.2.3 Request Pseudo-Header Fields - // "All HTTP/2 requests MUST include exactly one valid value" ... - testRejectRequest(t, func(st *serverTester) { - st.addLogFilter("duplicate pseudo-header") - st.bodylessReq1(":method", "GET", ":method", "POST") - }) -} - -func TestServer_Request_Reject_Pseudo_AfterRegular(t *testing.T) { - // 8.1.2.3 Request Pseudo-Header Fields - // "All pseudo-header fields MUST appear in the header block - // before regular header fields. Any request or response that - // contains a pseudo-header field that appears in a header - // block after a regular header field MUST be treated as - // malformed (Section 8.1.2.6)." - testRejectRequest(t, func(st *serverTester) { - st.addLogFilter("pseudo-header after regular header") - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - enc.WriteField(hpack.HeaderField{Name: ":method", Value: "GET"}) - enc.WriteField(hpack.HeaderField{Name: "regular", Value: "foobar"}) - enc.WriteField(hpack.HeaderField{Name: ":path", Value: "/"}) - enc.WriteField(hpack.HeaderField{Name: ":scheme", Value: "https"}) - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: buf.Bytes(), - EndStream: true, - EndHeaders: true, - }) - }) -} - -func TestServer_Request_Reject_Pseudo_Missing_path(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1(":path", "") }) -} - -func TestServer_Request_Reject_Pseudo_Missing_scheme(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1(":scheme", "") }) -} - -func TestServer_Request_Reject_Pseudo_scheme_invalid(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1(":scheme", "bogus") }) -} - -func TestServer_Request_Reject_Pseudo_Unknown(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { - st.addLogFilter(`invalid pseudo-header ":unknown_thing"`) - st.bodylessReq1(":unknown_thing", "") - }) -} - -func testRejectRequest(t *testing.T, send func(*serverTester)) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - t.Error("server request made it to handler; should've been rejected") - }) - defer st.Close() - - st.greet() - send(st) - st.wantRSTStream(1, ErrCodeProtocol) -} - -func testRejectRequestWithProtocolError(t *testing.T, send func(*serverTester)) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - t.Error("server request made it to handler; should've been rejected") - }, optQuiet) - defer st.Close() - - st.greet() - send(st) - gf := st.wantGoAway() - if gf.ErrCode != ErrCodeProtocol { - t.Errorf("err code = %v; want %v", gf.ErrCode, ErrCodeProtocol) - } -} - -// Section 5.1, on idle connections: "Receiving any frame other than -// HEADERS or PRIORITY on a stream in this state MUST be treated as a -// connection error (Section 5.4.1) of type PROTOCOL_ERROR." -func TestRejectFrameOnIdle_WindowUpdate(t *testing.T) { - testRejectRequestWithProtocolError(t, func(st *serverTester) { - st.fr.WriteWindowUpdate(123, 456) - }) -} -func TestRejectFrameOnIdle_Data(t *testing.T) { - testRejectRequestWithProtocolError(t, func(st *serverTester) { - st.fr.WriteData(123, true, nil) - }) -} -func TestRejectFrameOnIdle_RSTStream(t *testing.T) { - testRejectRequestWithProtocolError(t, func(st *serverTester) { - st.fr.WriteRSTStream(123, ErrCodeCancel) - }) -} - -func TestServer_Request_Connect(t *testing.T) { - testServerRequest(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeaderRaw( - ":method", "CONNECT", - ":authority", "example.com:123", - ), - EndStream: true, - EndHeaders: true, - }) - }, func(r *http.Request) { - if g, w := r.Method, "CONNECT"; g != w { - t.Errorf("Method = %q; want %q", g, w) - } - if g, w := r.RequestURI, "example.com:123"; g != w { - t.Errorf("RequestURI = %q; want %q", g, w) - } - if g, w := r.URL.Host, "example.com:123"; g != w { - t.Errorf("URL.Host = %q; want %q", g, w) - } - }) -} - -func TestServer_Request_Connect_InvalidPath(t *testing.T) { - testServerRejectsStream(t, ErrCodeProtocol, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeaderRaw( - ":method", "CONNECT", - ":authority", "example.com:123", - ":path", "/bogus", - ), - EndStream: true, - EndHeaders: true, - }) - }) -} - -func TestServer_Request_Connect_InvalidScheme(t *testing.T) { - testServerRejectsStream(t, ErrCodeProtocol, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeaderRaw( - ":method", "CONNECT", - ":authority", "example.com:123", - ":scheme", "https", - ), - EndStream: true, - EndHeaders: true, - }) - }) -} - -func TestServer_Ping(t *testing.T) { - st := newServerTester(t, nil) - defer st.Close() - st.greet() - - // Server should ignore this one, since it has ACK set. - ackPingData := [8]byte{1, 2, 4, 8, 16, 32, 64, 128} - if err := st.fr.WritePing(true, ackPingData); err != nil { - t.Fatal(err) - } - - // But the server should reply to this one, since ACK is false. - pingData := [8]byte{1, 2, 3, 4, 5, 6, 7, 8} - if err := st.fr.WritePing(false, pingData); err != nil { - t.Fatal(err) - } - - pf := st.wantPing() - if !pf.Flags.Has(FlagPingAck) { - t.Error("response ping doesn't have ACK set") - } - if pf.Data != pingData { - t.Errorf("response ping has data %q; want %q", pf.Data, pingData) - } -} - -func TestServer_RejectsLargeFrames(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skip("see golang.org/issue/13434") - } - - st := newServerTester(t, nil) - defer st.Close() - st.greet() - - // Write too large of a frame (too large by one byte) - // We ignore the return value because it's expected that the server - // will only read the first 9 bytes (the headre) and then disconnect. - st.fr.WriteRawFrame(0xff, 0, 0, make([]byte, defaultMaxReadFrameSize+1)) - - gf := st.wantGoAway() - if gf.ErrCode != ErrCodeFrameSize { - t.Errorf("GOAWAY err = %v; want %v", gf.ErrCode, ErrCodeFrameSize) - } - if st.serverLogBuf.Len() != 0 { - // Previously we spun here for a bit until the GOAWAY disconnect - // timer fired, logging while we fired. - t.Errorf("unexpected server output: %.500s\n", st.serverLogBuf.Bytes()) - } -} - -func TestServer_Handler_Sends_WindowUpdate(t *testing.T) { - puppet := newHandlerPuppet() - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - puppet.act(w, r) - }) - defer st.Close() - defer puppet.done() - - st.greet() - - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: false, // data coming - EndHeaders: true, - }) - st.writeData(1, false, []byte("abcdef")) - puppet.do(readBodyHandler(t, "abc")) - st.wantWindowUpdate(0, 3) - st.wantWindowUpdate(1, 3) - - puppet.do(readBodyHandler(t, "def")) - st.wantWindowUpdate(0, 3) - st.wantWindowUpdate(1, 3) - - st.writeData(1, true, []byte("ghijkl")) // END_STREAM here - puppet.do(readBodyHandler(t, "ghi")) - puppet.do(readBodyHandler(t, "jkl")) - st.wantWindowUpdate(0, 3) - st.wantWindowUpdate(0, 3) // no more stream-level, since END_STREAM -} - -// 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{0, 0, 0, 0}) - - // 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() - st.greet() - if err := st.fr.WriteWindowUpdate(0, 1<<31-1); err != nil { - t.Fatal(err) - } - gf := st.wantGoAway() - if gf.ErrCode != ErrCodeFlowControl { - t.Errorf("GOAWAY err = %v; want %v", gf.ErrCode, ErrCodeFlowControl) - } - if gf.LastStreamID != 0 { - t.Errorf("GOAWAY last stream ID = %v; want %v", gf.LastStreamID, 0) - } -} - -func TestServer_Send_RstStream_After_Bogus_WindowUpdate(t *testing.T) { - inHandler := make(chan bool) - blockHandler := make(chan bool) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - inHandler <- true - <-blockHandler - }) - defer st.Close() - defer close(blockHandler) - st.greet() - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: false, // keep it open - EndHeaders: true, - }) - <-inHandler - // Send a bogus window update: - if err := st.fr.WriteWindowUpdate(1, 1<<31-1); err != nil { - t.Fatal(err) - } - st.wantRSTStream(1, ErrCodeFlowControl) -} - -// testServerPostUnblock sends a hanging POST with unsent data to handler, -// then runs fn once in the handler, and verifies that the error returned from -// handler is acceptable. It fails if takes over 5 seconds for handler to exit. -func testServerPostUnblock(t *testing.T, - handler func(http.ResponseWriter, *http.Request) error, - fn func(*serverTester), - checkErr func(error), - otherHeaders ...string) { - inHandler := make(chan bool) - errc := make(chan error, 1) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - inHandler <- true - errc <- handler(w, r) - }) - defer st.Close() - st.greet() - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(append([]string{":method", "POST"}, otherHeaders...)...), - EndStream: false, // keep it open - EndHeaders: true, - }) - <-inHandler - fn(st) - select { - case err := <-errc: - if checkErr != nil { - checkErr(err) - } - case <-time.After(5 * time.Second): - t.Fatal("timeout waiting for Handler to return") - } -} - -func TestServer_RSTStream_Unblocks_Read(t *testing.T) { - testServerPostUnblock(t, - func(w http.ResponseWriter, r *http.Request) (err error) { - _, err = r.Body.Read(make([]byte, 1)) - return - }, - func(st *serverTester) { - if err := st.fr.WriteRSTStream(1, ErrCodeCancel); err != nil { - t.Fatal(err) - } - }, - func(err error) { - want := StreamError{StreamID: 0x1, Code: 0x8} - if !reflect.DeepEqual(err, want) { - t.Errorf("Read error = %v; want %v", err, want) - } - }, - ) -} - -func TestServer_RSTStream_Unblocks_Header_Write(t *testing.T) { - // Run this test a bunch, because it doesn't always - // deadlock. But with a bunch, it did. - n := 50 - if testing.Short() { - n = 5 - } - for i := 0; i < n; i++ { - testServer_RSTStream_Unblocks_Header_Write(t) - } -} - -func testServer_RSTStream_Unblocks_Header_Write(t *testing.T) { - inHandler := make(chan bool, 1) - unblockHandler := make(chan bool, 1) - headerWritten := make(chan bool, 1) - wroteRST := make(chan bool, 1) - - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - inHandler <- true - <-wroteRST - w.Header().Set("foo", "bar") - w.WriteHeader(200) - w.(http.Flusher).Flush() - headerWritten <- true - <-unblockHandler - }) - defer st.Close() - - st.greet() - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: false, // keep it open - EndHeaders: true, - }) - <-inHandler - if err := st.fr.WriteRSTStream(1, ErrCodeCancel); err != nil { - t.Fatal(err) - } - wroteRST <- true - st.awaitIdle() - select { - case <-headerWritten: - case <-time.After(2 * time.Second): - t.Error("timeout waiting for header write") - } - unblockHandler <- true -} - -func TestServer_DeadConn_Unblocks_Read(t *testing.T) { - testServerPostUnblock(t, - func(w http.ResponseWriter, r *http.Request) (err error) { - _, err = r.Body.Read(make([]byte, 1)) - return - }, - func(st *serverTester) { st.cc.Close() }, - func(err error) { - if err == nil { - t.Error("unexpected nil error from Request.Body.Read") - } - }, - ) -} - -var blockUntilClosed = func(w http.ResponseWriter, r *http.Request) error { - <-w.(http.CloseNotifier).CloseNotify() - return nil -} - -func TestServer_CloseNotify_After_RSTStream(t *testing.T) { - testServerPostUnblock(t, blockUntilClosed, func(st *serverTester) { - if err := st.fr.WriteRSTStream(1, ErrCodeCancel); err != nil { - t.Fatal(err) - } - }, nil) -} - -func TestServer_CloseNotify_After_ConnClose(t *testing.T) { - testServerPostUnblock(t, blockUntilClosed, func(st *serverTester) { st.cc.Close() }, nil) -} - -// that CloseNotify unblocks after a stream error due to the client's -// problem that's unrelated to them explicitly canceling it (which is -// TestServer_CloseNotify_After_RSTStream above) -func TestServer_CloseNotify_After_StreamError(t *testing.T) { - testServerPostUnblock(t, blockUntilClosed, func(st *serverTester) { - // data longer than declared Content-Length => stream error - st.writeData(1, true, []byte("1234")) - }, nil, "content-length", "3") -} - -func TestServer_StateTransitions(t *testing.T) { - var st *serverTester - inHandler := make(chan bool) - writeData := make(chan bool) - leaveHandler := make(chan bool) - st = newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - inHandler <- true - if st.stream(1) == nil { - t.Errorf("nil stream 1 in handler") - } - if got, want := st.streamState(1), stateOpen; got != want { - t.Errorf("in handler, state is %v; want %v", got, want) - } - writeData <- true - if n, err := r.Body.Read(make([]byte, 1)); n != 0 || err != io.EOF { - t.Errorf("body read = %d, %v; want 0, EOF", n, err) - } - if got, want := st.streamState(1), stateHalfClosedRemote; got != want { - t.Errorf("in handler, state is %v; want %v", got, want) - } - - <-leaveHandler - }) - st.greet() - if st.stream(1) != nil { - t.Fatal("stream 1 should be empty") - } - if got := st.streamState(1); got != stateIdle { - t.Fatalf("stream 1 should be idle; got %v", got) - } - - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: false, // keep it open - EndHeaders: true, - }) - <-inHandler - <-writeData - st.writeData(1, true, nil) - - leaveHandler <- true - hf := st.wantHeaders() - if !hf.StreamEnded() { - t.Fatal("expected END_STREAM flag") - } - - if got, want := st.streamState(1), stateClosed; got != want { - t.Errorf("at end, state is %v; want %v", got, want) - } - if st.stream(1) != nil { - t.Fatal("at end, stream 1 should be gone") - } -} - -// test HEADERS w/o EndHeaders + another HEADERS (should get rejected) -func TestServer_Rejects_HeadersNoEnd_Then_Headers(t *testing.T) { - testServerRejectsConn(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(), - EndStream: true, - EndHeaders: false, - }) - st.writeHeaders(HeadersFrameParam{ // Not a continuation. - StreamID: 3, // different stream. - BlockFragment: st.encodeHeader(), - EndStream: true, - EndHeaders: true, - }) - }) -} - -// test HEADERS w/o EndHeaders + PING (should get rejected) -func TestServer_Rejects_HeadersNoEnd_Then_Ping(t *testing.T) { - testServerRejectsConn(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(), - EndStream: true, - EndHeaders: false, - }) - if err := st.fr.WritePing(false, [8]byte{}); err != nil { - t.Fatal(err) - } - }) -} - -// test HEADERS w/ EndHeaders + a continuation HEADERS (should get rejected) -func TestServer_Rejects_HeadersEnd_Then_Continuation(t *testing.T) { - testServerRejectsConn(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(), - EndStream: true, - EndHeaders: true, - }) - st.wantHeaders() - if err := st.fr.WriteContinuation(1, true, encodeHeaderNoImplicit(t, "foo", "bar")); err != nil { - t.Fatal(err) - } - }) -} - -// test HEADERS w/o EndHeaders + a continuation HEADERS on wrong stream ID -func TestServer_Rejects_HeadersNoEnd_Then_ContinuationWrongStream(t *testing.T) { - testServerRejectsConn(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(), - EndStream: true, - EndHeaders: false, - }) - if err := st.fr.WriteContinuation(3, true, encodeHeaderNoImplicit(t, "foo", "bar")); err != nil { - t.Fatal(err) - } - }) -} - -// No HEADERS on stream 0. -func TestServer_Rejects_Headers0(t *testing.T) { - testServerRejectsConn(t, func(st *serverTester) { - st.fr.AllowIllegalWrites = true - st.writeHeaders(HeadersFrameParam{ - StreamID: 0, - BlockFragment: st.encodeHeader(), - EndStream: true, - EndHeaders: true, - }) - }) -} - -// No CONTINUATION on stream 0. -func TestServer_Rejects_Continuation0(t *testing.T) { - testServerRejectsConn(t, func(st *serverTester) { - st.fr.AllowIllegalWrites = true - if err := st.fr.WriteContinuation(0, true, st.encodeHeader()); err != nil { - t.Fatal(err) - } - }) -} - -// No PRIORITY on stream 0. -func TestServer_Rejects_Priority0(t *testing.T) { - testServerRejectsConn(t, func(st *serverTester) { - st.fr.AllowIllegalWrites = true - st.writePriority(0, PriorityParam{StreamDep: 1}) - }) -} - -// No HEADERS frame with a self-dependence. -func TestServer_Rejects_HeadersSelfDependence(t *testing.T) { - testServerRejectsStream(t, ErrCodeProtocol, func(st *serverTester) { - st.fr.AllowIllegalWrites = true - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(), - EndStream: true, - EndHeaders: true, - Priority: PriorityParam{StreamDep: 1}, - }) - }) -} - -// No PRIORTY frame with a self-dependence. -func TestServer_Rejects_PrioritySelfDependence(t *testing.T) { - testServerRejectsStream(t, ErrCodeProtocol, func(st *serverTester) { - st.fr.AllowIllegalWrites = true - st.writePriority(1, PriorityParam{StreamDep: 1}) - }) -} - -func TestServer_Rejects_PushPromise(t *testing.T) { - testServerRejectsConn(t, func(st *serverTester) { - pp := PushPromiseParam{ - StreamID: 1, - PromiseID: 3, - } - if err := st.fr.WritePushPromise(pp); err != nil { - t.Fatal(err) - } - }) -} - -// testServerRejectsConn tests that the server hangs up with a GOAWAY -// frame and a server close after the client does something -// deserving a CONNECTION_ERROR. -func testServerRejectsConn(t *testing.T, writeReq func(*serverTester)) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) {}) - st.addLogFilter("connection error: PROTOCOL_ERROR") - defer st.Close() - st.greet() - writeReq(st) - - st.wantGoAway() - errc := make(chan error, 1) - go func() { - fr, err := st.fr.ReadFrame() - if err == nil { - err = fmt.Errorf("got frame of type %T", fr) - } - errc <- err - }() - select { - case err := <-errc: - if err != io.EOF { - t.Errorf("ReadFrame = %v; want io.EOF", err) - } - case <-time.After(2 * time.Second): - t.Error("timeout waiting for disconnect") - } -} - -// testServerRejectsStream tests that the server sends a RST_STREAM with the provided -// error code after a client sends a bogus request. -func testServerRejectsStream(t *testing.T, code ErrCode, writeReq func(*serverTester)) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) {}) - defer st.Close() - st.greet() - writeReq(st) - st.wantRSTStream(1, code) -} - -// testServerRequest sets up an idle HTTP/2 connection and lets you -// write a single request with writeReq, and then verify that the -// *http.Request is built correctly in checkReq. -func testServerRequest(t *testing.T, writeReq func(*serverTester), checkReq func(*http.Request)) { - gotReq := make(chan bool, 1) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - if r.Body == nil { - t.Fatal("nil Body") - } - checkReq(r) - gotReq <- true - }) - defer st.Close() - - st.greet() - writeReq(st) - - select { - case <-gotReq: - case <-time.After(2 * time.Second): - t.Error("timeout waiting for request") - } -} - -func getSlash(st *serverTester) { st.bodylessReq1() } - -func TestServer_Response_NoData(t *testing.T) { - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - // Nothing. - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if !hf.StreamEnded() { - t.Fatal("want END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - }) -} - -func TestServer_Response_NoData_Header_FooBar(t *testing.T) { - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.Header().Set("Foo-Bar", "some-value") - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if !hf.StreamEnded() { - t.Fatal("want END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"foo-bar", "some-value"}, - {"content-type", "text/plain; charset=utf-8"}, - {"content-length", "0"}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - }) -} - -func TestServer_Response_Data_Sniff_DoesntOverride(t *testing.T) { - const msg = "this is HTML." - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.Header().Set("Content-Type", "foo/bar") - io.WriteString(w, msg) - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("don't want END_STREAM, expecting data") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"content-type", "foo/bar"}, - {"content-length", strconv.Itoa(len(msg))}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - df := st.wantData() - if !df.StreamEnded() { - t.Error("expected DATA to have END_STREAM flag") - } - if got := string(df.Data()); got != msg { - t.Errorf("got DATA %q; want %q", got, msg) - } - }) -} - -func TestServer_Response_TransferEncoding_chunked(t *testing.T) { - const msg = "hi" - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.Header().Set("Transfer-Encoding", "chunked") // should be stripped - io.WriteString(w, msg) - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"content-type", "text/plain; charset=utf-8"}, - {"content-length", strconv.Itoa(len(msg))}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - }) -} - -// Header accessed only after the initial write. -func TestServer_Response_Data_IgnoreHeaderAfterWrite_After(t *testing.T) { - const msg = "this is HTML." - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - io.WriteString(w, msg) - w.Header().Set("foo", "should be ignored") - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"content-type", "text/html; charset=utf-8"}, - {"content-length", strconv.Itoa(len(msg))}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - }) -} - -// Header accessed before the initial write and later mutated. -func TestServer_Response_Data_IgnoreHeaderAfterWrite_Overwrite(t *testing.T) { - const msg = "this is HTML." - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.Header().Set("foo", "proper value") - io.WriteString(w, msg) - w.Header().Set("foo", "should be ignored") - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"foo", "proper value"}, - {"content-type", "text/html; charset=utf-8"}, - {"content-length", strconv.Itoa(len(msg))}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - }) -} - -func TestServer_Response_Data_SniffLenType(t *testing.T) { - const msg = "this is HTML." - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - io.WriteString(w, msg) - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("don't want END_STREAM, expecting data") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"content-type", "text/html; charset=utf-8"}, - {"content-length", strconv.Itoa(len(msg))}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - df := st.wantData() - if !df.StreamEnded() { - t.Error("expected DATA to have END_STREAM flag") - } - if got := string(df.Data()); got != msg { - t.Errorf("got DATA %q; want %q", got, msg) - } - }) -} - -func TestServer_Response_Header_Flush_MidWrite(t *testing.T) { - const msg = "this is HTML" - const msg2 = ", and this is the next chunk" - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - io.WriteString(w, msg) - w.(http.Flusher).Flush() - io.WriteString(w, msg2) - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"content-type", "text/html; charset=utf-8"}, // sniffed - // and no content-length - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - { - df := st.wantData() - if df.StreamEnded() { - t.Error("unexpected END_STREAM flag") - } - if got := string(df.Data()); got != msg { - t.Errorf("got DATA %q; want %q", got, msg) - } - } - { - df := st.wantData() - if !df.StreamEnded() { - t.Error("wanted END_STREAM flag on last data chunk") - } - if got := string(df.Data()); got != msg2 { - t.Errorf("got DATA %q; want %q", got, msg2) - } - } - }) -} - -func TestServer_Response_LargeWrite(t *testing.T) { - const size = 1 << 20 - const maxFrameSize = 16 << 10 - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - n, err := w.Write(bytes.Repeat([]byte("a"), size)) - if err != nil { - return fmt.Errorf("Write error: %v", err) - } - if n != size { - return fmt.Errorf("wrong size %d from Write", n) - } - return nil - }, func(st *serverTester) { - if err := st.fr.WriteSettings( - Setting{SettingInitialWindowSize, 0}, - Setting{SettingMaxFrameSize, maxFrameSize}, - ); err != nil { - t.Fatal(err) - } - st.wantSettingsAck() - - getSlash(st) // make the single request - - // Give the handler quota to write: - if err := st.fr.WriteWindowUpdate(1, size); err != nil { - t.Fatal(err) - } - // Give the handler quota to write to connection-level - // window as well - if err := st.fr.WriteWindowUpdate(0, size); err != nil { - t.Fatal(err) - } - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"content-type", "text/plain; charset=utf-8"}, // sniffed - // and no content-length - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - var bytes, frames int - for { - df := st.wantData() - bytes += len(df.Data()) - frames++ - for _, b := range df.Data() { - if b != 'a' { - t.Fatal("non-'a' byte seen in DATA") - } - } - if df.StreamEnded() { - break - } - } - if bytes != size { - t.Errorf("Got %d bytes; want %d", bytes, size) - } - if want := int(size / maxFrameSize); frames < want || frames > want*2 { - t.Errorf("Got %d frames; want %d", frames, size) - } - }) -} - -// Test that the handler can't write more than the client allows -func TestServer_Response_LargeWrite_FlowControlled(t *testing.T) { - // Make these reads. Before each read, the client adds exactly enough - // flow-control to satisfy the read. Numbers chosen arbitrarily. - reads := []int{123, 1, 13, 127} - size := 0 - for _, n := range reads { - size += n - } - - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.(http.Flusher).Flush() - n, err := w.Write(bytes.Repeat([]byte("a"), size)) - if err != nil { - return fmt.Errorf("Write error: %v", err) - } - if n != size { - return fmt.Errorf("wrong size %d from Write", n) - } - return nil - }, func(st *serverTester) { - // Set the window size to something explicit for this test. - // It's also how much initial data we expect. - if err := st.fr.WriteSettings(Setting{SettingInitialWindowSize, uint32(reads[0])}); err != nil { - t.Fatal(err) - } - st.wantSettingsAck() - - getSlash(st) // make the single request - - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - - df := st.wantData() - if got := len(df.Data()); got != reads[0] { - t.Fatalf("Initial window size = %d but got DATA with %d bytes", reads[0], got) - } - - for _, quota := range reads[1:] { - if err := st.fr.WriteWindowUpdate(1, uint32(quota)); err != nil { - t.Fatal(err) - } - df := st.wantData() - if int(quota) != len(df.Data()) { - t.Fatalf("read %d bytes after giving %d quota", len(df.Data()), quota) - } - } - }) -} - -// Test that the handler blocked in a Write is unblocked if the server sends a RST_STREAM. -func TestServer_Response_RST_Unblocks_LargeWrite(t *testing.T) { - const size = 1 << 20 - const maxFrameSize = 16 << 10 - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.(http.Flusher).Flush() - errc := make(chan error, 1) - go func() { - _, err := w.Write(bytes.Repeat([]byte("a"), size)) - errc <- err - }() - select { - case err := <-errc: - if err == nil { - return errors.New("unexpected nil error from Write in handler") - } - return nil - case <-time.After(2 * time.Second): - return errors.New("timeout waiting for Write in handler") - } - }, func(st *serverTester) { - if err := st.fr.WriteSettings( - Setting{SettingInitialWindowSize, 0}, - Setting{SettingMaxFrameSize, maxFrameSize}, - ); err != nil { - t.Fatal(err) - } - st.wantSettingsAck() - - getSlash(st) // make the single request - - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - - if err := st.fr.WriteRSTStream(1, ErrCodeCancel); err != nil { - t.Fatal(err) - } - }) -} - -func TestServer_Response_Empty_Data_Not_FlowControlled(t *testing.T) { - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.(http.Flusher).Flush() - // Nothing; send empty DATA - return nil - }, func(st *serverTester) { - // Handler gets no data quota: - if err := st.fr.WriteSettings(Setting{SettingInitialWindowSize, 0}); err != nil { - t.Fatal(err) - } - st.wantSettingsAck() - - getSlash(st) // make the single request - - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - - df := st.wantData() - if got := len(df.Data()); got != 0 { - t.Fatalf("unexpected %d DATA bytes; want 0", got) - } - if !df.StreamEnded() { - t.Fatal("DATA didn't have END_STREAM") - } - }) -} - -func TestServer_Response_Automatic100Continue(t *testing.T) { - const msg = "foo" - const reply = "bar" - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - if v := r.Header.Get("Expect"); v != "" { - t.Errorf("Expect header = %q; want empty", v) - } - buf := make([]byte, len(msg)) - // This read should trigger the 100-continue being sent. - if n, err := io.ReadFull(r.Body, buf); err != nil || n != len(msg) || string(buf) != msg { - return fmt.Errorf("ReadFull = %q, %v; want %q, nil", buf[:n], err, msg) - } - _, err := io.WriteString(w, reply) - return err - }, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":method", "POST", "expect", "100-continue"), - EndStream: false, - EndHeaders: true, - }) - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "100"}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Fatalf("Got headers %v; want %v", goth, wanth) - } - - // Okay, they sent status 100, so we can send our - // gigantic and/or sensitive "foo" payload now. - st.writeData(1, true, []byte(msg)) - - st.wantWindowUpdate(0, uint32(len(msg))) - - hf = st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("expected data to follow") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth = st.decodeHeader(hf.HeaderBlockFragment()) - wanth = [][2]string{ - {":status", "200"}, - {"content-type", "text/plain; charset=utf-8"}, - {"content-length", strconv.Itoa(len(reply))}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - - df := st.wantData() - if string(df.Data()) != reply { - t.Errorf("Client read %q; want %q", df.Data(), reply) - } - if !df.StreamEnded() { - t.Errorf("expect data stream end") - } - }) -} - -func TestServer_HandlerWriteErrorOnDisconnect(t *testing.T) { - errc := make(chan error, 1) - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - p := []byte("some data.\n") - for { - _, err := w.Write(p) - if err != nil { - errc <- err - return nil - } - } - }, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(), - EndStream: false, - EndHeaders: true, - }) - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - // Close the connection and wait for the handler to (hopefully) notice. - st.cc.Close() - select { - case <-errc: - case <-time.After(5 * time.Second): - t.Error("timeout") - } - }) -} - -func TestServer_Rejects_Too_Many_Streams(t *testing.T) { - const testPath = "/some/path" - - inHandler := make(chan uint32) - leaveHandler := make(chan bool) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - id := w.(*responseWriter).rws.stream.id - inHandler <- id - if id == 1+(defaultMaxStreams+1)*2 && r.URL.Path != testPath { - t.Errorf("decoded final path as %q; want %q", r.URL.Path, testPath) - } - <-leaveHandler - }) - defer st.Close() - st.greet() - nextStreamID := uint32(1) - streamID := func() uint32 { - defer func() { nextStreamID += 2 }() - return nextStreamID - } - sendReq := func(id uint32, headers ...string) { - st.writeHeaders(HeadersFrameParam{ - StreamID: id, - BlockFragment: st.encodeHeader(headers...), - EndStream: true, - EndHeaders: true, - }) - } - for i := 0; i < defaultMaxStreams; i++ { - sendReq(streamID()) - <-inHandler - } - defer func() { - for i := 0; i < defaultMaxStreams; i++ { - leaveHandler <- true - } - }() - - // And this one should cross the limit: - // (It's also sent as a CONTINUATION, to verify we still track the decoder context, - // even if we're rejecting it) - rejectID := streamID() - headerBlock := st.encodeHeader(":path", testPath) - frag1, frag2 := headerBlock[:3], headerBlock[3:] - st.writeHeaders(HeadersFrameParam{ - StreamID: rejectID, - BlockFragment: frag1, - EndStream: true, - EndHeaders: false, // CONTINUATION coming - }) - if err := st.fr.WriteContinuation(rejectID, true, frag2); err != nil { - t.Fatal(err) - } - st.wantRSTStream(rejectID, ErrCodeProtocol) - - // But let a handler finish: - leaveHandler <- true - st.wantHeaders() - - // And now another stream should be able to start: - goodID := streamID() - sendReq(goodID, ":path", testPath) - select { - case got := <-inHandler: - if got != goodID { - t.Errorf("Got stream %d; want %d", got, goodID) - } - case <-time.After(3 * time.Second): - t.Error("timeout waiting for handler") - } -} - -// So many response headers that the server needs to use CONTINUATION frames: -func TestServer_Response_ManyHeaders_With_Continuation(t *testing.T) { - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - h := w.Header() - for i := 0; i < 5000; i++ { - h.Set(fmt.Sprintf("x-header-%d", i), fmt.Sprintf("x-value-%d", i)) - } - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if hf.HeadersEnded() { - t.Fatal("got unwanted END_HEADERS flag") - } - n := 0 - for { - n++ - cf := st.wantContinuation() - if cf.HeadersEnded() { - break - } - } - if n < 5 { - t.Errorf("Only got %d CONTINUATION frames; expected 5+ (currently 6)", n) - } - }) -} - -// This previously crashed (reported by Mathieu Lonjaret as observed -// while using Camlistore) because we got a DATA frame from the client -// after the handler exited and our logic at the time was wrong, -// keeping a stream in the map in stateClosed, which tickled an -// invariant check later when we tried to remove that stream (via -// defer sc.closeAllStreamsOnConnClose) when the serverConn serve loop -// ended. -func TestServer_NoCrash_HandlerClose_Then_ClientClose(t *testing.T) { - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - // nothing - return nil - }, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(), - EndStream: false, // DATA is coming - EndHeaders: true, - }) - hf := st.wantHeaders() - if !hf.HeadersEnded() || !hf.StreamEnded() { - t.Fatalf("want END_HEADERS+END_STREAM, got %v", hf) - } - - // Sent when the a Handler closes while a client has - // indicated it's still sending DATA: - st.wantRSTStream(1, ErrCodeNo) - - // Now the handler has ended, so it's ended its - // stream, but the client hasn't closed its side - // (stateClosedLocal). So send more data and verify - // it doesn't crash with an internal invariant panic, like - // it did before. - st.writeData(1, true, []byte("foo")) - - // 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 - // first. - st.wantRSTStream(1, ErrCodeStreamClosed) - - // Set up a bunch of machinery to record the panic we saw - // previously. - var ( - panMu sync.Mutex - panicVal interface{} - ) - - testHookOnPanicMu.Lock() - testHookOnPanic = func(sc *serverConn, pv interface{}) bool { - panMu.Lock() - panicVal = pv - panMu.Unlock() - return true - } - testHookOnPanicMu.Unlock() - - // Now force the serve loop to end, via closing the connection. - st.cc.Close() - select { - case <-st.sc.doneServing: - // Loop has exited. - panMu.Lock() - got := panicVal - panMu.Unlock() - if got != nil { - t.Errorf("Got panic: %v", got) - } - case <-time.After(5 * time.Second): - t.Error("timeout") - } - }) -} - -func TestServer_Rejects_TLS10(t *testing.T) { testRejectTLS(t, tls.VersionTLS10) } -func TestServer_Rejects_TLS11(t *testing.T) { testRejectTLS(t, tls.VersionTLS11) } - -func testRejectTLS(t *testing.T, max uint16) { - st := newServerTester(t, nil, func(c *tls.Config) { - c.MaxVersion = max - }) - defer st.Close() - gf := st.wantGoAway() - if got, want := gf.ErrCode, ErrCodeInadequateSecurity; got != want { - t.Errorf("Got error code %v; want %v", got, want) - } -} - -func TestServer_Rejects_TLSBadCipher(t *testing.T) { - st := newServerTester(t, nil, func(c *tls.Config) { - // Only list bad ones: - c.CipherSuites = []uint16{ - tls.TLS_RSA_WITH_RC4_128_SHA, - tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, - tls.TLS_RSA_WITH_AES_128_CBC_SHA, - tls.TLS_RSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, - tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, - } - }) - defer st.Close() - gf := st.wantGoAway() - if got, want := gf.ErrCode, ErrCodeInadequateSecurity; got != want { - t.Errorf("Got error code %v; want %v", got, want) - } -} - -func TestServer_Advertises_Common_Cipher(t *testing.T) { - const requiredSuite = tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 - st := newServerTester(t, nil, func(c *tls.Config) { - // Have the client only support the one required by the spec. - c.CipherSuites = []uint16{requiredSuite} - }, func(ts *httptest.Server) { - var srv *http.Server = ts.Config - // Have the server configured with no specific cipher suites. - // This tests that Go's defaults include the required one. - srv.TLSConfig = nil - }) - defer st.Close() - st.greet() -} - -func (st *serverTester) onHeaderField(f hpack.HeaderField) { - if f.Name == "date" { - return - } - st.decodedHeaders = append(st.decodedHeaders, [2]string{f.Name, f.Value}) -} - -func (st *serverTester) decodeHeader(headerBlock []byte) (pairs [][2]string) { - st.decodedHeaders = nil - if _, err := st.hpackDec.Write(headerBlock); err != nil { - st.t.Fatalf("hpack decoding error: %v", err) - } - if err := st.hpackDec.Close(); err != nil { - st.t.Fatalf("hpack decoding error: %v", err) - } - return st.decodedHeaders -} - -// testServerResponse sets up an idle HTTP/2 connection. The client function should -// write a single request that must be handled by the handler. This waits up to 5s -// for client to return, then up to an additional 2s for the handler to return. -func testServerResponse(t testing.TB, - handler func(http.ResponseWriter, *http.Request) error, - client func(*serverTester), -) { - errc := make(chan error, 1) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - if r.Body == nil { - t.Fatal("nil Body") - } - errc <- handler(w, r) - }) - defer st.Close() - - donec := make(chan bool) - go func() { - defer close(donec) - st.greet() - client(st) - }() - - select { - case <-donec: - case <-time.After(5 * time.Second): - t.Fatal("timeout in client") - } - - select { - case err := <-errc: - if err != nil { - t.Fatalf("Error in handler: %v", err) - } - case <-time.After(2 * time.Second): - t.Fatal("timeout in handler") - } -} - -// readBodyHandler returns an http Handler func that reads len(want) -// bytes from r.Body and fails t if the contents read were not -// the value of want. -func readBodyHandler(t *testing.T, want string) func(w http.ResponseWriter, r *http.Request) { - return func(w http.ResponseWriter, r *http.Request) { - buf := make([]byte, len(want)) - _, err := io.ReadFull(r.Body, buf) - if err != nil { - t.Error(err) - return - } - if string(buf) != want { - t.Errorf("read %q; want %q", buf, want) - } - } -} - -// TestServerWithCurl currently fails, hence the LenientCipherSuites test. See: -// https://github.com/tatsuhiro-t/nghttp2/issues/140 & -// http://sourceforge.net/p/curl/bugs/1472/ -func TestServerWithCurl(t *testing.T) { testServerWithCurl(t, false) } -func TestServerWithCurl_LenientCipherSuites(t *testing.T) { testServerWithCurl(t, true) } - -func testServerWithCurl(t *testing.T, permitProhibitedCipherSuites bool) { - if runtime.GOOS != "linux" { - t.Skip("skipping Docker test when not on Linux; requires --net which won't work with boot2docker anyway") - } - if testing.Short() { - t.Skip("skipping curl test in short mode") - } - requireCurl(t) - var gotConn int32 - testHookOnConn = func() { atomic.StoreInt32(&gotConn, 1) } - - const msg = "Hello from curl!\n" - ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Foo", "Bar") - w.Header().Set("Client-Proto", r.Proto) - io.WriteString(w, msg) - })) - ConfigureServer(ts.Config, &Server{ - PermitProhibitedCipherSuites: permitProhibitedCipherSuites, - }) - ts.TLS = ts.Config.TLSConfig // the httptest.Server has its own copy of this TLS config - ts.StartTLS() - defer ts.Close() - - t.Logf("Running test server for curl to hit at: %s", ts.URL) - container := curl(t, "--silent", "--http2", "--insecure", "-v", ts.URL) - defer kill(container) - resc := make(chan interface{}, 1) - go func() { - res, err := dockerLogs(container) - if err != nil { - resc <- err - } else { - resc <- res - } - }() - select { - case res := <-resc: - if err, ok := res.(error); ok { - t.Fatal(err) - } - body := string(res.([]byte)) - // Search for both "key: value" and "key:value", since curl changed their format - // Our Dockerfile contains the latest version (no space), but just in case people - // didn't rebuild, check both. - if !strings.Contains(body, "foo: Bar") && !strings.Contains(body, "foo:Bar") { - t.Errorf("didn't see foo: Bar header") - t.Logf("Got: %s", body) - } - if !strings.Contains(body, "client-proto: HTTP/2") && !strings.Contains(body, "client-proto:HTTP/2") { - t.Errorf("didn't see client-proto: HTTP/2 header") - t.Logf("Got: %s", res) - } - if !strings.Contains(string(res.([]byte)), msg) { - t.Errorf("didn't see %q content", msg) - t.Logf("Got: %s", res) - } - case <-time.After(3 * time.Second): - t.Errorf("timeout waiting for curl") - } - - if atomic.LoadInt32(&gotConn) == 0 { - t.Error("never saw an http2 connection") - } -} - -var doh2load = flag.Bool("h2load", false, "Run h2load test") - -func TestServerWithH2Load(t *testing.T) { - if !*doh2load { - t.Skip("Skipping without --h2load flag.") - } - if runtime.GOOS != "linux" { - t.Skip("skipping Docker test when not on Linux; requires --net which won't work with boot2docker anyway") - } - requireH2load(t) - - msg := strings.Repeat("Hello, h2load!\n", 5000) - ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, msg) - w.(http.Flusher).Flush() - io.WriteString(w, msg) - })) - ts.StartTLS() - defer ts.Close() - - cmd := exec.Command("docker", "run", "--net=host", "--entrypoint=/usr/local/bin/h2load", "gohttp2/curl", - "-n100000", "-c100", "-m100", ts.URL) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - if err := cmd.Run(); err != nil { - t.Fatal(err) - } -} - -// Issue 12843 -func TestServerDoS_MaxHeaderListSize(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) {}) - defer st.Close() - - // shake hands - frameSize := defaultMaxReadFrameSize - var advHeaderListSize *uint32 - st.greetAndCheckSettings(func(s Setting) error { - switch s.ID { - case SettingMaxFrameSize: - if s.Val < minMaxFrameSize { - frameSize = minMaxFrameSize - } else if s.Val > maxFrameSize { - frameSize = maxFrameSize - } else { - frameSize = int(s.Val) - } - case SettingMaxHeaderListSize: - advHeaderListSize = &s.Val - } - return nil - }) - - if advHeaderListSize == nil { - t.Errorf("server didn't advertise a max header list size") - } else if *advHeaderListSize == 0 { - t.Errorf("server advertised a max header list size of 0") - } - - st.encodeHeaderField(":method", "GET") - st.encodeHeaderField(":path", "/") - st.encodeHeaderField(":scheme", "https") - cookie := strings.Repeat("*", 4058) - st.encodeHeaderField("cookie", cookie) - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.headerBuf.Bytes(), - EndStream: true, - EndHeaders: false, - }) - - // Capture the short encoding of a duplicate ~4K cookie, now - // that we've already sent it once. - st.headerBuf.Reset() - st.encodeHeaderField("cookie", cookie) - - // Now send 1MB of it. - const size = 1 << 20 - b := bytes.Repeat(st.headerBuf.Bytes(), size/st.headerBuf.Len()) - for len(b) > 0 { - chunk := b - if len(chunk) > frameSize { - chunk = chunk[:frameSize] - } - b = b[len(chunk):] - st.fr.WriteContinuation(1, len(b) == 0, chunk) - } - - h := st.wantHeaders() - if !h.HeadersEnded() { - t.Fatalf("Got HEADERS without END_HEADERS set: %v", h) - } - headers := st.decodeHeader(h.HeaderBlockFragment()) - want := [][2]string{ - {":status", "431"}, - {"content-type", "text/html; charset=utf-8"}, - {"content-length", "63"}, - } - if !reflect.DeepEqual(headers, want) { - t.Errorf("Headers mismatch.\n got: %q\nwant: %q\n", headers, want) - } -} - -func TestCompressionErrorOnWrite(t *testing.T) { - const maxStrLen = 8 << 10 - var serverConfig *http.Server - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - // No response body. - }, func(ts *httptest.Server) { - serverConfig = ts.Config - serverConfig.MaxHeaderBytes = maxStrLen - }) - st.addLogFilter("connection error: COMPRESSION_ERROR") - defer st.Close() - st.greet() - - maxAllowed := st.sc.framer.maxHeaderStringLen() - - // Crank this up, now that we have a conn connected with the - // hpack.Decoder's max string length set has been initialized - // from the earlier low ~8K value. We want this higher so don't - // hit the max header list size. We only want to test hitting - // the max string size. - serverConfig.MaxHeaderBytes = 1 << 20 - - // First a request with a header that's exactly the max allowed size - // for the hpack compression. It's still too long for the header list - // size, so we'll get the 431 error, but that keeps the compression - // context still valid. - hbf := st.encodeHeader("foo", strings.Repeat("a", maxAllowed)) - - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: hbf, - EndStream: true, - EndHeaders: true, - }) - h := st.wantHeaders() - if !h.HeadersEnded() { - t.Fatalf("Got HEADERS without END_HEADERS set: %v", h) - } - headers := st.decodeHeader(h.HeaderBlockFragment()) - want := [][2]string{ - {":status", "431"}, - {"content-type", "text/html; charset=utf-8"}, - {"content-length", "63"}, - } - if !reflect.DeepEqual(headers, want) { - t.Errorf("Headers mismatch.\n got: %q\nwant: %q\n", headers, want) - } - df := st.wantData() - if !strings.Contains(string(df.Data()), "HTTP Error 431") { - t.Errorf("Unexpected data body: %q", df.Data()) - } - if !df.StreamEnded() { - t.Fatalf("expect data stream end") - } - - // And now send one that's just one byte too big. - hbf = st.encodeHeader("bar", strings.Repeat("b", maxAllowed+1)) - st.writeHeaders(HeadersFrameParam{ - StreamID: 3, - BlockFragment: hbf, - EndStream: true, - EndHeaders: true, - }) - ga := st.wantGoAway() - if ga.ErrCode != ErrCodeCompression { - t.Errorf("GOAWAY err = %v; want ErrCodeCompression", ga.ErrCode) - } -} - -func TestCompressionErrorOnClose(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - // No response body. - }) - st.addLogFilter("connection error: COMPRESSION_ERROR") - defer st.Close() - st.greet() - - hbf := st.encodeHeader("foo", "bar") - hbf = hbf[:len(hbf)-1] // truncate one byte from the end, so hpack.Decoder.Close fails. - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: hbf, - EndStream: true, - EndHeaders: true, - }) - ga := st.wantGoAway() - if ga.ErrCode != ErrCodeCompression { - t.Errorf("GOAWAY err = %v; want ErrCodeCompression", ga.ErrCode) - } -} - -// test that a server handler can read trailers from a client -func TestServerReadsTrailers(t *testing.T) { - const testBody = "some test body" - writeReq := func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader("trailer", "Foo, Bar", "trailer", "Baz"), - EndStream: false, - EndHeaders: true, - }) - st.writeData(1, false, []byte(testBody)) - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeaderRaw( - "foo", "foov", - "bar", "barv", - "baz", "bazv", - "surprise", "wasn't declared; shouldn't show up", - ), - EndStream: true, - EndHeaders: true, - }) - } - checkReq := func(r *http.Request) { - wantTrailer := http.Header{ - "Foo": nil, - "Bar": nil, - "Baz": nil, - } - if !reflect.DeepEqual(r.Trailer, wantTrailer) { - t.Errorf("initial Trailer = %v; want %v", r.Trailer, wantTrailer) - } - slurp, err := ioutil.ReadAll(r.Body) - if string(slurp) != testBody { - t.Errorf("read body %q; want %q", slurp, testBody) - } - if err != nil { - t.Fatalf("Body slurp: %v", err) - } - wantTrailerAfter := http.Header{ - "Foo": {"foov"}, - "Bar": {"barv"}, - "Baz": {"bazv"}, - } - if !reflect.DeepEqual(r.Trailer, wantTrailerAfter) { - t.Errorf("final Trailer = %v; want %v", r.Trailer, wantTrailerAfter) - } - } - testServerRequest(t, writeReq, checkReq) -} - -// test that a server handler can send trailers -func TestServerWritesTrailers_WithFlush(t *testing.T) { testServerWritesTrailers(t, true) } -func TestServerWritesTrailers_WithoutFlush(t *testing.T) { testServerWritesTrailers(t, false) } - -func testServerWritesTrailers(t *testing.T, withFlush bool) { - // See https://httpwg.github.io/specs/rfc7540.html#rfc.section.8.1.3 - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.Header().Set("Trailer", "Server-Trailer-A, Server-Trailer-B") - w.Header().Add("Trailer", "Server-Trailer-C") - w.Header().Add("Trailer", "Transfer-Encoding, Content-Length, Trailer") // filtered - - // Regular headers: - w.Header().Set("Foo", "Bar") - w.Header().Set("Content-Length", "5") // len("Hello") - - io.WriteString(w, "Hello") - if withFlush { - w.(http.Flusher).Flush() - } - w.Header().Set("Server-Trailer-A", "valuea") - w.Header().Set("Server-Trailer-C", "valuec") // skipping B - // After a flush, random keys like Server-Surprise shouldn't show up: - w.Header().Set("Server-Surpise", "surprise! this isn't predeclared!") - // But we do permit promoting keys to trailers after a - // flush if they start with the magic - // otherwise-invalid "Trailer:" prefix: - w.Header().Set("Trailer:Post-Header-Trailer", "hi1") - w.Header().Set("Trailer:post-header-trailer2", "hi2") - w.Header().Set("Trailer:Range", "invalid") - w.Header().Set("Trailer:Foo\x01Bogus", "invalid") - w.Header().Set("Transfer-Encoding", "should not be included; Forbidden by RFC 2616 14.40") - w.Header().Set("Content-Length", "should not be included; Forbidden by RFC 2616 14.40") - w.Header().Set("Trailer", "should not be included; Forbidden by RFC 2616 14.40") - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("response HEADERS had END_STREAM") - } - if !hf.HeadersEnded() { - t.Fatal("response HEADERS didn't have END_HEADERS") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"foo", "Bar"}, - {"trailer", "Server-Trailer-A, Server-Trailer-B"}, - {"trailer", "Server-Trailer-C"}, - {"trailer", "Transfer-Encoding, Content-Length, Trailer"}, - {"content-type", "text/plain; charset=utf-8"}, - {"content-length", "5"}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Header mismatch.\n got: %v\nwant: %v", goth, wanth) - } - df := st.wantData() - if string(df.Data()) != "Hello" { - t.Fatalf("Client read %q; want Hello", df.Data()) - } - if df.StreamEnded() { - t.Fatalf("data frame had STREAM_ENDED") - } - tf := st.wantHeaders() // for the trailers - if !tf.StreamEnded() { - t.Fatalf("trailers HEADERS lacked END_STREAM") - } - if !tf.HeadersEnded() { - t.Fatalf("trailers HEADERS lacked END_HEADERS") - } - wanth = [][2]string{ - {"post-header-trailer", "hi1"}, - {"post-header-trailer2", "hi2"}, - {"server-trailer-a", "valuea"}, - {"server-trailer-c", "valuec"}, - } - goth = st.decodeHeader(tf.HeaderBlockFragment()) - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Header mismatch.\n got: %v\nwant: %v", goth, wanth) - } - }) -} - -// validate transmitted header field names & values -// golang.org/issue/14048 -func TestServerDoesntWriteInvalidHeaders(t *testing.T) { - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.Header().Add("OK1", "x") - w.Header().Add("Bad:Colon", "x") // colon (non-token byte) in key - w.Header().Add("Bad1\x00", "x") // null in key - w.Header().Add("Bad2", "x\x00y") // null in value - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if !hf.StreamEnded() { - t.Error("response HEADERS lacked END_STREAM") - } - if !hf.HeadersEnded() { - t.Fatal("response HEADERS didn't have END_HEADERS") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"ok1", "x"}, - {"content-type", "text/plain; charset=utf-8"}, - {"content-length", "0"}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Header mismatch.\n got: %v\nwant: %v", goth, wanth) - } - }) -} - -func BenchmarkServerGets(b *testing.B) { - defer disableGoroutineTracking()() - b.ReportAllocs() - - const msg = "Hello, world" - st := newServerTester(b, func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, msg) - }) - defer st.Close() - st.greet() - - // Give the server quota to reply. (plus it has the the 64KB) - if err := st.fr.WriteWindowUpdate(0, uint32(b.N*len(msg))); err != nil { - b.Fatal(err) - } - - for i := 0; i < b.N; i++ { - id := 1 + uint32(i)*2 - st.writeHeaders(HeadersFrameParam{ - StreamID: id, - BlockFragment: st.encodeHeader(), - EndStream: true, - EndHeaders: true, - }) - st.wantHeaders() - df := st.wantData() - if !df.StreamEnded() { - b.Fatalf("DATA didn't have END_STREAM; got %v", df) - } - } -} - -func BenchmarkServerPosts(b *testing.B) { - defer disableGoroutineTracking()() - b.ReportAllocs() - - const msg = "Hello, world" - st := newServerTester(b, func(w http.ResponseWriter, r *http.Request) { - // Consume the (empty) body from th peer before replying, otherwise - // the server will sometimes (depending on scheduling) send the peer a - // a RST_STREAM with the CANCEL error code. - if n, err := io.Copy(ioutil.Discard, r.Body); n != 0 || err != nil { - b.Errorf("Copy error; got %v, %v; want 0, nil", n, err) - } - io.WriteString(w, msg) - }) - defer st.Close() - st.greet() - - // Give the server quota to reply. (plus it has the the 64KB) - if err := st.fr.WriteWindowUpdate(0, uint32(b.N*len(msg))); err != nil { - b.Fatal(err) - } - - for i := 0; i < b.N; i++ { - id := 1 + uint32(i)*2 - st.writeHeaders(HeadersFrameParam{ - StreamID: id, - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: false, - EndHeaders: true, - }) - st.writeData(id, true, nil) - st.wantHeaders() - df := st.wantData() - if !df.StreamEnded() { - b.Fatalf("DATA didn't have END_STREAM; got %v", df) - } - } -} - -// Send a stream of messages from server to client in separate data frames. -// Brings up performance issues seen in long streams. -// Created to show problem in go issue #18502 -func BenchmarkServerToClientStreamDefaultOptions(b *testing.B) { - benchmarkServerToClientStream(b) -} - -// Justification for Change-Id: Iad93420ef6c3918f54249d867098f1dadfa324d8 -// Expect to see memory/alloc reduction by opting in to Frame reuse with the Framer. -func BenchmarkServerToClientStreamReuseFrames(b *testing.B) { - benchmarkServerToClientStream(b, optFramerReuseFrames) -} - -func benchmarkServerToClientStream(b *testing.B, newServerOpts ...interface{}) { - defer disableGoroutineTracking()() - b.ReportAllocs() - const msgLen = 1 - // default window size - const windowSize = 1<<16 - 1 - - // next message to send from the server and for the client to expect - nextMsg := func(i int) []byte { - msg := make([]byte, msgLen) - msg[0] = byte(i) - if len(msg) != msgLen { - panic("invalid test setup msg length") - } - return msg - } - - st := newServerTester(b, func(w http.ResponseWriter, r *http.Request) { - // Consume the (empty) body from th peer before replying, otherwise - // the server will sometimes (depending on scheduling) send the peer a - // a RST_STREAM with the CANCEL error code. - if n, err := io.Copy(ioutil.Discard, r.Body); n != 0 || err != nil { - b.Errorf("Copy error; got %v, %v; want 0, nil", n, err) - } - for i := 0; i < b.N; i += 1 { - w.Write(nextMsg(i)) - w.(http.Flusher).Flush() - } - }, newServerOpts...) - defer st.Close() - st.greet() - - const id = uint32(1) - - st.writeHeaders(HeadersFrameParam{ - StreamID: id, - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: false, - EndHeaders: true, - }) - - st.writeData(id, true, nil) - st.wantHeaders() - - var pendingWindowUpdate = uint32(0) - - for i := 0; i < b.N; i += 1 { - expected := nextMsg(i) - df := st.wantData() - if bytes.Compare(expected, df.data) != 0 { - b.Fatalf("Bad message received; want %v; got %v", expected, df.data) - } - // try to send infrequent but large window updates so they don't overwhelm the test - pendingWindowUpdate += uint32(len(df.data)) - if pendingWindowUpdate >= windowSize/2 { - if err := st.fr.WriteWindowUpdate(0, pendingWindowUpdate); err != nil { - b.Fatal(err) - } - if err := st.fr.WriteWindowUpdate(id, pendingWindowUpdate); err != nil { - b.Fatal(err) - } - pendingWindowUpdate = 0 - } - } - df := st.wantData() - if !df.StreamEnded() { - b.Fatalf("DATA didn't have END_STREAM; got %v", df) - } -} - -// go-fuzz bug, originally reported at https://github.com/bradfitz/http2/issues/53 -// Verify we don't hang. -func TestIssue53(t *testing.T) { - const data = "PRI * HTTP/2.0\r\n\r\nSM" + - "\r\n\r\n\x00\x00\x00\x01\ainfinfin\ad" - s := &http.Server{ - ErrorLog: log.New(io.MultiWriter(stderrv(), twriter{t: t}), "", log.LstdFlags), - Handler: http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - w.Write([]byte("hello")) - }), - } - s2 := &Server{ - MaxReadFrameSize: 1 << 16, - PermitProhibitedCipherSuites: true, - } - c := &issue53Conn{[]byte(data), false, false} - s2.ServeConn(c, &ServeConnOpts{BaseConfig: s}) - if !c.closed { - t.Fatal("connection is not closed") - } -} - -type issue53Conn struct { - data []byte - closed bool - written bool -} - -func (c *issue53Conn) Read(b []byte) (n int, err error) { - if len(c.data) == 0 { - return 0, io.EOF - } - n = copy(b, c.data) - c.data = c.data[n:] - return -} - -func (c *issue53Conn) Write(b []byte) (n int, err error) { - c.written = true - return len(b), nil -} - -func (c *issue53Conn) Close() error { - c.closed = true - return nil -} - -func (c *issue53Conn) LocalAddr() net.Addr { - return &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 49706} -} -func (c *issue53Conn) RemoteAddr() net.Addr { - return &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 49706} -} -func (c *issue53Conn) SetDeadline(t time.Time) error { return nil } -func (c *issue53Conn) SetReadDeadline(t time.Time) error { return nil } -func (c *issue53Conn) SetWriteDeadline(t time.Time) error { return nil } - -// golang.org/issue/12895 -func TestConfigureServer(t *testing.T) { - tests := []struct { - name string - tlsConfig *tls.Config - wantErr string - }{ - { - name: "empty server", - }, - { - name: "just the required cipher suite", - tlsConfig: &tls.Config{ - CipherSuites: []uint16{tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, - }, - }, - { - name: "missing required cipher suite", - tlsConfig: &tls.Config{ - CipherSuites: []uint16{tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, - }, - wantErr: "is missing HTTP/2-required TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", - }, - { - name: "required after bad", - tlsConfig: &tls.Config{ - CipherSuites: []uint16{tls.TLS_RSA_WITH_RC4_128_SHA, tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, - }, - wantErr: "contains an HTTP/2-approved cipher suite (0xc02f), but it comes after", - }, - { - name: "bad after required", - tlsConfig: &tls.Config{ - CipherSuites: []uint16{tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, tls.TLS_RSA_WITH_RC4_128_SHA}, - }, - }, - } - for _, tt := range tests { - srv := &http.Server{TLSConfig: tt.tlsConfig} - err := ConfigureServer(srv, nil) - if (err != nil) != (tt.wantErr != "") { - if tt.wantErr != "" { - t.Errorf("%s: success, but want error", tt.name) - } else { - t.Errorf("%s: unexpected error: %v", tt.name, err) - } - } - if err != nil && tt.wantErr != "" && !strings.Contains(err.Error(), tt.wantErr) { - t.Errorf("%s: err = %v; want substring %q", tt.name, err, tt.wantErr) - } - if err == nil && !srv.TLSConfig.PreferServerCipherSuites { - t.Errorf("%s: PreferServerCipherSuite is false; want true", tt.name) - } - } -} - -func TestServerRejectHeadWithBody(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - // No response body. - }) - defer st.Close() - st.greet() - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":method", "HEAD"), - EndStream: false, // what we're testing, a bogus HEAD request with body - EndHeaders: true, - }) - st.wantRSTStream(1, ErrCodeProtocol) -} - -func TestServerNoAutoContentLengthOnHead(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - // No response body. (or smaller than one frame) - }) - defer st.Close() - st.greet() - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":method", "HEAD"), - EndStream: true, - EndHeaders: true, - }) - h := st.wantHeaders() - headers := st.decodeHeader(h.HeaderBlockFragment()) - want := [][2]string{ - {":status", "200"}, - {"content-type", "text/plain; charset=utf-8"}, - } - if !reflect.DeepEqual(headers, want) { - t.Errorf("Headers mismatch.\n got: %q\nwant: %q\n", headers, want) - } -} - -// golang.org/issue/13495 -func TestServerNoDuplicateContentType(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - w.Header()["Content-Type"] = []string{""} - fmt.Fprintf(w, "hi") - }) - defer st.Close() - st.greet() - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(), - EndStream: true, - EndHeaders: true, - }) - h := st.wantHeaders() - headers := st.decodeHeader(h.HeaderBlockFragment()) - want := [][2]string{ - {":status", "200"}, - {"content-type", ""}, - {"content-length", "41"}, - } - if !reflect.DeepEqual(headers, want) { - t.Errorf("Headers mismatch.\n got: %q\nwant: %q\n", headers, want) - } -} - -func disableGoroutineTracking() (restore func()) { - old := DebugGoroutines - DebugGoroutines = false - return func() { DebugGoroutines = old } -} - -func BenchmarkServer_GetRequest(b *testing.B) { - defer disableGoroutineTracking()() - b.ReportAllocs() - const msg = "Hello, world." - st := newServerTester(b, func(w http.ResponseWriter, r *http.Request) { - n, err := io.Copy(ioutil.Discard, r.Body) - if err != nil || n > 0 { - b.Errorf("Read %d bytes, error %v; want 0 bytes.", n, err) - } - io.WriteString(w, msg) - }) - defer st.Close() - - st.greet() - // Give the server quota to reply. (plus it has the the 64KB) - if err := st.fr.WriteWindowUpdate(0, uint32(b.N*len(msg))); err != nil { - b.Fatal(err) - } - hbf := st.encodeHeader(":method", "GET") - for i := 0; i < b.N; i++ { - streamID := uint32(1 + 2*i) - st.writeHeaders(HeadersFrameParam{ - StreamID: streamID, - BlockFragment: hbf, - EndStream: true, - EndHeaders: true, - }) - st.wantHeaders() - st.wantData() - } -} - -func BenchmarkServer_PostRequest(b *testing.B) { - defer disableGoroutineTracking()() - b.ReportAllocs() - const msg = "Hello, world." - st := newServerTester(b, func(w http.ResponseWriter, r *http.Request) { - n, err := io.Copy(ioutil.Discard, r.Body) - if err != nil || n > 0 { - b.Errorf("Read %d bytes, error %v; want 0 bytes.", n, err) - } - io.WriteString(w, msg) - }) - defer st.Close() - st.greet() - // Give the server quota to reply. (plus it has the the 64KB) - if err := st.fr.WriteWindowUpdate(0, uint32(b.N*len(msg))); err != nil { - b.Fatal(err) - } - hbf := st.encodeHeader(":method", "POST") - for i := 0; i < b.N; i++ { - streamID := uint32(1 + 2*i) - st.writeHeaders(HeadersFrameParam{ - StreamID: streamID, - BlockFragment: hbf, - EndStream: false, - EndHeaders: true, - }) - st.writeData(streamID, true, nil) - st.wantHeaders() - st.wantData() - } -} - -type connStateConn struct { - net.Conn - cs tls.ConnectionState -} - -func (c connStateConn) ConnectionState() tls.ConnectionState { return c.cs } - -// golang.org/issue/12737 -- handle any net.Conn, not just -// *tls.Conn. -func TestServerHandleCustomConn(t *testing.T) { - var s Server - c1, c2 := net.Pipe() - clientDone := make(chan struct{}) - handlerDone := make(chan struct{}) - var req *http.Request - go func() { - defer close(clientDone) - defer c2.Close() - fr := NewFramer(c2, c2) - io.WriteString(c2, ClientPreface) - fr.WriteSettings() - fr.WriteSettingsAck() - f, err := fr.ReadFrame() - if err != nil { - t.Error(err) - return - } - if sf, ok := f.(*SettingsFrame); !ok || sf.IsAck() { - t.Errorf("Got %v; want non-ACK SettingsFrame", summarizeFrame(f)) - return - } - f, err = fr.ReadFrame() - if err != nil { - t.Error(err) - return - } - if sf, ok := f.(*SettingsFrame); !ok || !sf.IsAck() { - t.Errorf("Got %v; want ACK SettingsFrame", summarizeFrame(f)) - return - } - var henc hpackEncoder - fr.WriteHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: henc.encodeHeaderRaw(t, ":method", "GET", ":path", "/", ":scheme", "https", ":authority", "foo.com"), - EndStream: true, - EndHeaders: true, - }) - go io.Copy(ioutil.Discard, c2) - <-handlerDone - }() - const testString = "my custom ConnectionState" - fakeConnState := tls.ConnectionState{ - ServerName: testString, - Version: tls.VersionTLS12, - } - go s.ServeConn(connStateConn{c1, fakeConnState}, &ServeConnOpts{ - BaseConfig: &http.Server{ - Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - defer close(handlerDone) - req = r - }), - }}) - select { - case <-clientDone: - case <-time.After(5 * time.Second): - t.Fatal("timeout waiting for handler") - } - if req.TLS == nil { - t.Fatalf("Request.TLS is nil. Got: %#v", req) - } - if req.TLS.ServerName != testString { - t.Fatalf("Request.TLS = %+v; want ServerName of %q", req.TLS, testString) - } -} - -// golang.org/issue/14214 -func TestServer_Rejects_ConnHeaders(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - t.Error("should not get to Handler") - }) - defer st.Close() - st.greet() - st.bodylessReq1("connection", "foo") - hf := st.wantHeaders() - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "400"}, - {"content-type", "text/plain; charset=utf-8"}, - {"x-content-type-options", "nosniff"}, - {"content-length", "51"}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } -} - -type hpackEncoder struct { - enc *hpack.Encoder - buf bytes.Buffer -} - -func (he *hpackEncoder) encodeHeaderRaw(t *testing.T, headers ...string) []byte { - if len(headers)%2 == 1 { - panic("odd number of kv args") - } - he.buf.Reset() - if he.enc == nil { - he.enc = hpack.NewEncoder(&he.buf) - } - for len(headers) > 0 { - k, v := headers[0], headers[1] - err := he.enc.WriteField(hpack.HeaderField{Name: k, Value: v}) - if err != nil { - t.Fatalf("HPACK encoding error for %q/%q: %v", k, v, err) - } - headers = headers[2:] - } - return he.buf.Bytes() -} - -func TestCheckValidHTTP2Request(t *testing.T) { - tests := []struct { - h http.Header - want error - }{ - { - h: http.Header{"Te": {"trailers"}}, - want: nil, - }, - { - h: http.Header{"Te": {"trailers", "bogus"}}, - want: errors.New(`request header "TE" may only be "trailers" in HTTP/2`), - }, - { - h: http.Header{"Foo": {""}}, - want: nil, - }, - { - h: http.Header{"Connection": {""}}, - want: errors.New(`request header "Connection" is not valid in HTTP/2`), - }, - { - h: http.Header{"Proxy-Connection": {""}}, - want: errors.New(`request header "Proxy-Connection" is not valid in HTTP/2`), - }, - { - h: http.Header{"Keep-Alive": {""}}, - want: errors.New(`request header "Keep-Alive" is not valid in HTTP/2`), - }, - { - h: http.Header{"Upgrade": {""}}, - want: errors.New(`request header "Upgrade" is not valid in HTTP/2`), - }, - } - for i, tt := range tests { - got := checkValidHTTP2RequestHeaders(tt.h) - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("%d. checkValidHTTP2Request = %v; want %v", i, got, tt.want) - } - } -} - -// golang.org/issue/14030 -func TestExpect100ContinueAfterHandlerWrites(t *testing.T) { - const msg = "Hello" - const msg2 = "World" - - doRead := make(chan bool, 1) - defer close(doRead) // fallback cleanup - - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, msg) - w.(http.Flusher).Flush() - - // Do a read, which might force a 100-continue status to be sent. - <-doRead - r.Body.Read(make([]byte, 10)) - - io.WriteString(w, msg2) - - }, optOnlyServer) - defer st.Close() - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - - req, _ := http.NewRequest("POST", st.ts.URL, io.LimitReader(neverEnding('A'), 2<<20)) - req.Header.Set("Expect", "100-continue") - - res, err := tr.RoundTrip(req) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - - buf := make([]byte, len(msg)) - if _, err := io.ReadFull(res.Body, buf); err != nil { - t.Fatal(err) - } - if string(buf) != msg { - t.Fatalf("msg = %q; want %q", buf, msg) - } - - doRead <- true - - if _, err := io.ReadFull(res.Body, buf); err != nil { - t.Fatal(err) - } - if string(buf) != msg2 { - t.Fatalf("second msg = %q; want %q", buf, msg2) - } -} - -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() - } - -} - -func TestServerIdleTimeout(t *testing.T) { - if testing.Short() { - t.Skip("skipping in short mode") - } - - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - }, func(h2s *Server) { - h2s.IdleTimeout = 500 * time.Millisecond - }) - defer st.Close() - - st.greet() - ga := st.wantGoAway() - if ga.ErrCode != ErrCodeNo { - t.Errorf("GOAWAY error = %v; want ErrCodeNo", ga.ErrCode) - } -} - -func TestServerIdleTimeout_AfterRequest(t *testing.T) { - if testing.Short() { - t.Skip("skipping in short mode") - } - const timeout = 250 * time.Millisecond - - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - time.Sleep(timeout * 2) - }, func(h2s *Server) { - h2s.IdleTimeout = timeout - }) - defer st.Close() - - st.greet() - - // Send a request which takes twice the timeout. Verifies the - // idle timeout doesn't fire while we're in a request: - st.bodylessReq1() - st.wantHeaders() - - // But the idle timeout should be rearmed after the request - // is done: - ga := st.wantGoAway() - if ga.ErrCode != ErrCodeNo { - t.Errorf("GOAWAY error = %v; want ErrCodeNo", ga.ErrCode) - } -} - -// grpc-go closes the Request.Body currently with a Read. -// Verify that it doesn't race. -// See https://github.com/grpc/grpc-go/pull/938 -func TestRequestBodyReadCloseRace(t *testing.T) { - for i := 0; i < 100; i++ { - body := &requestBody{ - pipe: &pipe{ - b: new(bytes.Buffer), - }, - } - body.pipe.CloseWithError(io.EOF) - - done := make(chan bool, 1) - buf := make([]byte, 10) - go func() { - time.Sleep(1 * time.Millisecond) - body.Close() - done <- true - }() - body.Read(buf) - <-done - } -} - -func TestServerGracefulShutdown(t *testing.T) { - shutdownCh := make(chan struct{}) - defer func() { testh1ServerShutdownChan = nil }() - testh1ServerShutdownChan = func(*http.Server) <-chan struct{} { return shutdownCh } - - var st *serverTester - handlerDone := make(chan struct{}) - st = newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - defer close(handlerDone) - close(shutdownCh) - - ga := st.wantGoAway() - if ga.ErrCode != ErrCodeNo { - t.Errorf("GOAWAY error = %v; want ErrCodeNo", ga.ErrCode) - } - if ga.LastStreamID != 1 { - t.Errorf("GOAWAY LastStreamID = %v; want 1", ga.LastStreamID) - } - - w.Header().Set("x-foo", "bar") - }) - defer st.Close() - - st.greet() - st.bodylessReq1() - - <-handlerDone - hf := st.wantHeaders() - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"x-foo", "bar"}, - {"content-type", "text/plain; charset=utf-8"}, - {"content-length", "0"}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - - n, err := st.cc.Read([]byte{0}) - if n != 0 || err == nil { - t.Errorf("Read = %v, %v; want 0, non-nil", n, err) - } -} diff --git a/vendor/golang.org/x/net/http2/testdata/draft-ietf-httpbis-http2.xml b/vendor/golang.org/x/net/http2/testdata/draft-ietf-httpbis-http2.xml deleted file mode 100644 index 31a84bed4..000000000 --- a/vendor/golang.org/x/net/http2/testdata/draft-ietf-httpbis-http2.xml +++ /dev/null @@ -1,5021 +0,0 @@ - - - - - - - - - - - - - - - - - - - Hypertext Transfer Protocol version 2 - - - Twist -
    - mbelshe@chromium.org -
    -
    - - - Google, Inc -
    - fenix@google.com -
    -
    - - - Mozilla -
    - - 331 E Evelyn Street - Mountain View - CA - 94041 - US - - martin.thomson@gmail.com -
    -
    - - - Applications - HTTPbis - HTTP - SPDY - Web - - - - This specification describes an optimized expression of the semantics of the Hypertext - Transfer Protocol (HTTP). HTTP/2 enables a more efficient use of network resources and a - reduced perception of latency by introducing header field compression and allowing multiple - concurrent messages on the same connection. It also introduces unsolicited push of - representations from servers to clients. - - - This specification is an alternative to, but does not obsolete, the HTTP/1.1 message syntax. - HTTP's existing semantics remain unchanged. - - - - - - Discussion of this draft takes place on the HTTPBIS working group mailing list - (ietf-http-wg@w3.org), which is archived at . - - - Working Group information can be found at ; that specific to HTTP/2 are at . - - - The changes in this draft are summarized in . - - - -
    - - -
    - - - The Hypertext Transfer Protocol (HTTP) is a wildly successful protocol. However, the - HTTP/1.1 message format () has - several characteristics that have a negative overall effect on application performance - today. - - - In particular, HTTP/1.0 allowed only one request to be outstanding at a time on a given - TCP connection. HTTP/1.1 added request pipelining, but this only partially addressed - request concurrency and still suffers from head-of-line blocking. Therefore, HTTP/1.1 - clients that need to make many requests typically use multiple connections to a server in - order to achieve concurrency and thereby reduce latency. - - - Furthermore, HTTP header fields are often repetitive and verbose, causing unnecessary - network traffic, as well as causing the initial TCP congestion - window to quickly fill. This can result in excessive latency when multiple requests are - made on a new TCP connection. - - - HTTP/2 addresses these issues by defining an optimized mapping of HTTP's semantics to an - underlying connection. Specifically, it allows interleaving of request and response - messages on the same connection and uses an efficient coding for HTTP header fields. It - also allows prioritization of requests, letting more important requests complete more - quickly, further improving performance. - - - The resulting protocol is more friendly to the network, because fewer TCP connections can - be used in comparison to HTTP/1.x. This means less competition with other flows, and - longer-lived connections, which in turn leads to better utilization of available network - capacity. - - - Finally, HTTP/2 also enables more efficient processing of messages through use of binary - message framing. - -
    - -
    - - HTTP/2 provides an optimized transport for HTTP semantics. HTTP/2 supports all of the core - features of HTTP/1.1, but aims to be more efficient in several ways. - - - The basic protocol unit in HTTP/2 is a frame. Each frame - type serves a different purpose. For example, HEADERS and - DATA frames form the basis of HTTP requests and - responses; other frame types like SETTINGS, - WINDOW_UPDATE, and PUSH_PROMISE are used in support of other - HTTP/2 features. - - - Multiplexing of requests is achieved by having each HTTP request-response exchange - associated with its own stream. Streams are largely - independent of each other, so a blocked or stalled request or response does not prevent - progress on other streams. - - - Flow control and prioritization ensure that it is possible to efficiently use multiplexed - streams. Flow control helps to ensure that only data that - can be used by a receiver is transmitted. Prioritization ensures that limited resources can be directed - to the most important streams first. - - - HTTP/2 adds a new interaction mode, whereby a server can push - responses to a client. Server push allows a server to speculatively send a client - data that the server anticipates the client will need, trading off some network usage - against a potential latency gain. The server does this by synthesizing a request, which it - sends as a PUSH_PROMISE frame. The server is then able to send a response to - the synthetic request on a separate stream. - - - Frames that contain HTTP header fields are compressed. - HTTP requests can be highly redundant, so compression can reduce the size of requests and - responses significantly. - - -
    - - The HTTP/2 specification is split into four parts: - - - Starting HTTP/2 covers how an HTTP/2 connection is - initiated. - - - The framing and streams layers describe the way HTTP/2 frames are - structured and formed into multiplexed streams. - - - Frame and error - definitions include details of the frame and error types used in HTTP/2. - - - HTTP mappings and additional - requirements describe how HTTP semantics are expressed using frames and - streams. - - - - - While some of the frame and stream layer concepts are isolated from HTTP, this - specification does not define a completely generic framing layer. The framing and streams - layers are tailored to the needs of the HTTP protocol and server push. - -
    - -
    - - The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD - NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as - described in RFC 2119. - - - All numeric values are in network byte order. Values are unsigned unless otherwise - indicated. Literal values are provided in decimal or hexadecimal as appropriate. - Hexadecimal literals are prefixed with 0x to distinguish them - from decimal literals. - - - The following terms are used: - - - The endpoint initiating the HTTP/2 connection. - - - A transport-layer connection between two endpoints. - - - An error that affects the entire HTTP/2 connection. - - - Either the client or server of the connection. - - - The smallest unit of communication within an HTTP/2 connection, consisting of a header - and a variable-length sequence of octets structured according to the frame type. - - - An endpoint. When discussing a particular endpoint, "peer" refers to the endpoint - that is remote to the primary subject of discussion. - - - An endpoint that is receiving frames. - - - An endpoint that is transmitting frames. - - - The endpoint which did not initiate the HTTP/2 connection. - - - A bi-directional flow of frames across a virtual channel within the HTTP/2 connection. - - - An error on the individual HTTP/2 stream. - - - - - Finally, the terms "gateway", "intermediary", "proxy", and "tunnel" are defined - in . - -
    -
    - -
    - - An HTTP/2 connection is an application layer protocol running on top of a TCP connection - (). The client is the TCP connection initiator. - - - HTTP/2 uses the same "http" and "https" URI schemes used by HTTP/1.1. HTTP/2 shares the same - default port numbers: 80 for "http" URIs and 443 for "https" URIs. As a result, - implementations processing requests for target resource URIs like http://example.org/foo or https://example.com/bar are required to first discover whether the - upstream server (the immediate peer to which the client wishes to establish a connection) - supports HTTP/2. - - - - The means by which support for HTTP/2 is determined is different for "http" and "https" - URIs. Discovery for "http" URIs is described in . Discovery - for "https" URIs is described in . - - -
    - - The protocol defined in this document has two identifiers. - - - - The string "h2" identifies the protocol where HTTP/2 uses TLS. This identifier is used in the TLS application layer protocol negotiation extension (ALPN) - field and any place that HTTP/2 over TLS is identified. - - - The "h2" string is serialized into an ALPN protocol identifier as the two octet - sequence: 0x68, 0x32. - - - - - The string "h2c" identifies the protocol where HTTP/2 is run over cleartext TCP. - This identifier is used in the HTTP/1.1 Upgrade header field and any place that - HTTP/2 over TCP is identified. - - - - - - Negotiating "h2" or "h2c" implies the use of the transport, security, framing and message - semantics described in this document. - - - RFC Editor's Note: please remove the remainder of this section prior to the - publication of a final version of this document. - - - Only implementations of the final, published RFC can identify themselves as "h2" or "h2c". - Until such an RFC exists, implementations MUST NOT identify themselves using these - strings. - - - Examples and text throughout the rest of this document use "h2" as a matter of - editorial convenience only. Implementations of draft versions MUST NOT identify using - this string. - - - Implementations of draft versions of the protocol MUST add the string "-" and the - corresponding draft number to the identifier. For example, draft-ietf-httpbis-http2-11 - over TLS is identified using the string "h2-11". - - - Non-compatible experiments that are based on these draft versions MUST append the string - "-" and an experiment name to the identifier. For example, an experimental implementation - of packet mood-based encoding based on draft-ietf-httpbis-http2-09 might identify itself - as "h2-09-emo". Note that any label MUST conform to the "token" syntax defined in - . Experimenters are - encouraged to coordinate their experiments on the ietf-http-wg@w3.org mailing list. - -
    - -
    - - A client that makes a request for an "http" URI without prior knowledge about support for - HTTP/2 uses the HTTP Upgrade mechanism (). The client makes an HTTP/1.1 request that includes an Upgrade - header field identifying HTTP/2 with the "h2c" token. The HTTP/1.1 request MUST include - exactly one HTTP2-Settings header field. - -
    - For example: - - -]]> -
    - - Requests that contain an entity body MUST be sent in their entirety before the client can - send HTTP/2 frames. This means that a large request entity can block the use of the - connection until it is completely sent. - - - If concurrency of an initial request with subsequent requests is important, an OPTIONS - request can be used to perform the upgrade to HTTP/2, at the cost of an additional - round-trip. - - - A server that does not support HTTP/2 can respond to the request as though the Upgrade - header field were absent: - -
    - -HTTP/1.1 200 OK -Content-Length: 243 -Content-Type: text/html - -... - -
    - - A server MUST ignore a "h2" token in an Upgrade header field. Presence of a token with - "h2" implies HTTP/2 over TLS, which is instead negotiated as described in . - - - A server that supports HTTP/2 can accept the upgrade with a 101 (Switching Protocols) - response. After the empty line that terminates the 101 response, the server can begin - sending HTTP/2 frames. These frames MUST include a response to the request that initiated - the Upgrade. - - -
    - - For example: - - -HTTP/1.1 101 Switching Protocols -Connection: Upgrade -Upgrade: h2c - -[ HTTP/2 connection ... - -
    - - The first HTTP/2 frame sent by the server is a SETTINGS frame () as the server connection preface (). Upon receiving the 101 response, the client sends a connection preface, which includes a - SETTINGS frame. - - - The HTTP/1.1 request that is sent prior to upgrade is assigned stream identifier 1 and is - assigned default priority values. Stream 1 is - implicitly half closed from the client toward the server, since the request is completed - as an HTTP/1.1 request. After commencing the HTTP/2 connection, stream 1 is used for the - response. - - -
    - - A request that upgrades from HTTP/1.1 to HTTP/2 MUST include exactly one HTTP2-Settings header field. The HTTP2-Settings header field is a connection-specific header field - that includes parameters that govern the HTTP/2 connection, provided in anticipation of - the server accepting the request to upgrade. - -
    - -
    - - A server MUST NOT upgrade the connection to HTTP/2 if this header field is not present, - or if more than one is present. A server MUST NOT send this header field. - - - - The content of the HTTP2-Settings header field is the - payload of a SETTINGS frame (), encoded as a - base64url string (that is, the URL- and filename-safe Base64 encoding described in , with any trailing '=' characters omitted). The - ABNF production for token68 is - defined in . - - - Since the upgrade is only intended to apply to the immediate connection, a client - sending HTTP2-Settings MUST also send HTTP2-Settings as a connection option in the Connection header field to prevent it from being forwarded - downstream. - - - A server decodes and interprets these values as it would any other - SETTINGS frame. Acknowledgement of the - SETTINGS parameters is not necessary, since a 101 response serves as implicit - acknowledgment. Providing these values in the Upgrade request gives a client an - opportunity to provide parameters prior to receiving any frames from the server. - -
    -
    - -
    - - A client that makes a request to an "https" URI uses TLS - with the application layer protocol negotiation extension. - - - HTTP/2 over TLS uses the "h2" application token. The "h2c" token MUST NOT be sent by a - client or selected by a server. - - - Once TLS negotiation is complete, both the client and the server send a connection preface. - -
    - -
    - - A client can learn that a particular server supports HTTP/2 by other means. For example, - describes a mechanism for advertising this capability. - - - A client MAY immediately send HTTP/2 frames to a server that is known to support HTTP/2, - after the connection preface; a server can - identify such a connection by the presence of the connection preface. This only affects - the establishment of HTTP/2 connections over cleartext TCP; implementations that support - HTTP/2 over TLS MUST use protocol negotiation in TLS. - - - Without additional information, prior support for HTTP/2 is not a strong signal that a - given server will support HTTP/2 for future connections. For example, it is possible for - server configurations to change, for configurations to differ between instances in - clustered servers, or for network conditions to change. - -
    - -
    - - Upon establishment of a TCP connection and determination that HTTP/2 will be used by both - peers, each endpoint MUST send a connection preface as a final confirmation and to - establish the initial SETTINGS parameters for the HTTP/2 connection. The client and - server each send a different connection preface. - - - The client connection preface starts with a sequence of 24 octets, which in hex notation - are: - -
    - -
    - - (the string PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n). This sequence - is followed by a SETTINGS frame (). The - SETTINGS frame MAY be empty. The client sends the client connection - preface immediately upon receipt of a 101 Switching Protocols response (indicating a - successful upgrade), or as the first application data octets of a TLS connection. If - starting an HTTP/2 connection with prior knowledge of server support for the protocol, the - client connection preface is sent upon connection establishment. - - - - - The client connection preface is selected so that a large proportion of HTTP/1.1 or - HTTP/1.0 servers and intermediaries do not attempt to process further frames. Note - that this does not address the concerns raised in . - - - - - The server connection preface consists of a potentially empty SETTINGS - frame () that MUST be the first frame the server sends in the - HTTP/2 connection. - - - The SETTINGS frames received from a peer as part of the connection preface - MUST be acknowledged (see ) after sending the connection - preface. - - - To avoid unnecessary latency, clients are permitted to send additional frames to the - server immediately after sending the client connection preface, without waiting to receive - the server connection preface. It is important to note, however, that the server - connection preface SETTINGS frame might include parameters that necessarily - alter how a client is expected to communicate with the server. Upon receiving the - SETTINGS frame, the client is expected to honor any parameters established. - In some configurations, it is possible for the server to transmit SETTINGS - before the client sends additional frames, providing an opportunity to avoid this issue. - - - Clients and servers MUST treat an invalid connection preface as a connection error of type - PROTOCOL_ERROR. A GOAWAY frame () - MAY be omitted in this case, since an invalid preface indicates that the peer is not using - HTTP/2. - -
    -
    - -
    - - Once the HTTP/2 connection is established, endpoints can begin exchanging frames. - - -
    - - All frames begin with a fixed 9-octet header followed by a variable-length payload. - -
    - -
    - - The fields of the frame header are defined as: - - - - The length of the frame payload expressed as an unsigned 24-bit integer. Values - greater than 214 (16,384) MUST NOT be sent unless the receiver has - set a larger value for SETTINGS_MAX_FRAME_SIZE. - - - The 9 octets of the frame header are not included in this value. - - - - - The 8-bit type of the frame. The frame type determines the format and semantics of - the frame. Implementations MUST ignore and discard any frame that has a type that - is unknown. - - - - - An 8-bit field reserved for frame-type specific boolean flags. - - - Flags are assigned semantics specific to the indicated frame type. Flags that have - no defined semantics for a particular frame type MUST be ignored, and MUST be left - unset (0) when sending. - - - - - A reserved 1-bit field. The semantics of this bit are undefined and the bit MUST - remain unset (0) when sending and MUST be ignored when receiving. - - - - - A 31-bit stream identifier (see ). The value 0 is - reserved for frames that are associated with the connection as a whole as opposed to - an individual stream. - - - - - - The structure and content of the frame payload is dependent entirely on the frame type. - -
    - -
    - - The size of a frame payload is limited by the maximum size that a receiver advertises in - the SETTINGS_MAX_FRAME_SIZE setting. This setting can have any value - between 214 (16,384) and 224-1 (16,777,215) octets, - inclusive. - - - All implementations MUST be capable of receiving and minimally processing frames up to - 214 octets in length, plus the 9 octet frame - header. The size of the frame header is not included when describing frame sizes. - - - Certain frame types, such as PING, impose additional limits - on the amount of payload data allowed. - - - - - If a frame size exceeds any defined limit, or is too small to contain mandatory frame - data, the endpoint MUST send a FRAME_SIZE_ERROR error. A frame size error - in a frame that could alter the state of the entire connection MUST be treated as a connection error; this includes any frame carrying - a header block (that is, HEADERS, - PUSH_PROMISE, and CONTINUATION), SETTINGS, - and any WINDOW_UPDATE frame with a stream identifier of 0. - - - Endpoints are not obligated to use all available space in a frame. Responsiveness can be - improved by using frames that are smaller than the permitted maximum size. Sending large - frames can result in delays in sending time-sensitive frames (such - RST_STREAM, WINDOW_UPDATE, or PRIORITY) - which if blocked by the transmission of a large frame, could affect performance. - -
    - -
    - - Just as in HTTP/1, a header field in HTTP/2 is a name with one or more associated values. - They are used within HTTP request and response messages as well as server push operations - (see ). - - - Header lists are collections of zero or more header fields. When transmitted over a - connection, a header list is serialized into a header block using HTTP Header Compression. The serialized header block is then - divided into one or more octet sequences, called header block fragments, and transmitted - within the payload of HEADERS, PUSH_PROMISE or CONTINUATION frames. - - - The Cookie header field is treated specially by the HTTP - mapping (see ). - - - A receiving endpoint reassembles the header block by concatenating its fragments, then - decompresses the block to reconstruct the header list. - - - A complete header block consists of either: - - - a single HEADERS or PUSH_PROMISE frame, - with the END_HEADERS flag set, or - - - a HEADERS or PUSH_PROMISE frame with the END_HEADERS - flag cleared and one or more CONTINUATION frames, - where the last CONTINUATION frame has the END_HEADERS flag set. - - - - - Header compression is stateful. One compression context and one decompression context is - used for the entire connection. Each header block is processed as a discrete unit. - Header blocks MUST be transmitted as a contiguous sequence of frames, with no interleaved - frames of any other type or from any other stream. The last frame in a sequence of - HEADERS or CONTINUATION frames MUST have the END_HEADERS - flag set. The last frame in a sequence of PUSH_PROMISE or - CONTINUATION frames MUST have the END_HEADERS flag set. This allows a - header block to be logically equivalent to a single frame. - - - Header block fragments can only be sent as the payload of HEADERS, - PUSH_PROMISE or CONTINUATION frames, because these frames - carry data that can modify the compression context maintained by a receiver. An endpoint - receiving HEADERS, PUSH_PROMISE or - CONTINUATION frames MUST reassemble header blocks and perform decompression - even if the frames are to be discarded. A receiver MUST terminate the connection with a - connection error of type - COMPRESSION_ERROR if it does not decompress a header block. - -
    -
    - -
    - - A "stream" is an independent, bi-directional sequence of frames exchanged between the client - and server within an HTTP/2 connection. Streams have several important characteristics: - - - A single HTTP/2 connection can contain multiple concurrently open streams, with either - endpoint interleaving frames from multiple streams. - - - Streams can be established and used unilaterally or shared by either the client or - server. - - - Streams can be closed by either endpoint. - - - The order in which frames are sent on a stream is significant. Recipients process frames - in the order they are received. In particular, the order of HEADERS, - and DATA frames is semantically significant. - - - Streams are identified by an integer. Stream identifiers are assigned to streams by the - endpoint initiating the stream. - - - - -
    - - The lifecycle of a stream is shown in . - - -
    - - | |<-----------' | - | R | closed | R | - `-------------------->| |<--------------------' - +--------+ - - H: HEADERS frame (with implied CONTINUATIONs) - PP: PUSH_PROMISE frame (with implied CONTINUATIONs) - ES: END_STREAM flag - R: RST_STREAM frame -]]> - -
    - - - Note that this diagram shows stream state transitions and the frames and flags that affect - those transitions only. In this regard, CONTINUATION frames do not result - in state transitions; they are effectively part of the HEADERS or - PUSH_PROMISE that they follow. For this purpose, the END_STREAM flag is - processed as a separate event to the frame that bears it; a HEADERS frame - with the END_STREAM flag set can cause two state transitions. - - - Both endpoints have a subjective view of the state of a stream that could be different - when frames are in transit. Endpoints do not coordinate the creation of streams; they are - created unilaterally by either endpoint. The negative consequences of a mismatch in - states are limited to the "closed" state after sending RST_STREAM, where - frames might be received for some time after closing. - - - Streams have the following states: - - - - - - All streams start in the "idle" state. In this state, no frames have been - exchanged. - - - The following transitions are valid from this state: - - - Sending or receiving a HEADERS frame causes the stream to become - "open". The stream identifier is selected as described in . The same HEADERS frame can also - cause a stream to immediately become "half closed". - - - Sending a PUSH_PROMISE frame marks the associated stream for - later use. The stream state for the reserved stream transitions to "reserved - (local)". - - - Receiving a PUSH_PROMISE frame marks the associated stream as - reserved by the remote peer. The state of the stream becomes "reserved - (remote)". - - - - - Receiving any frames other than HEADERS or - PUSH_PROMISE on a stream in this state MUST be treated as a connection error of type - PROTOCOL_ERROR. - - - - - - - A stream in the "reserved (local)" state is one that has been promised by sending a - PUSH_PROMISE frame. A PUSH_PROMISE frame reserves an - idle stream by associating the stream with an open stream that was initiated by the - remote peer (see ). - - - In this state, only the following transitions are possible: - - - The endpoint can send a HEADERS frame. This causes the stream to - open in a "half closed (remote)" state. - - - Either endpoint can send a RST_STREAM frame to cause the stream - to become "closed". This releases the stream reservation. - - - - - An endpoint MUST NOT send any type of frame other than HEADERS or - RST_STREAM in this state. - - - A PRIORITY frame MAY be received in this state. Receiving any type - of frame other than RST_STREAM or PRIORITY on a stream - in this state MUST be treated as a connection - error of type PROTOCOL_ERROR. - - - - - - - A stream in the "reserved (remote)" state has been reserved by a remote peer. - - - In this state, only the following transitions are possible: - - - Receiving a HEADERS frame causes the stream to transition to - "half closed (local)". - - - Either endpoint can send a RST_STREAM frame to cause the stream - to become "closed". This releases the stream reservation. - - - - - An endpoint MAY send a PRIORITY frame in this state to reprioritize - the reserved stream. An endpoint MUST NOT send any type of frame other than - RST_STREAM, WINDOW_UPDATE, or PRIORITY - in this state. - - - Receiving any type of frame other than HEADERS or - RST_STREAM on a stream in this state MUST be treated as a connection error of type - PROTOCOL_ERROR. - - - - - - - A stream in the "open" state may be used by both peers to send frames of any type. - In this state, sending peers observe advertised stream - level flow control limits. - - - From this state either endpoint can send a frame with an END_STREAM flag set, which - causes the stream to transition into one of the "half closed" states: an endpoint - sending an END_STREAM flag causes the stream state to become "half closed (local)"; - an endpoint receiving an END_STREAM flag causes the stream state to become "half - closed (remote)". - - - Either endpoint can send a RST_STREAM frame from this state, causing - it to transition immediately to "closed". - - - - - - - A stream that is in the "half closed (local)" state cannot be used for sending - frames. Only WINDOW_UPDATE, PRIORITY and - RST_STREAM frames can be sent in this state. - - - A stream transitions from this state to "closed" when a frame that contains an - END_STREAM flag is received, or when either peer sends a RST_STREAM - frame. - - - A receiver can ignore WINDOW_UPDATE frames in this state, which might - arrive for a short period after a frame bearing the END_STREAM flag is sent. - - - PRIORITY frames received in this state are used to reprioritize - streams that depend on the current stream. - - - - - - - A stream that is "half closed (remote)" is no longer being used by the peer to send - frames. In this state, an endpoint is no longer obligated to maintain a receiver - flow control window if it performs flow control. - - - If an endpoint receives additional frames for a stream that is in this state, other - than WINDOW_UPDATE, PRIORITY or - RST_STREAM, it MUST respond with a stream error of type - STREAM_CLOSED. - - - A stream that is "half closed (remote)" can be used by the endpoint to send frames - of any type. In this state, the endpoint continues to observe advertised stream level flow control limits. - - - A stream can transition from this state to "closed" by sending a frame that contains - an END_STREAM flag, or when either peer sends a RST_STREAM frame. - - - - - - - The "closed" state is the terminal state. - - - An endpoint MUST NOT send frames other than PRIORITY on a closed - stream. An endpoint that receives any frame other than PRIORITY - after receiving a RST_STREAM MUST treat that as a stream error of type - STREAM_CLOSED. Similarly, an endpoint that receives any frames after - receiving a frame with the END_STREAM flag set MUST treat that as a connection error of type - STREAM_CLOSED, unless the frame is permitted as described below. - - - WINDOW_UPDATE or RST_STREAM frames can be received in - this state for a short period after a DATA or HEADERS - frame containing an END_STREAM flag is sent. Until the remote peer receives and - processes RST_STREAM or the frame bearing the END_STREAM flag, it - might send frames of these types. Endpoints MUST ignore - WINDOW_UPDATE or RST_STREAM frames received in this - state, though endpoints MAY choose to treat frames that arrive a significant time - after sending END_STREAM as a connection - error of type PROTOCOL_ERROR. - - - PRIORITY frames can be sent on closed streams to prioritize streams - that are dependent on the closed stream. Endpoints SHOULD process - PRIORITY frame, though they can be ignored if the stream has been - removed from the dependency tree (see ). - - - If this state is reached as a result of sending a RST_STREAM frame, - the peer that receives the RST_STREAM might have already sent - or - enqueued for sending - frames on the stream that cannot be withdrawn. An endpoint - MUST ignore frames that it receives on closed streams after it has sent a - RST_STREAM frame. An endpoint MAY choose to limit the period over - which it ignores frames and treat frames that arrive after this time as being in - error. - - - Flow controlled frames (i.e., DATA) received after sending - RST_STREAM are counted toward the connection flow control window. - Even though these frames might be ignored, because they are sent before the sender - receives the RST_STREAM, the sender will consider the frames to count - against the flow control window. - - - An endpoint might receive a PUSH_PROMISE frame after it sends - RST_STREAM. PUSH_PROMISE causes a stream to become - "reserved" even if the associated stream has been reset. Therefore, a - RST_STREAM is needed to close an unwanted promised stream. - - - - - - In the absence of more specific guidance elsewhere in this document, implementations - SHOULD treat the receipt of a frame that is not expressly permitted in the description of - a state as a connection error of type - PROTOCOL_ERROR. Frame of unknown types are ignored. - - - An example of the state transitions for an HTTP request/response exchange can be found in - . An example of the state transitions for server push can be - found in and . - - -
    - - Streams are identified with an unsigned 31-bit integer. Streams initiated by a client - MUST use odd-numbered stream identifiers; those initiated by the server MUST use - even-numbered stream identifiers. A stream identifier of zero (0x0) is used for - connection control messages; the stream identifier zero cannot be used to establish a - new stream. - - - HTTP/1.1 requests that are upgraded to HTTP/2 (see ) are - responded to with a stream identifier of one (0x1). After the upgrade - completes, stream 0x1 is "half closed (local)" to the client. Therefore, stream 0x1 - cannot be selected as a new stream identifier by a client that upgrades from HTTP/1.1. - - - The identifier of a newly established stream MUST be numerically greater than all - streams that the initiating endpoint has opened or reserved. This governs streams that - are opened using a HEADERS frame and streams that are reserved using - PUSH_PROMISE. An endpoint that receives an unexpected stream identifier - MUST respond with a connection error of - type PROTOCOL_ERROR. - - - The first use of a new stream identifier implicitly closes all streams in the "idle" - state that might have been initiated by that peer with a lower-valued stream identifier. - For example, if a client sends a HEADERS frame on stream 7 without ever - sending a frame on stream 5, then stream 5 transitions to the "closed" state when the - first frame for stream 7 is sent or received. - - - Stream identifiers cannot be reused. Long-lived connections can result in an endpoint - exhausting the available range of stream identifiers. A client that is unable to - establish a new stream identifier can establish a new connection for new streams. A - server that is unable to establish a new stream identifier can send a - GOAWAY frame so that the client is forced to open a new connection for - new streams. - -
    - -
    - - A peer can limit the number of concurrently active streams using the - SETTINGS_MAX_CONCURRENT_STREAMS parameter (see ) within a SETTINGS frame. The maximum concurrent - streams setting is specific to each endpoint and applies only to the peer that receives - the setting. That is, clients specify the maximum number of concurrent streams the - server can initiate, and servers specify the maximum number of concurrent streams the - client can initiate. - - - Streams that are in the "open" state, or either of the "half closed" states count toward - the maximum number of streams that an endpoint is permitted to open. Streams in any of - these three states count toward the limit advertised in the - SETTINGS_MAX_CONCURRENT_STREAMS setting. Streams in either of the - "reserved" states do not count toward the stream limit. - - - Endpoints MUST NOT exceed the limit set by their peer. An endpoint that receives a - HEADERS frame that causes their advertised concurrent stream limit to be - exceeded MUST treat this as a stream error. An - endpoint that wishes to reduce the value of - SETTINGS_MAX_CONCURRENT_STREAMS to a value that is below the current - number of open streams can either close streams that exceed the new value or allow - streams to complete. - -
    -
    - -
    - - Using streams for multiplexing introduces contention over use of the TCP connection, - resulting in blocked streams. A flow control scheme ensures that streams on the same - connection do not destructively interfere with each other. Flow control is used for both - individual streams and for the connection as a whole. - - - HTTP/2 provides for flow control through use of the WINDOW_UPDATE frame. - - -
    - - HTTP/2 stream flow control aims to allow a variety of flow control algorithms to be - used without requiring protocol changes. Flow control in HTTP/2 has the following - characteristics: - - - Flow control is specific to a connection; i.e., it is "hop-by-hop", not - "end-to-end". - - - Flow control is based on window update frames. Receivers advertise how many octets - they are prepared to receive on a stream and for the entire connection. This is a - credit-based scheme. - - - Flow control is directional with overall control provided by the receiver. A - receiver MAY choose to set any window size that it desires for each stream and for - the entire connection. A sender MUST respect flow control limits imposed by a - receiver. Clients, servers and intermediaries all independently advertise their - flow control window as a receiver and abide by the flow control limits set by - their peer when sending. - - - The initial value for the flow control window is 65,535 octets for both new streams - and the overall connection. - - - The frame type determines whether flow control applies to a frame. Of the frames - specified in this document, only DATA frames are subject to flow - control; all other frame types do not consume space in the advertised flow control - window. This ensures that important control frames are not blocked by flow control. - - - Flow control cannot be disabled. - - - HTTP/2 defines only the format and semantics of the WINDOW_UPDATE - frame (). This document does not stipulate how a - receiver decides when to send this frame or the value that it sends, nor does it - specify how a sender chooses to send packets. Implementations are able to select - any algorithm that suits their needs. - - - - - Implementations are also responsible for managing how requests and responses are sent - based on priority; choosing how to avoid head of line blocking for requests; and - managing the creation of new streams. Algorithm choices for these could interact with - any flow control algorithm. - -
    - -
    - - Flow control is defined to protect endpoints that are operating under resource - constraints. For example, a proxy needs to share memory between many connections, and - also might have a slow upstream connection and a fast downstream one. Flow control - addresses cases where the receiver is unable process data on one stream, yet wants to - continue to process other streams in the same connection. - - - Deployments that do not require this capability can advertise a flow control window of - the maximum size, incrementing the available space when new data is received. This - effectively disables flow control for that receiver. Conversely, a sender is always - subject to the flow control window advertised by the receiver. - - - Deployments with constrained resources (for example, memory) can employ flow control to - limit the amount of memory a peer can consume. Note, however, that this can lead to - suboptimal use of available network resources if flow control is enabled without - knowledge of the bandwidth-delay product (see ). - - - Even with full awareness of the current bandwidth-delay product, implementation of flow - control can be difficult. When using flow control, the receiver MUST read from the TCP - receive buffer in a timely fashion. Failure to do so could lead to a deadlock when - critical frames, such as WINDOW_UPDATE, are not read and acted upon. - -
    -
    - -
    - - A client can assign a priority for a new stream by including prioritization information in - the HEADERS frame that opens the stream. For an existing - stream, the PRIORITY frame can be used to change the - priority. - - - The purpose of prioritization is to allow an endpoint to express how it would prefer its - peer allocate resources when managing concurrent streams. Most importantly, priority can - be used to select streams for transmitting frames when there is limited capacity for - sending. - - - Streams can be prioritized by marking them as dependent on the completion of other streams - (). Each dependency is assigned a relative weight, a number - that is used to determine the relative proportion of available resources that are assigned - to streams dependent on the same stream. - - - - Explicitly setting the priority for a stream is input to a prioritization process. It - does not guarantee any particular processing or transmission order for the stream relative - to any other stream. An endpoint cannot force a peer to process concurrent streams in a - particular order using priority. Expressing priority is therefore only ever a suggestion. - - - Providing prioritization information is optional, so default values are used if no - explicit indicator is provided (). - - -
    - - Each stream can be given an explicit dependency on another stream. Including a - dependency expresses a preference to allocate resources to the identified stream rather - than to the dependent stream. - - - A stream that is not dependent on any other stream is given a stream dependency of 0x0. - In other words, the non-existent stream 0 forms the root of the tree. - - - A stream that depends on another stream is a dependent stream. The stream upon which a - stream is dependent is a parent stream. A dependency on a stream that is not currently - in the tree - such as a stream in the "idle" state - results in that stream being given - a default priority. - - - When assigning a dependency on another stream, the stream is added as a new dependency - of the parent stream. Dependent streams that share the same parent are not ordered with - respect to each other. For example, if streams B and C are dependent on stream A, and - if stream D is created with a dependency on stream A, this results in a dependency order - of A followed by B, C, and D in any order. - -
    - /|\ - B C B D C -]]> -
    - - An exclusive flag allows for the insertion of a new level of dependencies. The - exclusive flag causes the stream to become the sole dependency of its parent stream, - causing other dependencies to become dependent on the exclusive stream. In the - previous example, if stream D is created with an exclusive dependency on stream A, this - results in D becoming the dependency parent of B and C. - -
    - D - B C / \ - B C -]]> -
    - - Inside the dependency tree, a dependent stream SHOULD only be allocated resources if all - of the streams that it depends on (the chain of parent streams up to 0x0) are either - closed, or it is not possible to make progress on them. - - - A stream cannot depend on itself. An endpoint MUST treat this as a stream error of type PROTOCOL_ERROR. - -
    - -
    - - All dependent streams are allocated an integer weight between 1 and 256 (inclusive). - - - Streams with the same parent SHOULD be allocated resources proportionally based on their - weight. Thus, if stream B depends on stream A with weight 4, and C depends on stream A - with weight 12, and if no progress can be made on A, stream B ideally receives one third - of the resources allocated to stream C. - -
    - -
    - - Stream priorities are changed using the PRIORITY frame. Setting a - dependency causes a stream to become dependent on the identified parent stream. - - - Dependent streams move with their parent stream if the parent is reprioritized. Setting - a dependency with the exclusive flag for a reprioritized stream moves all the - dependencies of the new parent stream to become dependent on the reprioritized stream. - - - If a stream is made dependent on one of its own dependencies, the formerly dependent - stream is first moved to be dependent on the reprioritized stream's previous parent. - The moved dependency retains its weight. - -
    - - For example, consider an original dependency tree where B and C depend on A, D and E - depend on C, and F depends on D. If A is made dependent on D, then D takes the place - of A. All other dependency relationships stay the same, except for F, which becomes - dependent on A if the reprioritization is exclusive. - - F B C ==> F A OR A - / \ | / \ /|\ - D E E B C B C F - | | | - F E E - (intermediate) (non-exclusive) (exclusive) -]]> -
    -
    - -
    - - When a stream is removed from the dependency tree, its dependencies can be moved to - become dependent on the parent of the closed stream. The weights of new dependencies - are recalculated by distributing the weight of the dependency of the closed stream - proportionally based on the weights of its dependencies. - - - Streams that are removed from the dependency tree cause some prioritization information - to be lost. Resources are shared between streams with the same parent stream, which - means that if a stream in that set closes or becomes blocked, any spare capacity - allocated to a stream is distributed to the immediate neighbors of the stream. However, - if the common dependency is removed from the tree, those streams share resources with - streams at the next highest level. - - - For example, assume streams A and B share a parent, and streams C and D both depend on - stream A. Prior to the removal of stream A, if streams A and D are unable to proceed, - then stream C receives all the resources dedicated to stream A. If stream A is removed - from the tree, the weight of stream A is divided between streams C and D. If stream D - is still unable to proceed, this results in stream C receiving a reduced proportion of - resources. For equal starting weights, C receives one third, rather than one half, of - available resources. - - - It is possible for a stream to become closed while prioritization information that - creates a dependency on that stream is in transit. If a stream identified in a - dependency has no associated priority information, then the dependent stream is instead - assigned a default priority. This potentially creates - suboptimal prioritization, since the stream could be given a priority that is different - to what is intended. - - - To avoid these problems, an endpoint SHOULD retain stream prioritization state for a - period after streams become closed. The longer state is retained, the lower the chance - that streams are assigned incorrect or default priority values. - - - This could create a large state burden for an endpoint, so this state MAY be limited. - An endpoint MAY apply a fixed upper limit on the number of closed streams for which - prioritization state is tracked to limit state exposure. The amount of additional state - an endpoint maintains could be dependent on load; under high load, prioritization state - can be discarded to limit resource commitments. In extreme cases, an endpoint could - even discard prioritization state for active or reserved streams. If a fixed limit is - applied, endpoints SHOULD maintain state for at least as many streams as allowed by - their setting for SETTINGS_MAX_CONCURRENT_STREAMS. - - - An endpoint receiving a PRIORITY frame that changes the priority of a - closed stream SHOULD alter the dependencies of the streams that depend on it, if it has - retained enough state to do so. - -
    - -
    - - Providing priority information is optional. Streams are assigned a non-exclusive - dependency on stream 0x0 by default. Pushed streams - initially depend on their associated stream. In both cases, streams are assigned a - default weight of 16. - -
    -
    - -
    - - HTTP/2 framing permits two classes of error: - - - An error condition that renders the entire connection unusable is a connection error. - - - An error in an individual stream is a stream error. - - - - - A list of error codes is included in . - - -
    - - A connection error is any error which prevents further processing of the framing layer, - or which corrupts any connection state. - - - An endpoint that encounters a connection error SHOULD first send a GOAWAY - frame () with the stream identifier of the last stream that it - successfully received from its peer. The GOAWAY frame includes an error - code that indicates why the connection is terminating. After sending the - GOAWAY frame, the endpoint MUST close the TCP connection. - - - It is possible that the GOAWAY will not be reliably received by the - receiving endpoint (see ). In the event of a connection error, - GOAWAY only provides a best effort attempt to communicate with the peer - about why the connection is being terminated. - - - An endpoint can end a connection at any time. In particular, an endpoint MAY choose to - treat a stream error as a connection error. Endpoints SHOULD send a - GOAWAY frame when ending a connection, providing that circumstances - permit it. - -
    - -
    - - A stream error is an error related to a specific stream that does not affect processing - of other streams. - - - An endpoint that detects a stream error sends a RST_STREAM frame () that contains the stream identifier of the stream where the error - occurred. The RST_STREAM frame includes an error code that indicates the - type of error. - - - A RST_STREAM is the last frame that an endpoint can send on a stream. - The peer that sends the RST_STREAM frame MUST be prepared to receive any - frames that were sent or enqueued for sending by the remote peer. These frames can be - ignored, except where they modify connection state (such as the state maintained for - header compression, or flow control). - - - Normally, an endpoint SHOULD NOT send more than one RST_STREAM frame for - any stream. However, an endpoint MAY send additional RST_STREAM frames if - it receives frames on a closed stream after more than a round-trip time. This behavior - is permitted to deal with misbehaving implementations. - - - An endpoint MUST NOT send a RST_STREAM in response to an - RST_STREAM frame, to avoid looping. - -
    - -
    - - If the TCP connection is closed or reset while streams remain in open or half closed - states, then the endpoint MUST assume that those streams were abnormally interrupted and - could be incomplete. - -
    -
    - -
    - - HTTP/2 permits extension of the protocol. Protocol extensions can be used to provide - additional services or alter any aspect of the protocol, within the limitations described - in this section. Extensions are effective only within the scope of a single HTTP/2 - connection. - - - Extensions are permitted to use new frame types, new - settings, or new error - codes. Registries are established for managing these extension points: frame types, settings and - error codes. - - - Implementations MUST ignore unknown or unsupported values in all extensible protocol - elements. Implementations MUST discard frames that have unknown or unsupported types. - This means that any of these extension points can be safely used by extensions without - prior arrangement or negotiation. However, extension frames that appear in the middle of - a header block are not permitted; these MUST be treated - as a connection error of type - PROTOCOL_ERROR. - - - However, extensions that could change the semantics of existing protocol components MUST - be negotiated before being used. For example, an extension that changes the layout of the - HEADERS frame cannot be used until the peer has given a positive signal - that this is acceptable. In this case, it could also be necessary to coordinate when the - revised layout comes into effect. Note that treating any frame other than - DATA frames as flow controlled is such a change in semantics, and can only - be done through negotiation. - - - This document doesn't mandate a specific method for negotiating the use of an extension, - but notes that a setting could be used for that - purpose. If both peers set a value that indicates willingness to use the extension, then - the extension can be used. If a setting is used for extension negotiation, the initial - value MUST be defined so that the extension is initially disabled. - -
    -
    - -
    - - This specification defines a number of frame types, each identified by a unique 8-bit type - code. Each frame type serves a distinct purpose either in the establishment and management - of the connection as a whole, or of individual streams. - - - The transmission of specific frame types can alter the state of a connection. If endpoints - fail to maintain a synchronized view of the connection state, successful communication - within the connection will no longer be possible. Therefore, it is important that endpoints - have a shared comprehension of how the state is affected by the use any given frame. - - -
    - - DATA frames (type=0x0) convey arbitrary, variable-length sequences of octets associated - with a stream. One or more DATA frames are used, for instance, to carry HTTP request or - response payloads. - - - DATA frames MAY also contain arbitrary padding. Padding can be added to DATA frames to - obscure the size of messages. - -
    - -
    - - The DATA frame contains the following fields: - - - An 8-bit field containing the length of the frame padding in units of octets. This - field is optional and is only present if the PADDED flag is set. - - - Application data. The amount of data is the remainder of the frame payload after - subtracting the length of the other fields that are present. - - - Padding octets that contain no application semantic value. Padding octets MUST be set - to zero when sending and ignored when receiving. - - - - - - The DATA frame defines the following flags: - - - Bit 1 being set indicates that this frame is the last that the endpoint will send for - the identified stream. Setting this flag causes the stream to enter one of the "half closed" states or the "closed" state. - - - Bit 4 being set indicates that the Pad Length field and any padding that it describes - is present. - - - - - DATA frames MUST be associated with a stream. If a DATA frame is received whose stream - identifier field is 0x0, the recipient MUST respond with a connection error of type - PROTOCOL_ERROR. - - - DATA frames are subject to flow control and can only be sent when a stream is in the - "open" or "half closed (remote)" states. The entire DATA frame payload is included in flow - control, including Pad Length and Padding fields if present. If a DATA frame is received - whose stream is not in "open" or "half closed (local)" state, the recipient MUST respond - with a stream error of type - STREAM_CLOSED. - - - The total number of padding octets is determined by the value of the Pad Length field. If - the length of the padding is greater than the length of the frame payload, the recipient - MUST treat this as a connection error of - type PROTOCOL_ERROR. - - - A frame can be increased in size by one octet by including a Pad Length field with a - value of zero. - - - - - Padding is a security feature; see . - -
    - -
    - - The HEADERS frame (type=0x1) is used to open a stream, - and additionally carries a header block fragment. HEADERS frames can be sent on a stream - in the "open" or "half closed (remote)" states. - -
    - -
    - - The HEADERS frame payload has the following fields: - - - An 8-bit field containing the length of the frame padding in units of octets. This - field is only present if the PADDED flag is set. - - - A single bit flag indicates that the stream dependency is exclusive, see . This field is only present if the PRIORITY flag is set. - - - A 31-bit stream identifier for the stream that this stream depends on, see . This field is only present if the PRIORITY flag is set. - - - An 8-bit weight for the stream, see . Add one to the - value to obtain a weight between 1 and 256. This field is only present if the - PRIORITY flag is set. - - - A header block fragment. - - - Padding octets that contain no application semantic value. Padding octets MUST be set - to zero when sending and ignored when receiving. - - - - - - The HEADERS frame defines the following flags: - - - - Bit 1 being set indicates that the header block is - the last that the endpoint will send for the identified stream. Setting this flag - causes the stream to enter one of "half closed" - states. - - - A HEADERS frame carries the END_STREAM flag that signals the end of a stream. - However, a HEADERS frame with the END_STREAM flag set can be followed by - CONTINUATION frames on the same stream. Logically, the - CONTINUATION frames are part of the HEADERS frame. - - - - - Bit 3 being set indicates that this frame contains an entire header block and is not followed by any - CONTINUATION frames. - - - A HEADERS frame without the END_HEADERS flag set MUST be followed by a - CONTINUATION frame for the same stream. A receiver MUST treat the - receipt of any other type of frame or a frame on a different stream as a connection error of type - PROTOCOL_ERROR. - - - - - Bit 4 being set indicates that the Pad Length field and any padding that it - describes is present. - - - - - Bit 6 being set indicates that the Exclusive Flag (E), Stream Dependency, and Weight - fields are present; see . - - - - - - - The payload of a HEADERS frame contains a header block - fragment. A header block that does not fit within a HEADERS frame is continued in - a CONTINUATION frame. - - - - HEADERS frames MUST be associated with a stream. If a HEADERS frame is received whose - stream identifier field is 0x0, the recipient MUST respond with a connection error of type - PROTOCOL_ERROR. - - - - The HEADERS frame changes the connection state as described in . - - - - The HEADERS frame includes optional padding. Padding fields and flags are identical to - those defined for DATA frames. - - - Prioritization information in a HEADERS frame is logically equivalent to a separate - PRIORITY frame, but inclusion in HEADERS avoids the potential for churn in - stream prioritization when new streams are created. Priorization fields in HEADERS frames - subsequent to the first on a stream reprioritize the - stream. - -
    - -
    - - The PRIORITY frame (type=0x2) specifies the sender-advised - priority of a stream. It can be sent at any time for an existing stream, including - closed streams. This enables reprioritization of existing streams. - -
    - -
    - - The payload of a PRIORITY frame contains the following fields: - - - A single bit flag indicates that the stream dependency is exclusive, see . - - - A 31-bit stream identifier for the stream that this stream depends on, see . - - - An 8-bit weight for the identified stream dependency, see . Add one to the value to obtain a weight between 1 and 256. - - - - - - The PRIORITY frame does not define any flags. - - - - The PRIORITY frame is associated with an existing stream. If a PRIORITY frame is received - with a stream identifier of 0x0, the recipient MUST respond with a connection error of type - PROTOCOL_ERROR. - - - The PRIORITY frame can be sent on a stream in any of the "reserved (remote)", "open", - "half closed (local)", "half closed (remote)", or "closed" states, though it cannot be - sent between consecutive frames that comprise a single header - block. Note that this frame could arrive after processing or frame sending has - completed, which would cause it to have no effect on the current stream. For a stream - that is in the "half closed (remote)" or "closed" - state, this frame can only affect - processing of the current stream and not frame transmission. - - - The PRIORITY frame is the only frame that can be sent for a stream in the "closed" state. - This allows for the reprioritization of a group of dependent streams by altering the - priority of a parent stream, which might be closed. However, a PRIORITY frame sent on a - closed stream risks being ignored due to the peer having discarded priority state - information for that stream. - -
    - -
    - - The RST_STREAM frame (type=0x3) allows for abnormal termination of a stream. When sent by - the initiator of a stream, it indicates that they wish to cancel the stream or that an - error condition has occurred. When sent by the receiver of a stream, it indicates that - either the receiver is rejecting the stream, requesting that the stream be cancelled, or - that an error condition has occurred. - -
    - -
    - - - The RST_STREAM frame contains a single unsigned, 32-bit integer identifying the error code. The error code indicates why the stream is being - terminated. - - - - The RST_STREAM frame does not define any flags. - - - - The RST_STREAM frame fully terminates the referenced stream and causes it to enter the - closed state. After receiving a RST_STREAM on a stream, the receiver MUST NOT send - additional frames for that stream, with the exception of PRIORITY. However, - after sending the RST_STREAM, the sending endpoint MUST be prepared to receive and process - additional frames sent on the stream that might have been sent by the peer prior to the - arrival of the RST_STREAM. - - - - RST_STREAM frames MUST be associated with a stream. If a RST_STREAM frame is received - with a stream identifier of 0x0, the recipient MUST treat this as a connection error of type - PROTOCOL_ERROR. - - - - RST_STREAM frames MUST NOT be sent for a stream in the "idle" state. If a RST_STREAM - frame identifying an idle stream is received, the recipient MUST treat this as a connection error of type - PROTOCOL_ERROR. - - -
    - -
    - - The SETTINGS frame (type=0x4) conveys configuration parameters that affect how endpoints - communicate, such as preferences and constraints on peer behavior. The SETTINGS frame is - also used to acknowledge the receipt of those parameters. Individually, a SETTINGS - parameter can also be referred to as a "setting". - - - SETTINGS parameters are not negotiated; they describe characteristics of the sending peer, - which are used by the receiving peer. Different values for the same parameter can be - advertised by each peer. For example, a client might set a high initial flow control - window, whereas a server might set a lower value to conserve resources. - - - - A SETTINGS frame MUST be sent by both endpoints at the start of a connection, and MAY be - sent at any other time by either endpoint over the lifetime of the connection. - Implementations MUST support all of the parameters defined by this specification. - - - - Each parameter in a SETTINGS frame replaces any existing value for that parameter. - Parameters are processed in the order in which they appear, and a receiver of a SETTINGS - frame does not need to maintain any state other than the current value of its - parameters. Therefore, the value of a SETTINGS parameter is the last value that is seen by - a receiver. - - - SETTINGS parameters are acknowledged by the receiving peer. To enable this, the SETTINGS - frame defines the following flag: - - - Bit 1 being set indicates that this frame acknowledges receipt and application of the - peer's SETTINGS frame. When this bit is set, the payload of the SETTINGS frame MUST - be empty. Receipt of a SETTINGS frame with the ACK flag set and a length field value - other than 0 MUST be treated as a connection - error of type FRAME_SIZE_ERROR. For more info, see Settings Synchronization. - - - - - SETTINGS frames always apply to a connection, never a single stream. The stream - identifier for a SETTINGS frame MUST be zero (0x0). If an endpoint receives a SETTINGS - frame whose stream identifier field is anything other than 0x0, the endpoint MUST respond - with a connection error of type - PROTOCOL_ERROR. - - - The SETTINGS frame affects connection state. A badly formed or incomplete SETTINGS frame - MUST be treated as a connection error of type - PROTOCOL_ERROR. - - -
    - - The payload of a SETTINGS frame consists of zero or more parameters, each consisting of - an unsigned 16-bit setting identifier and an unsigned 32-bit value. - - -
    - -
    -
    - -
    - - The following parameters are defined: - - - - Allows the sender to inform the remote endpoint of the maximum size of the header - compression table used to decode header blocks, in octets. The encoder can select - any size equal to or less than this value by using signaling specific to the - header compression format inside a header block. The initial value is 4,096 - octets. - - - - - This setting can be use to disable server - push. An endpoint MUST NOT send a PUSH_PROMISE frame if it - receives this parameter set to a value of 0. An endpoint that has both set this - parameter to 0 and had it acknowledged MUST treat the receipt of a - PUSH_PROMISE frame as a connection error of type - PROTOCOL_ERROR. - - - The initial value is 1, which indicates that server push is permitted. Any value - other than 0 or 1 MUST be treated as a connection error of type - PROTOCOL_ERROR. - - - - - Indicates the maximum number of concurrent streams that the sender will allow. - This limit is directional: it applies to the number of streams that the sender - permits the receiver to create. Initially there is no limit to this value. It is - recommended that this value be no smaller than 100, so as to not unnecessarily - limit parallelism. - - - A value of 0 for SETTINGS_MAX_CONCURRENT_STREAMS SHOULD NOT be treated as special - by endpoints. A zero value does prevent the creation of new streams, however this - can also happen for any limit that is exhausted with active streams. Servers - SHOULD only set a zero value for short durations; if a server does not wish to - accept requests, closing the connection could be preferable. - - - - - Indicates the sender's initial window size (in octets) for stream level flow - control. The initial value is 216-1 (65,535) octets. - - - This setting affects the window size of all streams, including existing streams, - see . - - - Values above the maximum flow control window size of 231-1 MUST - be treated as a connection error of - type FLOW_CONTROL_ERROR. - - - - - Indicates the size of the largest frame payload that the sender is willing to - receive, in octets. - - - The initial value is 214 (16,384) octets. The value advertised by - an endpoint MUST be between this initial value and the maximum allowed frame size - (224-1 or 16,777,215 octets), inclusive. Values outside this range - MUST be treated as a connection error - of type PROTOCOL_ERROR. - - - - - This advisory setting informs a peer of the maximum size of header list that the - sender is prepared to accept, in octets. The value is based on the uncompressed - size of header fields, including the length of the name and value in octets plus - an overhead of 32 octets for each header field. - - - For any given request, a lower limit than what is advertised MAY be enforced. The - initial value of this setting is unlimited. - - - - - - An endpoint that receives a SETTINGS frame with any unknown or unsupported identifier - MUST ignore that setting. - -
    - -
    - - Most values in SETTINGS benefit from or require an understanding of when the peer has - received and applied the changed parameter values. In order to provide - such synchronization timepoints, the recipient of a SETTINGS frame in which the ACK flag - is not set MUST apply the updated parameters as soon as possible upon receipt. - - - The values in the SETTINGS frame MUST be processed in the order they appear, with no - other frame processing between values. Unsupported parameters MUST be ignored. Once - all values have been processed, the recipient MUST immediately emit a SETTINGS frame - with the ACK flag set. Upon receiving a SETTINGS frame with the ACK flag set, the sender - of the altered parameters can rely on the setting having been applied. - - - If the sender of a SETTINGS frame does not receive an acknowledgement within a - reasonable amount of time, it MAY issue a connection error of type - SETTINGS_TIMEOUT. - -
    -
    - -
    - - The PUSH_PROMISE frame (type=0x5) is used to notify the peer endpoint in advance of - streams the sender intends to initiate. The PUSH_PROMISE frame includes the unsigned - 31-bit identifier of the stream the endpoint plans to create along with a set of headers - that provide additional context for the stream. contains a - thorough description of the use of PUSH_PROMISE frames. - - -
    - -
    - - The PUSH_PROMISE frame payload has the following fields: - - - An 8-bit field containing the length of the frame padding in units of octets. This - field is only present if the PADDED flag is set. - - - A single reserved bit. - - - An unsigned 31-bit integer that identifies the stream that is reserved by the - PUSH_PROMISE. The promised stream identifier MUST be a valid choice for the next - stream sent by the sender (see new stream - identifier). - - - A header block fragment containing request header - fields. - - - Padding octets. - - - - - - The PUSH_PROMISE frame defines the following flags: - - - - Bit 3 being set indicates that this frame contains an entire header block and is not followed by any - CONTINUATION frames. - - - A PUSH_PROMISE frame without the END_HEADERS flag set MUST be followed by a - CONTINUATION frame for the same stream. A receiver MUST treat the receipt of any - other type of frame or a frame on a different stream as a connection error of type - PROTOCOL_ERROR. - - - - - Bit 4 being set indicates that the Pad Length field and any padding that it - describes is present. - - - - - - - PUSH_PROMISE frames MUST be associated with an existing, peer-initiated stream. The stream - identifier of a PUSH_PROMISE frame indicates the stream it is associated with. If the - stream identifier field specifies the value 0x0, a recipient MUST respond with a connection error of type - PROTOCOL_ERROR. - - - - Promised streams are not required to be used in the order they are promised. The - PUSH_PROMISE only reserves stream identifiers for later use. - - - - PUSH_PROMISE MUST NOT be sent if the SETTINGS_ENABLE_PUSH setting of the - peer endpoint is set to 0. An endpoint that has set this setting and has received - acknowledgement MUST treat the receipt of a PUSH_PROMISE frame as a connection error of type - PROTOCOL_ERROR. - - - Recipients of PUSH_PROMISE frames can choose to reject promised streams by returning a - RST_STREAM referencing the promised stream identifier back to the sender of - the PUSH_PROMISE. - - - - A PUSH_PROMISE frame modifies the connection state in two ways. The inclusion of a header block potentially modifies the state maintained for - header compression. PUSH_PROMISE also reserves a stream for later use, causing the - promised stream to enter the "reserved" state. A sender MUST NOT send a PUSH_PROMISE on a - stream unless that stream is either "open" or "half closed (remote)"; the sender MUST - ensure that the promised stream is a valid choice for a new stream identifier (that is, the promised stream MUST - be in the "idle" state). - - - Since PUSH_PROMISE reserves a stream, ignoring a PUSH_PROMISE frame causes the stream - state to become indeterminate. A receiver MUST treat the receipt of a PUSH_PROMISE on a - stream that is neither "open" nor "half closed (local)" as a connection error of type - PROTOCOL_ERROR. However, an endpoint that has sent - RST_STREAM on the associated stream MUST handle PUSH_PROMISE frames that - might have been created before the RST_STREAM frame is received and - processed. - - - A receiver MUST treat the receipt of a PUSH_PROMISE that promises an illegal stream identifier (that is, an identifier for a - stream that is not currently in the "idle" state) as a connection error of type - PROTOCOL_ERROR. - - - - The PUSH_PROMISE frame includes optional padding. Padding fields and flags are identical - to those defined for DATA frames. - -
    - -
    - - The PING frame (type=0x6) is a mechanism for measuring a minimal round trip time from the - sender, as well as determining whether an idle connection is still functional. PING - frames can be sent from any endpoint. - -
    - -
    - - - In addition to the frame header, PING frames MUST contain 8 octets of data in the payload. - A sender can include any value it chooses and use those bytes in any fashion. - - - Receivers of a PING frame that does not include an ACK flag MUST send a PING frame with - the ACK flag set in response, with an identical payload. PING responses SHOULD be given - higher priority than any other frame. - - - - The PING frame defines the following flags: - - - Bit 1 being set indicates that this PING frame is a PING response. An endpoint MUST - set this flag in PING responses. An endpoint MUST NOT respond to PING frames - containing this flag. - - - - - PING frames are not associated with any individual stream. If a PING frame is received - with a stream identifier field value other than 0x0, the recipient MUST respond with a - connection error of type - PROTOCOL_ERROR. - - - Receipt of a PING frame with a length field value other than 8 MUST be treated as a connection error of type - FRAME_SIZE_ERROR. - - -
    - -
    - - The GOAWAY frame (type=0x7) informs the remote peer to stop creating streams on this - connection. GOAWAY can be sent by either the client or the server. Once sent, the sender - will ignore frames sent on any new streams with identifiers higher than the included last - stream identifier. Receivers of a GOAWAY frame MUST NOT open additional streams on the - connection, although a new connection can be established for new streams. - - - The purpose of this frame is to allow an endpoint to gracefully stop accepting new - streams, while still finishing processing of previously established streams. This enables - administrative actions, like server maintainance. - - - There is an inherent race condition between an endpoint starting new streams and the - remote sending a GOAWAY frame. To deal with this case, the GOAWAY contains the stream - identifier of the last peer-initiated stream which was or might be processed on the - sending endpoint in this connection. For instance, if the server sends a GOAWAY frame, - the identified stream is the highest numbered stream initiated by the client. - - - If the receiver of the GOAWAY has sent data on streams with a higher stream identifier - than what is indicated in the GOAWAY frame, those streams are not or will not be - processed. The receiver of the GOAWAY frame can treat the streams as though they had - never been created at all, thereby allowing those streams to be retried later on a new - connection. - - - Endpoints SHOULD always send a GOAWAY frame before closing a connection so that the remote - can know whether a stream has been partially processed or not. For example, if an HTTP - client sends a POST at the same time that a server closes a connection, the client cannot - know if the server started to process that POST request if the server does not send a - GOAWAY frame to indicate what streams it might have acted on. - - - An endpoint might choose to close a connection without sending GOAWAY for misbehaving - peers. - - -
    - -
    - - The GOAWAY frame does not define any flags. - - - The GOAWAY frame applies to the connection, not a specific stream. An endpoint MUST treat - a GOAWAY frame with a stream identifier other than 0x0 as a connection error of type - PROTOCOL_ERROR. - - - The last stream identifier in the GOAWAY frame contains the highest numbered stream - identifier for which the sender of the GOAWAY frame might have taken some action on, or - might yet take action on. All streams up to and including the identified stream might - have been processed in some way. The last stream identifier can be set to 0 if no streams - were processed. - - - In this context, "processed" means that some data from the stream was passed to some - higher layer of software that might have taken some action as a result. - - - If a connection terminates without a GOAWAY frame, the last stream identifier is - effectively the highest possible stream identifier. - - - On streams with lower or equal numbered identifiers that were not closed completely prior - to the connection being closed, re-attempting requests, transactions, or any protocol - activity is not possible, with the exception of idempotent actions like HTTP GET, PUT, or - DELETE. Any protocol activity that uses higher numbered streams can be safely retried - using a new connection. - - - Activity on streams numbered lower or equal to the last stream identifier might still - complete successfully. The sender of a GOAWAY frame might gracefully shut down a - connection by sending a GOAWAY frame, maintaining the connection in an open state until - all in-progress streams complete. - - - An endpoint MAY send multiple GOAWAY frames if circumstances change. For instance, an - endpoint that sends GOAWAY with NO_ERROR during graceful shutdown could - subsequently encounter an condition that requires immediate termination of the connection. - The last stream identifier from the last GOAWAY frame received indicates which streams - could have been acted upon. Endpoints MUST NOT increase the value they send in the last - stream identifier, since the peers might already have retried unprocessed requests on - another connection. - - - A client that is unable to retry requests loses all requests that are in flight when the - server closes the connection. This is especially true for intermediaries that might - not be serving clients using HTTP/2. A server that is attempting to gracefully shut down - a connection SHOULD send an initial GOAWAY frame with the last stream identifier set to - 231-1 and a NO_ERROR code. This signals to the client that - a shutdown is imminent and that no further requests can be initiated. After waiting at - least one round trip time, the server can send another GOAWAY frame with an updated last - stream identifier. This ensures that a connection can be cleanly shut down without losing - requests. - - - - After sending a GOAWAY frame, the sender can discard frames for streams with identifiers - higher than the identified last stream. However, any frames that alter connection state - cannot be completely ignored. For instance, HEADERS, - PUSH_PROMISE and CONTINUATION frames MUST be minimally - processed to ensure the state maintained for header compression is consistent (see ); similarly DATA frames MUST be counted toward the connection flow - control window. Failure to process these frames can cause flow control or header - compression state to become unsynchronized. - - - - The GOAWAY frame also contains a 32-bit error code that - contains the reason for closing the connection. - - - Endpoints MAY append opaque data to the payload of any GOAWAY frame. Additional debug - data is intended for diagnostic purposes only and carries no semantic value. Debug - information could contain security- or privacy-sensitive data. Logged or otherwise - persistently stored debug data MUST have adequate safeguards to prevent unauthorized - access. - -
    - -
    - - The WINDOW_UPDATE frame (type=0x8) is used to implement flow control; see for an overview. - - - Flow control operates at two levels: on each individual stream and on the entire - connection. - - - Both types of flow control are hop-by-hop; that is, only between the two endpoints. - Intermediaries do not forward WINDOW_UPDATE frames between dependent connections. - However, throttling of data transfer by any receiver can indirectly cause the propagation - of flow control information toward the original sender. - - - Flow control only applies to frames that are identified as being subject to flow control. - Of the frame types defined in this document, this includes only DATA frames. - Frames that are exempt from flow control MUST be accepted and processed, unless the - receiver is unable to assign resources to handling the frame. A receiver MAY respond with - a stream error or connection error of type - FLOW_CONTROL_ERROR if it is unable to accept a frame. - -
    - -
    - - The payload of a WINDOW_UPDATE frame is one reserved bit, plus an unsigned 31-bit integer - indicating the number of octets that the sender can transmit in addition to the existing - flow control window. The legal range for the increment to the flow control window is 1 to - 231-1 (0x7fffffff) octets. - - - The WINDOW_UPDATE frame does not define any flags. - - - The WINDOW_UPDATE frame can be specific to a stream or to the entire connection. In the - former case, the frame's stream identifier indicates the affected stream; in the latter, - the value "0" indicates that the entire connection is the subject of the frame. - - - A receiver MUST treat the receipt of a WINDOW_UPDATE frame with an flow control window - increment of 0 as a stream error of type - PROTOCOL_ERROR; errors on the connection flow control window MUST be - treated as a connection error. - - - WINDOW_UPDATE can be sent by a peer that has sent a frame bearing the END_STREAM flag. - This means that a receiver could receive a WINDOW_UPDATE frame on a "half closed (remote)" - or "closed" stream. A receiver MUST NOT treat this as an error, see . - - - A receiver that receives a flow controlled frame MUST always account for its contribution - against the connection flow control window, unless the receiver treats this as a connection error. This is necessary even if the - frame is in error. Since the sender counts the frame toward the flow control window, if - the receiver does not, the flow control window at sender and receiver can become - different. - - -
    - - Flow control in HTTP/2 is implemented using a window kept by each sender on every - stream. The flow control window is a simple integer value that indicates how many octets - of data the sender is permitted to transmit; as such, its size is a measure of the - buffering capacity of the receiver. - - - Two flow control windows are applicable: the stream flow control window and the - connection flow control window. The sender MUST NOT send a flow controlled frame with a - length that exceeds the space available in either of the flow control windows advertised - by the receiver. Frames with zero length with the END_STREAM flag set (that is, an - empty DATA frame) MAY be sent if there is no available space in either - flow control window. - - - For flow control calculations, the 9 octet frame header is not counted. - - - After sending a flow controlled frame, the sender reduces the space available in both - windows by the length of the transmitted frame. - - - The receiver of a frame sends a WINDOW_UPDATE frame as it consumes data and frees up - space in flow control windows. Separate WINDOW_UPDATE frames are sent for the stream - and connection level flow control windows. - - - A sender that receives a WINDOW_UPDATE frame updates the corresponding window by the - amount specified in the frame. - - - A sender MUST NOT allow a flow control window to exceed 231-1 octets. - If a sender receives a WINDOW_UPDATE that causes a flow control window to exceed this - maximum it MUST terminate either the stream or the connection, as appropriate. For - streams, the sender sends a RST_STREAM with the error code of - FLOW_CONTROL_ERROR code; for the connection, a GOAWAY - frame with a FLOW_CONTROL_ERROR code. - - - Flow controlled frames from the sender and WINDOW_UPDATE frames from the receiver are - completely asynchronous with respect to each other. This property allows a receiver to - aggressively update the window size kept by the sender to prevent streams from stalling. - -
    - -
    - - When an HTTP/2 connection is first established, new streams are created with an initial - flow control window size of 65,535 octets. The connection flow control window is 65,535 - octets. Both endpoints can adjust the initial window size for new streams by including - a value for SETTINGS_INITIAL_WINDOW_SIZE in the SETTINGS - frame that forms part of the connection preface. The connection flow control window can - only be changed using WINDOW_UPDATE frames. - - - Prior to receiving a SETTINGS frame that sets a value for - SETTINGS_INITIAL_WINDOW_SIZE, an endpoint can only use the default - initial window size when sending flow controlled frames. Similarly, the connection flow - control window is set to the default initial window size until a WINDOW_UPDATE frame is - received. - - - A SETTINGS frame can alter the initial flow control window size for all - current streams. When the value of SETTINGS_INITIAL_WINDOW_SIZE changes, - a receiver MUST adjust the size of all stream flow control windows that it maintains by - the difference between the new value and the old value. - - - A change to SETTINGS_INITIAL_WINDOW_SIZE can cause the available space in - a flow control window to become negative. A sender MUST track the negative flow control - window, and MUST NOT send new flow controlled frames until it receives WINDOW_UPDATE - frames that cause the flow control window to become positive. - - - For example, if the client sends 60KB immediately on connection establishment, and the - server sets the initial window size to be 16KB, the client will recalculate the - available flow control window to be -44KB on receipt of the SETTINGS - frame. The client retains a negative flow control window until WINDOW_UPDATE frames - restore the window to being positive, after which the client can resume sending. - - - A SETTINGS frame cannot alter the connection flow control window. - - - An endpoint MUST treat a change to SETTINGS_INITIAL_WINDOW_SIZE that - causes any flow control window to exceed the maximum size as a connection error of type - FLOW_CONTROL_ERROR. - -
    - -
    - - A receiver that wishes to use a smaller flow control window than the current size can - send a new SETTINGS frame. However, the receiver MUST be prepared to - receive data that exceeds this window size, since the sender might send data that - exceeds the lower limit prior to processing the SETTINGS frame. - - - After sending a SETTINGS frame that reduces the initial flow control window size, a - receiver has two options for handling streams that exceed flow control limits: - - - The receiver can immediately send RST_STREAM with - FLOW_CONTROL_ERROR error code for the affected streams. - - - The receiver can accept the streams and tolerate the resulting head of line - blocking, sending WINDOW_UPDATE frames as it consumes data. - - - -
    -
    - -
    - - The CONTINUATION frame (type=0x9) is used to continue a sequence of header block fragments. Any number of CONTINUATION frames can - be sent on an existing stream, as long as the preceding frame is on the same stream and is - a HEADERS, PUSH_PROMISE or CONTINUATION frame without the - END_HEADERS flag set. - - -
    - -
    - - The CONTINUATION frame payload contains a header block - fragment. - - - - The CONTINUATION frame defines the following flag: - - - - Bit 3 being set indicates that this frame ends a header - block. - - - If the END_HEADERS bit is not set, this frame MUST be followed by another - CONTINUATION frame. A receiver MUST treat the receipt of any other type of frame or - a frame on a different stream as a connection - error of type PROTOCOL_ERROR. - - - - - - - The CONTINUATION frame changes the connection state as defined in . - - - - CONTINUATION frames MUST be associated with a stream. If a CONTINUATION frame is received - whose stream identifier field is 0x0, the recipient MUST respond with a connection error of type PROTOCOL_ERROR. - - - - A CONTINUATION frame MUST be preceded by a HEADERS, - PUSH_PROMISE or CONTINUATION frame without the END_HEADERS flag set. A - recipient that observes violation of this rule MUST respond with a connection error of type - PROTOCOL_ERROR. - -
    -
    - -
    - - Error codes are 32-bit fields that are used in RST_STREAM and - GOAWAY frames to convey the reasons for the stream or connection error. - - - - Error codes share a common code space. Some error codes apply only to either streams or the - entire connection and have no defined semantics in the other context. - - - - The following error codes are defined: - - - The associated condition is not as a result of an error. For example, a - GOAWAY might include this code to indicate graceful shutdown of a - connection. - - - The endpoint detected an unspecific protocol error. This error is for use when a more - specific error code is not available. - - - The endpoint encountered an unexpected internal error. - - - The endpoint detected that its peer violated the flow control protocol. - - - The endpoint sent a SETTINGS frame, but did not receive a response in a - timely manner. See Settings Synchronization. - - - The endpoint received a frame after a stream was half closed. - - - The endpoint received a frame with an invalid size. - - - The endpoint refuses the stream prior to performing any application processing, see - for details. - - - Used by the endpoint to indicate that the stream is no longer needed. - - - The endpoint is unable to maintain the header compression context for the connection. - - - The connection established in response to a CONNECT - request was reset or abnormally closed. - - - The endpoint detected that its peer is exhibiting a behavior that might be generating - excessive load. - - - The underlying transport has properties that do not meet minimum security - requirements (see ). - - - - - Unknown or unsupported error codes MUST NOT trigger any special behavior. These MAY be - treated by an implementation as being equivalent to INTERNAL_ERROR. - -
    - -
    - - HTTP/2 is intended to be as compatible as possible with current uses of HTTP. This means - that, from the application perspective, the features of the protocol are largely - unchanged. To achieve this, all request and response semantics are preserved, although the - syntax of conveying those semantics has changed. - - - Thus, the specification and requirements of HTTP/1.1 Semantics and Content , Conditional Requests , Range Requests , Caching and Authentication are applicable to HTTP/2. Selected portions of HTTP/1.1 Message Syntax - and Routing , such as the HTTP and HTTPS URI schemes, are also - applicable in HTTP/2, but the expression of those semantics for this protocol are defined - in the sections below. - - -
    - - A client sends an HTTP request on a new stream, using a previously unused stream identifier. A server sends an HTTP response on - the same stream as the request. - - - An HTTP message (request or response) consists of: - - - for a response only, zero or more HEADERS frames (each followed by zero - or more CONTINUATION frames) containing the message headers of - informational (1xx) HTTP responses (see and ), - and - - - one HEADERS frame (followed by zero or more CONTINUATION - frames) containing the message headers (see ), and - - - zero or more DATA frames containing the message payload (see ), and - - - optionally, one HEADERS frame, followed by zero or more - CONTINUATION frames containing the trailer-part, if present (see ). - - - The last frame in the sequence bears an END_STREAM flag, noting that a - HEADERS frame bearing the END_STREAM flag can be followed by - CONTINUATION frames that carry any remaining portions of the header block. - - - Other frames (from any stream) MUST NOT occur between either HEADERS frame - and any CONTINUATION frames that might follow. - - - - Trailing header fields are carried in a header block that also terminates the stream. - That is, a sequence starting with a HEADERS frame, followed by zero or more - CONTINUATION frames, where the HEADERS frame bears an - END_STREAM flag. Header blocks after the first that do not terminate the stream are not - part of an HTTP request or response. - - - A HEADERS frame (and associated CONTINUATION frames) can - only appear at the start or end of a stream. An endpoint that receives a - HEADERS frame without the END_STREAM flag set after receiving a final - (non-informational) status code MUST treat the corresponding request or response as malformed. - - - - An HTTP request/response exchange fully consumes a single stream. A request starts with - the HEADERS frame that puts the stream into an "open" state. The request - ends with a frame bearing END_STREAM, which causes the stream to become "half closed - (local)" for the client and "half closed (remote)" for the server. A response starts with - a HEADERS frame and ends with a frame bearing END_STREAM, which places the - stream in the "closed" state. - - - -
    - - HTTP/2 removes support for the 101 (Switching Protocols) informational status code - (). - - - The semantics of 101 (Switching Protocols) aren't applicable to a multiplexed protocol. - Alternative protocols are able to use the same mechanisms that HTTP/2 uses to negotiate - their use (see ). - -
    - -
    - - HTTP header fields carry information as a series of key-value pairs. For a listing of - registered HTTP headers, see the Message Header Field Registry maintained at . - - -
    - - While HTTP/1.x used the message start-line (see ) to convey the target URI and method of the request, and the - status code for the response, HTTP/2 uses special pseudo-header fields beginning with - ':' character (ASCII 0x3a) for this purpose. - - - Pseudo-header fields are not HTTP header fields. Endpoints MUST NOT generate - pseudo-header fields other than those defined in this document. - - - Pseudo-header fields are only valid in the context in which they are defined. - Pseudo-header fields defined for requests MUST NOT appear in responses; pseudo-header - fields defined for responses MUST NOT appear in requests. Pseudo-header fields MUST - NOT appear in trailers. Endpoints MUST treat a request or response that contains - undefined or invalid pseudo-header fields as malformed. - - - Just as in HTTP/1.x, header field names are strings of ASCII characters that are - compared in a case-insensitive fashion. However, header field names MUST be converted - to lowercase prior to their encoding in HTTP/2. A request or response containing - uppercase header field names MUST be treated as malformed. - - - All pseudo-header fields MUST appear in the header block before regular header fields. - Any request or response that contains a pseudo-header field that appears in a header - block after a regular header field MUST be treated as malformed. - -
    - -
    - - HTTP/2 does not use the Connection header field to - indicate connection-specific header fields; in this protocol, connection-specific - metadata is conveyed by other means. An endpoint MUST NOT generate a HTTP/2 message - containing connection-specific header fields; any message containing - connection-specific header fields MUST be treated as malformed. - - - This means that an intermediary transforming an HTTP/1.x message to HTTP/2 will need - to remove any header fields nominated by the Connection header field, along with the - Connection header field itself. Such intermediaries SHOULD also remove other - connection-specific header fields, such as Keep-Alive, Proxy-Connection, - Transfer-Encoding and Upgrade, even if they are not nominated by Connection. - - - One exception to this is the TE header field, which MAY be present in an HTTP/2 - request, but when it is MUST NOT contain any value other than "trailers". - - - - - HTTP/2 purposefully does not support upgrade to another protocol. The handshake - methods described in are believed sufficient to - negotiate the use of alternative protocols. - - - -
    - -
    - - The following pseudo-header fields are defined for HTTP/2 requests: - - - - The :method pseudo-header field includes the HTTP - method (). - - - - - The :scheme pseudo-header field includes the scheme - portion of the target URI (). - - - :scheme is not restricted to http and https schemed URIs. A - proxy or gateway can translate requests for non-HTTP schemes, enabling the use - of HTTP to interact with non-HTTP services. - - - - - The :authority pseudo-header field includes the - authority portion of the target URI (). The authority MUST NOT include the deprecated userinfo subcomponent for http - or https schemed URIs. - - - To ensure that the HTTP/1.1 request line can be reproduced accurately, this - pseudo-header field MUST be omitted when translating from an HTTP/1.1 request - that has a request target in origin or asterisk form (see ). Clients that generate - HTTP/2 requests directly SHOULD use the :authority pseudo-header - field instead of the Host header field. An - intermediary that converts an HTTP/2 request to HTTP/1.1 MUST create a Host header field if one is not present in a request by - copying the value of the :authority pseudo-header - field. - - - - - The :path pseudo-header field includes the path and - query parts of the target URI (the path-absolute - production from and optionally a '?' character - followed by the query production, see and ). A request in asterisk form includes the value '*' for the - :path pseudo-header field. - - - This pseudo-header field MUST NOT be empty for http - or https URIs; http or - https URIs that do not contain a path component - MUST include a value of '/'. The exception to this rule is an OPTIONS request - for an http or https - URI that does not include a path component; these MUST include a :path pseudo-header field with a value of '*' (see ). - - - - - - All HTTP/2 requests MUST include exactly one valid value for the :method, :scheme, and :path pseudo-header fields, unless it is a CONNECT request. An HTTP request that omits mandatory - pseudo-header fields is malformed. - - - HTTP/2 does not define a way to carry the version identifier that is included in the - HTTP/1.1 request line. - -
    - -
    - - For HTTP/2 responses, a single :status pseudo-header - field is defined that carries the HTTP status code field (see ). This pseudo-header field MUST be included in all - responses, otherwise the response is malformed. - - - HTTP/2 does not define a way to carry the version or reason phrase that is included in - an HTTP/1.1 status line. - -
    - -
    - - The Cookie header field can carry a significant amount of - redundant data. - - - The Cookie header field uses a semi-colon (";") to delimit cookie-pairs (or "crumbs"). - This header field doesn't follow the list construction rules in HTTP (see ), which prevents cookie-pairs from - being separated into different name-value pairs. This can significantly reduce - compression efficiency as individual cookie-pairs are updated. - - - To allow for better compression efficiency, the Cookie header field MAY be split into - separate header fields, each with one or more cookie-pairs. If there are multiple - Cookie header fields after decompression, these MUST be concatenated into a single - octet string using the two octet delimiter of 0x3B, 0x20 (the ASCII string "; ") - before being passed into a non-HTTP/2 context, such as an HTTP/1.1 connection, or a - generic HTTP server application. - -
    - - Therefore, the following two lists of Cookie header fields are semantically - equivalent. - - -
    -
    - -
    - - A malformed request or response is one that is an otherwise valid sequence of HTTP/2 - frames, but is otherwise invalid due to the presence of extraneous frames, prohibited - header fields, the absence of mandatory header fields, or the inclusion of uppercase - header field names. - - - A request or response that includes an entity body can include a content-length header field. A request or response is also - malformed if the value of a content-length header field - does not equal the sum of the DATA frame payload lengths that form the - body. A response that is defined to have no payload, as described in , can have a non-zero - content-length header field, even though no content is - included in DATA frames. - - - Intermediaries that process HTTP requests or responses (i.e., any intermediary not - acting as a tunnel) MUST NOT forward a malformed request or response. Malformed - requests or responses that are detected MUST be treated as a stream error of type PROTOCOL_ERROR. - - - For malformed requests, a server MAY send an HTTP response prior to closing or - resetting the stream. Clients MUST NOT accept a malformed response. Note that these - requirements are intended to protect against several types of common attacks against - HTTP; they are deliberately strict, because being permissive can expose - implementations to these vulnerabilities. - -
    -
    - -
    - - This section shows HTTP/1.1 requests and responses, with illustrations of equivalent - HTTP/2 requests and responses. - - - An HTTP GET request includes request header fields and no body and is therefore - transmitted as a single HEADERS frame, followed by zero or more - CONTINUATION frames containing the serialized block of request header - fields. The HEADERS frame in the following has both the END_HEADERS and - END_STREAM flags set; no CONTINUATION frames are sent: - - -
    - + END_STREAM - Accept: image/jpeg + END_HEADERS - :method = GET - :scheme = https - :path = /resource - host = example.org - accept = image/jpeg -]]> -
    - - - Similarly, a response that includes only response header fields is transmitted as a - HEADERS frame (again, followed by zero or more - CONTINUATION frames) containing the serialized block of response header - fields. - - -
    - + END_STREAM - Expires: Thu, 23 Jan ... + END_HEADERS - :status = 304 - etag = "xyzzy" - expires = Thu, 23 Jan ... -]]> -
    - - - An HTTP POST request that includes request header fields and payload data is transmitted - as one HEADERS frame, followed by zero or more - CONTINUATION frames containing the request header fields, followed by one - or more DATA frames, with the last CONTINUATION (or - HEADERS) frame having the END_HEADERS flag set and the final - DATA frame having the END_STREAM flag set: - - -
    - - END_STREAM - Content-Type: image/jpeg - END_HEADERS - Content-Length: 123 :method = POST - :path = /resource - {binary data} :scheme = https - - CONTINUATION - + END_HEADERS - content-type = image/jpeg - host = example.org - content-length = 123 - - DATA - + END_STREAM - {binary data} -]]> - - Note that data contributing to any given header field could be spread between header - block fragments. The allocation of header fields to frames in this example is - illustrative only. - -
    - - - A response that includes header fields and payload data is transmitted as a - HEADERS frame, followed by zero or more CONTINUATION - frames, followed by one or more DATA frames, with the last - DATA frame in the sequence having the END_STREAM flag set: - - -
    - - END_STREAM - Content-Length: 123 + END_HEADERS - :status = 200 - {binary data} content-type = image/jpeg - content-length = 123 - - DATA - + END_STREAM - {binary data} -]]> -
    - - - Trailing header fields are sent as a header block after both the request or response - header block and all the DATA frames have been sent. The - HEADERS frame starting the trailers header block has the END_STREAM flag - set. - - -
    - - END_STREAM - Transfer-Encoding: chunked + END_HEADERS - Trailer: Foo :status = 200 - content-length = 123 - 123 content-type = image/jpeg - {binary data} trailer = Foo - 0 - Foo: bar DATA - - END_STREAM - {binary data} - - HEADERS - + END_STREAM - + END_HEADERS - foo = bar -]]> -
    - - -
    - - An informational response using a 1xx status code other than 101 is transmitted as a - HEADERS frame, followed by zero or more CONTINUATION - frames: - - - END_STREAM - + END_HEADERS - :status = 103 - extension-field = bar -]]> -
    -
    - -
    - - In HTTP/1.1, an HTTP client is unable to retry a non-idempotent request when an error - occurs, because there is no means to determine the nature of the error. It is possible - that some server processing occurred prior to the error, which could result in - undesirable effects if the request were reattempted. - - - HTTP/2 provides two mechanisms for providing a guarantee to a client that a request has - not been processed: - - - The GOAWAY frame indicates the highest stream number that might have - been processed. Requests on streams with higher numbers are therefore guaranteed to - be safe to retry. - - - The REFUSED_STREAM error code can be included in a - RST_STREAM frame to indicate that the stream is being closed prior to - any processing having occurred. Any request that was sent on the reset stream can - be safely retried. - - - - - Requests that have not been processed have not failed; clients MAY automatically retry - them, even those with non-idempotent methods. - - - A server MUST NOT indicate that a stream has not been processed unless it can guarantee - that fact. If frames that are on a stream are passed to the application layer for any - stream, then REFUSED_STREAM MUST NOT be used for that stream, and a - GOAWAY frame MUST include a stream identifier that is greater than or - equal to the given stream identifier. - - - In addition to these mechanisms, the PING frame provides a way for a - client to easily test a connection. Connections that remain idle can become broken as - some middleboxes (for instance, network address translators, or load balancers) silently - discard connection bindings. The PING frame allows a client to safely - test whether a connection is still active without sending a request. - -
    -
    - -
    - - HTTP/2 allows a server to pre-emptively send (or "push") responses (along with - corresponding "promised" requests) to a client in association with a previous - client-initiated request. This can be useful when the server knows the client will need - to have those responses available in order to fully process the response to the original - request. - - - - Pushing additional message exchanges in this fashion is optional, and is negotiated - between individual endpoints. The SETTINGS_ENABLE_PUSH setting can be set - to 0 to indicate that server push is disabled. - - - Promised requests MUST be cacheable (see ), MUST be safe (see ) and MUST NOT include a request body. Clients that receive a - promised request that is not cacheable, unsafe or that includes a request body MUST - reset the stream with a stream error of type - PROTOCOL_ERROR. - - - Pushed responses that are cacheable (see ) can be stored by the client, if it implements a HTTP - cache. Pushed responses are considered successfully validated on the origin server (e.g., - if the "no-cache" cache response directive is present) while the stream identified by the - promised stream ID is still open. - - - Pushed responses that are not cacheable MUST NOT be stored by any HTTP cache. They MAY - be made available to the application separately. - - - An intermediary can receive pushes from the server and choose not to forward them on to - the client. In other words, how to make use of the pushed information is up to that - intermediary. Equally, the intermediary might choose to make additional pushes to the - client, without any action taken by the server. - - - A client cannot push. Thus, servers MUST treat the receipt of a - PUSH_PROMISE frame as a connection - error of type PROTOCOL_ERROR. Clients MUST reject any attempt to - change the SETTINGS_ENABLE_PUSH setting to a value other than 0 by treating - the message as a connection error of type - PROTOCOL_ERROR. - - -
    - - Server push is semantically equivalent to a server responding to a request; however, in - this case that request is also sent by the server, as a PUSH_PROMISE - frame. - - - The PUSH_PROMISE frame includes a header block that contains a complete - set of request header fields that the server attributes to the request. It is not - possible to push a response to a request that includes a request body. - - - - Pushed responses are always associated with an explicit request from the client. The - PUSH_PROMISE frames sent by the server are sent on that explicit - request's stream. The PUSH_PROMISE frame also includes a promised stream - identifier, chosen from the stream identifiers available to the server (see ). - - - - The header fields in PUSH_PROMISE and any subsequent - CONTINUATION frames MUST be a valid and complete set of request header fields. The server MUST include a method in - the :method header field that is safe and cacheable. If a - client receives a PUSH_PROMISE that does not include a complete and valid - set of header fields, or the :method header field identifies - a method that is not safe, it MUST respond with a stream error of type PROTOCOL_ERROR. - - - - The server SHOULD send PUSH_PROMISE () - frames prior to sending any frames that reference the promised responses. This avoids a - race where clients issue requests prior to receiving any PUSH_PROMISE - frames. - - - For example, if the server receives a request for a document containing embedded links - to multiple image files, and the server chooses to push those additional images to the - client, sending push promises before the DATA frames that contain the - image links ensures that the client is able to see the promises before discovering - embedded links. Similarly, if the server pushes responses referenced by the header block - (for instance, in Link header fields), sending the push promises before sending the - header block ensures that clients do not request them. - - - - PUSH_PROMISE frames MUST NOT be sent by the client. - - - PUSH_PROMISE frames can be sent by the server in response to any - client-initiated stream, but the stream MUST be in either the "open" or "half closed - (remote)" state with respect to the server. PUSH_PROMISE frames are - interspersed with the frames that comprise a response, though they cannot be - interspersed with HEADERS and CONTINUATION frames that - comprise a single header block. - - - Sending a PUSH_PROMISE frame creates a new stream and puts the stream - into the “reserved (local)†state for the server and the “reserved (remote)†state for - the client. - -
    - -
    - - After sending the PUSH_PROMISE frame, the server can begin delivering the - pushed response as a response on a server-initiated - stream that uses the promised stream identifier. The server uses this stream to - transmit an HTTP response, using the same sequence of frames as defined in . This stream becomes "half closed" - to the client after the initial HEADERS frame is sent. - - - - Once a client receives a PUSH_PROMISE frame and chooses to accept the - pushed response, the client SHOULD NOT issue any requests for the promised response - until after the promised stream has closed. - - - - If the client determines, for any reason, that it does not wish to receive the pushed - response from the server, or if the server takes too long to begin sending the promised - response, the client can send an RST_STREAM frame, using either the - CANCEL or REFUSED_STREAM codes, and referencing the pushed - stream's identifier. - - - A client can use the SETTINGS_MAX_CONCURRENT_STREAMS setting to limit the - number of responses that can be concurrently pushed by a server. Advertising a - SETTINGS_MAX_CONCURRENT_STREAMS value of zero disables server push by - preventing the server from creating the necessary streams. This does not prohibit a - server from sending PUSH_PROMISE frames; clients need to reset any - promised streams that are not wanted. - - - - Clients receiving a pushed response MUST validate that either the server is - authoritative (see ), or the proxy that provided the pushed - response is configured for the corresponding request. For example, a server that offers - a certificate for only the example.com DNS-ID or Common Name - is not permitted to push a response for https://www.example.org/doc. - - - The response for a PUSH_PROMISE stream begins with a - HEADERS frame, which immediately puts the stream into the “half closed - (remote)†state for the server and “half closed (local)†state for the client, and ends - with a frame bearing END_STREAM, which places the stream in the "closed" state. - - - The client never sends a frame with the END_STREAM flag for a server push. - - - -
    - -
    - -
    - - In HTTP/1.x, the pseudo-method CONNECT () is used to convert an HTTP connection into a tunnel to a remote host. - CONNECT is primarily used with HTTP proxies to establish a TLS session with an origin - server for the purposes of interacting with https resources. - - - In HTTP/2, the CONNECT method is used to establish a tunnel over a single HTTP/2 stream to - a remote host, for similar purposes. The HTTP header field mapping works as defined in - Request Header Fields, with a few - differences. Specifically: - - - The :method header field is set to CONNECT. - - - The :scheme and :path header - fields MUST be omitted. - - - The :authority header field contains the host and port to - connect to (equivalent to the authority-form of the request-target of CONNECT - requests, see ). - - - - - A proxy that supports CONNECT establishes a TCP connection to - the server identified in the :authority header field. Once - this connection is successfully established, the proxy sends a HEADERS - frame containing a 2xx series status code to the client, as defined in . - - - After the initial HEADERS frame sent by each peer, all subsequent - DATA frames correspond to data sent on the TCP connection. The payload of - any DATA frames sent by the client is transmitted by the proxy to the TCP - server; data received from the TCP server is assembled into DATA frames by - the proxy. Frame types other than DATA or stream management frames - (RST_STREAM, WINDOW_UPDATE, and PRIORITY) - MUST NOT be sent on a connected stream, and MUST be treated as a stream error if received. - - - The TCP connection can be closed by either peer. The END_STREAM flag on a - DATA frame is treated as being equivalent to the TCP FIN bit. A client is - expected to send a DATA frame with the END_STREAM flag set after receiving - a frame bearing the END_STREAM flag. A proxy that receives a DATA frame - with the END_STREAM flag set sends the attached data with the FIN bit set on the last TCP - segment. A proxy that receives a TCP segment with the FIN bit set sends a - DATA frame with the END_STREAM flag set. Note that the final TCP segment - or DATA frame could be empty. - - - A TCP connection error is signaled with RST_STREAM. A proxy treats any - error in the TCP connection, which includes receiving a TCP segment with the RST bit set, - as a stream error of type - CONNECT_ERROR. Correspondingly, a proxy MUST send a TCP segment with the - RST bit set if it detects an error with the stream or the HTTP/2 connection. - -
    -
    - -
    - - This section outlines attributes of the HTTP protocol that improve interoperability, reduce - exposure to known security vulnerabilities, or reduce the potential for implementation - variation. - - -
    - - HTTP/2 connections are persistent. For best performance, it is expected clients will not - close connections until it is determined that no further communication with a server is - necessary (for example, when a user navigates away from a particular web page), or until - the server closes the connection. - - - Clients SHOULD NOT open more than one HTTP/2 connection to a given host and port pair, - where host is derived from a URI, a selected alternative - service, or a configured proxy. - - - A client can create additional connections as replacements, either to replace connections - that are near to exhausting the available stream - identifier space, to refresh the keying material for a TLS connection, or to - replace connections that have encountered errors. - - - A client MAY open multiple connections to the same IP address and TCP port using different - Server Name Indication values or to provide different TLS - client certificates, but SHOULD avoid creating multiple connections with the same - configuration. - - - Servers are encouraged to maintain open connections for as long as possible, but are - permitted to terminate idle connections if necessary. When either endpoint chooses to - close the transport-layer TCP connection, the terminating endpoint SHOULD first send a - GOAWAY () frame so that both endpoints can reliably - determine whether previously sent frames have been processed and gracefully complete or - terminate any necessary remaining tasks. - - -
    - - Connections that are made to an origin servers, either directly or through a tunnel - created using the CONNECT method MAY be reused for - requests with multiple different URI authority components. A connection can be reused - as long as the origin server is authoritative. For - http resources, this depends on the host having resolved to - the same IP address. - - - For https resources, connection reuse additionally depends - on having a certificate that is valid for the host in the URI. An origin server might - offer a certificate with multiple subjectAltName attributes, - or names with wildcards, one of which is valid for the authority in the URI. For - example, a certificate with a subjectAltName of *.example.com might permit the use of the same connection for - requests to URIs starting with https://a.example.com/ and - https://b.example.com/. - - - In some deployments, reusing a connection for multiple origins can result in requests - being directed to the wrong origin server. For example, TLS termination might be - performed by a middlebox that uses the TLS Server Name Indication - (SNI) extension to select an origin server. This means that it is possible - for clients to send confidential information to servers that might not be the intended - target for the request, even though the server is otherwise authoritative. - - - A server that does not wish clients to reuse connections can indicate that it is not - authoritative for a request by sending a 421 (Misdirected Request) status code in response - to the request (see ). - - - A client that is configured to use a proxy over HTTP/2 directs requests to that proxy - through a single connection. That is, all requests sent via a proxy reuse the - connection to the proxy. - -
    - -
    - - The 421 (Misdirected Request) status code indicates that the request was directed at a - server that is not able to produce a response. This can be sent by a server that is not - configured to produce responses for the combination of scheme and authority that are - included in the request URI. - - - Clients receiving a 421 (Misdirected Request) response from a server MAY retry the - request - whether the request method is idempotent or not - over a different connection. - This is possible if a connection is reused () or if an alternative - service is selected (). - - - This status code MUST NOT be generated by proxies. - - - A 421 response is cacheable by default; i.e., unless otherwise indicated by the method - definition or explicit cache controls (see ). - -
    -
    - -
    - - Implementations of HTTP/2 MUST support TLS 1.2 for HTTP/2 over - TLS. The general TLS usage guidance in SHOULD be followed, with - some additional restrictions that are specific to HTTP/2. - - - - An implementation of HTTP/2 over TLS MUST use TLS 1.2 or higher with the restrictions on - feature set and cipher suite described in this section. Due to implementation - limitations, it might not be possible to fail TLS negotiation. An endpoint MUST - immediately terminate an HTTP/2 connection that does not meet these minimum requirements - with a connection error of type - INADEQUATE_SECURITY. - - -
    - - The TLS implementation MUST support the Server Name Indication - (SNI) extension to TLS. HTTP/2 clients MUST indicate the target domain name when - negotiating TLS. - - - The TLS implementation MUST disable compression. TLS compression can lead to the - exposure of information that would not otherwise be revealed . - Generic compression is unnecessary since HTTP/2 provides compression features that are - more aware of context and therefore likely to be more appropriate for use for - performance, security or other reasons. - - - The TLS implementation MUST disable renegotiation. An endpoint MUST treat a TLS - renegotiation as a connection error of type - PROTOCOL_ERROR. Note that disabling renegotiation can result in - long-lived connections becoming unusable due to limits on the number of messages the - underlying cipher suite can encipher. - - - A client MAY use renegotiation to provide confidentiality protection for client - credentials offered in the handshake, but any renegotiation MUST occur prior to sending - the connection preface. A server SHOULD request a client certificate if it sees a - renegotiation request immediately after establishing a connection. - - - This effectively prevents the use of renegotiation in response to a request for a - specific protected resource. A future specification might provide a way to support this - use case. - -
    - -
    - - The set of TLS cipher suites that are permitted in HTTP/2 is restricted. HTTP/2 MUST - only be used with cipher suites that have ephemeral key exchange, such as the ephemeral Diffie-Hellman (DHE) or the elliptic curve variant (ECDHE). Ephemeral key exchange MUST - have a minimum size of 2048 bits for DHE or security level of 128 bits for ECDHE. - Clients MUST accept DHE sizes of up to 4096 bits. HTTP MUST NOT be used with cipher - suites that use stream or block ciphers. Authenticated Encryption with Additional Data - (AEAD) modes, such as the Galois Counter Model (GCM) mode for - AES are acceptable. - - - The effect of these restrictions is that TLS 1.2 implementations could have - non-intersecting sets of available cipher suites, since these prevent the use of the - cipher suite that TLS 1.2 makes mandatory. To avoid this problem, implementations of - HTTP/2 that use TLS 1.2 MUST support TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 with P256 . - - - Clients MAY advertise support of cipher suites that are prohibited by the above - restrictions in order to allow for connection to servers that do not support HTTP/2. - This enables a fallback to protocols without these constraints without the additional - latency imposed by using a separate connection for fallback. - -
    -
    -
    - -
    -
    - - HTTP/2 relies on the HTTP/1.1 definition of authority for determining whether a server is - authoritative in providing a given response, see . This relies on local name resolution for the "http" - URI scheme, and the authenticated server identity for the "https" scheme (see ). - -
    - -
    - - In a cross-protocol attack, an attacker causes a client to initiate a transaction in one - protocol toward a server that understands a different protocol. An attacker might be able - to cause the transaction to appear as valid transaction in the second protocol. In - combination with the capabilities of the web context, this can be used to interact with - poorly protected servers in private networks. - - - Completing a TLS handshake with an ALPN identifier for HTTP/2 can be considered sufficient - protection against cross protocol attacks. ALPN provides a positive indication that a - server is willing to proceed with HTTP/2, which prevents attacks on other TLS-based - protocols. - - - The encryption in TLS makes it difficult for attackers to control the data which could be - used in a cross-protocol attack on a cleartext protocol. - - - The cleartext version of HTTP/2 has minimal protection against cross-protocol attacks. - The connection preface contains a string that is - designed to confuse HTTP/1.1 servers, but no special protection is offered for other - protocols. A server that is willing to ignore parts of an HTTP/1.1 request containing an - Upgrade header field in addition to the client connection preface could be exposed to a - cross-protocol attack. - -
    - -
    - - HTTP/2 header field names and values are encoded as sequences of octets with a length - prefix. This enables HTTP/2 to carry any string of octets as the name or value of a - header field. An intermediary that translates HTTP/2 requests or responses into HTTP/1.1 - directly could permit the creation of corrupted HTTP/1.1 messages. An attacker might - exploit this behavior to cause the intermediary to create HTTP/1.1 messages with illegal - header fields, extra header fields, or even new messages that are entirely falsified. - - - Header field names or values that contain characters not permitted by HTTP/1.1, including - carriage return (ASCII 0xd) or line feed (ASCII 0xa) MUST NOT be translated verbatim by an - intermediary, as stipulated in . - - - Translation from HTTP/1.x to HTTP/2 does not produce the same opportunity to an attacker. - Intermediaries that perform translation to HTTP/2 MUST remove any instances of the obs-fold production from header field values. - -
    - -
    - - Pushed responses do not have an explicit request from the client; the request - is provided by the server in the PUSH_PROMISE frame. - - - Caching responses that are pushed is possible based on the guidance provided by the origin - server in the Cache-Control header field. However, this can cause issues if a single - server hosts more than one tenant. For example, a server might offer multiple users each - a small portion of its URI space. - - - Where multiple tenants share space on the same server, that server MUST ensure that - tenants are not able to push representations of resources that they do not have authority - over. Failure to enforce this would allow a tenant to provide a representation that would - be served out of cache, overriding the actual representation that the authoritative tenant - provides. - - - Pushed responses for which an origin server is not authoritative (see - ) are never cached or used. - -
    - -
    - - An HTTP/2 connection can demand a greater commitment of resources to operate than a - HTTP/1.1 connection. The use of header compression and flow control depend on a - commitment of resources for storing a greater amount of state. Settings for these - features ensure that memory commitments for these features are strictly bounded. - - - The number of PUSH_PROMISE frames is not constrained in the same fashion. - A client that accepts server push SHOULD limit the number of streams it allows to be in - the "reserved (remote)" state. Excessive number of server push streams can be treated as - a stream error of type - ENHANCE_YOUR_CALM. - - - Processing capacity cannot be guarded as effectively as state capacity. - - - The SETTINGS frame can be abused to cause a peer to expend additional - processing time. This might be done by pointlessly changing SETTINGS parameters, setting - multiple undefined parameters, or changing the same setting multiple times in the same - frame. WINDOW_UPDATE or PRIORITY frames can be abused to - cause an unnecessary waste of resources. - - - Large numbers of small or empty frames can be abused to cause a peer to expend time - processing frame headers. Note however that some uses are entirely legitimate, such as - the sending of an empty DATA frame to end a stream. - - - Header compression also offers some opportunities to waste processing resources; see for more details on potential abuses. - - - Limits in SETTINGS parameters cannot be reduced instantaneously, which - leaves an endpoint exposed to behavior from a peer that could exceed the new limits. In - particular, immediately after establishing a connection, limits set by a server are not - known to clients and could be exceeded without being an obvious protocol violation. - - - All these features - i.e., SETTINGS changes, small frames, header - compression - have legitimate uses. These features become a burden only when they are - used unnecessarily or to excess. - - - An endpoint that doesn't monitor this behavior exposes itself to a risk of denial of - service attack. Implementations SHOULD track the use of these features and set limits on - their use. An endpoint MAY treat activity that is suspicious as a connection error of type - ENHANCE_YOUR_CALM. - - -
    - - A large header block can cause an implementation to - commit a large amount of state. Header fields that are critical for routing can appear - toward the end of a header block, which prevents streaming of header fields to their - ultimate destination. For this an other reasons, such as ensuring cache correctness, - means that an endpoint might need to buffer the entire header block. Since there is no - hard limit to the size of a header block, some endpoints could be forced commit a large - amount of available memory for header fields. - - - An endpoint can use the SETTINGS_MAX_HEADER_LIST_SIZE to advise peers of - limits that might apply on the size of header blocks. This setting is only advisory, so - endpoints MAY choose to send header blocks that exceed this limit and risk having the - request or response being treated as malformed. This setting specific to a connection, - so any request or response could encounter a hop with a lower, unknown limit. An - intermediary can attempt to avoid this problem by passing on values presented by - different peers, but they are not obligated to do so. - - - A server that receives a larger header block than it is willing to handle can send an - HTTP 431 (Request Header Fields Too Large) status code . A - client can discard responses that it cannot process. The header block MUST be processed - to ensure a consistent connection state, unless the connection is closed. - -
    -
    - -
    - - HTTP/2 enables greater use of compression for both header fields () and entity bodies. Compression can allow an attacker to recover - secret data when it is compressed in the same context as data under attacker control. - - - There are demonstrable attacks on compression that exploit the characteristics of the web - (e.g., ). The attacker induces multiple requests containing - varying plaintext, observing the length of the resulting ciphertext in each, which - reveals a shorter length when a guess about the secret is correct. - - - Implementations communicating on a secure channel MUST NOT compress content that includes - both confidential and attacker-controlled data unless separate compression dictionaries - are used for each source of data. Compression MUST NOT be used if the source of data - cannot be reliably determined. Generic stream compression, such as that provided by TLS - MUST NOT be used with HTTP/2 (). - - - Further considerations regarding the compression of header fields are described in . - -
    - -
    - - Padding within HTTP/2 is not intended as a replacement for general purpose padding, such - as might be provided by TLS. Redundant padding could even be - counterproductive. Correct application can depend on having specific knowledge of the - data that is being padded. - - - To mitigate attacks that rely on compression, disabling or limiting compression might be - preferable to padding as a countermeasure. - - - Padding can be used to obscure the exact size of frame content, and is provided to - mitigate specific attacks within HTTP. For example, attacks where compressed content - includes both attacker-controlled plaintext and secret data (see for example, ). - - - Use of padding can result in less protection than might seem immediately obvious. At - best, padding only makes it more difficult for an attacker to infer length information by - increasing the number of frames an attacker has to observe. Incorrectly implemented - padding schemes can be easily defeated. In particular, randomized padding with a - predictable distribution provides very little protection; similarly, padding payloads to a - fixed size exposes information as payload sizes cross the fixed size boundary, which could - be possible if an attacker can control plaintext. - - - Intermediaries SHOULD retain padding for DATA frames, but MAY drop padding - for HEADERS and PUSH_PROMISE frames. A valid reason for an - intermediary to change the amount of padding of frames is to improve the protections that - padding provides. - -
    - -
    - - Several characteristics of HTTP/2 provide an observer an opportunity to correlate actions - of a single client or server over time. This includes the value of settings, the manner - in which flow control windows are managed, the way priorities are allocated to streams, - timing of reactions to stimulus, and handling of any optional features. - - - As far as this creates observable differences in behavior, they could be used as a basis - for fingerprinting a specific client, as defined in . - -
    -
    - -
    - - A string for identifying HTTP/2 is entered into the "Application Layer Protocol Negotiation - (ALPN) Protocol IDs" registry established in . - - - This document establishes a registry for frame types, settings, and error codes. These new - registries are entered into a new "Hypertext Transfer Protocol (HTTP) 2 Parameters" section. - - - This document registers the HTTP2-Settings header field for - use in HTTP; and the 421 (Misdirected Request) status code. - - - This document registers the PRI method for use in HTTP, to avoid - collisions with the connection preface. - - -
    - - This document creates two registrations for the identification of HTTP/2 in the - "Application Layer Protocol Negotiation (ALPN) Protocol IDs" registry established in . - - - The "h2" string identifies HTTP/2 when used over TLS: - - HTTP/2 over TLS - 0x68 0x32 ("h2") - This document - - - - The "h2c" string identifies HTTP/2 when used over cleartext TCP: - - HTTP/2 over TCP - 0x68 0x32 0x63 ("h2c") - This document - - -
    - -
    - - This document establishes a registry for HTTP/2 frame type codes. The "HTTP/2 Frame - Type" registry manages an 8-bit space. The "HTTP/2 Frame Type" registry operates under - either of the "IETF Review" or "IESG Approval" policies for - values between 0x00 and 0xef, with values between 0xf0 and 0xff being reserved for - experimental use. - - - New entries in this registry require the following information: - - - A name or label for the frame type. - - - The 8-bit code assigned to the frame type. - - - A reference to a specification that includes a description of the frame layout, - it's semantics and flags that the frame type uses, including any parts of the frame - that are conditionally present based on the value of flags. - - - - - The entries in the following table are registered by this document. - - - Frame Type - Code - Section - DATA0x0 - HEADERS0x1 - PRIORITY0x2 - RST_STREAM0x3 - SETTINGS0x4 - PUSH_PROMISE0x5 - PING0x6 - GOAWAY0x7 - WINDOW_UPDATE0x8 - CONTINUATION0x9 - -
    - -
    - - This document establishes a registry for HTTP/2 settings. The "HTTP/2 Settings" registry - manages a 16-bit space. The "HTTP/2 Settings" registry operates under the "Expert Review" policy for values in the range from 0x0000 to - 0xefff, with values between and 0xf000 and 0xffff being reserved for experimental use. - - - New registrations are advised to provide the following information: - - - A symbolic name for the setting. Specifying a setting name is optional. - - - The 16-bit code assigned to the setting. - - - An initial value for the setting. - - - An optional reference to a specification that describes the use of the setting. - - - - - An initial set of setting registrations can be found in . - - - Name - Code - Initial Value - Specification - HEADER_TABLE_SIZE - 0x14096 - ENABLE_PUSH - 0x21 - MAX_CONCURRENT_STREAMS - 0x3(infinite) - INITIAL_WINDOW_SIZE - 0x465535 - MAX_FRAME_SIZE - 0x516384 - MAX_HEADER_LIST_SIZE - 0x6(infinite) - - -
    - -
    - - This document establishes a registry for HTTP/2 error codes. The "HTTP/2 Error Code" - registry manages a 32-bit space. The "HTTP/2 Error Code" registry operates under the - "Expert Review" policy. - - - Registrations for error codes are required to include a description of the error code. An - expert reviewer is advised to examine new registrations for possible duplication with - existing error codes. Use of existing registrations is to be encouraged, but not - mandated. - - - New registrations are advised to provide the following information: - - - A name for the error code. Specifying an error code name is optional. - - - The 32-bit error code value. - - - A brief description of the error code semantics, longer if no detailed specification - is provided. - - - An optional reference for a specification that defines the error code. - - - - - The entries in the following table are registered by this document. - - - Name - Code - Description - Specification - NO_ERROR0x0 - Graceful shutdown - - PROTOCOL_ERROR0x1 - Protocol error detected - - INTERNAL_ERROR0x2 - Implementation fault - - FLOW_CONTROL_ERROR0x3 - Flow control limits exceeded - - SETTINGS_TIMEOUT0x4 - Settings not acknowledged - - STREAM_CLOSED0x5 - Frame received for closed stream - - FRAME_SIZE_ERROR0x6 - Frame size incorrect - - REFUSED_STREAM0x7 - Stream not processed - - CANCEL0x8 - Stream cancelled - - COMPRESSION_ERROR0x9 - Compression state not updated - - CONNECT_ERROR0xa - TCP connection error for CONNECT method - - ENHANCE_YOUR_CALM0xb - Processing capacity exceeded - - INADEQUATE_SECURITY0xc - Negotiated TLS parameters not acceptable - - - -
    - -
    - - This section registers the HTTP2-Settings header field in the - Permanent Message Header Field Registry. - - - HTTP2-Settings - - - http - - - standard - - - IETF - - - of this document - - - This header field is only used by an HTTP/2 client for Upgrade-based negotiation. - - - -
    - -
    - - This section registers the PRI method in the HTTP Method - Registry (). - - - PRI - - - No - - - No - - - of this document - - - This method is never used by an actual client. This method will appear to be used - when an HTTP/1.1 server or intermediary attempts to parse an HTTP/2 connection - preface. - - - -
    - -
    - - This document registers the 421 (Misdirected Request) HTTP Status code in the Hypertext - Transfer Protocol (HTTP) Status Code Registry (). - - - - - 421 - - - Misdirected Request - - - of this document - - - -
    - -
    - -
    - - This document includes substantial input from the following individuals: - - - Adam Langley, Wan-Teh Chang, Jim Morrison, Mark Nottingham, Alyssa Wilk, Costin - Manolache, William Chan, Vitaliy Lvin, Joe Chan, Adam Barth, Ryan Hamilton, Gavin - Peters, Kent Alstad, Kevin Lindsay, Paul Amer, Fan Yang, Jonathan Leighton (SPDY - contributors). - - - Gabriel Montenegro and Willy Tarreau (Upgrade mechanism). - - - William Chan, Salvatore Loreto, Osama Mazahir, Gabriel Montenegro, Jitu Padhye, Roberto - Peon, Rob Trace (Flow control). - - - Mike Bishop (Extensibility). - - - Mark Nottingham, Julian Reschke, James Snell, Jeff Pinner, Mike Bishop, Herve Ruellan - (Substantial editorial contributions). - - - Kari Hurtta, Tatsuhiro Tsujikawa, Greg Wilkins, Poul-Henning Kamp. - - - Alexey Melnikov was an editor of this document during 2013. - - - A substantial proportion of Martin's contribution was supported by Microsoft during his - employment there. - - - -
    -
    - - - - - - HPACK - Header Compression for HTTP/2 - - - - - - - - - - - - Transmission Control Protocol - - - University of Southern California (USC)/Information Sciences - Institute - - - - - - - - - - - Key words for use in RFCs to Indicate Requirement Levels - - - Harvard University -
    sob@harvard.edu
    -
    - -
    - - -
    - - - - - HTTP Over TLS - - - - - - - - - - Uniform Resource Identifier (URI): Generic - Syntax - - - - - - - - - - - - The Base16, Base32, and Base64 Data Encodings - - - - - - - - - Guidelines for Writing an IANA Considerations Section in RFCs - - - - - - - - - - - Augmented BNF for Syntax Specifications: ABNF - - - - - - - - - - - The Transport Layer Security (TLS) Protocol Version 1.2 - - - - - - - - - - - Transport Layer Security (TLS) Extensions: Extension Definitions - - - - - - - - - - Transport Layer Security (TLS) Application-Layer Protocol Negotiation Extension - - - - - - - - - - - - - TLS Elliptic Curve Cipher Suites with SHA-256/384 and AES Galois - Counter Mode (GCM) - - - - - - - - - - - Digital Signature Standard (DSS) - - NIST - - - - - - - - - Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing - - Adobe Systems Incorporated -
    fielding@gbiv.com
    -
    - - greenbytes GmbH -
    julian.reschke@greenbytes.de
    -
    - -
    - - -
    - - - - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content - - Adobe Systems Incorporated -
    fielding@gbiv.com
    -
    - - greenbytes GmbH -
    julian.reschke@greenbytes.de
    -
    - -
    - - -
    - - - Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests - - Adobe Systems Incorporated -
    fielding@gbiv.com
    -
    - - greenbytes GmbH -
    julian.reschke@greenbytes.de
    -
    - -
    - -
    - - - Hypertext Transfer Protocol (HTTP/1.1): Range Requests - - Adobe Systems Incorporated -
    fielding@gbiv.com
    -
    - - World Wide Web Consortium -
    ylafon@w3.org
    -
    - - greenbytes GmbH -
    julian.reschke@greenbytes.de
    -
    - -
    - -
    - - - Hypertext Transfer Protocol (HTTP/1.1): Caching - - Adobe Systems Incorporated -
    fielding@gbiv.com
    -
    - - Akamai -
    mnot@mnot.net
    -
    - - greenbytes GmbH -
    julian.reschke@greenbytes.de
    -
    - -
    - - -
    - - - Hypertext Transfer Protocol (HTTP/1.1): Authentication - - Adobe Systems Incorporated -
    fielding@gbiv.com
    -
    - - greenbytes GmbH -
    julian.reschke@greenbytes.de
    -
    - -
    - - -
    - - - - HTTP State Management Mechanism - - - - - -
    - - - - - - TCP Extensions for High Performance - - - - - - - - - - - - Transport Layer Security Protocol Compression Methods - - - - - - - - - Additional HTTP Status Codes - - - - - - - - - - - Elliptic Curve Cryptography (ECC) Cipher Suites for Transport Layer Security (TLS) - - - - - - - - - - - - - - - AES Galois Counter Mode (GCM) Cipher Suites for TLS - - - - - - - - - - - - HTML5 - - - - - - - - - - - Latest version available at - . - - - - - - - Talking to Yourself for Fun and Profit - - - - - - - - - - - - - - BREACH: Reviving the CRIME Attack - - - - - - - - - - - Registration Procedures for Message Header Fields - - Nine by Nine -
    GK-IETF@ninebynine.org
    -
    - - BEA Systems -
    mnot@pobox.com
    -
    - - HP Labs -
    JeffMogul@acm.org
    -
    - -
    - - -
    - - - - Recommendations for Secure Use of TLS and DTLS - - - - - - - - - - - - - - - - - - HTTP Alternative Services - - - Akamai - - - Mozilla - - - greenbytes - - - - - - -
    - -
    - - This section is to be removed by RFC Editor before publication. - - -
    - - Renamed Not Authoritative status code to Misdirected Request. - -
    - -
    - - Pseudo-header fields are now required to appear strictly before regular ones. - - - Restored 1xx series status codes, except 101. - - - Changed frame length field 24-bits. Expanded frame header to 9 octets. Added a setting - to limit the damage. - - - Added a setting to advise peers of header set size limits. - - - Removed segments. - - - Made non-semantic-bearing HEADERS frames illegal in the HTTP mapping. - -
    - -
    - - Restored extensibility options. - - - Restricting TLS cipher suites to AEAD only. - - - Removing Content-Encoding requirements. - - - Permitting the use of PRIORITY after stream close. - - - Removed ALTSVC frame. - - - Removed BLOCKED frame. - - - Reducing the maximum padding size to 256 octets; removing padding from - CONTINUATION frames. - - - Removed per-frame GZIP compression. - -
    - -
    - - Added BLOCKED frame (at risk). - - - Simplified priority scheme. - - - Added DATA per-frame GZIP compression. - -
    - -
    - - Changed "connection header" to "connection preface" to avoid confusion. - - - Added dependency-based stream prioritization. - - - Added "h2c" identifier to distinguish between cleartext and secured HTTP/2. - - - Adding missing padding to PUSH_PROMISE. - - - Integrate ALTSVC frame and supporting text. - - - Dropping requirement on "deflate" Content-Encoding. - - - Improving security considerations around use of compression. - -
    - -
    - - Adding padding for data frames. - - - Renumbering frame types, error codes, and settings. - - - Adding INADEQUATE_SECURITY error code. - - - Updating TLS usage requirements to 1.2; forbidding TLS compression. - - - Removing extensibility for frames and settings. - - - Changing setting identifier size. - - - Removing the ability to disable flow control. - - - Changing the protocol identification token to "h2". - - - Changing the use of :authority to make it optional and to allow userinfo in non-HTTP - cases. - - - Allowing split on 0x0 for Cookie. - - - Reserved PRI method in HTTP/1.1 to avoid possible future collisions. - -
    - -
    - - Added cookie crumbling for more efficient header compression. - - - Added header field ordering with the value-concatenation mechanism. - -
    - -
    - - Marked draft for implementation. - -
    - -
    - - Adding definition for CONNECT method. - - - Constraining the use of push to safe, cacheable methods with no request body. - - - Changing from :host to :authority to remove any potential confusion. - - - Adding setting for header compression table size. - - - Adding settings acknowledgement. - - - Removing unnecessary and potentially problematic flags from CONTINUATION. - - - Added denial of service considerations. - -
    -
    - - Marking the draft ready for implementation. - - - Renumbering END_PUSH_PROMISE flag. - - - Editorial clarifications and changes. - -
    - -
    - - Added CONTINUATION frame for HEADERS and PUSH_PROMISE. - - - PUSH_PROMISE is no longer implicitly prohibited if SETTINGS_MAX_CONCURRENT_STREAMS is - zero. - - - Push expanded to allow all safe methods without a request body. - - - Clarified the use of HTTP header fields in requests and responses. Prohibited HTTP/1.1 - hop-by-hop header fields. - - - Requiring that intermediaries not forward requests with missing or illegal routing - :-headers. - - - Clarified requirements around handling different frames after stream close, stream reset - and GOAWAY. - - - Added more specific prohibitions for sending of different frame types in various stream - states. - - - Making the last received setting value the effective value. - - - Clarified requirements on TLS version, extension and ciphers. - -
    - -
    - - Committed major restructuring atrocities. - - - Added reference to first header compression draft. - - - Added more formal description of frame lifecycle. - - - Moved END_STREAM (renamed from FINAL) back to HEADERS/DATA. - - - Removed HEADERS+PRIORITY, added optional priority to HEADERS frame. - - - Added PRIORITY frame. - -
    - -
    - - Added continuations to frames carrying header blocks. - - - Replaced use of "session" with "connection" to avoid confusion with other HTTP stateful - concepts, like cookies. - - - Removed "message". - - - Switched to TLS ALPN from NPN. - - - Editorial changes. - -
    - -
    - - Added IANA considerations section for frame types, error codes and settings. - - - Removed data frame compression. - - - Added PUSH_PROMISE. - - - Added globally applicable flags to framing. - - - Removed zlib-based header compression mechanism. - - - Updated references. - - - Clarified stream identifier reuse. - - - Removed CREDENTIALS frame and associated mechanisms. - - - Added advice against naive implementation of flow control. - - - Added session header section. - - - Restructured frame header. Removed distinction between data and control frames. - - - Altered flow control properties to include session-level limits. - - - Added note on cacheability of pushed resources and multiple tenant servers. - - - Changed protocol label form based on discussions. - -
    - -
    - - Changed title throughout. - - - Removed section on Incompatibilities with SPDY draft#2. - - - Changed INTERNAL_ERROR on GOAWAY to have a value of 2 . - - - Replaced abstract and introduction. - - - Added section on starting HTTP/2.0, including upgrade mechanism. - - - Removed unused references. - - - Added flow control principles based on . - -
    - -
    - - Adopted as base for draft-ietf-httpbis-http2. - - - Updated authors/editors list. - - - Added status note. - -
    -
    - -
    -
    - diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go deleted file mode 100644 index 84d042d46..000000000 --- a/vendor/golang.org/x/net/http2/transport.go +++ /dev/null @@ -1,2128 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Transport code. - -package http2 - -import ( - "bufio" - "bytes" - "compress/gzip" - "crypto/rand" - "crypto/tls" - "errors" - "fmt" - "io" - "io/ioutil" - "log" - "math" - "net" - "net/http" - "sort" - "strconv" - "strings" - "sync" - "time" - - "golang.org/x/net/http2/hpack" - "golang.org/x/net/idna" - "golang.org/x/net/lex/httplex" -) - -const ( - // transportDefaultConnFlow is how many connection-level flow control - // tokens we give the server at start-up, past the default 64k. - transportDefaultConnFlow = 1 << 30 - - // transportDefaultStreamFlow is how many stream-level flow - // control tokens we announce to the peer, and how many bytes - // we buffer per stream. - transportDefaultStreamFlow = 4 << 20 - - // transportDefaultStreamMinRefresh is the minimum number of bytes we'll send - // a stream-level WINDOW_UPDATE for at a time. - transportDefaultStreamMinRefresh = 4 << 10 - - defaultUserAgent = "Go-http-client/2.0" -) - -// Transport is an HTTP/2 Transport. -// -// A Transport internally caches connections to servers. It is safe -// for concurrent use by multiple goroutines. -type Transport struct { - // DialTLS specifies an optional dial function for creating - // TLS connections for requests. - // - // If DialTLS is nil, tls.Dial is used. - // - // If the returned net.Conn has a ConnectionState method like tls.Conn, - // it will be used to set http.Response.TLS. - DialTLS func(network, addr string, cfg *tls.Config) (net.Conn, error) - - // TLSClientConfig specifies the TLS configuration to use with - // tls.Client. If nil, the default configuration is used. - TLSClientConfig *tls.Config - - // ConnPool optionally specifies an alternate connection pool to use. - // If nil, the default is used. - ConnPool ClientConnPool - - // DisableCompression, if true, prevents the Transport from - // requesting compression with an "Accept-Encoding: gzip" - // request header when the Request contains no existing - // Accept-Encoding value. If the Transport requests gzip on - // its own and gets a gzipped response, it's transparently - // decoded in the Response.Body. However, if the user - // explicitly requested gzip it is not automatically - // uncompressed. - DisableCompression bool - - // AllowHTTP, if true, permits HTTP/2 requests using the insecure, - // plain-text "http" scheme. Note that this does not enable h2c support. - AllowHTTP bool - - // MaxHeaderListSize is the http2 SETTINGS_MAX_HEADER_LIST_SIZE to - // send in the initial settings frame. It is how many bytes - // of response headers are allow. Unlike the http2 spec, zero here - // means to use a default limit (currently 10MB). If you actually - // want to advertise an ulimited value to the peer, Transport - // interprets the highest possible value here (0xffffffff or 1<<32-1) - // to mean no limit. - MaxHeaderListSize uint32 - - // t1, if non-nil, is the standard library Transport using - // this transport. Its settings are used (but not its - // RoundTrip method, etc). - t1 *http.Transport - - connPoolOnce sync.Once - connPoolOrDef ClientConnPool // non-nil version of ConnPool -} - -func (t *Transport) maxHeaderListSize() uint32 { - if t.MaxHeaderListSize == 0 { - return 10 << 20 - } - if t.MaxHeaderListSize == 0xffffffff { - return 0 - } - return t.MaxHeaderListSize -} - -func (t *Transport) disableCompression() bool { - return t.DisableCompression || (t.t1 != nil && t.t1.DisableCompression) -} - -var errTransportVersion = errors.New("http2: ConfigureTransport is only supported starting at Go 1.6") - -// ConfigureTransport configures a net/http HTTP/1 Transport to use HTTP/2. -// It requires Go 1.6 or later and returns an error if the net/http package is too old -// or if t1 has already been HTTP/2-enabled. -func ConfigureTransport(t1 *http.Transport) error { - _, err := configureTransport(t1) // in configure_transport.go (go1.6) or not_go16.go - return err -} - -func (t *Transport) connPool() ClientConnPool { - t.connPoolOnce.Do(t.initConnPool) - return t.connPoolOrDef -} - -func (t *Transport) initConnPool() { - if t.ConnPool != nil { - t.connPoolOrDef = t.ConnPool - } else { - t.connPoolOrDef = &clientConnPool{t: t} - } -} - -// ClientConn is the state of a single HTTP/2 client connection to an -// HTTP/2 server. -type ClientConn struct { - t *Transport - tconn net.Conn // usually *tls.Conn, except specialized impls - tlsState *tls.ConnectionState // nil only for specialized impls - singleUse bool // whether being used for a single http.Request - - // readLoop goroutine fields: - readerDone chan struct{} // closed on error - readerErr error // set before readerDone is closed - - idleTimeout time.Duration // or 0 for never - idleTimer *time.Timer - - 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 - pings map[[8]byte]chan struct{} // in flight ping data to notification channel - 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 - - wmu sync.Mutex // held while writing; acquire AFTER mu if holding both - werr error // first write error that has occurred -} - -// clientStream is the state for a single HTTP/2 stream. One of these -// is created for each Transport.RoundTrip call. -type clientStream struct { - cc *ClientConn - req *http.Request - trace *clientTrace // or nil - ID uint32 - resc chan resAndError - bufPipe pipe // buffered pipe with the flow-controlled response payload - startedWrite bool // started request body write; guarded by cc.mu - requestedGzip bool - on100 func() // optional code to run if get a 100 continue response - - flow flow // guarded by cc.mu - inflow flow // guarded by cc.mu - bytesRemain int64 // -1 means unknown; owned by transportResponseBody.Read - readErr error // sticky read error; owned by transportResponseBody.Read - stopReqBody error // if non-nil, stop writing req body; guarded by cc.mu - didReset bool // whether we sent a RST_STREAM to the server; guarded by cc.mu - - peerReset chan struct{} // closed on peer reset - resetErr error // populated before peerReset is closed - - done chan struct{} // closed when stream remove from cc.streams map; close calls guarded by cc.mu - - // owned by clientConnReadLoop: - firstByte bool // got the first response byte - pastHeaders bool // got first MetaHeadersFrame (actual headers) - pastTrailers bool // got optional second MetaHeadersFrame (trailers) - - trailer http.Header // accumulated trailers - resTrailer *http.Header // client's Response.Trailer -} - -// awaitRequestCancel runs in its own goroutine and waits for the user -// to cancel a RoundTrip request, its context to expire, or for the -// request to be done (any way it might be removed from the cc.streams -// map: peer reset, successful completion, TCP connection breakage, -// etc) -func (cs *clientStream) awaitRequestCancel(req *http.Request) { - ctx := reqContext(req) - if req.Cancel == nil && ctx.Done() == nil { - return - } - select { - case <-req.Cancel: - cs.cancelStream() - cs.bufPipe.CloseWithError(errRequestCanceled) - case <-ctx.Done(): - cs.cancelStream() - cs.bufPipe.CloseWithError(ctx.Err()) - case <-cs.done: - } -} - -func (cs *clientStream) cancelStream() { - cs.cc.mu.Lock() - didReset := cs.didReset - cs.didReset = true - cs.cc.mu.Unlock() - - if !didReset { - cs.cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) - } -} - -// checkResetOrDone reports any error sent in a RST_STREAM frame by the -// server, or errStreamClosed if the stream is complete. -func (cs *clientStream) checkResetOrDone() error { - select { - case <-cs.peerReset: - return cs.resetErr - case <-cs.done: - return errStreamClosed - default: - return nil - } -} - -func (cs *clientStream) abortRequestBodyWrite(err error) { - if err == nil { - panic("nil error") - } - cc := cs.cc - cc.mu.Lock() - cs.stopReqBody = err - cc.cond.Broadcast() - cc.mu.Unlock() -} - -type stickyErrWriter struct { - w io.Writer - err *error -} - -func (sew stickyErrWriter) Write(p []byte) (n int, err error) { - if *sew.err != nil { - return 0, *sew.err - } - n, err = sew.w.Write(p) - *sew.err = err - return -} - -var ErrNoCachedConn = errors.New("http2: no cached connection was available") - -// RoundTripOpt are options for the Transport.RoundTripOpt method. -type RoundTripOpt struct { - // OnlyCachedConn controls whether RoundTripOpt may - // create a new TCP connection. If set true and - // no cached connection is available, RoundTripOpt - // will return ErrNoCachedConn. - OnlyCachedConn bool -} - -func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { - return t.RoundTripOpt(req, RoundTripOpt{}) -} - -// authorityAddr returns a given authority (a host/IP, or host:port / ip:port) -// and returns a host:port. The port 443 is added if needed. -func authorityAddr(scheme string, authority string) (addr string) { - host, port, err := net.SplitHostPort(authority) - if err != nil { // authority didn't have a port - port = "443" - if scheme == "http" { - port = "80" - } - host = authority - } - if a, err := idna.ToASCII(host); err == nil { - host = a - } - // IPv6 address literal, without a port: - if strings.HasPrefix(host, "[") && strings.HasSuffix(host, "]") { - return host + ":" + port - } - return net.JoinHostPort(host, port) -} - -// RoundTripOpt is like RoundTrip, but takes options. -func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Response, error) { - if !(req.URL.Scheme == "https" || (req.URL.Scheme == "http" && t.AllowHTTP)) { - return nil, errors.New("http2: unsupported scheme") - } - - addr := authorityAddr(req.URL.Scheme, req.URL.Host) - for { - cc, err := t.connPool().GetClientConn(req, addr) - if err != nil { - t.vlogf("http2: Transport failed to get client conn for %s: %v", addr, err) - return nil, err - } - traceGotConn(req, cc) - res, err := cc.RoundTrip(req) - if err != nil { - if req, err = shouldRetryRequest(req, err); err == nil { - continue - } - } - if err != nil { - t.vlogf("RoundTrip failure: %v", err) - return nil, err - } - return res, nil - } -} - -// CloseIdleConnections closes any connections which were previously -// connected from previous requests but are now sitting idle. -// It does not interrupt any connections currently in use. -func (t *Transport) CloseIdleConnections() { - if cp, ok := t.connPool().(clientConnPoolIdleCloser); ok { - cp.closeIdleConnections() - } -} - -var ( - errClientConnClosed = errors.New("http2: client conn is closed") - errClientConnUnusable = errors.New("http2: client conn not usable") - - errClientConnGotGoAway = errors.New("http2: Transport received Server's graceful shutdown GOAWAY") - errClientConnGotGoAwayAfterSomeReqBody = errors.New("http2: Transport received Server's graceful shutdown GOAWAY; some request body already written") -) - -// shouldRetryRequest is called by RoundTrip when a request fails to get -// response headers. It is always called with a non-nil error. -// It returns either a request to retry (either the same request, or a -// modified clone), or an error if the request can't be replayed. -func shouldRetryRequest(req *http.Request, err error) (*http.Request, error) { - switch err { - default: - return nil, err - case errClientConnUnusable, errClientConnGotGoAway: - return req, nil - case errClientConnGotGoAwayAfterSomeReqBody: - // If the Body is nil (or http.NoBody), it's safe to reuse - // this request and its Body. - if req.Body == nil || reqBodyIsNoBody(req.Body) { - return req, nil - } - // Otherwise we depend on the Request having its GetBody - // func defined. - getBody := reqGetBody(req) // Go 1.8: getBody = req.GetBody - if getBody == nil { - return nil, errors.New("http2: Transport: peer server initiated graceful shutdown after some of Request.Body was written; define Request.GetBody to avoid this error") - } - body, err := getBody() - if err != nil { - return nil, err - } - newReq := *req - newReq.Body = body - return &newReq, nil - } -} - -func (t *Transport) dialClientConn(addr string, singleUse bool) (*ClientConn, error) { - host, _, err := net.SplitHostPort(addr) - if err != nil { - return nil, err - } - tconn, err := t.dialTLS()("tcp", addr, t.newTLSConfig(host)) - if err != nil { - return nil, err - } - return t.newClientConn(tconn, singleUse) -} - -func (t *Transport) newTLSConfig(host string) *tls.Config { - cfg := new(tls.Config) - if t.TLSClientConfig != nil { - *cfg = *cloneTLSConfig(t.TLSClientConfig) - } - if !strSliceContains(cfg.NextProtos, NextProtoTLS) { - cfg.NextProtos = append([]string{NextProtoTLS}, cfg.NextProtos...) - } - if cfg.ServerName == "" { - cfg.ServerName = host - } - return cfg -} - -func (t *Transport) dialTLS() func(string, string, *tls.Config) (net.Conn, error) { - if t.DialTLS != nil { - return t.DialTLS - } - return t.dialTLSDefault -} - -func (t *Transport) dialTLSDefault(network, addr string, cfg *tls.Config) (net.Conn, error) { - cn, err := tls.Dial(network, addr, cfg) - if err != nil { - return nil, err - } - if err := cn.Handshake(); err != nil { - return nil, err - } - if !cfg.InsecureSkipVerify { - if err := cn.VerifyHostname(cfg.ServerName); err != nil { - return nil, err - } - } - state := cn.ConnectionState() - if p := state.NegotiatedProtocol; p != NextProtoTLS { - return nil, fmt.Errorf("http2: unexpected ALPN protocol %q; want %q", p, NextProtoTLS) - } - if !state.NegotiatedProtocolIsMutual { - return nil, errors.New("http2: could not negotiate protocol mutually") - } - return cn, nil -} - -// disableKeepAlives reports whether connections should be closed as -// soon as possible after handling the first request. -func (t *Transport) disableKeepAlives() bool { - return t.t1 != nil && t.t1.DisableKeepAlives -} - -func (t *Transport) expectContinueTimeout() time.Duration { - if t.t1 == nil { - return 0 - } - return transportExpectContinueTimeout(t.t1) -} - -func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error) { - return t.newClientConn(c, false) -} - -func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, error) { - cc := &ClientConn{ - t: t, - tconn: c, - readerDone: make(chan struct{}), - nextStreamID: 1, - maxFrameSize: 16 << 10, // spec default - initialWindowSize: 65535, // spec default - maxConcurrentStreams: 1000, // "infinite", per spec. 1000 seems good enough. - streams: make(map[uint32]*clientStream), - singleUse: singleUse, - wantSettingsAck: true, - pings: make(map[[8]byte]chan struct{}), - } - if d := t.idleConnTimeout(); d != 0 { - cc.idleTimeout = d - cc.idleTimer = time.AfterFunc(d, cc.onIdleTimeout) - } - 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)) - - // TODO: adjust this writer size to account for frame size + - // MTU + crypto/tls record padding. - cc.bw = bufio.NewWriter(stickyErrWriter{c, &cc.werr}) - cc.br = bufio.NewReader(c) - cc.fr = NewFramer(cc.bw, cc.br) - cc.fr.ReadMetaHeaders = hpack.NewDecoder(initialHeaderTableSize, nil) - cc.fr.MaxHeaderListSize = t.maxHeaderListSize() - - // TODO: SetMaxDynamicTableSize, SetMaxDynamicTableSizeLimit on - // henc in response to SETTINGS frames? - cc.henc = hpack.NewEncoder(&cc.hbuf) - - if cs, ok := c.(connectionStater); ok { - state := cs.ConnectionState() - cc.tlsState = &state - } - - initialSettings := []Setting{ - {ID: SettingEnablePush, Val: 0}, - {ID: SettingInitialWindowSize, Val: transportDefaultStreamFlow}, - } - if max := t.maxHeaderListSize(); max != 0 { - initialSettings = append(initialSettings, Setting{ID: SettingMaxHeaderListSize, Val: max}) - } - - cc.bw.Write(clientPreface) - cc.fr.WriteSettings(initialSettings...) - cc.fr.WriteWindowUpdate(0, transportDefaultConnFlow) - cc.inflow.add(transportDefaultConnFlow + initialWindowSize) - cc.bw.Flush() - if cc.werr != nil { - return nil, cc.werr - } - - go cc.readLoop() - return cc, nil -} - -func (cc *ClientConn) setGoAway(f *GoAwayFrame) { - cc.mu.Lock() - defer cc.mu.Unlock() - - old := cc.goAway - cc.goAway = f - - // Merge the previous and current GoAway error frames. - if cc.goAwayDebug == "" { - cc.goAwayDebug = string(f.DebugData()) - } - if old != nil && old.ErrCode != ErrCodeNo { - cc.goAway.ErrCode = old.ErrCode - } - last := f.LastStreamID - for streamID, cs := range cc.streams { - if streamID > last { - select { - case cs.resc <- resAndError{err: errClientConnGotGoAway}: - default: - } - } - } -} - -func (cc *ClientConn) CanTakeNewRequest() bool { - cc.mu.Lock() - defer cc.mu.Unlock() - return cc.canTakeNewRequestLocked() -} - -func (cc *ClientConn) canTakeNewRequestLocked() bool { - if cc.singleUse && cc.nextStreamID > 1 { - return false - } - return cc.goAway == nil && !cc.closed && - int64(len(cc.streams)+1) < int64(cc.maxConcurrentStreams) && - cc.nextStreamID < math.MaxInt32 -} - -// onIdleTimeout is called from a time.AfterFunc goroutine. It will -// only be called when we're idle, but because we're coming from a new -// goroutine, there could be a new request coming in at the same time, -// so this simply calls the synchronized closeIfIdle to shut down this -// connection. The timer could just call closeIfIdle, but this is more -// clear. -func (cc *ClientConn) onIdleTimeout() { - cc.closeIfIdle() -} - -func (cc *ClientConn) closeIfIdle() { - cc.mu.Lock() - if len(cc.streams) > 0 { - cc.mu.Unlock() - 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() -} - -const maxAllocFrameSize = 512 << 10 - -// frameBuffer returns a scratch buffer suitable for writing DATA frames. -// They're capped at the min of the peer's max frame size or 512KB -// (kinda arbitrarily), but definitely capped so we don't allocate 4GB -// bufers. -func (cc *ClientConn) frameScratchBuffer() []byte { - cc.mu.Lock() - size := cc.maxFrameSize - if size > maxAllocFrameSize { - size = maxAllocFrameSize - } - for i, buf := range cc.freeBuf { - if len(buf) >= int(size) { - cc.freeBuf[i] = nil - cc.mu.Unlock() - return buf[:size] - } - } - cc.mu.Unlock() - return make([]byte, size) -} - -func (cc *ClientConn) putFrameScratchBuffer(buf []byte) { - cc.mu.Lock() - defer cc.mu.Unlock() - const maxBufs = 4 // arbitrary; 4 concurrent requests per conn? investigate. - if len(cc.freeBuf) < maxBufs { - cc.freeBuf = append(cc.freeBuf, buf) - return - } - for i, old := range cc.freeBuf { - if old == nil { - cc.freeBuf[i] = buf - return - } - } - // forget about it. -} - -// errRequestCanceled is a copy of net/http's errRequestCanceled because it's not -// exported. At least they'll be DeepEqual for h1-vs-h2 comparisons tests. -var errRequestCanceled = errors.New("net/http: request canceled") - -func commaSeparatedTrailers(req *http.Request) (string, error) { - keys := make([]string, 0, len(req.Trailer)) - for k := range req.Trailer { - k = http.CanonicalHeaderKey(k) - switch k { - case "Transfer-Encoding", "Trailer", "Content-Length": - return "", &badStringError{"invalid Trailer key", k} - } - keys = append(keys, k) - } - if len(keys) > 0 { - sort.Strings(keys) - return strings.Join(keys, ","), nil - } - return "", nil -} - -func (cc *ClientConn) responseHeaderTimeout() time.Duration { - if cc.t.t1 != nil { - return cc.t.t1.ResponseHeaderTimeout - } - // No way to do this (yet?) with just an http2.Transport. Probably - // no need. Request.Cancel this is the new way. We only need to support - // this for compatibility with the old http.Transport fields when - // we're doing transparent http2. - return 0 -} - -// checkConnHeaders checks whether req has any invalid connection-level headers. -// per RFC 7540 section 8.1.2.2: Connection-Specific Header Fields. -// Certain headers are special-cased as okay but not transmitted later. -func checkConnHeaders(req *http.Request) error { - if v := req.Header.Get("Upgrade"); v != "" { - return fmt.Errorf("http2: invalid Upgrade request header: %q", req.Header["Upgrade"]) - } - if vv := req.Header["Transfer-Encoding"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && vv[0] != "chunked") { - return fmt.Errorf("http2: invalid Transfer-Encoding request header: %q", vv) - } - if vv := req.Header["Connection"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && vv[0] != "close" && vv[0] != "keep-alive") { - return fmt.Errorf("http2: invalid Connection request header: %q", vv) - } - return nil -} - -// actualContentLength returns a sanitized version of -// req.ContentLength, where 0 actually means zero (not unknown) and -1 -// means unknown. -func actualContentLength(req *http.Request) int64 { - if req.Body == nil { - return 0 - } - if req.ContentLength != 0 { - return req.ContentLength - } - return -1 -} - -func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) { - if err := checkConnHeaders(req); err != nil { - return nil, err - } - if cc.idleTimer != nil { - cc.idleTimer.Stop() - } - - trailers, err := commaSeparatedTrailers(req) - if err != nil { - return nil, err - } - hasTrailers := trailers != "" - - cc.mu.Lock() - cc.lastActive = time.Now() - if cc.closed || !cc.canTakeNewRequestLocked() { - cc.mu.Unlock() - return nil, errClientConnUnusable - } - - body := req.Body - hasBody := body != nil - contentLen := actualContentLength(req) - - // TODO(bradfitz): this is a copy of the logic in net/http. Unify somewhere? - var requestedGzip bool - if !cc.t.disableCompression() && - req.Header.Get("Accept-Encoding") == "" && - req.Header.Get("Range") == "" && - req.Method != "HEAD" { - // Request gzip only, not deflate. Deflate is ambiguous and - // not as universally supported anyway. - // See: http://www.gzip.org/zlib/zlib_faq.html#faq38 - // - // Note that we don't request this for HEAD requests, - // due to a bug in nginx: - // http://trac.nginx.org/nginx/ticket/358 - // https://golang.org/issue/5522 - // - // We don't request gzip if the request is for a range, since - // auto-decoding a portion of a gzipped document will just fail - // anyway. See https://golang.org/issue/8923 - requestedGzip = true - } - - // we send: HEADERS{1}, CONTINUATION{0,} + DATA{0,} (DATA is - // sent by writeRequestBody below, along with any Trailers, - // again in form HEADERS{1}, CONTINUATION{0,}) - hdrs, err := cc.encodeHeaders(req, requestedGzip, trailers, contentLen) - if err != nil { - cc.mu.Unlock() - return nil, err - } - - cs := cc.newStream() - cs.req = req - cs.trace = requestTrace(req) - cs.requestedGzip = requestedGzip - bodyWriter := cc.t.getBodyWriterState(cs, body) - cs.on100 = bodyWriter.on100 - - cc.wmu.Lock() - endStream := !hasBody && !hasTrailers - werr := cc.writeHeaders(cs.ID, endStream, hdrs) - cc.wmu.Unlock() - traceWroteHeaders(cs.trace) - cc.mu.Unlock() - - if werr != nil { - if hasBody { - req.Body.Close() // per RoundTripper contract - bodyWriter.cancel() - } - cc.forgetStreamID(cs.ID) - // Don't bother sending a RST_STREAM (our write already failed; - // no need to keep writing) - traceWroteRequest(cs.trace, werr) - return nil, werr - } - - var respHeaderTimer <-chan time.Time - if hasBody { - bodyWriter.scheduleBodyWrite() - } else { - traceWroteRequest(cs.trace, nil) - if d := cc.responseHeaderTimeout(); d != 0 { - timer := time.NewTimer(d) - defer timer.Stop() - respHeaderTimer = timer.C - } - } - - readLoopResCh := cs.resc - bodyWritten := false - ctx := reqContext(req) - - handleReadLoopResponse := func(re resAndError) (*http.Response, error) { - res := re.res - if re.err != nil || res.StatusCode > 299 { - // On error or status code 3xx, 4xx, 5xx, etc abort any - // ongoing write, assuming that the server doesn't care - // about our request body. If the server replied with 1xx or - // 2xx, however, then assume the server DOES potentially - // want our body (e.g. full-duplex streaming: - // golang.org/issue/13444). If it turns out the server - // doesn't, they'll RST_STREAM us soon enough. This is a - // heuristic to avoid adding knobs to Transport. Hopefully - // we can keep it. - bodyWriter.cancel() - cs.abortRequestBodyWrite(errStopReqBodyWrite) - } - if re.err != nil { - if re.err == errClientConnGotGoAway { - cc.mu.Lock() - if cs.startedWrite { - re.err = errClientConnGotGoAwayAfterSomeReqBody - } - cc.mu.Unlock() - } - cc.forgetStreamID(cs.ID) - return nil, re.err - } - res.Request = req - res.TLS = cc.tlsState - return res, nil - } - - for { - select { - case re := <-readLoopResCh: - return handleReadLoopResponse(re) - case <-respHeaderTimer: - cc.forgetStreamID(cs.ID) - if !hasBody || bodyWritten { - cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) - } else { - bodyWriter.cancel() - cs.abortRequestBodyWrite(errStopReqBodyWriteAndCancel) - } - return nil, errTimeout - case <-ctx.Done(): - cc.forgetStreamID(cs.ID) - if !hasBody || bodyWritten { - cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) - } else { - bodyWriter.cancel() - cs.abortRequestBodyWrite(errStopReqBodyWriteAndCancel) - } - return nil, ctx.Err() - case <-req.Cancel: - cc.forgetStreamID(cs.ID) - if !hasBody || bodyWritten { - cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) - } else { - bodyWriter.cancel() - cs.abortRequestBodyWrite(errStopReqBodyWriteAndCancel) - } - return nil, errRequestCanceled - case <-cs.peerReset: - // processResetStream already removed the - // stream from the streams map; no need for - // forgetStreamID. - return nil, cs.resetErr - case err := <-bodyWriter.resc: - // Prefer the read loop's response, if available. Issue 16102. - select { - case re := <-readLoopResCh: - return handleReadLoopResponse(re) - default: - } - if err != nil { - return nil, err - } - bodyWritten = true - if d := cc.responseHeaderTimeout(); d != 0 { - timer := time.NewTimer(d) - defer timer.Stop() - respHeaderTimer = timer.C - } - } - } -} - -// requires cc.wmu be held -func (cc *ClientConn) writeHeaders(streamID uint32, endStream bool, hdrs []byte) error { - first := true // first frame written (HEADERS is first, then CONTINUATION) - frameSize := int(cc.maxFrameSize) - for len(hdrs) > 0 && cc.werr == nil { - chunk := hdrs - if len(chunk) > frameSize { - chunk = chunk[:frameSize] - } - hdrs = hdrs[len(chunk):] - endHeaders := len(hdrs) == 0 - if first { - cc.fr.WriteHeaders(HeadersFrameParam{ - StreamID: streamID, - BlockFragment: chunk, - EndStream: endStream, - EndHeaders: endHeaders, - }) - first = false - } else { - cc.fr.WriteContinuation(streamID, endHeaders, chunk) - } - } - // TODO(bradfitz): this Flush could potentially block (as - // could the WriteHeaders call(s) above), which means they - // wouldn't respond to Request.Cancel being readable. That's - // rare, but this should probably be in a goroutine. - cc.bw.Flush() - return cc.werr -} - -// internal error values; they don't escape to callers -var ( - // abort request body write; don't send cancel - errStopReqBodyWrite = errors.New("http2: aborting request body write") - - // abort request body write, but send stream reset of cancel. - errStopReqBodyWriteAndCancel = errors.New("http2: canceling request") -) - -func (cs *clientStream) writeRequestBody(body io.Reader, bodyCloser io.Closer) (err error) { - cc := cs.cc - sentEnd := false // whether we sent the final DATA frame w/ END_STREAM - buf := cc.frameScratchBuffer() - defer cc.putFrameScratchBuffer(buf) - - defer func() { - traceWroteRequest(cs.trace, err) - // TODO: write h12Compare test showing whether - // Request.Body is closed by the Transport, - // and in multiple cases: server replies <=299 and >299 - // while still writing request body - cerr := bodyCloser.Close() - if err == nil { - err = cerr - } - }() - - req := cs.req - hasTrailers := req.Trailer != nil - - var sawEOF bool - for !sawEOF { - n, err := body.Read(buf) - if err == io.EOF { - sawEOF = true - err = nil - } else if err != nil { - return err - } - - remain := buf[:n] - for len(remain) > 0 && err == nil { - var allowed int32 - allowed, err = cs.awaitFlowControl(len(remain)) - switch { - case err == errStopReqBodyWrite: - return err - case err == errStopReqBodyWriteAndCancel: - cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) - return err - case err != nil: - return err - } - cc.wmu.Lock() - data := remain[:allowed] - remain = remain[allowed:] - sentEnd = sawEOF && len(remain) == 0 && !hasTrailers - err = cc.fr.WriteData(cs.ID, sentEnd, data) - if err == nil { - // TODO(bradfitz): this flush is for latency, not bandwidth. - // Most requests won't need this. Make this opt-in or - // opt-out? Use some heuristic on the body type? Nagel-like - // timers? Based on 'n'? Only last chunk of this for loop, - // unless flow control tokens are low? For now, always. - // If we change this, see comment below. - err = cc.bw.Flush() - } - cc.wmu.Unlock() - } - if err != nil { - return err - } - } - - if sentEnd { - // Already sent END_STREAM (which implies we have no - // trailers) and flushed, because currently all - // WriteData frames above get a flush. So we're done. - return nil - } - - var trls []byte - if hasTrailers { - cc.mu.Lock() - defer cc.mu.Unlock() - trls = cc.encodeTrailers(req) - } - - cc.wmu.Lock() - defer cc.wmu.Unlock() - - // Two ways to send END_STREAM: either with trailers, or - // with an empty DATA frame. - 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 - } - return err -} - -// awaitFlowControl waits for [1, min(maxBytes, cc.cs.maxFrameSize)] flow -// control tokens from the server. -// It returns either the non-zero number of tokens taken or an error -// if the stream is dead. -func (cs *clientStream) awaitFlowControl(maxBytes int) (taken int32, err error) { - cc := cs.cc - cc.mu.Lock() - defer cc.mu.Unlock() - for { - if cc.closed { - return 0, errClientConnClosed - } - if cs.stopReqBody != nil { - return 0, cs.stopReqBody - } - if err := cs.checkResetOrDone(); err != nil { - return 0, err - } - if a := cs.flow.available(); a > 0 { - take := a - if int(take) > maxBytes { - - take = int32(maxBytes) // can't truncate int; take is int32 - } - if take > int32(cc.maxFrameSize) { - take = int32(cc.maxFrameSize) - } - cs.flow.take(take) - return take, nil - } - cc.cond.Wait() - } -} - -type badStringError struct { - what string - str string -} - -func (e *badStringError) Error() string { return fmt.Sprintf("%s %q", e.what, e.str) } - -// requires cc.mu be held. -func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trailers string, contentLength int64) ([]byte, error) { - cc.hbuf.Reset() - - host := req.Host - if host == "" { - host = req.URL.Host - } - host, err := httplex.PunycodeHostPort(host) - if err != nil { - return nil, err - } - - var path string - if req.Method != "CONNECT" { - path = req.URL.RequestURI() - if !validPseudoPath(path) { - orig := path - path = strings.TrimPrefix(path, req.URL.Scheme+"://"+host) - if !validPseudoPath(path) { - if req.URL.Opaque != "" { - return nil, fmt.Errorf("invalid request :path %q from URL.Opaque = %q", orig, req.URL.Opaque) - } else { - return nil, fmt.Errorf("invalid request :path %q", orig) - } - } - } - } - - // Check for any invalid headers and return an error before we - // potentially pollute our hpack state. (We want to be able to - // continue to reuse the hpack encoder for future requests) - for k, vv := range req.Header { - if !httplex.ValidHeaderFieldName(k) { - return nil, fmt.Errorf("invalid HTTP header name %q", k) - } - for _, v := range vv { - if !httplex.ValidHeaderFieldValue(v) { - return nil, fmt.Errorf("invalid HTTP header value %q for header %q", v, k) - } - } - } - - // 8.1.2.3 Request Pseudo-Header Fields - // The :path pseudo-header field includes the path and query parts of the - // target URI (the path-absolute production and optionally a '?' character - // followed by the query production (see Sections 3.3 and 3.4 of - // [RFC3986]). - cc.writeHeader(":authority", host) - cc.writeHeader(":method", req.Method) - if req.Method != "CONNECT" { - cc.writeHeader(":path", path) - cc.writeHeader(":scheme", req.URL.Scheme) - } - if trailers != "" { - cc.writeHeader("trailer", trailers) - } - - var didUA bool - for k, vv := range req.Header { - lowKey := strings.ToLower(k) - switch lowKey { - case "host", "content-length": - // Host is :authority, already sent. - // Content-Length is automatic, set below. - continue - case "connection", "proxy-connection", "transfer-encoding", "upgrade", "keep-alive": - // Per 8.1.2.2 Connection-Specific Header - // Fields, don't send connection-specific - // fields. We have already checked if any - // are error-worthy so just ignore the rest. - continue - case "user-agent": - // Match Go's http1 behavior: at most one - // User-Agent. If set to nil or empty string, - // then omit it. Otherwise if not mentioned, - // include the default (below). - didUA = true - if len(vv) < 1 { - continue - } - vv = vv[:1] - if vv[0] == "" { - continue - } - } - for _, v := range vv { - cc.writeHeader(lowKey, v) - } - } - if shouldSendReqContentLength(req.Method, contentLength) { - cc.writeHeader("content-length", strconv.FormatInt(contentLength, 10)) - } - if addGzipHeader { - cc.writeHeader("accept-encoding", "gzip") - } - if !didUA { - cc.writeHeader("user-agent", defaultUserAgent) - } - return cc.hbuf.Bytes(), nil -} - -// shouldSendReqContentLength reports whether the http2.Transport should send -// a "content-length" request header. This logic is basically a copy of the net/http -// transferWriter.shouldSendContentLength. -// The contentLength is the corrected contentLength (so 0 means actually 0, not unknown). -// -1 means unknown. -func shouldSendReqContentLength(method string, contentLength int64) bool { - if contentLength > 0 { - return true - } - if contentLength < 0 { - return false - } - // For zero bodies, whether we send a content-length depends on the method. - // It also kinda doesn't matter for http2 either way, with END_STREAM. - switch method { - case "POST", "PUT", "PATCH": - return true - default: - return false - } -} - -// requires cc.mu be held. -func (cc *ClientConn) encodeTrailers(req *http.Request) []byte { - cc.hbuf.Reset() - for k, vv := range req.Trailer { - // Transfer-Encoding, etc.. have already been filter at the - // start of RoundTrip - lowKey := strings.ToLower(k) - for _, v := range vv { - cc.writeHeader(lowKey, v) - } - } - return cc.hbuf.Bytes() -} - -func (cc *ClientConn) writeHeader(name, value string) { - if VerboseLogs { - log.Printf("http2: Transport encoding header %q = %q", name, value) - } - cc.henc.WriteField(hpack.HeaderField{Name: name, Value: value}) -} - -type resAndError struct { - res *http.Response - err error -} - -// requires cc.mu be held. -func (cc *ClientConn) newStream() *clientStream { - cs := &clientStream{ - cc: cc, - ID: cc.nextStreamID, - resc: make(chan resAndError, 1), - peerReset: make(chan struct{}), - done: make(chan struct{}), - } - cs.flow.add(int32(cc.initialWindowSize)) - cs.flow.setConnFlow(&cc.flow) - cs.inflow.add(transportDefaultStreamFlow) - cs.inflow.setConnFlow(&cc.inflow) - cc.nextStreamID += 2 - cc.streams[cs.ID] = cs - return cs -} - -func (cc *ClientConn) forgetStreamID(id uint32) { - cc.streamByID(id, true) -} - -func (cc *ClientConn) streamByID(id uint32, andRemove bool) *clientStream { - cc.mu.Lock() - defer cc.mu.Unlock() - cs := cc.streams[id] - if andRemove && cs != nil && !cc.closed { - cc.lastActive = time.Now() - delete(cc.streams, id) - if len(cc.streams) == 0 && cc.idleTimer != nil { - cc.idleTimer.Reset(cc.idleTimeout) - } - close(cs.done) - cc.cond.Broadcast() // wake up checkResetOrDone via clientStream.awaitFlowControl - } - return cs -} - -// clientConnReadLoop is the state owned by the clientConn's frame-reading readLoop. -type clientConnReadLoop struct { - cc *ClientConn - activeRes map[uint32]*clientStream // keyed by streamID - closeWhenIdle bool -} - -// readLoop runs in its own goroutine and reads and dispatches frames. -func (cc *ClientConn) readLoop() { - rl := &clientConnReadLoop{ - cc: cc, - activeRes: make(map[uint32]*clientStream), - } - - defer rl.cleanup() - cc.readerErr = rl.run() - if ce, ok := cc.readerErr.(ConnectionError); ok { - cc.wmu.Lock() - cc.fr.WriteGoAway(0, ErrCode(ce), nil) - cc.wmu.Unlock() - } -} - -// GoAwayError is returned by the Transport when the server closes the -// TCP connection after sending a GOAWAY frame. -type GoAwayError struct { - LastStreamID uint32 - ErrCode ErrCode - DebugData string -} - -func (e GoAwayError) Error() string { - return fmt.Sprintf("http2: server sent GOAWAY and closed the connection; LastStreamID=%v, ErrCode=%v, debug=%q", - 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() - defer cc.t.connPool().MarkDead(cc) - defer close(cc.readerDone) - - if cc.idleTimer != nil { - cc.idleTimer.Stop() - } - - // Close any response bodies if the server closes prematurely. - // TODO: also do this if we've written the headers but not - // gotten a response yet. - err := cc.readerErr - cc.mu.Lock() - 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) - } - for _, cs := range cc.streams { - select { - case cs.resc <- resAndError{err: err}: - default: - } - close(cs.done) - } - cc.closed = true - cc.cond.Broadcast() - cc.mu.Unlock() -} - -func (rl *clientConnReadLoop) run() error { - cc := rl.cc - rl.closeWhenIdle = cc.t.disableKeepAlives() || cc.singleUse - gotReply := false // ever saw a HEADERS reply - gotSettings := false - for { - f, err := cc.fr.ReadFrame() - if err != nil { - 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 { - 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 { - return err - } - 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) { - case *MetaHeadersFrame: - err = rl.processHeaders(f) - maybeIdle = true - gotReply = true - case *DataFrame: - err = rl.processData(f) - maybeIdle = true - case *GoAwayFrame: - err = rl.processGoAway(f) - maybeIdle = true - case *RSTStreamFrame: - err = rl.processResetStream(f) - maybeIdle = true - case *SettingsFrame: - err = rl.processSettings(f) - case *PushPromiseFrame: - err = rl.processPushPromise(f) - case *WindowUpdateFrame: - err = rl.processWindowUpdate(f) - case *PingFrame: - err = rl.processPing(f) - default: - cc.logf("Transport: unhandled response frame type %T", f) - } - if err != nil { - 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 { - cc.closeIfIdle() - } - } -} - -func (rl *clientConnReadLoop) processHeaders(f *MetaHeadersFrame) error { - cc := rl.cc - cs := cc.streamByID(f.StreamID, f.StreamEnded()) - if cs == nil { - // We'd get here if we canceled a request while the - // server had its response still in flight. So if this - // was just something we canceled, ignore it. - return nil - } - if !cs.firstByte { - if cs.trace != nil { - // TODO(bradfitz): move first response byte earlier, - // when we first read the 9 byte header, not waiting - // until all the HEADERS+CONTINUATION frames have been - // merged. This works for now. - traceFirstResponseByte(cs.trace) - } - cs.firstByte = true - } - if !cs.pastHeaders { - cs.pastHeaders = true - } else { - return rl.processTrailers(cs, f) - } - - res, err := rl.handleResponse(cs, f) - if err != nil { - if _, ok := err.(ConnectionError); ok { - return err - } - // Any other error type is a stream error. - cs.cc.writeStreamReset(f.StreamID, ErrCodeProtocol, err) - cs.resc <- resAndError{err: err} - return nil // return nil from process* funcs to keep conn alive - } - if res == nil { - // (nil, nil) special case. See handleResponse docs. - return nil - } - if res.Body != noBody { - rl.activeRes[cs.ID] = cs - } - cs.resTrailer = &res.Trailer - cs.resc <- resAndError{res: res} - return nil -} - -// may return error types nil, or ConnectionError. Any other error value -// is a StreamError of type ErrCodeProtocol. The returned error in that case -// is the detail. -// -// As a special case, handleResponse may return (nil, nil) to skip the -// frame (currently only used for 100 expect continue). This special -// case is going away after Issue 13851 is fixed. -func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFrame) (*http.Response, error) { - if f.Truncated { - return nil, errResponseHeaderListSize - } - - status := f.PseudoValue("status") - if status == "" { - return nil, errors.New("missing status pseudo header") - } - statusCode, err := strconv.Atoi(status) - if err != nil { - return nil, errors.New("malformed non-numeric status pseudo header") - } - - if statusCode == 100 { - traceGot100Continue(cs.trace) - if cs.on100 != nil { - cs.on100() // forces any write delay timer to fire - } - cs.pastHeaders = false // do it all again - return nil, nil - } - - header := make(http.Header) - res := &http.Response{ - Proto: "HTTP/2.0", - ProtoMajor: 2, - Header: header, - StatusCode: statusCode, - Status: status + " " + http.StatusText(statusCode), - } - for _, hf := range f.RegularFields() { - key := http.CanonicalHeaderKey(hf.Name) - if key == "Trailer" { - t := res.Trailer - if t == nil { - t = make(http.Header) - res.Trailer = t - } - foreachHeaderElement(hf.Value, func(v string) { - t[http.CanonicalHeaderKey(v)] = nil - }) - } else { - header[key] = append(header[key], hf.Value) - } - } - - streamEnded := f.StreamEnded() - isHead := cs.req.Method == "HEAD" - if !streamEnded || isHead { - res.ContentLength = -1 - if clens := res.Header["Content-Length"]; len(clens) == 1 { - if clen64, err := strconv.ParseInt(clens[0], 10, 64); err == nil { - res.ContentLength = clen64 - } else { - // TODO: care? unlike http/1, it won't mess up our framing, so it's - // more safe smuggling-wise to ignore. - } - } else if len(clens) > 1 { - // TODO: care? unlike http/1, it won't mess up our framing, so it's - // more safe smuggling-wise to ignore. - } - } - - if streamEnded || isHead { - res.Body = noBody - return res, nil - } - - cs.bufPipe = pipe{b: &dataBuffer{expected: res.ContentLength}} - cs.bytesRemain = res.ContentLength - res.Body = transportResponseBody{cs} - go cs.awaitRequestCancel(cs.req) - - if cs.requestedGzip && res.Header.Get("Content-Encoding") == "gzip" { - res.Header.Del("Content-Encoding") - res.Header.Del("Content-Length") - res.ContentLength = -1 - res.Body = &gzipReader{body: res.Body} - setResponseUncompressed(res) - } - return res, nil -} - -func (rl *clientConnReadLoop) processTrailers(cs *clientStream, f *MetaHeadersFrame) error { - if cs.pastTrailers { - // Too many HEADERS frames for this stream. - return ConnectionError(ErrCodeProtocol) - } - cs.pastTrailers = true - if !f.StreamEnded() { - // We expect that any headers for trailers also - // has END_STREAM. - return ConnectionError(ErrCodeProtocol) - } - if len(f.PseudoFields()) > 0 { - // No pseudo header fields are defined for trailers. - // TODO: ConnectionError might be overly harsh? Check. - return ConnectionError(ErrCodeProtocol) - } - - trailer := make(http.Header) - for _, hf := range f.RegularFields() { - key := http.CanonicalHeaderKey(hf.Name) - trailer[key] = append(trailer[key], hf.Value) - } - cs.trailer = trailer - - rl.endStream(cs) - return nil -} - -// transportResponseBody is the concrete type of Transport.RoundTrip's -// Response.Body. It is an io.ReadCloser. On Read, it reads from cs.body. -// On Close it sends RST_STREAM if EOF wasn't already seen. -type transportResponseBody struct { - cs *clientStream -} - -func (b transportResponseBody) Read(p []byte) (n int, err error) { - cs := b.cs - cc := cs.cc - - if cs.readErr != nil { - return 0, cs.readErr - } - n, err = b.cs.bufPipe.Read(p) - if cs.bytesRemain != -1 { - if int64(n) > cs.bytesRemain { - n = int(cs.bytesRemain) - if err == nil { - err = errors.New("net/http: server replied with more than declared Content-Length; truncated") - cc.writeStreamReset(cs.ID, ErrCodeProtocol, err) - } - cs.readErr = err - return int(cs.bytesRemain), err - } - cs.bytesRemain -= int64(n) - if err == io.EOF && cs.bytesRemain > 0 { - err = io.ErrUnexpectedEOF - cs.readErr = err - return n, err - } - } - if n == 0 { - // No flow control tokens to send back. - return - } - - cc.mu.Lock() - defer cc.mu.Unlock() - - var connAdd, streamAdd int32 - // Check the conn-level first, before the stream-level. - if v := cc.inflow.available(); v < transportDefaultConnFlow/2 { - connAdd = transportDefaultConnFlow - v - cc.inflow.add(connAdd) - } - if err == nil { // No need to refresh if the stream is over or failed. - // Consider any buffered body data (read from the conn but not - // consumed by the client) when computing flow control for this - // stream. - v := int(cs.inflow.available()) + cs.bufPipe.Len() - if v < transportDefaultStreamFlow-transportDefaultStreamMinRefresh { - streamAdd = int32(transportDefaultStreamFlow - v) - cs.inflow.add(streamAdd) - } - } - if connAdd != 0 || streamAdd != 0 { - cc.wmu.Lock() - defer cc.wmu.Unlock() - if connAdd != 0 { - cc.fr.WriteWindowUpdate(0, mustUint31(connAdd)) - } - if streamAdd != 0 { - cc.fr.WriteWindowUpdate(cs.ID, mustUint31(streamAdd)) - } - cc.bw.Flush() - } - return -} - -var errClosedResponseBody = errors.New("http2: response body closed") - -func (b transportResponseBody) Close() error { - cs := b.cs - 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 -} - -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 - cc.mu.Unlock() - if f.StreamID >= neverSent { - // We never asked for this. - cc.logf("http2: Transport received unsolicited DATA frame; closing connection") - return ConnectionError(ErrCodeProtocol) - } - // We probably did ask for this, but canceled. Just ignore it. - // TODO: be stricter here? only silently ignore things which - // we canceled, but not things which were closed normally - // by the peer? Tough without accumulating too much state. - - // 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 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) - } - - // Check connection-level flow control. - cc.mu.Lock() - 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() - } - didReset := cs.didReset - cc.mu.Unlock() - - if len(data) > 0 && !didReset { - if _, err := cs.bufPipe.Write(data); err != nil { - rl.endStreamError(cs, err) - return err - } - } - } - - if f.StreamEnded() { - rl.endStream(cs) - } - return nil -} - -var errInvalidTrailers = errors.New("http2: invalid trailers") - -func (rl *clientConnReadLoop) endStream(cs *clientStream) { - // TODO: check that any declared content-length matches, like - // server.go's (*stream).endStream method. - rl.endStreamError(cs, nil) -} - -func (rl *clientConnReadLoop) endStreamError(cs *clientStream, err error) { - var code func() - if err == nil { - err = io.EOF - code = cs.copyTrailers - } - cs.bufPipe.closeWithErrorAndCode(err, code) - delete(rl.activeRes, cs.ID) - if isConnectionCloseRequest(cs.req) { - rl.closeWhenIdle = true - } - - select { - case cs.resc <- resAndError{err: err}: - default: - } -} - -func (cs *clientStream) copyTrailers() { - for k, vv := range cs.trailer { - t := cs.resTrailer - if *t == nil { - *t = make(http.Header) - } - (*t)[k] = vv - } -} - -func (rl *clientConnReadLoop) processGoAway(f *GoAwayFrame) error { - cc := rl.cc - cc.t.connPool().MarkDead(cc) - if f.ErrCode != 0 { - // TODO: deal with GOAWAY more. particularly the error code - cc.vlogf("transport got GOAWAY with error code = %v", f.ErrCode) - } - cc.setGoAway(f) - return nil -} - -func (rl *clientConnReadLoop) processSettings(f *SettingsFrame) error { - cc := rl.cc - cc.mu.Lock() - defer cc.mu.Unlock() - - 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: - // 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) - } - - // 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. - cc.vlogf("Unhandled Setting: %v", s) - } - 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 { - cc := rl.cc - cs := cc.streamByID(f.StreamID, false) - if f.StreamID != 0 && cs == nil { - return nil - } - - cc.mu.Lock() - defer cc.mu.Unlock() - - fl := &cc.flow - if cs != nil { - fl = &cs.flow - } - if !fl.add(int32(f.Increment)) { - return ConnectionError(ErrCodeFlowControl) - } - cc.cond.Broadcast() - return nil -} - -func (rl *clientConnReadLoop) processResetStream(f *RSTStreamFrame) error { - cs := rl.cc.streamByID(f.StreamID, true) - if cs == nil { - // TODO: return error if server tries to RST_STEAM an idle stream - return nil - } - select { - case <-cs.peerReset: - // Already reset. - // This is the only goroutine - // which closes this, so there - // isn't a race. - default: - err := streamError(cs.ID, f.ErrCode) - cs.resetErr = err - close(cs.peerReset) - cs.bufPipe.CloseWithError(err) - cs.cc.cond.Broadcast() // wake up checkResetOrDone via clientStream.awaitFlowControl - } - delete(rl.activeRes, cs.ID) - return nil -} - -// Ping sends a PING frame to the server and waits for the ack. -// Public implementation is in go17.go and not_go17.go -func (cc *ClientConn) ping(ctx contextContext) error { - c := make(chan struct{}) - // Generate a random payload - var p [8]byte - for { - if _, err := rand.Read(p[:]); err != nil { - return err - } - cc.mu.Lock() - // check for dup before insert - if _, found := cc.pings[p]; !found { - cc.pings[p] = c - cc.mu.Unlock() - break - } - cc.mu.Unlock() - } - cc.wmu.Lock() - if err := cc.fr.WritePing(false, p); err != nil { - cc.wmu.Unlock() - return err - } - if err := cc.bw.Flush(); err != nil { - cc.wmu.Unlock() - return err - } - cc.wmu.Unlock() - select { - case <-c: - return nil - case <-ctx.Done(): - return ctx.Err() - case <-cc.readerDone: - // connection closed - return cc.readerErr - } -} - -func (rl *clientConnReadLoop) processPing(f *PingFrame) error { - if f.IsAck() { - cc := rl.cc - cc.mu.Lock() - defer cc.mu.Unlock() - // If ack, notify listener if any - if c, ok := cc.pings[f.Data]; ok { - close(c) - delete(cc.pings, f.Data) - } - return nil - } - cc := rl.cc - cc.wmu.Lock() - defer cc.wmu.Unlock() - if err := cc.fr.WritePing(true, f.Data); err != nil { - return err - } - return cc.bw.Flush() -} - -func (rl *clientConnReadLoop) processPushPromise(f *PushPromiseFrame) error { - // We told the peer we don't want them. - // Spec says: - // "PUSH_PROMISE MUST NOT be sent if the SETTINGS_ENABLE_PUSH - // setting of the peer endpoint is set to 0. An endpoint that - // has set this setting and has received acknowledgement MUST - // treat the receipt of a PUSH_PROMISE frame as a connection - // error (Section 5.4.1) of type PROTOCOL_ERROR." - return ConnectionError(ErrCodeProtocol) -} - -func (cc *ClientConn) writeStreamReset(streamID uint32, code ErrCode, err error) { - // TODO: 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() - cc.wmu.Unlock() -} - -var ( - errResponseHeaderListSize = errors.New("http2: response header list larger than advertised limit") - errPseudoTrailers = errors.New("http2: invalid pseudo header in trailers") -) - -func (cc *ClientConn) logf(format string, args ...interface{}) { - cc.t.logf(format, args...) -} - -func (cc *ClientConn) vlogf(format string, args ...interface{}) { - cc.t.vlogf(format, args...) -} - -func (t *Transport) vlogf(format string, args ...interface{}) { - if VerboseLogs { - t.logf(format, args...) - } -} - -func (t *Transport) logf(format string, args ...interface{}) { - log.Printf(format, args...) -} - -var noBody io.ReadCloser = ioutil.NopCloser(bytes.NewReader(nil)) - -func strSliceContains(ss []string, s string) bool { - for _, v := range ss { - if v == s { - return true - } - } - return false -} - -type erringRoundTripper struct{ err error } - -func (rt erringRoundTripper) RoundTrip(*http.Request) (*http.Response, error) { return nil, rt.err } - -// gzipReader wraps a response body so it can lazily -// call gzip.NewReader on the first call to Read -type gzipReader struct { - body io.ReadCloser // underlying Response.Body - zr *gzip.Reader // lazily-initialized gzip reader - zerr error // sticky error -} - -func (gz *gzipReader) Read(p []byte) (n int, err error) { - if gz.zerr != nil { - return 0, gz.zerr - } - if gz.zr == nil { - gz.zr, err = gzip.NewReader(gz.body) - if err != nil { - gz.zerr = err - return 0, err - } - } - return gz.zr.Read(p) -} - -func (gz *gzipReader) Close() error { - return gz.body.Close() -} - -type errorReader struct{ err error } - -func (r errorReader) Read(p []byte) (int, error) { return 0, r.err } - -// bodyWriterState encapsulates various state around the Transport's writing -// of the request body, particularly regarding doing delayed writes of the body -// when the request contains "Expect: 100-continue". -type bodyWriterState struct { - cs *clientStream - timer *time.Timer // if non-nil, we're doing a delayed write - fnonce *sync.Once // to call fn with - fn func() // the code to run in the goroutine, writing the body - resc chan error // result of fn's execution - delay time.Duration // how long we should delay a delayed write for -} - -func (t *Transport) getBodyWriterState(cs *clientStream, body io.Reader) (s bodyWriterState) { - s.cs = cs - if body == nil { - return - } - resc := make(chan error, 1) - s.resc = resc - s.fn = func() { - cs.cc.mu.Lock() - cs.startedWrite = true - cs.cc.mu.Unlock() - resc <- cs.writeRequestBody(body, cs.req.Body) - } - s.delay = t.expectContinueTimeout() - if s.delay == 0 || - !httplex.HeaderValuesContainsToken( - cs.req.Header["Expect"], - "100-continue") { - return - } - s.fnonce = new(sync.Once) - - // Arm the timer with a very large duration, which we'll - // intentionally lower later. It has to be large now because - // we need a handle to it before writing the headers, but the - // s.delay value is defined to not start until after the - // request headers were written. - const hugeDuration = 365 * 24 * time.Hour - s.timer = time.AfterFunc(hugeDuration, func() { - s.fnonce.Do(s.fn) - }) - return -} - -func (s bodyWriterState) cancel() { - if s.timer != nil { - s.timer.Stop() - } -} - -func (s bodyWriterState) on100() { - if s.timer == nil { - // If we didn't do a delayed write, ignore the server's - // bogus 100 continue response. - return - } - s.timer.Stop() - go func() { s.fnonce.Do(s.fn) }() -} - -// scheduleBodyWrite starts writing the body, either immediately (in -// the common case) or after the delay timeout. It should not be -// called until after the headers have been written. -func (s bodyWriterState) scheduleBodyWrite() { - if s.timer == nil { - // We're not doing a delayed write (see - // getBodyWriterState), so just start the writing - // goroutine immediately. - go s.fn() - return - } - traceWait100Continue(s.cs.trace) - if s.timer.Stop() { - s.timer.Reset(s.delay) - } -} - -// isConnectionCloseRequest reports whether req should use its own -// connection for a single request and then close the connection. -func isConnectionCloseRequest(req *http.Request) bool { - return req.Close || httplex.HeaderValuesContainsToken(req.Header["Connection"], "close") -} diff --git a/vendor/golang.org/x/net/http2/transport_test.go b/vendor/golang.org/x/net/http2/transport_test.go deleted file mode 100644 index 7ae8ff787..000000000 --- a/vendor/golang.org/x/net/http2/transport_test.go +++ /dev/null @@ -1,2916 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "bufio" - "bytes" - "crypto/tls" - "errors" - "flag" - "fmt" - "io" - "io/ioutil" - "math/rand" - "net" - "net/http" - "net/url" - "os" - "reflect" - "runtime" - "sort" - "strconv" - "strings" - "sync" - "sync/atomic" - "testing" - "time" - - "golang.org/x/net/http2/hpack" -) - -var ( - extNet = flag.Bool("extnet", false, "do external network tests") - transportHost = flag.String("transporthost", "http2.golang.org", "hostname to use for TestTransport") - insecure = flag.Bool("insecure", false, "insecure TLS dials") // TODO: dead code. remove? -) - -var tlsConfigInsecure = &tls.Config{InsecureSkipVerify: true} - -type testContext struct{} - -func (testContext) Done() <-chan struct{} { return make(chan struct{}) } -func (testContext) Err() error { panic("should not be called") } -func (testContext) Deadline() (deadline time.Time, ok bool) { return time.Time{}, false } -func (testContext) Value(key interface{}) interface{} { return nil } - -func TestTransportExternal(t *testing.T) { - if !*extNet { - t.Skip("skipping external network test") - } - req, _ := http.NewRequest("GET", "https://"+*transportHost+"/", nil) - rt := &Transport{TLSClientConfig: tlsConfigInsecure} - res, err := rt.RoundTrip(req) - if err != nil { - t.Fatalf("%v", err) - } - res.Write(os.Stdout) -} - -type fakeTLSConn struct { - net.Conn -} - -func (c *fakeTLSConn) ConnectionState() tls.ConnectionState { - return tls.ConnectionState{ - Version: tls.VersionTLS12, - } -} - -func startH2cServer(t *testing.T) net.Listener { - h2Server := &Server{} - l := newLocalListener(t) - go func() { - conn, err := l.Accept() - if err != nil { - t.Error(err) - return - } - h2Server.ServeConn(&fakeTLSConn{conn}, &ServeConnOpts{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf(w, "Hello, %v, http: %v", r.URL.Path, r.TLS == nil) - })}) - }() - return l -} - -func TestTransportH2c(t *testing.T) { - l := startH2cServer(t) - defer l.Close() - req, err := http.NewRequest("GET", "http://"+l.Addr().String()+"/foobar", nil) - if err != nil { - t.Fatal(err) - } - tr := &Transport{ - AllowHTTP: true, - DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { - return net.Dial(network, addr) - }, - } - res, err := tr.RoundTrip(req) - if err != nil { - t.Fatal(err) - } - if res.ProtoMajor != 2 { - t.Fatal("proto not h2c") - } - body, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal(err) - } - if got, want := string(body), "Hello, /foobar, http: true"; got != want { - t.Fatalf("response got %v, want %v", got, want) - } -} - -func TestTransport(t *testing.T) { - const body = "sup" - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, body) - }, optOnlyServer) - defer st.Close() - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - - req, err := http.NewRequest("GET", st.ts.URL, nil) - if err != nil { - t.Fatal(err) - } - res, err := tr.RoundTrip(req) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - - t.Logf("Got res: %+v", res) - if g, w := res.StatusCode, 200; g != w { - t.Errorf("StatusCode = %v; want %v", g, w) - } - if g, w := res.Status, "200 OK"; g != w { - t.Errorf("Status = %q; want %q", g, w) - } - wantHeader := http.Header{ - "Content-Length": []string{"3"}, - "Content-Type": []string{"text/plain; charset=utf-8"}, - "Date": []string{"XXX"}, // see cleanDate - } - cleanDate(res) - if !reflect.DeepEqual(res.Header, wantHeader) { - t.Errorf("res Header = %v; want %v", res.Header, wantHeader) - } - if res.Request != req { - t.Errorf("Response.Request = %p; want %p", res.Request, req) - } - if res.TLS == nil { - t.Error("Response.TLS = nil; want non-nil") - } - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Errorf("Body read: %v", err) - } else if string(slurp) != body { - t.Errorf("Body = %q; want %q", slurp, body) - } -} - -func onSameConn(t *testing.T, modReq func(*http.Request)) bool { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, r.RemoteAddr) - }, optOnlyServer, func(c net.Conn, st http.ConnState) { - t.Logf("conn %v is now state %v", c.RemoteAddr(), st) - }) - defer st.Close() - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - get := func() string { - req, err := http.NewRequest("GET", st.ts.URL, nil) - if err != nil { - t.Fatal(err) - } - modReq(req) - res, err := tr.RoundTrip(req) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatalf("Body read: %v", err) - } - addr := strings.TrimSpace(string(slurp)) - if addr == "" { - t.Fatalf("didn't get an addr in response") - } - return addr - } - first := get() - second := get() - return first == second -} - -func TestTransportReusesConns(t *testing.T) { - if !onSameConn(t, func(*http.Request) {}) { - t.Errorf("first and second responses were on different connections") - } -} - -func TestTransportReusesConn_RequestClose(t *testing.T) { - if onSameConn(t, func(r *http.Request) { r.Close = true }) { - t.Errorf("first and second responses were not on different connections") - } -} - -func TestTransportReusesConn_ConnClose(t *testing.T) { - if onSameConn(t, func(r *http.Request) { r.Header.Set("Connection", "close") }) { - t.Errorf("first and second responses were not on different connections") - } -} - -// Tests that the Transport only keeps one pending dial open per destination address. -// https://golang.org/issue/13397 -func TestTransportGroupsPendingDials(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, r.RemoteAddr) - }, optOnlyServer) - defer st.Close() - tr := &Transport{ - TLSClientConfig: tlsConfigInsecure, - } - defer tr.CloseIdleConnections() - var ( - mu sync.Mutex - dials = map[string]int{} - ) - var wg sync.WaitGroup - for i := 0; i < 10; i++ { - wg.Add(1) - go func() { - defer wg.Done() - req, err := http.NewRequest("GET", st.ts.URL, nil) - if err != nil { - t.Error(err) - return - } - res, err := tr.RoundTrip(req) - if err != nil { - t.Error(err) - return - } - defer res.Body.Close() - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Errorf("Body read: %v", err) - } - addr := strings.TrimSpace(string(slurp)) - if addr == "" { - t.Errorf("didn't get an addr in response") - } - mu.Lock() - dials[addr]++ - mu.Unlock() - }() - } - wg.Wait() - if len(dials) != 1 { - t.Errorf("saw %d dials; want 1: %v", len(dials), dials) - } - tr.CloseIdleConnections() - if err := retry(50, 10*time.Millisecond, func() error { - cp, ok := tr.connPool().(*clientConnPool) - if !ok { - return fmt.Errorf("Conn pool is %T; want *clientConnPool", tr.connPool()) - } - cp.mu.Lock() - defer cp.mu.Unlock() - if len(cp.dialing) != 0 { - return fmt.Errorf("dialing map = %v; want empty", cp.dialing) - } - if len(cp.conns) != 0 { - return fmt.Errorf("conns = %v; want empty", cp.conns) - } - if len(cp.keys) != 0 { - return fmt.Errorf("keys = %v; want empty", cp.keys) - } - return nil - }); err != nil { - t.Errorf("State of pool after CloseIdleConnections: %v", err) - } -} - -func retry(tries int, delay time.Duration, fn func() error) error { - var err error - for i := 0; i < tries; i++ { - err = fn() - if err == nil { - return nil - } - time.Sleep(delay) - } - return err -} - -func TestTransportAbortClosesPipes(t *testing.T) { - shutdown := make(chan struct{}) - st := newServerTester(t, - func(w http.ResponseWriter, r *http.Request) { - w.(http.Flusher).Flush() - <-shutdown - }, - optOnlyServer, - ) - defer st.Close() - defer close(shutdown) // we must shutdown before st.Close() to avoid hanging - - done := make(chan struct{}) - requestMade := make(chan struct{}) - go func() { - defer close(done) - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - req, err := http.NewRequest("GET", st.ts.URL, nil) - if err != nil { - t.Fatal(err) - } - res, err := tr.RoundTrip(req) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - close(requestMade) - _, err = ioutil.ReadAll(res.Body) - if err == nil { - t.Error("expected error from res.Body.Read") - } - }() - - <-requestMade - // Now force the serve loop to end, via closing the connection. - st.closeConn() - // deadlock? that's a bug. - select { - case <-done: - case <-time.After(3 * time.Second): - t.Fatal("timeout") - } -} - -// TODO: merge this with TestTransportBody to make TestTransportRequest? This -// could be a table-driven test with extra goodies. -func TestTransportPath(t *testing.T) { - gotc := make(chan *url.URL, 1) - st := newServerTester(t, - func(w http.ResponseWriter, r *http.Request) { - gotc <- r.URL - }, - optOnlyServer, - ) - defer st.Close() - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - const ( - path = "/testpath" - query = "q=1" - ) - surl := st.ts.URL + path + "?" + query - req, err := http.NewRequest("POST", surl, nil) - if err != nil { - t.Fatal(err) - } - c := &http.Client{Transport: tr} - res, err := c.Do(req) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - got := <-gotc - if got.Path != path { - t.Errorf("Read Path = %q; want %q", got.Path, path) - } - if got.RawQuery != query { - t.Errorf("Read RawQuery = %q; want %q", got.RawQuery, query) - } -} - -func randString(n int) string { - rnd := rand.New(rand.NewSource(int64(n))) - b := make([]byte, n) - for i := range b { - b[i] = byte(rnd.Intn(256)) - } - return string(b) -} - -type panicReader struct{} - -func (panicReader) Read([]byte) (int, error) { panic("unexpected Read") } -func (panicReader) Close() error { panic("unexpected Close") } - -func TestActualContentLength(t *testing.T) { - tests := []struct { - req *http.Request - want int64 - }{ - // Verify we don't read from Body: - 0: { - req: &http.Request{Body: panicReader{}}, - want: -1, - }, - // nil Body means 0, regardless of ContentLength: - 1: { - req: &http.Request{Body: nil, ContentLength: 5}, - want: 0, - }, - // ContentLength is used if set. - 2: { - req: &http.Request{Body: panicReader{}, ContentLength: 5}, - want: 5, - }, - } - for i, tt := range tests { - got := actualContentLength(tt.req) - if got != tt.want { - t.Errorf("test[%d]: got %d; want %d", i, got, tt.want) - } - } -} - -func TestTransportBody(t *testing.T) { - bodyTests := []struct { - body string - noContentLen bool - }{ - {body: "some message"}, - {body: "some message", noContentLen: true}, - {body: strings.Repeat("a", 1<<20), noContentLen: true}, - {body: strings.Repeat("a", 1<<20)}, - {body: randString(16<<10 - 1)}, - {body: randString(16 << 10)}, - {body: randString(16<<10 + 1)}, - {body: randString(512<<10 - 1)}, - {body: randString(512 << 10)}, - {body: randString(512<<10 + 1)}, - {body: randString(1<<20 - 1)}, - {body: randString(1 << 20)}, - {body: randString(1<<20 + 2)}, - } - - type reqInfo struct { - req *http.Request - slurp []byte - err error - } - gotc := make(chan reqInfo, 1) - st := newServerTester(t, - func(w http.ResponseWriter, r *http.Request) { - slurp, err := ioutil.ReadAll(r.Body) - if err != nil { - gotc <- reqInfo{err: err} - } else { - gotc <- reqInfo{req: r, slurp: slurp} - } - }, - optOnlyServer, - ) - defer st.Close() - - for i, tt := range bodyTests { - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - - var body io.Reader = strings.NewReader(tt.body) - if tt.noContentLen { - body = struct{ io.Reader }{body} // just a Reader, hiding concrete type and other methods - } - req, err := http.NewRequest("POST", st.ts.URL, body) - if err != nil { - t.Fatalf("#%d: %v", i, err) - } - c := &http.Client{Transport: tr} - res, err := c.Do(req) - if err != nil { - t.Fatalf("#%d: %v", i, err) - } - defer res.Body.Close() - ri := <-gotc - if ri.err != nil { - t.Errorf("#%d: read error: %v", i, ri.err) - continue - } - if got := string(ri.slurp); got != tt.body { - t.Errorf("#%d: Read body mismatch.\n got: %q (len %d)\nwant: %q (len %d)", i, shortString(got), len(got), shortString(tt.body), len(tt.body)) - } - wantLen := int64(len(tt.body)) - if tt.noContentLen && tt.body != "" { - wantLen = -1 - } - if ri.req.ContentLength != wantLen { - t.Errorf("#%d. handler got ContentLength = %v; want %v", i, ri.req.ContentLength, wantLen) - } - } -} - -func shortString(v string) string { - const maxLen = 100 - if len(v) <= maxLen { - return v - } - return fmt.Sprintf("%v[...%d bytes omitted...]%v", v[:maxLen/2], len(v)-maxLen, v[len(v)-maxLen/2:]) -} - -func TestTransportDialTLS(t *testing.T) { - var mu sync.Mutex // guards following - var gotReq, didDial bool - - ts := newServerTester(t, - func(w http.ResponseWriter, r *http.Request) { - mu.Lock() - gotReq = true - mu.Unlock() - }, - optOnlyServer, - ) - defer ts.Close() - tr := &Transport{ - DialTLS: func(netw, addr string, cfg *tls.Config) (net.Conn, error) { - mu.Lock() - didDial = true - mu.Unlock() - cfg.InsecureSkipVerify = true - c, err := tls.Dial(netw, addr, cfg) - if err != nil { - return nil, err - } - return c, c.Handshake() - }, - } - defer tr.CloseIdleConnections() - client := &http.Client{Transport: tr} - res, err := client.Get(ts.ts.URL) - if err != nil { - t.Fatal(err) - } - res.Body.Close() - mu.Lock() - if !gotReq { - t.Error("didn't get request") - } - if !didDial { - t.Error("didn't use dial hook") - } -} - -func TestConfigureTransport(t *testing.T) { - t1 := &http.Transport{} - err := ConfigureTransport(t1) - if err == errTransportVersion { - t.Skip(err) - } - if err != nil { - t.Fatal(err) - } - if got := fmt.Sprintf("%#v", t1); !strings.Contains(got, `"h2"`) { - // Laziness, to avoid buildtags. - t.Errorf("stringification of HTTP/1 transport didn't contain \"h2\": %v", got) - } - wantNextProtos := []string{"h2", "http/1.1"} - if t1.TLSClientConfig == nil { - t.Errorf("nil t1.TLSClientConfig") - } else if !reflect.DeepEqual(t1.TLSClientConfig.NextProtos, wantNextProtos) { - t.Errorf("TLSClientConfig.NextProtos = %q; want %q", t1.TLSClientConfig.NextProtos, wantNextProtos) - } - if err := ConfigureTransport(t1); err == nil { - t.Error("unexpected success on second call to ConfigureTransport") - } - - // And does it work? - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, r.Proto) - }, optOnlyServer) - defer st.Close() - - t1.TLSClientConfig.InsecureSkipVerify = true - c := &http.Client{Transport: t1} - res, err := c.Get(st.ts.URL) - if err != nil { - t.Fatal(err) - } - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal(err) - } - if got, want := string(slurp), "HTTP/2.0"; got != want { - t.Errorf("body = %q; want %q", got, want) - } -} - -type capitalizeReader struct { - r io.Reader -} - -func (cr capitalizeReader) Read(p []byte) (n int, err error) { - n, err = cr.r.Read(p) - for i, b := range p[:n] { - if b >= 'a' && b <= 'z' { - p[i] = b - ('a' - 'A') - } - } - return -} - -type flushWriter struct { - w io.Writer -} - -func (fw flushWriter) Write(p []byte) (n int, err error) { - n, err = fw.w.Write(p) - if f, ok := fw.w.(http.Flusher); ok { - f.Flush() - } - return -} - -type clientTester struct { - t *testing.T - tr *Transport - sc, cc net.Conn // server and client conn - fr *Framer // server's framer - client func() error - server func() error -} - -func newClientTester(t *testing.T) *clientTester { - var dialOnce struct { - sync.Mutex - dialed bool - } - ct := &clientTester{ - t: t, - } - ct.tr = &Transport{ - TLSClientConfig: tlsConfigInsecure, - DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { - dialOnce.Lock() - defer dialOnce.Unlock() - if dialOnce.dialed { - return nil, errors.New("only one dial allowed in test mode") - } - dialOnce.dialed = true - return ct.cc, nil - }, - } - - ln := newLocalListener(t) - cc, err := net.Dial("tcp", ln.Addr().String()) - if err != nil { - t.Fatal(err) - - } - sc, err := ln.Accept() - if err != nil { - t.Fatal(err) - } - ln.Close() - ct.cc = cc - ct.sc = sc - ct.fr = NewFramer(sc, sc) - return ct -} - -func newLocalListener(t *testing.T) net.Listener { - ln, err := net.Listen("tcp4", "127.0.0.1:0") - if err == nil { - return ln - } - ln, err = net.Listen("tcp6", "[::1]:0") - if err != nil { - t.Fatal(err) - } - return ln -} - -func (ct *clientTester) greet() { - buf := make([]byte, len(ClientPreface)) - _, err := io.ReadFull(ct.sc, buf) - if err != nil { - ct.t.Fatalf("reading client preface: %v", err) - } - f, err := ct.fr.ReadFrame() - if err != nil { - ct.t.Fatalf("Reading client settings frame: %v", err) - } - if sf, ok := f.(*SettingsFrame); !ok { - ct.t.Fatalf("Wanted client settings frame; got %v", f) - _ = sf // stash it away? - } - if err := ct.fr.WriteSettings(); err != nil { - ct.t.Fatal(err) - } - if err := ct.fr.WriteSettingsAck(); err != nil { - ct.t.Fatal(err) - } -} - -func (ct *clientTester) 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() -} - -func (ct *clientTester) run() { - errc := make(chan error, 2) - ct.start("client", errc, ct.client) - ct.start("server", errc, ct.server) - defer ct.cleanup() - for i := 0; i < 2; i++ { - if err := <-errc; err != nil { - ct.t.Error(err) - return - } - } -} - -func (ct *clientTester) start(which string, errc chan<- error, fn func() error) { - go func() { - finished := false - var err error - defer func() { - if !finished { - err = fmt.Errorf("%s goroutine didn't finish.", which) - } else if err != nil { - err = fmt.Errorf("%s: %v", which, err) - } - errc <- err - }() - err = fn() - finished = true - }() -} - -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 -} - -func (r countingReader) Read(p []byte) (n int, err error) { - for i := range p { - p[i] = byte(i) - } - atomic.AddInt64(r.n, int64(len(p))) - return len(p), err -} - -func TestTransportReqBodyAfterResponse_200(t *testing.T) { testTransportReqBodyAfterResponse(t, 200) } -func TestTransportReqBodyAfterResponse_403(t *testing.T) { testTransportReqBodyAfterResponse(t, 403) } - -func testTransportReqBodyAfterResponse(t *testing.T, status int) { - const bodySize = 10 << 20 - 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 { - return err - } - res, err := ct.tr.RoundTrip(req) - if err != nil { - return fmt.Errorf("RoundTrip: %v", err) - } - defer res.Body.Close() - if res.StatusCode != status { - return fmt.Errorf("status code = %v; want %v", res.StatusCode, status) - } - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - return fmt.Errorf("Slurp: %v", err) - } - if len(slurp) > 0 { - return fmt.Errorf("unexpected body: %q", slurp) - } - if status == 200 { - if got := atomic.LoadInt64(&n); got != bodySize { - return fmt.Errorf("For 200 response, Transport wrote %d bytes; want %d", got, bodySize) - } - } else { - if got := atomic.LoadInt64(&n); got == 0 || got >= bodySize { - return fmt.Errorf("For %d response, Transport wrote %d bytes; want (0,%d) exclusive", status, got, bodySize) - } - } - return nil - } - ct.server = func() error { - ct.greet() - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - var dataRecv int64 - var closed bool - for { - f, err := ct.fr.ReadFrame() - if err != nil { - 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) { - case *WindowUpdateFrame, *SettingsFrame: - case *HeadersFrame: - if !f.HeadersEnded() { - return fmt.Errorf("headers should have END_HEADERS be ended: %v", f) - } - if f.StreamEnded() { - return fmt.Errorf("headers contains END_STREAM unexpectedly: %v", f) - } - case *DataFrame: - dataLen := len(f.Data()) - if dataLen > 0 { - if dataRecv == 0 { - enc.WriteField(hpack.HeaderField{Name: ":status", Value: strconv.Itoa(status)}) - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: f.StreamID, - EndHeaders: true, - EndStream: false, - BlockFragment: buf.Bytes(), - }) - } - if err := ct.fr.WriteWindowUpdate(0, uint32(dataLen)); err != nil { - return err - } - if err := ct.fr.WriteWindowUpdate(f.StreamID, uint32(dataLen)); err != nil { - return err - } - } - dataRecv += int64(dataLen) - - if !closed && ((status != 200 && dataRecv > 0) || - (status == 200 && dataRecv == bodySize)) { - closed = true - if err := ct.fr.WriteData(f.StreamID, true, nil); err != nil { - return err - } - } - default: - return fmt.Errorf("Unexpected client frame %v", f) - } - } - } - ct.run() -} - -// See golang.org/issue/13444 -func TestTransportFullDuplex(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) // redundant but for clarity - w.(http.Flusher).Flush() - io.Copy(flushWriter{w}, capitalizeReader{r.Body}) - fmt.Fprintf(w, "bye.\n") - }, optOnlyServer) - defer st.Close() - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - c := &http.Client{Transport: tr} - - pr, pw := io.Pipe() - req, err := http.NewRequest("PUT", st.ts.URL, ioutil.NopCloser(pr)) - if err != nil { - t.Fatal(err) - } - req.ContentLength = -1 - res, err := c.Do(req) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - if res.StatusCode != 200 { - t.Fatalf("StatusCode = %v; want %v", res.StatusCode, 200) - } - bs := bufio.NewScanner(res.Body) - want := func(v string) { - if !bs.Scan() { - t.Fatalf("wanted to read %q but Scan() = false, err = %v", v, bs.Err()) - } - } - write := func(v string) { - _, err := io.WriteString(pw, v) - if err != nil { - t.Fatalf("pipe write: %v", err) - } - } - write("foo\n") - want("FOO") - write("bar\n") - want("BAR") - pw.Close() - want("bye.") - if err := bs.Err(); err != nil { - t.Fatal(err) - } -} - -func TestTransportConnectRequest(t *testing.T) { - gotc := make(chan *http.Request, 1) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - gotc <- r - }, optOnlyServer) - defer st.Close() - - u, err := url.Parse(st.ts.URL) - if err != nil { - t.Fatal(err) - } - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - c := &http.Client{Transport: tr} - - tests := []struct { - req *http.Request - want string - }{ - { - req: &http.Request{ - Method: "CONNECT", - Header: http.Header{}, - URL: u, - }, - want: u.Host, - }, - { - req: &http.Request{ - Method: "CONNECT", - Header: http.Header{}, - URL: u, - Host: "example.com:123", - }, - want: "example.com:123", - }, - } - - for i, tt := range tests { - res, err := c.Do(tt.req) - if err != nil { - t.Errorf("%d. RoundTrip = %v", i, err) - continue - } - res.Body.Close() - req := <-gotc - if req.Method != "CONNECT" { - t.Errorf("method = %q; want CONNECT", req.Method) - } - if req.Host != tt.want { - t.Errorf("Host = %q; want %q", req.Host, tt.want) - } - if req.URL.Host != tt.want { - t.Errorf("URL.Host = %q; want %q", req.URL.Host, tt.want) - } - } -} - -type headerType int - -const ( - noHeader headerType = iota // omitted - oneHeader - splitHeader // broken into continuation on purpose -) - -const ( - f0 = noHeader - f1 = oneHeader - f2 = splitHeader - d0 = false - d1 = true -) - -// Test all 36 combinations of response frame orders: -// (3 ways of 100-continue) * (2 ways of headers) * (2 ways of data) * (3 ways of trailers):func TestTransportResponsePattern_00f0(t *testing.T) { testTransportResponsePattern(h0, h1, false, h0) } -// Generated by http://play.golang.org/p/SScqYKJYXd -func TestTransportResPattern_c0h1d0t0(t *testing.T) { testTransportResPattern(t, f0, f1, d0, f0) } -func TestTransportResPattern_c0h1d0t1(t *testing.T) { testTransportResPattern(t, f0, f1, d0, f1) } -func TestTransportResPattern_c0h1d0t2(t *testing.T) { testTransportResPattern(t, f0, f1, d0, f2) } -func TestTransportResPattern_c0h1d1t0(t *testing.T) { testTransportResPattern(t, f0, f1, d1, f0) } -func TestTransportResPattern_c0h1d1t1(t *testing.T) { testTransportResPattern(t, f0, f1, d1, f1) } -func TestTransportResPattern_c0h1d1t2(t *testing.T) { testTransportResPattern(t, f0, f1, d1, f2) } -func TestTransportResPattern_c0h2d0t0(t *testing.T) { testTransportResPattern(t, f0, f2, d0, f0) } -func TestTransportResPattern_c0h2d0t1(t *testing.T) { testTransportResPattern(t, f0, f2, d0, f1) } -func TestTransportResPattern_c0h2d0t2(t *testing.T) { testTransportResPattern(t, f0, f2, d0, f2) } -func TestTransportResPattern_c0h2d1t0(t *testing.T) { testTransportResPattern(t, f0, f2, d1, f0) } -func TestTransportResPattern_c0h2d1t1(t *testing.T) { testTransportResPattern(t, f0, f2, d1, f1) } -func TestTransportResPattern_c0h2d1t2(t *testing.T) { testTransportResPattern(t, f0, f2, d1, f2) } -func TestTransportResPattern_c1h1d0t0(t *testing.T) { testTransportResPattern(t, f1, f1, d0, f0) } -func TestTransportResPattern_c1h1d0t1(t *testing.T) { testTransportResPattern(t, f1, f1, d0, f1) } -func TestTransportResPattern_c1h1d0t2(t *testing.T) { testTransportResPattern(t, f1, f1, d0, f2) } -func TestTransportResPattern_c1h1d1t0(t *testing.T) { testTransportResPattern(t, f1, f1, d1, f0) } -func TestTransportResPattern_c1h1d1t1(t *testing.T) { testTransportResPattern(t, f1, f1, d1, f1) } -func TestTransportResPattern_c1h1d1t2(t *testing.T) { testTransportResPattern(t, f1, f1, d1, f2) } -func TestTransportResPattern_c1h2d0t0(t *testing.T) { testTransportResPattern(t, f1, f2, d0, f0) } -func TestTransportResPattern_c1h2d0t1(t *testing.T) { testTransportResPattern(t, f1, f2, d0, f1) } -func TestTransportResPattern_c1h2d0t2(t *testing.T) { testTransportResPattern(t, f1, f2, d0, f2) } -func TestTransportResPattern_c1h2d1t0(t *testing.T) { testTransportResPattern(t, f1, f2, d1, f0) } -func TestTransportResPattern_c1h2d1t1(t *testing.T) { testTransportResPattern(t, f1, f2, d1, f1) } -func TestTransportResPattern_c1h2d1t2(t *testing.T) { testTransportResPattern(t, f1, f2, d1, f2) } -func TestTransportResPattern_c2h1d0t0(t *testing.T) { testTransportResPattern(t, f2, f1, d0, f0) } -func TestTransportResPattern_c2h1d0t1(t *testing.T) { testTransportResPattern(t, f2, f1, d0, f1) } -func TestTransportResPattern_c2h1d0t2(t *testing.T) { testTransportResPattern(t, f2, f1, d0, f2) } -func TestTransportResPattern_c2h1d1t0(t *testing.T) { testTransportResPattern(t, f2, f1, d1, f0) } -func TestTransportResPattern_c2h1d1t1(t *testing.T) { testTransportResPattern(t, f2, f1, d1, f1) } -func TestTransportResPattern_c2h1d1t2(t *testing.T) { testTransportResPattern(t, f2, f1, d1, f2) } -func TestTransportResPattern_c2h2d0t0(t *testing.T) { testTransportResPattern(t, f2, f2, d0, f0) } -func TestTransportResPattern_c2h2d0t1(t *testing.T) { testTransportResPattern(t, f2, f2, d0, f1) } -func TestTransportResPattern_c2h2d0t2(t *testing.T) { testTransportResPattern(t, f2, f2, d0, f2) } -func TestTransportResPattern_c2h2d1t0(t *testing.T) { testTransportResPattern(t, f2, f2, d1, f0) } -func TestTransportResPattern_c2h2d1t1(t *testing.T) { testTransportResPattern(t, f2, f2, d1, f1) } -func TestTransportResPattern_c2h2d1t2(t *testing.T) { testTransportResPattern(t, f2, f2, d1, f2) } - -func testTransportResPattern(t *testing.T, expect100Continue, resHeader headerType, withData bool, trailers headerType) { - const reqBody = "some request body" - const resBody = "some response body" - - if resHeader == noHeader { - // TODO: test 100-continue followed by immediate - // server stream reset, without headers in the middle? - panic("invalid combination") - } - - ct := newClientTester(t) - ct.client = func() error { - req, _ := http.NewRequest("POST", "https://dummy.tld/", strings.NewReader(reqBody)) - if expect100Continue != noHeader { - req.Header.Set("Expect", "100-continue") - } - res, err := ct.tr.RoundTrip(req) - if err != nil { - return fmt.Errorf("RoundTrip: %v", err) - } - defer res.Body.Close() - if res.StatusCode != 200 { - return fmt.Errorf("status code = %v; want 200", res.StatusCode) - } - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - return fmt.Errorf("Slurp: %v", err) - } - wantBody := resBody - if !withData { - wantBody = "" - } - if string(slurp) != wantBody { - return fmt.Errorf("body = %q; want %q", slurp, wantBody) - } - if trailers == noHeader { - if len(res.Trailer) > 0 { - t.Errorf("Trailer = %v; want none", res.Trailer) - } - } else { - want := http.Header{"Some-Trailer": {"some-value"}} - if !reflect.DeepEqual(res.Trailer, want) { - t.Errorf("Trailer = %v; want %v", res.Trailer, want) - } - } - return nil - } - ct.server = func() error { - ct.greet() - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - - for { - f, err := ct.fr.ReadFrame() - if err != nil { - return err - } - endStream := false - send := func(mode headerType) { - hbf := buf.Bytes() - switch mode { - case oneHeader: - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: f.Header().StreamID, - EndHeaders: true, - EndStream: endStream, - BlockFragment: hbf, - }) - case splitHeader: - if len(hbf) < 2 { - panic("too small") - } - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: f.Header().StreamID, - EndHeaders: false, - EndStream: endStream, - BlockFragment: hbf[:1], - }) - ct.fr.WriteContinuation(f.Header().StreamID, true, hbf[1:]) - default: - panic("bogus mode") - } - } - switch f := f.(type) { - case *WindowUpdateFrame, *SettingsFrame: - case *DataFrame: - if !f.StreamEnded() { - // No need to send flow control tokens. The test request body is tiny. - continue - } - // Response headers (1+ frames; 1 or 2 in this test, but never 0) - { - buf.Reset() - enc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) - enc.WriteField(hpack.HeaderField{Name: "x-foo", Value: "blah"}) - enc.WriteField(hpack.HeaderField{Name: "x-bar", Value: "more"}) - if trailers != noHeader { - enc.WriteField(hpack.HeaderField{Name: "trailer", Value: "some-trailer"}) - } - endStream = withData == false && trailers == noHeader - send(resHeader) - } - if withData { - endStream = trailers == noHeader - ct.fr.WriteData(f.StreamID, endStream, []byte(resBody)) - } - if trailers != noHeader { - endStream = true - buf.Reset() - enc.WriteField(hpack.HeaderField{Name: "some-trailer", Value: "some-value"}) - send(trailers) - } - if endStream { - return nil - } - case *HeadersFrame: - if expect100Continue != noHeader { - buf.Reset() - enc.WriteField(hpack.HeaderField{Name: ":status", Value: "100"}) - send(expect100Continue) - } - } - } - } - ct.run() -} - -func TestTransportReceiveUndeclaredTrailer(t *testing.T) { - ct := newClientTester(t) - ct.client = func() error { - req, _ := http.NewRequest("GET", "https://dummy.tld/", nil) - res, err := ct.tr.RoundTrip(req) - if err != nil { - return fmt.Errorf("RoundTrip: %v", err) - } - defer res.Body.Close() - if res.StatusCode != 200 { - return fmt.Errorf("status code = %v; want 200", res.StatusCode) - } - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - return fmt.Errorf("res.Body ReadAll error = %q, %v; want %v", slurp, err, nil) - } - if len(slurp) > 0 { - return fmt.Errorf("body = %q; want nothing", slurp) - } - if _, ok := res.Trailer["Some-Trailer"]; !ok { - return fmt.Errorf("expected Some-Trailer") - } - return nil - } - ct.server = func() error { - ct.greet() - - var n int - var hf *HeadersFrame - for hf == nil && n < 10 { - f, err := ct.fr.ReadFrame() - if err != nil { - return err - } - hf, _ = f.(*HeadersFrame) - n++ - } - - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - - // send headers without Trailer header - enc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: hf.StreamID, - EndHeaders: true, - EndStream: false, - BlockFragment: buf.Bytes(), - }) - - // send trailers - buf.Reset() - enc.WriteField(hpack.HeaderField{Name: "some-trailer", Value: "I'm an undeclared Trailer!"}) - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: hf.StreamID, - EndHeaders: true, - EndStream: true, - BlockFragment: buf.Bytes(), - }) - return nil - } - ct.run() -} - -func TestTransportInvalidTrailer_Pseudo1(t *testing.T) { - testTransportInvalidTrailer_Pseudo(t, oneHeader) -} -func TestTransportInvalidTrailer_Pseudo2(t *testing.T) { - testTransportInvalidTrailer_Pseudo(t, splitHeader) -} -func testTransportInvalidTrailer_Pseudo(t *testing.T, trailers headerType) { - testInvalidTrailer(t, trailers, pseudoHeaderError(":colon"), func(enc *hpack.Encoder) { - enc.WriteField(hpack.HeaderField{Name: ":colon", Value: "foo"}) - enc.WriteField(hpack.HeaderField{Name: "foo", Value: "bar"}) - }) -} - -func TestTransportInvalidTrailer_Capital1(t *testing.T) { - testTransportInvalidTrailer_Capital(t, oneHeader) -} -func TestTransportInvalidTrailer_Capital2(t *testing.T) { - testTransportInvalidTrailer_Capital(t, splitHeader) -} -func testTransportInvalidTrailer_Capital(t *testing.T, trailers headerType) { - testInvalidTrailer(t, trailers, headerFieldNameError("Capital"), func(enc *hpack.Encoder) { - enc.WriteField(hpack.HeaderField{Name: "foo", Value: "bar"}) - enc.WriteField(hpack.HeaderField{Name: "Capital", Value: "bad"}) - }) -} -func TestTransportInvalidTrailer_EmptyFieldName(t *testing.T) { - testInvalidTrailer(t, oneHeader, headerFieldNameError(""), func(enc *hpack.Encoder) { - enc.WriteField(hpack.HeaderField{Name: "", Value: "bad"}) - }) -} -func TestTransportInvalidTrailer_BinaryFieldValue(t *testing.T) { - testInvalidTrailer(t, oneHeader, headerFieldValueError("has\nnewline"), func(enc *hpack.Encoder) { - enc.WriteField(hpack.HeaderField{Name: "x", Value: "has\nnewline"}) - }) -} - -func testInvalidTrailer(t *testing.T, trailers headerType, wantErr error, writeTrailer func(*hpack.Encoder)) { - ct := newClientTester(t) - ct.client = func() error { - req, _ := http.NewRequest("GET", "https://dummy.tld/", nil) - res, err := ct.tr.RoundTrip(req) - if err != nil { - return fmt.Errorf("RoundTrip: %v", err) - } - defer res.Body.Close() - if res.StatusCode != 200 { - return fmt.Errorf("status code = %v; want 200", res.StatusCode) - } - slurp, err := ioutil.ReadAll(res.Body) - 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) - } - return nil - } - ct.server = func() error { - ct.greet() - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - - for { - f, err := ct.fr.ReadFrame() - if err != nil { - return err - } - switch f := f.(type) { - case *HeadersFrame: - var endStream bool - send := func(mode headerType) { - hbf := buf.Bytes() - switch mode { - case oneHeader: - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: f.StreamID, - EndHeaders: true, - EndStream: endStream, - BlockFragment: hbf, - }) - case splitHeader: - if len(hbf) < 2 { - panic("too small") - } - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: f.StreamID, - EndHeaders: false, - EndStream: endStream, - BlockFragment: hbf[:1], - }) - ct.fr.WriteContinuation(f.StreamID, true, hbf[1:]) - default: - panic("bogus mode") - } - } - // Response headers (1+ frames; 1 or 2 in this test, but never 0) - { - buf.Reset() - enc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) - enc.WriteField(hpack.HeaderField{Name: "trailer", Value: "declared"}) - endStream = false - send(oneHeader) - } - // Trailers: - { - endStream = true - buf.Reset() - writeTrailer(enc) - send(trailers) - } - return nil - } - } - } - ct.run() -} - -func TestTransportChecksResponseHeaderListSize(t *testing.T) { - ct := newClientTester(t) - ct.client = func() error { - req, _ := http.NewRequest("GET", "https://dummy.tld/", nil) - res, err := ct.tr.RoundTrip(req) - if err != errResponseHeaderListSize { - if res != nil { - res.Body.Close() - } - size := int64(0) - for k, vv := range res.Header { - for _, v := range vv { - size += int64(len(k)) + int64(len(v)) + 32 - } - } - return fmt.Errorf("RoundTrip Error = %v (and %d bytes of response headers); want errResponseHeaderListSize", err, size) - } - return nil - } - ct.server = func() error { - ct.greet() - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - - for { - f, err := ct.fr.ReadFrame() - if err != nil { - return err - } - switch f := f.(type) { - case *HeadersFrame: - enc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) - large := strings.Repeat("a", 1<<10) - for i := 0; i < 5042; i++ { - enc.WriteField(hpack.HeaderField{Name: large, Value: large}) - } - if size, want := buf.Len(), 6329; size != want { - // Note: this number might change if - // our hpack implementation - // changes. That's fine. This is - // just a sanity check that our - // response can fit in a single - // header block fragment frame. - return fmt.Errorf("encoding over 10MB of duplicate keypairs took %d bytes; expected %d", size, want) - } - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: f.StreamID, - EndHeaders: true, - EndStream: true, - BlockFragment: buf.Bytes(), - }) - return nil - } - } - } - ct.run() -} - -// Test that the the Transport returns a typed error from Response.Body.Read calls -// when the server sends an error. (here we use a panic, since that should generate -// a stream error, but others like cancel should be similar) -func TestTransportBodyReadErrorType(t *testing.T) { - doPanic := make(chan bool, 1) - st := newServerTester(t, - func(w http.ResponseWriter, r *http.Request) { - w.(http.Flusher).Flush() // force headers out - <-doPanic - panic("boom") - }, - optOnlyServer, - optQuiet, - ) - defer st.Close() - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - c := &http.Client{Transport: tr} - - res, err := c.Get(st.ts.URL) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - doPanic <- true - buf := make([]byte, 100) - n, err := res.Body.Read(buf) - want := StreamError{StreamID: 0x1, Code: 0x2} - if !reflect.DeepEqual(want, err) { - t.Errorf("Read = %v, %#v; want error %#v", n, err, want) - } -} - -// golang.org/issue/13924 -// This used to fail after many iterations, especially with -race: -// go test -v -run=TestTransportDoubleCloseOnWriteError -count=500 -race -func TestTransportDoubleCloseOnWriteError(t *testing.T) { - var ( - mu sync.Mutex - conn net.Conn // to close if set - ) - - st := newServerTester(t, - func(w http.ResponseWriter, r *http.Request) { - mu.Lock() - defer mu.Unlock() - if conn != nil { - conn.Close() - } - }, - optOnlyServer, - ) - defer st.Close() - - tr := &Transport{ - TLSClientConfig: tlsConfigInsecure, - DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { - tc, err := tls.Dial(network, addr, cfg) - if err != nil { - return nil, err - } - mu.Lock() - defer mu.Unlock() - conn = tc - return tc, nil - }, - } - defer tr.CloseIdleConnections() - c := &http.Client{Transport: tr} - c.Get(st.ts.URL) -} - -// Test that the http1 Transport.DisableKeepAlives option is respected -// and connections are closed as soon as idle. -// See golang.org/issue/14008 -func TestTransportDisableKeepAlives(t *testing.T) { - st := newServerTester(t, - func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, "hi") - }, - optOnlyServer, - ) - defer st.Close() - - connClosed := make(chan struct{}) // closed on tls.Conn.Close - tr := &Transport{ - t1: &http.Transport{ - DisableKeepAlives: true, - }, - TLSClientConfig: tlsConfigInsecure, - DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { - tc, err := tls.Dial(network, addr, cfg) - if err != nil { - return nil, err - } - return ¬eCloseConn{Conn: tc, closefn: func() { close(connClosed) }}, nil - }, - } - c := &http.Client{Transport: tr} - res, err := c.Get(st.ts.URL) - if err != nil { - t.Fatal(err) - } - if _, err := ioutil.ReadAll(res.Body); err != nil { - t.Fatal(err) - } - defer res.Body.Close() - - select { - case <-connClosed: - case <-time.After(1 * time.Second): - t.Errorf("timeout") - } - -} - -// Test concurrent requests with Transport.DisableKeepAlives. We can share connections, -// but when things are totally idle, it still needs to close. -func TestTransportDisableKeepAlives_Concurrency(t *testing.T) { - const D = 25 * time.Millisecond - st := newServerTester(t, - func(w http.ResponseWriter, r *http.Request) { - time.Sleep(D) - io.WriteString(w, "hi") - }, - optOnlyServer, - ) - defer st.Close() - - var dials int32 - var conns sync.WaitGroup - tr := &Transport{ - t1: &http.Transport{ - DisableKeepAlives: true, - }, - TLSClientConfig: tlsConfigInsecure, - DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { - tc, err := tls.Dial(network, addr, cfg) - if err != nil { - return nil, err - } - atomic.AddInt32(&dials, 1) - conns.Add(1) - return ¬eCloseConn{Conn: tc, closefn: func() { conns.Done() }}, nil - }, - } - c := &http.Client{Transport: tr} - var reqs sync.WaitGroup - const N = 20 - for i := 0; i < N; i++ { - reqs.Add(1) - if i == N-1 { - // For the final request, try to make all the - // others close. This isn't verified in the - // count, other than the Log statement, since - // it's so timing dependent. This test is - // really to make sure we don't interrupt a - // valid request. - time.Sleep(D * 2) - } - go func() { - defer reqs.Done() - res, err := c.Get(st.ts.URL) - if err != nil { - t.Error(err) - return - } - if _, err := ioutil.ReadAll(res.Body); err != nil { - t.Error(err) - return - } - res.Body.Close() - }() - } - reqs.Wait() - conns.Wait() - t.Logf("did %d dials, %d requests", atomic.LoadInt32(&dials), N) -} - -type noteCloseConn struct { - net.Conn - onceClose sync.Once - closefn func() -} - -func (c *noteCloseConn) Close() error { - c.onceClose.Do(c.closefn) - return c.Conn.Close() -} - -func isTimeout(err error) bool { - switch err := err.(type) { - case nil: - return false - case *url.Error: - return isTimeout(err.Err) - case net.Error: - return err.Timeout() - } - return false -} - -// Test that the http1 Transport.ResponseHeaderTimeout option and cancel is sent. -func TestTransportResponseHeaderTimeout_NoBody(t *testing.T) { - testTransportResponseHeaderTimeout(t, false) -} -func TestTransportResponseHeaderTimeout_Body(t *testing.T) { - testTransportResponseHeaderTimeout(t, true) -} - -func testTransportResponseHeaderTimeout(t *testing.T, body bool) { - ct := newClientTester(t) - ct.tr.t1 = &http.Transport{ - ResponseHeaderTimeout: 5 * time.Millisecond, - } - ct.client = func() error { - c := &http.Client{Transport: ct.tr} - var err error - var n int64 - const bodySize = 4 << 20 - if body { - _, err = c.Post("https://dummy.tld/", "text/foo", io.LimitReader(countingReader{&n}, bodySize)) - } else { - _, err = c.Get("https://dummy.tld/") - } - if !isTimeout(err) { - t.Errorf("client expected timeout error; got %#v", err) - } - if body && n != bodySize { - t.Errorf("only read %d bytes of body; want %d", n, bodySize) - } - return nil - } - ct.server = func() error { - ct.greet() - for { - f, err := ct.fr.ReadFrame() - if err != nil { - t.Logf("ReadFrame: %v", err) - return nil - } - switch f := f.(type) { - case *DataFrame: - dataLen := len(f.Data()) - if dataLen > 0 { - if err := ct.fr.WriteWindowUpdate(0, uint32(dataLen)); err != nil { - return err - } - if err := ct.fr.WriteWindowUpdate(f.StreamID, uint32(dataLen)); err != nil { - return err - } - } - case *RSTStreamFrame: - if f.StreamID == 1 && f.ErrCode == ErrCodeCancel { - return nil - } - } - } - } - ct.run() -} - -func TestTransportDisableCompression(t *testing.T) { - const body = "sup" - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - want := http.Header{ - "User-Agent": []string{"Go-http-client/2.0"}, - } - if !reflect.DeepEqual(r.Header, want) { - t.Errorf("request headers = %v; want %v", r.Header, want) - } - }, optOnlyServer) - defer st.Close() - - tr := &Transport{ - TLSClientConfig: tlsConfigInsecure, - t1: &http.Transport{ - DisableCompression: true, - }, - } - defer tr.CloseIdleConnections() - - req, err := http.NewRequest("GET", st.ts.URL, nil) - if err != nil { - t.Fatal(err) - } - res, err := tr.RoundTrip(req) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() -} - -// RFC 7540 section 8.1.2.2 -func TestTransportRejectsConnHeaders(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - var got []string - for k := range r.Header { - got = append(got, k) - } - sort.Strings(got) - w.Header().Set("Got-Header", strings.Join(got, ",")) - }, optOnlyServer) - defer st.Close() - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - - tests := []struct { - key string - value []string - want string - }{ - { - key: "Upgrade", - value: []string{"anything"}, - want: "ERROR: http2: invalid Upgrade request header: [\"anything\"]", - }, - { - key: "Connection", - value: []string{"foo"}, - want: "ERROR: http2: invalid Connection request header: [\"foo\"]", - }, - { - key: "Connection", - value: []string{"close"}, - want: "Accept-Encoding,User-Agent", - }, - { - key: "Connection", - value: []string{"close", "something-else"}, - want: "ERROR: http2: invalid Connection request header: [\"close\" \"something-else\"]", - }, - { - key: "Connection", - value: []string{"keep-alive"}, - want: "Accept-Encoding,User-Agent", - }, - { - key: "Proxy-Connection", // just deleted and ignored - value: []string{"keep-alive"}, - want: "Accept-Encoding,User-Agent", - }, - { - key: "Transfer-Encoding", - value: []string{""}, - want: "Accept-Encoding,User-Agent", - }, - { - key: "Transfer-Encoding", - value: []string{"foo"}, - want: "ERROR: http2: invalid Transfer-Encoding request header: [\"foo\"]", - }, - { - key: "Transfer-Encoding", - value: []string{"chunked"}, - want: "Accept-Encoding,User-Agent", - }, - { - key: "Transfer-Encoding", - value: []string{"chunked", "other"}, - want: "ERROR: http2: invalid Transfer-Encoding request header: [\"chunked\" \"other\"]", - }, - { - key: "Content-Length", - value: []string{"123"}, - want: "Accept-Encoding,User-Agent", - }, - { - key: "Keep-Alive", - value: []string{"doop"}, - want: "Accept-Encoding,User-Agent", - }, - } - - for _, tt := range tests { - req, _ := http.NewRequest("GET", st.ts.URL, nil) - req.Header[tt.key] = tt.value - res, err := tr.RoundTrip(req) - var got string - if err != nil { - got = fmt.Sprintf("ERROR: %v", err) - } else { - got = res.Header.Get("Got-Header") - res.Body.Close() - } - if got != tt.want { - t.Errorf("For key %q, value %q, got = %q; want %q", tt.key, tt.value, got, tt.want) - } - } -} - -// golang.org/issue/14048 -func TestTransportFailsOnInvalidHeaders(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - var got []string - for k := range r.Header { - got = append(got, k) - } - sort.Strings(got) - w.Header().Set("Got-Header", strings.Join(got, ",")) - }, optOnlyServer) - defer st.Close() - - tests := [...]struct { - h http.Header - wantErr string - }{ - 0: { - h: http.Header{"with space": {"foo"}}, - wantErr: `invalid HTTP header name "with space"`, - }, - 1: { - h: http.Header{"name": {"БрÑд"}}, - wantErr: "", // okay - }, - 2: { - h: http.Header{"имÑ": {"Brad"}}, - wantErr: `invalid HTTP header name "имÑ"`, - }, - 3: { - h: http.Header{"foo": {"foo\x01bar"}}, - wantErr: `invalid HTTP header value "foo\x01bar" for header "foo"`, - }, - } - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - - for i, tt := range tests { - req, _ := http.NewRequest("GET", st.ts.URL, nil) - req.Header = tt.h - res, err := tr.RoundTrip(req) - var bad bool - if tt.wantErr == "" { - if err != nil { - bad = true - t.Errorf("case %d: error = %v; want no error", i, err) - } - } else { - if !strings.Contains(fmt.Sprint(err), tt.wantErr) { - bad = true - t.Errorf("case %d: error = %v; want error %q", i, err, tt.wantErr) - } - } - if err == nil { - if bad { - t.Logf("case %d: server got headers %q", i, res.Header.Get("Got-Header")) - } - res.Body.Close() - } - } -} - -// Tests that gzipReader doesn't crash on a second Read call following -// the first Read call's gzip.NewReader returning an error. -func TestGzipReader_DoubleReadCrash(t *testing.T) { - gz := &gzipReader{ - body: ioutil.NopCloser(strings.NewReader("0123456789")), - } - var buf [1]byte - n, err1 := gz.Read(buf[:]) - if n != 0 || !strings.Contains(fmt.Sprint(err1), "invalid header") { - t.Fatalf("Read = %v, %v; want 0, invalid header", n, err1) - } - n, err2 := gz.Read(buf[:]) - if n != 0 || err2 != err1 { - t.Fatalf("second Read = %v, %v; want 0, %v", n, err2, err1) - } -} - -func TestTransportNewTLSConfig(t *testing.T) { - tests := [...]struct { - conf *tls.Config - host string - want *tls.Config - }{ - // Normal case. - 0: { - conf: nil, - host: "foo.com", - want: &tls.Config{ - ServerName: "foo.com", - NextProtos: []string{NextProtoTLS}, - }, - }, - - // User-provided name (bar.com) takes precedence: - 1: { - conf: &tls.Config{ - ServerName: "bar.com", - }, - host: "foo.com", - want: &tls.Config{ - ServerName: "bar.com", - NextProtos: []string{NextProtoTLS}, - }, - }, - - // NextProto is prepended: - 2: { - conf: &tls.Config{ - NextProtos: []string{"foo", "bar"}, - }, - host: "example.com", - want: &tls.Config{ - ServerName: "example.com", - NextProtos: []string{NextProtoTLS, "foo", "bar"}, - }, - }, - - // NextProto is not duplicated: - 3: { - conf: &tls.Config{ - NextProtos: []string{"foo", "bar", NextProtoTLS}, - }, - host: "example.com", - want: &tls.Config{ - ServerName: "example.com", - NextProtos: []string{"foo", "bar", NextProtoTLS}, - }, - }, - } - for i, tt := range tests { - // Ignore the session ticket keys part, which ends up populating - // unexported fields in the Config: - if tt.conf != nil { - tt.conf.SessionTicketsDisabled = true - } - - tr := &Transport{TLSClientConfig: tt.conf} - got := tr.newTLSConfig(tt.host) - - got.SessionTicketsDisabled = false - - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("%d. got %#v; want %#v", i, got, tt.want) - } - } -} - -// The Google GFE responds to HEAD requests with a HEADERS frame -// without END_STREAM, followed by a 0-length DATA frame with -// END_STREAM. Make sure we don't get confused by that. (We did.) -func TestTransportReadHeadResponse(t *testing.T) { - ct := newClientTester(t) - clientDone := make(chan struct{}) - ct.client = func() error { - defer close(clientDone) - req, _ := http.NewRequest("HEAD", "https://dummy.tld/", nil) - res, err := ct.tr.RoundTrip(req) - if err != nil { - return err - } - if res.ContentLength != 123 { - return fmt.Errorf("Content-Length = %d; want 123", res.ContentLength) - } - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - return fmt.Errorf("ReadAll: %v", err) - } - if len(slurp) > 0 { - return fmt.Errorf("Unexpected non-empty ReadAll body: %q", slurp) - } - return nil - } - ct.server = func() error { - ct.greet() - for { - f, err := ct.fr.ReadFrame() - if err != nil { - t.Logf("ReadFrame: %v", err) - return nil - } - hf, ok := f.(*HeadersFrame) - if !ok { - continue - } - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - enc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) - enc.WriteField(hpack.HeaderField{Name: "content-length", Value: "123"}) - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: hf.StreamID, - EndHeaders: true, - EndStream: false, // as the GFE does - BlockFragment: buf.Bytes(), - }) - ct.fr.WriteData(hf.StreamID, true, nil) - - <-clientDone - return nil - } - } - ct.run() -} - -type neverEnding byte - -func (b neverEnding) Read(p []byte) (int, error) { - for i := range p { - p[i] = byte(b) - } - return len(p), nil -} - -// golang.org/issue/15425: test that a handler closing the request -// body doesn't terminate the stream to the peer. (It just stops -// readability from the handler's side, and eventually the client -// runs out of flow control tokens) -func TestTransportHandlerBodyClose(t *testing.T) { - const bodySize = 10 << 20 - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - r.Body.Close() - io.Copy(w, io.LimitReader(neverEnding('A'), bodySize)) - }, optOnlyServer) - defer st.Close() - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - - g0 := runtime.NumGoroutine() - - const numReq = 10 - for i := 0; i < numReq; i++ { - req, err := http.NewRequest("POST", st.ts.URL, struct{ io.Reader }{io.LimitReader(neverEnding('A'), bodySize)}) - if err != nil { - t.Fatal(err) - } - res, err := tr.RoundTrip(req) - if err != nil { - t.Fatal(err) - } - n, err := io.Copy(ioutil.Discard, res.Body) - res.Body.Close() - if n != bodySize || err != nil { - t.Fatalf("req#%d: Copy = %d, %v; want %d, nil", i, n, err, bodySize) - } - } - tr.CloseIdleConnections() - - gd := runtime.NumGoroutine() - g0 - if gd > numReq/2 { - t.Errorf("appeared to leak goroutines") - } - -} - -// https://golang.org/issue/15930 -func TestTransportFlowControl(t *testing.T) { - const bufLen = 64 << 10 - var total int64 = 100 << 20 // 100MB - if testing.Short() { - total = 10 << 20 - } - - var wrote int64 // updated atomically - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - b := make([]byte, bufLen) - for wrote < total { - n, err := w.Write(b) - atomic.AddInt64(&wrote, int64(n)) - if err != nil { - t.Errorf("ResponseWriter.Write error: %v", err) - break - } - w.(http.Flusher).Flush() - } - }, optOnlyServer) - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - req, err := http.NewRequest("GET", st.ts.URL, nil) - if err != nil { - t.Fatal("NewRequest error:", err) - } - resp, err := tr.RoundTrip(req) - if err != nil { - t.Fatal("RoundTrip error:", err) - } - defer resp.Body.Close() - - var read int64 - b := make([]byte, bufLen) - for { - n, err := resp.Body.Read(b) - if err == io.EOF { - break - } - if err != nil { - t.Fatal("Read error:", err) - } - read += int64(n) - - const max = transportDefaultStreamFlow - if w := atomic.LoadInt64(&wrote); -max > read-w || read-w > max { - t.Fatalf("Too much data inflight: server wrote %v bytes but client only received %v", w, read) - } - - // Let the server get ahead of the client. - time.Sleep(1 * time.Millisecond) - } -} - -// golang.org/issue/14627 -- if the server sends a GOAWAY frame, make -// the Transport remember it and return it back to users (via -// RoundTrip or request body reads) if needed (e.g. if the server -// proceeds to close the TCP connection before the client gets its -// response) -func TestTransportUsesGoAwayDebugError_RoundTrip(t *testing.T) { - testTransportUsesGoAwayDebugError(t, false) -} - -func TestTransportUsesGoAwayDebugError_Body(t *testing.T) { - testTransportUsesGoAwayDebugError(t, true) -} - -func testTransportUsesGoAwayDebugError(t *testing.T, failMidBody bool) { - ct := newClientTester(t) - clientDone := make(chan struct{}) - - const goAwayErrCode = ErrCodeHTTP11Required // arbitrary - const goAwayDebugData = "some debug data" - - ct.client = func() error { - defer close(clientDone) - req, _ := http.NewRequest("GET", "https://dummy.tld/", nil) - res, err := ct.tr.RoundTrip(req) - if failMidBody { - if err != nil { - return fmt.Errorf("unexpected client RoundTrip error: %v", err) - } - _, err = io.Copy(ioutil.Discard, res.Body) - res.Body.Close() - } - want := GoAwayError{ - LastStreamID: 5, - ErrCode: goAwayErrCode, - DebugData: goAwayDebugData, - } - if !reflect.DeepEqual(err, want) { - t.Errorf("RoundTrip error = %T: %#v, want %T (%#v)", err, err, want, want) - } - return nil - } - ct.server = func() error { - ct.greet() - for { - f, err := ct.fr.ReadFrame() - if err != nil { - t.Logf("ReadFrame: %v", err) - return nil - } - hf, ok := f.(*HeadersFrame) - if !ok { - continue - } - if failMidBody { - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - enc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) - enc.WriteField(hpack.HeaderField{Name: "content-length", Value: "123"}) - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: hf.StreamID, - EndHeaders: true, - EndStream: false, - BlockFragment: buf.Bytes(), - }) - } - // Write two GOAWAY frames, to test that the Transport takes - // the interesting parts of both. - ct.fr.WriteGoAway(5, ErrCodeNo, []byte(goAwayDebugData)) - ct.fr.WriteGoAway(5, goAwayErrCode, nil) - 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 := make([]byte, 5) - 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() -} - -// byteAndEOFReader returns is in an io.Reader which reads one byte -// (the underlying byte) and io.EOF at once in its Read call. -type byteAndEOFReader byte - -func (b byteAndEOFReader) Read(p []byte) (n int, err error) { - if len(p) == 0 { - panic("unexpected useless call") - } - p[0] = byte(b) - return 1, io.EOF -} - -// Issue 16788: the Transport had a regression where it started -// sending a spurious DATA frame with a duplicate END_STREAM bit after -// the request body writer goroutine had already read an EOF from the -// Request.Body and included the END_STREAM on a data-carrying DATA -// frame. -// -// Notably, to trigger this, the requests need to use a Request.Body -// which returns (non-0, io.EOF) and also needs to set the ContentLength -// explicitly. -func TestTransportBodyDoubleEndStream(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - // Nothing. - }, optOnlyServer) - defer st.Close() - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - - for i := 0; i < 2; i++ { - req, _ := http.NewRequest("POST", st.ts.URL, byteAndEOFReader('a')) - req.ContentLength = 1 - res, err := tr.RoundTrip(req) - if err != nil { - t.Fatalf("failure on req %d: %v", i+1, err) - } - defer res.Body.Close() - } -} - -// golangorg/issue/16847 -func TestTransportRequestPathPseudo(t *testing.T) { - type result struct { - path string - err string - } - tests := []struct { - req *http.Request - want result - }{ - 0: { - req: &http.Request{ - Method: "GET", - URL: &url.URL{ - Host: "foo.com", - Path: "/foo", - }, - }, - want: result{path: "/foo"}, - }, - // I guess we just don't let users request "//foo" as - // a path, since it's illegal to start with two - // slashes.... - 1: { - req: &http.Request{ - Method: "GET", - URL: &url.URL{ - Host: "foo.com", - Path: "//foo", - }, - }, - want: result{err: `invalid request :path "//foo"`}, - }, - - // Opaque with //$Matching_Hostname/path - 2: { - req: &http.Request{ - Method: "GET", - URL: &url.URL{ - Scheme: "https", - Opaque: "//foo.com/path", - Host: "foo.com", - Path: "/ignored", - }, - }, - want: result{path: "/path"}, - }, - - // Opaque with some other Request.Host instead: - 3: { - req: &http.Request{ - Method: "GET", - Host: "bar.com", - URL: &url.URL{ - Scheme: "https", - Opaque: "//bar.com/path", - Host: "foo.com", - Path: "/ignored", - }, - }, - want: result{path: "/path"}, - }, - - // Opaque without the leading "//": - 4: { - req: &http.Request{ - Method: "GET", - URL: &url.URL{ - Opaque: "/path", - Host: "foo.com", - Path: "/ignored", - }, - }, - want: result{path: "/path"}, - }, - - // Opaque we can't handle: - 5: { - req: &http.Request{ - Method: "GET", - URL: &url.URL{ - Scheme: "https", - Opaque: "//unknown_host/path", - Host: "foo.com", - Path: "/ignored", - }, - }, - want: result{err: `invalid request :path "https://unknown_host/path" from URL.Opaque = "//unknown_host/path"`}, - }, - - // A CONNECT request: - 6: { - req: &http.Request{ - Method: "CONNECT", - URL: &url.URL{ - Host: "foo.com", - }, - }, - want: result{}, - }, - } - for i, tt := range tests { - cc := &ClientConn{} - cc.henc = hpack.NewEncoder(&cc.hbuf) - cc.mu.Lock() - hdrs, err := cc.encodeHeaders(tt.req, false, "", -1) - cc.mu.Unlock() - var got result - hpackDec := hpack.NewDecoder(initialHeaderTableSize, func(f hpack.HeaderField) { - if f.Name == ":path" { - got.path = f.Value - } - }) - if err != nil { - got.err = err.Error() - } else if len(hdrs) > 0 { - if _, err := hpackDec.Write(hdrs); err != nil { - t.Errorf("%d. bogus hpack: %v", i, err) - continue - } - } - if got != tt.want { - t.Errorf("%d. got %+v; want %+v", i, got, tt.want) - } - - } - -} - -// golang.org/issue/17071 -- don't sniff the first byte of the request body -// before we've determined that the ClientConn is usable. -func TestRoundTripDoesntConsumeRequestBodyEarly(t *testing.T) { - const body = "foo" - req, _ := http.NewRequest("POST", "http://foo.com/", ioutil.NopCloser(strings.NewReader(body))) - cc := &ClientConn{ - closed: true, - } - _, err := cc.RoundTrip(req) - if err != errClientConnUnusable { - t.Fatalf("RoundTrip = %v; want errClientConnUnusable", err) - } - slurp, err := ioutil.ReadAll(req.Body) - if err != nil { - t.Errorf("ReadAll = %v", err) - } - if string(slurp) != body { - t.Errorf("Body = %q; want %q", slurp, body) - } -} - -func TestClientConnPing(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) {}, optOnlyServer) - defer st.Close() - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - cc, err := tr.dialClientConn(st.ts.Listener.Addr().String(), false) - if err != nil { - t.Fatal(err) - } - if err = cc.Ping(testContext{}); err != nil { - t.Fatal(err) - } -} - -// Issue 16974: if the server sent a DATA frame after the user -// canceled the Transport's Request, the Transport previously wrote to a -// closed pipe, got an error, and ended up closing the whole TCP -// connection. -func TestTransportCancelDataResponseRace(t *testing.T) { - cancel := make(chan struct{}) - clientGotError := make(chan bool, 1) - - const msg = "Hello." - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - if strings.Contains(r.URL.Path, "/hello") { - time.Sleep(50 * time.Millisecond) - io.WriteString(w, msg) - return - } - for i := 0; i < 50; i++ { - io.WriteString(w, "Some data.") - w.(http.Flusher).Flush() - if i == 2 { - close(cancel) - <-clientGotError - } - time.Sleep(10 * time.Millisecond) - } - }, optOnlyServer) - defer st.Close() - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - - c := &http.Client{Transport: tr} - req, _ := http.NewRequest("GET", st.ts.URL, nil) - req.Cancel = cancel - res, err := c.Do(req) - if err != nil { - t.Fatal(err) - } - if _, err = io.Copy(ioutil.Discard, res.Body); err == nil { - t.Fatal("unexpected success") - } - clientGotError <- true - - res, err = c.Get(st.ts.URL + "/hello") - if err != nil { - t.Fatal(err) - } - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal(err) - } - if string(slurp) != msg { - t.Errorf("Got = %q; want %q", slurp, msg) - } -} - -func TestTransportRetryAfterGOAWAY(t *testing.T) { - var dialer struct { - sync.Mutex - count int - } - ct1 := make(chan *clientTester) - ct2 := make(chan *clientTester) - - ln := newLocalListener(t) - defer ln.Close() - - tr := &Transport{ - TLSClientConfig: tlsConfigInsecure, - } - tr.DialTLS = func(network, addr string, cfg *tls.Config) (net.Conn, error) { - dialer.Lock() - defer dialer.Unlock() - dialer.count++ - if dialer.count == 3 { - return nil, errors.New("unexpected number of dials") - } - cc, err := net.Dial("tcp", ln.Addr().String()) - if err != nil { - return nil, fmt.Errorf("dial error: %v", err) - } - sc, err := ln.Accept() - if err != nil { - return nil, fmt.Errorf("accept error: %v", err) - } - ct := &clientTester{ - t: t, - tr: tr, - cc: cc, - sc: sc, - fr: NewFramer(sc, sc), - } - switch dialer.count { - case 1: - ct1 <- ct - case 2: - ct2 <- ct - } - return cc, nil - } - - errs := make(chan error, 3) - done := make(chan struct{}) - defer close(done) - - // Client. - go func() { - req, _ := http.NewRequest("GET", "https://dummy.tld/", nil) - res, err := tr.RoundTrip(req) - if res != nil { - res.Body.Close() - if got := res.Header.Get("Foo"); got != "bar" { - err = fmt.Errorf("foo header = %q; want bar", got) - } - } - if err != nil { - err = fmt.Errorf("RoundTrip: %v", err) - } - errs <- err - }() - - connToClose := make(chan io.Closer, 2) - - // Server for the first request. - go func() { - var ct *clientTester - select { - case ct = <-ct1: - case <-done: - return - } - - connToClose <- ct.cc - ct.greet() - hf, err := ct.firstHeaders() - if err != nil { - errs <- fmt.Errorf("server1 failed reading HEADERS: %v", err) - return - } - t.Logf("server1 got %v", hf) - if err := ct.fr.WriteGoAway(0 /*max id*/, ErrCodeNo, nil); err != nil { - errs <- fmt.Errorf("server1 failed writing GOAWAY: %v", err) - return - } - errs <- nil - }() - - // Server for the second request. - go func() { - var ct *clientTester - select { - case ct = <-ct2: - case <-done: - return - } - - connToClose <- ct.cc - ct.greet() - hf, err := ct.firstHeaders() - if err != nil { - errs <- fmt.Errorf("server2 failed reading HEADERS: %v", err) - return - } - t.Logf("server2 got %v", hf) - - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - enc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) - enc.WriteField(hpack.HeaderField{Name: "foo", Value: "bar"}) - err = ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: hf.StreamID, - EndHeaders: true, - EndStream: false, - BlockFragment: buf.Bytes(), - }) - if err != nil { - errs <- fmt.Errorf("server2 failed writing response HEADERS: %v", err) - } else { - errs <- nil - } - }() - - for k := 0; k < 3; k++ { - select { - case err := <-errs: - if err != nil { - t.Error(err) - } - case <-time.After(1 * time.Second): - t.Errorf("timed out") - } - } - - for { - select { - case c := <-connToClose: - c.Close() - default: - return - } - } -} - -func TestAuthorityAddr(t *testing.T) { - tests := []struct { - scheme, authority string - want string - }{ - {"http", "foo.com", "foo.com:80"}, - {"https", "foo.com", "foo.com:443"}, - {"https", "foo.com:1234", "foo.com:1234"}, - {"https", "1.2.3.4:1234", "1.2.3.4:1234"}, - {"https", "1.2.3.4", "1.2.3.4:443"}, - {"https", "[::1]:1234", "[::1]:1234"}, - {"https", "[::1]", "[::1]:443"}, - } - for _, tt := range tests { - got := authorityAddr(tt.scheme, tt.authority) - if got != tt.want { - t.Errorf("authorityAddr(%q, %q) = %q; want %q", tt.scheme, tt.authority, got, tt.want) - } - } -} diff --git a/vendor/golang.org/x/net/http2/write.go b/vendor/golang.org/x/net/http2/write.go deleted file mode 100644 index 6b0dfae31..000000000 --- a/vendor/golang.org/x/net/http2/write.go +++ /dev/null @@ -1,370 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "bytes" - "fmt" - "log" - "net/http" - "net/url" - "time" - - "golang.org/x/net/http2/hpack" - "golang.org/x/net/lex/httplex" -) - -// writeFramer is implemented by any type that is used to write frames. -type writeFramer interface { - writeFrame(writeContext) error - - // staysWithinBuffer reports whether this writer promises that - // it will only write less than or equal to size bytes, and it - // won't Flush the write context. - staysWithinBuffer(size int) bool -} - -// writeContext is the interface needed by the various frame writer -// types below. All the writeFrame methods below are scheduled via the -// frame writing scheduler (see writeScheduler in writesched.go). -// -// This interface is implemented by *serverConn. -// -// TODO: decide whether to a) use this in the client code (which didn't -// end up using this yet, because it has a simpler design, not -// currently implementing priorities), or b) delete this and -// make the server code a bit more concrete. -type writeContext interface { - Framer() *Framer - Flush() error - CloseConn() error - // HeaderEncoder returns an HPACK encoder that writes to the - // returned buffer. - HeaderEncoder() (*hpack.Encoder, *bytes.Buffer) -} - -// writeEndsStream reports whether w writes a frame that will transition -// the stream to a half-closed local state. This returns false for RST_STREAM, -// which closes the entire stream (not just the local half). -func writeEndsStream(w writeFramer) bool { - switch v := w.(type) { - case *writeData: - return v.endStream - case *writeResHeaders: - return v.endStream - case nil: - // This can only happen if the caller reuses w after it's - // been intentionally nil'ed out to prevent use. Keep this - // here to catch future refactoring breaking it. - panic("writeEndsStream called on nil writeFramer") - } - return false -} - -type flushFrameWriter struct{} - -func (flushFrameWriter) writeFrame(ctx writeContext) error { - return ctx.Flush() -} - -func (flushFrameWriter) staysWithinBuffer(max int) bool { return false } - -type writeSettings []Setting - -func (s writeSettings) staysWithinBuffer(max int) bool { - const settingSize = 6 // uint16 + uint32 - return frameHeaderLen+settingSize*len(s) <= max - -} - -func (s writeSettings) writeFrame(ctx writeContext) error { - return ctx.Framer().WriteSettings([]Setting(s)...) -} - -type writeGoAway struct { - maxStreamID uint32 - code ErrCode -} - -func (p *writeGoAway) writeFrame(ctx writeContext) error { - err := ctx.Framer().WriteGoAway(p.maxStreamID, p.code, nil) - if p.code != 0 { - ctx.Flush() // ignore error: we're hanging up on them anyway - time.Sleep(50 * time.Millisecond) - ctx.CloseConn() - } - return err -} - -func (*writeGoAway) staysWithinBuffer(max int) bool { return false } // flushes - -type writeData struct { - streamID uint32 - p []byte - endStream bool -} - -func (w *writeData) String() string { - return fmt.Sprintf("writeData(stream=%d, p=%d, endStream=%v)", w.streamID, len(w.p), w.endStream) -} - -func (w *writeData) writeFrame(ctx writeContext) error { - return ctx.Framer().WriteData(w.streamID, w.endStream, w.p) -} - -func (w *writeData) staysWithinBuffer(max int) bool { - return frameHeaderLen+len(w.p) <= max -} - -// handlerPanicRST is the message sent from handler goroutines when -// the handler panics. -type handlerPanicRST struct { - StreamID uint32 -} - -func (hp handlerPanicRST) writeFrame(ctx writeContext) error { - return ctx.Framer().WriteRSTStream(hp.StreamID, ErrCodeInternal) -} - -func (hp handlerPanicRST) staysWithinBuffer(max int) bool { return frameHeaderLen+4 <= max } - -func (se StreamError) writeFrame(ctx writeContext) error { - return ctx.Framer().WriteRSTStream(se.StreamID, se.Code) -} - -func (se StreamError) staysWithinBuffer(max int) bool { return frameHeaderLen+4 <= max } - -type writePingAck struct{ pf *PingFrame } - -func (w writePingAck) writeFrame(ctx writeContext) error { - return ctx.Framer().WritePing(true, w.pf.Data) -} - -func (w writePingAck) staysWithinBuffer(max int) bool { return frameHeaderLen+len(w.pf.Data) <= max } - -type writeSettingsAck struct{} - -func (writeSettingsAck) writeFrame(ctx writeContext) error { - return ctx.Framer().WriteSettingsAck() -} - -func (writeSettingsAck) staysWithinBuffer(max int) bool { return frameHeaderLen <= max } - -// splitHeaderBlock splits headerBlock into fragments so that each fragment fits -// in a single frame, then calls fn for each fragment. firstFrag/lastFrag are true -// for the first/last fragment, respectively. -func splitHeaderBlock(ctx writeContext, headerBlock []byte, fn func(ctx writeContext, frag []byte, firstFrag, lastFrag bool) error) error { - // For now we're lazy and just pick the minimum MAX_FRAME_SIZE - // that all peers must support (16KB). Later we could care - // more and send larger frames if the peer advertised it, but - // there's little point. Most headers are small anyway (so we - // generally won't have CONTINUATION frames), and extra frames - // only waste 9 bytes anyway. - const maxFrameSize = 16384 - - first := true - for len(headerBlock) > 0 { - frag := headerBlock - if len(frag) > maxFrameSize { - frag = frag[:maxFrameSize] - } - headerBlock = headerBlock[len(frag):] - if err := fn(ctx, frag, first, len(headerBlock) == 0); err != nil { - return err - } - first = false - } - return nil -} - -// writeResHeaders is a request to write a HEADERS and 0+ CONTINUATION frames -// for HTTP response headers or trailers from a server handler. -type writeResHeaders struct { - streamID uint32 - httpResCode int // 0 means no ":status" line - h http.Header // may be nil - trailers []string // if non-nil, which keys of h to write. nil means all. - endStream bool - - date string - contentType string - contentLength string -} - -func encKV(enc *hpack.Encoder, k, v string) { - if VerboseLogs { - log.Printf("http2: server encoding header %q = %q", k, v) - } - enc.WriteField(hpack.HeaderField{Name: k, Value: v}) -} - -func (w *writeResHeaders) staysWithinBuffer(max int) bool { - // TODO: this is a common one. It'd be nice to return true - // here and get into the fast path if we could be clever and - // calculate the size fast enough, or at least a conservative - // uppper bound that usually fires. (Maybe if w.h and - // w.trailers are nil, so we don't need to enumerate it.) - // Otherwise I'm afraid that just calculating the length to - // answer this question would be slower than the ~2µs benefit. - return false -} - -func (w *writeResHeaders) writeFrame(ctx writeContext) error { - enc, buf := ctx.HeaderEncoder() - buf.Reset() - - if w.httpResCode != 0 { - encKV(enc, ":status", httpCodeString(w.httpResCode)) - } - - encodeHeaders(enc, w.h, w.trailers) - - if w.contentType != "" { - encKV(enc, "content-type", w.contentType) - } - if w.contentLength != "" { - encKV(enc, "content-length", w.contentLength) - } - if w.date != "" { - encKV(enc, "date", w.date) - } - - headerBlock := buf.Bytes() - if len(headerBlock) == 0 && w.trailers == nil { - panic("unexpected empty hpack") - } - - return splitHeaderBlock(ctx, headerBlock, w.writeHeaderBlock) -} - -func (w *writeResHeaders) writeHeaderBlock(ctx writeContext, frag []byte, firstFrag, lastFrag bool) error { - if firstFrag { - return ctx.Framer().WriteHeaders(HeadersFrameParam{ - StreamID: w.streamID, - BlockFragment: frag, - EndStream: w.endStream, - EndHeaders: lastFrag, - }) - } else { - return ctx.Framer().WriteContinuation(w.streamID, lastFrag, frag) - } -} - -// writePushPromise is a request to write a PUSH_PROMISE and 0+ CONTINUATION frames. -type writePushPromise struct { - streamID uint32 // pusher stream - method string // for :method - url *url.URL // for :scheme, :authority, :path - h http.Header - - // Creates an ID for a pushed stream. This runs on serveG just before - // the frame is written. The returned ID is copied to promisedID. - allocatePromisedID func() (uint32, error) - promisedID uint32 -} - -func (w *writePushPromise) staysWithinBuffer(max int) bool { - // TODO: see writeResHeaders.staysWithinBuffer - return false -} - -func (w *writePushPromise) writeFrame(ctx writeContext) error { - enc, buf := ctx.HeaderEncoder() - buf.Reset() - - encKV(enc, ":method", w.method) - encKV(enc, ":scheme", w.url.Scheme) - encKV(enc, ":authority", w.url.Host) - encKV(enc, ":path", w.url.RequestURI()) - encodeHeaders(enc, w.h, nil) - - headerBlock := buf.Bytes() - if len(headerBlock) == 0 { - panic("unexpected empty hpack") - } - - return splitHeaderBlock(ctx, headerBlock, w.writeHeaderBlock) -} - -func (w *writePushPromise) writeHeaderBlock(ctx writeContext, frag []byte, firstFrag, lastFrag bool) error { - if firstFrag { - return ctx.Framer().WritePushPromise(PushPromiseParam{ - StreamID: w.streamID, - PromiseID: w.promisedID, - BlockFragment: frag, - EndHeaders: lastFrag, - }) - } else { - return ctx.Framer().WriteContinuation(w.streamID, lastFrag, frag) - } -} - -type write100ContinueHeadersFrame struct { - streamID uint32 -} - -func (w write100ContinueHeadersFrame) writeFrame(ctx writeContext) error { - enc, buf := ctx.HeaderEncoder() - buf.Reset() - encKV(enc, ":status", "100") - return ctx.Framer().WriteHeaders(HeadersFrameParam{ - StreamID: w.streamID, - BlockFragment: buf.Bytes(), - EndStream: false, - EndHeaders: true, - }) -} - -func (w write100ContinueHeadersFrame) staysWithinBuffer(max int) bool { - // Sloppy but conservative: - return 9+2*(len(":status")+len("100")) <= max -} - -type writeWindowUpdate struct { - streamID uint32 // or 0 for conn-level - n uint32 -} - -func (wu writeWindowUpdate) staysWithinBuffer(max int) bool { return frameHeaderLen+4 <= max } - -func (wu writeWindowUpdate) writeFrame(ctx writeContext) error { - return ctx.Framer().WriteWindowUpdate(wu.streamID, wu.n) -} - -// encodeHeaders encodes an http.Header. If keys is not nil, then (k, h[k]) -// is encoded only only if k is in keys. -func encodeHeaders(enc *hpack.Encoder, h http.Header, keys []string) { - if keys == nil { - sorter := sorterPool.Get().(*sorter) - // Using defer here, since the returned keys from the - // sorter.Keys method is only valid until the sorter - // is returned: - defer sorterPool.Put(sorter) - keys = sorter.Keys(h) - } - for _, k := range keys { - vv := h[k] - k = lowerHeader(k) - if !validWireHeaderFieldName(k) { - // Skip it as backup paranoia. Per - // golang.org/issue/14048, these should - // already be rejected at a higher level. - continue - } - isTE := k == "transfer-encoding" - for _, v := range vv { - if !httplex.ValidHeaderFieldValue(v) { - // TODO: return an error? golang.org/issue/14048 - // For now just omit it. - continue - } - // TODO: more of "8.1.2.2 Connection-Specific Header Fields" - if isTE && v != "trailers" { - continue - } - encKV(enc, k, v) - } - } -} diff --git a/vendor/golang.org/x/net/http2/writesched.go b/vendor/golang.org/x/net/http2/writesched.go deleted file mode 100644 index 4fe307307..000000000 --- a/vendor/golang.org/x/net/http2/writesched.go +++ /dev/null @@ -1,242 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import "fmt" - -// WriteScheduler is the interface implemented by HTTP/2 write schedulers. -// Methods are never called concurrently. -type WriteScheduler interface { - // OpenStream opens a new stream in the write scheduler. - // It is illegal to call this with streamID=0 or with a streamID that is - // already open -- the call may panic. - OpenStream(streamID uint32, options OpenStreamOptions) - - // CloseStream closes a stream in the write scheduler. Any frames queued on - // this stream should be discarded. It is illegal to call this on a stream - // that is not open -- the call may panic. - CloseStream(streamID uint32) - - // AdjustStream adjusts the priority of the given stream. This may be called - // on a stream that has not yet been opened or has been closed. Note that - // RFC 7540 allows PRIORITY frames to be sent on streams in any state. See: - // https://tools.ietf.org/html/rfc7540#section-5.1 - AdjustStream(streamID uint32, priority PriorityParam) - - // Push queues a frame in the scheduler. In most cases, this will not be - // called with wr.StreamID()!=0 unless that stream is currently open. The one - // exception is RST_STREAM frames, which may be sent on idle or closed streams. - Push(wr FrameWriteRequest) - - // Pop dequeues the next frame to write. Returns false if no frames can - // be written. Frames with a given wr.StreamID() are Pop'd in the same - // order they are Push'd. - Pop() (wr FrameWriteRequest, ok bool) -} - -// OpenStreamOptions specifies extra options for WriteScheduler.OpenStream. -type OpenStreamOptions struct { - // PusherID is zero if the stream was initiated by the client. Otherwise, - // PusherID names the stream that pushed the newly opened stream. - PusherID uint32 -} - -// FrameWriteRequest is a request to write a frame. -type FrameWriteRequest struct { - // write is the interface value that does the writing, once the - // WriteScheduler has selected this frame to write. The write - // functions are all defined in write.go. - write writeFramer - - // stream is the stream on which this frame will be written. - // nil for non-stream frames like PING and SETTINGS. - stream *stream - - // done, if non-nil, must be a buffered channel with space for - // 1 message and is sent the return value from write (or an - // earlier error) when the frame has been written. - done chan error -} - -// StreamID returns the id of the stream this frame will be written to. -// 0 is used for non-stream frames such as PING and SETTINGS. -func (wr FrameWriteRequest) StreamID() uint32 { - if wr.stream == nil { - if se, ok := wr.write.(StreamError); ok { - // (*serverConn).resetStream doesn't set - // stream because it doesn't necessarily have - // one. So special case this type of write - // message. - return se.StreamID - } - return 0 - } - return wr.stream.id -} - -// DataSize returns the number of flow control bytes that must be consumed -// to write this entire frame. This is 0 for non-DATA frames. -func (wr FrameWriteRequest) DataSize() int { - if wd, ok := wr.write.(*writeData); ok { - return len(wd.p) - } - return 0 -} - -// Consume consumes min(n, available) bytes from this frame, where available -// is the number of flow control bytes available on the stream. Consume returns -// 0, 1, or 2 frames, where the integer return value gives the number of frames -// returned. -// -// If flow control prevents consuming any bytes, this returns (_, _, 0). If -// the entire frame was consumed, this returns (wr, _, 1). Otherwise, this -// returns (consumed, rest, 2), where 'consumed' contains the consumed bytes and -// 'rest' contains the remaining bytes. The consumed bytes are deducted from the -// underlying stream's flow control budget. -func (wr FrameWriteRequest) Consume(n int32) (FrameWriteRequest, FrameWriteRequest, int) { - var empty FrameWriteRequest - - // Non-DATA frames are always consumed whole. - wd, ok := wr.write.(*writeData) - if !ok || len(wd.p) == 0 { - return wr, empty, 1 - } - - // Might need to split after applying limits. - allowed := wr.stream.flow.available() - if n < allowed { - allowed = n - } - if wr.stream.sc.maxFrameSize < allowed { - allowed = wr.stream.sc.maxFrameSize - } - if allowed <= 0 { - return empty, empty, 0 - } - if len(wd.p) > int(allowed) { - wr.stream.flow.take(allowed) - consumed := FrameWriteRequest{ - stream: wr.stream, - write: &writeData{ - streamID: wd.streamID, - p: wd.p[:allowed], - // Even if the original had endStream set, there - // are bytes remaining because len(wd.p) > allowed, - // so we know endStream is false. - endStream: false, - }, - // Our caller is blocking on the final DATA frame, not - // this intermediate frame, so no need to wait. - done: nil, - } - rest := FrameWriteRequest{ - stream: wr.stream, - write: &writeData{ - streamID: wd.streamID, - p: wd.p[allowed:], - endStream: wd.endStream, - }, - done: wr.done, - } - return consumed, rest, 2 - } - - // The frame is consumed whole. - // NB: This cast cannot overflow because allowed is <= math.MaxInt32. - wr.stream.flow.take(int32(len(wd.p))) - return wr, empty, 1 -} - -// String is for debugging only. -func (wr FrameWriteRequest) String() string { - var des string - if s, ok := wr.write.(fmt.Stringer); ok { - des = s.String() - } else { - des = fmt.Sprintf("%T", wr.write) - } - return fmt.Sprintf("[FrameWriteRequest stream=%d, ch=%v, writer=%v]", wr.StreamID(), wr.done != nil, des) -} - -// replyToWriter sends err to wr.done and panics if the send must block -// This does nothing if wr.done is nil. -func (wr *FrameWriteRequest) replyToWriter(err error) { - if wr.done == nil { - return - } - select { - case wr.done <- err: - default: - panic(fmt.Sprintf("unbuffered done channel passed in for type %T", wr.write)) - } - wr.write = nil // prevent use (assume it's tainted after wr.done send) -} - -// writeQueue is used by implementations of WriteScheduler. -type writeQueue struct { - s []FrameWriteRequest -} - -func (q *writeQueue) empty() bool { return len(q.s) == 0 } - -func (q *writeQueue) push(wr FrameWriteRequest) { - q.s = append(q.s, wr) -} - -func (q *writeQueue) shift() FrameWriteRequest { - if len(q.s) == 0 { - panic("invalid use of queue") - } - wr := q.s[0] - // TODO: less copy-happy queue. - copy(q.s, q.s[1:]) - q.s[len(q.s)-1] = FrameWriteRequest{} - q.s = q.s[:len(q.s)-1] - return wr -} - -// consume consumes up to n bytes from q.s[0]. If the frame is -// entirely consumed, it is removed from the queue. If the frame -// is partially consumed, the frame is kept with the consumed -// bytes removed. Returns true iff any bytes were consumed. -func (q *writeQueue) consume(n int32) (FrameWriteRequest, bool) { - if len(q.s) == 0 { - return FrameWriteRequest{}, false - } - consumed, rest, numresult := q.s[0].Consume(n) - switch numresult { - case 0: - return FrameWriteRequest{}, false - case 1: - q.shift() - case 2: - q.s[0] = rest - } - return consumed, true -} - -type writeQueuePool []*writeQueue - -// put inserts an unused writeQueue into the pool. -func (p *writeQueuePool) put(q *writeQueue) { - for i := range q.s { - q.s[i] = FrameWriteRequest{} - } - q.s = q.s[:0] - *p = append(*p, q) -} - -// get returns an empty writeQueue. -func (p *writeQueuePool) get() *writeQueue { - ln := len(*p) - if ln == 0 { - return new(writeQueue) - } - x := ln - 1 - q := (*p)[x] - (*p)[x] = nil - *p = (*p)[:x] - return q -} diff --git a/vendor/golang.org/x/net/http2/writesched_priority.go b/vendor/golang.org/x/net/http2/writesched_priority.go deleted file mode 100644 index 01132721b..000000000 --- a/vendor/golang.org/x/net/http2/writesched_priority.go +++ /dev/null @@ -1,452 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "fmt" - "math" - "sort" -) - -// RFC 7540, Section 5.3.5: the default weight is 16. -const priorityDefaultWeight = 15 // 16 = 15 + 1 - -// PriorityWriteSchedulerConfig configures a priorityWriteScheduler. -type PriorityWriteSchedulerConfig struct { - // MaxClosedNodesInTree controls the maximum number of closed streams to - // retain in the priority tree. Setting this to zero saves a small amount - // of memory at the cost of performance. - // - // See RFC 7540, Section 5.3.4: - // "It is possible for a stream to become closed while prioritization - // information ... is in transit. ... This potentially creates suboptimal - // prioritization, since the stream could be given a priority that is - // different from what is intended. To avoid these problems, an endpoint - // SHOULD retain stream prioritization state for a period after streams - // become closed. The longer state is retained, the lower the chance that - // streams are assigned incorrect or default priority values." - MaxClosedNodesInTree int - - // MaxIdleNodesInTree controls the maximum number of idle streams to - // retain in the priority tree. Setting this to zero saves a small amount - // of memory at the cost of performance. - // - // See RFC 7540, Section 5.3.4: - // Similarly, streams that are in the "idle" state can be assigned - // priority or become a parent of other streams. This allows for the - // creation of a grouping node in the dependency tree, which enables - // more flexible expressions of priority. Idle streams begin with a - // default priority (Section 5.3.5). - MaxIdleNodesInTree int - - // ThrottleOutOfOrderWrites enables write throttling to help ensure that - // data is delivered in priority order. This works around a race where - // stream B depends on stream A and both streams are about to call Write - // to queue DATA frames. If B wins the race, a naive scheduler would eagerly - // write as much data from B as possible, but this is suboptimal because A - // is a higher-priority stream. With throttling enabled, we write a small - // amount of data from B to minimize the amount of bandwidth that B can - // steal from A. - ThrottleOutOfOrderWrites bool -} - -// NewPriorityWriteScheduler constructs a WriteScheduler that schedules -// frames by following HTTP/2 priorities as described in RFC 7340 Section 5.3. -// If cfg is nil, default options are used. -func NewPriorityWriteScheduler(cfg *PriorityWriteSchedulerConfig) WriteScheduler { - if cfg == nil { - // For justification of these defaults, see: - // https://docs.google.com/document/d/1oLhNg1skaWD4_DtaoCxdSRN5erEXrH-KnLrMwEpOtFY - cfg = &PriorityWriteSchedulerConfig{ - MaxClosedNodesInTree: 10, - MaxIdleNodesInTree: 10, - ThrottleOutOfOrderWrites: false, - } - } - - ws := &priorityWriteScheduler{ - nodes: make(map[uint32]*priorityNode), - maxClosedNodesInTree: cfg.MaxClosedNodesInTree, - maxIdleNodesInTree: cfg.MaxIdleNodesInTree, - enableWriteThrottle: cfg.ThrottleOutOfOrderWrites, - } - ws.nodes[0] = &ws.root - if cfg.ThrottleOutOfOrderWrites { - ws.writeThrottleLimit = 1024 - } else { - ws.writeThrottleLimit = math.MaxInt32 - } - return ws -} - -type priorityNodeState int - -const ( - priorityNodeOpen priorityNodeState = iota - priorityNodeClosed - priorityNodeIdle -) - -// priorityNode is a node in an HTTP/2 priority tree. -// Each node is associated with a single stream ID. -// See RFC 7540, Section 5.3. -type priorityNode struct { - q writeQueue // queue of pending frames to write - id uint32 // id of the stream, or 0 for the root of the tree - weight uint8 // the actual weight is weight+1, so the value is in [1,256] - state priorityNodeState // open | closed | idle - bytes int64 // number of bytes written by this node, or 0 if closed - subtreeBytes int64 // sum(node.bytes) of all nodes in this subtree - - // These links form the priority tree. - parent *priorityNode - kids *priorityNode // start of the kids list - prev, next *priorityNode // doubly-linked list of siblings -} - -func (n *priorityNode) setParent(parent *priorityNode) { - if n == parent { - panic("setParent to self") - } - if n.parent == parent { - return - } - // Unlink from current parent. - if parent := n.parent; parent != nil { - if n.prev == nil { - parent.kids = n.next - } else { - n.prev.next = n.next - } - if n.next != nil { - n.next.prev = n.prev - } - } - // Link to new parent. - // If parent=nil, remove n from the tree. - // Always insert at the head of parent.kids (this is assumed by walkReadyInOrder). - n.parent = parent - if parent == nil { - n.next = nil - n.prev = nil - } else { - n.next = parent.kids - n.prev = nil - if n.next != nil { - n.next.prev = n - } - parent.kids = n - } -} - -func (n *priorityNode) addBytes(b int64) { - n.bytes += b - for ; n != nil; n = n.parent { - n.subtreeBytes += b - } -} - -// walkReadyInOrder iterates over the tree in priority order, calling f for each node -// with a non-empty write queue. When f returns true, this funcion returns true and the -// walk halts. tmp is used as scratch space for sorting. -// -// f(n, openParent) takes two arguments: the node to visit, n, and a bool that is true -// if any ancestor p of n is still open (ignoring the root node). -func (n *priorityNode) walkReadyInOrder(openParent bool, tmp *[]*priorityNode, f func(*priorityNode, bool) bool) bool { - if !n.q.empty() && f(n, openParent) { - return true - } - if n.kids == nil { - return false - } - - // Don't consider the root "open" when updating openParent since - // we can't send data frames on the root stream (only control frames). - if n.id != 0 { - openParent = openParent || (n.state == priorityNodeOpen) - } - - // Common case: only one kid or all kids have the same weight. - // Some clients don't use weights; other clients (like web browsers) - // use mostly-linear priority trees. - w := n.kids.weight - needSort := false - for k := n.kids.next; k != nil; k = k.next { - if k.weight != w { - needSort = true - break - } - } - if !needSort { - for k := n.kids; k != nil; k = k.next { - if k.walkReadyInOrder(openParent, tmp, f) { - return true - } - } - return false - } - - // Uncommon case: sort the child nodes. We remove the kids from the parent, - // then re-insert after sorting so we can reuse tmp for future sort calls. - *tmp = (*tmp)[:0] - for n.kids != nil { - *tmp = append(*tmp, n.kids) - n.kids.setParent(nil) - } - sort.Sort(sortPriorityNodeSiblings(*tmp)) - for i := len(*tmp) - 1; i >= 0; i-- { - (*tmp)[i].setParent(n) // setParent inserts at the head of n.kids - } - for k := n.kids; k != nil; k = k.next { - if k.walkReadyInOrder(openParent, tmp, f) { - return true - } - } - return false -} - -type sortPriorityNodeSiblings []*priorityNode - -func (z sortPriorityNodeSiblings) Len() int { return len(z) } -func (z sortPriorityNodeSiblings) Swap(i, k int) { z[i], z[k] = z[k], z[i] } -func (z sortPriorityNodeSiblings) Less(i, k int) bool { - // Prefer the subtree that has sent fewer bytes relative to its weight. - // See sections 5.3.2 and 5.3.4. - wi, bi := float64(z[i].weight+1), float64(z[i].subtreeBytes) - wk, bk := float64(z[k].weight+1), float64(z[k].subtreeBytes) - if bi == 0 && bk == 0 { - return wi >= wk - } - if bk == 0 { - return false - } - return bi/bk <= wi/wk -} - -type priorityWriteScheduler struct { - // root is the root of the priority tree, where root.id = 0. - // The root queues control frames that are not associated with any stream. - root priorityNode - - // nodes maps stream ids to priority tree nodes. - nodes map[uint32]*priorityNode - - // maxID is the maximum stream id in nodes. - maxID uint32 - - // lists of nodes that have been closed or are idle, but are kept in - // the tree for improved prioritization. When the lengths exceed either - // maxClosedNodesInTree or maxIdleNodesInTree, old nodes are discarded. - closedNodes, idleNodes []*priorityNode - - // From the config. - maxClosedNodesInTree int - maxIdleNodesInTree int - writeThrottleLimit int32 - enableWriteThrottle bool - - // tmp is scratch space for priorityNode.walkReadyInOrder to reduce allocations. - tmp []*priorityNode - - // pool of empty queues for reuse. - queuePool writeQueuePool -} - -func (ws *priorityWriteScheduler) OpenStream(streamID uint32, options OpenStreamOptions) { - // The stream may be currently idle but cannot be opened or closed. - if curr := ws.nodes[streamID]; curr != nil { - if curr.state != priorityNodeIdle { - panic(fmt.Sprintf("stream %d already opened", streamID)) - } - curr.state = priorityNodeOpen - return - } - - // RFC 7540, Section 5.3.5: - // "All streams are initially assigned a non-exclusive dependency on stream 0x0. - // Pushed streams initially depend on their associated stream. In both cases, - // streams are assigned a default weight of 16." - parent := ws.nodes[options.PusherID] - if parent == nil { - parent = &ws.root - } - n := &priorityNode{ - q: *ws.queuePool.get(), - id: streamID, - weight: priorityDefaultWeight, - state: priorityNodeOpen, - } - n.setParent(parent) - ws.nodes[streamID] = n - if streamID > ws.maxID { - ws.maxID = streamID - } -} - -func (ws *priorityWriteScheduler) CloseStream(streamID uint32) { - if streamID == 0 { - panic("violation of WriteScheduler interface: cannot close stream 0") - } - if ws.nodes[streamID] == nil { - panic(fmt.Sprintf("violation of WriteScheduler interface: unknown stream %d", streamID)) - } - if ws.nodes[streamID].state != priorityNodeOpen { - panic(fmt.Sprintf("violation of WriteScheduler interface: stream %d already closed", streamID)) - } - - n := ws.nodes[streamID] - n.state = priorityNodeClosed - n.addBytes(-n.bytes) - - q := n.q - ws.queuePool.put(&q) - n.q.s = nil - if ws.maxClosedNodesInTree > 0 { - ws.addClosedOrIdleNode(&ws.closedNodes, ws.maxClosedNodesInTree, n) - } else { - ws.removeNode(n) - } -} - -func (ws *priorityWriteScheduler) AdjustStream(streamID uint32, priority PriorityParam) { - if streamID == 0 { - panic("adjustPriority on root") - } - - // If streamID does not exist, there are two cases: - // - A closed stream that has been removed (this will have ID <= maxID) - // - An idle stream that is being used for "grouping" (this will have ID > maxID) - n := ws.nodes[streamID] - if n == nil { - if streamID <= ws.maxID || ws.maxIdleNodesInTree == 0 { - return - } - ws.maxID = streamID - n = &priorityNode{ - q: *ws.queuePool.get(), - id: streamID, - weight: priorityDefaultWeight, - state: priorityNodeIdle, - } - n.setParent(&ws.root) - ws.nodes[streamID] = n - ws.addClosedOrIdleNode(&ws.idleNodes, ws.maxIdleNodesInTree, n) - } - - // Section 5.3.1: A dependency on a stream that is not currently in the tree - // results in that stream being given a default priority (Section 5.3.5). - parent := ws.nodes[priority.StreamDep] - if parent == nil { - n.setParent(&ws.root) - n.weight = priorityDefaultWeight - return - } - - // Ignore if the client tries to make a node its own parent. - if n == parent { - return - } - - // Section 5.3.3: - // "If a stream is made dependent on one of its own dependencies, the - // formerly dependent stream is first moved to be dependent on the - // reprioritized stream's previous parent. The moved dependency retains - // its weight." - // - // That is: if parent depends on n, move parent to depend on n.parent. - for x := parent.parent; x != nil; x = x.parent { - if x == n { - parent.setParent(n.parent) - break - } - } - - // Section 5.3.3: The exclusive flag causes the stream to become the sole - // dependency of its parent stream, causing other dependencies to become - // dependent on the exclusive stream. - if priority.Exclusive { - k := parent.kids - for k != nil { - next := k.next - if k != n { - k.setParent(n) - } - k = next - } - } - - n.setParent(parent) - n.weight = priority.Weight -} - -func (ws *priorityWriteScheduler) Push(wr FrameWriteRequest) { - var n *priorityNode - if id := wr.StreamID(); id == 0 { - n = &ws.root - } else { - n = ws.nodes[id] - if n == nil { - // id is an idle or closed stream. wr should not be a HEADERS or - // DATA frame. However, wr can be a RST_STREAM. In this case, we - // push wr onto the root, rather than creating a new priorityNode, - // since RST_STREAM is tiny and the stream's priority is unknown - // anyway. See issue #17919. - if wr.DataSize() > 0 { - panic("add DATA on non-open stream") - } - n = &ws.root - } - } - n.q.push(wr) -} - -func (ws *priorityWriteScheduler) Pop() (wr FrameWriteRequest, ok bool) { - ws.root.walkReadyInOrder(false, &ws.tmp, func(n *priorityNode, openParent bool) bool { - limit := int32(math.MaxInt32) - if openParent { - limit = ws.writeThrottleLimit - } - wr, ok = n.q.consume(limit) - if !ok { - return false - } - n.addBytes(int64(wr.DataSize())) - // If B depends on A and B continuously has data available but A - // does not, gradually increase the throttling limit to allow B to - // steal more and more bandwidth from A. - if openParent { - ws.writeThrottleLimit += 1024 - if ws.writeThrottleLimit < 0 { - ws.writeThrottleLimit = math.MaxInt32 - } - } else if ws.enableWriteThrottle { - ws.writeThrottleLimit = 1024 - } - return true - }) - return wr, ok -} - -func (ws *priorityWriteScheduler) addClosedOrIdleNode(list *[]*priorityNode, maxSize int, n *priorityNode) { - if maxSize == 0 { - return - } - if len(*list) == maxSize { - // Remove the oldest node, then shift left. - ws.removeNode((*list)[0]) - x := (*list)[1:] - copy(*list, x) - *list = (*list)[:len(x)] - } - *list = append(*list, n) -} - -func (ws *priorityWriteScheduler) removeNode(n *priorityNode) { - for k := n.kids; k != nil; k = k.next { - k.setParent(n.parent) - } - n.setParent(nil) - delete(ws.nodes, n.id) -} diff --git a/vendor/golang.org/x/net/http2/writesched_priority_test.go b/vendor/golang.org/x/net/http2/writesched_priority_test.go deleted file mode 100644 index f2b535a2c..000000000 --- a/vendor/golang.org/x/net/http2/writesched_priority_test.go +++ /dev/null @@ -1,541 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "bytes" - "fmt" - "sort" - "testing" -) - -func defaultPriorityWriteScheduler() *priorityWriteScheduler { - return NewPriorityWriteScheduler(nil).(*priorityWriteScheduler) -} - -func checkPriorityWellFormed(ws *priorityWriteScheduler) error { - for id, n := range ws.nodes { - if id != n.id { - return fmt.Errorf("bad ws.nodes: ws.nodes[%d] = %d", id, n.id) - } - if n.parent == nil { - if n.next != nil || n.prev != nil { - return fmt.Errorf("bad node %d: nil parent but prev/next not nil", id) - } - continue - } - found := false - for k := n.parent.kids; k != nil; k = k.next { - if k.id == id { - found = true - break - } - } - if !found { - return fmt.Errorf("bad node %d: not found in parent %d kids list", id, n.parent.id) - } - } - return nil -} - -func fmtTree(ws *priorityWriteScheduler, fmtNode func(*priorityNode) string) string { - var ids []int - for _, n := range ws.nodes { - ids = append(ids, int(n.id)) - } - sort.Ints(ids) - - var buf bytes.Buffer - for _, id := range ids { - if buf.Len() != 0 { - buf.WriteString(" ") - } - if id == 0 { - buf.WriteString(fmtNode(&ws.root)) - } else { - buf.WriteString(fmtNode(ws.nodes[uint32(id)])) - } - } - return buf.String() -} - -func fmtNodeParentSkipRoot(n *priorityNode) string { - switch { - case n.id == 0: - return "" - case n.parent == nil: - return fmt.Sprintf("%d{parent:nil}", n.id) - default: - return fmt.Sprintf("%d{parent:%d}", n.id, n.parent.id) - } -} - -func fmtNodeWeightParentSkipRoot(n *priorityNode) string { - switch { - case n.id == 0: - return "" - case n.parent == nil: - return fmt.Sprintf("%d{weight:%d,parent:nil}", n.id, n.weight) - default: - return fmt.Sprintf("%d{weight:%d,parent:%d}", n.id, n.weight, n.parent.id) - } -} - -func TestPriorityTwoStreams(t *testing.T) { - ws := defaultPriorityWriteScheduler() - ws.OpenStream(1, OpenStreamOptions{}) - ws.OpenStream(2, OpenStreamOptions{}) - - want := "1{weight:15,parent:0} 2{weight:15,parent:0}" - if got := fmtTree(ws, fmtNodeWeightParentSkipRoot); got != want { - t.Errorf("After open\ngot %q\nwant %q", got, want) - } - - // Move 1's parent to 2. - ws.AdjustStream(1, PriorityParam{ - StreamDep: 2, - Weight: 32, - Exclusive: false, - }) - want = "1{weight:32,parent:2} 2{weight:15,parent:0}" - if got := fmtTree(ws, fmtNodeWeightParentSkipRoot); got != want { - t.Errorf("After adjust\ngot %q\nwant %q", got, want) - } - - if err := checkPriorityWellFormed(ws); err != nil { - t.Error(err) - } -} - -func TestPriorityAdjustExclusiveZero(t *testing.T) { - // 1, 2, and 3 are all children of the 0 stream. - // Exclusive reprioritization to any of the streams should bring - // the rest of the streams under the reprioritized stream. - ws := defaultPriorityWriteScheduler() - ws.OpenStream(1, OpenStreamOptions{}) - ws.OpenStream(2, OpenStreamOptions{}) - ws.OpenStream(3, OpenStreamOptions{}) - - want := "1{weight:15,parent:0} 2{weight:15,parent:0} 3{weight:15,parent:0}" - if got := fmtTree(ws, fmtNodeWeightParentSkipRoot); got != want { - t.Errorf("After open\ngot %q\nwant %q", got, want) - } - - ws.AdjustStream(2, PriorityParam{ - StreamDep: 0, - Weight: 20, - Exclusive: true, - }) - want = "1{weight:15,parent:2} 2{weight:20,parent:0} 3{weight:15,parent:2}" - if got := fmtTree(ws, fmtNodeWeightParentSkipRoot); got != want { - t.Errorf("After adjust\ngot %q\nwant %q", got, want) - } - - if err := checkPriorityWellFormed(ws); err != nil { - t.Error(err) - } -} - -func TestPriorityAdjustOwnParent(t *testing.T) { - // Assigning a node as its own parent should have no effect. - ws := defaultPriorityWriteScheduler() - ws.OpenStream(1, OpenStreamOptions{}) - ws.OpenStream(2, OpenStreamOptions{}) - ws.AdjustStream(2, PriorityParam{ - StreamDep: 2, - Weight: 20, - Exclusive: true, - }) - want := "1{weight:15,parent:0} 2{weight:15,parent:0}" - if got := fmtTree(ws, fmtNodeWeightParentSkipRoot); got != want { - t.Errorf("After adjust\ngot %q\nwant %q", got, want) - } - if err := checkPriorityWellFormed(ws); err != nil { - t.Error(err) - } -} - -func TestPriorityClosedStreams(t *testing.T) { - ws := NewPriorityWriteScheduler(&PriorityWriteSchedulerConfig{MaxClosedNodesInTree: 2}).(*priorityWriteScheduler) - ws.OpenStream(1, OpenStreamOptions{}) - ws.OpenStream(2, OpenStreamOptions{PusherID: 1}) - ws.OpenStream(3, OpenStreamOptions{PusherID: 2}) - ws.OpenStream(4, OpenStreamOptions{PusherID: 3}) - - // Close the first three streams. We lose 1, but keep 2 and 3. - ws.CloseStream(1) - ws.CloseStream(2) - ws.CloseStream(3) - - want := "2{weight:15,parent:0} 3{weight:15,parent:2} 4{weight:15,parent:3}" - if got := fmtTree(ws, fmtNodeWeightParentSkipRoot); got != want { - t.Errorf("After close\ngot %q\nwant %q", got, want) - } - if err := checkPriorityWellFormed(ws); err != nil { - t.Error(err) - } - - // Adding a stream as an exclusive child of 1 gives it default - // priorities, since 1 is gone. - ws.OpenStream(5, OpenStreamOptions{}) - ws.AdjustStream(5, PriorityParam{StreamDep: 1, Weight: 15, Exclusive: true}) - - // Adding a stream as an exclusive child of 2 should work, since 2 is not gone. - ws.OpenStream(6, OpenStreamOptions{}) - ws.AdjustStream(6, PriorityParam{StreamDep: 2, Weight: 15, Exclusive: true}) - - want = "2{weight:15,parent:0} 3{weight:15,parent:6} 4{weight:15,parent:3} 5{weight:15,parent:0} 6{weight:15,parent:2}" - if got := fmtTree(ws, fmtNodeWeightParentSkipRoot); got != want { - t.Errorf("After add streams\ngot %q\nwant %q", got, want) - } - if err := checkPriorityWellFormed(ws); err != nil { - t.Error(err) - } -} - -func TestPriorityClosedStreamsDisabled(t *testing.T) { - ws := NewPriorityWriteScheduler(&PriorityWriteSchedulerConfig{}).(*priorityWriteScheduler) - ws.OpenStream(1, OpenStreamOptions{}) - ws.OpenStream(2, OpenStreamOptions{PusherID: 1}) - ws.OpenStream(3, OpenStreamOptions{PusherID: 2}) - - // Close the first two streams. We keep only 3. - ws.CloseStream(1) - ws.CloseStream(2) - - want := "3{weight:15,parent:0}" - if got := fmtTree(ws, fmtNodeWeightParentSkipRoot); got != want { - t.Errorf("After close\ngot %q\nwant %q", got, want) - } - if err := checkPriorityWellFormed(ws); err != nil { - t.Error(err) - } -} - -func TestPriorityIdleStreams(t *testing.T) { - ws := NewPriorityWriteScheduler(&PriorityWriteSchedulerConfig{MaxIdleNodesInTree: 2}).(*priorityWriteScheduler) - ws.AdjustStream(1, PriorityParam{StreamDep: 0, Weight: 15}) // idle - ws.AdjustStream(2, PriorityParam{StreamDep: 0, Weight: 15}) // idle - ws.AdjustStream(3, PriorityParam{StreamDep: 2, Weight: 20}) // idle - ws.OpenStream(4, OpenStreamOptions{}) - ws.OpenStream(5, OpenStreamOptions{}) - ws.OpenStream(6, OpenStreamOptions{}) - ws.AdjustStream(4, PriorityParam{StreamDep: 1, Weight: 15}) - ws.AdjustStream(5, PriorityParam{StreamDep: 2, Weight: 15}) - ws.AdjustStream(6, PriorityParam{StreamDep: 3, Weight: 15}) - - want := "2{weight:15,parent:0} 3{weight:20,parent:2} 4{weight:15,parent:0} 5{weight:15,parent:2} 6{weight:15,parent:3}" - if got := fmtTree(ws, fmtNodeWeightParentSkipRoot); got != want { - t.Errorf("After open\ngot %q\nwant %q", got, want) - } - if err := checkPriorityWellFormed(ws); err != nil { - t.Error(err) - } -} - -func TestPriorityIdleStreamsDisabled(t *testing.T) { - ws := NewPriorityWriteScheduler(&PriorityWriteSchedulerConfig{}).(*priorityWriteScheduler) - ws.AdjustStream(1, PriorityParam{StreamDep: 0, Weight: 15}) // idle - ws.AdjustStream(2, PriorityParam{StreamDep: 0, Weight: 15}) // idle - ws.AdjustStream(3, PriorityParam{StreamDep: 2, Weight: 20}) // idle - ws.OpenStream(4, OpenStreamOptions{}) - - want := "4{weight:15,parent:0}" - if got := fmtTree(ws, fmtNodeWeightParentSkipRoot); got != want { - t.Errorf("After open\ngot %q\nwant %q", got, want) - } - if err := checkPriorityWellFormed(ws); err != nil { - t.Error(err) - } -} - -func TestPrioritySection531NonExclusive(t *testing.T) { - // Example from RFC 7540 Section 5.3.1. - // A,B,C,D = 1,2,3,4 - ws := defaultPriorityWriteScheduler() - ws.OpenStream(1, OpenStreamOptions{}) - ws.OpenStream(2, OpenStreamOptions{PusherID: 1}) - ws.OpenStream(3, OpenStreamOptions{PusherID: 1}) - ws.OpenStream(4, OpenStreamOptions{}) - ws.AdjustStream(4, PriorityParam{ - StreamDep: 1, - Weight: 15, - Exclusive: false, - }) - want := "1{parent:0} 2{parent:1} 3{parent:1} 4{parent:1}" - if got := fmtTree(ws, fmtNodeParentSkipRoot); got != want { - t.Errorf("After adjust\ngot %q\nwant %q", got, want) - } - if err := checkPriorityWellFormed(ws); err != nil { - t.Error(err) - } -} - -func TestPrioritySection531Exclusive(t *testing.T) { - // Example from RFC 7540 Section 5.3.1. - // A,B,C,D = 1,2,3,4 - ws := defaultPriorityWriteScheduler() - ws.OpenStream(1, OpenStreamOptions{}) - ws.OpenStream(2, OpenStreamOptions{PusherID: 1}) - ws.OpenStream(3, OpenStreamOptions{PusherID: 1}) - ws.OpenStream(4, OpenStreamOptions{}) - ws.AdjustStream(4, PriorityParam{ - StreamDep: 1, - Weight: 15, - Exclusive: true, - }) - want := "1{parent:0} 2{parent:4} 3{parent:4} 4{parent:1}" - if got := fmtTree(ws, fmtNodeParentSkipRoot); got != want { - t.Errorf("After adjust\ngot %q\nwant %q", got, want) - } - if err := checkPriorityWellFormed(ws); err != nil { - t.Error(err) - } -} - -func makeSection533Tree() *priorityWriteScheduler { - // Initial tree from RFC 7540 Section 5.3.3. - // A,B,C,D,E,F = 1,2,3,4,5,6 - ws := defaultPriorityWriteScheduler() - ws.OpenStream(1, OpenStreamOptions{}) - ws.OpenStream(2, OpenStreamOptions{PusherID: 1}) - ws.OpenStream(3, OpenStreamOptions{PusherID: 1}) - ws.OpenStream(4, OpenStreamOptions{PusherID: 3}) - ws.OpenStream(5, OpenStreamOptions{PusherID: 3}) - ws.OpenStream(6, OpenStreamOptions{PusherID: 4}) - return ws -} - -func TestPrioritySection533NonExclusive(t *testing.T) { - // Example from RFC 7540 Section 5.3.3. - // A,B,C,D,E,F = 1,2,3,4,5,6 - ws := defaultPriorityWriteScheduler() - ws.OpenStream(1, OpenStreamOptions{}) - ws.OpenStream(2, OpenStreamOptions{PusherID: 1}) - ws.OpenStream(3, OpenStreamOptions{PusherID: 1}) - ws.OpenStream(4, OpenStreamOptions{PusherID: 3}) - ws.OpenStream(5, OpenStreamOptions{PusherID: 3}) - ws.OpenStream(6, OpenStreamOptions{PusherID: 4}) - ws.AdjustStream(1, PriorityParam{ - StreamDep: 4, - Weight: 15, - Exclusive: false, - }) - want := "1{parent:4} 2{parent:1} 3{parent:1} 4{parent:0} 5{parent:3} 6{parent:4}" - if got := fmtTree(ws, fmtNodeParentSkipRoot); got != want { - t.Errorf("After adjust\ngot %q\nwant %q", got, want) - } - if err := checkPriorityWellFormed(ws); err != nil { - t.Error(err) - } -} - -func TestPrioritySection533Exclusive(t *testing.T) { - // Example from RFC 7540 Section 5.3.3. - // A,B,C,D,E,F = 1,2,3,4,5,6 - ws := defaultPriorityWriteScheduler() - ws.OpenStream(1, OpenStreamOptions{}) - ws.OpenStream(2, OpenStreamOptions{PusherID: 1}) - ws.OpenStream(3, OpenStreamOptions{PusherID: 1}) - ws.OpenStream(4, OpenStreamOptions{PusherID: 3}) - ws.OpenStream(5, OpenStreamOptions{PusherID: 3}) - ws.OpenStream(6, OpenStreamOptions{PusherID: 4}) - ws.AdjustStream(1, PriorityParam{ - StreamDep: 4, - Weight: 15, - Exclusive: true, - }) - want := "1{parent:4} 2{parent:1} 3{parent:1} 4{parent:0} 5{parent:3} 6{parent:1}" - if got := fmtTree(ws, fmtNodeParentSkipRoot); got != want { - t.Errorf("After adjust\ngot %q\nwant %q", got, want) - } - if err := checkPriorityWellFormed(ws); err != nil { - t.Error(err) - } -} - -func checkPopAll(ws WriteScheduler, order []uint32) error { - for k, id := range order { - wr, ok := ws.Pop() - if !ok { - return fmt.Errorf("Pop[%d]: got ok=false, want %d (order=%v)", k, id, order) - } - if got := wr.StreamID(); got != id { - return fmt.Errorf("Pop[%d]: got %v, want %d (order=%v)", k, got, id, order) - } - } - wr, ok := ws.Pop() - if ok { - return fmt.Errorf("Pop[%d]: got %v, want ok=false (order=%v)", len(order), wr.StreamID(), order) - } - return nil -} - -func TestPriorityPopFrom533Tree(t *testing.T) { - ws := makeSection533Tree() - - ws.Push(makeWriteHeadersRequest(3 /*C*/)) - ws.Push(makeWriteNonStreamRequest()) - ws.Push(makeWriteHeadersRequest(5 /*E*/)) - ws.Push(makeWriteHeadersRequest(1 /*A*/)) - t.Log("tree:", fmtTree(ws, fmtNodeParentSkipRoot)) - - if err := checkPopAll(ws, []uint32{0 /*NonStream*/, 1, 3, 5}); err != nil { - t.Error(err) - } -} - -func TestPriorityPopFromLinearTree(t *testing.T) { - ws := defaultPriorityWriteScheduler() - ws.OpenStream(1, OpenStreamOptions{}) - ws.OpenStream(2, OpenStreamOptions{PusherID: 1}) - ws.OpenStream(3, OpenStreamOptions{PusherID: 2}) - ws.OpenStream(4, OpenStreamOptions{PusherID: 3}) - - ws.Push(makeWriteHeadersRequest(3)) - ws.Push(makeWriteHeadersRequest(4)) - ws.Push(makeWriteHeadersRequest(1)) - ws.Push(makeWriteHeadersRequest(2)) - ws.Push(makeWriteNonStreamRequest()) - ws.Push(makeWriteNonStreamRequest()) - t.Log("tree:", fmtTree(ws, fmtNodeParentSkipRoot)) - - if err := checkPopAll(ws, []uint32{0, 0 /*NonStreams*/, 1, 2, 3, 4}); err != nil { - t.Error(err) - } -} - -func TestPriorityFlowControl(t *testing.T) { - ws := NewPriorityWriteScheduler(&PriorityWriteSchedulerConfig{ThrottleOutOfOrderWrites: false}) - ws.OpenStream(1, OpenStreamOptions{}) - ws.OpenStream(2, OpenStreamOptions{PusherID: 1}) - - sc := &serverConn{maxFrameSize: 16} - st1 := &stream{id: 1, sc: sc} - st2 := &stream{id: 2, sc: sc} - - ws.Push(FrameWriteRequest{&writeData{1, make([]byte, 16), false}, st1, nil}) - ws.Push(FrameWriteRequest{&writeData{2, make([]byte, 16), false}, st2, nil}) - ws.AdjustStream(2, PriorityParam{StreamDep: 1}) - - // No flow-control bytes available. - if wr, ok := ws.Pop(); ok { - t.Fatalf("Pop(limited by flow control)=%v,true, want false", wr) - } - - // Add enough flow-control bytes to write st2 in two Pop calls. - // Should write data from st2 even though it's lower priority than st1. - for i := 1; i <= 2; i++ { - st2.flow.add(8) - wr, ok := ws.Pop() - if !ok { - t.Fatalf("Pop(%d)=false, want true", i) - } - if got, want := wr.DataSize(), 8; got != want { - t.Fatalf("Pop(%d)=%d bytes, want %d bytes", i, got, want) - } - } -} - -func TestPriorityThrottleOutOfOrderWrites(t *testing.T) { - ws := NewPriorityWriteScheduler(&PriorityWriteSchedulerConfig{ThrottleOutOfOrderWrites: true}) - ws.OpenStream(1, OpenStreamOptions{}) - ws.OpenStream(2, OpenStreamOptions{PusherID: 1}) - - sc := &serverConn{maxFrameSize: 4096} - st1 := &stream{id: 1, sc: sc} - st2 := &stream{id: 2, sc: sc} - st1.flow.add(4096) - st2.flow.add(4096) - ws.Push(FrameWriteRequest{&writeData{2, make([]byte, 4096), false}, st2, nil}) - ws.AdjustStream(2, PriorityParam{StreamDep: 1}) - - // We have enough flow-control bytes to write st2 in a single Pop call. - // However, due to out-of-order write throttling, the first call should - // only write 1KB. - wr, ok := ws.Pop() - if !ok { - t.Fatalf("Pop(st2.first)=false, want true") - } - if got, want := wr.StreamID(), uint32(2); got != want { - t.Fatalf("Pop(st2.first)=stream %d, want stream %d", got, want) - } - if got, want := wr.DataSize(), 1024; got != want { - t.Fatalf("Pop(st2.first)=%d bytes, want %d bytes", got, want) - } - - // Now add data on st1. This should take precedence. - ws.Push(FrameWriteRequest{&writeData{1, make([]byte, 4096), false}, st1, nil}) - wr, ok = ws.Pop() - if !ok { - t.Fatalf("Pop(st1)=false, want true") - } - if got, want := wr.StreamID(), uint32(1); got != want { - t.Fatalf("Pop(st1)=stream %d, want stream %d", got, want) - } - if got, want := wr.DataSize(), 4096; got != want { - t.Fatalf("Pop(st1)=%d bytes, want %d bytes", got, want) - } - - // Should go back to writing 1KB from st2. - wr, ok = ws.Pop() - if !ok { - t.Fatalf("Pop(st2.last)=false, want true") - } - if got, want := wr.StreamID(), uint32(2); got != want { - t.Fatalf("Pop(st2.last)=stream %d, want stream %d", got, want) - } - if got, want := wr.DataSize(), 1024; got != want { - t.Fatalf("Pop(st2.last)=%d bytes, want %d bytes", got, want) - } -} - -func TestPriorityWeights(t *testing.T) { - ws := defaultPriorityWriteScheduler() - ws.OpenStream(1, OpenStreamOptions{}) - ws.OpenStream(2, OpenStreamOptions{}) - - sc := &serverConn{maxFrameSize: 8} - st1 := &stream{id: 1, sc: sc} - st2 := &stream{id: 2, sc: sc} - st1.flow.add(40) - st2.flow.add(40) - - ws.Push(FrameWriteRequest{&writeData{1, make([]byte, 40), false}, st1, nil}) - ws.Push(FrameWriteRequest{&writeData{2, make([]byte, 40), false}, st2, nil}) - ws.AdjustStream(1, PriorityParam{StreamDep: 0, Weight: 34}) - ws.AdjustStream(2, PriorityParam{StreamDep: 0, Weight: 9}) - - // st1 gets 3.5x the bandwidth of st2 (3.5 = (34+1)/(9+1)). - // The maximum frame size is 8 bytes. The write sequence should be: - // st1, total bytes so far is (st1=8, st=0) - // st2, total bytes so far is (st1=8, st=8) - // st1, total bytes so far is (st1=16, st=8) - // st1, total bytes so far is (st1=24, st=8) // 3x bandwidth - // st1, total bytes so far is (st1=32, st=8) // 4x bandwidth - // st2, total bytes so far is (st1=32, st=16) // 2x bandwidth - // st1, total bytes so far is (st1=40, st=16) - // st2, total bytes so far is (st1=40, st=24) - // st2, total bytes so far is (st1=40, st=32) - // st2, total bytes so far is (st1=40, st=40) - if err := checkPopAll(ws, []uint32{1, 2, 1, 1, 1, 2, 1, 2, 2, 2}); err != nil { - t.Error(err) - } -} - -func TestPriorityRstStreamOnNonOpenStreams(t *testing.T) { - ws := NewPriorityWriteScheduler(&PriorityWriteSchedulerConfig{ - MaxClosedNodesInTree: 0, - MaxIdleNodesInTree: 0, - }) - ws.OpenStream(1, OpenStreamOptions{}) - ws.CloseStream(1) - ws.Push(FrameWriteRequest{write: streamError(1, ErrCodeProtocol)}) - ws.Push(FrameWriteRequest{write: streamError(2, ErrCodeProtocol)}) - - if err := checkPopAll(ws, []uint32{1, 2}); err != nil { - t.Error(err) - } -} diff --git a/vendor/golang.org/x/net/http2/writesched_random.go b/vendor/golang.org/x/net/http2/writesched_random.go deleted file mode 100644 index 36d7919f1..000000000 --- a/vendor/golang.org/x/net/http2/writesched_random.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import "math" - -// NewRandomWriteScheduler constructs a WriteScheduler that ignores HTTP/2 -// priorities. Control frames like SETTINGS and PING are written before DATA -// frames, but if no control frames are queued and multiple streams have queued -// HEADERS or DATA frames, Pop selects a ready stream arbitrarily. -func NewRandomWriteScheduler() WriteScheduler { - return &randomWriteScheduler{sq: make(map[uint32]*writeQueue)} -} - -type randomWriteScheduler struct { - // zero are frames not associated with a specific stream. - zero writeQueue - - // sq contains the stream-specific queues, keyed by stream ID. - // When a stream is idle or closed, it's deleted from the map. - sq map[uint32]*writeQueue - - // pool of empty queues for reuse. - queuePool writeQueuePool -} - -func (ws *randomWriteScheduler) OpenStream(streamID uint32, options OpenStreamOptions) { - // no-op: idle streams are not tracked -} - -func (ws *randomWriteScheduler) CloseStream(streamID uint32) { - q, ok := ws.sq[streamID] - if !ok { - return - } - delete(ws.sq, streamID) - ws.queuePool.put(q) -} - -func (ws *randomWriteScheduler) AdjustStream(streamID uint32, priority PriorityParam) { - // no-op: priorities are ignored -} - -func (ws *randomWriteScheduler) Push(wr FrameWriteRequest) { - id := wr.StreamID() - if id == 0 { - ws.zero.push(wr) - return - } - q, ok := ws.sq[id] - if !ok { - q = ws.queuePool.get() - ws.sq[id] = q - } - q.push(wr) -} - -func (ws *randomWriteScheduler) Pop() (FrameWriteRequest, bool) { - // Control frames first. - if !ws.zero.empty() { - return ws.zero.shift(), true - } - // Iterate over all non-idle streams until finding one that can be consumed. - for _, q := range ws.sq { - if wr, ok := q.consume(math.MaxInt32); ok { - return wr, true - } - } - return FrameWriteRequest{}, false -} diff --git a/vendor/golang.org/x/net/http2/writesched_random_test.go b/vendor/golang.org/x/net/http2/writesched_random_test.go deleted file mode 100644 index 3bf4aa36a..000000000 --- a/vendor/golang.org/x/net/http2/writesched_random_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import "testing" - -func TestRandomScheduler(t *testing.T) { - ws := NewRandomWriteScheduler() - ws.Push(makeWriteHeadersRequest(3)) - ws.Push(makeWriteHeadersRequest(4)) - ws.Push(makeWriteHeadersRequest(1)) - ws.Push(makeWriteHeadersRequest(2)) - ws.Push(makeWriteNonStreamRequest()) - ws.Push(makeWriteNonStreamRequest()) - - // Pop all frames. Should get the non-stream requests first, - // followed by the stream requests in any order. - var order []FrameWriteRequest - for { - wr, ok := ws.Pop() - if !ok { - break - } - order = append(order, wr) - } - t.Logf("got frames: %v", order) - if len(order) != 6 { - t.Fatalf("got %d frames, expected 6", len(order)) - } - if order[0].StreamID() != 0 || order[1].StreamID() != 0 { - t.Fatal("expected non-stream frames first", order[0], order[1]) - } - got := make(map[uint32]bool) - for _, wr := range order[2:] { - got[wr.StreamID()] = true - } - for id := uint32(1); id <= 4; id++ { - if !got[id] { - t.Errorf("frame not found for stream %d", id) - } - } -} diff --git a/vendor/golang.org/x/net/http2/writesched_test.go b/vendor/golang.org/x/net/http2/writesched_test.go deleted file mode 100644 index 0807056bc..000000000 --- a/vendor/golang.org/x/net/http2/writesched_test.go +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "fmt" - "math" - "reflect" - "testing" -) - -func makeWriteNonStreamRequest() FrameWriteRequest { - return FrameWriteRequest{writeSettingsAck{}, nil, nil} -} - -func makeWriteHeadersRequest(streamID uint32) FrameWriteRequest { - st := &stream{id: streamID} - return FrameWriteRequest{&writeResHeaders{streamID: streamID, httpResCode: 200}, st, nil} -} - -func checkConsume(wr FrameWriteRequest, nbytes int32, want []FrameWriteRequest) error { - consumed, rest, n := wr.Consume(nbytes) - var wantConsumed, wantRest FrameWriteRequest - switch len(want) { - case 0: - case 1: - wantConsumed = want[0] - case 2: - wantConsumed = want[0] - wantRest = want[1] - } - if !reflect.DeepEqual(consumed, wantConsumed) || !reflect.DeepEqual(rest, wantRest) || n != len(want) { - return fmt.Errorf("got %v, %v, %v\nwant %v, %v, %v", consumed, rest, n, wantConsumed, wantRest, len(want)) - } - return nil -} - -func TestFrameWriteRequestNonData(t *testing.T) { - wr := makeWriteNonStreamRequest() - if got, want := wr.DataSize(), 0; got != want { - t.Errorf("DataSize: got %v, want %v", got, want) - } - - // Non-DATA frames are always consumed whole. - if err := checkConsume(wr, 0, []FrameWriteRequest{wr}); err != nil { - t.Errorf("Consume:\n%v", err) - } -} - -func TestFrameWriteRequestData(t *testing.T) { - st := &stream{ - id: 1, - sc: &serverConn{maxFrameSize: 16}, - } - const size = 32 - wr := FrameWriteRequest{&writeData{st.id, make([]byte, size), true}, st, make(chan error)} - if got, want := wr.DataSize(), size; got != want { - t.Errorf("DataSize: got %v, want %v", got, want) - } - - // No flow-control bytes available: cannot consume anything. - if err := checkConsume(wr, math.MaxInt32, []FrameWriteRequest{}); err != nil { - t.Errorf("Consume(limited by flow control):\n%v", err) - } - - // Add enough flow-control bytes to consume the entire frame, - // but we're now restricted by st.sc.maxFrameSize. - st.flow.add(size) - want := []FrameWriteRequest{ - { - write: &writeData{st.id, make([]byte, st.sc.maxFrameSize), false}, - stream: st, - done: nil, - }, - { - write: &writeData{st.id, make([]byte, size-st.sc.maxFrameSize), true}, - stream: st, - done: wr.done, - }, - } - if err := checkConsume(wr, math.MaxInt32, want); err != nil { - t.Errorf("Consume(limited by maxFrameSize):\n%v", err) - } - rest := want[1] - - // Consume 8 bytes from the remaining frame. - want = []FrameWriteRequest{ - { - write: &writeData{st.id, make([]byte, 8), false}, - stream: st, - done: nil, - }, - { - write: &writeData{st.id, make([]byte, size-st.sc.maxFrameSize-8), true}, - stream: st, - done: wr.done, - }, - } - if err := checkConsume(rest, 8, want); err != nil { - t.Errorf("Consume(8):\n%v", err) - } - rest = want[1] - - // Consume all remaining bytes. - want = []FrameWriteRequest{ - { - write: &writeData{st.id, make([]byte, size-st.sc.maxFrameSize-8), true}, - stream: st, - done: wr.done, - }, - } - if err := checkConsume(rest, math.MaxInt32, want); err != nil { - t.Errorf("Consume(remainder):\n%v", err) - } -} - -func TestFrameWriteRequest_StreamID(t *testing.T) { - const streamID = 123 - wr := FrameWriteRequest{write: streamError(streamID, ErrCodeNo)} - if got := wr.StreamID(); got != streamID { - t.Errorf("FrameWriteRequest(StreamError) = %v; want %v", got, streamID) - } -} diff --git a/vendor/golang.org/x/net/http2/z_spec_test.go b/vendor/golang.org/x/net/http2/z_spec_test.go deleted file mode 100644 index 610b2cdbc..000000000 --- a/vendor/golang.org/x/net/http2/z_spec_test.go +++ /dev/null @@ -1,356 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "bytes" - "encoding/xml" - "flag" - "fmt" - "io" - "os" - "reflect" - "regexp" - "sort" - "strconv" - "strings" - "sync" - "testing" -) - -var coverSpec = flag.Bool("coverspec", false, "Run spec coverage tests") - -// The global map of sentence coverage for the http2 spec. -var defaultSpecCoverage specCoverage - -var loadSpecOnce sync.Once - -func loadSpec() { - if f, err := os.Open("testdata/draft-ietf-httpbis-http2.xml"); err != nil { - panic(err) - } else { - defaultSpecCoverage = readSpecCov(f) - f.Close() - } -} - -// covers marks all sentences for section sec in defaultSpecCoverage. Sentences not -// "covered" will be included in report outputted by TestSpecCoverage. -func covers(sec, sentences string) { - loadSpecOnce.Do(loadSpec) - defaultSpecCoverage.cover(sec, sentences) -} - -type specPart struct { - section string - sentence string -} - -func (ss specPart) Less(oo specPart) bool { - atoi := func(s string) int { - n, err := strconv.Atoi(s) - if err != nil { - panic(err) - } - return n - } - a := strings.Split(ss.section, ".") - b := strings.Split(oo.section, ".") - for len(a) > 0 { - if len(b) == 0 { - return false - } - x, y := atoi(a[0]), atoi(b[0]) - if x == y { - a, b = a[1:], b[1:] - continue - } - return x < y - } - if len(b) > 0 { - return true - } - return false -} - -type bySpecSection []specPart - -func (a bySpecSection) Len() int { return len(a) } -func (a bySpecSection) Less(i, j int) bool { return a[i].Less(a[j]) } -func (a bySpecSection) Swap(i, j int) { a[i], a[j] = a[j], a[i] } - -type specCoverage struct { - coverage map[specPart]bool - d *xml.Decoder -} - -func joinSection(sec []int) string { - s := fmt.Sprintf("%d", sec[0]) - for _, n := range sec[1:] { - s = fmt.Sprintf("%s.%d", s, n) - } - return s -} - -func (sc specCoverage) readSection(sec []int) { - var ( - buf = new(bytes.Buffer) - sub = 0 - ) - for { - tk, err := sc.d.Token() - if err != nil { - if err == io.EOF { - return - } - panic(err) - } - switch v := tk.(type) { - case xml.StartElement: - if skipElement(v) { - if err := sc.d.Skip(); err != nil { - panic(err) - } - if v.Name.Local == "section" { - sub++ - } - break - } - switch v.Name.Local { - case "section": - sub++ - sc.readSection(append(sec, sub)) - case "xref": - buf.Write(sc.readXRef(v)) - } - case xml.CharData: - if len(sec) == 0 { - break - } - buf.Write(v) - case xml.EndElement: - if v.Name.Local == "section" { - sc.addSentences(joinSection(sec), buf.String()) - return - } - } - } -} - -func (sc specCoverage) readXRef(se xml.StartElement) []byte { - var b []byte - for { - tk, err := sc.d.Token() - if err != nil { - panic(err) - } - switch v := tk.(type) { - case xml.CharData: - if b != nil { - panic("unexpected CharData") - } - b = []byte(string(v)) - case xml.EndElement: - if v.Name.Local != "xref" { - panic("expected ") - } - if b != nil { - return b - } - sig := attrSig(se) - switch sig { - case "target": - return []byte(fmt.Sprintf("[%s]", attrValue(se, "target"))) - case "fmt-of,rel,target", "fmt-,,rel,target": - return []byte(fmt.Sprintf("[%s, %s]", attrValue(se, "target"), attrValue(se, "rel"))) - case "fmt-of,sec,target", "fmt-,,sec,target": - return []byte(fmt.Sprintf("[section %s of %s]", attrValue(se, "sec"), attrValue(se, "target"))) - case "fmt-of,rel,sec,target": - return []byte(fmt.Sprintf("[section %s of %s, %s]", attrValue(se, "sec"), attrValue(se, "target"), attrValue(se, "rel"))) - default: - panic(fmt.Sprintf("unknown attribute signature %q in %#v", sig, fmt.Sprintf("%#v", se))) - } - default: - panic(fmt.Sprintf("unexpected tag %q", v)) - } - } -} - -var skipAnchor = map[string]bool{ - "intro": true, - "Overview": true, -} - -var skipTitle = map[string]bool{ - "Acknowledgements": true, - "Change Log": true, - "Document Organization": true, - "Conventions and Terminology": true, -} - -func skipElement(s xml.StartElement) bool { - switch s.Name.Local { - case "artwork": - return true - case "section": - for _, attr := range s.Attr { - switch attr.Name.Local { - case "anchor": - if skipAnchor[attr.Value] || strings.HasPrefix(attr.Value, "changes.since.") { - return true - } - case "title": - if skipTitle[attr.Value] { - return true - } - } - } - } - return false -} - -func readSpecCov(r io.Reader) specCoverage { - sc := specCoverage{ - coverage: map[specPart]bool{}, - d: xml.NewDecoder(r)} - sc.readSection(nil) - return sc -} - -func (sc specCoverage) addSentences(sec string, sentence string) { - for _, s := range parseSentences(sentence) { - sc.coverage[specPart{sec, s}] = false - } -} - -func (sc specCoverage) cover(sec string, sentence string) { - for _, s := range parseSentences(sentence) { - p := specPart{sec, s} - if _, ok := sc.coverage[p]; !ok { - panic(fmt.Sprintf("Not found in spec: %q, %q", sec, s)) - } - sc.coverage[specPart{sec, s}] = true - } - -} - -var whitespaceRx = regexp.MustCompile(`\s+`) - -func parseSentences(sens string) []string { - sens = strings.TrimSpace(sens) - if sens == "" { - return nil - } - ss := strings.Split(whitespaceRx.ReplaceAllString(sens, " "), ". ") - for i, s := range ss { - s = strings.TrimSpace(s) - if !strings.HasSuffix(s, ".") { - s += "." - } - ss[i] = s - } - return ss -} - -func TestSpecParseSentences(t *testing.T) { - tests := []struct { - ss string - want []string - }{ - {"Sentence 1. Sentence 2.", - []string{ - "Sentence 1.", - "Sentence 2.", - }}, - {"Sentence 1. \nSentence 2.\tSentence 3.", - []string{ - "Sentence 1.", - "Sentence 2.", - "Sentence 3.", - }}, - } - - for i, tt := range tests { - got := parseSentences(tt.ss) - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("%d: got = %q, want %q", i, got, tt.want) - } - } -} - -func TestSpecCoverage(t *testing.T) { - if !*coverSpec { - t.Skip() - } - - loadSpecOnce.Do(loadSpec) - - var ( - list []specPart - cv = defaultSpecCoverage.coverage - total = len(cv) - complete = 0 - ) - - for sp, touched := range defaultSpecCoverage.coverage { - if touched { - complete++ - } else { - list = append(list, sp) - } - } - sort.Stable(bySpecSection(list)) - - if testing.Short() && len(list) > 5 { - list = list[:5] - } - - for _, p := range list { - t.Errorf("\tSECTION %s: %s", p.section, p.sentence) - } - - t.Logf("%d/%d (%d%%) sentences covered", complete, total, (complete/total)*100) -} - -func attrSig(se xml.StartElement) string { - var names []string - for _, attr := range se.Attr { - if attr.Name.Local == "fmt" { - names = append(names, "fmt-"+attr.Value) - } else { - names = append(names, attr.Name.Local) - } - } - sort.Strings(names) - return strings.Join(names, ",") -} - -func attrValue(se xml.StartElement, attr string) string { - for _, a := range se.Attr { - if a.Name.Local == attr { - return a.Value - } - } - panic("unknown attribute " + attr) -} - -func TestSpecPartLess(t *testing.T) { - tests := []struct { - sec1, sec2 string - want bool - }{ - {"6.2.1", "6.2", false}, - {"6.2", "6.2.1", true}, - {"6.10", "6.10.1", true}, - {"6.10", "6.1.1", false}, // 10, not 1 - {"6.1", "6.1", false}, // equal, so not less - } - for _, tt := range tests { - got := (specPart{tt.sec1, "foo"}).Less(specPart{tt.sec2, "foo"}) - if got != tt.want { - t.Errorf("Less(%q, %q) = %v; want %v", tt.sec1, tt.sec2, got, tt.want) - } - } -} diff --git a/vendor/golang.org/x/net/icmp/dstunreach.go b/vendor/golang.org/x/net/icmp/dstunreach.go deleted file mode 100644 index 75db991df..000000000 --- a/vendor/golang.org/x/net/icmp/dstunreach.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -// A DstUnreach represents an ICMP destination unreachable message -// body. -type DstUnreach struct { - Data []byte // data, known as original datagram field - Extensions []Extension // extensions -} - -// Len implements the Len method of MessageBody interface. -func (p *DstUnreach) Len(proto int) int { - if p == nil { - return 0 - } - l, _ := multipartMessageBodyDataLen(proto, p.Data, p.Extensions) - return 4 + l -} - -// Marshal implements the Marshal method of MessageBody interface. -func (p *DstUnreach) Marshal(proto int) ([]byte, error) { - return marshalMultipartMessageBody(proto, p.Data, p.Extensions) -} - -// parseDstUnreach parses b as an ICMP destination unreachable message -// body. -func parseDstUnreach(proto int, b []byte) (MessageBody, error) { - if len(b) < 4 { - return nil, errMessageTooShort - } - p := &DstUnreach{} - var err error - p.Data, p.Extensions, err = parseMultipartMessageBody(proto, b) - if err != nil { - return nil, err - } - return p, nil -} diff --git a/vendor/golang.org/x/net/icmp/echo.go b/vendor/golang.org/x/net/icmp/echo.go deleted file mode 100644 index e6f15efd7..000000000 --- a/vendor/golang.org/x/net/icmp/echo.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import "encoding/binary" - -// An Echo represents an ICMP echo request or reply message body. -type Echo struct { - ID int // identifier - Seq int // sequence number - Data []byte // data -} - -// Len implements the Len method of MessageBody interface. -func (p *Echo) Len(proto int) int { - if p == nil { - return 0 - } - return 4 + len(p.Data) -} - -// Marshal implements the Marshal method of MessageBody interface. -func (p *Echo) Marshal(proto int) ([]byte, error) { - b := make([]byte, 4+len(p.Data)) - binary.BigEndian.PutUint16(b[:2], uint16(p.ID)) - binary.BigEndian.PutUint16(b[2:4], uint16(p.Seq)) - copy(b[4:], p.Data) - return b, nil -} - -// parseEcho parses b as an ICMP echo request or reply message body. -func parseEcho(proto int, b []byte) (MessageBody, error) { - bodyLen := len(b) - if bodyLen < 4 { - return nil, errMessageTooShort - } - p := &Echo{ID: int(binary.BigEndian.Uint16(b[:2])), Seq: int(binary.BigEndian.Uint16(b[2:4]))} - if bodyLen > 4 { - p.Data = make([]byte, bodyLen-4) - copy(p.Data, b[4:]) - } - return p, nil -} diff --git a/vendor/golang.org/x/net/icmp/endpoint.go b/vendor/golang.org/x/net/icmp/endpoint.go deleted file mode 100644 index a68bfb010..000000000 --- a/vendor/golang.org/x/net/icmp/endpoint.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import ( - "net" - "runtime" - "syscall" - "time" - - "golang.org/x/net/ipv4" - "golang.org/x/net/ipv6" -) - -var _ net.PacketConn = &PacketConn{} - -// A PacketConn represents a packet network endpoint that uses either -// ICMPv4 or ICMPv6. -type PacketConn struct { - c net.PacketConn - p4 *ipv4.PacketConn - p6 *ipv6.PacketConn -} - -func (c *PacketConn) ok() bool { return c != nil && c.c != nil } - -// IPv4PacketConn returns the ipv4.PacketConn of c. -// It returns nil when c is not created as the endpoint for ICMPv4. -func (c *PacketConn) IPv4PacketConn() *ipv4.PacketConn { - if !c.ok() { - return nil - } - return c.p4 -} - -// IPv6PacketConn returns the ipv6.PacketConn of c. -// It returns nil when c is not created as the endpoint for ICMPv6. -func (c *PacketConn) IPv6PacketConn() *ipv6.PacketConn { - if !c.ok() { - return nil - } - return c.p6 -} - -// ReadFrom reads an ICMP message from the connection. -func (c *PacketConn) ReadFrom(b []byte) (int, net.Addr, error) { - if !c.ok() { - return 0, nil, syscall.EINVAL - } - // Please be informed that ipv4.NewPacketConn enables - // IP_STRIPHDR option by default on Darwin. - // See golang.org/issue/9395 for further information. - if runtime.GOOS == "darwin" && c.p4 != nil { - n, _, peer, err := c.p4.ReadFrom(b) - return n, peer, err - } - return c.c.ReadFrom(b) -} - -// WriteTo writes the ICMP message b to dst. -// Dst must be net.UDPAddr when c is a non-privileged -// datagram-oriented ICMP endpoint. Otherwise it must be net.IPAddr. -func (c *PacketConn) WriteTo(b []byte, dst net.Addr) (int, error) { - if !c.ok() { - return 0, syscall.EINVAL - } - return c.c.WriteTo(b, dst) -} - -// Close closes the endpoint. -func (c *PacketConn) Close() error { - if !c.ok() { - return syscall.EINVAL - } - return c.c.Close() -} - -// LocalAddr returns the local network address. -func (c *PacketConn) LocalAddr() net.Addr { - if !c.ok() { - return nil - } - return c.c.LocalAddr() -} - -// SetDeadline sets the read and write deadlines associated with the -// endpoint. -func (c *PacketConn) SetDeadline(t time.Time) error { - if !c.ok() { - return syscall.EINVAL - } - return c.c.SetDeadline(t) -} - -// SetReadDeadline sets the read deadline associated with the -// endpoint. -func (c *PacketConn) SetReadDeadline(t time.Time) error { - if !c.ok() { - return syscall.EINVAL - } - return c.c.SetReadDeadline(t) -} - -// SetWriteDeadline sets the write deadline associated with the -// endpoint. -func (c *PacketConn) SetWriteDeadline(t time.Time) error { - if !c.ok() { - return syscall.EINVAL - } - return c.c.SetWriteDeadline(t) -} diff --git a/vendor/golang.org/x/net/icmp/example_test.go b/vendor/golang.org/x/net/icmp/example_test.go deleted file mode 100644 index 1df4ceccd..000000000 --- a/vendor/golang.org/x/net/icmp/example_test.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp_test - -import ( - "log" - "net" - "os" - "runtime" - - "golang.org/x/net/icmp" - "golang.org/x/net/ipv6" -) - -func ExamplePacketConn_nonPrivilegedPing() { - switch runtime.GOOS { - case "darwin": - case "linux": - log.Println("you may need to adjust the net.ipv4.ping_group_range kernel state") - default: - log.Println("not supported on", runtime.GOOS) - return - } - - c, err := icmp.ListenPacket("udp6", "fe80::1%en0") - if err != nil { - log.Fatal(err) - } - defer c.Close() - - wm := icmp.Message{ - Type: ipv6.ICMPTypeEchoRequest, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, Seq: 1, - Data: []byte("HELLO-R-U-THERE"), - }, - } - wb, err := wm.Marshal(nil) - if err != nil { - log.Fatal(err) - } - if _, err := c.WriteTo(wb, &net.UDPAddr{IP: net.ParseIP("ff02::1"), Zone: "en0"}); err != nil { - log.Fatal(err) - } - - rb := make([]byte, 1500) - n, peer, err := c.ReadFrom(rb) - if err != nil { - log.Fatal(err) - } - rm, err := icmp.ParseMessage(58, rb[:n]) - if err != nil { - log.Fatal(err) - } - switch rm.Type { - case ipv6.ICMPTypeEchoReply: - log.Printf("got reflection from %v", peer) - default: - log.Printf("got %+v; want echo reply", rm) - } -} diff --git a/vendor/golang.org/x/net/icmp/extension.go b/vendor/golang.org/x/net/icmp/extension.go deleted file mode 100644 index 402a7514b..000000000 --- a/vendor/golang.org/x/net/icmp/extension.go +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import "encoding/binary" - -// An Extension represents an ICMP extension. -type Extension interface { - // Len returns the length of ICMP extension. - // Proto must be either the ICMPv4 or ICMPv6 protocol number. - Len(proto int) int - - // Marshal returns the binary encoding of ICMP extension. - // Proto must be either the ICMPv4 or ICMPv6 protocol number. - Marshal(proto int) ([]byte, error) -} - -const extensionVersion = 2 - -func validExtensionHeader(b []byte) bool { - v := int(b[0]&0xf0) >> 4 - s := binary.BigEndian.Uint16(b[2:4]) - if s != 0 { - s = checksum(b) - } - if v != extensionVersion || s != 0 { - return false - } - return true -} - -// parseExtensions parses b as a list of ICMP extensions. -// The length attribute l must be the length attribute field in -// received icmp messages. -// -// It will return a list of ICMP extensions and an adjusted length -// attribute that represents the length of the padded original -// datagram field. Otherwise, it returns an error. -func parseExtensions(b []byte, l int) ([]Extension, int, error) { - // Still a lot of non-RFC 4884 compliant implementations are - // out there. Set the length attribute l to 128 when it looks - // inappropriate for backwards compatibility. - // - // A minimal extension at least requires 8 octets; 4 octets - // for an extension header, and 4 octets for a single object - // header. - // - // See RFC 4884 for further information. - if 128 > l || l+8 > len(b) { - l = 128 - } - if l+8 > len(b) { - return nil, -1, errNoExtension - } - if !validExtensionHeader(b[l:]) { - if l == 128 { - return nil, -1, errNoExtension - } - l = 128 - if !validExtensionHeader(b[l:]) { - return nil, -1, errNoExtension - } - } - var exts []Extension - for b = b[l+4:]; len(b) >= 4; { - ol := int(binary.BigEndian.Uint16(b[:2])) - if 4 > ol || ol > len(b) { - break - } - switch b[2] { - case classMPLSLabelStack: - ext, err := parseMPLSLabelStack(b[:ol]) - if err != nil { - return nil, -1, err - } - exts = append(exts, ext) - case classInterfaceInfo: - ext, err := parseInterfaceInfo(b[:ol]) - if err != nil { - return nil, -1, err - } - exts = append(exts, ext) - } - b = b[ol:] - } - return exts, l, nil -} diff --git a/vendor/golang.org/x/net/icmp/extension_test.go b/vendor/golang.org/x/net/icmp/extension_test.go deleted file mode 100644 index 0b3f7b9e1..000000000 --- a/vendor/golang.org/x/net/icmp/extension_test.go +++ /dev/null @@ -1,259 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import ( - "net" - "reflect" - "testing" - - "golang.org/x/net/internal/iana" -) - -var marshalAndParseExtensionTests = []struct { - proto int - hdr []byte - obj []byte - exts []Extension -}{ - // MPLS label stack with no label - { - proto: iana.ProtocolICMP, - hdr: []byte{ - 0x20, 0x00, 0x00, 0x00, - }, - obj: []byte{ - 0x00, 0x04, 0x01, 0x01, - }, - exts: []Extension{ - &MPLSLabelStack{ - Class: classMPLSLabelStack, - Type: typeIncomingMPLSLabelStack, - }, - }, - }, - // MPLS label stack with a single label - { - proto: iana.ProtocolIPv6ICMP, - hdr: []byte{ - 0x20, 0x00, 0x00, 0x00, - }, - obj: []byte{ - 0x00, 0x08, 0x01, 0x01, - 0x03, 0xe8, 0xe9, 0xff, - }, - exts: []Extension{ - &MPLSLabelStack{ - Class: classMPLSLabelStack, - Type: typeIncomingMPLSLabelStack, - Labels: []MPLSLabel{ - { - Label: 16014, - TC: 0x4, - S: true, - TTL: 255, - }, - }, - }, - }, - }, - // MPLS label stack with multiple labels - { - proto: iana.ProtocolICMP, - hdr: []byte{ - 0x20, 0x00, 0x00, 0x00, - }, - obj: []byte{ - 0x00, 0x0c, 0x01, 0x01, - 0x03, 0xe8, 0xde, 0xfe, - 0x03, 0xe8, 0xe1, 0xff, - }, - exts: []Extension{ - &MPLSLabelStack{ - Class: classMPLSLabelStack, - Type: typeIncomingMPLSLabelStack, - Labels: []MPLSLabel{ - { - Label: 16013, - TC: 0x7, - S: false, - TTL: 254, - }, - { - Label: 16014, - TC: 0, - S: true, - TTL: 255, - }, - }, - }, - }, - }, - // Interface information with no attribute - { - proto: iana.ProtocolICMP, - hdr: []byte{ - 0x20, 0x00, 0x00, 0x00, - }, - obj: []byte{ - 0x00, 0x04, 0x02, 0x00, - }, - exts: []Extension{ - &InterfaceInfo{ - Class: classInterfaceInfo, - }, - }, - }, - // Interface information with ifIndex and name - { - proto: iana.ProtocolICMP, - hdr: []byte{ - 0x20, 0x00, 0x00, 0x00, - }, - obj: []byte{ - 0x00, 0x10, 0x02, 0x0a, - 0x00, 0x00, 0x00, 0x10, - 0x08, byte('e'), byte('n'), byte('1'), - byte('0'), byte('1'), 0x00, 0x00, - }, - exts: []Extension{ - &InterfaceInfo{ - Class: classInterfaceInfo, - Type: 0x0a, - Interface: &net.Interface{ - Index: 16, - Name: "en101", - }, - }, - }, - }, - // Interface information with ifIndex, IPAddr, name and MTU - { - proto: iana.ProtocolIPv6ICMP, - hdr: []byte{ - 0x20, 0x00, 0x00, 0x00, - }, - obj: []byte{ - 0x00, 0x28, 0x02, 0x0f, - 0x00, 0x00, 0x00, 0x0f, - 0x00, 0x02, 0x00, 0x00, - 0xfe, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x08, byte('e'), byte('n'), byte('1'), - byte('0'), byte('1'), 0x00, 0x00, - 0x00, 0x00, 0x20, 0x00, - }, - exts: []Extension{ - &InterfaceInfo{ - Class: classInterfaceInfo, - Type: 0x0f, - Interface: &net.Interface{ - Index: 15, - Name: "en101", - MTU: 8192, - }, - Addr: &net.IPAddr{ - IP: net.ParseIP("fe80::1"), - Zone: "en101", - }, - }, - }, - }, -} - -func TestMarshalAndParseExtension(t *testing.T) { - for i, tt := range marshalAndParseExtensionTests { - for j, ext := range tt.exts { - var err error - var b []byte - switch ext := ext.(type) { - case *MPLSLabelStack: - b, err = ext.Marshal(tt.proto) - if err != nil { - t.Errorf("#%v/%v: %v", i, j, err) - continue - } - case *InterfaceInfo: - b, err = ext.Marshal(tt.proto) - if err != nil { - t.Errorf("#%v/%v: %v", i, j, err) - continue - } - } - if !reflect.DeepEqual(b, tt.obj) { - t.Errorf("#%v/%v: got %#v; want %#v", i, j, b, tt.obj) - continue - } - } - - for j, wire := range []struct { - data []byte // original datagram - inlattr int // length of padded original datagram, a hint - outlattr int // length of padded original datagram, a want - err error - }{ - {nil, 0, -1, errNoExtension}, - {make([]byte, 127), 128, -1, errNoExtension}, - - {make([]byte, 128), 127, -1, errNoExtension}, - {make([]byte, 128), 128, -1, errNoExtension}, - {make([]byte, 128), 129, -1, errNoExtension}, - - {append(make([]byte, 128), append(tt.hdr, tt.obj...)...), 127, 128, nil}, - {append(make([]byte, 128), append(tt.hdr, tt.obj...)...), 128, 128, nil}, - {append(make([]byte, 128), append(tt.hdr, tt.obj...)...), 129, 128, nil}, - - {append(make([]byte, 512), append(tt.hdr, tt.obj...)...), 511, -1, errNoExtension}, - {append(make([]byte, 512), append(tt.hdr, tt.obj...)...), 512, 512, nil}, - {append(make([]byte, 512), append(tt.hdr, tt.obj...)...), 513, -1, errNoExtension}, - } { - exts, l, err := parseExtensions(wire.data, wire.inlattr) - if err != wire.err { - t.Errorf("#%v/%v: got %v; want %v", i, j, err, wire.err) - continue - } - if wire.err != nil { - continue - } - if l != wire.outlattr { - t.Errorf("#%v/%v: got %v; want %v", i, j, l, wire.outlattr) - } - if !reflect.DeepEqual(exts, tt.exts) { - for j, ext := range exts { - switch ext := ext.(type) { - case *MPLSLabelStack: - want := tt.exts[j].(*MPLSLabelStack) - t.Errorf("#%v/%v: got %#v; want %#v", i, j, ext, want) - case *InterfaceInfo: - want := tt.exts[j].(*InterfaceInfo) - t.Errorf("#%v/%v: got %#v; want %#v", i, j, ext, want) - } - } - continue - } - } - } -} - -var parseInterfaceNameTests = []struct { - b []byte - error -}{ - {[]byte{0, 'e', 'n', '0'}, errInvalidExtension}, - {[]byte{4, 'e', 'n', '0'}, nil}, - {[]byte{7, 'e', 'n', '0', 0xff, 0xff, 0xff, 0xff}, errInvalidExtension}, - {[]byte{8, 'e', 'n', '0', 0xff, 0xff, 0xff}, errMessageTooShort}, -} - -func TestParseInterfaceName(t *testing.T) { - ifi := InterfaceInfo{Interface: &net.Interface{}} - for i, tt := range parseInterfaceNameTests { - if _, err := ifi.parseName(tt.b); err != tt.error { - t.Errorf("#%d: got %v; want %v", i, err, tt.error) - } - } -} diff --git a/vendor/golang.org/x/net/icmp/helper.go b/vendor/golang.org/x/net/icmp/helper.go deleted file mode 100644 index 6c4e633bc..000000000 --- a/vendor/golang.org/x/net/icmp/helper.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import ( - "encoding/binary" - "unsafe" -) - -var ( - // See http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html. - freebsdVersion uint32 - - nativeEndian binary.ByteOrder -) - -func init() { - i := uint32(1) - b := (*[4]byte)(unsafe.Pointer(&i)) - if b[0] == 1 { - nativeEndian = binary.LittleEndian - } else { - nativeEndian = binary.BigEndian - } -} diff --git a/vendor/golang.org/x/net/icmp/helper_posix.go b/vendor/golang.org/x/net/icmp/helper_posix.go deleted file mode 100644 index 398fd388f..000000000 --- a/vendor/golang.org/x/net/icmp/helper_posix.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package icmp - -import ( - "net" - "strconv" - "syscall" -) - -func sockaddr(family int, address string) (syscall.Sockaddr, error) { - switch family { - case syscall.AF_INET: - a, err := net.ResolveIPAddr("ip4", address) - if err != nil { - return nil, err - } - if len(a.IP) == 0 { - a.IP = net.IPv4zero - } - if a.IP = a.IP.To4(); a.IP == nil { - return nil, net.InvalidAddrError("non-ipv4 address") - } - sa := &syscall.SockaddrInet4{} - copy(sa.Addr[:], a.IP) - return sa, nil - case syscall.AF_INET6: - a, err := net.ResolveIPAddr("ip6", address) - if err != nil { - return nil, err - } - if len(a.IP) == 0 { - a.IP = net.IPv6unspecified - } - if a.IP.Equal(net.IPv4zero) { - a.IP = net.IPv6unspecified - } - if a.IP = a.IP.To16(); a.IP == nil || a.IP.To4() != nil { - return nil, net.InvalidAddrError("non-ipv6 address") - } - sa := &syscall.SockaddrInet6{ZoneId: zoneToUint32(a.Zone)} - copy(sa.Addr[:], a.IP) - return sa, nil - default: - return nil, net.InvalidAddrError("unexpected family") - } -} - -func zoneToUint32(zone string) uint32 { - if zone == "" { - return 0 - } - if ifi, err := net.InterfaceByName(zone); err == nil { - return uint32(ifi.Index) - } - n, err := strconv.Atoi(zone) - if err != nil { - return 0 - } - return uint32(n) -} - -func last(s string, b byte) int { - i := len(s) - for i--; i >= 0; i-- { - if s[i] == b { - break - } - } - return i -} diff --git a/vendor/golang.org/x/net/icmp/interface.go b/vendor/golang.org/x/net/icmp/interface.go deleted file mode 100644 index 78b5b98bf..000000000 --- a/vendor/golang.org/x/net/icmp/interface.go +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import ( - "encoding/binary" - "net" - "strings" - - "golang.org/x/net/internal/iana" -) - -const ( - classInterfaceInfo = 2 - - afiIPv4 = 1 - afiIPv6 = 2 -) - -const ( - attrMTU = 1 << iota - attrName - attrIPAddr - attrIfIndex -) - -// An InterfaceInfo represents interface and next-hop identification. -type InterfaceInfo struct { - Class int // extension object class number - Type int // extension object sub-type - Interface *net.Interface - Addr *net.IPAddr -} - -func (ifi *InterfaceInfo) nameLen() int { - if len(ifi.Interface.Name) > 63 { - return 64 - } - l := 1 + len(ifi.Interface.Name) - return (l + 3) &^ 3 -} - -func (ifi *InterfaceInfo) attrsAndLen(proto int) (attrs, l int) { - l = 4 - if ifi.Interface != nil && ifi.Interface.Index > 0 { - attrs |= attrIfIndex - l += 4 - if len(ifi.Interface.Name) > 0 { - attrs |= attrName - l += ifi.nameLen() - } - if ifi.Interface.MTU > 0 { - attrs |= attrMTU - l += 4 - } - } - if ifi.Addr != nil { - switch proto { - case iana.ProtocolICMP: - if ifi.Addr.IP.To4() != nil { - attrs |= attrIPAddr - l += 4 + net.IPv4len - } - case iana.ProtocolIPv6ICMP: - if ifi.Addr.IP.To16() != nil && ifi.Addr.IP.To4() == nil { - attrs |= attrIPAddr - l += 4 + net.IPv6len - } - } - } - return -} - -// Len implements the Len method of Extension interface. -func (ifi *InterfaceInfo) Len(proto int) int { - _, l := ifi.attrsAndLen(proto) - return l -} - -// Marshal implements the Marshal method of Extension interface. -func (ifi *InterfaceInfo) Marshal(proto int) ([]byte, error) { - attrs, l := ifi.attrsAndLen(proto) - b := make([]byte, l) - if err := ifi.marshal(proto, b, attrs, l); err != nil { - return nil, err - } - return b, nil -} - -func (ifi *InterfaceInfo) marshal(proto int, b []byte, attrs, l int) error { - binary.BigEndian.PutUint16(b[:2], uint16(l)) - b[2], b[3] = classInterfaceInfo, byte(ifi.Type) - for b = b[4:]; len(b) > 0 && attrs != 0; { - switch { - case attrs&attrIfIndex != 0: - b = ifi.marshalIfIndex(proto, b) - attrs &^= attrIfIndex - case attrs&attrIPAddr != 0: - b = ifi.marshalIPAddr(proto, b) - attrs &^= attrIPAddr - case attrs&attrName != 0: - b = ifi.marshalName(proto, b) - attrs &^= attrName - case attrs&attrMTU != 0: - b = ifi.marshalMTU(proto, b) - attrs &^= attrMTU - } - } - return nil -} - -func (ifi *InterfaceInfo) marshalIfIndex(proto int, b []byte) []byte { - binary.BigEndian.PutUint32(b[:4], uint32(ifi.Interface.Index)) - return b[4:] -} - -func (ifi *InterfaceInfo) parseIfIndex(b []byte) ([]byte, error) { - if len(b) < 4 { - return nil, errMessageTooShort - } - ifi.Interface.Index = int(binary.BigEndian.Uint32(b[:4])) - return b[4:], nil -} - -func (ifi *InterfaceInfo) marshalIPAddr(proto int, b []byte) []byte { - switch proto { - case iana.ProtocolICMP: - binary.BigEndian.PutUint16(b[:2], uint16(afiIPv4)) - copy(b[4:4+net.IPv4len], ifi.Addr.IP.To4()) - b = b[4+net.IPv4len:] - case iana.ProtocolIPv6ICMP: - binary.BigEndian.PutUint16(b[:2], uint16(afiIPv6)) - copy(b[4:4+net.IPv6len], ifi.Addr.IP.To16()) - b = b[4+net.IPv6len:] - } - return b -} - -func (ifi *InterfaceInfo) parseIPAddr(b []byte) ([]byte, error) { - if len(b) < 4 { - return nil, errMessageTooShort - } - afi := int(binary.BigEndian.Uint16(b[:2])) - b = b[4:] - switch afi { - case afiIPv4: - if len(b) < net.IPv4len { - return nil, errMessageTooShort - } - ifi.Addr.IP = make(net.IP, net.IPv4len) - copy(ifi.Addr.IP, b[:net.IPv4len]) - b = b[net.IPv4len:] - case afiIPv6: - if len(b) < net.IPv6len { - return nil, errMessageTooShort - } - ifi.Addr.IP = make(net.IP, net.IPv6len) - copy(ifi.Addr.IP, b[:net.IPv6len]) - b = b[net.IPv6len:] - } - return b, nil -} - -func (ifi *InterfaceInfo) marshalName(proto int, b []byte) []byte { - l := byte(ifi.nameLen()) - b[0] = l - copy(b[1:], []byte(ifi.Interface.Name)) - return b[l:] -} - -func (ifi *InterfaceInfo) parseName(b []byte) ([]byte, error) { - if 4 > len(b) || len(b) < int(b[0]) { - return nil, errMessageTooShort - } - l := int(b[0]) - if l%4 != 0 || 4 > l || l > 64 { - return nil, errInvalidExtension - } - var name [63]byte - copy(name[:], b[1:l]) - ifi.Interface.Name = strings.Trim(string(name[:]), "\000") - return b[l:], nil -} - -func (ifi *InterfaceInfo) marshalMTU(proto int, b []byte) []byte { - binary.BigEndian.PutUint32(b[:4], uint32(ifi.Interface.MTU)) - return b[4:] -} - -func (ifi *InterfaceInfo) parseMTU(b []byte) ([]byte, error) { - if len(b) < 4 { - return nil, errMessageTooShort - } - ifi.Interface.MTU = int(binary.BigEndian.Uint32(b[:4])) - return b[4:], nil -} - -func parseInterfaceInfo(b []byte) (Extension, error) { - ifi := &InterfaceInfo{ - Class: int(b[2]), - Type: int(b[3]), - } - if ifi.Type&(attrIfIndex|attrName|attrMTU) != 0 { - ifi.Interface = &net.Interface{} - } - if ifi.Type&attrIPAddr != 0 { - ifi.Addr = &net.IPAddr{} - } - attrs := ifi.Type & (attrIfIndex | attrIPAddr | attrName | attrMTU) - for b = b[4:]; len(b) > 0 && attrs != 0; { - var err error - switch { - case attrs&attrIfIndex != 0: - b, err = ifi.parseIfIndex(b) - attrs &^= attrIfIndex - case attrs&attrIPAddr != 0: - b, err = ifi.parseIPAddr(b) - attrs &^= attrIPAddr - case attrs&attrName != 0: - b, err = ifi.parseName(b) - attrs &^= attrName - case attrs&attrMTU != 0: - b, err = ifi.parseMTU(b) - attrs &^= attrMTU - } - if err != nil { - return nil, err - } - } - if ifi.Interface != nil && ifi.Interface.Name != "" && ifi.Addr != nil && ifi.Addr.IP.To16() != nil && ifi.Addr.IP.To4() == nil { - ifi.Addr.Zone = ifi.Interface.Name - } - return ifi, nil -} diff --git a/vendor/golang.org/x/net/icmp/ipv4.go b/vendor/golang.org/x/net/icmp/ipv4.go deleted file mode 100644 index 729ddc97c..000000000 --- a/vendor/golang.org/x/net/icmp/ipv4.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import ( - "encoding/binary" - "net" - "runtime" - - "golang.org/x/net/ipv4" -) - -// ParseIPv4Header parses b as an IPv4 header of ICMP error message -// invoking packet, which is contained in ICMP error message. -func ParseIPv4Header(b []byte) (*ipv4.Header, error) { - if len(b) < ipv4.HeaderLen { - return nil, errHeaderTooShort - } - hdrlen := int(b[0]&0x0f) << 2 - if hdrlen > len(b) { - return nil, errBufferTooShort - } - h := &ipv4.Header{ - Version: int(b[0] >> 4), - Len: hdrlen, - TOS: int(b[1]), - ID: int(binary.BigEndian.Uint16(b[4:6])), - FragOff: int(binary.BigEndian.Uint16(b[6:8])), - TTL: int(b[8]), - Protocol: int(b[9]), - Checksum: int(binary.BigEndian.Uint16(b[10:12])), - Src: net.IPv4(b[12], b[13], b[14], b[15]), - Dst: net.IPv4(b[16], b[17], b[18], b[19]), - } - switch runtime.GOOS { - case "darwin": - h.TotalLen = int(nativeEndian.Uint16(b[2:4])) - case "freebsd": - if freebsdVersion >= 1000000 { - h.TotalLen = int(binary.BigEndian.Uint16(b[2:4])) - } else { - h.TotalLen = int(nativeEndian.Uint16(b[2:4])) - } - default: - h.TotalLen = int(binary.BigEndian.Uint16(b[2:4])) - } - h.Flags = ipv4.HeaderFlags(h.FragOff&0xe000) >> 13 - h.FragOff = h.FragOff & 0x1fff - if hdrlen-ipv4.HeaderLen > 0 { - h.Options = make([]byte, hdrlen-ipv4.HeaderLen) - copy(h.Options, b[ipv4.HeaderLen:]) - } - return h, nil -} diff --git a/vendor/golang.org/x/net/icmp/ipv4_test.go b/vendor/golang.org/x/net/icmp/ipv4_test.go deleted file mode 100644 index 47cc00d07..000000000 --- a/vendor/golang.org/x/net/icmp/ipv4_test.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import ( - "encoding/binary" - "net" - "reflect" - "runtime" - "testing" - - "golang.org/x/net/ipv4" -) - -type ipv4HeaderTest struct { - wireHeaderFromKernel [ipv4.HeaderLen]byte - wireHeaderFromTradBSDKernel [ipv4.HeaderLen]byte - Header *ipv4.Header -} - -var ipv4HeaderLittleEndianTest = ipv4HeaderTest{ - // TODO(mikio): Add platform dependent wire header formats when - // we support new platforms. - wireHeaderFromKernel: [ipv4.HeaderLen]byte{ - 0x45, 0x01, 0xbe, 0xef, - 0xca, 0xfe, 0x45, 0xdc, - 0xff, 0x01, 0xde, 0xad, - 172, 16, 254, 254, - 192, 168, 0, 1, - }, - wireHeaderFromTradBSDKernel: [ipv4.HeaderLen]byte{ - 0x45, 0x01, 0xef, 0xbe, - 0xca, 0xfe, 0x45, 0xdc, - 0xff, 0x01, 0xde, 0xad, - 172, 16, 254, 254, - 192, 168, 0, 1, - }, - Header: &ipv4.Header{ - Version: ipv4.Version, - Len: ipv4.HeaderLen, - TOS: 1, - TotalLen: 0xbeef, - ID: 0xcafe, - Flags: ipv4.DontFragment, - FragOff: 1500, - TTL: 255, - Protocol: 1, - Checksum: 0xdead, - Src: net.IPv4(172, 16, 254, 254), - Dst: net.IPv4(192, 168, 0, 1), - }, -} - -func TestParseIPv4Header(t *testing.T) { - tt := &ipv4HeaderLittleEndianTest - if nativeEndian != binary.LittleEndian { - t.Skip("no test for non-little endian machine yet") - } - - var wh []byte - switch runtime.GOOS { - case "darwin": - wh = tt.wireHeaderFromTradBSDKernel[:] - case "freebsd": - if freebsdVersion >= 1000000 { - wh = tt.wireHeaderFromKernel[:] - } else { - wh = tt.wireHeaderFromTradBSDKernel[:] - } - default: - wh = tt.wireHeaderFromKernel[:] - } - h, err := ParseIPv4Header(wh) - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(h, tt.Header) { - t.Fatalf("got %#v; want %#v", h, tt.Header) - } -} diff --git a/vendor/golang.org/x/net/icmp/ipv6.go b/vendor/golang.org/x/net/icmp/ipv6.go deleted file mode 100644 index 2e8cfeb13..000000000 --- a/vendor/golang.org/x/net/icmp/ipv6.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import ( - "net" - - "golang.org/x/net/internal/iana" -) - -const ipv6PseudoHeaderLen = 2*net.IPv6len + 8 - -// IPv6PseudoHeader returns an IPv6 pseudo header for checksum -// calculation. -func IPv6PseudoHeader(src, dst net.IP) []byte { - b := make([]byte, ipv6PseudoHeaderLen) - copy(b, src.To16()) - copy(b[net.IPv6len:], dst.To16()) - b[len(b)-1] = byte(iana.ProtocolIPv6ICMP) - return b -} diff --git a/vendor/golang.org/x/net/icmp/listen_posix.go b/vendor/golang.org/x/net/icmp/listen_posix.go deleted file mode 100644 index 7fac4f965..000000000 --- a/vendor/golang.org/x/net/icmp/listen_posix.go +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package icmp - -import ( - "net" - "os" - "runtime" - "syscall" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/ipv4" - "golang.org/x/net/ipv6" -) - -const sysIP_STRIPHDR = 0x17 // for now only darwin supports this option - -// ListenPacket listens for incoming ICMP packets addressed to -// address. See net.Dial for the syntax of address. -// -// For non-privileged datagram-oriented ICMP endpoints, network must -// be "udp4" or "udp6". The endpoint allows to read, write a few -// limited ICMP messages such as echo request and echo reply. -// Currently only Darwin and Linux support this. -// -// Examples: -// ListenPacket("udp4", "192.168.0.1") -// ListenPacket("udp4", "0.0.0.0") -// ListenPacket("udp6", "fe80::1%en0") -// ListenPacket("udp6", "::") -// -// For privileged raw ICMP endpoints, network must be "ip4" or "ip6" -// followed by a colon and an ICMP protocol number or name. -// -// Examples: -// ListenPacket("ip4:icmp", "192.168.0.1") -// ListenPacket("ip4:1", "0.0.0.0") -// ListenPacket("ip6:ipv6-icmp", "fe80::1%en0") -// ListenPacket("ip6:58", "::") -func ListenPacket(network, address string) (*PacketConn, error) { - var family, proto int - switch network { - case "udp4": - family, proto = syscall.AF_INET, iana.ProtocolICMP - case "udp6": - family, proto = syscall.AF_INET6, iana.ProtocolIPv6ICMP - default: - i := last(network, ':') - switch network[:i] { - case "ip4": - proto = iana.ProtocolICMP - case "ip6": - proto = iana.ProtocolIPv6ICMP - } - } - var cerr error - var c net.PacketConn - switch family { - case syscall.AF_INET, syscall.AF_INET6: - s, err := syscall.Socket(family, syscall.SOCK_DGRAM, proto) - if err != nil { - return nil, os.NewSyscallError("socket", err) - } - if runtime.GOOS == "darwin" && family == syscall.AF_INET { - if err := syscall.SetsockoptInt(s, iana.ProtocolIP, sysIP_STRIPHDR, 1); err != nil { - syscall.Close(s) - return nil, os.NewSyscallError("setsockopt", err) - } - } - sa, err := sockaddr(family, address) - if err != nil { - syscall.Close(s) - return nil, err - } - if err := syscall.Bind(s, sa); err != nil { - syscall.Close(s) - return nil, os.NewSyscallError("bind", err) - } - f := os.NewFile(uintptr(s), "datagram-oriented icmp") - c, cerr = net.FilePacketConn(f) - f.Close() - default: - c, cerr = net.ListenPacket(network, address) - } - if cerr != nil { - return nil, cerr - } - switch proto { - case iana.ProtocolICMP: - return &PacketConn{c: c, p4: ipv4.NewPacketConn(c)}, nil - case iana.ProtocolIPv6ICMP: - return &PacketConn{c: c, p6: ipv6.NewPacketConn(c)}, nil - default: - return &PacketConn{c: c}, nil - } -} diff --git a/vendor/golang.org/x/net/icmp/listen_stub.go b/vendor/golang.org/x/net/icmp/listen_stub.go deleted file mode 100644 index 668728d17..000000000 --- a/vendor/golang.org/x/net/icmp/listen_stub.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package icmp - -// ListenPacket listens for incoming ICMP packets addressed to -// address. See net.Dial for the syntax of address. -// -// For non-privileged datagram-oriented ICMP endpoints, network must -// be "udp4" or "udp6". The endpoint allows to read, write a few -// limited ICMP messages such as echo request and echo reply. -// Currently only Darwin and Linux support this. -// -// Examples: -// ListenPacket("udp4", "192.168.0.1") -// ListenPacket("udp4", "0.0.0.0") -// ListenPacket("udp6", "fe80::1%en0") -// ListenPacket("udp6", "::") -// -// For privileged raw ICMP endpoints, network must be "ip4" or "ip6" -// followed by a colon and an ICMP protocol number or name. -// -// Examples: -// ListenPacket("ip4:icmp", "192.168.0.1") -// ListenPacket("ip4:1", "0.0.0.0") -// ListenPacket("ip6:ipv6-icmp", "fe80::1%en0") -// ListenPacket("ip6:58", "::") -func ListenPacket(network, address string) (*PacketConn, error) { - return nil, errOpNoSupport -} diff --git a/vendor/golang.org/x/net/icmp/message.go b/vendor/golang.org/x/net/icmp/message.go deleted file mode 100644 index 81140b0df..000000000 --- a/vendor/golang.org/x/net/icmp/message.go +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package icmp provides basic functions for the manipulation of -// messages used in the Internet Control Message Protocols, -// ICMPv4 and ICMPv6. -// -// ICMPv4 and ICMPv6 are defined in RFC 792 and RFC 4443. -// Multi-part message support for ICMP is defined in RFC 4884. -// ICMP extensions for MPLS are defined in RFC 4950. -// ICMP extensions for interface and next-hop identification are -// defined in RFC 5837. -package icmp // import "golang.org/x/net/icmp" - -import ( - "encoding/binary" - "errors" - "net" - "syscall" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/ipv4" - "golang.org/x/net/ipv6" -) - -// BUG(mikio): This package is not implemented on NaCl and Plan 9. - -var ( - errMessageTooShort = errors.New("message too short") - errHeaderTooShort = errors.New("header too short") - errBufferTooShort = errors.New("buffer too short") - errOpNoSupport = errors.New("operation not supported") - errNoExtension = errors.New("no extension") - errInvalidExtension = errors.New("invalid extension") -) - -func checksum(b []byte) uint16 { - csumcv := len(b) - 1 // checksum coverage - s := uint32(0) - for i := 0; i < csumcv; i += 2 { - s += uint32(b[i+1])<<8 | uint32(b[i]) - } - if csumcv&1 == 0 { - s += uint32(b[csumcv]) - } - s = s>>16 + s&0xffff - s = s + s>>16 - return ^uint16(s) -} - -// A Type represents an ICMP message type. -type Type interface { - Protocol() int -} - -// A Message represents an ICMP message. -type Message struct { - Type Type // type, either ipv4.ICMPType or ipv6.ICMPType - Code int // code - Checksum int // checksum - Body MessageBody // body -} - -// Marshal returns the binary encoding of the ICMP message m. -// -// For an ICMPv4 message, the returned message always contains the -// calculated checksum field. -// -// For an ICMPv6 message, the returned message contains the calculated -// checksum field when psh is not nil, otherwise the kernel will -// compute the checksum field during the message transmission. -// When psh is not nil, it must be the pseudo header for IPv6. -func (m *Message) Marshal(psh []byte) ([]byte, error) { - var mtype int - switch typ := m.Type.(type) { - case ipv4.ICMPType: - mtype = int(typ) - case ipv6.ICMPType: - mtype = int(typ) - default: - return nil, syscall.EINVAL - } - b := []byte{byte(mtype), byte(m.Code), 0, 0} - if m.Type.Protocol() == iana.ProtocolIPv6ICMP && psh != nil { - b = append(psh, b...) - } - if m.Body != nil && m.Body.Len(m.Type.Protocol()) != 0 { - mb, err := m.Body.Marshal(m.Type.Protocol()) - if err != nil { - return nil, err - } - b = append(b, mb...) - } - if m.Type.Protocol() == iana.ProtocolIPv6ICMP { - if psh == nil { // cannot calculate checksum here - return b, nil - } - off, l := 2*net.IPv6len, len(b)-len(psh) - binary.BigEndian.PutUint32(b[off:off+4], uint32(l)) - } - s := checksum(b) - // Place checksum back in header; using ^= avoids the - // assumption the checksum bytes are zero. - b[len(psh)+2] ^= byte(s) - b[len(psh)+3] ^= byte(s >> 8) - return b[len(psh):], nil -} - -var parseFns = map[Type]func(int, []byte) (MessageBody, error){ - ipv4.ICMPTypeDestinationUnreachable: parseDstUnreach, - ipv4.ICMPTypeTimeExceeded: parseTimeExceeded, - ipv4.ICMPTypeParameterProblem: parseParamProb, - - ipv4.ICMPTypeEcho: parseEcho, - ipv4.ICMPTypeEchoReply: parseEcho, - - ipv6.ICMPTypeDestinationUnreachable: parseDstUnreach, - ipv6.ICMPTypePacketTooBig: parsePacketTooBig, - ipv6.ICMPTypeTimeExceeded: parseTimeExceeded, - ipv6.ICMPTypeParameterProblem: parseParamProb, - - ipv6.ICMPTypeEchoRequest: parseEcho, - ipv6.ICMPTypeEchoReply: parseEcho, -} - -// ParseMessage parses b as an ICMP message. -// Proto must be either the ICMPv4 or ICMPv6 protocol number. -func ParseMessage(proto int, b []byte) (*Message, error) { - if len(b) < 4 { - return nil, errMessageTooShort - } - var err error - m := &Message{Code: int(b[1]), Checksum: int(binary.BigEndian.Uint16(b[2:4]))} - switch proto { - case iana.ProtocolICMP: - m.Type = ipv4.ICMPType(b[0]) - case iana.ProtocolIPv6ICMP: - m.Type = ipv6.ICMPType(b[0]) - default: - return nil, syscall.EINVAL - } - if fn, ok := parseFns[m.Type]; !ok { - m.Body, err = parseDefaultMessageBody(proto, b[4:]) - } else { - m.Body, err = fn(proto, b[4:]) - } - if err != nil { - return nil, err - } - return m, nil -} diff --git a/vendor/golang.org/x/net/icmp/message_test.go b/vendor/golang.org/x/net/icmp/message_test.go deleted file mode 100644 index 5d2605f8d..000000000 --- a/vendor/golang.org/x/net/icmp/message_test.go +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp_test - -import ( - "net" - "reflect" - "testing" - - "golang.org/x/net/icmp" - "golang.org/x/net/internal/iana" - "golang.org/x/net/ipv4" - "golang.org/x/net/ipv6" -) - -var marshalAndParseMessageForIPv4Tests = []icmp.Message{ - { - Type: ipv4.ICMPTypeDestinationUnreachable, Code: 15, - Body: &icmp.DstUnreach{ - Data: []byte("ERROR-INVOKING-PACKET"), - }, - }, - { - Type: ipv4.ICMPTypeTimeExceeded, Code: 1, - Body: &icmp.TimeExceeded{ - Data: []byte("ERROR-INVOKING-PACKET"), - }, - }, - { - Type: ipv4.ICMPTypeParameterProblem, Code: 2, - Body: &icmp.ParamProb{ - Pointer: 8, - Data: []byte("ERROR-INVOKING-PACKET"), - }, - }, - { - Type: ipv4.ICMPTypeEcho, Code: 0, - Body: &icmp.Echo{ - ID: 1, Seq: 2, - Data: []byte("HELLO-R-U-THERE"), - }, - }, - { - Type: ipv4.ICMPTypePhoturis, - Body: &icmp.DefaultMessageBody{ - Data: []byte{0x80, 0x40, 0x20, 0x10}, - }, - }, -} - -func TestMarshalAndParseMessageForIPv4(t *testing.T) { - for i, tt := range marshalAndParseMessageForIPv4Tests { - b, err := tt.Marshal(nil) - if err != nil { - t.Fatal(err) - } - m, err := icmp.ParseMessage(iana.ProtocolICMP, b) - if err != nil { - t.Fatal(err) - } - if m.Type != tt.Type || m.Code != tt.Code { - t.Errorf("#%v: got %v; want %v", i, m, &tt) - } - if !reflect.DeepEqual(m.Body, tt.Body) { - t.Errorf("#%v: got %v; want %v", i, m.Body, tt.Body) - } - } -} - -var marshalAndParseMessageForIPv6Tests = []icmp.Message{ - { - Type: ipv6.ICMPTypeDestinationUnreachable, Code: 6, - Body: &icmp.DstUnreach{ - Data: []byte("ERROR-INVOKING-PACKET"), - }, - }, - { - Type: ipv6.ICMPTypePacketTooBig, Code: 0, - Body: &icmp.PacketTooBig{ - MTU: 1<<16 - 1, - Data: []byte("ERROR-INVOKING-PACKET"), - }, - }, - { - Type: ipv6.ICMPTypeTimeExceeded, Code: 1, - Body: &icmp.TimeExceeded{ - Data: []byte("ERROR-INVOKING-PACKET"), - }, - }, - { - Type: ipv6.ICMPTypeParameterProblem, Code: 2, - Body: &icmp.ParamProb{ - Pointer: 8, - Data: []byte("ERROR-INVOKING-PACKET"), - }, - }, - { - Type: ipv6.ICMPTypeEchoRequest, Code: 0, - Body: &icmp.Echo{ - ID: 1, Seq: 2, - Data: []byte("HELLO-R-U-THERE"), - }, - }, - { - Type: ipv6.ICMPTypeDuplicateAddressConfirmation, - Body: &icmp.DefaultMessageBody{ - Data: []byte{0x80, 0x40, 0x20, 0x10}, - }, - }, -} - -func TestMarshalAndParseMessageForIPv6(t *testing.T) { - pshicmp := icmp.IPv6PseudoHeader(net.ParseIP("fe80::1"), net.ParseIP("ff02::1")) - for i, tt := range marshalAndParseMessageForIPv6Tests { - for _, psh := range [][]byte{pshicmp, nil} { - b, err := tt.Marshal(psh) - if err != nil { - t.Fatal(err) - } - m, err := icmp.ParseMessage(iana.ProtocolIPv6ICMP, b) - if err != nil { - t.Fatal(err) - } - if m.Type != tt.Type || m.Code != tt.Code { - t.Errorf("#%v: got %v; want %v", i, m, &tt) - } - if !reflect.DeepEqual(m.Body, tt.Body) { - t.Errorf("#%v: got %v; want %v", i, m.Body, tt.Body) - } - } - } -} diff --git a/vendor/golang.org/x/net/icmp/messagebody.go b/vendor/golang.org/x/net/icmp/messagebody.go deleted file mode 100644 index 2463730ae..000000000 --- a/vendor/golang.org/x/net/icmp/messagebody.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -// A MessageBody represents an ICMP message body. -type MessageBody interface { - // Len returns the length of ICMP message body. - // Proto must be either the ICMPv4 or ICMPv6 protocol number. - Len(proto int) int - - // Marshal returns the binary encoding of ICMP message body. - // Proto must be either the ICMPv4 or ICMPv6 protocol number. - Marshal(proto int) ([]byte, error) -} - -// A DefaultMessageBody represents the default message body. -type DefaultMessageBody struct { - Data []byte // data -} - -// Len implements the Len method of MessageBody interface. -func (p *DefaultMessageBody) Len(proto int) int { - if p == nil { - return 0 - } - return len(p.Data) -} - -// Marshal implements the Marshal method of MessageBody interface. -func (p *DefaultMessageBody) Marshal(proto int) ([]byte, error) { - return p.Data, nil -} - -// parseDefaultMessageBody parses b as an ICMP message body. -func parseDefaultMessageBody(proto int, b []byte) (MessageBody, error) { - p := &DefaultMessageBody{Data: make([]byte, len(b))} - copy(p.Data, b) - return p, nil -} diff --git a/vendor/golang.org/x/net/icmp/mpls.go b/vendor/golang.org/x/net/icmp/mpls.go deleted file mode 100644 index c31491748..000000000 --- a/vendor/golang.org/x/net/icmp/mpls.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import "encoding/binary" - -// A MPLSLabel represents a MPLS label stack entry. -type MPLSLabel struct { - Label int // label value - TC int // traffic class; formerly experimental use - S bool // bottom of stack - TTL int // time to live -} - -const ( - classMPLSLabelStack = 1 - typeIncomingMPLSLabelStack = 1 -) - -// A MPLSLabelStack represents a MPLS label stack. -type MPLSLabelStack struct { - Class int // extension object class number - Type int // extension object sub-type - Labels []MPLSLabel -} - -// Len implements the Len method of Extension interface. -func (ls *MPLSLabelStack) Len(proto int) int { - return 4 + (4 * len(ls.Labels)) -} - -// Marshal implements the Marshal method of Extension interface. -func (ls *MPLSLabelStack) Marshal(proto int) ([]byte, error) { - b := make([]byte, ls.Len(proto)) - if err := ls.marshal(proto, b); err != nil { - return nil, err - } - return b, nil -} - -func (ls *MPLSLabelStack) marshal(proto int, b []byte) error { - l := ls.Len(proto) - binary.BigEndian.PutUint16(b[:2], uint16(l)) - b[2], b[3] = classMPLSLabelStack, typeIncomingMPLSLabelStack - off := 4 - for _, ll := range ls.Labels { - b[off], b[off+1], b[off+2] = byte(ll.Label>>12), byte(ll.Label>>4&0xff), byte(ll.Label<<4&0xf0) - b[off+2] |= byte(ll.TC << 1 & 0x0e) - if ll.S { - b[off+2] |= 0x1 - } - b[off+3] = byte(ll.TTL) - off += 4 - } - return nil -} - -func parseMPLSLabelStack(b []byte) (Extension, error) { - ls := &MPLSLabelStack{ - Class: int(b[2]), - Type: int(b[3]), - } - for b = b[4:]; len(b) >= 4; b = b[4:] { - ll := MPLSLabel{ - Label: int(b[0])<<12 | int(b[1])<<4 | int(b[2])>>4, - TC: int(b[2]&0x0e) >> 1, - TTL: int(b[3]), - } - if b[2]&0x1 != 0 { - ll.S = true - } - ls.Labels = append(ls.Labels, ll) - } - return ls, nil -} diff --git a/vendor/golang.org/x/net/icmp/multipart.go b/vendor/golang.org/x/net/icmp/multipart.go deleted file mode 100644 index f27135660..000000000 --- a/vendor/golang.org/x/net/icmp/multipart.go +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import "golang.org/x/net/internal/iana" - -// multipartMessageBodyDataLen takes b as an original datagram and -// exts as extensions, and returns a required length for message body -// and a required length for a padded original datagram in wire -// format. -func multipartMessageBodyDataLen(proto int, b []byte, exts []Extension) (bodyLen, dataLen int) { - for _, ext := range exts { - bodyLen += ext.Len(proto) - } - if bodyLen > 0 { - dataLen = multipartMessageOrigDatagramLen(proto, b) - bodyLen += 4 // length of extension header - } else { - dataLen = len(b) - } - bodyLen += dataLen - return bodyLen, dataLen -} - -// multipartMessageOrigDatagramLen takes b as an original datagram, -// and returns a required length for a padded orignal datagram in wire -// format. -func multipartMessageOrigDatagramLen(proto int, b []byte) int { - roundup := func(b []byte, align int) int { - // According to RFC 4884, the padded original datagram - // field must contain at least 128 octets. - if len(b) < 128 { - return 128 - } - r := len(b) - return (r + align - 1) & ^(align - 1) - } - switch proto { - case iana.ProtocolICMP: - return roundup(b, 4) - case iana.ProtocolIPv6ICMP: - return roundup(b, 8) - default: - return len(b) - } -} - -// marshalMultipartMessageBody takes data as an original datagram and -// exts as extesnsions, and returns a binary encoding of message body. -// It can be used for non-multipart message bodies when exts is nil. -func marshalMultipartMessageBody(proto int, data []byte, exts []Extension) ([]byte, error) { - bodyLen, dataLen := multipartMessageBodyDataLen(proto, data, exts) - b := make([]byte, 4+bodyLen) - copy(b[4:], data) - off := dataLen + 4 - if len(exts) > 0 { - b[dataLen+4] = byte(extensionVersion << 4) - off += 4 // length of object header - for _, ext := range exts { - switch ext := ext.(type) { - case *MPLSLabelStack: - if err := ext.marshal(proto, b[off:]); err != nil { - return nil, err - } - off += ext.Len(proto) - case *InterfaceInfo: - attrs, l := ext.attrsAndLen(proto) - if err := ext.marshal(proto, b[off:], attrs, l); err != nil { - return nil, err - } - off += ext.Len(proto) - } - } - s := checksum(b[dataLen+4:]) - b[dataLen+4+2] ^= byte(s) - b[dataLen+4+3] ^= byte(s >> 8) - switch proto { - case iana.ProtocolICMP: - b[1] = byte(dataLen / 4) - case iana.ProtocolIPv6ICMP: - b[0] = byte(dataLen / 8) - } - } - return b, nil -} - -// parseMultipartMessageBody parses b as either a non-multipart -// message body or a multipart message body. -func parseMultipartMessageBody(proto int, b []byte) ([]byte, []Extension, error) { - var l int - switch proto { - case iana.ProtocolICMP: - l = 4 * int(b[1]) - case iana.ProtocolIPv6ICMP: - l = 8 * int(b[0]) - } - if len(b) == 4 { - return nil, nil, nil - } - exts, l, err := parseExtensions(b[4:], l) - if err != nil { - l = len(b) - 4 - } - data := make([]byte, l) - copy(data, b[4:]) - return data, exts, nil -} diff --git a/vendor/golang.org/x/net/icmp/multipart_test.go b/vendor/golang.org/x/net/icmp/multipart_test.go deleted file mode 100644 index 966ccb8da..000000000 --- a/vendor/golang.org/x/net/icmp/multipart_test.go +++ /dev/null @@ -1,442 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp_test - -import ( - "fmt" - "net" - "reflect" - "testing" - - "golang.org/x/net/icmp" - "golang.org/x/net/internal/iana" - "golang.org/x/net/ipv4" - "golang.org/x/net/ipv6" -) - -var marshalAndParseMultipartMessageForIPv4Tests = []icmp.Message{ - { - Type: ipv4.ICMPTypeDestinationUnreachable, Code: 15, - Body: &icmp.DstUnreach{ - Data: []byte("ERROR-INVOKING-PACKET"), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{ - Class: 1, - Type: 1, - Labels: []icmp.MPLSLabel{ - { - Label: 16014, - TC: 0x4, - S: true, - TTL: 255, - }, - }, - }, - &icmp.InterfaceInfo{ - Class: 2, - Type: 0x0f, - Interface: &net.Interface{ - Index: 15, - Name: "en101", - MTU: 8192, - }, - Addr: &net.IPAddr{ - IP: net.IPv4(192, 168, 0, 1).To4(), - }, - }, - }, - }, - }, - { - Type: ipv4.ICMPTypeTimeExceeded, Code: 1, - Body: &icmp.TimeExceeded{ - Data: []byte("ERROR-INVOKING-PACKET"), - Extensions: []icmp.Extension{ - &icmp.InterfaceInfo{ - Class: 2, - Type: 0x0f, - Interface: &net.Interface{ - Index: 15, - Name: "en101", - MTU: 8192, - }, - Addr: &net.IPAddr{ - IP: net.IPv4(192, 168, 0, 1).To4(), - }, - }, - &icmp.MPLSLabelStack{ - Class: 1, - Type: 1, - Labels: []icmp.MPLSLabel{ - { - Label: 16014, - TC: 0x4, - S: true, - TTL: 255, - }, - }, - }, - }, - }, - }, - { - Type: ipv4.ICMPTypeParameterProblem, Code: 2, - Body: &icmp.ParamProb{ - Pointer: 8, - Data: []byte("ERROR-INVOKING-PACKET"), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{ - Class: 1, - Type: 1, - Labels: []icmp.MPLSLabel{ - { - Label: 16014, - TC: 0x4, - S: true, - TTL: 255, - }, - }, - }, - &icmp.InterfaceInfo{ - Class: 2, - Type: 0x0f, - Interface: &net.Interface{ - Index: 15, - Name: "en101", - MTU: 8192, - }, - Addr: &net.IPAddr{ - IP: net.IPv4(192, 168, 0, 1).To4(), - }, - }, - &icmp.InterfaceInfo{ - Class: 2, - Type: 0x2f, - Interface: &net.Interface{ - Index: 16, - Name: "en102", - MTU: 8192, - }, - Addr: &net.IPAddr{ - IP: net.IPv4(192, 168, 0, 2).To4(), - }, - }, - }, - }, - }, -} - -func TestMarshalAndParseMultipartMessageForIPv4(t *testing.T) { - for i, tt := range marshalAndParseMultipartMessageForIPv4Tests { - b, err := tt.Marshal(nil) - if err != nil { - t.Fatal(err) - } - if b[5] != 32 { - t.Errorf("#%v: got %v; want 32", i, b[5]) - } - m, err := icmp.ParseMessage(iana.ProtocolICMP, b) - if err != nil { - t.Fatal(err) - } - if m.Type != tt.Type || m.Code != tt.Code { - t.Errorf("#%v: got %v; want %v", i, m, &tt) - } - switch m.Type { - case ipv4.ICMPTypeDestinationUnreachable: - got, want := m.Body.(*icmp.DstUnreach), tt.Body.(*icmp.DstUnreach) - if !reflect.DeepEqual(got.Extensions, want.Extensions) { - t.Error(dumpExtensions(i, got.Extensions, want.Extensions)) - } - if len(got.Data) != 128 { - t.Errorf("#%v: got %v; want 128", i, len(got.Data)) - } - case ipv4.ICMPTypeTimeExceeded: - got, want := m.Body.(*icmp.TimeExceeded), tt.Body.(*icmp.TimeExceeded) - if !reflect.DeepEqual(got.Extensions, want.Extensions) { - t.Error(dumpExtensions(i, got.Extensions, want.Extensions)) - } - if len(got.Data) != 128 { - t.Errorf("#%v: got %v; want 128", i, len(got.Data)) - } - case ipv4.ICMPTypeParameterProblem: - got, want := m.Body.(*icmp.ParamProb), tt.Body.(*icmp.ParamProb) - if !reflect.DeepEqual(got.Extensions, want.Extensions) { - t.Error(dumpExtensions(i, got.Extensions, want.Extensions)) - } - if len(got.Data) != 128 { - t.Errorf("#%v: got %v; want 128", i, len(got.Data)) - } - } - } -} - -var marshalAndParseMultipartMessageForIPv6Tests = []icmp.Message{ - { - Type: ipv6.ICMPTypeDestinationUnreachable, Code: 6, - Body: &icmp.DstUnreach{ - Data: []byte("ERROR-INVOKING-PACKET"), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{ - Class: 1, - Type: 1, - Labels: []icmp.MPLSLabel{ - { - Label: 16014, - TC: 0x4, - S: true, - TTL: 255, - }, - }, - }, - &icmp.InterfaceInfo{ - Class: 2, - Type: 0x0f, - Interface: &net.Interface{ - Index: 15, - Name: "en101", - MTU: 8192, - }, - Addr: &net.IPAddr{ - IP: net.ParseIP("fe80::1"), - Zone: "en101", - }, - }, - }, - }, - }, - { - Type: ipv6.ICMPTypeTimeExceeded, Code: 1, - Body: &icmp.TimeExceeded{ - Data: []byte("ERROR-INVOKING-PACKET"), - Extensions: []icmp.Extension{ - &icmp.InterfaceInfo{ - Class: 2, - Type: 0x0f, - Interface: &net.Interface{ - Index: 15, - Name: "en101", - MTU: 8192, - }, - Addr: &net.IPAddr{ - IP: net.ParseIP("fe80::1"), - Zone: "en101", - }, - }, - &icmp.MPLSLabelStack{ - Class: 1, - Type: 1, - Labels: []icmp.MPLSLabel{ - { - Label: 16014, - TC: 0x4, - S: true, - TTL: 255, - }, - }, - }, - &icmp.InterfaceInfo{ - Class: 2, - Type: 0x2f, - Interface: &net.Interface{ - Index: 16, - Name: "en102", - MTU: 8192, - }, - Addr: &net.IPAddr{ - IP: net.ParseIP("fe80::1"), - Zone: "en102", - }, - }, - }, - }, - }, -} - -func TestMarshalAndParseMultipartMessageForIPv6(t *testing.T) { - pshicmp := icmp.IPv6PseudoHeader(net.ParseIP("fe80::1"), net.ParseIP("ff02::1")) - for i, tt := range marshalAndParseMultipartMessageForIPv6Tests { - for _, psh := range [][]byte{pshicmp, nil} { - b, err := tt.Marshal(psh) - if err != nil { - t.Fatal(err) - } - if b[4] != 16 { - t.Errorf("#%v: got %v; want 16", i, b[4]) - } - m, err := icmp.ParseMessage(iana.ProtocolIPv6ICMP, b) - if err != nil { - t.Fatal(err) - } - if m.Type != tt.Type || m.Code != tt.Code { - t.Errorf("#%v: got %v; want %v", i, m, &tt) - } - switch m.Type { - case ipv6.ICMPTypeDestinationUnreachable: - got, want := m.Body.(*icmp.DstUnreach), tt.Body.(*icmp.DstUnreach) - if !reflect.DeepEqual(got.Extensions, want.Extensions) { - t.Error(dumpExtensions(i, got.Extensions, want.Extensions)) - } - if len(got.Data) != 128 { - t.Errorf("#%v: got %v; want 128", i, len(got.Data)) - } - case ipv6.ICMPTypeTimeExceeded: - got, want := m.Body.(*icmp.TimeExceeded), tt.Body.(*icmp.TimeExceeded) - if !reflect.DeepEqual(got.Extensions, want.Extensions) { - t.Error(dumpExtensions(i, got.Extensions, want.Extensions)) - } - if len(got.Data) != 128 { - t.Errorf("#%v: got %v; want 128", i, len(got.Data)) - } - } - } - } -} - -func dumpExtensions(i int, gotExts, wantExts []icmp.Extension) string { - var s string - for j, got := range gotExts { - switch got := got.(type) { - case *icmp.MPLSLabelStack: - want := wantExts[j].(*icmp.MPLSLabelStack) - if !reflect.DeepEqual(got, want) { - s += fmt.Sprintf("#%v/%v: got %#v; want %#v\n", i, j, got, want) - } - case *icmp.InterfaceInfo: - want := wantExts[j].(*icmp.InterfaceInfo) - if !reflect.DeepEqual(got, want) { - s += fmt.Sprintf("#%v/%v: got %#v, %#v, %#v; want %#v, %#v, %#v\n", i, j, got, got.Interface, got.Addr, want, want.Interface, want.Addr) - } - } - } - return s[:len(s)-1] -} - -var multipartMessageBodyLenTests = []struct { - proto int - in icmp.MessageBody - out int -}{ - { - iana.ProtocolICMP, - &icmp.DstUnreach{ - Data: make([]byte, ipv4.HeaderLen), - }, - 4 + ipv4.HeaderLen, // unused and original datagram - }, - { - iana.ProtocolICMP, - &icmp.TimeExceeded{ - Data: make([]byte, ipv4.HeaderLen), - }, - 4 + ipv4.HeaderLen, // unused and original datagram - }, - { - iana.ProtocolICMP, - &icmp.ParamProb{ - Data: make([]byte, ipv4.HeaderLen), - }, - 4 + ipv4.HeaderLen, // [pointer, unused] and original datagram - }, - - { - iana.ProtocolICMP, - &icmp.ParamProb{ - Data: make([]byte, ipv4.HeaderLen), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{}, - }, - }, - 4 + 4 + 4 + 0 + 128, // [pointer, length, unused], extension header, object header, object payload, original datagram - }, - { - iana.ProtocolICMP, - &icmp.ParamProb{ - Data: make([]byte, 128), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{}, - }, - }, - 4 + 4 + 4 + 0 + 128, // [pointer, length, unused], extension header, object header, object payload and original datagram - }, - { - iana.ProtocolICMP, - &icmp.ParamProb{ - Data: make([]byte, 129), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{}, - }, - }, - 4 + 4 + 4 + 0 + 132, // [pointer, length, unused], extension header, object header, object payload and original datagram - }, - - { - iana.ProtocolIPv6ICMP, - &icmp.DstUnreach{ - Data: make([]byte, ipv6.HeaderLen), - }, - 4 + ipv6.HeaderLen, // unused and original datagram - }, - { - iana.ProtocolIPv6ICMP, - &icmp.PacketTooBig{ - Data: make([]byte, ipv6.HeaderLen), - }, - 4 + ipv6.HeaderLen, // mtu and original datagram - }, - { - iana.ProtocolIPv6ICMP, - &icmp.TimeExceeded{ - Data: make([]byte, ipv6.HeaderLen), - }, - 4 + ipv6.HeaderLen, // unused and original datagram - }, - { - iana.ProtocolIPv6ICMP, - &icmp.ParamProb{ - Data: make([]byte, ipv6.HeaderLen), - }, - 4 + ipv6.HeaderLen, // pointer and original datagram - }, - - { - iana.ProtocolIPv6ICMP, - &icmp.DstUnreach{ - Data: make([]byte, 127), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{}, - }, - }, - 4 + 4 + 4 + 0 + 128, // [length, unused], extension header, object header, object payload and original datagram - }, - { - iana.ProtocolIPv6ICMP, - &icmp.DstUnreach{ - Data: make([]byte, 128), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{}, - }, - }, - 4 + 4 + 4 + 0 + 128, // [length, unused], extension header, object header, object payload and original datagram - }, - { - iana.ProtocolIPv6ICMP, - &icmp.DstUnreach{ - Data: make([]byte, 129), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{}, - }, - }, - 4 + 4 + 4 + 0 + 136, // [length, unused], extension header, object header, object payload and original datagram - }, -} - -func TestMultipartMessageBodyLen(t *testing.T) { - for i, tt := range multipartMessageBodyLenTests { - if out := tt.in.Len(tt.proto); out != tt.out { - t.Errorf("#%d: got %d; want %d", i, out, tt.out) - } - } -} diff --git a/vendor/golang.org/x/net/icmp/packettoobig.go b/vendor/golang.org/x/net/icmp/packettoobig.go deleted file mode 100644 index a1c9df7bf..000000000 --- a/vendor/golang.org/x/net/icmp/packettoobig.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import "encoding/binary" - -// A PacketTooBig represents an ICMP packet too big message body. -type PacketTooBig struct { - MTU int // maximum transmission unit of the nexthop link - Data []byte // data, known as original datagram field -} - -// Len implements the Len method of MessageBody interface. -func (p *PacketTooBig) Len(proto int) int { - if p == nil { - return 0 - } - return 4 + len(p.Data) -} - -// Marshal implements the Marshal method of MessageBody interface. -func (p *PacketTooBig) Marshal(proto int) ([]byte, error) { - b := make([]byte, 4+len(p.Data)) - binary.BigEndian.PutUint32(b[:4], uint32(p.MTU)) - copy(b[4:], p.Data) - return b, nil -} - -// parsePacketTooBig parses b as an ICMP packet too big message body. -func parsePacketTooBig(proto int, b []byte) (MessageBody, error) { - bodyLen := len(b) - if bodyLen < 4 { - return nil, errMessageTooShort - } - p := &PacketTooBig{MTU: int(binary.BigEndian.Uint32(b[:4]))} - if bodyLen > 4 { - p.Data = make([]byte, bodyLen-4) - copy(p.Data, b[4:]) - } - return p, nil -} diff --git a/vendor/golang.org/x/net/icmp/paramprob.go b/vendor/golang.org/x/net/icmp/paramprob.go deleted file mode 100644 index 0a2548daa..000000000 --- a/vendor/golang.org/x/net/icmp/paramprob.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import ( - "encoding/binary" - "golang.org/x/net/internal/iana" -) - -// A ParamProb represents an ICMP parameter problem message body. -type ParamProb struct { - Pointer uintptr // offset within the data where the error was detected - Data []byte // data, known as original datagram field - Extensions []Extension // extensions -} - -// Len implements the Len method of MessageBody interface. -func (p *ParamProb) Len(proto int) int { - if p == nil { - return 0 - } - l, _ := multipartMessageBodyDataLen(proto, p.Data, p.Extensions) - return 4 + l -} - -// Marshal implements the Marshal method of MessageBody interface. -func (p *ParamProb) Marshal(proto int) ([]byte, error) { - if proto == iana.ProtocolIPv6ICMP { - b := make([]byte, p.Len(proto)) - binary.BigEndian.PutUint32(b[:4], uint32(p.Pointer)) - copy(b[4:], p.Data) - return b, nil - } - b, err := marshalMultipartMessageBody(proto, p.Data, p.Extensions) - if err != nil { - return nil, err - } - b[0] = byte(p.Pointer) - return b, nil -} - -// parseParamProb parses b as an ICMP parameter problem message body. -func parseParamProb(proto int, b []byte) (MessageBody, error) { - if len(b) < 4 { - return nil, errMessageTooShort - } - p := &ParamProb{} - if proto == iana.ProtocolIPv6ICMP { - p.Pointer = uintptr(binary.BigEndian.Uint32(b[:4])) - p.Data = make([]byte, len(b)-4) - copy(p.Data, b[4:]) - return p, nil - } - p.Pointer = uintptr(b[0]) - var err error - p.Data, p.Extensions, err = parseMultipartMessageBody(proto, b) - if err != nil { - return nil, err - } - return p, nil -} diff --git a/vendor/golang.org/x/net/icmp/ping_test.go b/vendor/golang.org/x/net/icmp/ping_test.go deleted file mode 100644 index 3171dad11..000000000 --- a/vendor/golang.org/x/net/icmp/ping_test.go +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp_test - -import ( - "errors" - "fmt" - "net" - "os" - "runtime" - "sync" - "testing" - "time" - - "golang.org/x/net/icmp" - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv4" - "golang.org/x/net/ipv6" -) - -func googleAddr(c *icmp.PacketConn, protocol int) (net.Addr, error) { - const host = "www.google.com" - ips, err := net.LookupIP(host) - if err != nil { - return nil, err - } - netaddr := func(ip net.IP) (net.Addr, error) { - switch c.LocalAddr().(type) { - case *net.UDPAddr: - return &net.UDPAddr{IP: ip}, nil - case *net.IPAddr: - return &net.IPAddr{IP: ip}, nil - default: - return nil, errors.New("neither UDPAddr nor IPAddr") - } - } - for _, ip := range ips { - switch protocol { - case iana.ProtocolICMP: - if ip.To4() != nil { - return netaddr(ip) - } - case iana.ProtocolIPv6ICMP: - if ip.To16() != nil && ip.To4() == nil { - return netaddr(ip) - } - } - } - return nil, errors.New("no A or AAAA record") -} - -type pingTest struct { - network, address string - protocol int - mtype icmp.Type -} - -var nonPrivilegedPingTests = []pingTest{ - {"udp4", "0.0.0.0", iana.ProtocolICMP, ipv4.ICMPTypeEcho}, - - {"udp6", "::", iana.ProtocolIPv6ICMP, ipv6.ICMPTypeEchoRequest}, -} - -func TestNonPrivilegedPing(t *testing.T) { - if testing.Short() { - t.Skip("avoid external network") - } - switch runtime.GOOS { - case "darwin": - case "linux": - t.Log("you may need to adjust the net.ipv4.ping_group_range kernel state") - default: - t.Skipf("not supported on %s", runtime.GOOS) - } - - for i, tt := range nonPrivilegedPingTests { - if err := doPing(tt, i); err != nil { - t.Error(err) - } - } -} - -var privilegedPingTests = []pingTest{ - {"ip4:icmp", "0.0.0.0", iana.ProtocolICMP, ipv4.ICMPTypeEcho}, - - {"ip6:ipv6-icmp", "::", iana.ProtocolIPv6ICMP, ipv6.ICMPTypeEchoRequest}, -} - -func TestPrivilegedPing(t *testing.T) { - if testing.Short() { - t.Skip("avoid external network") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - for i, tt := range privilegedPingTests { - if err := doPing(tt, i); err != nil { - t.Error(err) - } - } -} - -func doPing(tt pingTest, seq int) error { - c, err := icmp.ListenPacket(tt.network, tt.address) - if err != nil { - return err - } - defer c.Close() - - dst, err := googleAddr(c, tt.protocol) - if err != nil { - return err - } - - if tt.network != "udp6" && tt.protocol == iana.ProtocolIPv6ICMP { - var f ipv6.ICMPFilter - f.SetAll(true) - f.Accept(ipv6.ICMPTypeDestinationUnreachable) - f.Accept(ipv6.ICMPTypePacketTooBig) - f.Accept(ipv6.ICMPTypeTimeExceeded) - f.Accept(ipv6.ICMPTypeParameterProblem) - f.Accept(ipv6.ICMPTypeEchoReply) - if err := c.IPv6PacketConn().SetICMPFilter(&f); err != nil { - return err - } - } - - wm := icmp.Message{ - Type: tt.mtype, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, Seq: 1 << uint(seq), - Data: []byte("HELLO-R-U-THERE"), - }, - } - wb, err := wm.Marshal(nil) - if err != nil { - return err - } - if n, err := c.WriteTo(wb, dst); err != nil { - return err - } else if n != len(wb) { - return fmt.Errorf("got %v; want %v", n, len(wb)) - } - - rb := make([]byte, 1500) - if err := c.SetReadDeadline(time.Now().Add(3 * time.Second)); err != nil { - return err - } - n, peer, err := c.ReadFrom(rb) - if err != nil { - return err - } - rm, err := icmp.ParseMessage(tt.protocol, rb[:n]) - if err != nil { - return err - } - switch rm.Type { - case ipv4.ICMPTypeEchoReply, ipv6.ICMPTypeEchoReply: - return nil - default: - return fmt.Errorf("got %+v from %v; want echo reply", rm, peer) - } -} - -func TestConcurrentNonPrivilegedListenPacket(t *testing.T) { - if testing.Short() { - t.Skip("avoid external network") - } - switch runtime.GOOS { - case "darwin": - case "linux": - t.Log("you may need to adjust the net.ipv4.ping_group_range kernel state") - default: - t.Skipf("not supported on %s", runtime.GOOS) - } - - network, address := "udp4", "127.0.0.1" - if !nettest.SupportsIPv4() { - network, address = "udp6", "::1" - } - const N = 1000 - var wg sync.WaitGroup - wg.Add(N) - for i := 0; i < N; i++ { - go func() { - defer wg.Done() - c, err := icmp.ListenPacket(network, address) - if err != nil { - t.Error(err) - return - } - c.Close() - }() - } - wg.Wait() -} diff --git a/vendor/golang.org/x/net/icmp/sys_freebsd.go b/vendor/golang.org/x/net/icmp/sys_freebsd.go deleted file mode 100644 index c75f3ddaa..000000000 --- a/vendor/golang.org/x/net/icmp/sys_freebsd.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import "syscall" - -func init() { - freebsdVersion, _ = syscall.SysctlUint32("kern.osreldate") -} diff --git a/vendor/golang.org/x/net/icmp/timeexceeded.go b/vendor/golang.org/x/net/icmp/timeexceeded.go deleted file mode 100644 index 344e15848..000000000 --- a/vendor/golang.org/x/net/icmp/timeexceeded.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -// A TimeExceeded represents an ICMP time exceeded message body. -type TimeExceeded struct { - Data []byte // data, known as original datagram field - Extensions []Extension // extensions -} - -// Len implements the Len method of MessageBody interface. -func (p *TimeExceeded) Len(proto int) int { - if p == nil { - return 0 - } - l, _ := multipartMessageBodyDataLen(proto, p.Data, p.Extensions) - return 4 + l -} - -// Marshal implements the Marshal method of MessageBody interface. -func (p *TimeExceeded) Marshal(proto int) ([]byte, error) { - return marshalMultipartMessageBody(proto, p.Data, p.Extensions) -} - -// parseTimeExceeded parses b as an ICMP time exceeded message body. -func parseTimeExceeded(proto int, b []byte) (MessageBody, error) { - if len(b) < 4 { - return nil, errMessageTooShort - } - p := &TimeExceeded{} - var err error - p.Data, p.Extensions, err = parseMultipartMessageBody(proto, b) - if err != nil { - return nil, err - } - return p, nil -} diff --git a/vendor/golang.org/x/net/idna/example_test.go b/vendor/golang.org/x/net/idna/example_test.go deleted file mode 100644 index 941e707d8..000000000 --- a/vendor/golang.org/x/net/idna/example_test.go +++ /dev/null @@ -1,65 +0,0 @@ -// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. - -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package idna_test - -import ( - "fmt" - - "golang.org/x/net/idna" -) - -func ExampleProfile() { - // Raw Punycode has no restrictions and does no mappings. - fmt.Println(idna.ToASCII("")) - fmt.Println(idna.ToASCII("*.faß.com")) - fmt.Println(idna.Punycode.ToASCII("*.faß.com")) - - // Rewrite IDN for lookup. This (currently) uses transitional mappings to - // find a balance between IDNA2003 and IDNA2008 compatibility. - fmt.Println(idna.Lookup.ToASCII("")) - fmt.Println(idna.Lookup.ToASCII("www.faß.com")) - - // Convert an IDN to ASCII for registration purposes. This changes the - // encoding, but reports an error if the input was illformed. - fmt.Println(idna.Registration.ToASCII("")) - fmt.Println(idna.Registration.ToASCII("www.faß.com")) - - // Output: - // - // *.xn--fa-hia.com - // *.xn--fa-hia.com - // - // www.fass.com - // idna: invalid label "" - // www.xn--fa-hia.com -} - -func ExampleNew() { - var p *idna.Profile - - // Raw Punycode has no restrictions and does no mappings. - p = idna.New() - fmt.Println(p.ToASCII("*.faß.com")) - - // Do mappings. Note that star is not allowed in a DNS lookup. - p = idna.New( - idna.MapForLookup(), - idna.Transitional(true)) // Map ß -> ss - fmt.Println(p.ToASCII("*.faß.com")) - - // Set up a profile maps for lookup, but allows wild cards. - p = idna.New( - idna.MapForLookup(), - idna.Transitional(true), // Map ß -> ss - idna.StrictDomainName(false)) // Set more permissive ASCII rules. - fmt.Println(p.ToASCII("*.faß.com")) - - // Output: - // *.xn--fa-hia.com - // *.fass.com idna: disallowed rune U+002E - // *.fass.com -} diff --git a/vendor/golang.org/x/net/idna/idna.go b/vendor/golang.org/x/net/idna/idna.go deleted file mode 100644 index ee2dbda6d..000000000 --- a/vendor/golang.org/x/net/idna/idna.go +++ /dev/null @@ -1,668 +0,0 @@ -// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. - -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package idna implements IDNA2008 using the compatibility processing -// defined by UTS (Unicode Technical Standard) #46, which defines a standard to -// deal with the transition from IDNA2003. -// -// IDNA2008 (Internationalized Domain Names for Applications), is defined in RFC -// 5890, RFC 5891, RFC 5892, RFC 5893 and RFC 5894. -// UTS #46 is defined in http://www.unicode.org/reports/tr46. -// See http://unicode.org/cldr/utility/idna.jsp for a visualization of the -// differences between these two standards. -package idna // import "golang.org/x/net/idna" - -import ( - "fmt" - "strings" - "unicode/utf8" - - "golang.org/x/text/secure/bidirule" - "golang.org/x/text/unicode/norm" -) - -// NOTE: Unlike common practice in Go APIs, the functions will return a -// sanitized domain name in case of errors. Browsers sometimes use a partially -// evaluated string as lookup. -// TODO: the current error handling is, in my opinion, the least opinionated. -// Other strategies are also viable, though: -// Option 1) Return an empty string in case of error, but allow the user to -// specify explicitly which errors to ignore. -// Option 2) Return the partially evaluated string if it is itself a valid -// string, otherwise return the empty string in case of error. -// Option 3) Option 1 and 2. -// Option 4) Always return an empty string for now and implement Option 1 as -// needed, and document that the return string may not be empty in case of -// error in the future. -// I think Option 1 is best, but it is quite opinionated. - -// ToASCII is a wrapper for Punycode.ToASCII. -func ToASCII(s string) (string, error) { - return Punycode.process(s, true) -} - -// ToUnicode is a wrapper for Punycode.ToUnicode. -func ToUnicode(s string) (string, error) { - return Punycode.process(s, false) -} - -// An Option configures a Profile at creation time. -type Option func(*options) - -// Transitional sets a Profile to use the Transitional mapping as defined in UTS -// #46. This will cause, for example, "ß" to be mapped to "ss". Using the -// transitional mapping provides a compromise between IDNA2003 and IDNA2008 -// compatibility. It is used by most browsers when resolving domain names. This -// option is only meaningful if combined with MapForLookup. -func Transitional(transitional bool) Option { - return func(o *options) { o.transitional = true } -} - -// VerifyDNSLength sets whether a Profile should fail if any of the IDN parts -// are longer than allowed by the RFC. -func VerifyDNSLength(verify bool) Option { - return func(o *options) { o.verifyDNSLength = verify } -} - -// ValidateLabels sets whether to check the mandatory label validation criteria -// as defined in Section 5.4 of RFC 5891. This includes testing for correct use -// of hyphens ('-'), normalization, validity of runes, and the context rules. -func ValidateLabels(enable bool) Option { - return func(o *options) { - // Don't override existing mappings, but set one that at least checks - // normalization if it is not set. - if o.mapping == nil && enable { - o.mapping = normalize - } - o.trie = trie - o.validateLabels = enable - o.fromPuny = validateFromPunycode - } -} - -// StrictDomainName limits the set of permissable ASCII characters to those -// allowed in domain names as defined in RFC 1034 (A-Z, a-z, 0-9 and the -// hyphen). This is set by default for MapForLookup and ValidateForRegistration. -// -// This option is useful, for instance, for browsers that allow characters -// outside this range, for example a '_' (U+005F LOW LINE). See -// http://www.rfc-editor.org/std/std3.txt for more details This option -// corresponds to the UseSTD3ASCIIRules option in UTS #46. -func StrictDomainName(use bool) Option { - return func(o *options) { - o.trie = trie - o.useSTD3Rules = use - o.fromPuny = validateFromPunycode - } -} - -// NOTE: the following options pull in tables. The tables should not be linked -// in as long as the options are not used. - -// BidiRule enables the Bidi rule as defined in RFC 5893. Any application -// that relies on proper validation of labels should include this rule. -func BidiRule() Option { - return func(o *options) { o.bidirule = bidirule.ValidString } -} - -// ValidateForRegistration sets validation options to verify that a given IDN is -// properly formatted for registration as defined by Section 4 of RFC 5891. -func ValidateForRegistration() Option { - return func(o *options) { - o.mapping = validateRegistration - StrictDomainName(true)(o) - ValidateLabels(true)(o) - VerifyDNSLength(true)(o) - BidiRule()(o) - } -} - -// MapForLookup sets validation and mapping options such that a given IDN is -// transformed for domain name lookup according to the requirements set out in -// Section 5 of RFC 5891. The mappings follow the recommendations of RFC 5894, -// RFC 5895 and UTS 46. It does not add the Bidi Rule. Use the BidiRule option -// to add this check. -// -// The mappings include normalization and mapping case, width and other -// compatibility mappings. -func MapForLookup() Option { - return func(o *options) { - o.mapping = validateAndMap - StrictDomainName(true)(o) - ValidateLabels(true)(o) - } -} - -type options struct { - transitional bool - useSTD3Rules bool - validateLabels bool - verifyDNSLength bool - - trie *idnaTrie - - // fromPuny calls validation rules when converting A-labels to U-labels. - fromPuny func(p *Profile, s string) error - - // mapping implements a validation and mapping step as defined in RFC 5895 - // or UTS 46, tailored to, for example, domain registration or lookup. - mapping func(p *Profile, s string) (string, error) - - // bidirule, if specified, checks whether s conforms to the Bidi Rule - // defined in RFC 5893. - bidirule func(s string) bool -} - -// A Profile defines the configuration of a IDNA mapper. -type Profile struct { - options -} - -func apply(o *options, opts []Option) { - for _, f := range opts { - f(o) - } -} - -// New creates a new Profile. -// -// With no options, the returned Profile is the most permissive and equals the -// Punycode Profile. Options can be passed to further restrict the Profile. The -// MapForLookup and ValidateForRegistration options set a collection of options, -// for lookup and registration purposes respectively, which can be tailored by -// adding more fine-grained options, where later options override earlier -// options. -func New(o ...Option) *Profile { - p := &Profile{} - apply(&p.options, o) - return p -} - -// ToASCII converts a domain or domain label to its ASCII form. For example, -// ToASCII("bücher.example.com") is "xn--bcher-kva.example.com", and -// ToASCII("golang") is "golang". If an error is encountered it will return -// an error and a (partially) processed result. -func (p *Profile) ToASCII(s string) (string, error) { - return p.process(s, true) -} - -// ToUnicode converts a domain or domain label to its Unicode form. For example, -// ToUnicode("xn--bcher-kva.example.com") is "bücher.example.com", and -// ToUnicode("golang") is "golang". If an error is encountered it will return -// an error and a (partially) processed result. -func (p *Profile) ToUnicode(s string) (string, error) { - pp := *p - pp.transitional = false - return pp.process(s, false) -} - -// String reports a string with a description of the profile for debugging -// purposes. The string format may change with different versions. -func (p *Profile) String() string { - s := "" - if p.transitional { - s = "Transitional" - } else { - s = "NonTransitional" - } - if p.useSTD3Rules { - s += ":UseSTD3Rules" - } - if p.validateLabels { - s += ":ValidateLabels" - } - if p.verifyDNSLength { - s += ":VerifyDNSLength" - } - return s -} - -var ( - // Punycode is a Profile that does raw punycode processing with a minimum - // of validation. - Punycode *Profile = punycode - - // Lookup is the recommended profile for looking up domain names, according - // to Section 5 of RFC 5891. The exact configuration of this profile may - // change over time. - Lookup *Profile = lookup - - // Display is the recommended profile for displaying domain names. - // The configuration of this profile may change over time. - Display *Profile = display - - // Registration is the recommended profile for checking whether a given - // IDN is valid for registration, according to Section 4 of RFC 5891. - Registration *Profile = registration - - punycode = &Profile{} - lookup = &Profile{options{ - transitional: true, - useSTD3Rules: true, - validateLabels: true, - trie: trie, - fromPuny: validateFromPunycode, - mapping: validateAndMap, - bidirule: bidirule.ValidString, - }} - display = &Profile{options{ - useSTD3Rules: true, - validateLabels: true, - trie: trie, - fromPuny: validateFromPunycode, - mapping: validateAndMap, - bidirule: bidirule.ValidString, - }} - registration = &Profile{options{ - useSTD3Rules: true, - validateLabels: true, - verifyDNSLength: true, - trie: trie, - fromPuny: validateFromPunycode, - mapping: validateRegistration, - bidirule: bidirule.ValidString, - }} - - // TODO: profiles - // Register: recommended for approving domain names: don't do any mappings - // but rather reject on invalid input. Bundle or block deviation characters. -) - -type labelError struct{ label, code_ string } - -func (e labelError) code() string { return e.code_ } -func (e labelError) Error() string { - return fmt.Sprintf("idna: invalid label %q", e.label) -} - -type runeError rune - -func (e runeError) code() string { return "P1" } -func (e runeError) Error() string { - return fmt.Sprintf("idna: disallowed rune %U", e) -} - -// process implements the algorithm described in section 4 of UTS #46, -// see http://www.unicode.org/reports/tr46. -func (p *Profile) process(s string, toASCII bool) (string, error) { - var err error - if p.mapping != nil { - s, err = p.mapping(p, s) - } - // Remove leading empty labels. - for ; len(s) > 0 && s[0] == '.'; s = s[1:] { - } - // It seems like we should only create this error on ToASCII, but the - // UTS 46 conformance tests suggests we should always check this. - if err == nil && p.verifyDNSLength && s == "" { - err = &labelError{s, "A4"} - } - labels := labelIter{orig: s} - for ; !labels.done(); labels.next() { - label := labels.label() - if label == "" { - // Empty labels are not okay. The label iterator skips the last - // label if it is empty. - if err == nil && p.verifyDNSLength { - err = &labelError{s, "A4"} - } - continue - } - if strings.HasPrefix(label, acePrefix) { - u, err2 := decode(label[len(acePrefix):]) - if err2 != nil { - if err == nil { - err = err2 - } - // Spec says keep the old label. - continue - } - labels.set(u) - if err == nil && p.validateLabels { - err = p.fromPuny(p, u) - } - if err == nil { - // This should be called on NonTransitional, according to the - // spec, but that currently does not have any effect. Use the - // original profile to preserve options. - err = p.validateLabel(u) - } - } else if err == nil { - err = p.validateLabel(label) - } - } - if toASCII { - for labels.reset(); !labels.done(); labels.next() { - label := labels.label() - if !ascii(label) { - a, err2 := encode(acePrefix, label) - if err == nil { - err = err2 - } - label = a - labels.set(a) - } - n := len(label) - if p.verifyDNSLength && err == nil && (n == 0 || n > 63) { - err = &labelError{label, "A4"} - } - } - } - s = labels.result() - if toASCII && p.verifyDNSLength && err == nil { - // Compute the length of the domain name minus the root label and its dot. - n := len(s) - if n > 0 && s[n-1] == '.' { - n-- - } - if len(s) < 1 || n > 253 { - err = &labelError{s, "A4"} - } - } - return s, err -} - -func normalize(p *Profile, s string) (string, error) { - return norm.NFC.String(s), nil -} - -func validateRegistration(p *Profile, s string) (string, error) { - if !norm.NFC.IsNormalString(s) { - return s, &labelError{s, "V1"} - } - var err error - for i := 0; i < len(s); { - v, sz := trie.lookupString(s[i:]) - i += sz - // Copy bytes not copied so far. - switch p.simplify(info(v).category()) { - // TODO: handle the NV8 defined in the Unicode idna data set to allow - // for strict conformance to IDNA2008. - case valid, deviation: - case disallowed, mapped, unknown, ignored: - if err == nil { - r, _ := utf8.DecodeRuneInString(s[i:]) - err = runeError(r) - } - } - } - return s, err -} - -func validateAndMap(p *Profile, s string) (string, error) { - var ( - err error - b []byte - k int - ) - for i := 0; i < len(s); { - v, sz := trie.lookupString(s[i:]) - start := i - i += sz - // Copy bytes not copied so far. - switch p.simplify(info(v).category()) { - case valid: - continue - case disallowed: - if err == nil { - r, _ := utf8.DecodeRuneInString(s[i:]) - err = runeError(r) - } - continue - case mapped, deviation: - b = append(b, s[k:start]...) - b = info(v).appendMapping(b, s[start:i]) - case ignored: - b = append(b, s[k:start]...) - // drop the rune - case unknown: - b = append(b, s[k:start]...) - b = append(b, "\ufffd"...) - } - k = i - } - if k == 0 { - // No changes so far. - s = norm.NFC.String(s) - } else { - b = append(b, s[k:]...) - if norm.NFC.QuickSpan(b) != len(b) { - b = norm.NFC.Bytes(b) - } - // TODO: the punycode converters require strings as input. - s = string(b) - } - return s, err -} - -// A labelIter allows iterating over domain name labels. -type labelIter struct { - orig string - slice []string - curStart int - curEnd int - i int -} - -func (l *labelIter) reset() { - l.curStart = 0 - l.curEnd = 0 - l.i = 0 -} - -func (l *labelIter) done() bool { - return l.curStart >= len(l.orig) -} - -func (l *labelIter) result() string { - if l.slice != nil { - return strings.Join(l.slice, ".") - } - return l.orig -} - -func (l *labelIter) label() string { - if l.slice != nil { - return l.slice[l.i] - } - p := strings.IndexByte(l.orig[l.curStart:], '.') - l.curEnd = l.curStart + p - if p == -1 { - l.curEnd = len(l.orig) - } - return l.orig[l.curStart:l.curEnd] -} - -// next sets the value to the next label. It skips the last label if it is empty. -func (l *labelIter) next() { - l.i++ - if l.slice != nil { - if l.i >= len(l.slice) || l.i == len(l.slice)-1 && l.slice[l.i] == "" { - l.curStart = len(l.orig) - } - } else { - l.curStart = l.curEnd + 1 - if l.curStart == len(l.orig)-1 && l.orig[l.curStart] == '.' { - l.curStart = len(l.orig) - } - } -} - -func (l *labelIter) set(s string) { - if l.slice == nil { - l.slice = strings.Split(l.orig, ".") - } - l.slice[l.i] = s -} - -// acePrefix is the ASCII Compatible Encoding prefix. -const acePrefix = "xn--" - -func (p *Profile) simplify(cat category) category { - switch cat { - case disallowedSTD3Mapped: - if p.useSTD3Rules { - cat = disallowed - } else { - cat = mapped - } - case disallowedSTD3Valid: - if p.useSTD3Rules { - cat = disallowed - } else { - cat = valid - } - case deviation: - if !p.transitional { - cat = valid - } - case validNV8, validXV8: - // TODO: handle V2008 - cat = valid - } - return cat -} - -func validateFromPunycode(p *Profile, s string) error { - if !norm.NFC.IsNormalString(s) { - return &labelError{s, "V1"} - } - for i := 0; i < len(s); { - v, sz := trie.lookupString(s[i:]) - if c := p.simplify(info(v).category()); c != valid && c != deviation { - return &labelError{s, "V6"} - } - i += sz - } - return nil -} - -const ( - zwnj = "\u200c" - zwj = "\u200d" -) - -type joinState int8 - -const ( - stateStart joinState = iota - stateVirama - stateBefore - stateBeforeVirama - stateAfter - stateFAIL -) - -var joinStates = [][numJoinTypes]joinState{ - stateStart: { - joiningL: stateBefore, - joiningD: stateBefore, - joinZWNJ: stateFAIL, - joinZWJ: stateFAIL, - joinVirama: stateVirama, - }, - stateVirama: { - joiningL: stateBefore, - joiningD: stateBefore, - }, - stateBefore: { - joiningL: stateBefore, - joiningD: stateBefore, - joiningT: stateBefore, - joinZWNJ: stateAfter, - joinZWJ: stateFAIL, - joinVirama: stateBeforeVirama, - }, - stateBeforeVirama: { - joiningL: stateBefore, - joiningD: stateBefore, - joiningT: stateBefore, - }, - stateAfter: { - joiningL: stateFAIL, - joiningD: stateBefore, - joiningT: stateAfter, - joiningR: stateStart, - joinZWNJ: stateFAIL, - joinZWJ: stateFAIL, - joinVirama: stateAfter, // no-op as we can't accept joiners here - }, - stateFAIL: { - 0: stateFAIL, - joiningL: stateFAIL, - joiningD: stateFAIL, - joiningT: stateFAIL, - joiningR: stateFAIL, - joinZWNJ: stateFAIL, - joinZWJ: stateFAIL, - joinVirama: stateFAIL, - }, -} - -// validateLabel validates the criteria from Section 4.1. Item 1, 4, and 6 are -// already implicitly satisfied by the overall implementation. -func (p *Profile) validateLabel(s string) error { - if s == "" { - if p.verifyDNSLength { - return &labelError{s, "A4"} - } - return nil - } - if p.bidirule != nil && !p.bidirule(s) { - return &labelError{s, "B"} - } - if !p.validateLabels { - return nil - } - trie := p.trie // p.validateLabels is only set if trie is set. - if len(s) > 4 && s[2] == '-' && s[3] == '-' { - return &labelError{s, "V2"} - } - if s[0] == '-' || s[len(s)-1] == '-' { - return &labelError{s, "V3"} - } - // TODO: merge the use of this in the trie. - v, sz := trie.lookupString(s) - x := info(v) - if x.isModifier() { - return &labelError{s, "V5"} - } - // Quickly return in the absence of zero-width (non) joiners. - if strings.Index(s, zwj) == -1 && strings.Index(s, zwnj) == -1 { - return nil - } - st := stateStart - for i := 0; ; { - jt := x.joinType() - if s[i:i+sz] == zwj { - jt = joinZWJ - } else if s[i:i+sz] == zwnj { - jt = joinZWNJ - } - st = joinStates[st][jt] - if x.isViramaModifier() { - st = joinStates[st][joinVirama] - } - if i += sz; i == len(s) { - break - } - v, sz = trie.lookupString(s[i:]) - x = info(v) - } - if st == stateFAIL || st == stateAfter { - return &labelError{s, "C"} - } - return nil -} - -func ascii(s string) bool { - for i := 0; i < len(s); i++ { - if s[i] >= utf8.RuneSelf { - return false - } - } - return true -} diff --git a/vendor/golang.org/x/net/idna/idna_test.go b/vendor/golang.org/x/net/idna/idna_test.go deleted file mode 100644 index b1bc6fa22..000000000 --- a/vendor/golang.org/x/net/idna/idna_test.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package idna - -import ( - "testing" -) - -var idnaTestCases = [...]struct { - ascii, unicode string -}{ - // Labels. - {"books", "books"}, - {"xn--bcher-kva", "bücher"}, - - // Domains. - {"foo--xn--bar.org", "foo--xn--bar.org"}, - {"golang.org", "golang.org"}, - {"example.xn--p1ai", "example.рф"}, - {"xn--czrw28b.tw", "商業.tw"}, - {"www.xn--mller-kva.de", "www.müller.de"}, -} - -func TestIDNA(t *testing.T) { - for _, tc := range idnaTestCases { - if a, err := ToASCII(tc.unicode); err != nil { - t.Errorf("ToASCII(%q): %v", tc.unicode, err) - } else if a != tc.ascii { - t.Errorf("ToASCII(%q): got %q, want %q", tc.unicode, a, tc.ascii) - } - - if u, err := ToUnicode(tc.ascii); err != nil { - t.Errorf("ToUnicode(%q): %v", tc.ascii, err) - } else if u != tc.unicode { - t.Errorf("ToUnicode(%q): got %q, want %q", tc.ascii, u, tc.unicode) - } - } -} - -// TODO(nigeltao): test errors, once we've specified when ToASCII and ToUnicode -// return errors. diff --git a/vendor/golang.org/x/net/idna/punycode.go b/vendor/golang.org/x/net/idna/punycode.go deleted file mode 100644 index 02c7d59af..000000000 --- a/vendor/golang.org/x/net/idna/punycode.go +++ /dev/null @@ -1,203 +0,0 @@ -// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. - -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package idna - -// This file implements the Punycode algorithm from RFC 3492. - -import ( - "math" - "strings" - "unicode/utf8" -) - -// These parameter values are specified in section 5. -// -// All computation is done with int32s, so that overflow behavior is identical -// regardless of whether int is 32-bit or 64-bit. -const ( - base int32 = 36 - damp int32 = 700 - initialBias int32 = 72 - initialN int32 = 128 - skew int32 = 38 - tmax int32 = 26 - tmin int32 = 1 -) - -func punyError(s string) error { return &labelError{s, "A3"} } - -// decode decodes a string as specified in section 6.2. -func decode(encoded string) (string, error) { - if encoded == "" { - return "", nil - } - pos := 1 + strings.LastIndex(encoded, "-") - if pos == 1 { - return "", punyError(encoded) - } - if pos == len(encoded) { - return encoded[:len(encoded)-1], nil - } - output := make([]rune, 0, len(encoded)) - if pos != 0 { - for _, r := range encoded[:pos-1] { - output = append(output, r) - } - } - i, n, bias := int32(0), initialN, initialBias - for pos < len(encoded) { - oldI, w := i, int32(1) - for k := base; ; k += base { - if pos == len(encoded) { - return "", punyError(encoded) - } - digit, ok := decodeDigit(encoded[pos]) - if !ok { - return "", punyError(encoded) - } - pos++ - i += digit * w - if i < 0 { - return "", punyError(encoded) - } - t := k - bias - if t < tmin { - t = tmin - } else if t > tmax { - t = tmax - } - if digit < t { - break - } - w *= base - t - if w >= math.MaxInt32/base { - return "", punyError(encoded) - } - } - x := int32(len(output) + 1) - bias = adapt(i-oldI, x, oldI == 0) - n += i / x - i %= x - if n > utf8.MaxRune || len(output) >= 1024 { - return "", punyError(encoded) - } - output = append(output, 0) - copy(output[i+1:], output[i:]) - output[i] = n - i++ - } - return string(output), nil -} - -// encode encodes a string as specified in section 6.3 and prepends prefix to -// the result. -// -// The "while h < length(input)" line in the specification becomes "for -// remaining != 0" in the Go code, because len(s) in Go is in bytes, not runes. -func encode(prefix, s string) (string, error) { - output := make([]byte, len(prefix), len(prefix)+1+2*len(s)) - copy(output, prefix) - delta, n, bias := int32(0), initialN, initialBias - b, remaining := int32(0), int32(0) - for _, r := range s { - if r < 0x80 { - b++ - output = append(output, byte(r)) - } else { - remaining++ - } - } - h := b - if b > 0 { - output = append(output, '-') - } - for remaining != 0 { - m := int32(0x7fffffff) - for _, r := range s { - if m > r && r >= n { - m = r - } - } - delta += (m - n) * (h + 1) - if delta < 0 { - return "", punyError(s) - } - n = m - for _, r := range s { - if r < n { - delta++ - if delta < 0 { - return "", punyError(s) - } - continue - } - if r > n { - continue - } - q := delta - for k := base; ; k += base { - t := k - bias - if t < tmin { - t = tmin - } else if t > tmax { - t = tmax - } - if q < t { - break - } - output = append(output, encodeDigit(t+(q-t)%(base-t))) - q = (q - t) / (base - t) - } - output = append(output, encodeDigit(q)) - bias = adapt(delta, h+1, h == b) - delta = 0 - h++ - remaining-- - } - delta++ - n++ - } - return string(output), nil -} - -func decodeDigit(x byte) (digit int32, ok bool) { - switch { - case '0' <= x && x <= '9': - return int32(x - ('0' - 26)), true - case 'A' <= x && x <= 'Z': - return int32(x - 'A'), true - case 'a' <= x && x <= 'z': - return int32(x - 'a'), true - } - return 0, false -} - -func encodeDigit(digit int32) byte { - switch { - case 0 <= digit && digit < 26: - return byte(digit + 'a') - case 26 <= digit && digit < 36: - return byte(digit + ('0' - 26)) - } - panic("idna: internal error in punycode encoding") -} - -// adapt is the bias adaptation function specified in section 6.1. -func adapt(delta, numPoints int32, firstTime bool) int32 { - if firstTime { - delta /= damp - } else { - delta /= 2 - } - delta += delta / numPoints - k := int32(0) - for delta > ((base-tmin)*tmax)/2 { - delta /= base - tmin - k += base - } - return k + (base-tmin+1)*delta/(delta+skew) -} diff --git a/vendor/golang.org/x/net/idna/punycode_test.go b/vendor/golang.org/x/net/idna/punycode_test.go deleted file mode 100644 index bfec81dec..000000000 --- a/vendor/golang.org/x/net/idna/punycode_test.go +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package idna - -import ( - "strings" - "testing" -) - -var punycodeTestCases = [...]struct { - s, encoded string -}{ - {"", ""}, - {"-", "--"}, - {"-a", "-a-"}, - {"-a-", "-a--"}, - {"a", "a-"}, - {"a-", "a--"}, - {"a-b", "a-b-"}, - {"books", "books-"}, - {"bücher", "bcher-kva"}, - {"Hello世界", "Hello-ck1hg65u"}, - {"ü", "tda"}, - {"üý", "tdac"}, - - // The test cases below come from RFC 3492 section 7.1 with Errata 3026. - { - // (A) Arabic (Egyptian). - "\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644" + - "\u0645\u0648\u0634\u0639\u0631\u0628\u064A\u061F", - "egbpdaj6bu4bxfgehfvwxn", - }, - { - // (B) Chinese (simplified). - "\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2D\u6587", - "ihqwcrb4cv8a8dqg056pqjye", - }, - { - // (C) Chinese (traditional). - "\u4ED6\u5011\u7232\u4EC0\u9EBD\u4E0D\u8AAA\u4E2D\u6587", - "ihqwctvzc91f659drss3x8bo0yb", - }, - { - // (D) Czech. - "\u0050\u0072\u006F\u010D\u0070\u0072\u006F\u0073\u0074" + - "\u011B\u006E\u0065\u006D\u006C\u0075\u0076\u00ED\u010D" + - "\u0065\u0073\u006B\u0079", - "Proprostnemluvesky-uyb24dma41a", - }, - { - // (E) Hebrew. - "\u05DC\u05DE\u05D4\u05D4\u05DD\u05E4\u05E9\u05D5\u05D8" + - "\u05DC\u05D0\u05DE\u05D3\u05D1\u05E8\u05D9\u05DD\u05E2" + - "\u05D1\u05E8\u05D9\u05EA", - "4dbcagdahymbxekheh6e0a7fei0b", - }, - { - // (F) Hindi (Devanagari). - "\u092F\u0939\u0932\u094B\u0917\u0939\u093F\u0928\u094D" + - "\u0926\u0940\u0915\u094D\u092F\u094B\u0902\u0928\u0939" + - "\u0940\u0902\u092C\u094B\u0932\u0938\u0915\u0924\u0947" + - "\u0939\u0948\u0902", - "i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd", - }, - { - // (G) Japanese (kanji and hiragana). - "\u306A\u305C\u307F\u3093\u306A\u65E5\u672C\u8A9E\u3092" + - "\u8A71\u3057\u3066\u304F\u308C\u306A\u3044\u306E\u304B", - "n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa", - }, - { - // (H) Korean (Hangul syllables). - "\uC138\uACC4\uC758\uBAA8\uB4E0\uC0AC\uB78C\uB4E4\uC774" + - "\uD55C\uAD6D\uC5B4\uB97C\uC774\uD574\uD55C\uB2E4\uBA74" + - "\uC5BC\uB9C8\uB098\uC88B\uC744\uAE4C", - "989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5j" + - "psd879ccm6fea98c", - }, - { - // (I) Russian (Cyrillic). - "\u043F\u043E\u0447\u0435\u043C\u0443\u0436\u0435\u043E" + - "\u043D\u0438\u043D\u0435\u0433\u043E\u0432\u043E\u0440" + - "\u044F\u0442\u043F\u043E\u0440\u0443\u0441\u0441\u043A" + - "\u0438", - "b1abfaaepdrnnbgefbadotcwatmq2g4l", - }, - { - // (J) Spanish. - "\u0050\u006F\u0072\u0071\u0075\u00E9\u006E\u006F\u0070" + - "\u0075\u0065\u0064\u0065\u006E\u0073\u0069\u006D\u0070" + - "\u006C\u0065\u006D\u0065\u006E\u0074\u0065\u0068\u0061" + - "\u0062\u006C\u0061\u0072\u0065\u006E\u0045\u0073\u0070" + - "\u0061\u00F1\u006F\u006C", - "PorqunopuedensimplementehablarenEspaol-fmd56a", - }, - { - // (K) Vietnamese. - "\u0054\u1EA1\u0069\u0073\u0061\u006F\u0068\u1ECD\u006B" + - "\u0068\u00F4\u006E\u0067\u0074\u0068\u1EC3\u0063\u0068" + - "\u1EC9\u006E\u00F3\u0069\u0074\u0069\u1EBF\u006E\u0067" + - "\u0056\u0069\u1EC7\u0074", - "TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g", - }, - { - // (L) 3B. - "\u0033\u5E74\u0042\u7D44\u91D1\u516B\u5148\u751F", - "3B-ww4c5e180e575a65lsy2b", - }, - { - // (M) -with-SUPER-MONKEYS. - "\u5B89\u5BA4\u5948\u7F8E\u6075\u002D\u0077\u0069\u0074" + - "\u0068\u002D\u0053\u0055\u0050\u0045\u0052\u002D\u004D" + - "\u004F\u004E\u004B\u0045\u0059\u0053", - "-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n", - }, - { - // (N) Hello-Another-Way-. - "\u0048\u0065\u006C\u006C\u006F\u002D\u0041\u006E\u006F" + - "\u0074\u0068\u0065\u0072\u002D\u0057\u0061\u0079\u002D" + - "\u305D\u308C\u305E\u308C\u306E\u5834\u6240", - "Hello-Another-Way--fc4qua05auwb3674vfr0b", - }, - { - // (O) 2. - "\u3072\u3068\u3064\u5C4B\u6839\u306E\u4E0B\u0032", - "2-u9tlzr9756bt3uc0v", - }, - { - // (P) MajiKoi5 - "\u004D\u0061\u006A\u0069\u3067\u004B\u006F\u0069\u3059" + - "\u308B\u0035\u79D2\u524D", - "MajiKoi5-783gue6qz075azm5e", - }, - { - // (Q) de - "\u30D1\u30D5\u30A3\u30FC\u0064\u0065\u30EB\u30F3\u30D0", - "de-jg4avhby1noc0d", - }, - { - // (R) - "\u305D\u306E\u30B9\u30D4\u30FC\u30C9\u3067", - "d9juau41awczczp", - }, - { - // (S) -> $1.00 <- - "\u002D\u003E\u0020\u0024\u0031\u002E\u0030\u0030\u0020" + - "\u003C\u002D", - "-> $1.00 <--", - }, -} - -func TestPunycode(t *testing.T) { - for _, tc := range punycodeTestCases { - if got, err := decode(tc.encoded); err != nil { - t.Errorf("decode(%q): %v", tc.encoded, err) - } else if got != tc.s { - t.Errorf("decode(%q): got %q, want %q", tc.encoded, got, tc.s) - } - - if got, err := encode("", tc.s); err != nil { - t.Errorf(`encode("", %q): %v`, tc.s, err) - } else if got != tc.encoded { - t.Errorf(`encode("", %q): got %q, want %q`, tc.s, got, tc.encoded) - } - } -} - -var punycodeErrorTestCases = [...]string{ - "decode -", // A sole '-' is invalid. - "decode foo\x00bar", // '\x00' is not in [0-9A-Za-z]. - "decode foo#bar", // '#' is not in [0-9A-Za-z]. - "decode foo\u00A3bar", // '\u00A3' is not in [0-9A-Za-z]. - "decode 9", // "9a" decodes to codepoint \u00A3; "9" is truncated. - "decode 99999a", // "99999a" decodes to codepoint \U0048A3C1, which is > \U0010FFFF. - "decode 9999999999a", // "9999999999a" overflows the int32 calculation. - - "encode " + strings.Repeat("x", 65536) + "\uff00", // int32 overflow. -} - -func TestPunycodeErrors(t *testing.T) { - for _, tc := range punycodeErrorTestCases { - var err error - switch { - case strings.HasPrefix(tc, "decode "): - _, err = decode(tc[7:]) - case strings.HasPrefix(tc, "encode "): - _, err = encode("", tc[7:]) - } - if err == nil { - if len(tc) > 256 { - tc = tc[:100] + "..." + tc[len(tc)-100:] - } - t.Errorf("no error for %s", tc) - } - } -} diff --git a/vendor/golang.org/x/net/idna/tables.go b/vendor/golang.org/x/net/idna/tables.go deleted file mode 100644 index d2819345f..000000000 --- a/vendor/golang.org/x/net/idna/tables.go +++ /dev/null @@ -1,4477 +0,0 @@ -// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. - -package idna - -// UnicodeVersion is the Unicode version from which the tables in this package are derived. -const UnicodeVersion = "9.0.0" - -var mappings string = "" + // Size: 8176 bytes - "\x00\x01 \x03 ̈\x01a\x03 Ì„\x012\x013\x03 Ì\x03 ̧\x011\x01o\x051â„4\x051â„2" + - "\x053â„4\x03i̇\x03l·\x03ʼn\x01s\x03dž\x03â±¥\x03ⱦ\x01h\x01j\x01r\x01w\x01y" + - "\x03 ̆\x03 ̇\x03 ÌŠ\x03 ̨\x03 ̃\x03 Ì‹\x01l\x01x\x04̈Ì\x03 ι\x01;\x05 ̈Ì" + - "\x04Õ¥Ö‚\x04اٴ\x04وٴ\x04Û‡Ù´\x04يٴ\x06क़\x06ख़\x06ग़\x06ज़\x06ड़\x06ढ़\x06फ़" + - "\x06य़\x06ড়\x06ঢ়\x06য়\x06ਲ਼\x06ਸ਼\x06ਖ਼\x06ਗ਼\x06ਜ਼\x06ਫ਼\x06ଡ଼\x06ଢ଼" + - "\x06à¹à¸²\x06à»àº²\x06ຫນ\x06ຫມ\x06གྷ\x06ཌྷ\x06དྷ\x06བྷ\x06ཛྷ\x06ཀྵ\x06ཱི\x06ཱུ" + - "\x06ྲྀ\x09ྲཱྀ\x06ླྀ\x09ླཱྀ\x06ཱྀ\x06ྒྷ\x06ྜྷ\x06ྡྷ\x06ྦྷ\x06ྫྷ\x06à¾à¾µ\x02" + - "в\x02д\x02о\x02Ñ\x02Ñ‚\x02ÑŠ\x02Ñ£\x02æ\x01b\x01d\x01e\x02Ç\x01g\x01i\x01k" + - "\x01m\x01n\x02È£\x01p\x01t\x01u\x02É\x02É‘\x02É™\x02É›\x02Éœ\x02Å‹\x02É”\x02ɯ" + - "\x01v\x02β\x02γ\x02δ\x02φ\x02χ\x02Ï\x02н\x02É’\x01c\x02É•\x02ð\x01f\x02ÉŸ" + - "\x02É¡\x02É¥\x02ɨ\x02É©\x02ɪ\x02Ê\x02É­\x02ÊŸ\x02ɱ\x02É°\x02ɲ\x02ɳ\x02É´\x02ɵ" + - "\x02ɸ\x02Ê‚\x02ʃ\x02Æ«\x02ʉ\x02ÊŠ\x02Ê‹\x02ÊŒ\x01z\x02Ê\x02Ê‘\x02Ê’\x02θ\x02ss" + - "\x02ά\x02έ\x02ή\x02ί\x02ÏŒ\x02Ï\x02ÏŽ\x05ἀι\x05á¼Î¹\x05ἂι\x05ἃι\x05ἄι\x05ἅι" + - "\x05ἆι\x05ἇι\x05ἠι\x05ἡι\x05ἢι\x05ἣι\x05ἤι\x05ἥι\x05ἦι\x05ἧι\x05ὠι\x05ὡι" + - "\x05ὢι\x05ὣι\x05ὤι\x05ὥι\x05ὦι\x05ὧι\x05ὰι\x04αι\x04άι\x05ᾶι\x02ι\x05 ̈͂" + - "\x05ὴι\x04ηι\x04ήι\x05ῆι\x05 Ì“Ì€\x05 Ì“Ì\x05 Ì“Í‚\x02Î\x05 ̔̀\x05 Ì”Ì\x05 ̔͂" + - "\x02ΰ\x05 ̈̀\x01`\x05ὼι\x04ωι\x04ώι\x05ῶι\x06′′\x09′′′\x06‵‵\x09‵‵‵\x02!" + - "!\x02??\x02?!\x02!?\x0c′′′′\x010\x014\x015\x016\x017\x018\x019\x01+\x01=" + - "\x01(\x01)\x02rs\x02ħ\x02no\x01q\x02sm\x02tm\x02ω\x02Ã¥\x02×\x02ב\x02×’" + - "\x02ד\x02Ï€\x051â„7\x051â„9\x061â„10\x051â„3\x052â„3\x051â„5\x052â„5\x053â„5\x054" + - "â„5\x051â„6\x055â„6\x051â„8\x053â„8\x055â„8\x057â„8\x041â„\x02ii\x02iv\x02vi" + - "\x04viii\x02ix\x02xi\x050â„3\x06∫∫\x09∫∫∫\x06∮∮\x09∮∮∮\x0210\x0211\x0212" + - "\x0213\x0214\x0215\x0216\x0217\x0218\x0219\x0220\x04(10)\x04(11)\x04(12)" + - "\x04(13)\x04(14)\x04(15)\x04(16)\x04(17)\x04(18)\x04(19)\x04(20)\x0c∫∫∫∫" + - "\x02==\x05â«Ì¸\x02É«\x02ɽ\x02È¿\x02É€\x01.\x04 ã‚™\x04 ã‚š\x06より\x06コト\x05(á„€)\x05" + - "(á„‚)\x05(ᄃ)\x05(á„…)\x05(ᄆ)\x05(ᄇ)\x05(ᄉ)\x05(á„‹)\x05(á„Œ)\x05(á„Ž)\x05(á„)\x05(á„" + - ")\x05(á„‘)\x05(á„’)\x05(ê°€)\x05(나)\x05(다)\x05(ë¼)\x05(마)\x05(ë°”)\x05(사)\x05(ì•„)" + - "\x05(ìž)\x05(ì°¨)\x05(ì¹´)\x05(타)\x05(파)\x05(하)\x05(주)\x08(오전)\x08(오후)\x05(一)" + - "\x05(二)\x05(三)\x05(å››)\x05(五)\x05(å…­)\x05(七)\x05(å…«)\x05(ä¹)\x05(å)\x05(月)" + - "\x05(ç«)\x05(æ°´)\x05(木)\x05(金)\x05(土)\x05(æ—¥)\x05(æ ª)\x05(有)\x05(社)\x05(å)" + - "\x05(特)\x05(財)\x05(ç¥)\x05(労)\x05(代)\x05(呼)\x05(å­¦)\x05(監)\x05(ä¼)\x05(資)" + - "\x05(å”)\x05(祭)\x05(休)\x05(自)\x05(至)\x0221\x0222\x0223\x0224\x0225\x0226" + - "\x0227\x0228\x0229\x0230\x0231\x0232\x0233\x0234\x0235\x06참고\x06주ì˜\x0236" + - "\x0237\x0238\x0239\x0240\x0241\x0242\x0243\x0244\x0245\x0246\x0247\x0248" + - "\x0249\x0250\x041月\x042月\x043月\x044月\x045月\x046月\x047月\x048月\x049月\x0510" + - "月\x0511月\x0512月\x02hg\x02ev\x0cアパート\x0cアルファ\x0cアンペア\x09アール\x0cイニング\x09" + - "インãƒ\x09ウォン\x0fエスクード\x0cエーカー\x09オンス\x09オーム\x09カイリ\x0cカラット\x0cカロリー\x09ガロ" + - "ン\x09ガンマ\x06ギガ\x09ギニー\x0cキュリー\x0cギルダー\x06キロ\x0fキログラム\x12キロメートル\x0fキロワッ" + - "ト\x09グラム\x0fグラムトン\x0fクルゼイロ\x0cクローãƒ\x09ケース\x09コルナ\x09コーãƒ\x0cサイクル\x0fサンãƒ" + - "ーム\x0cシリング\x09センãƒ\x09セント\x09ダース\x06デシ\x06ドル\x06トン\x06ナノ\x09ノット\x09ãƒã‚¤ãƒ„" + - "\x0fパーセント\x09パーツ\x0cãƒãƒ¼ãƒ¬ãƒ«\x0fピアストル\x09ピクル\x06ピコ\x06ビル\x0fファラッド\x0cフィート" + - "\x0fブッシェル\x09フラン\x0fヘクタール\x06ペソ\x09ペニヒ\x09ヘルツ\x09ペンス\x09ページ\x09ベータ\x0cãƒã‚¤" + - "ント\x09ボルト\x06ホン\x09ãƒãƒ³ãƒ‰\x09ホール\x09ホーン\x0cマイクロ\x09マイル\x09マッãƒ\x09マルク\x0fマ" + - "ンション\x0cミクロン\x06ミリ\x0fミリãƒãƒ¼ãƒ«\x06メガ\x0cメガトン\x0cメートル\x09ヤード\x09ヤール\x09ユアン" + - "\x0cリットル\x06リラ\x09ルピー\x0cルーブル\x06レム\x0fレントゲン\x09ワット\x040点\x041点\x042点" + - "\x043点\x044点\x045点\x046点\x047点\x048点\x049点\x0510点\x0511点\x0512点\x0513点" + - "\x0514点\x0515点\x0516点\x0517点\x0518点\x0519点\x0520点\x0521点\x0522点\x0523点" + - "\x0524点\x02da\x02au\x02ov\x02pc\x02dm\x02iu\x06å¹³æˆ\x06昭和\x06大正\x06明治\x0cæ ª" + - "å¼ä¼šç¤¾\x02pa\x02na\x02ma\x02ka\x02kb\x02mb\x02gb\x04kcal\x02pf\x02nf\x02m" + - "g\x02kg\x02hz\x02ml\x02dl\x02kl\x02fm\x02nm\x02mm\x02cm\x02km\x02m2\x02m" + - "3\x05m∕s\x06m∕s2\x07rad∕s\x08rad∕s2\x02ps\x02ns\x02ms\x02pv\x02nv\x02mv" + - "\x02kv\x02pw\x02nw\x02mw\x02kw\x02bq\x02cc\x02cd\x06c∕kg\x02db\x02gy\x02" + - "ha\x02hp\x02in\x02kk\x02kt\x02lm\x02ln\x02lx\x02ph\x02pr\x02sr\x02sv\x02" + - "wb\x05v∕m\x05a∕m\x041æ—¥\x042æ—¥\x043æ—¥\x044æ—¥\x045æ—¥\x046æ—¥\x047æ—¥\x048æ—¥\x049æ—¥" + - "\x0510æ—¥\x0511æ—¥\x0512æ—¥\x0513æ—¥\x0514æ—¥\x0515æ—¥\x0516æ—¥\x0517æ—¥\x0518æ—¥\x0519æ—¥" + - "\x0520æ—¥\x0521æ—¥\x0522æ—¥\x0523æ—¥\x0524æ—¥\x0525æ—¥\x0526æ—¥\x0527æ—¥\x0528æ—¥\x0529æ—¥" + - "\x0530æ—¥\x0531æ—¥\x02ÑŒ\x02ɦ\x02ɬ\x02Êž\x02ʇ\x02Å“\x04𤋮\x04𢡊\x04𢡄\x04ð£•\x04𥉉" + - "\x04ð¥³\x04𧻓\x02ff\x02fi\x02fl\x02st\x04Õ´Õ¶\x04Õ´Õ¥\x04Õ´Õ«\x04Õ¾Õ¶\x04Õ´Õ­\x04×™Ö´" + - "\x04ײַ\x02×¢\x02×”\x02×›\x02ל\x02×\x02ר\x02ת\x04ש×\x04שׂ\x06שּ×\x06שּׂ\x04×" + - "Ö·\x04×Ö¸\x04×Ö¼\x04בּ\x04×’Ö¼\x04דּ\x04×”Ö¼\x04וּ\x04×–Ö¼\x04טּ\x04×™Ö¼\x04ךּ\x04" + - "×›Ö¼\x04לּ\x04מּ\x04× Ö¼\x04סּ\x04×£Ö¼\x04פּ\x04צּ\x04קּ\x04רּ\x04שּ\x04תּ" + - "\x04וֹ\x04בֿ\x04×›Ö¿\x04פֿ\x04×ל\x02Ù±\x02Ù»\x02Ù¾\x02Ú€\x02Ùº\x02Ù¿\x02Ù¹\x02Ú¤" + - "\x02Ú¦\x02Ú„\x02Úƒ\x02Ú†\x02Ú‡\x02Ú\x02ÚŒ\x02ÚŽ\x02Úˆ\x02Ú˜\x02Ú‘\x02Ú©\x02Ú¯\x02Ú³" + - "\x02Ú±\x02Úº\x02Ú»\x02Û€\x02Û\x02Ú¾\x02Û’\x02Û“\x02Ú­\x02Û‡\x02Û†\x02Ûˆ\x02Û‹\x02Û…" + - "\x02Û‰\x02Û\x02Ù‰\x04ئا\x04ئە\x04ئو\x04ئۇ\x04ئۆ\x04ئۈ\x04ئÛ\x04ئى\x02ÛŒ\x04" + - "ئج\x04ئح\x04ئم\x04ئي\x04بج\x04بح\x04بخ\x04بم\x04بى\x04بي\x04تج\x04تح" + - "\x04تخ\x04تم\x04تى\x04تي\x04ثج\x04ثم\x04ثى\x04ثي\x04جح\x04جم\x04حج\x04حم" + - "\x04خج\x04خح\x04خم\x04سج\x04سح\x04سخ\x04سم\x04صح\x04صم\x04ضج\x04ضح\x04ضخ" + - "\x04ضم\x04طح\x04طم\x04ظم\x04عج\x04عم\x04غج\x04غم\x04Ùج\x04ÙØ­\x04ÙØ®\x04ÙÙ…" + - "\x04ÙÙ‰\x04ÙÙŠ\x04قح\x04قم\x04قى\x04قي\x04كا\x04كج\x04كح\x04كخ\x04كل\x04كم" + - "\x04كى\x04كي\x04لج\x04لح\x04لخ\x04لم\x04لى\x04لي\x04مج\x04مح\x04مخ\x04مم" + - "\x04مى\x04مي\x04نج\x04نح\x04نخ\x04نم\x04نى\x04ني\x04هج\x04هم\x04هى\x04هي" + - "\x04يج\x04يح\x04يخ\x04يم\x04يى\x04يي\x04ذٰ\x04رٰ\x04ىٰ\x05 ٌّ\x05 ÙÙ‘\x05" + - " ÙŽÙ‘\x05 ÙÙ‘\x05 ÙÙ‘\x05 ّٰ\x04ئر\x04ئز\x04ئن\x04بر\x04بز\x04بن\x04تر\x04تز" + - "\x04تن\x04ثر\x04ثز\x04ثن\x04ما\x04نر\x04نز\x04نن\x04ير\x04يز\x04ين\x04ئخ" + - "\x04ئه\x04به\x04ته\x04صخ\x04له\x04نه\x04هٰ\x04يه\x04ثه\x04سه\x04شم\x04شه" + - "\x06Ù€ÙŽÙ‘\x06Ù€ÙÙ‘\x06Ù€ÙÙ‘\x04طى\x04طي\x04عى\x04عي\x04غى\x04غي\x04سى\x04سي" + - "\x04شى\x04شي\x04حى\x04حي\x04جى\x04جي\x04خى\x04خي\x04صى\x04صي\x04ضى\x04ضي" + - "\x04شج\x04شح\x04شخ\x04شر\x04سر\x04صر\x04ضر\x04اً\x06تجم\x06تحج\x06تحم" + - "\x06تخم\x06تمج\x06تمح\x06تمخ\x06جمح\x06حمي\x06حمى\x06سحج\x06سجح\x06سجى" + - "\x06سمح\x06سمج\x06سمم\x06صحح\x06صمم\x06شحم\x06شجي\x06شمخ\x06شمم\x06ضحى" + - "\x06ضخم\x06طمح\x06طمم\x06طمي\x06عجم\x06عمم\x06عمى\x06غمم\x06غمي\x06غمى" + - "\x06Ùخم\x06قمح\x06قمم\x06لحم\x06لحي\x06لحى\x06لجج\x06لخم\x06لمح\x06محج" + - "\x06محم\x06محي\x06مجح\x06مجم\x06مخج\x06مخم\x06مجخ\x06همج\x06همم\x06نحم" + - "\x06نحى\x06نجم\x06نجى\x06نمي\x06نمى\x06يمم\x06بخي\x06تجي\x06تجى\x06تخي" + - "\x06تخى\x06تمي\x06تمى\x06جمي\x06جحى\x06جمى\x06سخى\x06صحي\x06شحي\x06ضحي" + - "\x06لجي\x06لمي\x06يحي\x06يجي\x06يمي\x06ممي\x06قمي\x06نحي\x06عمي\x06كمي" + - "\x06نجح\x06مخي\x06لجم\x06كمم\x06جحي\x06حجي\x06مجي\x06Ùمي\x06بحي\x06سخي" + - "\x06نجي\x06صلے\x06قلے\x08الله\x08اكبر\x08محمد\x08صلعم\x08رسول\x08عليه" + - "\x08وسلم\x06صلى!صلى الله عليه وسلم\x0fجل جلاله\x08ریال\x01,\x01:\x01!" + - "\x01?\x01_\x01{\x01}\x01[\x01]\x01#\x01&\x01*\x01-\x01<\x01>\x01\\\x01$" + - "\x01%\x01@\x04ـً\x04Ù€ÙŽ\x04Ù€Ù\x04Ù€Ù\x04ـّ\x04ـْ\x02Ø¡\x02Ø¢\x02Ø£\x02ؤ\x02Ø¥" + - "\x02ئ\x02ا\x02ب\x02Ø©\x02ت\x02Ø«\x02ج\x02Ø­\x02Ø®\x02د\x02Ø°\x02ر\x02ز\x02س" + - "\x02Ø´\x02ص\x02ض\x02Ø·\x02ظ\x02ع\x02غ\x02Ù\x02Ù‚\x02Ùƒ\x02Ù„\x02Ù…\x02Ù†\x02Ù‡" + - "\x02Ùˆ\x02ÙŠ\x04لآ\x04لأ\x04لإ\x04لا\x01\x22\x01'\x01/\x01^\x01|\x01~\x02¢" + - "\x02£\x02¬\x02¦\x02Â¥\x08ð…—ð…¥\x08ð…˜ð…¥\x0cð…˜ð…¥ð…®\x0cð…˜ð…¥ð…¯\x0cð…˜ð…¥ð…°\x0cð…˜ð…¥ð…±\x0cð…˜ð…¥ð…²\x08ð†¹" + - "ð…¥\x08ð†ºð…¥\x0cð†¹ð…¥ð…®\x0cð†ºð…¥ð…®\x0cð†¹ð…¥ð…¯\x0cð†ºð…¥ð…¯\x02ı\x02È·\x02α\x02ε\x02ζ\x02η\x02" + - "κ\x02λ\x02μ\x02ν\x02ξ\x02ο\x02σ\x02Ï„\x02Ï…\x02ψ\x03∇\x03∂\x02Ï\x02Ù®\x02Ú¡" + - "\x02Ù¯\x020,\x021,\x022,\x023,\x024,\x025,\x026,\x027,\x028,\x029,\x03(a)" + - "\x03(b)\x03(c)\x03(d)\x03(e)\x03(f)\x03(g)\x03(h)\x03(i)\x03(j)\x03(k)" + - "\x03(l)\x03(m)\x03(n)\x03(o)\x03(p)\x03(q)\x03(r)\x03(s)\x03(t)\x03(u)" + - "\x03(v)\x03(w)\x03(x)\x03(y)\x03(z)\x07〔s〕\x02wz\x02hv\x02sd\x03ppv\x02w" + - "c\x02mc\x02md\x02dj\x06ã»ã‹\x06ココ\x03サ\x03手\x03å­—\x03åŒ\x03デ\x03二\x03多\x03解" + - "\x03天\x03交\x03映\x03ç„¡\x03æ–™\x03å‰\x03後\x03å†\x03æ–°\x03åˆ\x03終\x03生\x03販\x03声" + - "\x03å¹\x03æ¼”\x03投\x03æ•\x03一\x03三\x03éŠ\x03å·¦\x03中\x03å³\x03指\x03èµ°\x03打\x03ç¦" + - "\x03空\x03åˆ\x03満\x03有\x03月\x03申\x03割\x03å–¶\x03é…\x09〔本〕\x09〔三〕\x09〔二〕\x09〔安" + - "〕\x09〔点〕\x09〔打〕\x09〔盗〕\x09〔å‹ã€•\x09〔敗〕\x03å¾—\x03å¯\x03丽\x03丸\x03ä¹\x03ä½ \x03" + - "ä¾®\x03ä¾»\x03倂\x03åº\x03å‚™\x03僧\x03åƒ\x03ã’ž\x03å…\x03å…”\x03å…¤\x03å…·\x03ã’¹\x03å…§\x03" + - "冗\x03冤\x03仌\x03冬\x03况\x03凵\x03刃\x03ã“Ÿ\x03刻\x03剆\x03剷\x03㔕\x03勇\x03勉\x03" + - "勤\x03勺\x03包\x03匆\x03北\x03å‰\x03å‘\x03åš\x03å³\x03å½\x03å¿\x03ç°\x03åŠ\x03åŸ\x03" + - "å«\x03å±\x03å†\x03å’ž\x03å¸\x03呈\x03周\x03å’¢\x03哶\x03å”\x03å•“\x03å•£\x03å–„\x03å–™\x03" + - "å–«\x03å–³\x03å—‚\x03圖\x03嘆\x03圗\x03噑\x03å™´\x03切\x03壮\x03城\x03埴\x03å \x03åž‹\x03" + - "å ²\x03å ±\x03墬\x03売\x03壷\x03夆\x03夢\x03奢\x03姬\x03娛\x03娧\x03姘\x03婦\x03ã›®\x03" + - "嬈\x03嬾\x03寃\x03寘\x03寧\x03寳\x03寿\x03å°†\x03å°¢\x03ãž\x03å± \x03å±®\x03å³€\x03å²\x03" + - "嵃\x03åµ®\x03嵫\x03åµ¼\x03å·¡\x03å·¢\x03ã ¯\x03å·½\x03帨\x03帽\x03幩\x03ã¡¢\x03㡼\x03庰\x03" + - "庳\x03庶\x03廊\x03廾\x03èˆ\x03å¼¢\x03㣇\x03å½¢\x03彫\x03㣣\x03徚\x03å¿\x03å¿—\x03忹\x03" + - "æ‚\x03㤺\x03㤜\x03æ‚”\x03惇\x03æ…ˆ\x03æ…Œ\x03æ…Ž\x03æ…º\x03憎\x03憲\x03憤\x03憯\x03懞\x03" + - "懲\x03懶\x03æˆ\x03戛\x03æ‰\x03抱\x03æ‹”\x03æ\x03挽\x03拼\x03æ¨\x03掃\x03æ¤\x03æ¢\x03" + - "æ…\x03掩\x03㨮\x03æ‘©\x03摾\x03æ’\x03æ‘·\x03㩬\x03æ•\x03敬\x03æ—£\x03書\x03晉\x03㬙\x03" + - "æš‘\x03㬈\x03㫤\x03冒\x03冕\x03最\x03æšœ\x03è‚­\x03ä™\x03朗\x03望\x03朡\x03æž\x03æ“\x03" + - "ã­‰\x03柺\x03æž…\x03æ¡’\x03梅\x03梎\x03æ Ÿ\x03椔\x03ã®\x03楂\x03榣\x03槪\x03檨\x03æ«›\x03" + - "ã°˜\x03次\x03æ­”\x03㱎\x03æ­²\x03殟\x03殺\x03æ®»\x03汎\x03沿\x03æ³\x03汧\x03æ´–\x03æ´¾\x03" + - "æµ·\x03æµ\x03浩\x03浸\x03涅\x03æ´´\x03港\x03æ¹®\x03ã´³\x03滋\x03滇\x03æ·¹\x03æ½®\x03濆\x03" + - "瀹\x03瀞\x03瀛\x03㶖\x03çŠ\x03ç½\x03ç·\x03ç‚­\x03ç……\x03熜\x03爨\x03爵\x03ç‰\x03犀\x03" + - "犕\x03çº\x03王\x03㺬\x03玥\x03㺸\x03瑇\x03ç‘œ\x03瑱\x03ç’…\x03ç“Š\x03ã¼›\x03甤\x03甾\x03" + - "ç•°\x03ç˜\x03㿼\x03䀈\x03ç›´\x03眞\x03真\x03çŠ\x03䀹\x03çž‹\x03ä†\x03ä‚–\x03ç¡Ž\x03碌\x03" + - "磌\x03䃣\x03祖\x03ç¦\x03秫\x03䄯\x03ç©€\x03ç©Š\x03ç©\x03䈂\x03篆\x03築\x03䈧\x03ç³’\x03" + - "䊠\x03糨\x03ç³£\x03ç´€\x03çµ£\x03äŒ\x03ç·‡\x03縂\x03ç¹…\x03䌴\x03ä™\x03罺\x03羕\x03翺\x03" + - "者\x03è \x03è°\x03ä•\x03育\x03脃\x03ä‹\x03脾\x03媵\x03舄\x03辞\x03ä‘«\x03芑\x03芋\x03" + - "èŠ\x03劳\x03花\x03芳\x03芽\x03苦\x03è‹¥\x03èŒ\x03è£\x03莭\x03茣\x03莽\x03è§\x03è‘—\x03" + - "è“\x03èŠ\x03èŒ\x03èœ\x03䔫\x03蓱\x03蓳\x03è”–\x03蕤\x03ä•\x03ä•¡\x03ä•«\x03è™\x03虜\x03" + - "虧\x03虩\x03èš©\x03蚈\x03蜎\x03蛢\x03è¹\x03蜨\x03è«\x03螆\x03蟡\x03è \x03ä—¹\x03è¡ \x03" + - "è¡£\x03裗\x03裞\x03䘵\x03裺\x03ã’»\x03äš¾\x03䛇\x03誠\x03è«­\x03變\x03豕\x03貫\x03è³\x03" + - "è´›\x03èµ·\x03è·‹\x03趼\x03è·°\x03è»”\x03輸\x03é‚”\x03郱\x03é„‘\x03é„›\x03鈸\x03é‹—\x03鋘\x03" + - "鉼\x03é¹\x03é•\x03é–‹\x03䦕\x03é–·\x03䧦\x03雃\x03嶲\x03霣\x03ä©®\x03䩶\x03韠\x03䪲\x03" + - "é ‹\x03é ©\x03飢\x03䬳\x03餩\x03馧\x03駂\x03駾\x03䯎\x03鬒\x03é±€\x03é³½\x03䳎\x03ä³­\x03" + - "鵧\x03䳸\x03麻\x03äµ–\x03黹\x03黾\x03é¼…\x03é¼\x03é¼–\x03é¼»" - -var xorData string = "" + // Size: 4855 bytes - "\x02\x0c\x09\x02\xb0\xec\x02\xad\xd8\x02\xad\xd9\x02\x06\x07\x02\x0f\x12" + - "\x02\x0f\x1f\x02\x0f\x1d\x02\x01\x13\x02\x0f\x16\x02\x0f\x0b\x02\x0f3" + - "\x02\x0f7\x02\x0f?\x02\x0f/\x02\x0f*\x02\x0c&\x02\x0c*\x02\x0c;\x02\x0c9" + - "\x02\x0c%\x02\xab\xed\x02\xab\xe2\x02\xab\xe3\x02\xa9\xe0\x02\xa9\xe1" + - "\x02\xa9\xe6\x02\xa3\xcb\x02\xa3\xc8\x02\xa3\xc9\x02\x01#\x02\x01\x08" + - "\x02\x0e>\x02\x0e'\x02\x0f\x03\x02\x03\x0d\x02\x03\x09\x02\x03\x17\x02" + - "\x03\x0e\x02\x02\x03\x02\x011\x02\x01\x00\x02\x01\x10\x02\x03<\x02\x07" + - "\x0d\x02\x02\x0c\x02\x0c0\x02\x01\x03\x02\x01\x01\x02\x01 \x02\x01\x22" + - "\x02\x01)\x02\x01\x0a\x02\x01\x0c\x02\x02\x06\x02\x02\x02\x02\x03\x10" + - "\x03\x037 \x03\x0b+\x03\x02\x01\x04\x02\x01\x02\x02\x019\x02\x03\x1c\x02" + - "\x02$\x03\x80p$\x02\x03:\x02\x03\x0a\x03\xc1r.\x03\xc1r,\x03\xc1r\x02" + - "\x02\x02:\x02\x02>\x02\x02,\x02\x02\x10\x02\x02\x00\x03\xc1s<\x03\xc1s*" + - "\x03\xc2L$\x03\xc2L;\x02\x09)\x02\x0a\x19\x03\x83\xab\xe3\x03\x83\xab" + - "\xf2\x03 4\xe0\x03\x81\xab\xea\x03\x81\xab\xf3\x03 4\xef\x03\x96\xe1\xcd" + - "\x03\x84\xe5\xc3\x02\x0d\x11\x03\x8b\xec\xcb\x03\x94\xec\xcf\x03\x9a\xec" + - "\xc2\x03\x8b\xec\xdb\x03\x94\xec\xdf\x03\x9a\xec\xd2\x03\x01\x0c!\x03" + - "\x01\x0c#\x03Ê \x9d\x03Ê£\x9c\x03Ê¢\x9f\x03Ê¥\x9e\x03ʤ\x91\x03ʧ\x90\x03ʦ\x93" + - "\x03Ê©\x92\x03ʨ\x95\x03\xca\xf3\xb5\x03\xca\xf0\xb4\x03\xca\xf1\xb7\x03" + - "\xca\xf6\xb6\x03\xca\xf7\x89\x03\xca\xf4\x88\x03\xca\xf5\x8b\x03\xca\xfa" + - "\x8a\x03\xca\xfb\x8d\x03\xca\xf8\x8c\x03\xca\xf9\x8f\x03\xca\xfe\x8e\x03" + - "\xca\xff\x81\x03\xca\xfc\x80\x03\xca\xfd\x83\x03\xca\xe2\x82\x03\xca\xe3" + - "\x85\x03\xca\xe0\x84\x03\xca\xe1\x87\x03\xca\xe6\x86\x03\xca\xe7\x99\x03" + - "\xca\xe4\x98\x03\xca\xe5\x9b\x03\xca\xea\x9a\x03\xca\xeb\x9d\x03\xca\xe8" + - "\x9c\x03Ø“\x89\x03ß”\x8b\x02\x010\x03\x03\x04\x1e\x03\x04\x15\x12\x03\x0b" + - "\x05,\x03\x06\x04\x00\x03\x06\x04)\x03\x06\x044\x03\x06\x04<\x03\x06\x05" + - "\x1d\x03\x06\x06\x00\x03\x06\x06\x0a\x03\x06\x06'\x03\x06\x062\x03\x0786" + - "\x03\x079/\x03\x079 \x03\x07:\x0e\x03\x07:\x1b\x03\x07:%\x03\x07;/\x03" + - "\x07;%\x03\x074\x11\x03\x076\x09\x03\x077*\x03\x070\x01\x03\x070\x0f\x03" + - "\x070.\x03\x071\x16\x03\x071\x04\x03\x0710\x03\x072\x18\x03\x072-\x03" + - "\x073\x14\x03\x073>\x03\x07'\x09\x03\x07 \x00\x03\x07\x1f\x0b\x03\x07" + - "\x18#\x03\x07\x18(\x03\x07\x186\x03\x07\x18\x03\x03\x07\x19\x16\x03\x07" + - "\x116\x03\x07\x12'\x03\x07\x13\x10\x03\x07\x0c&\x03\x07\x0c\x08\x03\x07" + - "\x0c\x13\x03\x07\x0d\x02\x03\x07\x0d\x1c\x03\x07\x0b5\x03\x07\x0b\x0a" + - "\x03\x07\x0b\x01\x03\x07\x0b\x0f\x03\x07\x05\x00\x03\x07\x05\x09\x03\x07" + - "\x05\x0b\x03\x07\x07\x01\x03\x07\x07\x08\x03\x07\x00<\x03\x07\x00+\x03" + - "\x07\x01)\x03\x07\x01\x1b\x03\x07\x01\x08\x03\x07\x03?\x03\x0445\x03\x04" + - "4\x08\x03\x0454\x03\x04)/\x03\x04)5\x03\x04+\x05\x03\x04+\x14\x03\x04+ " + - "\x03\x04+<\x03\x04*&\x03\x04*\x22\x03\x04&8\x03\x04!\x01\x03\x04!\x22" + - "\x03\x04\x11+\x03\x04\x10.\x03\x04\x104\x03\x04\x13=\x03\x04\x12\x04\x03" + - "\x04\x12\x0a\x03\x04\x0d\x1d\x03\x04\x0d\x07\x03\x04\x0d \x03\x05<>\x03" + - "\x055<\x03\x055!\x03\x055#\x03\x055&\x03\x054\x1d\x03\x054\x02\x03\x054" + - "\x07\x03\x0571\x03\x053\x1a\x03\x053\x16\x03\x05.<\x03\x05.\x07\x03\x05)" + - ":\x03\x05)<\x03\x05)\x0c\x03\x05)\x15\x03\x05+-\x03\x05+5\x03\x05$\x1e" + - "\x03\x05$\x14\x03\x05'\x04\x03\x05'\x14\x03\x05&\x02\x03\x05\x226\x03" + - "\x05\x22\x0c\x03\x05\x22\x1c\x03\x05\x19\x0a\x03\x05\x1b\x09\x03\x05\x1b" + - "\x0c\x03\x05\x14\x07\x03\x05\x16?\x03\x05\x16\x0c\x03\x05\x0c\x05\x03" + - "\x05\x0e\x0f\x03\x05\x01\x0e\x03\x05\x00(\x03\x05\x030\x03\x05\x03\x06" + - "\x03\x0a==\x03\x0a=1\x03\x0a=,\x03\x0a=\x0c\x03\x0a??\x03\x0a<\x08\x03" + - "\x0a9!\x03\x0a9)\x03\x0a97\x03\x0a99\x03\x0a6\x0a\x03\x0a6\x1c\x03\x0a6" + - "\x17\x03\x0a7'\x03\x0a78\x03\x0a73\x03\x0a'\x01\x03\x0a'&\x03\x0a\x1f" + - "\x0e\x03\x0a\x1f\x03\x03\x0a\x1f3\x03\x0a\x1b/\x03\x0a\x18\x19\x03\x0a" + - "\x19\x01\x03\x0a\x16\x14\x03\x0a\x0e\x22\x03\x0a\x0f\x10\x03\x0a\x0f\x02" + - "\x03\x0a\x0f \x03\x0a\x0c\x04\x03\x0a\x0b>\x03\x0a\x0b+\x03\x0a\x08/\x03" + - "\x0a\x046\x03\x0a\x05\x14\x03\x0a\x00\x04\x03\x0a\x00\x10\x03\x0a\x00" + - "\x14\x03\x0b<3\x03\x0b;*\x03\x0b9\x22\x03\x0b9)\x03\x0b97\x03\x0b+\x10" + - "\x03\x0b((\x03\x0b&5\x03\x0b$\x1c\x03\x0b$\x12\x03\x0b%\x04\x03\x0b#<" + - "\x03\x0b#0\x03\x0b#\x0d\x03\x0b#\x19\x03\x0b!:\x03\x0b!\x1f\x03\x0b!\x00" + - "\x03\x0b\x1e5\x03\x0b\x1c\x1d\x03\x0b\x1d-\x03\x0b\x1d(\x03\x0b\x18.\x03" + - "\x0b\x18 \x03\x0b\x18\x16\x03\x0b\x14\x13\x03\x0b\x15$\x03\x0b\x15\x22" + - "\x03\x0b\x12\x1b\x03\x0b\x12\x10\x03\x0b\x132\x03\x0b\x13=\x03\x0b\x12" + - "\x18\x03\x0b\x0c&\x03\x0b\x061\x03\x0b\x06:\x03\x0b\x05#\x03\x0b\x05<" + - "\x03\x0b\x04\x0b\x03\x0b\x04\x04\x03\x0b\x04\x1b\x03\x0b\x042\x03\x0b" + - "\x041\x03\x0b\x03\x03\x03\x0b\x03\x1d\x03\x0b\x03/\x03\x0b\x03+\x03\x0b" + - "\x02\x1b\x03\x0b\x02\x00\x03\x0b\x01\x1e\x03\x0b\x01\x08\x03\x0b\x015" + - "\x03\x06\x0d9\x03\x06\x0d=\x03\x06\x0d?\x03\x02\x001\x03\x02\x003\x03" + - "\x02\x02\x19\x03\x02\x006\x03\x02\x02\x1b\x03\x02\x004\x03\x02\x00<\x03" + - "\x02\x02\x0a\x03\x02\x02\x0e\x03\x02\x01\x1a\x03\x02\x01\x07\x03\x02\x01" + - "\x05\x03\x02\x01\x0b\x03\x02\x01%\x03\x02\x01\x0c\x03\x02\x01\x04\x03" + - "\x02\x01\x1c\x03\x02\x00.\x03\x02\x002\x03\x02\x00>\x03\x02\x00\x12\x03" + - "\x02\x00\x16\x03\x02\x011\x03\x02\x013\x03\x02\x02 \x03\x02\x02%\x03\x02" + - "\x02$\x03\x02\x028\x03\x02\x02;\x03\x02\x024\x03\x02\x012\x03\x02\x022" + - "\x03\x02\x02/\x03\x02\x01,\x03\x02\x01\x13\x03\x02\x01\x16\x03\x02\x01" + - "\x11\x03\x02\x01\x1e\x03\x02\x01\x15\x03\x02\x01\x17\x03\x02\x01\x0f\x03" + - "\x02\x01\x08\x03\x02\x00?\x03\x02\x03\x07\x03\x02\x03\x0d\x03\x02\x03" + - "\x13\x03\x02\x03\x1d\x03\x02\x03\x1f\x03\x02\x00\x03\x03\x02\x00\x0d\x03" + - "\x02\x00\x01\x03\x02\x00\x1b\x03\x02\x00\x19\x03\x02\x00\x18\x03\x02\x00" + - "\x13\x03\x02\x00/\x03\x07>\x12\x03\x07<\x1f\x03\x07>\x1d\x03\x06\x1d\x0e" + - "\x03\x07>\x1c\x03\x07>:\x03\x07>\x13\x03\x04\x12+\x03\x07?\x03\x03\x07>" + - "\x02\x03\x06\x224\x03\x06\x1a.\x03\x07<%\x03\x06\x1c\x0b\x03\x0609\x03" + - "\x05\x1f\x01\x03\x04'\x08\x03\x93\xfd\xf5\x03\x02\x0d \x03\x02\x0d#\x03" + - "\x02\x0d!\x03\x02\x0d&\x03\x02\x0d\x22\x03\x02\x0d/\x03\x02\x0d,\x03\x02" + - "\x0d$\x03\x02\x0d'\x03\x02\x0d%\x03\x02\x0d;\x03\x02\x0d=\x03\x02\x0d?" + - "\x03\x099.\x03\x08\x0b7\x03\x08\x02\x14\x03\x08\x14\x0d\x03\x08.:\x03" + - "\x089'\x03\x0f\x0b\x18\x03\x0f\x1c1\x03\x0f\x17&\x03\x0f9\x1f\x03\x0f0" + - "\x0c\x03\x0e\x0a9\x03\x0e\x056\x03\x0e\x1c#\x03\x0f\x13\x0e\x03\x072\x00" + - "\x03\x070\x0d\x03\x072\x0b\x03\x06\x11\x18\x03\x070\x10\x03\x06\x0f(\x03" + - "\x072\x05\x03\x06\x0f,\x03\x073\x15\x03\x06\x07\x08\x03\x05\x16\x02\x03" + - "\x04\x0b \x03\x05:8\x03\x05\x16%\x03\x0a\x0d\x1f\x03\x06\x16\x10\x03\x05" + - "\x1d5\x03\x05*;\x03\x05\x16\x1b\x03\x04.-\x03\x06\x1a\x19\x03\x04\x03," + - "\x03\x0b87\x03\x04/\x0a\x03\x06\x00,\x03\x04-\x01\x03\x04\x1e-\x03\x06/(" + - "\x03\x0a\x0b5\x03\x06\x0e7\x03\x06\x07.\x03\x0597\x03\x0a*%\x03\x0760" + - "\x03\x06\x0c;\x03\x05'\x00\x03\x072.\x03\x072\x08\x03\x06=\x01\x03\x06" + - "\x05\x1b\x03\x06\x06\x12\x03\x06$=\x03\x06'\x0d\x03\x04\x11\x0f\x03\x076" + - ",\x03\x06\x07;\x03\x06.,\x03\x86\xf9\xea\x03\x8f\xff\xeb\x02\x092\x02" + - "\x095\x02\x094\x02\x09;\x02\x09>\x02\x098\x02\x09*\x02\x09/\x02\x09,\x02" + - "\x09%\x02\x09&\x02\x09#\x02\x09 \x02\x08!\x02\x08%\x02\x08$\x02\x08+\x02" + - "\x08.\x02\x08*\x02\x08&\x02\x088\x02\x08>\x02\x084\x02\x086\x02\x080\x02" + - "\x08\x10\x02\x08\x17\x02\x08\x12\x02\x08\x1d\x02\x08\x1f\x02\x08\x13\x02" + - "\x08\x15\x02\x08\x14\x02\x08\x0c\x03\x8b\xfd\xd0\x03\x81\xec\xc6\x03\x87" + - "\xe0\x8a\x03-2\xe3\x03\x80\xef\xe4\x03-2\xea\x03\x88\xe6\xeb\x03\x8e\xe6" + - "\xe8\x03\x84\xe6\xe9\x03\x97\xe6\xee\x03-2\xf9\x03-2\xf6\x03\x8e\xe3\xad" + - "\x03\x80\xe3\x92\x03\x88\xe3\x90\x03\x8e\xe3\x90\x03\x80\xe3\x97\x03\x88" + - "\xe3\x95\x03\x88\xfe\xcb\x03\x8e\xfe\xca\x03\x84\xfe\xcd\x03\x91\xef\xc9" + - "\x03-2\xc1\x03-2\xc0\x03-2\xcb\x03\x88@\x09\x03\x8e@\x08\x03\x8f\xe0\xf5" + - "\x03\x8e\xe6\xf9\x03\x8e\xe0\xfa\x03\x93\xff\xf4\x03\x84\xee\xd3\x03\x0b" + - "(\x04\x023 \x021;\x02\x01*\x03\x0b#\x10\x03\x0b 0\x03\x0b!\x10\x03\x0b!0" + - "\x03\x07\x15\x08\x03\x09?5\x03\x07\x1f\x08\x03\x07\x17\x0b\x03\x09\x1f" + - "\x15\x03\x0b\x1c7\x03\x0a+#\x03\x06\x1a\x1b\x03\x06\x1a\x14\x03\x0a\x01" + - "\x18\x03\x06#\x1b\x03\x0a2\x0c\x03\x0a\x01\x04\x03\x09#;\x03\x08='\x03" + - "\x08\x1a\x0a\x03\x07\x03\x0a\x111\x03\x09\x1b\x09\x03\x073.\x03\x07\x01\x00" + - "\x03\x09/,\x03\x07#>\x03\x07\x048\x03\x0a\x1f\x22\x03\x098>\x03\x09\x11" + - "\x00\x03\x08/\x17\x03\x06'\x22\x03\x0b\x1a+\x03\x0a\x22\x19\x03\x0a/1" + - "\x03\x0974\x03\x09\x0f\x22\x03\x08,\x22\x03\x08?\x14\x03\x07$5\x03\x07<3" + - "\x03\x07=*\x03\x07\x13\x18\x03\x068\x0a\x03\x06\x09\x16\x03\x06\x13\x00" + - "\x03\x08\x067\x03\x08\x01\x03\x03\x08\x12\x1d\x03\x07+7\x03\x06(;\x03" + - "\x06\x1c?\x03\x07\x0e\x17\x03\x0a\x06\x1d\x03\x0a\x19\x07\x03\x08\x14$" + - "\x03\x07$;\x03\x08,$\x03\x08\x06\x0d\x03\x07\x16\x0a\x03\x06>>\x03\x0a" + - "\x06\x12\x03\x0a\x14)\x03\x09\x0d\x1f\x03\x09\x12\x17\x03\x09\x19\x01" + - "\x03\x08\x11 \x03\x08\x1d'\x03\x06<\x1a\x03\x0a.\x00\x03\x07'\x18\x03" + - "\x0a\x22\x08\x03\x08\x0d\x0a\x03\x08\x13)\x03\x07*)\x03\x06<,\x03\x07" + - "\x0b\x1a\x03\x09.\x14\x03\x09\x0d\x1e\x03\x07\x0e#\x03\x0b\x1d'\x03\x0a" + - "\x0a8\x03\x09%2\x03\x08+&\x03\x080\x12\x03\x0a)4\x03\x08\x06\x1f\x03\x0b" + - "\x1b\x1a\x03\x0a\x1b\x0f\x03\x0b\x1d*\x03\x09\x16$\x03\x090\x11\x03\x08" + - "\x11\x08\x03\x0a*(\x03\x0a\x042\x03\x089,\x03\x074'\x03\x07\x0f\x05\x03" + - "\x09\x0b\x0a\x03\x07\x1b\x01\x03\x09\x17:\x03\x09.\x0d\x03\x07.\x11\x03" + - "\x09+\x15\x03\x080\x13\x03\x0b\x1f\x19\x03\x0a \x11\x03\x0a\x220\x03\x09" + - "\x07;\x03\x08\x16\x1c\x03\x07,\x13\x03\x07\x0e/\x03\x06\x221\x03\x0a." + - "\x0a\x03\x0a7\x02\x03\x0a\x032\x03\x0a\x1d.\x03\x091\x06\x03\x09\x19:" + - "\x03\x08\x02/\x03\x060+\x03\x06\x0f-\x03\x06\x1c\x1f\x03\x06\x1d\x07\x03" + - "\x0a,\x11\x03\x09=\x0d\x03\x09\x0b;\x03\x07\x1b/\x03\x0a\x1f:\x03\x09 " + - "\x1f\x03\x09.\x10\x03\x094\x0b\x03\x09\x1a1\x03\x08#\x1a\x03\x084\x1d" + - "\x03\x08\x01\x1f\x03\x08\x11\x22\x03\x07'8\x03\x07\x1a>\x03\x0757\x03" + - "\x06&9\x03\x06+\x11\x03\x0a.\x0b\x03\x0a,>\x03\x0a4#\x03\x08%\x17\x03" + - "\x07\x05\x22\x03\x07\x0c\x0b\x03\x0a\x1d+\x03\x0a\x19\x16\x03\x09+\x1f" + - "\x03\x09\x08\x0b\x03\x08\x16\x18\x03\x08+\x12\x03\x0b\x1d\x0c\x03\x0a=" + - "\x10\x03\x0a\x09\x0d\x03\x0a\x10\x11\x03\x09&0\x03\x08(\x1f\x03\x087\x07" + - "\x03\x08\x185\x03\x07'6\x03\x06.\x05\x03\x06=\x04\x03\x06;;\x03\x06\x06," + - "\x03\x0b\x18>\x03\x08\x00\x18\x03\x06 \x03\x03\x06<\x00\x03\x09%\x18\x03" + - "\x0b\x1c<\x03\x0a%!\x03\x0a\x09\x12\x03\x0a\x16\x02\x03\x090'\x03\x09" + - "\x0e=\x03\x08 \x0e\x03\x08>\x03\x03\x074>\x03\x06&?\x03\x06\x19\x09\x03" + - "\x06?(\x03\x0a-\x0e\x03\x09:3\x03\x098:\x03\x09\x12\x0b\x03\x09\x1d\x17" + - "\x03\x087\x05\x03\x082\x14\x03\x08\x06%\x03\x08\x13\x1f\x03\x06\x06\x0e" + - "\x03\x0a\x22<\x03\x09/<\x03\x06>+\x03\x0a'?\x03\x0a\x13\x0c\x03\x09\x10<" + - "\x03\x07\x1b=\x03\x0a\x19\x13\x03\x09\x22\x1d\x03\x09\x07\x0d\x03\x08)" + - "\x1c\x03\x06=\x1a\x03\x0a/4\x03\x0a7\x11\x03\x0a\x16:\x03\x09?3\x03\x09:" + - "/\x03\x09\x05\x0a\x03\x09\x14\x06\x03\x087\x22\x03\x080\x07\x03\x08\x1a" + - "\x1f\x03\x07\x04(\x03\x07\x04\x09\x03\x06 %\x03\x06<\x08\x03\x0a+\x14" + - "\x03\x09\x1d\x16\x03\x0a70\x03\x08 >\x03\x0857\x03\x070\x0a\x03\x06=\x12" + - "\x03\x06\x16%\x03\x06\x1d,\x03\x099#\x03\x09\x10>\x03\x07 \x1e\x03\x08" + - "\x0c<\x03\x08\x0b\x18\x03\x08\x15+\x03\x08,:\x03\x08%\x22\x03\x07\x0a$" + - "\x03\x0b\x1c=\x03\x07+\x08\x03\x0a/\x05\x03\x0a \x07\x03\x0a\x12'\x03" + - "\x09#\x11\x03\x08\x1b\x15\x03\x0a\x06\x01\x03\x09\x1c\x1b\x03\x0922\x03" + - "\x07\x14<\x03\x07\x09\x04\x03\x061\x04\x03\x07\x0e\x01\x03\x0a\x13\x18" + - "\x03\x0a-\x0c\x03\x0a?\x0d\x03\x0a\x09\x0a\x03\x091&\x03\x0a/\x0b\x03" + - "\x08$<\x03\x083\x1d\x03\x08\x0c$\x03\x08\x0d\x07\x03\x08\x0d?\x03\x08" + - "\x0e\x14\x03\x065\x0a\x03\x08\x1a#\x03\x08\x16#\x03\x0702\x03\x07\x03" + - "\x1a\x03\x06(\x1d\x03\x06+\x1b\x03\x06\x0b\x05\x03\x06\x0b\x17\x03\x06" + - "\x0c\x04\x03\x06\x1e\x19\x03\x06+0\x03\x062\x18\x03\x0b\x16\x1e\x03\x0a+" + - "\x16\x03\x0a-?\x03\x0a#:\x03\x0a#\x10\x03\x0a%$\x03\x0a>+\x03\x0a01\x03" + - "\x0a1\x10\x03\x0a\x099\x03\x0a\x0a\x12\x03\x0a\x19\x1f\x03\x0a\x19\x12" + - "\x03\x09*)\x03\x09-\x16\x03\x09.1\x03\x09.2\x03\x09<\x0e\x03\x09> \x03" + - "\x093\x12\x03\x09\x0b\x01\x03\x09\x1c2\x03\x09\x11\x1c\x03\x09\x15%\x03" + - "\x08,&\x03\x08!\x22\x03\x089(\x03\x08\x0b\x1a\x03\x08\x0d2\x03\x08\x0c" + - "\x04\x03\x08\x0c\x06\x03\x08\x0c\x1f\x03\x08\x0c\x0c\x03\x08\x0f\x1f\x03" + - "\x08\x0f\x1d\x03\x08\x00\x14\x03\x08\x03\x14\x03\x08\x06\x16\x03\x08\x1e" + - "#\x03\x08\x11\x11\x03\x08\x10\x18\x03\x08\x14(\x03\x07)\x1e\x03\x07.1" + - "\x03\x07 $\x03\x07 '\x03\x078\x08\x03\x07\x0d0\x03\x07\x0f7\x03\x07\x05#" + - "\x03\x07\x05\x1a\x03\x07\x1a7\x03\x07\x1d-\x03\x07\x17\x10\x03\x06)\x1f" + - "\x03\x062\x0b\x03\x066\x16\x03\x06\x09\x11\x03\x09(\x1e\x03\x07!5\x03" + - "\x0b\x11\x16\x03\x0a/\x04\x03\x0a,\x1a\x03\x0b\x173\x03\x0a,1\x03\x0a/5" + - "\x03\x0a\x221\x03\x0a\x22\x0d\x03\x0a?%\x03\x0a<,\x03\x0a?#\x03\x0a>\x19" + - "\x03\x0a\x08&\x03\x0a\x0b\x0e\x03\x0a\x0c:\x03\x0a\x0c+\x03\x0a\x03\x22" + - "\x03\x0a\x06)\x03\x0a\x11\x10\x03\x0a\x11\x1a\x03\x0a\x17-\x03\x0a\x14(" + - "\x03\x09)\x1e\x03\x09/\x09\x03\x09.\x00\x03\x09,\x07\x03\x09/*\x03\x09-9" + - "\x03\x09\x228\x03\x09%\x09\x03\x09:\x12\x03\x09;\x1d\x03\x09?\x06\x03" + - "\x093%\x03\x096\x05\x03\x096\x08\x03\x097\x02\x03\x09\x07,\x03\x09\x04," + - "\x03\x09\x1f\x16\x03\x09\x11\x03\x03\x09\x11\x12\x03\x09\x168\x03\x08*" + - "\x05\x03\x08/2\x03\x084:\x03\x08\x22+\x03\x08 0\x03\x08&\x0a\x03\x08;" + - "\x10\x03\x08>$\x03\x08>\x18\x03\x0829\x03\x082:\x03\x081,\x03\x081<\x03" + - "\x081\x1c\x03\x087#\x03\x087*\x03\x08\x09'\x03\x08\x00\x1d\x03\x08\x05-" + - "\x03\x08\x1f4\x03\x08\x1d\x04\x03\x08\x16\x0f\x03\x07*7\x03\x07'!\x03" + - "\x07%\x1b\x03\x077\x0c\x03\x07\x0c1\x03\x07\x0c.\x03\x07\x00\x06\x03\x07" + - "\x01\x02\x03\x07\x010\x03\x07\x06=\x03\x07\x01\x03\x03\x07\x01\x13\x03" + - "\x07\x06\x06\x03\x07\x05\x0a\x03\x07\x1f\x09\x03\x07\x17:\x03\x06*1\x03" + - "\x06-\x1d\x03\x06\x223\x03\x062:\x03\x060$\x03\x066\x1e\x03\x064\x12\x03" + - "\x0645\x03\x06\x0b\x00\x03\x06\x0b7\x03\x06\x07\x1f\x03\x06\x15\x12\x03" + - "\x0c\x05\x0f\x03\x0b+\x0b\x03\x0b+-\x03\x06\x16\x1b\x03\x06\x15\x17\x03" + - "\x89\xca\xea\x03\x89\xca\xe8\x03\x0c8\x10\x03\x0c8\x01\x03\x0c8\x0f\x03" + - "\x0d8%\x03\x0d8!\x03\x0c8-\x03\x0c8/\x03\x0c8+\x03\x0c87\x03\x0c85\x03" + - "\x0c9\x09\x03\x0c9\x0d\x03\x0c9\x0f\x03\x0c9\x0b\x03\xcfu\x0c\x03\xcfu" + - "\x0f\x03\xcfu\x0e\x03\xcfu\x09\x03\x0c9\x10\x03\x0d9\x0c\x03\xcf`;\x03" + - "\xcf`>\x03\xcf`9\x03\xcf`8\x03\xcf`7\x03\xcf`*\x03\xcf`-\x03\xcf`,\x03" + - "\x0d\x1b\x1a\x03\x0d\x1b&\x03\x0c=.\x03\x0c=%\x03\x0c>\x1e\x03\x0c>\x14" + - "\x03\x0c?\x06\x03\x0c?\x0b\x03\x0c?\x0c\x03\x0c?\x0d\x03\x0c?\x02\x03" + - "\x0c>\x0f\x03\x0c>\x08\x03\x0c>\x09\x03\x0c>,\x03\x0c>\x0c\x03\x0c?\x13" + - "\x03\x0c?\x16\x03\x0c?\x15\x03\x0c?\x1c\x03\x0c?\x1f\x03\x0c?\x1d\x03" + - "\x0c?\x1a\x03\x0c?\x17\x03\x0c?\x08\x03\x0c?\x09\x03\x0c?\x0e\x03\x0c?" + - "\x04\x03\x0c?\x05\x03\x0c" + - "\x03\x0c=2\x03\x0c=6\x03\x0c<\x07\x03\x0c<\x05\x03\x0e:!\x03\x0e:#\x03" + - "\x0e8\x09\x03\x0e:&\x03\x0e8\x0b\x03\x0e:$\x03\x0e:,\x03\x0e8\x1a\x03" + - "\x0e8\x1e\x03\x0e:*\x03\x0e:7\x03\x0e:5\x03\x0e:;\x03\x0e:\x15\x03\x0e:<" + - "\x03\x0e:4\x03\x0e:'\x03\x0e:-\x03\x0e:%\x03\x0e:?\x03\x0e:=\x03\x0e:)" + - "\x03\x0e:/\x03\xcfs'\x03\x0d=\x0f\x03\x0d+*\x03\x0d99\x03\x0d9;\x03\x0d9" + - "?\x03\x0d)\x0d\x03\x0d(%\x02\x01\x18\x02\x01(\x02\x01\x1e\x03\x0f$!\x03" + - "\x0f87\x03\x0f4\x0e\x03\x0f5\x1d\x03\x06'\x03\x03\x0f\x08\x18\x03\x0f" + - "\x0d\x1b\x03\x0e2=\x03\x0e;\x08\x03\x0e:\x0b\x03\x0e\x06$\x03\x0e\x0d)" + - "\x03\x0e\x16\x1f\x03\x0e\x16\x1b\x03\x0d$\x0a\x03\x05,\x1d\x03\x0d. \x03" + - "\x0d.#\x03\x0c(/\x03\x09%\x02\x03\x0d90\x03\x0d\x0e4\x03\x0d\x0d\x0f\x03" + - "\x0c#\x00\x03\x0c,\x1e\x03\x0c2\x0e\x03\x0c\x01\x17\x03\x0c\x09:\x03\x0e" + - "\x173\x03\x0c\x08\x03\x03\x0c\x11\x07\x03\x0c\x10\x18\x03\x0c\x1f\x1c" + - "\x03\x0c\x19\x0e\x03\x0c\x1a\x1f\x03\x0f0>\x03\x0b->\x03\x0b<+\x03\x0b8" + - "\x13\x03\x0b\x043\x03\x0b\x14\x03\x03\x0b\x16%\x03\x0d\x22&\x03\x0b\x1a" + - "\x1a\x03\x0b\x1a\x04\x03\x0a%9\x03\x0a&2\x03\x0a&0\x03\x0a!\x1a\x03\x0a!" + - "7\x03\x0a5\x10\x03\x0a=4\x03\x0a?\x0e\x03\x0a>\x10\x03\x0a\x00 \x03\x0a" + - "\x0f:\x03\x0a\x0f9\x03\x0a\x0b\x0a\x03\x0a\x17%\x03\x0a\x1b-\x03\x09-" + - "\x1a\x03\x09,4\x03\x09.,\x03\x09)\x09\x03\x096!\x03\x091\x1f\x03\x093" + - "\x16\x03\x0c+\x1f\x03\x098 \x03\x098=\x03\x0c(\x1a\x03\x0c(\x16\x03\x09" + - "\x0a+\x03\x09\x16\x12\x03\x09\x13\x0e\x03\x09\x153\x03\x08)!\x03\x09\x1a" + - "\x01\x03\x09\x18\x01\x03\x08%#\x03\x08>\x22\x03\x08\x05%\x03\x08\x02*" + - "\x03\x08\x15;\x03\x08\x1b7\x03\x0f\x07\x1d\x03\x0f\x04\x03\x03\x070\x0c" + - "\x03\x07;\x0b\x03\x07\x08\x17\x03\x07\x12\x06\x03\x06/-\x03\x0671\x03" + - "\x065+\x03\x06>7\x03\x06\x049\x03\x05+\x1e\x03\x05,\x17\x03\x05 \x1d\x03" + - "\x05\x22\x05\x03\x050\x1d" - -// lookup returns the trie value for the first UTF-8 encoding in s and -// the width in bytes of this encoding. The size will be 0 if s does not -// hold enough bytes to complete the encoding. len(s) must be greater than 0. -func (t *idnaTrie) lookup(s []byte) (v uint16, sz int) { - c0 := s[0] - switch { - case c0 < 0x80: // is ASCII - return idnaValues[c0], 1 - case c0 < 0xC2: - return 0, 1 // Illegal UTF-8: not a starter, not ASCII. - case c0 < 0xE0: // 2-byte UTF-8 - if len(s) < 2 { - return 0, 0 - } - i := idnaIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c1), 2 - case c0 < 0xF0: // 3-byte UTF-8 - if len(s) < 3 { - return 0, 0 - } - i := idnaIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = idnaIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c2), 3 - case c0 < 0xF8: // 4-byte UTF-8 - if len(s) < 4 { - return 0, 0 - } - i := idnaIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = idnaIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - o = uint32(i)<<6 + uint32(c2) - i = idnaIndex[o] - c3 := s[3] - if c3 < 0x80 || 0xC0 <= c3 { - return 0, 3 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c3), 4 - } - // Illegal rune - return 0, 1 -} - -// lookupUnsafe returns the trie value for the first UTF-8 encoding in s. -// s must start with a full and valid UTF-8 encoded rune. -func (t *idnaTrie) lookupUnsafe(s []byte) uint16 { - c0 := s[0] - if c0 < 0x80 { // is ASCII - return idnaValues[c0] - } - i := idnaIndex[c0] - if c0 < 0xE0 { // 2-byte UTF-8 - return t.lookupValue(uint32(i), s[1]) - } - i = idnaIndex[uint32(i)<<6+uint32(s[1])] - if c0 < 0xF0 { // 3-byte UTF-8 - return t.lookupValue(uint32(i), s[2]) - } - i = idnaIndex[uint32(i)<<6+uint32(s[2])] - if c0 < 0xF8 { // 4-byte UTF-8 - return t.lookupValue(uint32(i), s[3]) - } - return 0 -} - -// lookupString returns the trie value for the first UTF-8 encoding in s and -// the width in bytes of this encoding. The size will be 0 if s does not -// hold enough bytes to complete the encoding. len(s) must be greater than 0. -func (t *idnaTrie) lookupString(s string) (v uint16, sz int) { - c0 := s[0] - switch { - case c0 < 0x80: // is ASCII - return idnaValues[c0], 1 - case c0 < 0xC2: - return 0, 1 // Illegal UTF-8: not a starter, not ASCII. - case c0 < 0xE0: // 2-byte UTF-8 - if len(s) < 2 { - return 0, 0 - } - i := idnaIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c1), 2 - case c0 < 0xF0: // 3-byte UTF-8 - if len(s) < 3 { - return 0, 0 - } - i := idnaIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = idnaIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c2), 3 - case c0 < 0xF8: // 4-byte UTF-8 - if len(s) < 4 { - return 0, 0 - } - i := idnaIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = idnaIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - o = uint32(i)<<6 + uint32(c2) - i = idnaIndex[o] - c3 := s[3] - if c3 < 0x80 || 0xC0 <= c3 { - return 0, 3 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c3), 4 - } - // Illegal rune - return 0, 1 -} - -// lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s. -// s must start with a full and valid UTF-8 encoded rune. -func (t *idnaTrie) lookupStringUnsafe(s string) uint16 { - c0 := s[0] - if c0 < 0x80 { // is ASCII - return idnaValues[c0] - } - i := idnaIndex[c0] - if c0 < 0xE0 { // 2-byte UTF-8 - return t.lookupValue(uint32(i), s[1]) - } - i = idnaIndex[uint32(i)<<6+uint32(s[1])] - if c0 < 0xF0 { // 3-byte UTF-8 - return t.lookupValue(uint32(i), s[2]) - } - i = idnaIndex[uint32(i)<<6+uint32(s[2])] - if c0 < 0xF8 { // 4-byte UTF-8 - return t.lookupValue(uint32(i), s[3]) - } - return 0 -} - -// idnaTrie. Total size: 28496 bytes (27.83 KiB). Checksum: 43288b883596640e. -type idnaTrie struct{} - -func newIdnaTrie(i int) *idnaTrie { - return &idnaTrie{} -} - -// lookupValue determines the type of block n and looks up the value for b. -func (t *idnaTrie) lookupValue(n uint32, b byte) uint16 { - switch { - case n < 123: - return uint16(idnaValues[n<<6+uint32(b)]) - default: - n -= 123 - return uint16(idnaSparse.lookup(n, b)) - } -} - -// idnaValues: 125 blocks, 8000 entries, 16000 bytes -// The third block is the zero block. -var idnaValues = [8000]uint16{ - // Block 0x0, offset 0x0 - 0x00: 0x0080, 0x01: 0x0080, 0x02: 0x0080, 0x03: 0x0080, 0x04: 0x0080, 0x05: 0x0080, - 0x06: 0x0080, 0x07: 0x0080, 0x08: 0x0080, 0x09: 0x0080, 0x0a: 0x0080, 0x0b: 0x0080, - 0x0c: 0x0080, 0x0d: 0x0080, 0x0e: 0x0080, 0x0f: 0x0080, 0x10: 0x0080, 0x11: 0x0080, - 0x12: 0x0080, 0x13: 0x0080, 0x14: 0x0080, 0x15: 0x0080, 0x16: 0x0080, 0x17: 0x0080, - 0x18: 0x0080, 0x19: 0x0080, 0x1a: 0x0080, 0x1b: 0x0080, 0x1c: 0x0080, 0x1d: 0x0080, - 0x1e: 0x0080, 0x1f: 0x0080, 0x20: 0x0080, 0x21: 0x0080, 0x22: 0x0080, 0x23: 0x0080, - 0x24: 0x0080, 0x25: 0x0080, 0x26: 0x0080, 0x27: 0x0080, 0x28: 0x0080, 0x29: 0x0080, - 0x2a: 0x0080, 0x2b: 0x0080, 0x2c: 0x0080, 0x2d: 0x0008, 0x2e: 0x0008, 0x2f: 0x0080, - 0x30: 0x0008, 0x31: 0x0008, 0x32: 0x0008, 0x33: 0x0008, 0x34: 0x0008, 0x35: 0x0008, - 0x36: 0x0008, 0x37: 0x0008, 0x38: 0x0008, 0x39: 0x0008, 0x3a: 0x0080, 0x3b: 0x0080, - 0x3c: 0x0080, 0x3d: 0x0080, 0x3e: 0x0080, 0x3f: 0x0080, - // Block 0x1, offset 0x40 - 0x40: 0x0080, 0x41: 0xe105, 0x42: 0xe105, 0x43: 0xe105, 0x44: 0xe105, 0x45: 0xe105, - 0x46: 0xe105, 0x47: 0xe105, 0x48: 0xe105, 0x49: 0xe105, 0x4a: 0xe105, 0x4b: 0xe105, - 0x4c: 0xe105, 0x4d: 0xe105, 0x4e: 0xe105, 0x4f: 0xe105, 0x50: 0xe105, 0x51: 0xe105, - 0x52: 0xe105, 0x53: 0xe105, 0x54: 0xe105, 0x55: 0xe105, 0x56: 0xe105, 0x57: 0xe105, - 0x58: 0xe105, 0x59: 0xe105, 0x5a: 0xe105, 0x5b: 0x0080, 0x5c: 0x0080, 0x5d: 0x0080, - 0x5e: 0x0080, 0x5f: 0x0080, 0x60: 0x0080, 0x61: 0x0008, 0x62: 0x0008, 0x63: 0x0008, - 0x64: 0x0008, 0x65: 0x0008, 0x66: 0x0008, 0x67: 0x0008, 0x68: 0x0008, 0x69: 0x0008, - 0x6a: 0x0008, 0x6b: 0x0008, 0x6c: 0x0008, 0x6d: 0x0008, 0x6e: 0x0008, 0x6f: 0x0008, - 0x70: 0x0008, 0x71: 0x0008, 0x72: 0x0008, 0x73: 0x0008, 0x74: 0x0008, 0x75: 0x0008, - 0x76: 0x0008, 0x77: 0x0008, 0x78: 0x0008, 0x79: 0x0008, 0x7a: 0x0008, 0x7b: 0x0080, - 0x7c: 0x0080, 0x7d: 0x0080, 0x7e: 0x0080, 0x7f: 0x0080, - // Block 0x2, offset 0x80 - // Block 0x3, offset 0xc0 - 0xc0: 0x0040, 0xc1: 0x0040, 0xc2: 0x0040, 0xc3: 0x0040, 0xc4: 0x0040, 0xc5: 0x0040, - 0xc6: 0x0040, 0xc7: 0x0040, 0xc8: 0x0040, 0xc9: 0x0040, 0xca: 0x0040, 0xcb: 0x0040, - 0xcc: 0x0040, 0xcd: 0x0040, 0xce: 0x0040, 0xcf: 0x0040, 0xd0: 0x0040, 0xd1: 0x0040, - 0xd2: 0x0040, 0xd3: 0x0040, 0xd4: 0x0040, 0xd5: 0x0040, 0xd6: 0x0040, 0xd7: 0x0040, - 0xd8: 0x0040, 0xd9: 0x0040, 0xda: 0x0040, 0xdb: 0x0040, 0xdc: 0x0040, 0xdd: 0x0040, - 0xde: 0x0040, 0xdf: 0x0040, 0xe0: 0x000a, 0xe1: 0x0018, 0xe2: 0x0018, 0xe3: 0x0018, - 0xe4: 0x0018, 0xe5: 0x0018, 0xe6: 0x0018, 0xe7: 0x0018, 0xe8: 0x001a, 0xe9: 0x0018, - 0xea: 0x0039, 0xeb: 0x0018, 0xec: 0x0018, 0xed: 0x03c0, 0xee: 0x0018, 0xef: 0x004a, - 0xf0: 0x0018, 0xf1: 0x0018, 0xf2: 0x0069, 0xf3: 0x0079, 0xf4: 0x008a, 0xf5: 0x0005, - 0xf6: 0x0018, 0xf7: 0x0008, 0xf8: 0x00aa, 0xf9: 0x00c9, 0xfa: 0x00d9, 0xfb: 0x0018, - 0xfc: 0x00e9, 0xfd: 0x0119, 0xfe: 0x0149, 0xff: 0x0018, - // Block 0x4, offset 0x100 - 0x100: 0xe00d, 0x101: 0x0008, 0x102: 0xe00d, 0x103: 0x0008, 0x104: 0xe00d, 0x105: 0x0008, - 0x106: 0xe00d, 0x107: 0x0008, 0x108: 0xe00d, 0x109: 0x0008, 0x10a: 0xe00d, 0x10b: 0x0008, - 0x10c: 0xe00d, 0x10d: 0x0008, 0x10e: 0xe00d, 0x10f: 0x0008, 0x110: 0xe00d, 0x111: 0x0008, - 0x112: 0xe00d, 0x113: 0x0008, 0x114: 0xe00d, 0x115: 0x0008, 0x116: 0xe00d, 0x117: 0x0008, - 0x118: 0xe00d, 0x119: 0x0008, 0x11a: 0xe00d, 0x11b: 0x0008, 0x11c: 0xe00d, 0x11d: 0x0008, - 0x11e: 0xe00d, 0x11f: 0x0008, 0x120: 0xe00d, 0x121: 0x0008, 0x122: 0xe00d, 0x123: 0x0008, - 0x124: 0xe00d, 0x125: 0x0008, 0x126: 0xe00d, 0x127: 0x0008, 0x128: 0xe00d, 0x129: 0x0008, - 0x12a: 0xe00d, 0x12b: 0x0008, 0x12c: 0xe00d, 0x12d: 0x0008, 0x12e: 0xe00d, 0x12f: 0x0008, - 0x130: 0x0179, 0x131: 0x0008, 0x132: 0x0035, 0x133: 0x004d, 0x134: 0xe00d, 0x135: 0x0008, - 0x136: 0xe00d, 0x137: 0x0008, 0x138: 0x0008, 0x139: 0xe01d, 0x13a: 0x0008, 0x13b: 0xe03d, - 0x13c: 0x0008, 0x13d: 0xe01d, 0x13e: 0x0008, 0x13f: 0x0199, - // Block 0x5, offset 0x140 - 0x140: 0x0199, 0x141: 0xe01d, 0x142: 0x0008, 0x143: 0xe03d, 0x144: 0x0008, 0x145: 0xe01d, - 0x146: 0x0008, 0x147: 0xe07d, 0x148: 0x0008, 0x149: 0x01b9, 0x14a: 0xe00d, 0x14b: 0x0008, - 0x14c: 0xe00d, 0x14d: 0x0008, 0x14e: 0xe00d, 0x14f: 0x0008, 0x150: 0xe00d, 0x151: 0x0008, - 0x152: 0xe00d, 0x153: 0x0008, 0x154: 0xe00d, 0x155: 0x0008, 0x156: 0xe00d, 0x157: 0x0008, - 0x158: 0xe00d, 0x159: 0x0008, 0x15a: 0xe00d, 0x15b: 0x0008, 0x15c: 0xe00d, 0x15d: 0x0008, - 0x15e: 0xe00d, 0x15f: 0x0008, 0x160: 0xe00d, 0x161: 0x0008, 0x162: 0xe00d, 0x163: 0x0008, - 0x164: 0xe00d, 0x165: 0x0008, 0x166: 0xe00d, 0x167: 0x0008, 0x168: 0xe00d, 0x169: 0x0008, - 0x16a: 0xe00d, 0x16b: 0x0008, 0x16c: 0xe00d, 0x16d: 0x0008, 0x16e: 0xe00d, 0x16f: 0x0008, - 0x170: 0xe00d, 0x171: 0x0008, 0x172: 0xe00d, 0x173: 0x0008, 0x174: 0xe00d, 0x175: 0x0008, - 0x176: 0xe00d, 0x177: 0x0008, 0x178: 0x0065, 0x179: 0xe01d, 0x17a: 0x0008, 0x17b: 0xe03d, - 0x17c: 0x0008, 0x17d: 0xe01d, 0x17e: 0x0008, 0x17f: 0x01d9, - // Block 0x6, offset 0x180 - 0x180: 0x0008, 0x181: 0x007d, 0x182: 0xe00d, 0x183: 0x0008, 0x184: 0xe00d, 0x185: 0x0008, - 0x186: 0x007d, 0x187: 0xe07d, 0x188: 0x0008, 0x189: 0x0095, 0x18a: 0x00ad, 0x18b: 0xe03d, - 0x18c: 0x0008, 0x18d: 0x0008, 0x18e: 0x00c5, 0x18f: 0x00dd, 0x190: 0x00f5, 0x191: 0xe01d, - 0x192: 0x0008, 0x193: 0x010d, 0x194: 0x0125, 0x195: 0x0008, 0x196: 0x013d, 0x197: 0x013d, - 0x198: 0xe00d, 0x199: 0x0008, 0x19a: 0x0008, 0x19b: 0x0008, 0x19c: 0x010d, 0x19d: 0x0155, - 0x19e: 0x0008, 0x19f: 0x016d, 0x1a0: 0xe00d, 0x1a1: 0x0008, 0x1a2: 0xe00d, 0x1a3: 0x0008, - 0x1a4: 0xe00d, 0x1a5: 0x0008, 0x1a6: 0x0185, 0x1a7: 0xe07d, 0x1a8: 0x0008, 0x1a9: 0x019d, - 0x1aa: 0x0008, 0x1ab: 0x0008, 0x1ac: 0xe00d, 0x1ad: 0x0008, 0x1ae: 0x0185, 0x1af: 0xe0fd, - 0x1b0: 0x0008, 0x1b1: 0x01b5, 0x1b2: 0x01cd, 0x1b3: 0xe03d, 0x1b4: 0x0008, 0x1b5: 0xe01d, - 0x1b6: 0x0008, 0x1b7: 0x01e5, 0x1b8: 0xe00d, 0x1b9: 0x0008, 0x1ba: 0x0008, 0x1bb: 0x0008, - 0x1bc: 0xe00d, 0x1bd: 0x0008, 0x1be: 0x0008, 0x1bf: 0x0008, - // Block 0x7, offset 0x1c0 - 0x1c0: 0x0008, 0x1c1: 0x0008, 0x1c2: 0x0008, 0x1c3: 0x0008, 0x1c4: 0x01e9, 0x1c5: 0x01e9, - 0x1c6: 0x01e9, 0x1c7: 0x01fd, 0x1c8: 0x0215, 0x1c9: 0x022d, 0x1ca: 0x0245, 0x1cb: 0x025d, - 0x1cc: 0x0275, 0x1cd: 0xe01d, 0x1ce: 0x0008, 0x1cf: 0xe0fd, 0x1d0: 0x0008, 0x1d1: 0xe01d, - 0x1d2: 0x0008, 0x1d3: 0xe03d, 0x1d4: 0x0008, 0x1d5: 0xe01d, 0x1d6: 0x0008, 0x1d7: 0xe07d, - 0x1d8: 0x0008, 0x1d9: 0xe01d, 0x1da: 0x0008, 0x1db: 0xe03d, 0x1dc: 0x0008, 0x1dd: 0x0008, - 0x1de: 0xe00d, 0x1df: 0x0008, 0x1e0: 0xe00d, 0x1e1: 0x0008, 0x1e2: 0xe00d, 0x1e3: 0x0008, - 0x1e4: 0xe00d, 0x1e5: 0x0008, 0x1e6: 0xe00d, 0x1e7: 0x0008, 0x1e8: 0xe00d, 0x1e9: 0x0008, - 0x1ea: 0xe00d, 0x1eb: 0x0008, 0x1ec: 0xe00d, 0x1ed: 0x0008, 0x1ee: 0xe00d, 0x1ef: 0x0008, - 0x1f0: 0x0008, 0x1f1: 0x028d, 0x1f2: 0x02a5, 0x1f3: 0x02bd, 0x1f4: 0xe00d, 0x1f5: 0x0008, - 0x1f6: 0x02d5, 0x1f7: 0x02ed, 0x1f8: 0xe00d, 0x1f9: 0x0008, 0x1fa: 0xe00d, 0x1fb: 0x0008, - 0x1fc: 0xe00d, 0x1fd: 0x0008, 0x1fe: 0xe00d, 0x1ff: 0x0008, - // Block 0x8, offset 0x200 - 0x200: 0xe00d, 0x201: 0x0008, 0x202: 0xe00d, 0x203: 0x0008, 0x204: 0xe00d, 0x205: 0x0008, - 0x206: 0xe00d, 0x207: 0x0008, 0x208: 0xe00d, 0x209: 0x0008, 0x20a: 0xe00d, 0x20b: 0x0008, - 0x20c: 0xe00d, 0x20d: 0x0008, 0x20e: 0xe00d, 0x20f: 0x0008, 0x210: 0xe00d, 0x211: 0x0008, - 0x212: 0xe00d, 0x213: 0x0008, 0x214: 0xe00d, 0x215: 0x0008, 0x216: 0xe00d, 0x217: 0x0008, - 0x218: 0xe00d, 0x219: 0x0008, 0x21a: 0xe00d, 0x21b: 0x0008, 0x21c: 0xe00d, 0x21d: 0x0008, - 0x21e: 0xe00d, 0x21f: 0x0008, 0x220: 0x0305, 0x221: 0x0008, 0x222: 0xe00d, 0x223: 0x0008, - 0x224: 0xe00d, 0x225: 0x0008, 0x226: 0xe00d, 0x227: 0x0008, 0x228: 0xe00d, 0x229: 0x0008, - 0x22a: 0xe00d, 0x22b: 0x0008, 0x22c: 0xe00d, 0x22d: 0x0008, 0x22e: 0xe00d, 0x22f: 0x0008, - 0x230: 0xe00d, 0x231: 0x0008, 0x232: 0xe00d, 0x233: 0x0008, 0x234: 0x0008, 0x235: 0x0008, - 0x236: 0x0008, 0x237: 0x0008, 0x238: 0x0008, 0x239: 0x0008, 0x23a: 0x0209, 0x23b: 0xe03d, - 0x23c: 0x0008, 0x23d: 0x031d, 0x23e: 0x0229, 0x23f: 0x0008, - // Block 0x9, offset 0x240 - 0x240: 0x0008, 0x241: 0x0008, 0x242: 0x0018, 0x243: 0x0018, 0x244: 0x0018, 0x245: 0x0018, - 0x246: 0x0008, 0x247: 0x0008, 0x248: 0x0008, 0x249: 0x0008, 0x24a: 0x0008, 0x24b: 0x0008, - 0x24c: 0x0008, 0x24d: 0x0008, 0x24e: 0x0008, 0x24f: 0x0008, 0x250: 0x0008, 0x251: 0x0008, - 0x252: 0x0018, 0x253: 0x0018, 0x254: 0x0018, 0x255: 0x0018, 0x256: 0x0018, 0x257: 0x0018, - 0x258: 0x029a, 0x259: 0x02ba, 0x25a: 0x02da, 0x25b: 0x02fa, 0x25c: 0x031a, 0x25d: 0x033a, - 0x25e: 0x0018, 0x25f: 0x0018, 0x260: 0x03ad, 0x261: 0x0359, 0x262: 0x01d9, 0x263: 0x0369, - 0x264: 0x03c5, 0x265: 0x0018, 0x266: 0x0018, 0x267: 0x0018, 0x268: 0x0018, 0x269: 0x0018, - 0x26a: 0x0018, 0x26b: 0x0018, 0x26c: 0x0008, 0x26d: 0x0018, 0x26e: 0x0008, 0x26f: 0x0018, - 0x270: 0x0018, 0x271: 0x0018, 0x272: 0x0018, 0x273: 0x0018, 0x274: 0x0018, 0x275: 0x0018, - 0x276: 0x0018, 0x277: 0x0018, 0x278: 0x0018, 0x279: 0x0018, 0x27a: 0x0018, 0x27b: 0x0018, - 0x27c: 0x0018, 0x27d: 0x0018, 0x27e: 0x0018, 0x27f: 0x0018, - // Block 0xa, offset 0x280 - 0x280: 0x03dd, 0x281: 0x03dd, 0x282: 0x1308, 0x283: 0x03f5, 0x284: 0x0379, 0x285: 0x040d, - 0x286: 0x1308, 0x287: 0x1308, 0x288: 0x1308, 0x289: 0x1308, 0x28a: 0x1308, 0x28b: 0x1308, - 0x28c: 0x1308, 0x28d: 0x1308, 0x28e: 0x1308, 0x28f: 0x13c0, 0x290: 0x1308, 0x291: 0x1308, - 0x292: 0x1308, 0x293: 0x1308, 0x294: 0x1308, 0x295: 0x1308, 0x296: 0x1308, 0x297: 0x1308, - 0x298: 0x1308, 0x299: 0x1308, 0x29a: 0x1308, 0x29b: 0x1308, 0x29c: 0x1308, 0x29d: 0x1308, - 0x29e: 0x1308, 0x29f: 0x1308, 0x2a0: 0x1308, 0x2a1: 0x1308, 0x2a2: 0x1308, 0x2a3: 0x1308, - 0x2a4: 0x1308, 0x2a5: 0x1308, 0x2a6: 0x1308, 0x2a7: 0x1308, 0x2a8: 0x1308, 0x2a9: 0x1308, - 0x2aa: 0x1308, 0x2ab: 0x1308, 0x2ac: 0x1308, 0x2ad: 0x1308, 0x2ae: 0x1308, 0x2af: 0x1308, - 0x2b0: 0xe00d, 0x2b1: 0x0008, 0x2b2: 0xe00d, 0x2b3: 0x0008, 0x2b4: 0x0425, 0x2b5: 0x0008, - 0x2b6: 0xe00d, 0x2b7: 0x0008, 0x2b8: 0x0040, 0x2b9: 0x0040, 0x2ba: 0x03a2, 0x2bb: 0x0008, - 0x2bc: 0x0008, 0x2bd: 0x0008, 0x2be: 0x03c2, 0x2bf: 0x043d, - // Block 0xb, offset 0x2c0 - 0x2c0: 0x0040, 0x2c1: 0x0040, 0x2c2: 0x0040, 0x2c3: 0x0040, 0x2c4: 0x008a, 0x2c5: 0x03d2, - 0x2c6: 0xe155, 0x2c7: 0x0455, 0x2c8: 0xe12d, 0x2c9: 0xe13d, 0x2ca: 0xe12d, 0x2cb: 0x0040, - 0x2cc: 0x03dd, 0x2cd: 0x0040, 0x2ce: 0x046d, 0x2cf: 0x0485, 0x2d0: 0x0008, 0x2d1: 0xe105, - 0x2d2: 0xe105, 0x2d3: 0xe105, 0x2d4: 0xe105, 0x2d5: 0xe105, 0x2d6: 0xe105, 0x2d7: 0xe105, - 0x2d8: 0xe105, 0x2d9: 0xe105, 0x2da: 0xe105, 0x2db: 0xe105, 0x2dc: 0xe105, 0x2dd: 0xe105, - 0x2de: 0xe105, 0x2df: 0xe105, 0x2e0: 0x049d, 0x2e1: 0x049d, 0x2e2: 0x0040, 0x2e3: 0x049d, - 0x2e4: 0x049d, 0x2e5: 0x049d, 0x2e6: 0x049d, 0x2e7: 0x049d, 0x2e8: 0x049d, 0x2e9: 0x049d, - 0x2ea: 0x049d, 0x2eb: 0x049d, 0x2ec: 0x0008, 0x2ed: 0x0008, 0x2ee: 0x0008, 0x2ef: 0x0008, - 0x2f0: 0x0008, 0x2f1: 0x0008, 0x2f2: 0x0008, 0x2f3: 0x0008, 0x2f4: 0x0008, 0x2f5: 0x0008, - 0x2f6: 0x0008, 0x2f7: 0x0008, 0x2f8: 0x0008, 0x2f9: 0x0008, 0x2fa: 0x0008, 0x2fb: 0x0008, - 0x2fc: 0x0008, 0x2fd: 0x0008, 0x2fe: 0x0008, 0x2ff: 0x0008, - // Block 0xc, offset 0x300 - 0x300: 0x0008, 0x301: 0x0008, 0x302: 0xe00f, 0x303: 0x0008, 0x304: 0x0008, 0x305: 0x0008, - 0x306: 0x0008, 0x307: 0x0008, 0x308: 0x0008, 0x309: 0x0008, 0x30a: 0x0008, 0x30b: 0x0008, - 0x30c: 0x0008, 0x30d: 0x0008, 0x30e: 0x0008, 0x30f: 0xe0c5, 0x310: 0x04b5, 0x311: 0x04cd, - 0x312: 0xe0bd, 0x313: 0xe0f5, 0x314: 0xe0fd, 0x315: 0xe09d, 0x316: 0xe0b5, 0x317: 0x0008, - 0x318: 0xe00d, 0x319: 0x0008, 0x31a: 0xe00d, 0x31b: 0x0008, 0x31c: 0xe00d, 0x31d: 0x0008, - 0x31e: 0xe00d, 0x31f: 0x0008, 0x320: 0xe00d, 0x321: 0x0008, 0x322: 0xe00d, 0x323: 0x0008, - 0x324: 0xe00d, 0x325: 0x0008, 0x326: 0xe00d, 0x327: 0x0008, 0x328: 0xe00d, 0x329: 0x0008, - 0x32a: 0xe00d, 0x32b: 0x0008, 0x32c: 0xe00d, 0x32d: 0x0008, 0x32e: 0xe00d, 0x32f: 0x0008, - 0x330: 0x04e5, 0x331: 0xe185, 0x332: 0xe18d, 0x333: 0x0008, 0x334: 0x04fd, 0x335: 0x03dd, - 0x336: 0x0018, 0x337: 0xe07d, 0x338: 0x0008, 0x339: 0xe1d5, 0x33a: 0xe00d, 0x33b: 0x0008, - 0x33c: 0x0008, 0x33d: 0x0515, 0x33e: 0x052d, 0x33f: 0x052d, - // Block 0xd, offset 0x340 - 0x340: 0x0008, 0x341: 0x0008, 0x342: 0x0008, 0x343: 0x0008, 0x344: 0x0008, 0x345: 0x0008, - 0x346: 0x0008, 0x347: 0x0008, 0x348: 0x0008, 0x349: 0x0008, 0x34a: 0x0008, 0x34b: 0x0008, - 0x34c: 0x0008, 0x34d: 0x0008, 0x34e: 0x0008, 0x34f: 0x0008, 0x350: 0x0008, 0x351: 0x0008, - 0x352: 0x0008, 0x353: 0x0008, 0x354: 0x0008, 0x355: 0x0008, 0x356: 0x0008, 0x357: 0x0008, - 0x358: 0x0008, 0x359: 0x0008, 0x35a: 0x0008, 0x35b: 0x0008, 0x35c: 0x0008, 0x35d: 0x0008, - 0x35e: 0x0008, 0x35f: 0x0008, 0x360: 0xe00d, 0x361: 0x0008, 0x362: 0xe00d, 0x363: 0x0008, - 0x364: 0xe00d, 0x365: 0x0008, 0x366: 0xe00d, 0x367: 0x0008, 0x368: 0xe00d, 0x369: 0x0008, - 0x36a: 0xe00d, 0x36b: 0x0008, 0x36c: 0xe00d, 0x36d: 0x0008, 0x36e: 0xe00d, 0x36f: 0x0008, - 0x370: 0xe00d, 0x371: 0x0008, 0x372: 0xe00d, 0x373: 0x0008, 0x374: 0xe00d, 0x375: 0x0008, - 0x376: 0xe00d, 0x377: 0x0008, 0x378: 0xe00d, 0x379: 0x0008, 0x37a: 0xe00d, 0x37b: 0x0008, - 0x37c: 0xe00d, 0x37d: 0x0008, 0x37e: 0xe00d, 0x37f: 0x0008, - // Block 0xe, offset 0x380 - 0x380: 0xe00d, 0x381: 0x0008, 0x382: 0x0018, 0x383: 0x1308, 0x384: 0x1308, 0x385: 0x1308, - 0x386: 0x1308, 0x387: 0x1308, 0x388: 0x1318, 0x389: 0x1318, 0x38a: 0xe00d, 0x38b: 0x0008, - 0x38c: 0xe00d, 0x38d: 0x0008, 0x38e: 0xe00d, 0x38f: 0x0008, 0x390: 0xe00d, 0x391: 0x0008, - 0x392: 0xe00d, 0x393: 0x0008, 0x394: 0xe00d, 0x395: 0x0008, 0x396: 0xe00d, 0x397: 0x0008, - 0x398: 0xe00d, 0x399: 0x0008, 0x39a: 0xe00d, 0x39b: 0x0008, 0x39c: 0xe00d, 0x39d: 0x0008, - 0x39e: 0xe00d, 0x39f: 0x0008, 0x3a0: 0xe00d, 0x3a1: 0x0008, 0x3a2: 0xe00d, 0x3a3: 0x0008, - 0x3a4: 0xe00d, 0x3a5: 0x0008, 0x3a6: 0xe00d, 0x3a7: 0x0008, 0x3a8: 0xe00d, 0x3a9: 0x0008, - 0x3aa: 0xe00d, 0x3ab: 0x0008, 0x3ac: 0xe00d, 0x3ad: 0x0008, 0x3ae: 0xe00d, 0x3af: 0x0008, - 0x3b0: 0xe00d, 0x3b1: 0x0008, 0x3b2: 0xe00d, 0x3b3: 0x0008, 0x3b4: 0xe00d, 0x3b5: 0x0008, - 0x3b6: 0xe00d, 0x3b7: 0x0008, 0x3b8: 0xe00d, 0x3b9: 0x0008, 0x3ba: 0xe00d, 0x3bb: 0x0008, - 0x3bc: 0xe00d, 0x3bd: 0x0008, 0x3be: 0xe00d, 0x3bf: 0x0008, - // Block 0xf, offset 0x3c0 - 0x3c0: 0x0040, 0x3c1: 0xe01d, 0x3c2: 0x0008, 0x3c3: 0xe03d, 0x3c4: 0x0008, 0x3c5: 0xe01d, - 0x3c6: 0x0008, 0x3c7: 0xe07d, 0x3c8: 0x0008, 0x3c9: 0xe01d, 0x3ca: 0x0008, 0x3cb: 0xe03d, - 0x3cc: 0x0008, 0x3cd: 0xe01d, 0x3ce: 0x0008, 0x3cf: 0x0008, 0x3d0: 0xe00d, 0x3d1: 0x0008, - 0x3d2: 0xe00d, 0x3d3: 0x0008, 0x3d4: 0xe00d, 0x3d5: 0x0008, 0x3d6: 0xe00d, 0x3d7: 0x0008, - 0x3d8: 0xe00d, 0x3d9: 0x0008, 0x3da: 0xe00d, 0x3db: 0x0008, 0x3dc: 0xe00d, 0x3dd: 0x0008, - 0x3de: 0xe00d, 0x3df: 0x0008, 0x3e0: 0xe00d, 0x3e1: 0x0008, 0x3e2: 0xe00d, 0x3e3: 0x0008, - 0x3e4: 0xe00d, 0x3e5: 0x0008, 0x3e6: 0xe00d, 0x3e7: 0x0008, 0x3e8: 0xe00d, 0x3e9: 0x0008, - 0x3ea: 0xe00d, 0x3eb: 0x0008, 0x3ec: 0xe00d, 0x3ed: 0x0008, 0x3ee: 0xe00d, 0x3ef: 0x0008, - 0x3f0: 0xe00d, 0x3f1: 0x0008, 0x3f2: 0xe00d, 0x3f3: 0x0008, 0x3f4: 0xe00d, 0x3f5: 0x0008, - 0x3f6: 0xe00d, 0x3f7: 0x0008, 0x3f8: 0xe00d, 0x3f9: 0x0008, 0x3fa: 0xe00d, 0x3fb: 0x0008, - 0x3fc: 0xe00d, 0x3fd: 0x0008, 0x3fe: 0xe00d, 0x3ff: 0x0008, - // Block 0x10, offset 0x400 - 0x400: 0xe00d, 0x401: 0x0008, 0x402: 0xe00d, 0x403: 0x0008, 0x404: 0xe00d, 0x405: 0x0008, - 0x406: 0xe00d, 0x407: 0x0008, 0x408: 0xe00d, 0x409: 0x0008, 0x40a: 0xe00d, 0x40b: 0x0008, - 0x40c: 0xe00d, 0x40d: 0x0008, 0x40e: 0xe00d, 0x40f: 0x0008, 0x410: 0xe00d, 0x411: 0x0008, - 0x412: 0xe00d, 0x413: 0x0008, 0x414: 0xe00d, 0x415: 0x0008, 0x416: 0xe00d, 0x417: 0x0008, - 0x418: 0xe00d, 0x419: 0x0008, 0x41a: 0xe00d, 0x41b: 0x0008, 0x41c: 0xe00d, 0x41d: 0x0008, - 0x41e: 0xe00d, 0x41f: 0x0008, 0x420: 0xe00d, 0x421: 0x0008, 0x422: 0xe00d, 0x423: 0x0008, - 0x424: 0xe00d, 0x425: 0x0008, 0x426: 0xe00d, 0x427: 0x0008, 0x428: 0xe00d, 0x429: 0x0008, - 0x42a: 0xe00d, 0x42b: 0x0008, 0x42c: 0xe00d, 0x42d: 0x0008, 0x42e: 0xe00d, 0x42f: 0x0008, - 0x430: 0x0040, 0x431: 0x03f5, 0x432: 0x03f5, 0x433: 0x03f5, 0x434: 0x03f5, 0x435: 0x03f5, - 0x436: 0x03f5, 0x437: 0x03f5, 0x438: 0x03f5, 0x439: 0x03f5, 0x43a: 0x03f5, 0x43b: 0x03f5, - 0x43c: 0x03f5, 0x43d: 0x03f5, 0x43e: 0x03f5, 0x43f: 0x03f5, - // Block 0x11, offset 0x440 - 0x440: 0x0040, 0x441: 0x0040, 0x442: 0x0040, 0x443: 0x0040, 0x444: 0x0040, 0x445: 0x0040, - 0x446: 0x0018, 0x447: 0x0018, 0x448: 0x0018, 0x449: 0x0018, 0x44a: 0x0018, 0x44b: 0x0018, - 0x44c: 0x0018, 0x44d: 0x0018, 0x44e: 0x0018, 0x44f: 0x0018, 0x450: 0x1308, 0x451: 0x1308, - 0x452: 0x1308, 0x453: 0x1308, 0x454: 0x1308, 0x455: 0x1308, 0x456: 0x1308, 0x457: 0x1308, - 0x458: 0x1308, 0x459: 0x1308, 0x45a: 0x1308, 0x45b: 0x0018, 0x45c: 0x0340, 0x45d: 0x0040, - 0x45e: 0x0018, 0x45f: 0x0018, 0x460: 0x0208, 0x461: 0x0008, 0x462: 0x0408, 0x463: 0x0408, - 0x464: 0x0408, 0x465: 0x0408, 0x466: 0x0208, 0x467: 0x0408, 0x468: 0x0208, 0x469: 0x0408, - 0x46a: 0x0208, 0x46b: 0x0208, 0x46c: 0x0208, 0x46d: 0x0208, 0x46e: 0x0208, 0x46f: 0x0408, - 0x470: 0x0408, 0x471: 0x0408, 0x472: 0x0408, 0x473: 0x0208, 0x474: 0x0208, 0x475: 0x0208, - 0x476: 0x0208, 0x477: 0x0208, 0x478: 0x0208, 0x479: 0x0208, 0x47a: 0x0208, 0x47b: 0x0208, - 0x47c: 0x0208, 0x47d: 0x0208, 0x47e: 0x0208, 0x47f: 0x0208, - // Block 0x12, offset 0x480 - 0x480: 0x0408, 0x481: 0x0208, 0x482: 0x0208, 0x483: 0x0408, 0x484: 0x0408, 0x485: 0x0408, - 0x486: 0x0408, 0x487: 0x0408, 0x488: 0x0408, 0x489: 0x0408, 0x48a: 0x0408, 0x48b: 0x0408, - 0x48c: 0x0208, 0x48d: 0x0408, 0x48e: 0x0208, 0x48f: 0x0408, 0x490: 0x0208, 0x491: 0x0208, - 0x492: 0x0408, 0x493: 0x0408, 0x494: 0x0018, 0x495: 0x0408, 0x496: 0x1308, 0x497: 0x1308, - 0x498: 0x1308, 0x499: 0x1308, 0x49a: 0x1308, 0x49b: 0x1308, 0x49c: 0x1308, 0x49d: 0x0040, - 0x49e: 0x0018, 0x49f: 0x1308, 0x4a0: 0x1308, 0x4a1: 0x1308, 0x4a2: 0x1308, 0x4a3: 0x1308, - 0x4a4: 0x1308, 0x4a5: 0x0008, 0x4a6: 0x0008, 0x4a7: 0x1308, 0x4a8: 0x1308, 0x4a9: 0x0018, - 0x4aa: 0x1308, 0x4ab: 0x1308, 0x4ac: 0x1308, 0x4ad: 0x1308, 0x4ae: 0x0408, 0x4af: 0x0408, - 0x4b0: 0x0008, 0x4b1: 0x0008, 0x4b2: 0x0008, 0x4b3: 0x0008, 0x4b4: 0x0008, 0x4b5: 0x0008, - 0x4b6: 0x0008, 0x4b7: 0x0008, 0x4b8: 0x0008, 0x4b9: 0x0008, 0x4ba: 0x0208, 0x4bb: 0x0208, - 0x4bc: 0x0208, 0x4bd: 0x0008, 0x4be: 0x0008, 0x4bf: 0x0208, - // Block 0x13, offset 0x4c0 - 0x4c0: 0x0018, 0x4c1: 0x0018, 0x4c2: 0x0018, 0x4c3: 0x0018, 0x4c4: 0x0018, 0x4c5: 0x0018, - 0x4c6: 0x0018, 0x4c7: 0x0018, 0x4c8: 0x0018, 0x4c9: 0x0018, 0x4ca: 0x0018, 0x4cb: 0x0018, - 0x4cc: 0x0018, 0x4cd: 0x0018, 0x4ce: 0x0040, 0x4cf: 0x0340, 0x4d0: 0x0408, 0x4d1: 0x1308, - 0x4d2: 0x0208, 0x4d3: 0x0208, 0x4d4: 0x0208, 0x4d5: 0x0408, 0x4d6: 0x0408, 0x4d7: 0x0408, - 0x4d8: 0x0408, 0x4d9: 0x0408, 0x4da: 0x0208, 0x4db: 0x0208, 0x4dc: 0x0208, 0x4dd: 0x0208, - 0x4de: 0x0408, 0x4df: 0x0208, 0x4e0: 0x0208, 0x4e1: 0x0208, 0x4e2: 0x0208, 0x4e3: 0x0208, - 0x4e4: 0x0208, 0x4e5: 0x0208, 0x4e6: 0x0208, 0x4e7: 0x0208, 0x4e8: 0x0408, 0x4e9: 0x0208, - 0x4ea: 0x0408, 0x4eb: 0x0208, 0x4ec: 0x0408, 0x4ed: 0x0208, 0x4ee: 0x0208, 0x4ef: 0x0408, - 0x4f0: 0x1308, 0x4f1: 0x1308, 0x4f2: 0x1308, 0x4f3: 0x1308, 0x4f4: 0x1308, 0x4f5: 0x1308, - 0x4f6: 0x1308, 0x4f7: 0x1308, 0x4f8: 0x1308, 0x4f9: 0x1308, 0x4fa: 0x1308, 0x4fb: 0x1308, - 0x4fc: 0x1308, 0x4fd: 0x1308, 0x4fe: 0x1308, 0x4ff: 0x1308, - // Block 0x14, offset 0x500 - 0x500: 0x1008, 0x501: 0x1308, 0x502: 0x1308, 0x503: 0x1308, 0x504: 0x1308, 0x505: 0x1308, - 0x506: 0x1308, 0x507: 0x1308, 0x508: 0x1308, 0x509: 0x1008, 0x50a: 0x1008, 0x50b: 0x1008, - 0x50c: 0x1008, 0x50d: 0x1b08, 0x50e: 0x1008, 0x50f: 0x1008, 0x510: 0x0008, 0x511: 0x1308, - 0x512: 0x1308, 0x513: 0x1308, 0x514: 0x1308, 0x515: 0x1308, 0x516: 0x1308, 0x517: 0x1308, - 0x518: 0x04c9, 0x519: 0x0501, 0x51a: 0x0539, 0x51b: 0x0571, 0x51c: 0x05a9, 0x51d: 0x05e1, - 0x51e: 0x0619, 0x51f: 0x0651, 0x520: 0x0008, 0x521: 0x0008, 0x522: 0x1308, 0x523: 0x1308, - 0x524: 0x0018, 0x525: 0x0018, 0x526: 0x0008, 0x527: 0x0008, 0x528: 0x0008, 0x529: 0x0008, - 0x52a: 0x0008, 0x52b: 0x0008, 0x52c: 0x0008, 0x52d: 0x0008, 0x52e: 0x0008, 0x52f: 0x0008, - 0x530: 0x0018, 0x531: 0x0008, 0x532: 0x0008, 0x533: 0x0008, 0x534: 0x0008, 0x535: 0x0008, - 0x536: 0x0008, 0x537: 0x0008, 0x538: 0x0008, 0x539: 0x0008, 0x53a: 0x0008, 0x53b: 0x0008, - 0x53c: 0x0008, 0x53d: 0x0008, 0x53e: 0x0008, 0x53f: 0x0008, - // Block 0x15, offset 0x540 - 0x540: 0x0008, 0x541: 0x1308, 0x542: 0x1008, 0x543: 0x1008, 0x544: 0x0040, 0x545: 0x0008, - 0x546: 0x0008, 0x547: 0x0008, 0x548: 0x0008, 0x549: 0x0008, 0x54a: 0x0008, 0x54b: 0x0008, - 0x54c: 0x0008, 0x54d: 0x0040, 0x54e: 0x0040, 0x54f: 0x0008, 0x550: 0x0008, 0x551: 0x0040, - 0x552: 0x0040, 0x553: 0x0008, 0x554: 0x0008, 0x555: 0x0008, 0x556: 0x0008, 0x557: 0x0008, - 0x558: 0x0008, 0x559: 0x0008, 0x55a: 0x0008, 0x55b: 0x0008, 0x55c: 0x0008, 0x55d: 0x0008, - 0x55e: 0x0008, 0x55f: 0x0008, 0x560: 0x0008, 0x561: 0x0008, 0x562: 0x0008, 0x563: 0x0008, - 0x564: 0x0008, 0x565: 0x0008, 0x566: 0x0008, 0x567: 0x0008, 0x568: 0x0008, 0x569: 0x0040, - 0x56a: 0x0008, 0x56b: 0x0008, 0x56c: 0x0008, 0x56d: 0x0008, 0x56e: 0x0008, 0x56f: 0x0008, - 0x570: 0x0008, 0x571: 0x0040, 0x572: 0x0008, 0x573: 0x0040, 0x574: 0x0040, 0x575: 0x0040, - 0x576: 0x0008, 0x577: 0x0008, 0x578: 0x0008, 0x579: 0x0008, 0x57a: 0x0040, 0x57b: 0x0040, - 0x57c: 0x1308, 0x57d: 0x0008, 0x57e: 0x1008, 0x57f: 0x1008, - // Block 0x16, offset 0x580 - 0x580: 0x1008, 0x581: 0x1308, 0x582: 0x1308, 0x583: 0x1308, 0x584: 0x1308, 0x585: 0x0040, - 0x586: 0x0040, 0x587: 0x1008, 0x588: 0x1008, 0x589: 0x0040, 0x58a: 0x0040, 0x58b: 0x1008, - 0x58c: 0x1008, 0x58d: 0x1b08, 0x58e: 0x0008, 0x58f: 0x0040, 0x590: 0x0040, 0x591: 0x0040, - 0x592: 0x0040, 0x593: 0x0040, 0x594: 0x0040, 0x595: 0x0040, 0x596: 0x0040, 0x597: 0x1008, - 0x598: 0x0040, 0x599: 0x0040, 0x59a: 0x0040, 0x59b: 0x0040, 0x59c: 0x0689, 0x59d: 0x06c1, - 0x59e: 0x0040, 0x59f: 0x06f9, 0x5a0: 0x0008, 0x5a1: 0x0008, 0x5a2: 0x1308, 0x5a3: 0x1308, - 0x5a4: 0x0040, 0x5a5: 0x0040, 0x5a6: 0x0008, 0x5a7: 0x0008, 0x5a8: 0x0008, 0x5a9: 0x0008, - 0x5aa: 0x0008, 0x5ab: 0x0008, 0x5ac: 0x0008, 0x5ad: 0x0008, 0x5ae: 0x0008, 0x5af: 0x0008, - 0x5b0: 0x0008, 0x5b1: 0x0008, 0x5b2: 0x0018, 0x5b3: 0x0018, 0x5b4: 0x0018, 0x5b5: 0x0018, - 0x5b6: 0x0018, 0x5b7: 0x0018, 0x5b8: 0x0018, 0x5b9: 0x0018, 0x5ba: 0x0018, 0x5bb: 0x0018, - 0x5bc: 0x0040, 0x5bd: 0x0040, 0x5be: 0x0040, 0x5bf: 0x0040, - // Block 0x17, offset 0x5c0 - 0x5c0: 0x0040, 0x5c1: 0x1308, 0x5c2: 0x1308, 0x5c3: 0x1008, 0x5c4: 0x0040, 0x5c5: 0x0008, - 0x5c6: 0x0008, 0x5c7: 0x0008, 0x5c8: 0x0008, 0x5c9: 0x0008, 0x5ca: 0x0008, 0x5cb: 0x0040, - 0x5cc: 0x0040, 0x5cd: 0x0040, 0x5ce: 0x0040, 0x5cf: 0x0008, 0x5d0: 0x0008, 0x5d1: 0x0040, - 0x5d2: 0x0040, 0x5d3: 0x0008, 0x5d4: 0x0008, 0x5d5: 0x0008, 0x5d6: 0x0008, 0x5d7: 0x0008, - 0x5d8: 0x0008, 0x5d9: 0x0008, 0x5da: 0x0008, 0x5db: 0x0008, 0x5dc: 0x0008, 0x5dd: 0x0008, - 0x5de: 0x0008, 0x5df: 0x0008, 0x5e0: 0x0008, 0x5e1: 0x0008, 0x5e2: 0x0008, 0x5e3: 0x0008, - 0x5e4: 0x0008, 0x5e5: 0x0008, 0x5e6: 0x0008, 0x5e7: 0x0008, 0x5e8: 0x0008, 0x5e9: 0x0040, - 0x5ea: 0x0008, 0x5eb: 0x0008, 0x5ec: 0x0008, 0x5ed: 0x0008, 0x5ee: 0x0008, 0x5ef: 0x0008, - 0x5f0: 0x0008, 0x5f1: 0x0040, 0x5f2: 0x0008, 0x5f3: 0x0731, 0x5f4: 0x0040, 0x5f5: 0x0008, - 0x5f6: 0x0769, 0x5f7: 0x0040, 0x5f8: 0x0008, 0x5f9: 0x0008, 0x5fa: 0x0040, 0x5fb: 0x0040, - 0x5fc: 0x1308, 0x5fd: 0x0040, 0x5fe: 0x1008, 0x5ff: 0x1008, - // Block 0x18, offset 0x600 - 0x600: 0x1008, 0x601: 0x1308, 0x602: 0x1308, 0x603: 0x0040, 0x604: 0x0040, 0x605: 0x0040, - 0x606: 0x0040, 0x607: 0x1308, 0x608: 0x1308, 0x609: 0x0040, 0x60a: 0x0040, 0x60b: 0x1308, - 0x60c: 0x1308, 0x60d: 0x1b08, 0x60e: 0x0040, 0x60f: 0x0040, 0x610: 0x0040, 0x611: 0x1308, - 0x612: 0x0040, 0x613: 0x0040, 0x614: 0x0040, 0x615: 0x0040, 0x616: 0x0040, 0x617: 0x0040, - 0x618: 0x0040, 0x619: 0x07a1, 0x61a: 0x07d9, 0x61b: 0x0811, 0x61c: 0x0008, 0x61d: 0x0040, - 0x61e: 0x0849, 0x61f: 0x0040, 0x620: 0x0040, 0x621: 0x0040, 0x622: 0x0040, 0x623: 0x0040, - 0x624: 0x0040, 0x625: 0x0040, 0x626: 0x0008, 0x627: 0x0008, 0x628: 0x0008, 0x629: 0x0008, - 0x62a: 0x0008, 0x62b: 0x0008, 0x62c: 0x0008, 0x62d: 0x0008, 0x62e: 0x0008, 0x62f: 0x0008, - 0x630: 0x1308, 0x631: 0x1308, 0x632: 0x0008, 0x633: 0x0008, 0x634: 0x0008, 0x635: 0x1308, - 0x636: 0x0040, 0x637: 0x0040, 0x638: 0x0040, 0x639: 0x0040, 0x63a: 0x0040, 0x63b: 0x0040, - 0x63c: 0x0040, 0x63d: 0x0040, 0x63e: 0x0040, 0x63f: 0x0040, - // Block 0x19, offset 0x640 - 0x640: 0x0040, 0x641: 0x1308, 0x642: 0x1308, 0x643: 0x1008, 0x644: 0x0040, 0x645: 0x0008, - 0x646: 0x0008, 0x647: 0x0008, 0x648: 0x0008, 0x649: 0x0008, 0x64a: 0x0008, 0x64b: 0x0008, - 0x64c: 0x0008, 0x64d: 0x0008, 0x64e: 0x0040, 0x64f: 0x0008, 0x650: 0x0008, 0x651: 0x0008, - 0x652: 0x0040, 0x653: 0x0008, 0x654: 0x0008, 0x655: 0x0008, 0x656: 0x0008, 0x657: 0x0008, - 0x658: 0x0008, 0x659: 0x0008, 0x65a: 0x0008, 0x65b: 0x0008, 0x65c: 0x0008, 0x65d: 0x0008, - 0x65e: 0x0008, 0x65f: 0x0008, 0x660: 0x0008, 0x661: 0x0008, 0x662: 0x0008, 0x663: 0x0008, - 0x664: 0x0008, 0x665: 0x0008, 0x666: 0x0008, 0x667: 0x0008, 0x668: 0x0008, 0x669: 0x0040, - 0x66a: 0x0008, 0x66b: 0x0008, 0x66c: 0x0008, 0x66d: 0x0008, 0x66e: 0x0008, 0x66f: 0x0008, - 0x670: 0x0008, 0x671: 0x0040, 0x672: 0x0008, 0x673: 0x0008, 0x674: 0x0040, 0x675: 0x0008, - 0x676: 0x0008, 0x677: 0x0008, 0x678: 0x0008, 0x679: 0x0008, 0x67a: 0x0040, 0x67b: 0x0040, - 0x67c: 0x1308, 0x67d: 0x0008, 0x67e: 0x1008, 0x67f: 0x1008, - // Block 0x1a, offset 0x680 - 0x680: 0x1008, 0x681: 0x1308, 0x682: 0x1308, 0x683: 0x1308, 0x684: 0x1308, 0x685: 0x1308, - 0x686: 0x0040, 0x687: 0x1308, 0x688: 0x1308, 0x689: 0x1008, 0x68a: 0x0040, 0x68b: 0x1008, - 0x68c: 0x1008, 0x68d: 0x1b08, 0x68e: 0x0040, 0x68f: 0x0040, 0x690: 0x0008, 0x691: 0x0040, - 0x692: 0x0040, 0x693: 0x0040, 0x694: 0x0040, 0x695: 0x0040, 0x696: 0x0040, 0x697: 0x0040, - 0x698: 0x0040, 0x699: 0x0040, 0x69a: 0x0040, 0x69b: 0x0040, 0x69c: 0x0040, 0x69d: 0x0040, - 0x69e: 0x0040, 0x69f: 0x0040, 0x6a0: 0x0008, 0x6a1: 0x0008, 0x6a2: 0x1308, 0x6a3: 0x1308, - 0x6a4: 0x0040, 0x6a5: 0x0040, 0x6a6: 0x0008, 0x6a7: 0x0008, 0x6a8: 0x0008, 0x6a9: 0x0008, - 0x6aa: 0x0008, 0x6ab: 0x0008, 0x6ac: 0x0008, 0x6ad: 0x0008, 0x6ae: 0x0008, 0x6af: 0x0008, - 0x6b0: 0x0018, 0x6b1: 0x0018, 0x6b2: 0x0040, 0x6b3: 0x0040, 0x6b4: 0x0040, 0x6b5: 0x0040, - 0x6b6: 0x0040, 0x6b7: 0x0040, 0x6b8: 0x0040, 0x6b9: 0x0008, 0x6ba: 0x0040, 0x6bb: 0x0040, - 0x6bc: 0x0040, 0x6bd: 0x0040, 0x6be: 0x0040, 0x6bf: 0x0040, - // Block 0x1b, offset 0x6c0 - 0x6c0: 0x0040, 0x6c1: 0x1308, 0x6c2: 0x1008, 0x6c3: 0x1008, 0x6c4: 0x0040, 0x6c5: 0x0008, - 0x6c6: 0x0008, 0x6c7: 0x0008, 0x6c8: 0x0008, 0x6c9: 0x0008, 0x6ca: 0x0008, 0x6cb: 0x0008, - 0x6cc: 0x0008, 0x6cd: 0x0040, 0x6ce: 0x0040, 0x6cf: 0x0008, 0x6d0: 0x0008, 0x6d1: 0x0040, - 0x6d2: 0x0040, 0x6d3: 0x0008, 0x6d4: 0x0008, 0x6d5: 0x0008, 0x6d6: 0x0008, 0x6d7: 0x0008, - 0x6d8: 0x0008, 0x6d9: 0x0008, 0x6da: 0x0008, 0x6db: 0x0008, 0x6dc: 0x0008, 0x6dd: 0x0008, - 0x6de: 0x0008, 0x6df: 0x0008, 0x6e0: 0x0008, 0x6e1: 0x0008, 0x6e2: 0x0008, 0x6e3: 0x0008, - 0x6e4: 0x0008, 0x6e5: 0x0008, 0x6e6: 0x0008, 0x6e7: 0x0008, 0x6e8: 0x0008, 0x6e9: 0x0040, - 0x6ea: 0x0008, 0x6eb: 0x0008, 0x6ec: 0x0008, 0x6ed: 0x0008, 0x6ee: 0x0008, 0x6ef: 0x0008, - 0x6f0: 0x0008, 0x6f1: 0x0040, 0x6f2: 0x0008, 0x6f3: 0x0008, 0x6f4: 0x0040, 0x6f5: 0x0008, - 0x6f6: 0x0008, 0x6f7: 0x0008, 0x6f8: 0x0008, 0x6f9: 0x0008, 0x6fa: 0x0040, 0x6fb: 0x0040, - 0x6fc: 0x1308, 0x6fd: 0x0008, 0x6fe: 0x1008, 0x6ff: 0x1308, - // Block 0x1c, offset 0x700 - 0x700: 0x1008, 0x701: 0x1308, 0x702: 0x1308, 0x703: 0x1308, 0x704: 0x1308, 0x705: 0x0040, - 0x706: 0x0040, 0x707: 0x1008, 0x708: 0x1008, 0x709: 0x0040, 0x70a: 0x0040, 0x70b: 0x1008, - 0x70c: 0x1008, 0x70d: 0x1b08, 0x70e: 0x0040, 0x70f: 0x0040, 0x710: 0x0040, 0x711: 0x0040, - 0x712: 0x0040, 0x713: 0x0040, 0x714: 0x0040, 0x715: 0x0040, 0x716: 0x1308, 0x717: 0x1008, - 0x718: 0x0040, 0x719: 0x0040, 0x71a: 0x0040, 0x71b: 0x0040, 0x71c: 0x0881, 0x71d: 0x08b9, - 0x71e: 0x0040, 0x71f: 0x0008, 0x720: 0x0008, 0x721: 0x0008, 0x722: 0x1308, 0x723: 0x1308, - 0x724: 0x0040, 0x725: 0x0040, 0x726: 0x0008, 0x727: 0x0008, 0x728: 0x0008, 0x729: 0x0008, - 0x72a: 0x0008, 0x72b: 0x0008, 0x72c: 0x0008, 0x72d: 0x0008, 0x72e: 0x0008, 0x72f: 0x0008, - 0x730: 0x0018, 0x731: 0x0008, 0x732: 0x0018, 0x733: 0x0018, 0x734: 0x0018, 0x735: 0x0018, - 0x736: 0x0018, 0x737: 0x0018, 0x738: 0x0040, 0x739: 0x0040, 0x73a: 0x0040, 0x73b: 0x0040, - 0x73c: 0x0040, 0x73d: 0x0040, 0x73e: 0x0040, 0x73f: 0x0040, - // Block 0x1d, offset 0x740 - 0x740: 0x0040, 0x741: 0x0040, 0x742: 0x1308, 0x743: 0x0008, 0x744: 0x0040, 0x745: 0x0008, - 0x746: 0x0008, 0x747: 0x0008, 0x748: 0x0008, 0x749: 0x0008, 0x74a: 0x0008, 0x74b: 0x0040, - 0x74c: 0x0040, 0x74d: 0x0040, 0x74e: 0x0008, 0x74f: 0x0008, 0x750: 0x0008, 0x751: 0x0040, - 0x752: 0x0008, 0x753: 0x0008, 0x754: 0x0008, 0x755: 0x0008, 0x756: 0x0040, 0x757: 0x0040, - 0x758: 0x0040, 0x759: 0x0008, 0x75a: 0x0008, 0x75b: 0x0040, 0x75c: 0x0008, 0x75d: 0x0040, - 0x75e: 0x0008, 0x75f: 0x0008, 0x760: 0x0040, 0x761: 0x0040, 0x762: 0x0040, 0x763: 0x0008, - 0x764: 0x0008, 0x765: 0x0040, 0x766: 0x0040, 0x767: 0x0040, 0x768: 0x0008, 0x769: 0x0008, - 0x76a: 0x0008, 0x76b: 0x0040, 0x76c: 0x0040, 0x76d: 0x0040, 0x76e: 0x0008, 0x76f: 0x0008, - 0x770: 0x0008, 0x771: 0x0008, 0x772: 0x0008, 0x773: 0x0008, 0x774: 0x0008, 0x775: 0x0008, - 0x776: 0x0008, 0x777: 0x0008, 0x778: 0x0008, 0x779: 0x0008, 0x77a: 0x0040, 0x77b: 0x0040, - 0x77c: 0x0040, 0x77d: 0x0040, 0x77e: 0x1008, 0x77f: 0x1008, - // Block 0x1e, offset 0x780 - 0x780: 0x1308, 0x781: 0x1008, 0x782: 0x1008, 0x783: 0x1008, 0x784: 0x1008, 0x785: 0x0040, - 0x786: 0x1308, 0x787: 0x1308, 0x788: 0x1308, 0x789: 0x0040, 0x78a: 0x1308, 0x78b: 0x1308, - 0x78c: 0x1308, 0x78d: 0x1b08, 0x78e: 0x0040, 0x78f: 0x0040, 0x790: 0x0040, 0x791: 0x0040, - 0x792: 0x0040, 0x793: 0x0040, 0x794: 0x0040, 0x795: 0x1308, 0x796: 0x1308, 0x797: 0x0040, - 0x798: 0x0008, 0x799: 0x0008, 0x79a: 0x0008, 0x79b: 0x0040, 0x79c: 0x0040, 0x79d: 0x0040, - 0x79e: 0x0040, 0x79f: 0x0040, 0x7a0: 0x0008, 0x7a1: 0x0008, 0x7a2: 0x1308, 0x7a3: 0x1308, - 0x7a4: 0x0040, 0x7a5: 0x0040, 0x7a6: 0x0008, 0x7a7: 0x0008, 0x7a8: 0x0008, 0x7a9: 0x0008, - 0x7aa: 0x0008, 0x7ab: 0x0008, 0x7ac: 0x0008, 0x7ad: 0x0008, 0x7ae: 0x0008, 0x7af: 0x0008, - 0x7b0: 0x0040, 0x7b1: 0x0040, 0x7b2: 0x0040, 0x7b3: 0x0040, 0x7b4: 0x0040, 0x7b5: 0x0040, - 0x7b6: 0x0040, 0x7b7: 0x0040, 0x7b8: 0x0018, 0x7b9: 0x0018, 0x7ba: 0x0018, 0x7bb: 0x0018, - 0x7bc: 0x0018, 0x7bd: 0x0018, 0x7be: 0x0018, 0x7bf: 0x0018, - // Block 0x1f, offset 0x7c0 - 0x7c0: 0x0008, 0x7c1: 0x1308, 0x7c2: 0x1008, 0x7c3: 0x1008, 0x7c4: 0x0040, 0x7c5: 0x0008, - 0x7c6: 0x0008, 0x7c7: 0x0008, 0x7c8: 0x0008, 0x7c9: 0x0008, 0x7ca: 0x0008, 0x7cb: 0x0008, - 0x7cc: 0x0008, 0x7cd: 0x0040, 0x7ce: 0x0008, 0x7cf: 0x0008, 0x7d0: 0x0008, 0x7d1: 0x0040, - 0x7d2: 0x0008, 0x7d3: 0x0008, 0x7d4: 0x0008, 0x7d5: 0x0008, 0x7d6: 0x0008, 0x7d7: 0x0008, - 0x7d8: 0x0008, 0x7d9: 0x0008, 0x7da: 0x0008, 0x7db: 0x0008, 0x7dc: 0x0008, 0x7dd: 0x0008, - 0x7de: 0x0008, 0x7df: 0x0008, 0x7e0: 0x0008, 0x7e1: 0x0008, 0x7e2: 0x0008, 0x7e3: 0x0008, - 0x7e4: 0x0008, 0x7e5: 0x0008, 0x7e6: 0x0008, 0x7e7: 0x0008, 0x7e8: 0x0008, 0x7e9: 0x0040, - 0x7ea: 0x0008, 0x7eb: 0x0008, 0x7ec: 0x0008, 0x7ed: 0x0008, 0x7ee: 0x0008, 0x7ef: 0x0008, - 0x7f0: 0x0008, 0x7f1: 0x0008, 0x7f2: 0x0008, 0x7f3: 0x0008, 0x7f4: 0x0040, 0x7f5: 0x0008, - 0x7f6: 0x0008, 0x7f7: 0x0008, 0x7f8: 0x0008, 0x7f9: 0x0008, 0x7fa: 0x0040, 0x7fb: 0x0040, - 0x7fc: 0x1308, 0x7fd: 0x0008, 0x7fe: 0x1008, 0x7ff: 0x1308, - // Block 0x20, offset 0x800 - 0x800: 0x1008, 0x801: 0x1008, 0x802: 0x1008, 0x803: 0x1008, 0x804: 0x1008, 0x805: 0x0040, - 0x806: 0x1308, 0x807: 0x1008, 0x808: 0x1008, 0x809: 0x0040, 0x80a: 0x1008, 0x80b: 0x1008, - 0x80c: 0x1308, 0x80d: 0x1b08, 0x80e: 0x0040, 0x80f: 0x0040, 0x810: 0x0040, 0x811: 0x0040, - 0x812: 0x0040, 0x813: 0x0040, 0x814: 0x0040, 0x815: 0x1008, 0x816: 0x1008, 0x817: 0x0040, - 0x818: 0x0040, 0x819: 0x0040, 0x81a: 0x0040, 0x81b: 0x0040, 0x81c: 0x0040, 0x81d: 0x0040, - 0x81e: 0x0008, 0x81f: 0x0040, 0x820: 0x0008, 0x821: 0x0008, 0x822: 0x1308, 0x823: 0x1308, - 0x824: 0x0040, 0x825: 0x0040, 0x826: 0x0008, 0x827: 0x0008, 0x828: 0x0008, 0x829: 0x0008, - 0x82a: 0x0008, 0x82b: 0x0008, 0x82c: 0x0008, 0x82d: 0x0008, 0x82e: 0x0008, 0x82f: 0x0008, - 0x830: 0x0040, 0x831: 0x0008, 0x832: 0x0008, 0x833: 0x0040, 0x834: 0x0040, 0x835: 0x0040, - 0x836: 0x0040, 0x837: 0x0040, 0x838: 0x0040, 0x839: 0x0040, 0x83a: 0x0040, 0x83b: 0x0040, - 0x83c: 0x0040, 0x83d: 0x0040, 0x83e: 0x0040, 0x83f: 0x0040, - // Block 0x21, offset 0x840 - 0x840: 0x1008, 0x841: 0x1308, 0x842: 0x1308, 0x843: 0x1308, 0x844: 0x1308, 0x845: 0x0040, - 0x846: 0x1008, 0x847: 0x1008, 0x848: 0x1008, 0x849: 0x0040, 0x84a: 0x1008, 0x84b: 0x1008, - 0x84c: 0x1008, 0x84d: 0x1b08, 0x84e: 0x0008, 0x84f: 0x0018, 0x850: 0x0040, 0x851: 0x0040, - 0x852: 0x0040, 0x853: 0x0040, 0x854: 0x0008, 0x855: 0x0008, 0x856: 0x0008, 0x857: 0x1008, - 0x858: 0x0018, 0x859: 0x0018, 0x85a: 0x0018, 0x85b: 0x0018, 0x85c: 0x0018, 0x85d: 0x0018, - 0x85e: 0x0018, 0x85f: 0x0008, 0x860: 0x0008, 0x861: 0x0008, 0x862: 0x1308, 0x863: 0x1308, - 0x864: 0x0040, 0x865: 0x0040, 0x866: 0x0008, 0x867: 0x0008, 0x868: 0x0008, 0x869: 0x0008, - 0x86a: 0x0008, 0x86b: 0x0008, 0x86c: 0x0008, 0x86d: 0x0008, 0x86e: 0x0008, 0x86f: 0x0008, - 0x870: 0x0018, 0x871: 0x0018, 0x872: 0x0018, 0x873: 0x0018, 0x874: 0x0018, 0x875: 0x0018, - 0x876: 0x0018, 0x877: 0x0018, 0x878: 0x0018, 0x879: 0x0018, 0x87a: 0x0008, 0x87b: 0x0008, - 0x87c: 0x0008, 0x87d: 0x0008, 0x87e: 0x0008, 0x87f: 0x0008, - // Block 0x22, offset 0x880 - 0x880: 0x0040, 0x881: 0x0008, 0x882: 0x0008, 0x883: 0x0040, 0x884: 0x0008, 0x885: 0x0040, - 0x886: 0x0040, 0x887: 0x0008, 0x888: 0x0008, 0x889: 0x0040, 0x88a: 0x0008, 0x88b: 0x0040, - 0x88c: 0x0040, 0x88d: 0x0008, 0x88e: 0x0040, 0x88f: 0x0040, 0x890: 0x0040, 0x891: 0x0040, - 0x892: 0x0040, 0x893: 0x0040, 0x894: 0x0008, 0x895: 0x0008, 0x896: 0x0008, 0x897: 0x0008, - 0x898: 0x0040, 0x899: 0x0008, 0x89a: 0x0008, 0x89b: 0x0008, 0x89c: 0x0008, 0x89d: 0x0008, - 0x89e: 0x0008, 0x89f: 0x0008, 0x8a0: 0x0040, 0x8a1: 0x0008, 0x8a2: 0x0008, 0x8a3: 0x0008, - 0x8a4: 0x0040, 0x8a5: 0x0008, 0x8a6: 0x0040, 0x8a7: 0x0008, 0x8a8: 0x0040, 0x8a9: 0x0040, - 0x8aa: 0x0008, 0x8ab: 0x0008, 0x8ac: 0x0040, 0x8ad: 0x0008, 0x8ae: 0x0008, 0x8af: 0x0008, - 0x8b0: 0x0008, 0x8b1: 0x1308, 0x8b2: 0x0008, 0x8b3: 0x0929, 0x8b4: 0x1308, 0x8b5: 0x1308, - 0x8b6: 0x1308, 0x8b7: 0x1308, 0x8b8: 0x1308, 0x8b9: 0x1308, 0x8ba: 0x0040, 0x8bb: 0x1308, - 0x8bc: 0x1308, 0x8bd: 0x0008, 0x8be: 0x0040, 0x8bf: 0x0040, - // Block 0x23, offset 0x8c0 - 0x8c0: 0x0008, 0x8c1: 0x0008, 0x8c2: 0x0008, 0x8c3: 0x09d1, 0x8c4: 0x0008, 0x8c5: 0x0008, - 0x8c6: 0x0008, 0x8c7: 0x0008, 0x8c8: 0x0040, 0x8c9: 0x0008, 0x8ca: 0x0008, 0x8cb: 0x0008, - 0x8cc: 0x0008, 0x8cd: 0x0a09, 0x8ce: 0x0008, 0x8cf: 0x0008, 0x8d0: 0x0008, 0x8d1: 0x0008, - 0x8d2: 0x0a41, 0x8d3: 0x0008, 0x8d4: 0x0008, 0x8d5: 0x0008, 0x8d6: 0x0008, 0x8d7: 0x0a79, - 0x8d8: 0x0008, 0x8d9: 0x0008, 0x8da: 0x0008, 0x8db: 0x0008, 0x8dc: 0x0ab1, 0x8dd: 0x0008, - 0x8de: 0x0008, 0x8df: 0x0008, 0x8e0: 0x0008, 0x8e1: 0x0008, 0x8e2: 0x0008, 0x8e3: 0x0008, - 0x8e4: 0x0008, 0x8e5: 0x0008, 0x8e6: 0x0008, 0x8e7: 0x0008, 0x8e8: 0x0008, 0x8e9: 0x0ae9, - 0x8ea: 0x0008, 0x8eb: 0x0008, 0x8ec: 0x0008, 0x8ed: 0x0040, 0x8ee: 0x0040, 0x8ef: 0x0040, - 0x8f0: 0x0040, 0x8f1: 0x1308, 0x8f2: 0x1308, 0x8f3: 0x0b21, 0x8f4: 0x1308, 0x8f5: 0x0b59, - 0x8f6: 0x0b91, 0x8f7: 0x0bc9, 0x8f8: 0x0c19, 0x8f9: 0x0c51, 0x8fa: 0x1308, 0x8fb: 0x1308, - 0x8fc: 0x1308, 0x8fd: 0x1308, 0x8fe: 0x1308, 0x8ff: 0x1008, - // Block 0x24, offset 0x900 - 0x900: 0x1308, 0x901: 0x0ca1, 0x902: 0x1308, 0x903: 0x1308, 0x904: 0x1b08, 0x905: 0x0018, - 0x906: 0x1308, 0x907: 0x1308, 0x908: 0x0008, 0x909: 0x0008, 0x90a: 0x0008, 0x90b: 0x0008, - 0x90c: 0x0008, 0x90d: 0x1308, 0x90e: 0x1308, 0x90f: 0x1308, 0x910: 0x1308, 0x911: 0x1308, - 0x912: 0x1308, 0x913: 0x0cd9, 0x914: 0x1308, 0x915: 0x1308, 0x916: 0x1308, 0x917: 0x1308, - 0x918: 0x0040, 0x919: 0x1308, 0x91a: 0x1308, 0x91b: 0x1308, 0x91c: 0x1308, 0x91d: 0x0d11, - 0x91e: 0x1308, 0x91f: 0x1308, 0x920: 0x1308, 0x921: 0x1308, 0x922: 0x0d49, 0x923: 0x1308, - 0x924: 0x1308, 0x925: 0x1308, 0x926: 0x1308, 0x927: 0x0d81, 0x928: 0x1308, 0x929: 0x1308, - 0x92a: 0x1308, 0x92b: 0x1308, 0x92c: 0x0db9, 0x92d: 0x1308, 0x92e: 0x1308, 0x92f: 0x1308, - 0x930: 0x1308, 0x931: 0x1308, 0x932: 0x1308, 0x933: 0x1308, 0x934: 0x1308, 0x935: 0x1308, - 0x936: 0x1308, 0x937: 0x1308, 0x938: 0x1308, 0x939: 0x0df1, 0x93a: 0x1308, 0x93b: 0x1308, - 0x93c: 0x1308, 0x93d: 0x0040, 0x93e: 0x0018, 0x93f: 0x0018, - // Block 0x25, offset 0x940 - 0x940: 0x0008, 0x941: 0x0008, 0x942: 0x0008, 0x943: 0x0008, 0x944: 0x0008, 0x945: 0x0008, - 0x946: 0x0008, 0x947: 0x0008, 0x948: 0x0008, 0x949: 0x0008, 0x94a: 0x0008, 0x94b: 0x0008, - 0x94c: 0x0008, 0x94d: 0x0008, 0x94e: 0x0008, 0x94f: 0x0008, 0x950: 0x0008, 0x951: 0x0008, - 0x952: 0x0008, 0x953: 0x0008, 0x954: 0x0008, 0x955: 0x0008, 0x956: 0x0008, 0x957: 0x0008, - 0x958: 0x0008, 0x959: 0x0008, 0x95a: 0x0008, 0x95b: 0x0008, 0x95c: 0x0008, 0x95d: 0x0008, - 0x95e: 0x0008, 0x95f: 0x0008, 0x960: 0x0008, 0x961: 0x0008, 0x962: 0x0008, 0x963: 0x0008, - 0x964: 0x0008, 0x965: 0x0008, 0x966: 0x0008, 0x967: 0x0008, 0x968: 0x0008, 0x969: 0x0008, - 0x96a: 0x0008, 0x96b: 0x0008, 0x96c: 0x0039, 0x96d: 0x0ed1, 0x96e: 0x0ee9, 0x96f: 0x0008, - 0x970: 0x0ef9, 0x971: 0x0f09, 0x972: 0x0f19, 0x973: 0x0f31, 0x974: 0x0249, 0x975: 0x0f41, - 0x976: 0x0259, 0x977: 0x0f51, 0x978: 0x0359, 0x979: 0x0f61, 0x97a: 0x0f71, 0x97b: 0x0008, - 0x97c: 0x00d9, 0x97d: 0x0f81, 0x97e: 0x0f99, 0x97f: 0x0269, - // Block 0x26, offset 0x980 - 0x980: 0x0fa9, 0x981: 0x0fb9, 0x982: 0x0279, 0x983: 0x0039, 0x984: 0x0fc9, 0x985: 0x0fe1, - 0x986: 0x059d, 0x987: 0x0ee9, 0x988: 0x0ef9, 0x989: 0x0f09, 0x98a: 0x0ff9, 0x98b: 0x1011, - 0x98c: 0x1029, 0x98d: 0x0f31, 0x98e: 0x0008, 0x98f: 0x0f51, 0x990: 0x0f61, 0x991: 0x1041, - 0x992: 0x00d9, 0x993: 0x1059, 0x994: 0x05b5, 0x995: 0x05b5, 0x996: 0x0f99, 0x997: 0x0fa9, - 0x998: 0x0fb9, 0x999: 0x059d, 0x99a: 0x1071, 0x99b: 0x1089, 0x99c: 0x05cd, 0x99d: 0x1099, - 0x99e: 0x10b1, 0x99f: 0x10c9, 0x9a0: 0x10e1, 0x9a1: 0x10f9, 0x9a2: 0x0f41, 0x9a3: 0x0269, - 0x9a4: 0x0fb9, 0x9a5: 0x1089, 0x9a6: 0x1099, 0x9a7: 0x10b1, 0x9a8: 0x1111, 0x9a9: 0x10e1, - 0x9aa: 0x10f9, 0x9ab: 0x0008, 0x9ac: 0x0008, 0x9ad: 0x0008, 0x9ae: 0x0008, 0x9af: 0x0008, - 0x9b0: 0x0008, 0x9b1: 0x0008, 0x9b2: 0x0008, 0x9b3: 0x0008, 0x9b4: 0x0008, 0x9b5: 0x0008, - 0x9b6: 0x0008, 0x9b7: 0x0008, 0x9b8: 0x1129, 0x9b9: 0x0008, 0x9ba: 0x0008, 0x9bb: 0x0008, - 0x9bc: 0x0008, 0x9bd: 0x0008, 0x9be: 0x0008, 0x9bf: 0x0008, - // Block 0x27, offset 0x9c0 - 0x9c0: 0x0008, 0x9c1: 0x0008, 0x9c2: 0x0008, 0x9c3: 0x0008, 0x9c4: 0x0008, 0x9c5: 0x0008, - 0x9c6: 0x0008, 0x9c7: 0x0008, 0x9c8: 0x0008, 0x9c9: 0x0008, 0x9ca: 0x0008, 0x9cb: 0x0008, - 0x9cc: 0x0008, 0x9cd: 0x0008, 0x9ce: 0x0008, 0x9cf: 0x0008, 0x9d0: 0x0008, 0x9d1: 0x0008, - 0x9d2: 0x0008, 0x9d3: 0x0008, 0x9d4: 0x0008, 0x9d5: 0x0008, 0x9d6: 0x0008, 0x9d7: 0x0008, - 0x9d8: 0x0008, 0x9d9: 0x0008, 0x9da: 0x0008, 0x9db: 0x1141, 0x9dc: 0x1159, 0x9dd: 0x1169, - 0x9de: 0x1181, 0x9df: 0x1029, 0x9e0: 0x1199, 0x9e1: 0x11a9, 0x9e2: 0x11c1, 0x9e3: 0x11d9, - 0x9e4: 0x11f1, 0x9e5: 0x1209, 0x9e6: 0x1221, 0x9e7: 0x05e5, 0x9e8: 0x1239, 0x9e9: 0x1251, - 0x9ea: 0xe17d, 0x9eb: 0x1269, 0x9ec: 0x1281, 0x9ed: 0x1299, 0x9ee: 0x12b1, 0x9ef: 0x12c9, - 0x9f0: 0x12e1, 0x9f1: 0x12f9, 0x9f2: 0x1311, 0x9f3: 0x1329, 0x9f4: 0x1341, 0x9f5: 0x1359, - 0x9f6: 0x1371, 0x9f7: 0x1389, 0x9f8: 0x05fd, 0x9f9: 0x13a1, 0x9fa: 0x13b9, 0x9fb: 0x13d1, - 0x9fc: 0x13e1, 0x9fd: 0x13f9, 0x9fe: 0x1411, 0x9ff: 0x1429, - // Block 0x28, offset 0xa00 - 0xa00: 0xe00d, 0xa01: 0x0008, 0xa02: 0xe00d, 0xa03: 0x0008, 0xa04: 0xe00d, 0xa05: 0x0008, - 0xa06: 0xe00d, 0xa07: 0x0008, 0xa08: 0xe00d, 0xa09: 0x0008, 0xa0a: 0xe00d, 0xa0b: 0x0008, - 0xa0c: 0xe00d, 0xa0d: 0x0008, 0xa0e: 0xe00d, 0xa0f: 0x0008, 0xa10: 0xe00d, 0xa11: 0x0008, - 0xa12: 0xe00d, 0xa13: 0x0008, 0xa14: 0xe00d, 0xa15: 0x0008, 0xa16: 0xe00d, 0xa17: 0x0008, - 0xa18: 0xe00d, 0xa19: 0x0008, 0xa1a: 0xe00d, 0xa1b: 0x0008, 0xa1c: 0xe00d, 0xa1d: 0x0008, - 0xa1e: 0xe00d, 0xa1f: 0x0008, 0xa20: 0xe00d, 0xa21: 0x0008, 0xa22: 0xe00d, 0xa23: 0x0008, - 0xa24: 0xe00d, 0xa25: 0x0008, 0xa26: 0xe00d, 0xa27: 0x0008, 0xa28: 0xe00d, 0xa29: 0x0008, - 0xa2a: 0xe00d, 0xa2b: 0x0008, 0xa2c: 0xe00d, 0xa2d: 0x0008, 0xa2e: 0xe00d, 0xa2f: 0x0008, - 0xa30: 0xe00d, 0xa31: 0x0008, 0xa32: 0xe00d, 0xa33: 0x0008, 0xa34: 0xe00d, 0xa35: 0x0008, - 0xa36: 0xe00d, 0xa37: 0x0008, 0xa38: 0xe00d, 0xa39: 0x0008, 0xa3a: 0xe00d, 0xa3b: 0x0008, - 0xa3c: 0xe00d, 0xa3d: 0x0008, 0xa3e: 0xe00d, 0xa3f: 0x0008, - // Block 0x29, offset 0xa40 - 0xa40: 0xe00d, 0xa41: 0x0008, 0xa42: 0xe00d, 0xa43: 0x0008, 0xa44: 0xe00d, 0xa45: 0x0008, - 0xa46: 0xe00d, 0xa47: 0x0008, 0xa48: 0xe00d, 0xa49: 0x0008, 0xa4a: 0xe00d, 0xa4b: 0x0008, - 0xa4c: 0xe00d, 0xa4d: 0x0008, 0xa4e: 0xe00d, 0xa4f: 0x0008, 0xa50: 0xe00d, 0xa51: 0x0008, - 0xa52: 0xe00d, 0xa53: 0x0008, 0xa54: 0xe00d, 0xa55: 0x0008, 0xa56: 0x0008, 0xa57: 0x0008, - 0xa58: 0x0008, 0xa59: 0x0008, 0xa5a: 0x0615, 0xa5b: 0x0635, 0xa5c: 0x0008, 0xa5d: 0x0008, - 0xa5e: 0x1441, 0xa5f: 0x0008, 0xa60: 0xe00d, 0xa61: 0x0008, 0xa62: 0xe00d, 0xa63: 0x0008, - 0xa64: 0xe00d, 0xa65: 0x0008, 0xa66: 0xe00d, 0xa67: 0x0008, 0xa68: 0xe00d, 0xa69: 0x0008, - 0xa6a: 0xe00d, 0xa6b: 0x0008, 0xa6c: 0xe00d, 0xa6d: 0x0008, 0xa6e: 0xe00d, 0xa6f: 0x0008, - 0xa70: 0xe00d, 0xa71: 0x0008, 0xa72: 0xe00d, 0xa73: 0x0008, 0xa74: 0xe00d, 0xa75: 0x0008, - 0xa76: 0xe00d, 0xa77: 0x0008, 0xa78: 0xe00d, 0xa79: 0x0008, 0xa7a: 0xe00d, 0xa7b: 0x0008, - 0xa7c: 0xe00d, 0xa7d: 0x0008, 0xa7e: 0xe00d, 0xa7f: 0x0008, - // Block 0x2a, offset 0xa80 - 0xa80: 0x0008, 0xa81: 0x0008, 0xa82: 0x0008, 0xa83: 0x0008, 0xa84: 0x0008, 0xa85: 0x0008, - 0xa86: 0x0040, 0xa87: 0x0040, 0xa88: 0xe045, 0xa89: 0xe045, 0xa8a: 0xe045, 0xa8b: 0xe045, - 0xa8c: 0xe045, 0xa8d: 0xe045, 0xa8e: 0x0040, 0xa8f: 0x0040, 0xa90: 0x0008, 0xa91: 0x0008, - 0xa92: 0x0008, 0xa93: 0x0008, 0xa94: 0x0008, 0xa95: 0x0008, 0xa96: 0x0008, 0xa97: 0x0008, - 0xa98: 0x0040, 0xa99: 0xe045, 0xa9a: 0x0040, 0xa9b: 0xe045, 0xa9c: 0x0040, 0xa9d: 0xe045, - 0xa9e: 0x0040, 0xa9f: 0xe045, 0xaa0: 0x0008, 0xaa1: 0x0008, 0xaa2: 0x0008, 0xaa3: 0x0008, - 0xaa4: 0x0008, 0xaa5: 0x0008, 0xaa6: 0x0008, 0xaa7: 0x0008, 0xaa8: 0xe045, 0xaa9: 0xe045, - 0xaaa: 0xe045, 0xaab: 0xe045, 0xaac: 0xe045, 0xaad: 0xe045, 0xaae: 0xe045, 0xaaf: 0xe045, - 0xab0: 0x0008, 0xab1: 0x1459, 0xab2: 0x0008, 0xab3: 0x1471, 0xab4: 0x0008, 0xab5: 0x1489, - 0xab6: 0x0008, 0xab7: 0x14a1, 0xab8: 0x0008, 0xab9: 0x14b9, 0xaba: 0x0008, 0xabb: 0x14d1, - 0xabc: 0x0008, 0xabd: 0x14e9, 0xabe: 0x0040, 0xabf: 0x0040, - // Block 0x2b, offset 0xac0 - 0xac0: 0x1501, 0xac1: 0x1531, 0xac2: 0x1561, 0xac3: 0x1591, 0xac4: 0x15c1, 0xac5: 0x15f1, - 0xac6: 0x1621, 0xac7: 0x1651, 0xac8: 0x1501, 0xac9: 0x1531, 0xaca: 0x1561, 0xacb: 0x1591, - 0xacc: 0x15c1, 0xacd: 0x15f1, 0xace: 0x1621, 0xacf: 0x1651, 0xad0: 0x1681, 0xad1: 0x16b1, - 0xad2: 0x16e1, 0xad3: 0x1711, 0xad4: 0x1741, 0xad5: 0x1771, 0xad6: 0x17a1, 0xad7: 0x17d1, - 0xad8: 0x1681, 0xad9: 0x16b1, 0xada: 0x16e1, 0xadb: 0x1711, 0xadc: 0x1741, 0xadd: 0x1771, - 0xade: 0x17a1, 0xadf: 0x17d1, 0xae0: 0x1801, 0xae1: 0x1831, 0xae2: 0x1861, 0xae3: 0x1891, - 0xae4: 0x18c1, 0xae5: 0x18f1, 0xae6: 0x1921, 0xae7: 0x1951, 0xae8: 0x1801, 0xae9: 0x1831, - 0xaea: 0x1861, 0xaeb: 0x1891, 0xaec: 0x18c1, 0xaed: 0x18f1, 0xaee: 0x1921, 0xaef: 0x1951, - 0xaf0: 0x0008, 0xaf1: 0x0008, 0xaf2: 0x1981, 0xaf3: 0x19b1, 0xaf4: 0x19d9, 0xaf5: 0x0040, - 0xaf6: 0x0008, 0xaf7: 0x1a01, 0xaf8: 0xe045, 0xaf9: 0xe045, 0xafa: 0x064d, 0xafb: 0x1459, - 0xafc: 0x19b1, 0xafd: 0x0666, 0xafe: 0x1a31, 0xaff: 0x0686, - // Block 0x2c, offset 0xb00 - 0xb00: 0x06a6, 0xb01: 0x1a4a, 0xb02: 0x1a79, 0xb03: 0x1aa9, 0xb04: 0x1ad1, 0xb05: 0x0040, - 0xb06: 0x0008, 0xb07: 0x1af9, 0xb08: 0x06c5, 0xb09: 0x1471, 0xb0a: 0x06dd, 0xb0b: 0x1489, - 0xb0c: 0x1aa9, 0xb0d: 0x1b2a, 0xb0e: 0x1b5a, 0xb0f: 0x1b8a, 0xb10: 0x0008, 0xb11: 0x0008, - 0xb12: 0x0008, 0xb13: 0x1bb9, 0xb14: 0x0040, 0xb15: 0x0040, 0xb16: 0x0008, 0xb17: 0x0008, - 0xb18: 0xe045, 0xb19: 0xe045, 0xb1a: 0x06f5, 0xb1b: 0x14a1, 0xb1c: 0x0040, 0xb1d: 0x1bd2, - 0xb1e: 0x1c02, 0xb1f: 0x1c32, 0xb20: 0x0008, 0xb21: 0x0008, 0xb22: 0x0008, 0xb23: 0x1c61, - 0xb24: 0x0008, 0xb25: 0x0008, 0xb26: 0x0008, 0xb27: 0x0008, 0xb28: 0xe045, 0xb29: 0xe045, - 0xb2a: 0x070d, 0xb2b: 0x14d1, 0xb2c: 0xe04d, 0xb2d: 0x1c7a, 0xb2e: 0x03d2, 0xb2f: 0x1caa, - 0xb30: 0x0040, 0xb31: 0x0040, 0xb32: 0x1cb9, 0xb33: 0x1ce9, 0xb34: 0x1d11, 0xb35: 0x0040, - 0xb36: 0x0008, 0xb37: 0x1d39, 0xb38: 0x0725, 0xb39: 0x14b9, 0xb3a: 0x0515, 0xb3b: 0x14e9, - 0xb3c: 0x1ce9, 0xb3d: 0x073e, 0xb3e: 0x075e, 0xb3f: 0x0040, - // Block 0x2d, offset 0xb40 - 0xb40: 0x000a, 0xb41: 0x000a, 0xb42: 0x000a, 0xb43: 0x000a, 0xb44: 0x000a, 0xb45: 0x000a, - 0xb46: 0x000a, 0xb47: 0x000a, 0xb48: 0x000a, 0xb49: 0x000a, 0xb4a: 0x000a, 0xb4b: 0x03c0, - 0xb4c: 0x0003, 0xb4d: 0x0003, 0xb4e: 0x0340, 0xb4f: 0x0340, 0xb50: 0x0018, 0xb51: 0xe00d, - 0xb52: 0x0018, 0xb53: 0x0018, 0xb54: 0x0018, 0xb55: 0x0018, 0xb56: 0x0018, 0xb57: 0x077e, - 0xb58: 0x0018, 0xb59: 0x0018, 0xb5a: 0x0018, 0xb5b: 0x0018, 0xb5c: 0x0018, 0xb5d: 0x0018, - 0xb5e: 0x0018, 0xb5f: 0x0018, 0xb60: 0x0018, 0xb61: 0x0018, 0xb62: 0x0018, 0xb63: 0x0018, - 0xb64: 0x0040, 0xb65: 0x0040, 0xb66: 0x0040, 0xb67: 0x0018, 0xb68: 0x0040, 0xb69: 0x0040, - 0xb6a: 0x0340, 0xb6b: 0x0340, 0xb6c: 0x0340, 0xb6d: 0x0340, 0xb6e: 0x0340, 0xb6f: 0x000a, - 0xb70: 0x0018, 0xb71: 0x0018, 0xb72: 0x0018, 0xb73: 0x1d69, 0xb74: 0x1da1, 0xb75: 0x0018, - 0xb76: 0x1df1, 0xb77: 0x1e29, 0xb78: 0x0018, 0xb79: 0x0018, 0xb7a: 0x0018, 0xb7b: 0x0018, - 0xb7c: 0x1e7a, 0xb7d: 0x0018, 0xb7e: 0x079e, 0xb7f: 0x0018, - // Block 0x2e, offset 0xb80 - 0xb80: 0x0018, 0xb81: 0x0018, 0xb82: 0x0018, 0xb83: 0x0018, 0xb84: 0x0018, 0xb85: 0x0018, - 0xb86: 0x0018, 0xb87: 0x1e92, 0xb88: 0x1eaa, 0xb89: 0x1ec2, 0xb8a: 0x0018, 0xb8b: 0x0018, - 0xb8c: 0x0018, 0xb8d: 0x0018, 0xb8e: 0x0018, 0xb8f: 0x0018, 0xb90: 0x0018, 0xb91: 0x0018, - 0xb92: 0x0018, 0xb93: 0x0018, 0xb94: 0x0018, 0xb95: 0x0018, 0xb96: 0x0018, 0xb97: 0x1ed9, - 0xb98: 0x0018, 0xb99: 0x0018, 0xb9a: 0x0018, 0xb9b: 0x0018, 0xb9c: 0x0018, 0xb9d: 0x0018, - 0xb9e: 0x0018, 0xb9f: 0x000a, 0xba0: 0x03c0, 0xba1: 0x0340, 0xba2: 0x0340, 0xba3: 0x0340, - 0xba4: 0x03c0, 0xba5: 0x0040, 0xba6: 0x0040, 0xba7: 0x0040, 0xba8: 0x0040, 0xba9: 0x0040, - 0xbaa: 0x0340, 0xbab: 0x0340, 0xbac: 0x0340, 0xbad: 0x0340, 0xbae: 0x0340, 0xbaf: 0x0340, - 0xbb0: 0x1f41, 0xbb1: 0x0f41, 0xbb2: 0x0040, 0xbb3: 0x0040, 0xbb4: 0x1f51, 0xbb5: 0x1f61, - 0xbb6: 0x1f71, 0xbb7: 0x1f81, 0xbb8: 0x1f91, 0xbb9: 0x1fa1, 0xbba: 0x1fb2, 0xbbb: 0x07bd, - 0xbbc: 0x1fc2, 0xbbd: 0x1fd2, 0xbbe: 0x1fe2, 0xbbf: 0x0f71, - // Block 0x2f, offset 0xbc0 - 0xbc0: 0x1f41, 0xbc1: 0x00c9, 0xbc2: 0x0069, 0xbc3: 0x0079, 0xbc4: 0x1f51, 0xbc5: 0x1f61, - 0xbc6: 0x1f71, 0xbc7: 0x1f81, 0xbc8: 0x1f91, 0xbc9: 0x1fa1, 0xbca: 0x1fb2, 0xbcb: 0x07d5, - 0xbcc: 0x1fc2, 0xbcd: 0x1fd2, 0xbce: 0x1fe2, 0xbcf: 0x0040, 0xbd0: 0x0039, 0xbd1: 0x0f09, - 0xbd2: 0x00d9, 0xbd3: 0x0369, 0xbd4: 0x0ff9, 0xbd5: 0x0249, 0xbd6: 0x0f51, 0xbd7: 0x0359, - 0xbd8: 0x0f61, 0xbd9: 0x0f71, 0xbda: 0x0f99, 0xbdb: 0x01d9, 0xbdc: 0x0fa9, 0xbdd: 0x0040, - 0xbde: 0x0040, 0xbdf: 0x0040, 0xbe0: 0x0018, 0xbe1: 0x0018, 0xbe2: 0x0018, 0xbe3: 0x0018, - 0xbe4: 0x0018, 0xbe5: 0x0018, 0xbe6: 0x0018, 0xbe7: 0x0018, 0xbe8: 0x1ff1, 0xbe9: 0x0018, - 0xbea: 0x0018, 0xbeb: 0x0018, 0xbec: 0x0018, 0xbed: 0x0018, 0xbee: 0x0018, 0xbef: 0x0018, - 0xbf0: 0x0018, 0xbf1: 0x0018, 0xbf2: 0x0018, 0xbf3: 0x0018, 0xbf4: 0x0018, 0xbf5: 0x0018, - 0xbf6: 0x0018, 0xbf7: 0x0018, 0xbf8: 0x0018, 0xbf9: 0x0018, 0xbfa: 0x0018, 0xbfb: 0x0018, - 0xbfc: 0x0018, 0xbfd: 0x0018, 0xbfe: 0x0018, 0xbff: 0x0040, - // Block 0x30, offset 0xc00 - 0xc00: 0x07ee, 0xc01: 0x080e, 0xc02: 0x1159, 0xc03: 0x082d, 0xc04: 0x0018, 0xc05: 0x084e, - 0xc06: 0x086e, 0xc07: 0x1011, 0xc08: 0x0018, 0xc09: 0x088d, 0xc0a: 0x0f31, 0xc0b: 0x0249, - 0xc0c: 0x0249, 0xc0d: 0x0249, 0xc0e: 0x0249, 0xc0f: 0x2009, 0xc10: 0x0f41, 0xc11: 0x0f41, - 0xc12: 0x0359, 0xc13: 0x0359, 0xc14: 0x0018, 0xc15: 0x0f71, 0xc16: 0x2021, 0xc17: 0x0018, - 0xc18: 0x0018, 0xc19: 0x0f99, 0xc1a: 0x2039, 0xc1b: 0x0269, 0xc1c: 0x0269, 0xc1d: 0x0269, - 0xc1e: 0x0018, 0xc1f: 0x0018, 0xc20: 0x2049, 0xc21: 0x08ad, 0xc22: 0x2061, 0xc23: 0x0018, - 0xc24: 0x13d1, 0xc25: 0x0018, 0xc26: 0x2079, 0xc27: 0x0018, 0xc28: 0x13d1, 0xc29: 0x0018, - 0xc2a: 0x0f51, 0xc2b: 0x2091, 0xc2c: 0x0ee9, 0xc2d: 0x1159, 0xc2e: 0x0018, 0xc2f: 0x0f09, - 0xc30: 0x0f09, 0xc31: 0x1199, 0xc32: 0x0040, 0xc33: 0x0f61, 0xc34: 0x00d9, 0xc35: 0x20a9, - 0xc36: 0x20c1, 0xc37: 0x20d9, 0xc38: 0x20f1, 0xc39: 0x0f41, 0xc3a: 0x0018, 0xc3b: 0x08cd, - 0xc3c: 0x2109, 0xc3d: 0x10b1, 0xc3e: 0x10b1, 0xc3f: 0x2109, - // Block 0x31, offset 0xc40 - 0xc40: 0x08ed, 0xc41: 0x0018, 0xc42: 0x0018, 0xc43: 0x0018, 0xc44: 0x0018, 0xc45: 0x0ef9, - 0xc46: 0x0ef9, 0xc47: 0x0f09, 0xc48: 0x0f41, 0xc49: 0x0259, 0xc4a: 0x0018, 0xc4b: 0x0018, - 0xc4c: 0x0018, 0xc4d: 0x0018, 0xc4e: 0x0008, 0xc4f: 0x0018, 0xc50: 0x2121, 0xc51: 0x2151, - 0xc52: 0x2181, 0xc53: 0x21b9, 0xc54: 0x21e9, 0xc55: 0x2219, 0xc56: 0x2249, 0xc57: 0x2279, - 0xc58: 0x22a9, 0xc59: 0x22d9, 0xc5a: 0x2309, 0xc5b: 0x2339, 0xc5c: 0x2369, 0xc5d: 0x2399, - 0xc5e: 0x23c9, 0xc5f: 0x23f9, 0xc60: 0x0f41, 0xc61: 0x2421, 0xc62: 0x0905, 0xc63: 0x2439, - 0xc64: 0x1089, 0xc65: 0x2451, 0xc66: 0x0925, 0xc67: 0x2469, 0xc68: 0x2491, 0xc69: 0x0369, - 0xc6a: 0x24a9, 0xc6b: 0x0945, 0xc6c: 0x0359, 0xc6d: 0x1159, 0xc6e: 0x0ef9, 0xc6f: 0x0f61, - 0xc70: 0x0f41, 0xc71: 0x2421, 0xc72: 0x0965, 0xc73: 0x2439, 0xc74: 0x1089, 0xc75: 0x2451, - 0xc76: 0x0985, 0xc77: 0x2469, 0xc78: 0x2491, 0xc79: 0x0369, 0xc7a: 0x24a9, 0xc7b: 0x09a5, - 0xc7c: 0x0359, 0xc7d: 0x1159, 0xc7e: 0x0ef9, 0xc7f: 0x0f61, - // Block 0x32, offset 0xc80 - 0xc80: 0x0018, 0xc81: 0x0018, 0xc82: 0x0018, 0xc83: 0x0018, 0xc84: 0x0018, 0xc85: 0x0018, - 0xc86: 0x0018, 0xc87: 0x0018, 0xc88: 0x0018, 0xc89: 0x0018, 0xc8a: 0x0018, 0xc8b: 0x0040, - 0xc8c: 0x0040, 0xc8d: 0x0040, 0xc8e: 0x0040, 0xc8f: 0x0040, 0xc90: 0x0040, 0xc91: 0x0040, - 0xc92: 0x0040, 0xc93: 0x0040, 0xc94: 0x0040, 0xc95: 0x0040, 0xc96: 0x0040, 0xc97: 0x0040, - 0xc98: 0x0040, 0xc99: 0x0040, 0xc9a: 0x0040, 0xc9b: 0x0040, 0xc9c: 0x0040, 0xc9d: 0x0040, - 0xc9e: 0x0040, 0xc9f: 0x0040, 0xca0: 0x00c9, 0xca1: 0x0069, 0xca2: 0x0079, 0xca3: 0x1f51, - 0xca4: 0x1f61, 0xca5: 0x1f71, 0xca6: 0x1f81, 0xca7: 0x1f91, 0xca8: 0x1fa1, 0xca9: 0x2601, - 0xcaa: 0x2619, 0xcab: 0x2631, 0xcac: 0x2649, 0xcad: 0x2661, 0xcae: 0x2679, 0xcaf: 0x2691, - 0xcb0: 0x26a9, 0xcb1: 0x26c1, 0xcb2: 0x26d9, 0xcb3: 0x26f1, 0xcb4: 0x0a06, 0xcb5: 0x0a26, - 0xcb6: 0x0a46, 0xcb7: 0x0a66, 0xcb8: 0x0a86, 0xcb9: 0x0aa6, 0xcba: 0x0ac6, 0xcbb: 0x0ae6, - 0xcbc: 0x0b06, 0xcbd: 0x270a, 0xcbe: 0x2732, 0xcbf: 0x275a, - // Block 0x33, offset 0xcc0 - 0xcc0: 0x2782, 0xcc1: 0x27aa, 0xcc2: 0x27d2, 0xcc3: 0x27fa, 0xcc4: 0x2822, 0xcc5: 0x284a, - 0xcc6: 0x2872, 0xcc7: 0x289a, 0xcc8: 0x0040, 0xcc9: 0x0040, 0xcca: 0x0040, 0xccb: 0x0040, - 0xccc: 0x0040, 0xccd: 0x0040, 0xcce: 0x0040, 0xccf: 0x0040, 0xcd0: 0x0040, 0xcd1: 0x0040, - 0xcd2: 0x0040, 0xcd3: 0x0040, 0xcd4: 0x0040, 0xcd5: 0x0040, 0xcd6: 0x0040, 0xcd7: 0x0040, - 0xcd8: 0x0040, 0xcd9: 0x0040, 0xcda: 0x0040, 0xcdb: 0x0040, 0xcdc: 0x0b26, 0xcdd: 0x0b46, - 0xcde: 0x0b66, 0xcdf: 0x0b86, 0xce0: 0x0ba6, 0xce1: 0x0bc6, 0xce2: 0x0be6, 0xce3: 0x0c06, - 0xce4: 0x0c26, 0xce5: 0x0c46, 0xce6: 0x0c66, 0xce7: 0x0c86, 0xce8: 0x0ca6, 0xce9: 0x0cc6, - 0xcea: 0x0ce6, 0xceb: 0x0d06, 0xcec: 0x0d26, 0xced: 0x0d46, 0xcee: 0x0d66, 0xcef: 0x0d86, - 0xcf0: 0x0da6, 0xcf1: 0x0dc6, 0xcf2: 0x0de6, 0xcf3: 0x0e06, 0xcf4: 0x0e26, 0xcf5: 0x0e46, - 0xcf6: 0x0039, 0xcf7: 0x0ee9, 0xcf8: 0x1159, 0xcf9: 0x0ef9, 0xcfa: 0x0f09, 0xcfb: 0x1199, - 0xcfc: 0x0f31, 0xcfd: 0x0249, 0xcfe: 0x0f41, 0xcff: 0x0259, - // Block 0x34, offset 0xd00 - 0xd00: 0x0f51, 0xd01: 0x0359, 0xd02: 0x0f61, 0xd03: 0x0f71, 0xd04: 0x00d9, 0xd05: 0x0f99, - 0xd06: 0x2039, 0xd07: 0x0269, 0xd08: 0x01d9, 0xd09: 0x0fa9, 0xd0a: 0x0fb9, 0xd0b: 0x1089, - 0xd0c: 0x0279, 0xd0d: 0x0369, 0xd0e: 0x0289, 0xd0f: 0x13d1, 0xd10: 0x0039, 0xd11: 0x0ee9, - 0xd12: 0x1159, 0xd13: 0x0ef9, 0xd14: 0x0f09, 0xd15: 0x1199, 0xd16: 0x0f31, 0xd17: 0x0249, - 0xd18: 0x0f41, 0xd19: 0x0259, 0xd1a: 0x0f51, 0xd1b: 0x0359, 0xd1c: 0x0f61, 0xd1d: 0x0f71, - 0xd1e: 0x00d9, 0xd1f: 0x0f99, 0xd20: 0x2039, 0xd21: 0x0269, 0xd22: 0x01d9, 0xd23: 0x0fa9, - 0xd24: 0x0fb9, 0xd25: 0x1089, 0xd26: 0x0279, 0xd27: 0x0369, 0xd28: 0x0289, 0xd29: 0x13d1, - 0xd2a: 0x1f41, 0xd2b: 0x0018, 0xd2c: 0x0018, 0xd2d: 0x0018, 0xd2e: 0x0018, 0xd2f: 0x0018, - 0xd30: 0x0018, 0xd31: 0x0018, 0xd32: 0x0018, 0xd33: 0x0018, 0xd34: 0x0018, 0xd35: 0x0018, - 0xd36: 0x0018, 0xd37: 0x0018, 0xd38: 0x0018, 0xd39: 0x0018, 0xd3a: 0x0018, 0xd3b: 0x0018, - 0xd3c: 0x0018, 0xd3d: 0x0018, 0xd3e: 0x0018, 0xd3f: 0x0018, - // Block 0x35, offset 0xd40 - 0xd40: 0x0008, 0xd41: 0x0008, 0xd42: 0x0008, 0xd43: 0x0008, 0xd44: 0x0008, 0xd45: 0x0008, - 0xd46: 0x0008, 0xd47: 0x0008, 0xd48: 0x0008, 0xd49: 0x0008, 0xd4a: 0x0008, 0xd4b: 0x0008, - 0xd4c: 0x0008, 0xd4d: 0x0008, 0xd4e: 0x0008, 0xd4f: 0x0008, 0xd50: 0x0008, 0xd51: 0x0008, - 0xd52: 0x0008, 0xd53: 0x0008, 0xd54: 0x0008, 0xd55: 0x0008, 0xd56: 0x0008, 0xd57: 0x0008, - 0xd58: 0x0008, 0xd59: 0x0008, 0xd5a: 0x0008, 0xd5b: 0x0008, 0xd5c: 0x0008, 0xd5d: 0x0008, - 0xd5e: 0x0008, 0xd5f: 0x0040, 0xd60: 0xe00d, 0xd61: 0x0008, 0xd62: 0x2971, 0xd63: 0x0ebd, - 0xd64: 0x2989, 0xd65: 0x0008, 0xd66: 0x0008, 0xd67: 0xe07d, 0xd68: 0x0008, 0xd69: 0xe01d, - 0xd6a: 0x0008, 0xd6b: 0xe03d, 0xd6c: 0x0008, 0xd6d: 0x0fe1, 0xd6e: 0x1281, 0xd6f: 0x0fc9, - 0xd70: 0x1141, 0xd71: 0x0008, 0xd72: 0xe00d, 0xd73: 0x0008, 0xd74: 0x0008, 0xd75: 0xe01d, - 0xd76: 0x0008, 0xd77: 0x0008, 0xd78: 0x0008, 0xd79: 0x0008, 0xd7a: 0x0008, 0xd7b: 0x0008, - 0xd7c: 0x0259, 0xd7d: 0x1089, 0xd7e: 0x29a1, 0xd7f: 0x29b9, - // Block 0x36, offset 0xd80 - 0xd80: 0xe00d, 0xd81: 0x0008, 0xd82: 0xe00d, 0xd83: 0x0008, 0xd84: 0xe00d, 0xd85: 0x0008, - 0xd86: 0xe00d, 0xd87: 0x0008, 0xd88: 0xe00d, 0xd89: 0x0008, 0xd8a: 0xe00d, 0xd8b: 0x0008, - 0xd8c: 0xe00d, 0xd8d: 0x0008, 0xd8e: 0xe00d, 0xd8f: 0x0008, 0xd90: 0xe00d, 0xd91: 0x0008, - 0xd92: 0xe00d, 0xd93: 0x0008, 0xd94: 0xe00d, 0xd95: 0x0008, 0xd96: 0xe00d, 0xd97: 0x0008, - 0xd98: 0xe00d, 0xd99: 0x0008, 0xd9a: 0xe00d, 0xd9b: 0x0008, 0xd9c: 0xe00d, 0xd9d: 0x0008, - 0xd9e: 0xe00d, 0xd9f: 0x0008, 0xda0: 0xe00d, 0xda1: 0x0008, 0xda2: 0xe00d, 0xda3: 0x0008, - 0xda4: 0x0008, 0xda5: 0x0018, 0xda6: 0x0018, 0xda7: 0x0018, 0xda8: 0x0018, 0xda9: 0x0018, - 0xdaa: 0x0018, 0xdab: 0xe03d, 0xdac: 0x0008, 0xdad: 0xe01d, 0xdae: 0x0008, 0xdaf: 0x1308, - 0xdb0: 0x1308, 0xdb1: 0x1308, 0xdb2: 0xe00d, 0xdb3: 0x0008, 0xdb4: 0x0040, 0xdb5: 0x0040, - 0xdb6: 0x0040, 0xdb7: 0x0040, 0xdb8: 0x0040, 0xdb9: 0x0018, 0xdba: 0x0018, 0xdbb: 0x0018, - 0xdbc: 0x0018, 0xdbd: 0x0018, 0xdbe: 0x0018, 0xdbf: 0x0018, - // Block 0x37, offset 0xdc0 - 0xdc0: 0x26fd, 0xdc1: 0x271d, 0xdc2: 0x273d, 0xdc3: 0x275d, 0xdc4: 0x277d, 0xdc5: 0x279d, - 0xdc6: 0x27bd, 0xdc7: 0x27dd, 0xdc8: 0x27fd, 0xdc9: 0x281d, 0xdca: 0x283d, 0xdcb: 0x285d, - 0xdcc: 0x287d, 0xdcd: 0x289d, 0xdce: 0x28bd, 0xdcf: 0x28dd, 0xdd0: 0x28fd, 0xdd1: 0x291d, - 0xdd2: 0x293d, 0xdd3: 0x295d, 0xdd4: 0x297d, 0xdd5: 0x299d, 0xdd6: 0x0040, 0xdd7: 0x0040, - 0xdd8: 0x0040, 0xdd9: 0x0040, 0xdda: 0x0040, 0xddb: 0x0040, 0xddc: 0x0040, 0xddd: 0x0040, - 0xdde: 0x0040, 0xddf: 0x0040, 0xde0: 0x0040, 0xde1: 0x0040, 0xde2: 0x0040, 0xde3: 0x0040, - 0xde4: 0x0040, 0xde5: 0x0040, 0xde6: 0x0040, 0xde7: 0x0040, 0xde8: 0x0040, 0xde9: 0x0040, - 0xdea: 0x0040, 0xdeb: 0x0040, 0xdec: 0x0040, 0xded: 0x0040, 0xdee: 0x0040, 0xdef: 0x0040, - 0xdf0: 0x0040, 0xdf1: 0x0040, 0xdf2: 0x0040, 0xdf3: 0x0040, 0xdf4: 0x0040, 0xdf5: 0x0040, - 0xdf6: 0x0040, 0xdf7: 0x0040, 0xdf8: 0x0040, 0xdf9: 0x0040, 0xdfa: 0x0040, 0xdfb: 0x0040, - 0xdfc: 0x0040, 0xdfd: 0x0040, 0xdfe: 0x0040, 0xdff: 0x0040, - // Block 0x38, offset 0xe00 - 0xe00: 0x000a, 0xe01: 0x0018, 0xe02: 0x29d1, 0xe03: 0x0018, 0xe04: 0x0018, 0xe05: 0x0008, - 0xe06: 0x0008, 0xe07: 0x0008, 0xe08: 0x0018, 0xe09: 0x0018, 0xe0a: 0x0018, 0xe0b: 0x0018, - 0xe0c: 0x0018, 0xe0d: 0x0018, 0xe0e: 0x0018, 0xe0f: 0x0018, 0xe10: 0x0018, 0xe11: 0x0018, - 0xe12: 0x0018, 0xe13: 0x0018, 0xe14: 0x0018, 0xe15: 0x0018, 0xe16: 0x0018, 0xe17: 0x0018, - 0xe18: 0x0018, 0xe19: 0x0018, 0xe1a: 0x0018, 0xe1b: 0x0018, 0xe1c: 0x0018, 0xe1d: 0x0018, - 0xe1e: 0x0018, 0xe1f: 0x0018, 0xe20: 0x0018, 0xe21: 0x0018, 0xe22: 0x0018, 0xe23: 0x0018, - 0xe24: 0x0018, 0xe25: 0x0018, 0xe26: 0x0018, 0xe27: 0x0018, 0xe28: 0x0018, 0xe29: 0x0018, - 0xe2a: 0x1308, 0xe2b: 0x1308, 0xe2c: 0x1308, 0xe2d: 0x1308, 0xe2e: 0x1018, 0xe2f: 0x1018, - 0xe30: 0x0018, 0xe31: 0x0018, 0xe32: 0x0018, 0xe33: 0x0018, 0xe34: 0x0018, 0xe35: 0x0018, - 0xe36: 0xe125, 0xe37: 0x0018, 0xe38: 0x29bd, 0xe39: 0x29dd, 0xe3a: 0x29fd, 0xe3b: 0x0018, - 0xe3c: 0x0008, 0xe3d: 0x0018, 0xe3e: 0x0018, 0xe3f: 0x0018, - // Block 0x39, offset 0xe40 - 0xe40: 0x2b3d, 0xe41: 0x2b5d, 0xe42: 0x2b7d, 0xe43: 0x2b9d, 0xe44: 0x2bbd, 0xe45: 0x2bdd, - 0xe46: 0x2bdd, 0xe47: 0x2bdd, 0xe48: 0x2bfd, 0xe49: 0x2bfd, 0xe4a: 0x2bfd, 0xe4b: 0x2bfd, - 0xe4c: 0x2c1d, 0xe4d: 0x2c1d, 0xe4e: 0x2c1d, 0xe4f: 0x2c3d, 0xe50: 0x2c5d, 0xe51: 0x2c5d, - 0xe52: 0x2a7d, 0xe53: 0x2a7d, 0xe54: 0x2c5d, 0xe55: 0x2c5d, 0xe56: 0x2c7d, 0xe57: 0x2c7d, - 0xe58: 0x2c5d, 0xe59: 0x2c5d, 0xe5a: 0x2a7d, 0xe5b: 0x2a7d, 0xe5c: 0x2c5d, 0xe5d: 0x2c5d, - 0xe5e: 0x2c3d, 0xe5f: 0x2c3d, 0xe60: 0x2c9d, 0xe61: 0x2c9d, 0xe62: 0x2cbd, 0xe63: 0x2cbd, - 0xe64: 0x0040, 0xe65: 0x2cdd, 0xe66: 0x2cfd, 0xe67: 0x2d1d, 0xe68: 0x2d1d, 0xe69: 0x2d3d, - 0xe6a: 0x2d5d, 0xe6b: 0x2d7d, 0xe6c: 0x2d9d, 0xe6d: 0x2dbd, 0xe6e: 0x2ddd, 0xe6f: 0x2dfd, - 0xe70: 0x2e1d, 0xe71: 0x2e3d, 0xe72: 0x2e3d, 0xe73: 0x2e5d, 0xe74: 0x2e7d, 0xe75: 0x2e7d, - 0xe76: 0x2e9d, 0xe77: 0x2ebd, 0xe78: 0x2e5d, 0xe79: 0x2edd, 0xe7a: 0x2efd, 0xe7b: 0x2edd, - 0xe7c: 0x2e5d, 0xe7d: 0x2f1d, 0xe7e: 0x2f3d, 0xe7f: 0x2f5d, - // Block 0x3a, offset 0xe80 - 0xe80: 0x2f7d, 0xe81: 0x2f9d, 0xe82: 0x2cfd, 0xe83: 0x2cdd, 0xe84: 0x2fbd, 0xe85: 0x2fdd, - 0xe86: 0x2ffd, 0xe87: 0x301d, 0xe88: 0x303d, 0xe89: 0x305d, 0xe8a: 0x307d, 0xe8b: 0x309d, - 0xe8c: 0x30bd, 0xe8d: 0x30dd, 0xe8e: 0x30fd, 0xe8f: 0x0040, 0xe90: 0x0018, 0xe91: 0x0018, - 0xe92: 0x311d, 0xe93: 0x313d, 0xe94: 0x315d, 0xe95: 0x317d, 0xe96: 0x319d, 0xe97: 0x31bd, - 0xe98: 0x31dd, 0xe99: 0x31fd, 0xe9a: 0x321d, 0xe9b: 0x323d, 0xe9c: 0x315d, 0xe9d: 0x325d, - 0xe9e: 0x327d, 0xe9f: 0x329d, 0xea0: 0x0008, 0xea1: 0x0008, 0xea2: 0x0008, 0xea3: 0x0008, - 0xea4: 0x0008, 0xea5: 0x0008, 0xea6: 0x0008, 0xea7: 0x0008, 0xea8: 0x0008, 0xea9: 0x0008, - 0xeaa: 0x0008, 0xeab: 0x0008, 0xeac: 0x0008, 0xead: 0x0008, 0xeae: 0x0008, 0xeaf: 0x0008, - 0xeb0: 0x0008, 0xeb1: 0x0008, 0xeb2: 0x0008, 0xeb3: 0x0008, 0xeb4: 0x0008, 0xeb5: 0x0008, - 0xeb6: 0x0008, 0xeb7: 0x0008, 0xeb8: 0x0008, 0xeb9: 0x0008, 0xeba: 0x0008, 0xebb: 0x0040, - 0xebc: 0x0040, 0xebd: 0x0040, 0xebe: 0x0040, 0xebf: 0x0040, - // Block 0x3b, offset 0xec0 - 0xec0: 0x36a2, 0xec1: 0x36d2, 0xec2: 0x3702, 0xec3: 0x3732, 0xec4: 0x32bd, 0xec5: 0x32dd, - 0xec6: 0x32fd, 0xec7: 0x331d, 0xec8: 0x0018, 0xec9: 0x0018, 0xeca: 0x0018, 0xecb: 0x0018, - 0xecc: 0x0018, 0xecd: 0x0018, 0xece: 0x0018, 0xecf: 0x0018, 0xed0: 0x333d, 0xed1: 0x3761, - 0xed2: 0x3779, 0xed3: 0x3791, 0xed4: 0x37a9, 0xed5: 0x37c1, 0xed6: 0x37d9, 0xed7: 0x37f1, - 0xed8: 0x3809, 0xed9: 0x3821, 0xeda: 0x3839, 0xedb: 0x3851, 0xedc: 0x3869, 0xedd: 0x3881, - 0xede: 0x3899, 0xedf: 0x38b1, 0xee0: 0x335d, 0xee1: 0x337d, 0xee2: 0x339d, 0xee3: 0x33bd, - 0xee4: 0x33dd, 0xee5: 0x33dd, 0xee6: 0x33fd, 0xee7: 0x341d, 0xee8: 0x343d, 0xee9: 0x345d, - 0xeea: 0x347d, 0xeeb: 0x349d, 0xeec: 0x34bd, 0xeed: 0x34dd, 0xeee: 0x34fd, 0xeef: 0x351d, - 0xef0: 0x353d, 0xef1: 0x355d, 0xef2: 0x357d, 0xef3: 0x359d, 0xef4: 0x35bd, 0xef5: 0x35dd, - 0xef6: 0x35fd, 0xef7: 0x361d, 0xef8: 0x363d, 0xef9: 0x365d, 0xefa: 0x367d, 0xefb: 0x369d, - 0xefc: 0x38c9, 0xefd: 0x3901, 0xefe: 0x36bd, 0xeff: 0x0018, - // Block 0x3c, offset 0xf00 - 0xf00: 0x36dd, 0xf01: 0x36fd, 0xf02: 0x371d, 0xf03: 0x373d, 0xf04: 0x375d, 0xf05: 0x377d, - 0xf06: 0x379d, 0xf07: 0x37bd, 0xf08: 0x37dd, 0xf09: 0x37fd, 0xf0a: 0x381d, 0xf0b: 0x383d, - 0xf0c: 0x385d, 0xf0d: 0x387d, 0xf0e: 0x389d, 0xf0f: 0x38bd, 0xf10: 0x38dd, 0xf11: 0x38fd, - 0xf12: 0x391d, 0xf13: 0x393d, 0xf14: 0x395d, 0xf15: 0x397d, 0xf16: 0x399d, 0xf17: 0x39bd, - 0xf18: 0x39dd, 0xf19: 0x39fd, 0xf1a: 0x3a1d, 0xf1b: 0x3a3d, 0xf1c: 0x3a5d, 0xf1d: 0x3a7d, - 0xf1e: 0x3a9d, 0xf1f: 0x3abd, 0xf20: 0x3add, 0xf21: 0x3afd, 0xf22: 0x3b1d, 0xf23: 0x3b3d, - 0xf24: 0x3b5d, 0xf25: 0x3b7d, 0xf26: 0x127d, 0xf27: 0x3b9d, 0xf28: 0x3bbd, 0xf29: 0x3bdd, - 0xf2a: 0x3bfd, 0xf2b: 0x3c1d, 0xf2c: 0x3c3d, 0xf2d: 0x3c5d, 0xf2e: 0x239d, 0xf2f: 0x3c7d, - 0xf30: 0x3c9d, 0xf31: 0x3939, 0xf32: 0x3951, 0xf33: 0x3969, 0xf34: 0x3981, 0xf35: 0x3999, - 0xf36: 0x39b1, 0xf37: 0x39c9, 0xf38: 0x39e1, 0xf39: 0x39f9, 0xf3a: 0x3a11, 0xf3b: 0x3a29, - 0xf3c: 0x3a41, 0xf3d: 0x3a59, 0xf3e: 0x3a71, 0xf3f: 0x3a89, - // Block 0x3d, offset 0xf40 - 0xf40: 0x3aa1, 0xf41: 0x3ac9, 0xf42: 0x3af1, 0xf43: 0x3b19, 0xf44: 0x3b41, 0xf45: 0x3b69, - 0xf46: 0x3b91, 0xf47: 0x3bb9, 0xf48: 0x3be1, 0xf49: 0x3c09, 0xf4a: 0x3c39, 0xf4b: 0x3c69, - 0xf4c: 0x3c99, 0xf4d: 0x3cbd, 0xf4e: 0x3cb1, 0xf4f: 0x3cdd, 0xf50: 0x3cfd, 0xf51: 0x3d15, - 0xf52: 0x3d2d, 0xf53: 0x3d45, 0xf54: 0x3d5d, 0xf55: 0x3d5d, 0xf56: 0x3d45, 0xf57: 0x3d75, - 0xf58: 0x07bd, 0xf59: 0x3d8d, 0xf5a: 0x3da5, 0xf5b: 0x3dbd, 0xf5c: 0x3dd5, 0xf5d: 0x3ded, - 0xf5e: 0x3e05, 0xf5f: 0x3e1d, 0xf60: 0x3e35, 0xf61: 0x3e4d, 0xf62: 0x3e65, 0xf63: 0x3e7d, - 0xf64: 0x3e95, 0xf65: 0x3e95, 0xf66: 0x3ead, 0xf67: 0x3ead, 0xf68: 0x3ec5, 0xf69: 0x3ec5, - 0xf6a: 0x3edd, 0xf6b: 0x3ef5, 0xf6c: 0x3f0d, 0xf6d: 0x3f25, 0xf6e: 0x3f3d, 0xf6f: 0x3f3d, - 0xf70: 0x3f55, 0xf71: 0x3f55, 0xf72: 0x3f55, 0xf73: 0x3f6d, 0xf74: 0x3f85, 0xf75: 0x3f9d, - 0xf76: 0x3fb5, 0xf77: 0x3f9d, 0xf78: 0x3fcd, 0xf79: 0x3fe5, 0xf7a: 0x3f6d, 0xf7b: 0x3ffd, - 0xf7c: 0x4015, 0xf7d: 0x4015, 0xf7e: 0x4015, 0xf7f: 0x0040, - // Block 0x3e, offset 0xf80 - 0xf80: 0x3cc9, 0xf81: 0x3d31, 0xf82: 0x3d99, 0xf83: 0x3e01, 0xf84: 0x3e51, 0xf85: 0x3eb9, - 0xf86: 0x3f09, 0xf87: 0x3f59, 0xf88: 0x3fd9, 0xf89: 0x4041, 0xf8a: 0x4091, 0xf8b: 0x40e1, - 0xf8c: 0x4131, 0xf8d: 0x4199, 0xf8e: 0x4201, 0xf8f: 0x4251, 0xf90: 0x42a1, 0xf91: 0x42d9, - 0xf92: 0x4329, 0xf93: 0x4391, 0xf94: 0x43f9, 0xf95: 0x4431, 0xf96: 0x44b1, 0xf97: 0x4549, - 0xf98: 0x45c9, 0xf99: 0x4619, 0xf9a: 0x4699, 0xf9b: 0x4719, 0xf9c: 0x4781, 0xf9d: 0x47d1, - 0xf9e: 0x4821, 0xf9f: 0x4871, 0xfa0: 0x48d9, 0xfa1: 0x4959, 0xfa2: 0x49c1, 0xfa3: 0x4a11, - 0xfa4: 0x4a61, 0xfa5: 0x4ab1, 0xfa6: 0x4ae9, 0xfa7: 0x4b21, 0xfa8: 0x4b59, 0xfa9: 0x4b91, - 0xfaa: 0x4be1, 0xfab: 0x4c31, 0xfac: 0x4cb1, 0xfad: 0x4d01, 0xfae: 0x4d69, 0xfaf: 0x4de9, - 0xfb0: 0x4e39, 0xfb1: 0x4e71, 0xfb2: 0x4ea9, 0xfb3: 0x4f29, 0xfb4: 0x4f91, 0xfb5: 0x5011, - 0xfb6: 0x5061, 0xfb7: 0x50e1, 0xfb8: 0x5119, 0xfb9: 0x5169, 0xfba: 0x51b9, 0xfbb: 0x5209, - 0xfbc: 0x5259, 0xfbd: 0x52a9, 0xfbe: 0x5311, 0xfbf: 0x5361, - // Block 0x3f, offset 0xfc0 - 0xfc0: 0x5399, 0xfc1: 0x53e9, 0xfc2: 0x5439, 0xfc3: 0x5489, 0xfc4: 0x54f1, 0xfc5: 0x5541, - 0xfc6: 0x5591, 0xfc7: 0x55e1, 0xfc8: 0x5661, 0xfc9: 0x56c9, 0xfca: 0x5701, 0xfcb: 0x5781, - 0xfcc: 0x57b9, 0xfcd: 0x5821, 0xfce: 0x5889, 0xfcf: 0x58d9, 0xfd0: 0x5929, 0xfd1: 0x5979, - 0xfd2: 0x59e1, 0xfd3: 0x5a19, 0xfd4: 0x5a69, 0xfd5: 0x5ad1, 0xfd6: 0x5b09, 0xfd7: 0x5b89, - 0xfd8: 0x5bd9, 0xfd9: 0x5c01, 0xfda: 0x5c29, 0xfdb: 0x5c51, 0xfdc: 0x5c79, 0xfdd: 0x5ca1, - 0xfde: 0x5cc9, 0xfdf: 0x5cf1, 0xfe0: 0x5d19, 0xfe1: 0x5d41, 0xfe2: 0x5d69, 0xfe3: 0x5d99, - 0xfe4: 0x5dc9, 0xfe5: 0x5df9, 0xfe6: 0x5e29, 0xfe7: 0x5e59, 0xfe8: 0x5e89, 0xfe9: 0x5eb9, - 0xfea: 0x5ee9, 0xfeb: 0x5f19, 0xfec: 0x5f49, 0xfed: 0x5f79, 0xfee: 0x5fa9, 0xfef: 0x5fd9, - 0xff0: 0x6009, 0xff1: 0x402d, 0xff2: 0x6039, 0xff3: 0x6051, 0xff4: 0x404d, 0xff5: 0x6069, - 0xff6: 0x6081, 0xff7: 0x6099, 0xff8: 0x406d, 0xff9: 0x406d, 0xffa: 0x60b1, 0xffb: 0x60c9, - 0xffc: 0x6101, 0xffd: 0x6139, 0xffe: 0x6171, 0xfff: 0x61a9, - // Block 0x40, offset 0x1000 - 0x1000: 0x6211, 0x1001: 0x6229, 0x1002: 0x408d, 0x1003: 0x6241, 0x1004: 0x6259, 0x1005: 0x6271, - 0x1006: 0x6289, 0x1007: 0x62a1, 0x1008: 0x40ad, 0x1009: 0x62b9, 0x100a: 0x62e1, 0x100b: 0x62f9, - 0x100c: 0x40cd, 0x100d: 0x40cd, 0x100e: 0x6311, 0x100f: 0x6329, 0x1010: 0x6341, 0x1011: 0x40ed, - 0x1012: 0x410d, 0x1013: 0x412d, 0x1014: 0x414d, 0x1015: 0x416d, 0x1016: 0x6359, 0x1017: 0x6371, - 0x1018: 0x6389, 0x1019: 0x63a1, 0x101a: 0x63b9, 0x101b: 0x418d, 0x101c: 0x63d1, 0x101d: 0x63e9, - 0x101e: 0x6401, 0x101f: 0x41ad, 0x1020: 0x41cd, 0x1021: 0x6419, 0x1022: 0x41ed, 0x1023: 0x420d, - 0x1024: 0x422d, 0x1025: 0x6431, 0x1026: 0x424d, 0x1027: 0x6449, 0x1028: 0x6479, 0x1029: 0x6211, - 0x102a: 0x426d, 0x102b: 0x428d, 0x102c: 0x42ad, 0x102d: 0x42cd, 0x102e: 0x64b1, 0x102f: 0x64f1, - 0x1030: 0x6539, 0x1031: 0x6551, 0x1032: 0x42ed, 0x1033: 0x6569, 0x1034: 0x6581, 0x1035: 0x6599, - 0x1036: 0x430d, 0x1037: 0x65b1, 0x1038: 0x65c9, 0x1039: 0x65b1, 0x103a: 0x65e1, 0x103b: 0x65f9, - 0x103c: 0x432d, 0x103d: 0x6611, 0x103e: 0x6629, 0x103f: 0x6611, - // Block 0x41, offset 0x1040 - 0x1040: 0x434d, 0x1041: 0x436d, 0x1042: 0x0040, 0x1043: 0x6641, 0x1044: 0x6659, 0x1045: 0x6671, - 0x1046: 0x6689, 0x1047: 0x0040, 0x1048: 0x66c1, 0x1049: 0x66d9, 0x104a: 0x66f1, 0x104b: 0x6709, - 0x104c: 0x6721, 0x104d: 0x6739, 0x104e: 0x6401, 0x104f: 0x6751, 0x1050: 0x6769, 0x1051: 0x6781, - 0x1052: 0x438d, 0x1053: 0x6799, 0x1054: 0x6289, 0x1055: 0x43ad, 0x1056: 0x43cd, 0x1057: 0x67b1, - 0x1058: 0x0040, 0x1059: 0x43ed, 0x105a: 0x67c9, 0x105b: 0x67e1, 0x105c: 0x67f9, 0x105d: 0x6811, - 0x105e: 0x6829, 0x105f: 0x6859, 0x1060: 0x6889, 0x1061: 0x68b1, 0x1062: 0x68d9, 0x1063: 0x6901, - 0x1064: 0x6929, 0x1065: 0x6951, 0x1066: 0x6979, 0x1067: 0x69a1, 0x1068: 0x69c9, 0x1069: 0x69f1, - 0x106a: 0x6a21, 0x106b: 0x6a51, 0x106c: 0x6a81, 0x106d: 0x6ab1, 0x106e: 0x6ae1, 0x106f: 0x6b11, - 0x1070: 0x6b41, 0x1071: 0x6b71, 0x1072: 0x6ba1, 0x1073: 0x6bd1, 0x1074: 0x6c01, 0x1075: 0x6c31, - 0x1076: 0x6c61, 0x1077: 0x6c91, 0x1078: 0x6cc1, 0x1079: 0x6cf1, 0x107a: 0x6d21, 0x107b: 0x6d51, - 0x107c: 0x6d81, 0x107d: 0x6db1, 0x107e: 0x6de1, 0x107f: 0x440d, - // Block 0x42, offset 0x1080 - 0x1080: 0xe00d, 0x1081: 0x0008, 0x1082: 0xe00d, 0x1083: 0x0008, 0x1084: 0xe00d, 0x1085: 0x0008, - 0x1086: 0xe00d, 0x1087: 0x0008, 0x1088: 0xe00d, 0x1089: 0x0008, 0x108a: 0xe00d, 0x108b: 0x0008, - 0x108c: 0xe00d, 0x108d: 0x0008, 0x108e: 0xe00d, 0x108f: 0x0008, 0x1090: 0xe00d, 0x1091: 0x0008, - 0x1092: 0xe00d, 0x1093: 0x0008, 0x1094: 0xe00d, 0x1095: 0x0008, 0x1096: 0xe00d, 0x1097: 0x0008, - 0x1098: 0xe00d, 0x1099: 0x0008, 0x109a: 0xe00d, 0x109b: 0x0008, 0x109c: 0xe00d, 0x109d: 0x0008, - 0x109e: 0xe00d, 0x109f: 0x0008, 0x10a0: 0xe00d, 0x10a1: 0x0008, 0x10a2: 0xe00d, 0x10a3: 0x0008, - 0x10a4: 0xe00d, 0x10a5: 0x0008, 0x10a6: 0xe00d, 0x10a7: 0x0008, 0x10a8: 0xe00d, 0x10a9: 0x0008, - 0x10aa: 0xe00d, 0x10ab: 0x0008, 0x10ac: 0xe00d, 0x10ad: 0x0008, 0x10ae: 0x0008, 0x10af: 0x1308, - 0x10b0: 0x1318, 0x10b1: 0x1318, 0x10b2: 0x1318, 0x10b3: 0x0018, 0x10b4: 0x1308, 0x10b5: 0x1308, - 0x10b6: 0x1308, 0x10b7: 0x1308, 0x10b8: 0x1308, 0x10b9: 0x1308, 0x10ba: 0x1308, 0x10bb: 0x1308, - 0x10bc: 0x1308, 0x10bd: 0x1308, 0x10be: 0x0018, 0x10bf: 0x0008, - // Block 0x43, offset 0x10c0 - 0x10c0: 0xe00d, 0x10c1: 0x0008, 0x10c2: 0xe00d, 0x10c3: 0x0008, 0x10c4: 0xe00d, 0x10c5: 0x0008, - 0x10c6: 0xe00d, 0x10c7: 0x0008, 0x10c8: 0xe00d, 0x10c9: 0x0008, 0x10ca: 0xe00d, 0x10cb: 0x0008, - 0x10cc: 0xe00d, 0x10cd: 0x0008, 0x10ce: 0xe00d, 0x10cf: 0x0008, 0x10d0: 0xe00d, 0x10d1: 0x0008, - 0x10d2: 0xe00d, 0x10d3: 0x0008, 0x10d4: 0xe00d, 0x10d5: 0x0008, 0x10d6: 0xe00d, 0x10d7: 0x0008, - 0x10d8: 0xe00d, 0x10d9: 0x0008, 0x10da: 0xe00d, 0x10db: 0x0008, 0x10dc: 0x0ea1, 0x10dd: 0x6e11, - 0x10de: 0x1308, 0x10df: 0x1308, 0x10e0: 0x0008, 0x10e1: 0x0008, 0x10e2: 0x0008, 0x10e3: 0x0008, - 0x10e4: 0x0008, 0x10e5: 0x0008, 0x10e6: 0x0008, 0x10e7: 0x0008, 0x10e8: 0x0008, 0x10e9: 0x0008, - 0x10ea: 0x0008, 0x10eb: 0x0008, 0x10ec: 0x0008, 0x10ed: 0x0008, 0x10ee: 0x0008, 0x10ef: 0x0008, - 0x10f0: 0x0008, 0x10f1: 0x0008, 0x10f2: 0x0008, 0x10f3: 0x0008, 0x10f4: 0x0008, 0x10f5: 0x0008, - 0x10f6: 0x0008, 0x10f7: 0x0008, 0x10f8: 0x0008, 0x10f9: 0x0008, 0x10fa: 0x0008, 0x10fb: 0x0008, - 0x10fc: 0x0008, 0x10fd: 0x0008, 0x10fe: 0x0008, 0x10ff: 0x0008, - // Block 0x44, offset 0x1100 - 0x1100: 0x0018, 0x1101: 0x0018, 0x1102: 0x0018, 0x1103: 0x0018, 0x1104: 0x0018, 0x1105: 0x0018, - 0x1106: 0x0018, 0x1107: 0x0018, 0x1108: 0x0018, 0x1109: 0x0018, 0x110a: 0x0018, 0x110b: 0x0018, - 0x110c: 0x0018, 0x110d: 0x0018, 0x110e: 0x0018, 0x110f: 0x0018, 0x1110: 0x0018, 0x1111: 0x0018, - 0x1112: 0x0018, 0x1113: 0x0018, 0x1114: 0x0018, 0x1115: 0x0018, 0x1116: 0x0018, 0x1117: 0x0008, - 0x1118: 0x0008, 0x1119: 0x0008, 0x111a: 0x0008, 0x111b: 0x0008, 0x111c: 0x0008, 0x111d: 0x0008, - 0x111e: 0x0008, 0x111f: 0x0008, 0x1120: 0x0018, 0x1121: 0x0018, 0x1122: 0xe00d, 0x1123: 0x0008, - 0x1124: 0xe00d, 0x1125: 0x0008, 0x1126: 0xe00d, 0x1127: 0x0008, 0x1128: 0xe00d, 0x1129: 0x0008, - 0x112a: 0xe00d, 0x112b: 0x0008, 0x112c: 0xe00d, 0x112d: 0x0008, 0x112e: 0xe00d, 0x112f: 0x0008, - 0x1130: 0x0008, 0x1131: 0x0008, 0x1132: 0xe00d, 0x1133: 0x0008, 0x1134: 0xe00d, 0x1135: 0x0008, - 0x1136: 0xe00d, 0x1137: 0x0008, 0x1138: 0xe00d, 0x1139: 0x0008, 0x113a: 0xe00d, 0x113b: 0x0008, - 0x113c: 0xe00d, 0x113d: 0x0008, 0x113e: 0xe00d, 0x113f: 0x0008, - // Block 0x45, offset 0x1140 - 0x1140: 0xe00d, 0x1141: 0x0008, 0x1142: 0xe00d, 0x1143: 0x0008, 0x1144: 0xe00d, 0x1145: 0x0008, - 0x1146: 0xe00d, 0x1147: 0x0008, 0x1148: 0xe00d, 0x1149: 0x0008, 0x114a: 0xe00d, 0x114b: 0x0008, - 0x114c: 0xe00d, 0x114d: 0x0008, 0x114e: 0xe00d, 0x114f: 0x0008, 0x1150: 0xe00d, 0x1151: 0x0008, - 0x1152: 0xe00d, 0x1153: 0x0008, 0x1154: 0xe00d, 0x1155: 0x0008, 0x1156: 0xe00d, 0x1157: 0x0008, - 0x1158: 0xe00d, 0x1159: 0x0008, 0x115a: 0xe00d, 0x115b: 0x0008, 0x115c: 0xe00d, 0x115d: 0x0008, - 0x115e: 0xe00d, 0x115f: 0x0008, 0x1160: 0xe00d, 0x1161: 0x0008, 0x1162: 0xe00d, 0x1163: 0x0008, - 0x1164: 0xe00d, 0x1165: 0x0008, 0x1166: 0xe00d, 0x1167: 0x0008, 0x1168: 0xe00d, 0x1169: 0x0008, - 0x116a: 0xe00d, 0x116b: 0x0008, 0x116c: 0xe00d, 0x116d: 0x0008, 0x116e: 0xe00d, 0x116f: 0x0008, - 0x1170: 0xe0fd, 0x1171: 0x0008, 0x1172: 0x0008, 0x1173: 0x0008, 0x1174: 0x0008, 0x1175: 0x0008, - 0x1176: 0x0008, 0x1177: 0x0008, 0x1178: 0x0008, 0x1179: 0xe01d, 0x117a: 0x0008, 0x117b: 0xe03d, - 0x117c: 0x0008, 0x117d: 0x442d, 0x117e: 0xe00d, 0x117f: 0x0008, - // Block 0x46, offset 0x1180 - 0x1180: 0xe00d, 0x1181: 0x0008, 0x1182: 0xe00d, 0x1183: 0x0008, 0x1184: 0xe00d, 0x1185: 0x0008, - 0x1186: 0xe00d, 0x1187: 0x0008, 0x1188: 0x0008, 0x1189: 0x0018, 0x118a: 0x0018, 0x118b: 0xe03d, - 0x118c: 0x0008, 0x118d: 0x11d9, 0x118e: 0x0008, 0x118f: 0x0008, 0x1190: 0xe00d, 0x1191: 0x0008, - 0x1192: 0xe00d, 0x1193: 0x0008, 0x1194: 0x0008, 0x1195: 0x0008, 0x1196: 0xe00d, 0x1197: 0x0008, - 0x1198: 0xe00d, 0x1199: 0x0008, 0x119a: 0xe00d, 0x119b: 0x0008, 0x119c: 0xe00d, 0x119d: 0x0008, - 0x119e: 0xe00d, 0x119f: 0x0008, 0x11a0: 0xe00d, 0x11a1: 0x0008, 0x11a2: 0xe00d, 0x11a3: 0x0008, - 0x11a4: 0xe00d, 0x11a5: 0x0008, 0x11a6: 0xe00d, 0x11a7: 0x0008, 0x11a8: 0xe00d, 0x11a9: 0x0008, - 0x11aa: 0x6e29, 0x11ab: 0x1029, 0x11ac: 0x11c1, 0x11ad: 0x6e41, 0x11ae: 0x1221, 0x11af: 0x0040, - 0x11b0: 0x6e59, 0x11b1: 0x6e71, 0x11b2: 0x1239, 0x11b3: 0x444d, 0x11b4: 0xe00d, 0x11b5: 0x0008, - 0x11b6: 0xe00d, 0x11b7: 0x0008, 0x11b8: 0x0040, 0x11b9: 0x0040, 0x11ba: 0x0040, 0x11bb: 0x0040, - 0x11bc: 0x0040, 0x11bd: 0x0040, 0x11be: 0x0040, 0x11bf: 0x0040, - // Block 0x47, offset 0x11c0 - 0x11c0: 0x64d5, 0x11c1: 0x64f5, 0x11c2: 0x6515, 0x11c3: 0x6535, 0x11c4: 0x6555, 0x11c5: 0x6575, - 0x11c6: 0x6595, 0x11c7: 0x65b5, 0x11c8: 0x65d5, 0x11c9: 0x65f5, 0x11ca: 0x6615, 0x11cb: 0x6635, - 0x11cc: 0x6655, 0x11cd: 0x6675, 0x11ce: 0x0008, 0x11cf: 0x0008, 0x11d0: 0x6695, 0x11d1: 0x0008, - 0x11d2: 0x66b5, 0x11d3: 0x0008, 0x11d4: 0x0008, 0x11d5: 0x66d5, 0x11d6: 0x66f5, 0x11d7: 0x6715, - 0x11d8: 0x6735, 0x11d9: 0x6755, 0x11da: 0x6775, 0x11db: 0x6795, 0x11dc: 0x67b5, 0x11dd: 0x67d5, - 0x11de: 0x67f5, 0x11df: 0x0008, 0x11e0: 0x6815, 0x11e1: 0x0008, 0x11e2: 0x6835, 0x11e3: 0x0008, - 0x11e4: 0x0008, 0x11e5: 0x6855, 0x11e6: 0x6875, 0x11e7: 0x0008, 0x11e8: 0x0008, 0x11e9: 0x0008, - 0x11ea: 0x6895, 0x11eb: 0x68b5, 0x11ec: 0x68d5, 0x11ed: 0x68f5, 0x11ee: 0x6915, 0x11ef: 0x6935, - 0x11f0: 0x6955, 0x11f1: 0x6975, 0x11f2: 0x6995, 0x11f3: 0x69b5, 0x11f4: 0x69d5, 0x11f5: 0x69f5, - 0x11f6: 0x6a15, 0x11f7: 0x6a35, 0x11f8: 0x6a55, 0x11f9: 0x6a75, 0x11fa: 0x6a95, 0x11fb: 0x6ab5, - 0x11fc: 0x6ad5, 0x11fd: 0x6af5, 0x11fe: 0x6b15, 0x11ff: 0x6b35, - // Block 0x48, offset 0x1200 - 0x1200: 0x7a95, 0x1201: 0x7ab5, 0x1202: 0x7ad5, 0x1203: 0x7af5, 0x1204: 0x7b15, 0x1205: 0x7b35, - 0x1206: 0x7b55, 0x1207: 0x7b75, 0x1208: 0x7b95, 0x1209: 0x7bb5, 0x120a: 0x7bd5, 0x120b: 0x7bf5, - 0x120c: 0x7c15, 0x120d: 0x7c35, 0x120e: 0x7c55, 0x120f: 0x6ec9, 0x1210: 0x6ef1, 0x1211: 0x6f19, - 0x1212: 0x7c75, 0x1213: 0x7c95, 0x1214: 0x7cb5, 0x1215: 0x6f41, 0x1216: 0x6f69, 0x1217: 0x6f91, - 0x1218: 0x7cd5, 0x1219: 0x7cf5, 0x121a: 0x0040, 0x121b: 0x0040, 0x121c: 0x0040, 0x121d: 0x0040, - 0x121e: 0x0040, 0x121f: 0x0040, 0x1220: 0x0040, 0x1221: 0x0040, 0x1222: 0x0040, 0x1223: 0x0040, - 0x1224: 0x0040, 0x1225: 0x0040, 0x1226: 0x0040, 0x1227: 0x0040, 0x1228: 0x0040, 0x1229: 0x0040, - 0x122a: 0x0040, 0x122b: 0x0040, 0x122c: 0x0040, 0x122d: 0x0040, 0x122e: 0x0040, 0x122f: 0x0040, - 0x1230: 0x0040, 0x1231: 0x0040, 0x1232: 0x0040, 0x1233: 0x0040, 0x1234: 0x0040, 0x1235: 0x0040, - 0x1236: 0x0040, 0x1237: 0x0040, 0x1238: 0x0040, 0x1239: 0x0040, 0x123a: 0x0040, 0x123b: 0x0040, - 0x123c: 0x0040, 0x123d: 0x0040, 0x123e: 0x0040, 0x123f: 0x0040, - // Block 0x49, offset 0x1240 - 0x1240: 0x6fb9, 0x1241: 0x6fd1, 0x1242: 0x6fe9, 0x1243: 0x7d15, 0x1244: 0x7d35, 0x1245: 0x7001, - 0x1246: 0x7001, 0x1247: 0x0040, 0x1248: 0x0040, 0x1249: 0x0040, 0x124a: 0x0040, 0x124b: 0x0040, - 0x124c: 0x0040, 0x124d: 0x0040, 0x124e: 0x0040, 0x124f: 0x0040, 0x1250: 0x0040, 0x1251: 0x0040, - 0x1252: 0x0040, 0x1253: 0x7019, 0x1254: 0x7041, 0x1255: 0x7069, 0x1256: 0x7091, 0x1257: 0x70b9, - 0x1258: 0x0040, 0x1259: 0x0040, 0x125a: 0x0040, 0x125b: 0x0040, 0x125c: 0x0040, 0x125d: 0x70e1, - 0x125e: 0x1308, 0x125f: 0x7109, 0x1260: 0x7131, 0x1261: 0x20a9, 0x1262: 0x20f1, 0x1263: 0x7149, - 0x1264: 0x7161, 0x1265: 0x7179, 0x1266: 0x7191, 0x1267: 0x71a9, 0x1268: 0x71c1, 0x1269: 0x1fb2, - 0x126a: 0x71d9, 0x126b: 0x7201, 0x126c: 0x7229, 0x126d: 0x7261, 0x126e: 0x7299, 0x126f: 0x72c1, - 0x1270: 0x72e9, 0x1271: 0x7311, 0x1272: 0x7339, 0x1273: 0x7361, 0x1274: 0x7389, 0x1275: 0x73b1, - 0x1276: 0x73d9, 0x1277: 0x0040, 0x1278: 0x7401, 0x1279: 0x7429, 0x127a: 0x7451, 0x127b: 0x7479, - 0x127c: 0x74a1, 0x127d: 0x0040, 0x127e: 0x74c9, 0x127f: 0x0040, - // Block 0x4a, offset 0x1280 - 0x1280: 0x74f1, 0x1281: 0x7519, 0x1282: 0x0040, 0x1283: 0x7541, 0x1284: 0x7569, 0x1285: 0x0040, - 0x1286: 0x7591, 0x1287: 0x75b9, 0x1288: 0x75e1, 0x1289: 0x7609, 0x128a: 0x7631, 0x128b: 0x7659, - 0x128c: 0x7681, 0x128d: 0x76a9, 0x128e: 0x76d1, 0x128f: 0x76f9, 0x1290: 0x7721, 0x1291: 0x7721, - 0x1292: 0x7739, 0x1293: 0x7739, 0x1294: 0x7739, 0x1295: 0x7739, 0x1296: 0x7751, 0x1297: 0x7751, - 0x1298: 0x7751, 0x1299: 0x7751, 0x129a: 0x7769, 0x129b: 0x7769, 0x129c: 0x7769, 0x129d: 0x7769, - 0x129e: 0x7781, 0x129f: 0x7781, 0x12a0: 0x7781, 0x12a1: 0x7781, 0x12a2: 0x7799, 0x12a3: 0x7799, - 0x12a4: 0x7799, 0x12a5: 0x7799, 0x12a6: 0x77b1, 0x12a7: 0x77b1, 0x12a8: 0x77b1, 0x12a9: 0x77b1, - 0x12aa: 0x77c9, 0x12ab: 0x77c9, 0x12ac: 0x77c9, 0x12ad: 0x77c9, 0x12ae: 0x77e1, 0x12af: 0x77e1, - 0x12b0: 0x77e1, 0x12b1: 0x77e1, 0x12b2: 0x77f9, 0x12b3: 0x77f9, 0x12b4: 0x77f9, 0x12b5: 0x77f9, - 0x12b6: 0x7811, 0x12b7: 0x7811, 0x12b8: 0x7811, 0x12b9: 0x7811, 0x12ba: 0x7829, 0x12bb: 0x7829, - 0x12bc: 0x7829, 0x12bd: 0x7829, 0x12be: 0x7841, 0x12bf: 0x7841, - // Block 0x4b, offset 0x12c0 - 0x12c0: 0x7841, 0x12c1: 0x7841, 0x12c2: 0x7859, 0x12c3: 0x7859, 0x12c4: 0x7871, 0x12c5: 0x7871, - 0x12c6: 0x7889, 0x12c7: 0x7889, 0x12c8: 0x78a1, 0x12c9: 0x78a1, 0x12ca: 0x78b9, 0x12cb: 0x78b9, - 0x12cc: 0x78d1, 0x12cd: 0x78d1, 0x12ce: 0x78e9, 0x12cf: 0x78e9, 0x12d0: 0x78e9, 0x12d1: 0x78e9, - 0x12d2: 0x7901, 0x12d3: 0x7901, 0x12d4: 0x7901, 0x12d5: 0x7901, 0x12d6: 0x7919, 0x12d7: 0x7919, - 0x12d8: 0x7919, 0x12d9: 0x7919, 0x12da: 0x7931, 0x12db: 0x7931, 0x12dc: 0x7931, 0x12dd: 0x7931, - 0x12de: 0x7949, 0x12df: 0x7949, 0x12e0: 0x7961, 0x12e1: 0x7961, 0x12e2: 0x7961, 0x12e3: 0x7961, - 0x12e4: 0x7979, 0x12e5: 0x7979, 0x12e6: 0x7991, 0x12e7: 0x7991, 0x12e8: 0x7991, 0x12e9: 0x7991, - 0x12ea: 0x79a9, 0x12eb: 0x79a9, 0x12ec: 0x79a9, 0x12ed: 0x79a9, 0x12ee: 0x79c1, 0x12ef: 0x79c1, - 0x12f0: 0x79d9, 0x12f1: 0x79d9, 0x12f2: 0x0018, 0x12f3: 0x0018, 0x12f4: 0x0018, 0x12f5: 0x0018, - 0x12f6: 0x0018, 0x12f7: 0x0018, 0x12f8: 0x0018, 0x12f9: 0x0018, 0x12fa: 0x0018, 0x12fb: 0x0018, - 0x12fc: 0x0018, 0x12fd: 0x0018, 0x12fe: 0x0018, 0x12ff: 0x0018, - // Block 0x4c, offset 0x1300 - 0x1300: 0x0018, 0x1301: 0x0018, 0x1302: 0x0040, 0x1303: 0x0040, 0x1304: 0x0040, 0x1305: 0x0040, - 0x1306: 0x0040, 0x1307: 0x0040, 0x1308: 0x0040, 0x1309: 0x0040, 0x130a: 0x0040, 0x130b: 0x0040, - 0x130c: 0x0040, 0x130d: 0x0040, 0x130e: 0x0040, 0x130f: 0x0040, 0x1310: 0x0040, 0x1311: 0x0040, - 0x1312: 0x0040, 0x1313: 0x79f1, 0x1314: 0x79f1, 0x1315: 0x79f1, 0x1316: 0x79f1, 0x1317: 0x7a09, - 0x1318: 0x7a09, 0x1319: 0x7a21, 0x131a: 0x7a21, 0x131b: 0x7a39, 0x131c: 0x7a39, 0x131d: 0x0479, - 0x131e: 0x7a51, 0x131f: 0x7a51, 0x1320: 0x7a69, 0x1321: 0x7a69, 0x1322: 0x7a81, 0x1323: 0x7a81, - 0x1324: 0x7a99, 0x1325: 0x7a99, 0x1326: 0x7a99, 0x1327: 0x7a99, 0x1328: 0x7ab1, 0x1329: 0x7ab1, - 0x132a: 0x7ac9, 0x132b: 0x7ac9, 0x132c: 0x7af1, 0x132d: 0x7af1, 0x132e: 0x7b19, 0x132f: 0x7b19, - 0x1330: 0x7b41, 0x1331: 0x7b41, 0x1332: 0x7b69, 0x1333: 0x7b69, 0x1334: 0x7b91, 0x1335: 0x7b91, - 0x1336: 0x7bb9, 0x1337: 0x7bb9, 0x1338: 0x7bb9, 0x1339: 0x7be1, 0x133a: 0x7be1, 0x133b: 0x7be1, - 0x133c: 0x7c09, 0x133d: 0x7c09, 0x133e: 0x7c09, 0x133f: 0x7c09, - // Block 0x4d, offset 0x1340 - 0x1340: 0x85f9, 0x1341: 0x8621, 0x1342: 0x8649, 0x1343: 0x8671, 0x1344: 0x8699, 0x1345: 0x86c1, - 0x1346: 0x86e9, 0x1347: 0x8711, 0x1348: 0x8739, 0x1349: 0x8761, 0x134a: 0x8789, 0x134b: 0x87b1, - 0x134c: 0x87d9, 0x134d: 0x8801, 0x134e: 0x8829, 0x134f: 0x8851, 0x1350: 0x8879, 0x1351: 0x88a1, - 0x1352: 0x88c9, 0x1353: 0x88f1, 0x1354: 0x8919, 0x1355: 0x8941, 0x1356: 0x8969, 0x1357: 0x8991, - 0x1358: 0x89b9, 0x1359: 0x89e1, 0x135a: 0x8a09, 0x135b: 0x8a31, 0x135c: 0x8a59, 0x135d: 0x8a81, - 0x135e: 0x8aaa, 0x135f: 0x8ada, 0x1360: 0x8b0a, 0x1361: 0x8b3a, 0x1362: 0x8b6a, 0x1363: 0x8b9a, - 0x1364: 0x8bc9, 0x1365: 0x8bf1, 0x1366: 0x7c71, 0x1367: 0x8c19, 0x1368: 0x7be1, 0x1369: 0x7c99, - 0x136a: 0x8c41, 0x136b: 0x8c69, 0x136c: 0x7d39, 0x136d: 0x8c91, 0x136e: 0x7d61, 0x136f: 0x7d89, - 0x1370: 0x8cb9, 0x1371: 0x8ce1, 0x1372: 0x7e29, 0x1373: 0x8d09, 0x1374: 0x7e51, 0x1375: 0x7e79, - 0x1376: 0x8d31, 0x1377: 0x8d59, 0x1378: 0x7ec9, 0x1379: 0x8d81, 0x137a: 0x7ef1, 0x137b: 0x7f19, - 0x137c: 0x83a1, 0x137d: 0x83c9, 0x137e: 0x8441, 0x137f: 0x8469, - // Block 0x4e, offset 0x1380 - 0x1380: 0x8491, 0x1381: 0x8531, 0x1382: 0x8559, 0x1383: 0x8581, 0x1384: 0x85a9, 0x1385: 0x8649, - 0x1386: 0x8671, 0x1387: 0x8699, 0x1388: 0x8da9, 0x1389: 0x8739, 0x138a: 0x8dd1, 0x138b: 0x8df9, - 0x138c: 0x8829, 0x138d: 0x8e21, 0x138e: 0x8851, 0x138f: 0x8879, 0x1390: 0x8a81, 0x1391: 0x8e49, - 0x1392: 0x8e71, 0x1393: 0x89b9, 0x1394: 0x8e99, 0x1395: 0x89e1, 0x1396: 0x8a09, 0x1397: 0x7c21, - 0x1398: 0x7c49, 0x1399: 0x8ec1, 0x139a: 0x7c71, 0x139b: 0x8ee9, 0x139c: 0x7cc1, 0x139d: 0x7ce9, - 0x139e: 0x7d11, 0x139f: 0x7d39, 0x13a0: 0x8f11, 0x13a1: 0x7db1, 0x13a2: 0x7dd9, 0x13a3: 0x7e01, - 0x13a4: 0x7e29, 0x13a5: 0x8f39, 0x13a6: 0x7ec9, 0x13a7: 0x7f41, 0x13a8: 0x7f69, 0x13a9: 0x7f91, - 0x13aa: 0x7fb9, 0x13ab: 0x7fe1, 0x13ac: 0x8031, 0x13ad: 0x8059, 0x13ae: 0x8081, 0x13af: 0x80a9, - 0x13b0: 0x80d1, 0x13b1: 0x80f9, 0x13b2: 0x8f61, 0x13b3: 0x8121, 0x13b4: 0x8149, 0x13b5: 0x8171, - 0x13b6: 0x8199, 0x13b7: 0x81c1, 0x13b8: 0x81e9, 0x13b9: 0x8239, 0x13ba: 0x8261, 0x13bb: 0x8289, - 0x13bc: 0x82b1, 0x13bd: 0x82d9, 0x13be: 0x8301, 0x13bf: 0x8329, - // Block 0x4f, offset 0x13c0 - 0x13c0: 0x8351, 0x13c1: 0x8379, 0x13c2: 0x83f1, 0x13c3: 0x8419, 0x13c4: 0x84b9, 0x13c5: 0x84e1, - 0x13c6: 0x8509, 0x13c7: 0x8531, 0x13c8: 0x8559, 0x13c9: 0x85d1, 0x13ca: 0x85f9, 0x13cb: 0x8621, - 0x13cc: 0x8649, 0x13cd: 0x8f89, 0x13ce: 0x86c1, 0x13cf: 0x86e9, 0x13d0: 0x8711, 0x13d1: 0x8739, - 0x13d2: 0x87b1, 0x13d3: 0x87d9, 0x13d4: 0x8801, 0x13d5: 0x8829, 0x13d6: 0x8fb1, 0x13d7: 0x88a1, - 0x13d8: 0x88c9, 0x13d9: 0x8fd9, 0x13da: 0x8941, 0x13db: 0x8969, 0x13dc: 0x8991, 0x13dd: 0x89b9, - 0x13de: 0x9001, 0x13df: 0x7c71, 0x13e0: 0x8ee9, 0x13e1: 0x7d39, 0x13e2: 0x8f11, 0x13e3: 0x7e29, - 0x13e4: 0x8f39, 0x13e5: 0x7ec9, 0x13e6: 0x9029, 0x13e7: 0x80d1, 0x13e8: 0x9051, 0x13e9: 0x9079, - 0x13ea: 0x90a1, 0x13eb: 0x8531, 0x13ec: 0x8559, 0x13ed: 0x8649, 0x13ee: 0x8829, 0x13ef: 0x8fb1, - 0x13f0: 0x89b9, 0x13f1: 0x9001, 0x13f2: 0x90c9, 0x13f3: 0x9101, 0x13f4: 0x9139, 0x13f5: 0x9171, - 0x13f6: 0x9199, 0x13f7: 0x91c1, 0x13f8: 0x91e9, 0x13f9: 0x9211, 0x13fa: 0x9239, 0x13fb: 0x9261, - 0x13fc: 0x9289, 0x13fd: 0x92b1, 0x13fe: 0x92d9, 0x13ff: 0x9301, - // Block 0x50, offset 0x1400 - 0x1400: 0x9329, 0x1401: 0x9351, 0x1402: 0x9379, 0x1403: 0x93a1, 0x1404: 0x93c9, 0x1405: 0x93f1, - 0x1406: 0x9419, 0x1407: 0x9441, 0x1408: 0x9469, 0x1409: 0x9491, 0x140a: 0x94b9, 0x140b: 0x94e1, - 0x140c: 0x9079, 0x140d: 0x9509, 0x140e: 0x9531, 0x140f: 0x9559, 0x1410: 0x9581, 0x1411: 0x9171, - 0x1412: 0x9199, 0x1413: 0x91c1, 0x1414: 0x91e9, 0x1415: 0x9211, 0x1416: 0x9239, 0x1417: 0x9261, - 0x1418: 0x9289, 0x1419: 0x92b1, 0x141a: 0x92d9, 0x141b: 0x9301, 0x141c: 0x9329, 0x141d: 0x9351, - 0x141e: 0x9379, 0x141f: 0x93a1, 0x1420: 0x93c9, 0x1421: 0x93f1, 0x1422: 0x9419, 0x1423: 0x9441, - 0x1424: 0x9469, 0x1425: 0x9491, 0x1426: 0x94b9, 0x1427: 0x94e1, 0x1428: 0x9079, 0x1429: 0x9509, - 0x142a: 0x9531, 0x142b: 0x9559, 0x142c: 0x9581, 0x142d: 0x9491, 0x142e: 0x94b9, 0x142f: 0x94e1, - 0x1430: 0x9079, 0x1431: 0x9051, 0x1432: 0x90a1, 0x1433: 0x8211, 0x1434: 0x8059, 0x1435: 0x8081, - 0x1436: 0x80a9, 0x1437: 0x9491, 0x1438: 0x94b9, 0x1439: 0x94e1, 0x143a: 0x8211, 0x143b: 0x8239, - 0x143c: 0x95a9, 0x143d: 0x95a9, 0x143e: 0x0018, 0x143f: 0x0018, - // Block 0x51, offset 0x1440 - 0x1440: 0x0040, 0x1441: 0x0040, 0x1442: 0x0040, 0x1443: 0x0040, 0x1444: 0x0040, 0x1445: 0x0040, - 0x1446: 0x0040, 0x1447: 0x0040, 0x1448: 0x0040, 0x1449: 0x0040, 0x144a: 0x0040, 0x144b: 0x0040, - 0x144c: 0x0040, 0x144d: 0x0040, 0x144e: 0x0040, 0x144f: 0x0040, 0x1450: 0x95d1, 0x1451: 0x9609, - 0x1452: 0x9609, 0x1453: 0x9641, 0x1454: 0x9679, 0x1455: 0x96b1, 0x1456: 0x96e9, 0x1457: 0x9721, - 0x1458: 0x9759, 0x1459: 0x9759, 0x145a: 0x9791, 0x145b: 0x97c9, 0x145c: 0x9801, 0x145d: 0x9839, - 0x145e: 0x9871, 0x145f: 0x98a9, 0x1460: 0x98a9, 0x1461: 0x98e1, 0x1462: 0x9919, 0x1463: 0x9919, - 0x1464: 0x9951, 0x1465: 0x9951, 0x1466: 0x9989, 0x1467: 0x99c1, 0x1468: 0x99c1, 0x1469: 0x99f9, - 0x146a: 0x9a31, 0x146b: 0x9a31, 0x146c: 0x9a69, 0x146d: 0x9a69, 0x146e: 0x9aa1, 0x146f: 0x9ad9, - 0x1470: 0x9ad9, 0x1471: 0x9b11, 0x1472: 0x9b11, 0x1473: 0x9b49, 0x1474: 0x9b81, 0x1475: 0x9bb9, - 0x1476: 0x9bf1, 0x1477: 0x9bf1, 0x1478: 0x9c29, 0x1479: 0x9c61, 0x147a: 0x9c99, 0x147b: 0x9cd1, - 0x147c: 0x9d09, 0x147d: 0x9d09, 0x147e: 0x9d41, 0x147f: 0x9d79, - // Block 0x52, offset 0x1480 - 0x1480: 0xa949, 0x1481: 0xa981, 0x1482: 0xa9b9, 0x1483: 0xa8a1, 0x1484: 0x9bb9, 0x1485: 0x9989, - 0x1486: 0xa9f1, 0x1487: 0xaa29, 0x1488: 0x0040, 0x1489: 0x0040, 0x148a: 0x0040, 0x148b: 0x0040, - 0x148c: 0x0040, 0x148d: 0x0040, 0x148e: 0x0040, 0x148f: 0x0040, 0x1490: 0x0040, 0x1491: 0x0040, - 0x1492: 0x0040, 0x1493: 0x0040, 0x1494: 0x0040, 0x1495: 0x0040, 0x1496: 0x0040, 0x1497: 0x0040, - 0x1498: 0x0040, 0x1499: 0x0040, 0x149a: 0x0040, 0x149b: 0x0040, 0x149c: 0x0040, 0x149d: 0x0040, - 0x149e: 0x0040, 0x149f: 0x0040, 0x14a0: 0x0040, 0x14a1: 0x0040, 0x14a2: 0x0040, 0x14a3: 0x0040, - 0x14a4: 0x0040, 0x14a5: 0x0040, 0x14a6: 0x0040, 0x14a7: 0x0040, 0x14a8: 0x0040, 0x14a9: 0x0040, - 0x14aa: 0x0040, 0x14ab: 0x0040, 0x14ac: 0x0040, 0x14ad: 0x0040, 0x14ae: 0x0040, 0x14af: 0x0040, - 0x14b0: 0xaa61, 0x14b1: 0xaa99, 0x14b2: 0xaad1, 0x14b3: 0xab19, 0x14b4: 0xab61, 0x14b5: 0xaba9, - 0x14b6: 0xabf1, 0x14b7: 0xac39, 0x14b8: 0xac81, 0x14b9: 0xacc9, 0x14ba: 0xad02, 0x14bb: 0xae12, - 0x14bc: 0xae91, 0x14bd: 0x0018, 0x14be: 0x0040, 0x14bf: 0x0040, - // Block 0x53, offset 0x14c0 - 0x14c0: 0x13c0, 0x14c1: 0x13c0, 0x14c2: 0x13c0, 0x14c3: 0x13c0, 0x14c4: 0x13c0, 0x14c5: 0x13c0, - 0x14c6: 0x13c0, 0x14c7: 0x13c0, 0x14c8: 0x13c0, 0x14c9: 0x13c0, 0x14ca: 0x13c0, 0x14cb: 0x13c0, - 0x14cc: 0x13c0, 0x14cd: 0x13c0, 0x14ce: 0x13c0, 0x14cf: 0x13c0, 0x14d0: 0xaeda, 0x14d1: 0x7d55, - 0x14d2: 0x0040, 0x14d3: 0xaeea, 0x14d4: 0x03c2, 0x14d5: 0xaefa, 0x14d6: 0xaf0a, 0x14d7: 0x7d75, - 0x14d8: 0x7d95, 0x14d9: 0x0040, 0x14da: 0x0040, 0x14db: 0x0040, 0x14dc: 0x0040, 0x14dd: 0x0040, - 0x14de: 0x0040, 0x14df: 0x0040, 0x14e0: 0x1308, 0x14e1: 0x1308, 0x14e2: 0x1308, 0x14e3: 0x1308, - 0x14e4: 0x1308, 0x14e5: 0x1308, 0x14e6: 0x1308, 0x14e7: 0x1308, 0x14e8: 0x1308, 0x14e9: 0x1308, - 0x14ea: 0x1308, 0x14eb: 0x1308, 0x14ec: 0x1308, 0x14ed: 0x1308, 0x14ee: 0x1308, 0x14ef: 0x1308, - 0x14f0: 0x0040, 0x14f1: 0x7db5, 0x14f2: 0x7dd5, 0x14f3: 0xaf1a, 0x14f4: 0xaf1a, 0x14f5: 0x1fd2, - 0x14f6: 0x1fe2, 0x14f7: 0xaf2a, 0x14f8: 0xaf3a, 0x14f9: 0x7df5, 0x14fa: 0x7e15, 0x14fb: 0x7e35, - 0x14fc: 0x7df5, 0x14fd: 0x7e55, 0x14fe: 0x7e75, 0x14ff: 0x7e55, - // Block 0x54, offset 0x1500 - 0x1500: 0x7e95, 0x1501: 0x7eb5, 0x1502: 0x7ed5, 0x1503: 0x7eb5, 0x1504: 0x7ef5, 0x1505: 0x0018, - 0x1506: 0x0018, 0x1507: 0xaf4a, 0x1508: 0xaf5a, 0x1509: 0x7f16, 0x150a: 0x7f36, 0x150b: 0x7f56, - 0x150c: 0x7f76, 0x150d: 0xaf1a, 0x150e: 0xaf1a, 0x150f: 0xaf1a, 0x1510: 0xaeda, 0x1511: 0x7f95, - 0x1512: 0x0040, 0x1513: 0x0040, 0x1514: 0x03c2, 0x1515: 0xaeea, 0x1516: 0xaf0a, 0x1517: 0xaefa, - 0x1518: 0x7fb5, 0x1519: 0x1fd2, 0x151a: 0x1fe2, 0x151b: 0xaf2a, 0x151c: 0xaf3a, 0x151d: 0x7e95, - 0x151e: 0x7ef5, 0x151f: 0xaf6a, 0x1520: 0xaf7a, 0x1521: 0xaf8a, 0x1522: 0x1fb2, 0x1523: 0xaf99, - 0x1524: 0xafaa, 0x1525: 0xafba, 0x1526: 0x1fc2, 0x1527: 0x0040, 0x1528: 0xafca, 0x1529: 0xafda, - 0x152a: 0xafea, 0x152b: 0xaffa, 0x152c: 0x0040, 0x152d: 0x0040, 0x152e: 0x0040, 0x152f: 0x0040, - 0x1530: 0x7fd6, 0x1531: 0xb009, 0x1532: 0x7ff6, 0x1533: 0x0008, 0x1534: 0x8016, 0x1535: 0x0040, - 0x1536: 0x8036, 0x1537: 0xb031, 0x1538: 0x8056, 0x1539: 0xb059, 0x153a: 0x8076, 0x153b: 0xb081, - 0x153c: 0x8096, 0x153d: 0xb0a9, 0x153e: 0x80b6, 0x153f: 0xb0d1, - // Block 0x55, offset 0x1540 - 0x1540: 0xb0f9, 0x1541: 0xb111, 0x1542: 0xb111, 0x1543: 0xb129, 0x1544: 0xb129, 0x1545: 0xb141, - 0x1546: 0xb141, 0x1547: 0xb159, 0x1548: 0xb159, 0x1549: 0xb171, 0x154a: 0xb171, 0x154b: 0xb171, - 0x154c: 0xb171, 0x154d: 0xb189, 0x154e: 0xb189, 0x154f: 0xb1a1, 0x1550: 0xb1a1, 0x1551: 0xb1a1, - 0x1552: 0xb1a1, 0x1553: 0xb1b9, 0x1554: 0xb1b9, 0x1555: 0xb1d1, 0x1556: 0xb1d1, 0x1557: 0xb1d1, - 0x1558: 0xb1d1, 0x1559: 0xb1e9, 0x155a: 0xb1e9, 0x155b: 0xb1e9, 0x155c: 0xb1e9, 0x155d: 0xb201, - 0x155e: 0xb201, 0x155f: 0xb201, 0x1560: 0xb201, 0x1561: 0xb219, 0x1562: 0xb219, 0x1563: 0xb219, - 0x1564: 0xb219, 0x1565: 0xb231, 0x1566: 0xb231, 0x1567: 0xb231, 0x1568: 0xb231, 0x1569: 0xb249, - 0x156a: 0xb249, 0x156b: 0xb261, 0x156c: 0xb261, 0x156d: 0xb279, 0x156e: 0xb279, 0x156f: 0xb291, - 0x1570: 0xb291, 0x1571: 0xb2a9, 0x1572: 0xb2a9, 0x1573: 0xb2a9, 0x1574: 0xb2a9, 0x1575: 0xb2c1, - 0x1576: 0xb2c1, 0x1577: 0xb2c1, 0x1578: 0xb2c1, 0x1579: 0xb2d9, 0x157a: 0xb2d9, 0x157b: 0xb2d9, - 0x157c: 0xb2d9, 0x157d: 0xb2f1, 0x157e: 0xb2f1, 0x157f: 0xb2f1, - // Block 0x56, offset 0x1580 - 0x1580: 0xb2f1, 0x1581: 0xb309, 0x1582: 0xb309, 0x1583: 0xb309, 0x1584: 0xb309, 0x1585: 0xb321, - 0x1586: 0xb321, 0x1587: 0xb321, 0x1588: 0xb321, 0x1589: 0xb339, 0x158a: 0xb339, 0x158b: 0xb339, - 0x158c: 0xb339, 0x158d: 0xb351, 0x158e: 0xb351, 0x158f: 0xb351, 0x1590: 0xb351, 0x1591: 0xb369, - 0x1592: 0xb369, 0x1593: 0xb369, 0x1594: 0xb369, 0x1595: 0xb381, 0x1596: 0xb381, 0x1597: 0xb381, - 0x1598: 0xb381, 0x1599: 0xb399, 0x159a: 0xb399, 0x159b: 0xb399, 0x159c: 0xb399, 0x159d: 0xb3b1, - 0x159e: 0xb3b1, 0x159f: 0xb3b1, 0x15a0: 0xb3b1, 0x15a1: 0xb3c9, 0x15a2: 0xb3c9, 0x15a3: 0xb3c9, - 0x15a4: 0xb3c9, 0x15a5: 0xb3e1, 0x15a6: 0xb3e1, 0x15a7: 0xb3e1, 0x15a8: 0xb3e1, 0x15a9: 0xb3f9, - 0x15aa: 0xb3f9, 0x15ab: 0xb3f9, 0x15ac: 0xb3f9, 0x15ad: 0xb411, 0x15ae: 0xb411, 0x15af: 0x7ab1, - 0x15b0: 0x7ab1, 0x15b1: 0xb429, 0x15b2: 0xb429, 0x15b3: 0xb429, 0x15b4: 0xb429, 0x15b5: 0xb441, - 0x15b6: 0xb441, 0x15b7: 0xb469, 0x15b8: 0xb469, 0x15b9: 0xb491, 0x15ba: 0xb491, 0x15bb: 0xb4b9, - 0x15bc: 0xb4b9, 0x15bd: 0x0040, 0x15be: 0x0040, 0x15bf: 0x03c0, - // Block 0x57, offset 0x15c0 - 0x15c0: 0x0040, 0x15c1: 0xaefa, 0x15c2: 0xb4e2, 0x15c3: 0xaf6a, 0x15c4: 0xafda, 0x15c5: 0xafea, - 0x15c6: 0xaf7a, 0x15c7: 0xb4f2, 0x15c8: 0x1fd2, 0x15c9: 0x1fe2, 0x15ca: 0xaf8a, 0x15cb: 0x1fb2, - 0x15cc: 0xaeda, 0x15cd: 0xaf99, 0x15ce: 0x29d1, 0x15cf: 0xb502, 0x15d0: 0x1f41, 0x15d1: 0x00c9, - 0x15d2: 0x0069, 0x15d3: 0x0079, 0x15d4: 0x1f51, 0x15d5: 0x1f61, 0x15d6: 0x1f71, 0x15d7: 0x1f81, - 0x15d8: 0x1f91, 0x15d9: 0x1fa1, 0x15da: 0xaeea, 0x15db: 0x03c2, 0x15dc: 0xafaa, 0x15dd: 0x1fc2, - 0x15de: 0xafba, 0x15df: 0xaf0a, 0x15e0: 0xaffa, 0x15e1: 0x0039, 0x15e2: 0x0ee9, 0x15e3: 0x1159, - 0x15e4: 0x0ef9, 0x15e5: 0x0f09, 0x15e6: 0x1199, 0x15e7: 0x0f31, 0x15e8: 0x0249, 0x15e9: 0x0f41, - 0x15ea: 0x0259, 0x15eb: 0x0f51, 0x15ec: 0x0359, 0x15ed: 0x0f61, 0x15ee: 0x0f71, 0x15ef: 0x00d9, - 0x15f0: 0x0f99, 0x15f1: 0x2039, 0x15f2: 0x0269, 0x15f3: 0x01d9, 0x15f4: 0x0fa9, 0x15f5: 0x0fb9, - 0x15f6: 0x1089, 0x15f7: 0x0279, 0x15f8: 0x0369, 0x15f9: 0x0289, 0x15fa: 0x13d1, 0x15fb: 0xaf4a, - 0x15fc: 0xafca, 0x15fd: 0xaf5a, 0x15fe: 0xb512, 0x15ff: 0xaf1a, - // Block 0x58, offset 0x1600 - 0x1600: 0x1caa, 0x1601: 0x0039, 0x1602: 0x0ee9, 0x1603: 0x1159, 0x1604: 0x0ef9, 0x1605: 0x0f09, - 0x1606: 0x1199, 0x1607: 0x0f31, 0x1608: 0x0249, 0x1609: 0x0f41, 0x160a: 0x0259, 0x160b: 0x0f51, - 0x160c: 0x0359, 0x160d: 0x0f61, 0x160e: 0x0f71, 0x160f: 0x00d9, 0x1610: 0x0f99, 0x1611: 0x2039, - 0x1612: 0x0269, 0x1613: 0x01d9, 0x1614: 0x0fa9, 0x1615: 0x0fb9, 0x1616: 0x1089, 0x1617: 0x0279, - 0x1618: 0x0369, 0x1619: 0x0289, 0x161a: 0x13d1, 0x161b: 0xaf2a, 0x161c: 0xb522, 0x161d: 0xaf3a, - 0x161e: 0xb532, 0x161f: 0x80d5, 0x1620: 0x80f5, 0x1621: 0x29d1, 0x1622: 0x8115, 0x1623: 0x8115, - 0x1624: 0x8135, 0x1625: 0x8155, 0x1626: 0x8175, 0x1627: 0x8195, 0x1628: 0x81b5, 0x1629: 0x81d5, - 0x162a: 0x81f5, 0x162b: 0x8215, 0x162c: 0x8235, 0x162d: 0x8255, 0x162e: 0x8275, 0x162f: 0x8295, - 0x1630: 0x82b5, 0x1631: 0x82d5, 0x1632: 0x82f5, 0x1633: 0x8315, 0x1634: 0x8335, 0x1635: 0x8355, - 0x1636: 0x8375, 0x1637: 0x8395, 0x1638: 0x83b5, 0x1639: 0x83d5, 0x163a: 0x83f5, 0x163b: 0x8415, - 0x163c: 0x81b5, 0x163d: 0x8435, 0x163e: 0x8455, 0x163f: 0x8215, - // Block 0x59, offset 0x1640 - 0x1640: 0x8475, 0x1641: 0x8495, 0x1642: 0x84b5, 0x1643: 0x84d5, 0x1644: 0x84f5, 0x1645: 0x8515, - 0x1646: 0x8535, 0x1647: 0x8555, 0x1648: 0x84d5, 0x1649: 0x8575, 0x164a: 0x84d5, 0x164b: 0x8595, - 0x164c: 0x8595, 0x164d: 0x85b5, 0x164e: 0x85b5, 0x164f: 0x85d5, 0x1650: 0x8515, 0x1651: 0x85f5, - 0x1652: 0x8615, 0x1653: 0x85f5, 0x1654: 0x8635, 0x1655: 0x8615, 0x1656: 0x8655, 0x1657: 0x8655, - 0x1658: 0x8675, 0x1659: 0x8675, 0x165a: 0x8695, 0x165b: 0x8695, 0x165c: 0x8615, 0x165d: 0x8115, - 0x165e: 0x86b5, 0x165f: 0x86d5, 0x1660: 0x0040, 0x1661: 0x86f5, 0x1662: 0x8715, 0x1663: 0x8735, - 0x1664: 0x8755, 0x1665: 0x8735, 0x1666: 0x8775, 0x1667: 0x8795, 0x1668: 0x87b5, 0x1669: 0x87b5, - 0x166a: 0x87d5, 0x166b: 0x87d5, 0x166c: 0x87f5, 0x166d: 0x87f5, 0x166e: 0x87d5, 0x166f: 0x87d5, - 0x1670: 0x8815, 0x1671: 0x8835, 0x1672: 0x8855, 0x1673: 0x8875, 0x1674: 0x8895, 0x1675: 0x88b5, - 0x1676: 0x88b5, 0x1677: 0x88b5, 0x1678: 0x88d5, 0x1679: 0x88d5, 0x167a: 0x88d5, 0x167b: 0x88d5, - 0x167c: 0x87b5, 0x167d: 0x87b5, 0x167e: 0x87b5, 0x167f: 0x0040, - // Block 0x5a, offset 0x1680 - 0x1680: 0x0040, 0x1681: 0x0040, 0x1682: 0x8715, 0x1683: 0x86f5, 0x1684: 0x88f5, 0x1685: 0x86f5, - 0x1686: 0x8715, 0x1687: 0x86f5, 0x1688: 0x0040, 0x1689: 0x0040, 0x168a: 0x8915, 0x168b: 0x8715, - 0x168c: 0x8935, 0x168d: 0x88f5, 0x168e: 0x8935, 0x168f: 0x8715, 0x1690: 0x0040, 0x1691: 0x0040, - 0x1692: 0x8955, 0x1693: 0x8975, 0x1694: 0x8875, 0x1695: 0x8935, 0x1696: 0x88f5, 0x1697: 0x8935, - 0x1698: 0x0040, 0x1699: 0x0040, 0x169a: 0x8995, 0x169b: 0x89b5, 0x169c: 0x8995, 0x169d: 0x0040, - 0x169e: 0x0040, 0x169f: 0x0040, 0x16a0: 0xb541, 0x16a1: 0xb559, 0x16a2: 0xb571, 0x16a3: 0x89d6, - 0x16a4: 0xb589, 0x16a5: 0xb5a1, 0x16a6: 0x89f5, 0x16a7: 0x0040, 0x16a8: 0x8a15, 0x16a9: 0x8a35, - 0x16aa: 0x8a55, 0x16ab: 0x8a35, 0x16ac: 0x8a75, 0x16ad: 0x8a95, 0x16ae: 0x8ab5, 0x16af: 0x0040, - 0x16b0: 0x0040, 0x16b1: 0x0040, 0x16b2: 0x0040, 0x16b3: 0x0040, 0x16b4: 0x0040, 0x16b5: 0x0040, - 0x16b6: 0x0040, 0x16b7: 0x0040, 0x16b8: 0x0040, 0x16b9: 0x0340, 0x16ba: 0x0340, 0x16bb: 0x0340, - 0x16bc: 0x0040, 0x16bd: 0x0040, 0x16be: 0x0040, 0x16bf: 0x0040, - // Block 0x5b, offset 0x16c0 - 0x16c0: 0x0208, 0x16c1: 0x0208, 0x16c2: 0x0208, 0x16c3: 0x0208, 0x16c4: 0x0208, 0x16c5: 0x0408, - 0x16c6: 0x0008, 0x16c7: 0x0408, 0x16c8: 0x0018, 0x16c9: 0x0408, 0x16ca: 0x0408, 0x16cb: 0x0008, - 0x16cc: 0x0008, 0x16cd: 0x0108, 0x16ce: 0x0408, 0x16cf: 0x0408, 0x16d0: 0x0408, 0x16d1: 0x0408, - 0x16d2: 0x0408, 0x16d3: 0x0208, 0x16d4: 0x0208, 0x16d5: 0x0208, 0x16d6: 0x0208, 0x16d7: 0x0108, - 0x16d8: 0x0208, 0x16d9: 0x0208, 0x16da: 0x0208, 0x16db: 0x0208, 0x16dc: 0x0208, 0x16dd: 0x0408, - 0x16de: 0x0208, 0x16df: 0x0208, 0x16e0: 0x0208, 0x16e1: 0x0408, 0x16e2: 0x0008, 0x16e3: 0x0008, - 0x16e4: 0x0408, 0x16e5: 0x1308, 0x16e6: 0x1308, 0x16e7: 0x0040, 0x16e8: 0x0040, 0x16e9: 0x0040, - 0x16ea: 0x0040, 0x16eb: 0x0218, 0x16ec: 0x0218, 0x16ed: 0x0218, 0x16ee: 0x0218, 0x16ef: 0x0418, - 0x16f0: 0x0018, 0x16f1: 0x0018, 0x16f2: 0x0018, 0x16f3: 0x0018, 0x16f4: 0x0018, 0x16f5: 0x0018, - 0x16f6: 0x0018, 0x16f7: 0x0040, 0x16f8: 0x0040, 0x16f9: 0x0040, 0x16fa: 0x0040, 0x16fb: 0x0040, - 0x16fc: 0x0040, 0x16fd: 0x0040, 0x16fe: 0x0040, 0x16ff: 0x0040, - // Block 0x5c, offset 0x1700 - 0x1700: 0x0208, 0x1701: 0x0408, 0x1702: 0x0208, 0x1703: 0x0408, 0x1704: 0x0408, 0x1705: 0x0408, - 0x1706: 0x0208, 0x1707: 0x0208, 0x1708: 0x0208, 0x1709: 0x0408, 0x170a: 0x0208, 0x170b: 0x0208, - 0x170c: 0x0408, 0x170d: 0x0208, 0x170e: 0x0408, 0x170f: 0x0408, 0x1710: 0x0208, 0x1711: 0x0408, - 0x1712: 0x0040, 0x1713: 0x0040, 0x1714: 0x0040, 0x1715: 0x0040, 0x1716: 0x0040, 0x1717: 0x0040, - 0x1718: 0x0040, 0x1719: 0x0018, 0x171a: 0x0018, 0x171b: 0x0018, 0x171c: 0x0018, 0x171d: 0x0040, - 0x171e: 0x0040, 0x171f: 0x0040, 0x1720: 0x0040, 0x1721: 0x0040, 0x1722: 0x0040, 0x1723: 0x0040, - 0x1724: 0x0040, 0x1725: 0x0040, 0x1726: 0x0040, 0x1727: 0x0040, 0x1728: 0x0040, 0x1729: 0x0418, - 0x172a: 0x0418, 0x172b: 0x0418, 0x172c: 0x0418, 0x172d: 0x0218, 0x172e: 0x0218, 0x172f: 0x0018, - 0x1730: 0x0040, 0x1731: 0x0040, 0x1732: 0x0040, 0x1733: 0x0040, 0x1734: 0x0040, 0x1735: 0x0040, - 0x1736: 0x0040, 0x1737: 0x0040, 0x1738: 0x0040, 0x1739: 0x0040, 0x173a: 0x0040, 0x173b: 0x0040, - 0x173c: 0x0040, 0x173d: 0x0040, 0x173e: 0x0040, 0x173f: 0x0040, - // Block 0x5d, offset 0x1740 - 0x1740: 0x1308, 0x1741: 0x1308, 0x1742: 0x1008, 0x1743: 0x1008, 0x1744: 0x0040, 0x1745: 0x0008, - 0x1746: 0x0008, 0x1747: 0x0008, 0x1748: 0x0008, 0x1749: 0x0008, 0x174a: 0x0008, 0x174b: 0x0008, - 0x174c: 0x0008, 0x174d: 0x0040, 0x174e: 0x0040, 0x174f: 0x0008, 0x1750: 0x0008, 0x1751: 0x0040, - 0x1752: 0x0040, 0x1753: 0x0008, 0x1754: 0x0008, 0x1755: 0x0008, 0x1756: 0x0008, 0x1757: 0x0008, - 0x1758: 0x0008, 0x1759: 0x0008, 0x175a: 0x0008, 0x175b: 0x0008, 0x175c: 0x0008, 0x175d: 0x0008, - 0x175e: 0x0008, 0x175f: 0x0008, 0x1760: 0x0008, 0x1761: 0x0008, 0x1762: 0x0008, 0x1763: 0x0008, - 0x1764: 0x0008, 0x1765: 0x0008, 0x1766: 0x0008, 0x1767: 0x0008, 0x1768: 0x0008, 0x1769: 0x0040, - 0x176a: 0x0008, 0x176b: 0x0008, 0x176c: 0x0008, 0x176d: 0x0008, 0x176e: 0x0008, 0x176f: 0x0008, - 0x1770: 0x0008, 0x1771: 0x0040, 0x1772: 0x0008, 0x1773: 0x0008, 0x1774: 0x0040, 0x1775: 0x0008, - 0x1776: 0x0008, 0x1777: 0x0008, 0x1778: 0x0008, 0x1779: 0x0008, 0x177a: 0x0040, 0x177b: 0x0040, - 0x177c: 0x1308, 0x177d: 0x0008, 0x177e: 0x1008, 0x177f: 0x1008, - // Block 0x5e, offset 0x1780 - 0x1780: 0x1308, 0x1781: 0x1008, 0x1782: 0x1008, 0x1783: 0x1008, 0x1784: 0x1008, 0x1785: 0x0040, - 0x1786: 0x0040, 0x1787: 0x1008, 0x1788: 0x1008, 0x1789: 0x0040, 0x178a: 0x0040, 0x178b: 0x1008, - 0x178c: 0x1008, 0x178d: 0x1808, 0x178e: 0x0040, 0x178f: 0x0040, 0x1790: 0x0008, 0x1791: 0x0040, - 0x1792: 0x0040, 0x1793: 0x0040, 0x1794: 0x0040, 0x1795: 0x0040, 0x1796: 0x0040, 0x1797: 0x1008, - 0x1798: 0x0040, 0x1799: 0x0040, 0x179a: 0x0040, 0x179b: 0x0040, 0x179c: 0x0040, 0x179d: 0x0008, - 0x179e: 0x0008, 0x179f: 0x0008, 0x17a0: 0x0008, 0x17a1: 0x0008, 0x17a2: 0x1008, 0x17a3: 0x1008, - 0x17a4: 0x0040, 0x17a5: 0x0040, 0x17a6: 0x1308, 0x17a7: 0x1308, 0x17a8: 0x1308, 0x17a9: 0x1308, - 0x17aa: 0x1308, 0x17ab: 0x1308, 0x17ac: 0x1308, 0x17ad: 0x0040, 0x17ae: 0x0040, 0x17af: 0x0040, - 0x17b0: 0x1308, 0x17b1: 0x1308, 0x17b2: 0x1308, 0x17b3: 0x1308, 0x17b4: 0x1308, 0x17b5: 0x0040, - 0x17b6: 0x0040, 0x17b7: 0x0040, 0x17b8: 0x0040, 0x17b9: 0x0040, 0x17ba: 0x0040, 0x17bb: 0x0040, - 0x17bc: 0x0040, 0x17bd: 0x0040, 0x17be: 0x0040, 0x17bf: 0x0040, - // Block 0x5f, offset 0x17c0 - 0x17c0: 0x0039, 0x17c1: 0x0ee9, 0x17c2: 0x1159, 0x17c3: 0x0ef9, 0x17c4: 0x0f09, 0x17c5: 0x1199, - 0x17c6: 0x0f31, 0x17c7: 0x0249, 0x17c8: 0x0f41, 0x17c9: 0x0259, 0x17ca: 0x0f51, 0x17cb: 0x0359, - 0x17cc: 0x0f61, 0x17cd: 0x0f71, 0x17ce: 0x00d9, 0x17cf: 0x0f99, 0x17d0: 0x2039, 0x17d1: 0x0269, - 0x17d2: 0x01d9, 0x17d3: 0x0fa9, 0x17d4: 0x0fb9, 0x17d5: 0x1089, 0x17d6: 0x0279, 0x17d7: 0x0369, - 0x17d8: 0x0289, 0x17d9: 0x13d1, 0x17da: 0x0039, 0x17db: 0x0ee9, 0x17dc: 0x1159, 0x17dd: 0x0ef9, - 0x17de: 0x0f09, 0x17df: 0x1199, 0x17e0: 0x0f31, 0x17e1: 0x0249, 0x17e2: 0x0f41, 0x17e3: 0x0259, - 0x17e4: 0x0f51, 0x17e5: 0x0359, 0x17e6: 0x0f61, 0x17e7: 0x0f71, 0x17e8: 0x00d9, 0x17e9: 0x0f99, - 0x17ea: 0x2039, 0x17eb: 0x0269, 0x17ec: 0x01d9, 0x17ed: 0x0fa9, 0x17ee: 0x0fb9, 0x17ef: 0x1089, - 0x17f0: 0x0279, 0x17f1: 0x0369, 0x17f2: 0x0289, 0x17f3: 0x13d1, 0x17f4: 0x0039, 0x17f5: 0x0ee9, - 0x17f6: 0x1159, 0x17f7: 0x0ef9, 0x17f8: 0x0f09, 0x17f9: 0x1199, 0x17fa: 0x0f31, 0x17fb: 0x0249, - 0x17fc: 0x0f41, 0x17fd: 0x0259, 0x17fe: 0x0f51, 0x17ff: 0x0359, - // Block 0x60, offset 0x1800 - 0x1800: 0x0f61, 0x1801: 0x0f71, 0x1802: 0x00d9, 0x1803: 0x0f99, 0x1804: 0x2039, 0x1805: 0x0269, - 0x1806: 0x01d9, 0x1807: 0x0fa9, 0x1808: 0x0fb9, 0x1809: 0x1089, 0x180a: 0x0279, 0x180b: 0x0369, - 0x180c: 0x0289, 0x180d: 0x13d1, 0x180e: 0x0039, 0x180f: 0x0ee9, 0x1810: 0x1159, 0x1811: 0x0ef9, - 0x1812: 0x0f09, 0x1813: 0x1199, 0x1814: 0x0f31, 0x1815: 0x0040, 0x1816: 0x0f41, 0x1817: 0x0259, - 0x1818: 0x0f51, 0x1819: 0x0359, 0x181a: 0x0f61, 0x181b: 0x0f71, 0x181c: 0x00d9, 0x181d: 0x0f99, - 0x181e: 0x2039, 0x181f: 0x0269, 0x1820: 0x01d9, 0x1821: 0x0fa9, 0x1822: 0x0fb9, 0x1823: 0x1089, - 0x1824: 0x0279, 0x1825: 0x0369, 0x1826: 0x0289, 0x1827: 0x13d1, 0x1828: 0x0039, 0x1829: 0x0ee9, - 0x182a: 0x1159, 0x182b: 0x0ef9, 0x182c: 0x0f09, 0x182d: 0x1199, 0x182e: 0x0f31, 0x182f: 0x0249, - 0x1830: 0x0f41, 0x1831: 0x0259, 0x1832: 0x0f51, 0x1833: 0x0359, 0x1834: 0x0f61, 0x1835: 0x0f71, - 0x1836: 0x00d9, 0x1837: 0x0f99, 0x1838: 0x2039, 0x1839: 0x0269, 0x183a: 0x01d9, 0x183b: 0x0fa9, - 0x183c: 0x0fb9, 0x183d: 0x1089, 0x183e: 0x0279, 0x183f: 0x0369, - // Block 0x61, offset 0x1840 - 0x1840: 0x0289, 0x1841: 0x13d1, 0x1842: 0x0039, 0x1843: 0x0ee9, 0x1844: 0x1159, 0x1845: 0x0ef9, - 0x1846: 0x0f09, 0x1847: 0x1199, 0x1848: 0x0f31, 0x1849: 0x0249, 0x184a: 0x0f41, 0x184b: 0x0259, - 0x184c: 0x0f51, 0x184d: 0x0359, 0x184e: 0x0f61, 0x184f: 0x0f71, 0x1850: 0x00d9, 0x1851: 0x0f99, - 0x1852: 0x2039, 0x1853: 0x0269, 0x1854: 0x01d9, 0x1855: 0x0fa9, 0x1856: 0x0fb9, 0x1857: 0x1089, - 0x1858: 0x0279, 0x1859: 0x0369, 0x185a: 0x0289, 0x185b: 0x13d1, 0x185c: 0x0039, 0x185d: 0x0040, - 0x185e: 0x1159, 0x185f: 0x0ef9, 0x1860: 0x0040, 0x1861: 0x0040, 0x1862: 0x0f31, 0x1863: 0x0040, - 0x1864: 0x0040, 0x1865: 0x0259, 0x1866: 0x0f51, 0x1867: 0x0040, 0x1868: 0x0040, 0x1869: 0x0f71, - 0x186a: 0x00d9, 0x186b: 0x0f99, 0x186c: 0x2039, 0x186d: 0x0040, 0x186e: 0x01d9, 0x186f: 0x0fa9, - 0x1870: 0x0fb9, 0x1871: 0x1089, 0x1872: 0x0279, 0x1873: 0x0369, 0x1874: 0x0289, 0x1875: 0x13d1, - 0x1876: 0x0039, 0x1877: 0x0ee9, 0x1878: 0x1159, 0x1879: 0x0ef9, 0x187a: 0x0040, 0x187b: 0x1199, - 0x187c: 0x0040, 0x187d: 0x0249, 0x187e: 0x0f41, 0x187f: 0x0259, - // Block 0x62, offset 0x1880 - 0x1880: 0x0f51, 0x1881: 0x0359, 0x1882: 0x0f61, 0x1883: 0x0f71, 0x1884: 0x0040, 0x1885: 0x0f99, - 0x1886: 0x2039, 0x1887: 0x0269, 0x1888: 0x01d9, 0x1889: 0x0fa9, 0x188a: 0x0fb9, 0x188b: 0x1089, - 0x188c: 0x0279, 0x188d: 0x0369, 0x188e: 0x0289, 0x188f: 0x13d1, 0x1890: 0x0039, 0x1891: 0x0ee9, - 0x1892: 0x1159, 0x1893: 0x0ef9, 0x1894: 0x0f09, 0x1895: 0x1199, 0x1896: 0x0f31, 0x1897: 0x0249, - 0x1898: 0x0f41, 0x1899: 0x0259, 0x189a: 0x0f51, 0x189b: 0x0359, 0x189c: 0x0f61, 0x189d: 0x0f71, - 0x189e: 0x00d9, 0x189f: 0x0f99, 0x18a0: 0x2039, 0x18a1: 0x0269, 0x18a2: 0x01d9, 0x18a3: 0x0fa9, - 0x18a4: 0x0fb9, 0x18a5: 0x1089, 0x18a6: 0x0279, 0x18a7: 0x0369, 0x18a8: 0x0289, 0x18a9: 0x13d1, - 0x18aa: 0x0039, 0x18ab: 0x0ee9, 0x18ac: 0x1159, 0x18ad: 0x0ef9, 0x18ae: 0x0f09, 0x18af: 0x1199, - 0x18b0: 0x0f31, 0x18b1: 0x0249, 0x18b2: 0x0f41, 0x18b3: 0x0259, 0x18b4: 0x0f51, 0x18b5: 0x0359, - 0x18b6: 0x0f61, 0x18b7: 0x0f71, 0x18b8: 0x00d9, 0x18b9: 0x0f99, 0x18ba: 0x2039, 0x18bb: 0x0269, - 0x18bc: 0x01d9, 0x18bd: 0x0fa9, 0x18be: 0x0fb9, 0x18bf: 0x1089, - // Block 0x63, offset 0x18c0 - 0x18c0: 0x0279, 0x18c1: 0x0369, 0x18c2: 0x0289, 0x18c3: 0x13d1, 0x18c4: 0x0039, 0x18c5: 0x0ee9, - 0x18c6: 0x0040, 0x18c7: 0x0ef9, 0x18c8: 0x0f09, 0x18c9: 0x1199, 0x18ca: 0x0f31, 0x18cb: 0x0040, - 0x18cc: 0x0040, 0x18cd: 0x0259, 0x18ce: 0x0f51, 0x18cf: 0x0359, 0x18d0: 0x0f61, 0x18d1: 0x0f71, - 0x18d2: 0x00d9, 0x18d3: 0x0f99, 0x18d4: 0x2039, 0x18d5: 0x0040, 0x18d6: 0x01d9, 0x18d7: 0x0fa9, - 0x18d8: 0x0fb9, 0x18d9: 0x1089, 0x18da: 0x0279, 0x18db: 0x0369, 0x18dc: 0x0289, 0x18dd: 0x0040, - 0x18de: 0x0039, 0x18df: 0x0ee9, 0x18e0: 0x1159, 0x18e1: 0x0ef9, 0x18e2: 0x0f09, 0x18e3: 0x1199, - 0x18e4: 0x0f31, 0x18e5: 0x0249, 0x18e6: 0x0f41, 0x18e7: 0x0259, 0x18e8: 0x0f51, 0x18e9: 0x0359, - 0x18ea: 0x0f61, 0x18eb: 0x0f71, 0x18ec: 0x00d9, 0x18ed: 0x0f99, 0x18ee: 0x2039, 0x18ef: 0x0269, - 0x18f0: 0x01d9, 0x18f1: 0x0fa9, 0x18f2: 0x0fb9, 0x18f3: 0x1089, 0x18f4: 0x0279, 0x18f5: 0x0369, - 0x18f6: 0x0289, 0x18f7: 0x13d1, 0x18f8: 0x0039, 0x18f9: 0x0ee9, 0x18fa: 0x0040, 0x18fb: 0x0ef9, - 0x18fc: 0x0f09, 0x18fd: 0x1199, 0x18fe: 0x0f31, 0x18ff: 0x0040, - // Block 0x64, offset 0x1900 - 0x1900: 0x0f41, 0x1901: 0x0259, 0x1902: 0x0f51, 0x1903: 0x0359, 0x1904: 0x0f61, 0x1905: 0x0040, - 0x1906: 0x00d9, 0x1907: 0x0040, 0x1908: 0x0040, 0x1909: 0x0040, 0x190a: 0x01d9, 0x190b: 0x0fa9, - 0x190c: 0x0fb9, 0x190d: 0x1089, 0x190e: 0x0279, 0x190f: 0x0369, 0x1910: 0x0289, 0x1911: 0x0040, - 0x1912: 0x0039, 0x1913: 0x0ee9, 0x1914: 0x1159, 0x1915: 0x0ef9, 0x1916: 0x0f09, 0x1917: 0x1199, - 0x1918: 0x0f31, 0x1919: 0x0249, 0x191a: 0x0f41, 0x191b: 0x0259, 0x191c: 0x0f51, 0x191d: 0x0359, - 0x191e: 0x0f61, 0x191f: 0x0f71, 0x1920: 0x00d9, 0x1921: 0x0f99, 0x1922: 0x2039, 0x1923: 0x0269, - 0x1924: 0x01d9, 0x1925: 0x0fa9, 0x1926: 0x0fb9, 0x1927: 0x1089, 0x1928: 0x0279, 0x1929: 0x0369, - 0x192a: 0x0289, 0x192b: 0x13d1, 0x192c: 0x0039, 0x192d: 0x0ee9, 0x192e: 0x1159, 0x192f: 0x0ef9, - 0x1930: 0x0f09, 0x1931: 0x1199, 0x1932: 0x0f31, 0x1933: 0x0249, 0x1934: 0x0f41, 0x1935: 0x0259, - 0x1936: 0x0f51, 0x1937: 0x0359, 0x1938: 0x0f61, 0x1939: 0x0f71, 0x193a: 0x00d9, 0x193b: 0x0f99, - 0x193c: 0x2039, 0x193d: 0x0269, 0x193e: 0x01d9, 0x193f: 0x0fa9, - // Block 0x65, offset 0x1940 - 0x1940: 0x0fb9, 0x1941: 0x1089, 0x1942: 0x0279, 0x1943: 0x0369, 0x1944: 0x0289, 0x1945: 0x13d1, - 0x1946: 0x0039, 0x1947: 0x0ee9, 0x1948: 0x1159, 0x1949: 0x0ef9, 0x194a: 0x0f09, 0x194b: 0x1199, - 0x194c: 0x0f31, 0x194d: 0x0249, 0x194e: 0x0f41, 0x194f: 0x0259, 0x1950: 0x0f51, 0x1951: 0x0359, - 0x1952: 0x0f61, 0x1953: 0x0f71, 0x1954: 0x00d9, 0x1955: 0x0f99, 0x1956: 0x2039, 0x1957: 0x0269, - 0x1958: 0x01d9, 0x1959: 0x0fa9, 0x195a: 0x0fb9, 0x195b: 0x1089, 0x195c: 0x0279, 0x195d: 0x0369, - 0x195e: 0x0289, 0x195f: 0x13d1, 0x1960: 0x0039, 0x1961: 0x0ee9, 0x1962: 0x1159, 0x1963: 0x0ef9, - 0x1964: 0x0f09, 0x1965: 0x1199, 0x1966: 0x0f31, 0x1967: 0x0249, 0x1968: 0x0f41, 0x1969: 0x0259, - 0x196a: 0x0f51, 0x196b: 0x0359, 0x196c: 0x0f61, 0x196d: 0x0f71, 0x196e: 0x00d9, 0x196f: 0x0f99, - 0x1970: 0x2039, 0x1971: 0x0269, 0x1972: 0x01d9, 0x1973: 0x0fa9, 0x1974: 0x0fb9, 0x1975: 0x1089, - 0x1976: 0x0279, 0x1977: 0x0369, 0x1978: 0x0289, 0x1979: 0x13d1, 0x197a: 0x0039, 0x197b: 0x0ee9, - 0x197c: 0x1159, 0x197d: 0x0ef9, 0x197e: 0x0f09, 0x197f: 0x1199, - // Block 0x66, offset 0x1980 - 0x1980: 0x0f31, 0x1981: 0x0249, 0x1982: 0x0f41, 0x1983: 0x0259, 0x1984: 0x0f51, 0x1985: 0x0359, - 0x1986: 0x0f61, 0x1987: 0x0f71, 0x1988: 0x00d9, 0x1989: 0x0f99, 0x198a: 0x2039, 0x198b: 0x0269, - 0x198c: 0x01d9, 0x198d: 0x0fa9, 0x198e: 0x0fb9, 0x198f: 0x1089, 0x1990: 0x0279, 0x1991: 0x0369, - 0x1992: 0x0289, 0x1993: 0x13d1, 0x1994: 0x0039, 0x1995: 0x0ee9, 0x1996: 0x1159, 0x1997: 0x0ef9, - 0x1998: 0x0f09, 0x1999: 0x1199, 0x199a: 0x0f31, 0x199b: 0x0249, 0x199c: 0x0f41, 0x199d: 0x0259, - 0x199e: 0x0f51, 0x199f: 0x0359, 0x19a0: 0x0f61, 0x19a1: 0x0f71, 0x19a2: 0x00d9, 0x19a3: 0x0f99, - 0x19a4: 0x2039, 0x19a5: 0x0269, 0x19a6: 0x01d9, 0x19a7: 0x0fa9, 0x19a8: 0x0fb9, 0x19a9: 0x1089, - 0x19aa: 0x0279, 0x19ab: 0x0369, 0x19ac: 0x0289, 0x19ad: 0x13d1, 0x19ae: 0x0039, 0x19af: 0x0ee9, - 0x19b0: 0x1159, 0x19b1: 0x0ef9, 0x19b2: 0x0f09, 0x19b3: 0x1199, 0x19b4: 0x0f31, 0x19b5: 0x0249, - 0x19b6: 0x0f41, 0x19b7: 0x0259, 0x19b8: 0x0f51, 0x19b9: 0x0359, 0x19ba: 0x0f61, 0x19bb: 0x0f71, - 0x19bc: 0x00d9, 0x19bd: 0x0f99, 0x19be: 0x2039, 0x19bf: 0x0269, - // Block 0x67, offset 0x19c0 - 0x19c0: 0x01d9, 0x19c1: 0x0fa9, 0x19c2: 0x0fb9, 0x19c3: 0x1089, 0x19c4: 0x0279, 0x19c5: 0x0369, - 0x19c6: 0x0289, 0x19c7: 0x13d1, 0x19c8: 0x0039, 0x19c9: 0x0ee9, 0x19ca: 0x1159, 0x19cb: 0x0ef9, - 0x19cc: 0x0f09, 0x19cd: 0x1199, 0x19ce: 0x0f31, 0x19cf: 0x0249, 0x19d0: 0x0f41, 0x19d1: 0x0259, - 0x19d2: 0x0f51, 0x19d3: 0x0359, 0x19d4: 0x0f61, 0x19d5: 0x0f71, 0x19d6: 0x00d9, 0x19d7: 0x0f99, - 0x19d8: 0x2039, 0x19d9: 0x0269, 0x19da: 0x01d9, 0x19db: 0x0fa9, 0x19dc: 0x0fb9, 0x19dd: 0x1089, - 0x19de: 0x0279, 0x19df: 0x0369, 0x19e0: 0x0289, 0x19e1: 0x13d1, 0x19e2: 0x0039, 0x19e3: 0x0ee9, - 0x19e4: 0x1159, 0x19e5: 0x0ef9, 0x19e6: 0x0f09, 0x19e7: 0x1199, 0x19e8: 0x0f31, 0x19e9: 0x0249, - 0x19ea: 0x0f41, 0x19eb: 0x0259, 0x19ec: 0x0f51, 0x19ed: 0x0359, 0x19ee: 0x0f61, 0x19ef: 0x0f71, - 0x19f0: 0x00d9, 0x19f1: 0x0f99, 0x19f2: 0x2039, 0x19f3: 0x0269, 0x19f4: 0x01d9, 0x19f5: 0x0fa9, - 0x19f6: 0x0fb9, 0x19f7: 0x1089, 0x19f8: 0x0279, 0x19f9: 0x0369, 0x19fa: 0x0289, 0x19fb: 0x13d1, - 0x19fc: 0x0039, 0x19fd: 0x0ee9, 0x19fe: 0x1159, 0x19ff: 0x0ef9, - // Block 0x68, offset 0x1a00 - 0x1a00: 0x0f09, 0x1a01: 0x1199, 0x1a02: 0x0f31, 0x1a03: 0x0249, 0x1a04: 0x0f41, 0x1a05: 0x0259, - 0x1a06: 0x0f51, 0x1a07: 0x0359, 0x1a08: 0x0f61, 0x1a09: 0x0f71, 0x1a0a: 0x00d9, 0x1a0b: 0x0f99, - 0x1a0c: 0x2039, 0x1a0d: 0x0269, 0x1a0e: 0x01d9, 0x1a0f: 0x0fa9, 0x1a10: 0x0fb9, 0x1a11: 0x1089, - 0x1a12: 0x0279, 0x1a13: 0x0369, 0x1a14: 0x0289, 0x1a15: 0x13d1, 0x1a16: 0x0039, 0x1a17: 0x0ee9, - 0x1a18: 0x1159, 0x1a19: 0x0ef9, 0x1a1a: 0x0f09, 0x1a1b: 0x1199, 0x1a1c: 0x0f31, 0x1a1d: 0x0249, - 0x1a1e: 0x0f41, 0x1a1f: 0x0259, 0x1a20: 0x0f51, 0x1a21: 0x0359, 0x1a22: 0x0f61, 0x1a23: 0x0f71, - 0x1a24: 0x00d9, 0x1a25: 0x0f99, 0x1a26: 0x2039, 0x1a27: 0x0269, 0x1a28: 0x01d9, 0x1a29: 0x0fa9, - 0x1a2a: 0x0fb9, 0x1a2b: 0x1089, 0x1a2c: 0x0279, 0x1a2d: 0x0369, 0x1a2e: 0x0289, 0x1a2f: 0x13d1, - 0x1a30: 0x0039, 0x1a31: 0x0ee9, 0x1a32: 0x1159, 0x1a33: 0x0ef9, 0x1a34: 0x0f09, 0x1a35: 0x1199, - 0x1a36: 0x0f31, 0x1a37: 0x0249, 0x1a38: 0x0f41, 0x1a39: 0x0259, 0x1a3a: 0x0f51, 0x1a3b: 0x0359, - 0x1a3c: 0x0f61, 0x1a3d: 0x0f71, 0x1a3e: 0x00d9, 0x1a3f: 0x0f99, - // Block 0x69, offset 0x1a40 - 0x1a40: 0x2039, 0x1a41: 0x0269, 0x1a42: 0x01d9, 0x1a43: 0x0fa9, 0x1a44: 0x0fb9, 0x1a45: 0x1089, - 0x1a46: 0x0279, 0x1a47: 0x0369, 0x1a48: 0x0289, 0x1a49: 0x13d1, 0x1a4a: 0x0039, 0x1a4b: 0x0ee9, - 0x1a4c: 0x1159, 0x1a4d: 0x0ef9, 0x1a4e: 0x0f09, 0x1a4f: 0x1199, 0x1a50: 0x0f31, 0x1a51: 0x0249, - 0x1a52: 0x0f41, 0x1a53: 0x0259, 0x1a54: 0x0f51, 0x1a55: 0x0359, 0x1a56: 0x0f61, 0x1a57: 0x0f71, - 0x1a58: 0x00d9, 0x1a59: 0x0f99, 0x1a5a: 0x2039, 0x1a5b: 0x0269, 0x1a5c: 0x01d9, 0x1a5d: 0x0fa9, - 0x1a5e: 0x0fb9, 0x1a5f: 0x1089, 0x1a60: 0x0279, 0x1a61: 0x0369, 0x1a62: 0x0289, 0x1a63: 0x13d1, - 0x1a64: 0xba81, 0x1a65: 0xba99, 0x1a66: 0x0040, 0x1a67: 0x0040, 0x1a68: 0xbab1, 0x1a69: 0x1099, - 0x1a6a: 0x10b1, 0x1a6b: 0x10c9, 0x1a6c: 0xbac9, 0x1a6d: 0xbae1, 0x1a6e: 0xbaf9, 0x1a6f: 0x1429, - 0x1a70: 0x1a31, 0x1a71: 0xbb11, 0x1a72: 0xbb29, 0x1a73: 0xbb41, 0x1a74: 0xbb59, 0x1a75: 0xbb71, - 0x1a76: 0xbb89, 0x1a77: 0x2109, 0x1a78: 0x1111, 0x1a79: 0x1429, 0x1a7a: 0xbba1, 0x1a7b: 0xbbb9, - 0x1a7c: 0xbbd1, 0x1a7d: 0x10e1, 0x1a7e: 0x10f9, 0x1a7f: 0xbbe9, - // Block 0x6a, offset 0x1a80 - 0x1a80: 0x2079, 0x1a81: 0xbc01, 0x1a82: 0xbab1, 0x1a83: 0x1099, 0x1a84: 0x10b1, 0x1a85: 0x10c9, - 0x1a86: 0xbac9, 0x1a87: 0xbae1, 0x1a88: 0xbaf9, 0x1a89: 0x1429, 0x1a8a: 0x1a31, 0x1a8b: 0xbb11, - 0x1a8c: 0xbb29, 0x1a8d: 0xbb41, 0x1a8e: 0xbb59, 0x1a8f: 0xbb71, 0x1a90: 0xbb89, 0x1a91: 0x2109, - 0x1a92: 0x1111, 0x1a93: 0xbba1, 0x1a94: 0xbba1, 0x1a95: 0xbbb9, 0x1a96: 0xbbd1, 0x1a97: 0x10e1, - 0x1a98: 0x10f9, 0x1a99: 0xbbe9, 0x1a9a: 0x2079, 0x1a9b: 0xbc21, 0x1a9c: 0xbac9, 0x1a9d: 0x1429, - 0x1a9e: 0xbb11, 0x1a9f: 0x10e1, 0x1aa0: 0x1111, 0x1aa1: 0x2109, 0x1aa2: 0xbab1, 0x1aa3: 0x1099, - 0x1aa4: 0x10b1, 0x1aa5: 0x10c9, 0x1aa6: 0xbac9, 0x1aa7: 0xbae1, 0x1aa8: 0xbaf9, 0x1aa9: 0x1429, - 0x1aaa: 0x1a31, 0x1aab: 0xbb11, 0x1aac: 0xbb29, 0x1aad: 0xbb41, 0x1aae: 0xbb59, 0x1aaf: 0xbb71, - 0x1ab0: 0xbb89, 0x1ab1: 0x2109, 0x1ab2: 0x1111, 0x1ab3: 0x1429, 0x1ab4: 0xbba1, 0x1ab5: 0xbbb9, - 0x1ab6: 0xbbd1, 0x1ab7: 0x10e1, 0x1ab8: 0x10f9, 0x1ab9: 0xbbe9, 0x1aba: 0x2079, 0x1abb: 0xbc01, - 0x1abc: 0xbab1, 0x1abd: 0x1099, 0x1abe: 0x10b1, 0x1abf: 0x10c9, - // Block 0x6b, offset 0x1ac0 - 0x1ac0: 0xbac9, 0x1ac1: 0xbae1, 0x1ac2: 0xbaf9, 0x1ac3: 0x1429, 0x1ac4: 0x1a31, 0x1ac5: 0xbb11, - 0x1ac6: 0xbb29, 0x1ac7: 0xbb41, 0x1ac8: 0xbb59, 0x1ac9: 0xbb71, 0x1aca: 0xbb89, 0x1acb: 0x2109, - 0x1acc: 0x1111, 0x1acd: 0xbba1, 0x1ace: 0xbba1, 0x1acf: 0xbbb9, 0x1ad0: 0xbbd1, 0x1ad1: 0x10e1, - 0x1ad2: 0x10f9, 0x1ad3: 0xbbe9, 0x1ad4: 0x2079, 0x1ad5: 0xbc21, 0x1ad6: 0xbac9, 0x1ad7: 0x1429, - 0x1ad8: 0xbb11, 0x1ad9: 0x10e1, 0x1ada: 0x1111, 0x1adb: 0x2109, 0x1adc: 0xbab1, 0x1add: 0x1099, - 0x1ade: 0x10b1, 0x1adf: 0x10c9, 0x1ae0: 0xbac9, 0x1ae1: 0xbae1, 0x1ae2: 0xbaf9, 0x1ae3: 0x1429, - 0x1ae4: 0x1a31, 0x1ae5: 0xbb11, 0x1ae6: 0xbb29, 0x1ae7: 0xbb41, 0x1ae8: 0xbb59, 0x1ae9: 0xbb71, - 0x1aea: 0xbb89, 0x1aeb: 0x2109, 0x1aec: 0x1111, 0x1aed: 0x1429, 0x1aee: 0xbba1, 0x1aef: 0xbbb9, - 0x1af0: 0xbbd1, 0x1af1: 0x10e1, 0x1af2: 0x10f9, 0x1af3: 0xbbe9, 0x1af4: 0x2079, 0x1af5: 0xbc01, - 0x1af6: 0xbab1, 0x1af7: 0x1099, 0x1af8: 0x10b1, 0x1af9: 0x10c9, 0x1afa: 0xbac9, 0x1afb: 0xbae1, - 0x1afc: 0xbaf9, 0x1afd: 0x1429, 0x1afe: 0x1a31, 0x1aff: 0xbb11, - // Block 0x6c, offset 0x1b00 - 0x1b00: 0xbb29, 0x1b01: 0xbb41, 0x1b02: 0xbb59, 0x1b03: 0xbb71, 0x1b04: 0xbb89, 0x1b05: 0x2109, - 0x1b06: 0x1111, 0x1b07: 0xbba1, 0x1b08: 0xbba1, 0x1b09: 0xbbb9, 0x1b0a: 0xbbd1, 0x1b0b: 0x10e1, - 0x1b0c: 0x10f9, 0x1b0d: 0xbbe9, 0x1b0e: 0x2079, 0x1b0f: 0xbc21, 0x1b10: 0xbac9, 0x1b11: 0x1429, - 0x1b12: 0xbb11, 0x1b13: 0x10e1, 0x1b14: 0x1111, 0x1b15: 0x2109, 0x1b16: 0xbab1, 0x1b17: 0x1099, - 0x1b18: 0x10b1, 0x1b19: 0x10c9, 0x1b1a: 0xbac9, 0x1b1b: 0xbae1, 0x1b1c: 0xbaf9, 0x1b1d: 0x1429, - 0x1b1e: 0x1a31, 0x1b1f: 0xbb11, 0x1b20: 0xbb29, 0x1b21: 0xbb41, 0x1b22: 0xbb59, 0x1b23: 0xbb71, - 0x1b24: 0xbb89, 0x1b25: 0x2109, 0x1b26: 0x1111, 0x1b27: 0x1429, 0x1b28: 0xbba1, 0x1b29: 0xbbb9, - 0x1b2a: 0xbbd1, 0x1b2b: 0x10e1, 0x1b2c: 0x10f9, 0x1b2d: 0xbbe9, 0x1b2e: 0x2079, 0x1b2f: 0xbc01, - 0x1b30: 0xbab1, 0x1b31: 0x1099, 0x1b32: 0x10b1, 0x1b33: 0x10c9, 0x1b34: 0xbac9, 0x1b35: 0xbae1, - 0x1b36: 0xbaf9, 0x1b37: 0x1429, 0x1b38: 0x1a31, 0x1b39: 0xbb11, 0x1b3a: 0xbb29, 0x1b3b: 0xbb41, - 0x1b3c: 0xbb59, 0x1b3d: 0xbb71, 0x1b3e: 0xbb89, 0x1b3f: 0x2109, - // Block 0x6d, offset 0x1b40 - 0x1b40: 0x1111, 0x1b41: 0xbba1, 0x1b42: 0xbba1, 0x1b43: 0xbbb9, 0x1b44: 0xbbd1, 0x1b45: 0x10e1, - 0x1b46: 0x10f9, 0x1b47: 0xbbe9, 0x1b48: 0x2079, 0x1b49: 0xbc21, 0x1b4a: 0xbac9, 0x1b4b: 0x1429, - 0x1b4c: 0xbb11, 0x1b4d: 0x10e1, 0x1b4e: 0x1111, 0x1b4f: 0x2109, 0x1b50: 0xbab1, 0x1b51: 0x1099, - 0x1b52: 0x10b1, 0x1b53: 0x10c9, 0x1b54: 0xbac9, 0x1b55: 0xbae1, 0x1b56: 0xbaf9, 0x1b57: 0x1429, - 0x1b58: 0x1a31, 0x1b59: 0xbb11, 0x1b5a: 0xbb29, 0x1b5b: 0xbb41, 0x1b5c: 0xbb59, 0x1b5d: 0xbb71, - 0x1b5e: 0xbb89, 0x1b5f: 0x2109, 0x1b60: 0x1111, 0x1b61: 0x1429, 0x1b62: 0xbba1, 0x1b63: 0xbbb9, - 0x1b64: 0xbbd1, 0x1b65: 0x10e1, 0x1b66: 0x10f9, 0x1b67: 0xbbe9, 0x1b68: 0x2079, 0x1b69: 0xbc01, - 0x1b6a: 0xbab1, 0x1b6b: 0x1099, 0x1b6c: 0x10b1, 0x1b6d: 0x10c9, 0x1b6e: 0xbac9, 0x1b6f: 0xbae1, - 0x1b70: 0xbaf9, 0x1b71: 0x1429, 0x1b72: 0x1a31, 0x1b73: 0xbb11, 0x1b74: 0xbb29, 0x1b75: 0xbb41, - 0x1b76: 0xbb59, 0x1b77: 0xbb71, 0x1b78: 0xbb89, 0x1b79: 0x2109, 0x1b7a: 0x1111, 0x1b7b: 0xbba1, - 0x1b7c: 0xbba1, 0x1b7d: 0xbbb9, 0x1b7e: 0xbbd1, 0x1b7f: 0x10e1, - // Block 0x6e, offset 0x1b80 - 0x1b80: 0x10f9, 0x1b81: 0xbbe9, 0x1b82: 0x2079, 0x1b83: 0xbc21, 0x1b84: 0xbac9, 0x1b85: 0x1429, - 0x1b86: 0xbb11, 0x1b87: 0x10e1, 0x1b88: 0x1111, 0x1b89: 0x2109, 0x1b8a: 0xbc41, 0x1b8b: 0xbc41, - 0x1b8c: 0x0040, 0x1b8d: 0x0040, 0x1b8e: 0x1f41, 0x1b8f: 0x00c9, 0x1b90: 0x0069, 0x1b91: 0x0079, - 0x1b92: 0x1f51, 0x1b93: 0x1f61, 0x1b94: 0x1f71, 0x1b95: 0x1f81, 0x1b96: 0x1f91, 0x1b97: 0x1fa1, - 0x1b98: 0x1f41, 0x1b99: 0x00c9, 0x1b9a: 0x0069, 0x1b9b: 0x0079, 0x1b9c: 0x1f51, 0x1b9d: 0x1f61, - 0x1b9e: 0x1f71, 0x1b9f: 0x1f81, 0x1ba0: 0x1f91, 0x1ba1: 0x1fa1, 0x1ba2: 0x1f41, 0x1ba3: 0x00c9, - 0x1ba4: 0x0069, 0x1ba5: 0x0079, 0x1ba6: 0x1f51, 0x1ba7: 0x1f61, 0x1ba8: 0x1f71, 0x1ba9: 0x1f81, - 0x1baa: 0x1f91, 0x1bab: 0x1fa1, 0x1bac: 0x1f41, 0x1bad: 0x00c9, 0x1bae: 0x0069, 0x1baf: 0x0079, - 0x1bb0: 0x1f51, 0x1bb1: 0x1f61, 0x1bb2: 0x1f71, 0x1bb3: 0x1f81, 0x1bb4: 0x1f91, 0x1bb5: 0x1fa1, - 0x1bb6: 0x1f41, 0x1bb7: 0x00c9, 0x1bb8: 0x0069, 0x1bb9: 0x0079, 0x1bba: 0x1f51, 0x1bbb: 0x1f61, - 0x1bbc: 0x1f71, 0x1bbd: 0x1f81, 0x1bbe: 0x1f91, 0x1bbf: 0x1fa1, - // Block 0x6f, offset 0x1bc0 - 0x1bc0: 0xe115, 0x1bc1: 0xe115, 0x1bc2: 0xe135, 0x1bc3: 0xe135, 0x1bc4: 0xe115, 0x1bc5: 0xe115, - 0x1bc6: 0xe175, 0x1bc7: 0xe175, 0x1bc8: 0xe115, 0x1bc9: 0xe115, 0x1bca: 0xe135, 0x1bcb: 0xe135, - 0x1bcc: 0xe115, 0x1bcd: 0xe115, 0x1bce: 0xe1f5, 0x1bcf: 0xe1f5, 0x1bd0: 0xe115, 0x1bd1: 0xe115, - 0x1bd2: 0xe135, 0x1bd3: 0xe135, 0x1bd4: 0xe115, 0x1bd5: 0xe115, 0x1bd6: 0xe175, 0x1bd7: 0xe175, - 0x1bd8: 0xe115, 0x1bd9: 0xe115, 0x1bda: 0xe135, 0x1bdb: 0xe135, 0x1bdc: 0xe115, 0x1bdd: 0xe115, - 0x1bde: 0x8b05, 0x1bdf: 0x8b05, 0x1be0: 0x04b5, 0x1be1: 0x04b5, 0x1be2: 0x0208, 0x1be3: 0x0208, - 0x1be4: 0x0208, 0x1be5: 0x0208, 0x1be6: 0x0208, 0x1be7: 0x0208, 0x1be8: 0x0208, 0x1be9: 0x0208, - 0x1bea: 0x0208, 0x1beb: 0x0208, 0x1bec: 0x0208, 0x1bed: 0x0208, 0x1bee: 0x0208, 0x1bef: 0x0208, - 0x1bf0: 0x0208, 0x1bf1: 0x0208, 0x1bf2: 0x0208, 0x1bf3: 0x0208, 0x1bf4: 0x0208, 0x1bf5: 0x0208, - 0x1bf6: 0x0208, 0x1bf7: 0x0208, 0x1bf8: 0x0208, 0x1bf9: 0x0208, 0x1bfa: 0x0208, 0x1bfb: 0x0208, - 0x1bfc: 0x0208, 0x1bfd: 0x0208, 0x1bfe: 0x0208, 0x1bff: 0x0208, - // Block 0x70, offset 0x1c00 - 0x1c00: 0xb189, 0x1c01: 0xb1a1, 0x1c02: 0xb201, 0x1c03: 0xb249, 0x1c04: 0x0040, 0x1c05: 0xb411, - 0x1c06: 0xb291, 0x1c07: 0xb219, 0x1c08: 0xb309, 0x1c09: 0xb429, 0x1c0a: 0xb399, 0x1c0b: 0xb3b1, - 0x1c0c: 0xb3c9, 0x1c0d: 0xb3e1, 0x1c0e: 0xb2a9, 0x1c0f: 0xb339, 0x1c10: 0xb369, 0x1c11: 0xb2d9, - 0x1c12: 0xb381, 0x1c13: 0xb279, 0x1c14: 0xb2c1, 0x1c15: 0xb1d1, 0x1c16: 0xb1e9, 0x1c17: 0xb231, - 0x1c18: 0xb261, 0x1c19: 0xb2f1, 0x1c1a: 0xb321, 0x1c1b: 0xb351, 0x1c1c: 0xbc59, 0x1c1d: 0x7949, - 0x1c1e: 0xbc71, 0x1c1f: 0xbc89, 0x1c20: 0x0040, 0x1c21: 0xb1a1, 0x1c22: 0xb201, 0x1c23: 0x0040, - 0x1c24: 0xb3f9, 0x1c25: 0x0040, 0x1c26: 0x0040, 0x1c27: 0xb219, 0x1c28: 0x0040, 0x1c29: 0xb429, - 0x1c2a: 0xb399, 0x1c2b: 0xb3b1, 0x1c2c: 0xb3c9, 0x1c2d: 0xb3e1, 0x1c2e: 0xb2a9, 0x1c2f: 0xb339, - 0x1c30: 0xb369, 0x1c31: 0xb2d9, 0x1c32: 0xb381, 0x1c33: 0x0040, 0x1c34: 0xb2c1, 0x1c35: 0xb1d1, - 0x1c36: 0xb1e9, 0x1c37: 0xb231, 0x1c38: 0x0040, 0x1c39: 0xb2f1, 0x1c3a: 0x0040, 0x1c3b: 0xb351, - 0x1c3c: 0x0040, 0x1c3d: 0x0040, 0x1c3e: 0x0040, 0x1c3f: 0x0040, - // Block 0x71, offset 0x1c40 - 0x1c40: 0x0040, 0x1c41: 0x0040, 0x1c42: 0xb201, 0x1c43: 0x0040, 0x1c44: 0x0040, 0x1c45: 0x0040, - 0x1c46: 0x0040, 0x1c47: 0xb219, 0x1c48: 0x0040, 0x1c49: 0xb429, 0x1c4a: 0x0040, 0x1c4b: 0xb3b1, - 0x1c4c: 0x0040, 0x1c4d: 0xb3e1, 0x1c4e: 0xb2a9, 0x1c4f: 0xb339, 0x1c50: 0x0040, 0x1c51: 0xb2d9, - 0x1c52: 0xb381, 0x1c53: 0x0040, 0x1c54: 0xb2c1, 0x1c55: 0x0040, 0x1c56: 0x0040, 0x1c57: 0xb231, - 0x1c58: 0x0040, 0x1c59: 0xb2f1, 0x1c5a: 0x0040, 0x1c5b: 0xb351, 0x1c5c: 0x0040, 0x1c5d: 0x7949, - 0x1c5e: 0x0040, 0x1c5f: 0xbc89, 0x1c60: 0x0040, 0x1c61: 0xb1a1, 0x1c62: 0xb201, 0x1c63: 0x0040, - 0x1c64: 0xb3f9, 0x1c65: 0x0040, 0x1c66: 0x0040, 0x1c67: 0xb219, 0x1c68: 0xb309, 0x1c69: 0xb429, - 0x1c6a: 0xb399, 0x1c6b: 0x0040, 0x1c6c: 0xb3c9, 0x1c6d: 0xb3e1, 0x1c6e: 0xb2a9, 0x1c6f: 0xb339, - 0x1c70: 0xb369, 0x1c71: 0xb2d9, 0x1c72: 0xb381, 0x1c73: 0x0040, 0x1c74: 0xb2c1, 0x1c75: 0xb1d1, - 0x1c76: 0xb1e9, 0x1c77: 0xb231, 0x1c78: 0x0040, 0x1c79: 0xb2f1, 0x1c7a: 0xb321, 0x1c7b: 0xb351, - 0x1c7c: 0xbc59, 0x1c7d: 0x0040, 0x1c7e: 0xbc71, 0x1c7f: 0x0040, - // Block 0x72, offset 0x1c80 - 0x1c80: 0xb189, 0x1c81: 0xb1a1, 0x1c82: 0xb201, 0x1c83: 0xb249, 0x1c84: 0xb3f9, 0x1c85: 0xb411, - 0x1c86: 0xb291, 0x1c87: 0xb219, 0x1c88: 0xb309, 0x1c89: 0xb429, 0x1c8a: 0x0040, 0x1c8b: 0xb3b1, - 0x1c8c: 0xb3c9, 0x1c8d: 0xb3e1, 0x1c8e: 0xb2a9, 0x1c8f: 0xb339, 0x1c90: 0xb369, 0x1c91: 0xb2d9, - 0x1c92: 0xb381, 0x1c93: 0xb279, 0x1c94: 0xb2c1, 0x1c95: 0xb1d1, 0x1c96: 0xb1e9, 0x1c97: 0xb231, - 0x1c98: 0xb261, 0x1c99: 0xb2f1, 0x1c9a: 0xb321, 0x1c9b: 0xb351, 0x1c9c: 0x0040, 0x1c9d: 0x0040, - 0x1c9e: 0x0040, 0x1c9f: 0x0040, 0x1ca0: 0x0040, 0x1ca1: 0xb1a1, 0x1ca2: 0xb201, 0x1ca3: 0xb249, - 0x1ca4: 0x0040, 0x1ca5: 0xb411, 0x1ca6: 0xb291, 0x1ca7: 0xb219, 0x1ca8: 0xb309, 0x1ca9: 0xb429, - 0x1caa: 0x0040, 0x1cab: 0xb3b1, 0x1cac: 0xb3c9, 0x1cad: 0xb3e1, 0x1cae: 0xb2a9, 0x1caf: 0xb339, - 0x1cb0: 0xb369, 0x1cb1: 0xb2d9, 0x1cb2: 0xb381, 0x1cb3: 0xb279, 0x1cb4: 0xb2c1, 0x1cb5: 0xb1d1, - 0x1cb6: 0xb1e9, 0x1cb7: 0xb231, 0x1cb8: 0xb261, 0x1cb9: 0xb2f1, 0x1cba: 0xb321, 0x1cbb: 0xb351, - 0x1cbc: 0x0040, 0x1cbd: 0x0040, 0x1cbe: 0x0040, 0x1cbf: 0x0040, - // Block 0x73, offset 0x1cc0 - 0x1cc0: 0x0040, 0x1cc1: 0xbca2, 0x1cc2: 0xbcba, 0x1cc3: 0xbcd2, 0x1cc4: 0xbcea, 0x1cc5: 0xbd02, - 0x1cc6: 0xbd1a, 0x1cc7: 0xbd32, 0x1cc8: 0xbd4a, 0x1cc9: 0xbd62, 0x1cca: 0xbd7a, 0x1ccb: 0x0018, - 0x1ccc: 0x0018, 0x1ccd: 0x0040, 0x1cce: 0x0040, 0x1ccf: 0x0040, 0x1cd0: 0xbd92, 0x1cd1: 0xbdb2, - 0x1cd2: 0xbdd2, 0x1cd3: 0xbdf2, 0x1cd4: 0xbe12, 0x1cd5: 0xbe32, 0x1cd6: 0xbe52, 0x1cd7: 0xbe72, - 0x1cd8: 0xbe92, 0x1cd9: 0xbeb2, 0x1cda: 0xbed2, 0x1cdb: 0xbef2, 0x1cdc: 0xbf12, 0x1cdd: 0xbf32, - 0x1cde: 0xbf52, 0x1cdf: 0xbf72, 0x1ce0: 0xbf92, 0x1ce1: 0xbfb2, 0x1ce2: 0xbfd2, 0x1ce3: 0xbff2, - 0x1ce4: 0xc012, 0x1ce5: 0xc032, 0x1ce6: 0xc052, 0x1ce7: 0xc072, 0x1ce8: 0xc092, 0x1ce9: 0xc0b2, - 0x1cea: 0xc0d1, 0x1ceb: 0x1159, 0x1cec: 0x0269, 0x1ced: 0x6671, 0x1cee: 0xc111, 0x1cef: 0x0040, - 0x1cf0: 0x0039, 0x1cf1: 0x0ee9, 0x1cf2: 0x1159, 0x1cf3: 0x0ef9, 0x1cf4: 0x0f09, 0x1cf5: 0x1199, - 0x1cf6: 0x0f31, 0x1cf7: 0x0249, 0x1cf8: 0x0f41, 0x1cf9: 0x0259, 0x1cfa: 0x0f51, 0x1cfb: 0x0359, - 0x1cfc: 0x0f61, 0x1cfd: 0x0f71, 0x1cfe: 0x00d9, 0x1cff: 0x0f99, - // Block 0x74, offset 0x1d00 - 0x1d00: 0x2039, 0x1d01: 0x0269, 0x1d02: 0x01d9, 0x1d03: 0x0fa9, 0x1d04: 0x0fb9, 0x1d05: 0x1089, - 0x1d06: 0x0279, 0x1d07: 0x0369, 0x1d08: 0x0289, 0x1d09: 0x13d1, 0x1d0a: 0xc129, 0x1d0b: 0x65b1, - 0x1d0c: 0xc141, 0x1d0d: 0x1441, 0x1d0e: 0xc159, 0x1d0f: 0xc179, 0x1d10: 0x0018, 0x1d11: 0x0018, - 0x1d12: 0x0018, 0x1d13: 0x0018, 0x1d14: 0x0018, 0x1d15: 0x0018, 0x1d16: 0x0018, 0x1d17: 0x0018, - 0x1d18: 0x0018, 0x1d19: 0x0018, 0x1d1a: 0x0018, 0x1d1b: 0x0018, 0x1d1c: 0x0018, 0x1d1d: 0x0018, - 0x1d1e: 0x0018, 0x1d1f: 0x0018, 0x1d20: 0x0018, 0x1d21: 0x0018, 0x1d22: 0x0018, 0x1d23: 0x0018, - 0x1d24: 0x0018, 0x1d25: 0x0018, 0x1d26: 0x0018, 0x1d27: 0x0018, 0x1d28: 0x0018, 0x1d29: 0x0018, - 0x1d2a: 0xc191, 0x1d2b: 0xc1a9, 0x1d2c: 0x0040, 0x1d2d: 0x0040, 0x1d2e: 0x0040, 0x1d2f: 0x0040, - 0x1d30: 0x0018, 0x1d31: 0x0018, 0x1d32: 0x0018, 0x1d33: 0x0018, 0x1d34: 0x0018, 0x1d35: 0x0018, - 0x1d36: 0x0018, 0x1d37: 0x0018, 0x1d38: 0x0018, 0x1d39: 0x0018, 0x1d3a: 0x0018, 0x1d3b: 0x0018, - 0x1d3c: 0x0018, 0x1d3d: 0x0018, 0x1d3e: 0x0018, 0x1d3f: 0x0018, - // Block 0x75, offset 0x1d40 - 0x1d40: 0xc1d9, 0x1d41: 0xc211, 0x1d42: 0xc249, 0x1d43: 0x0040, 0x1d44: 0x0040, 0x1d45: 0x0040, - 0x1d46: 0x0040, 0x1d47: 0x0040, 0x1d48: 0x0040, 0x1d49: 0x0040, 0x1d4a: 0x0040, 0x1d4b: 0x0040, - 0x1d4c: 0x0040, 0x1d4d: 0x0040, 0x1d4e: 0x0040, 0x1d4f: 0x0040, 0x1d50: 0xc269, 0x1d51: 0xc289, - 0x1d52: 0xc2a9, 0x1d53: 0xc2c9, 0x1d54: 0xc2e9, 0x1d55: 0xc309, 0x1d56: 0xc329, 0x1d57: 0xc349, - 0x1d58: 0xc369, 0x1d59: 0xc389, 0x1d5a: 0xc3a9, 0x1d5b: 0xc3c9, 0x1d5c: 0xc3e9, 0x1d5d: 0xc409, - 0x1d5e: 0xc429, 0x1d5f: 0xc449, 0x1d60: 0xc469, 0x1d61: 0xc489, 0x1d62: 0xc4a9, 0x1d63: 0xc4c9, - 0x1d64: 0xc4e9, 0x1d65: 0xc509, 0x1d66: 0xc529, 0x1d67: 0xc549, 0x1d68: 0xc569, 0x1d69: 0xc589, - 0x1d6a: 0xc5a9, 0x1d6b: 0xc5c9, 0x1d6c: 0xc5e9, 0x1d6d: 0xc609, 0x1d6e: 0xc629, 0x1d6f: 0xc649, - 0x1d70: 0xc669, 0x1d71: 0xc689, 0x1d72: 0xc6a9, 0x1d73: 0xc6c9, 0x1d74: 0xc6e9, 0x1d75: 0xc709, - 0x1d76: 0xc729, 0x1d77: 0xc749, 0x1d78: 0xc769, 0x1d79: 0xc789, 0x1d7a: 0xc7a9, 0x1d7b: 0xc7c9, - 0x1d7c: 0x0040, 0x1d7d: 0x0040, 0x1d7e: 0x0040, 0x1d7f: 0x0040, - // Block 0x76, offset 0x1d80 - 0x1d80: 0xcaf9, 0x1d81: 0xcb19, 0x1d82: 0xcb39, 0x1d83: 0x8b1d, 0x1d84: 0xcb59, 0x1d85: 0xcb79, - 0x1d86: 0xcb99, 0x1d87: 0xcbb9, 0x1d88: 0xcbd9, 0x1d89: 0xcbf9, 0x1d8a: 0xcc19, 0x1d8b: 0xcc39, - 0x1d8c: 0xcc59, 0x1d8d: 0x8b3d, 0x1d8e: 0xcc79, 0x1d8f: 0xcc99, 0x1d90: 0xccb9, 0x1d91: 0xccd9, - 0x1d92: 0x8b5d, 0x1d93: 0xccf9, 0x1d94: 0xcd19, 0x1d95: 0xc429, 0x1d96: 0x8b7d, 0x1d97: 0xcd39, - 0x1d98: 0xcd59, 0x1d99: 0xcd79, 0x1d9a: 0xcd99, 0x1d9b: 0xcdb9, 0x1d9c: 0x8b9d, 0x1d9d: 0xcdd9, - 0x1d9e: 0xcdf9, 0x1d9f: 0xce19, 0x1da0: 0xce39, 0x1da1: 0xce59, 0x1da2: 0xc789, 0x1da3: 0xce79, - 0x1da4: 0xce99, 0x1da5: 0xceb9, 0x1da6: 0xced9, 0x1da7: 0xcef9, 0x1da8: 0xcf19, 0x1da9: 0xcf39, - 0x1daa: 0xcf59, 0x1dab: 0xcf79, 0x1dac: 0xcf99, 0x1dad: 0xcfb9, 0x1dae: 0xcfd9, 0x1daf: 0xcff9, - 0x1db0: 0xd019, 0x1db1: 0xd039, 0x1db2: 0xd039, 0x1db3: 0xd039, 0x1db4: 0x8bbd, 0x1db5: 0xd059, - 0x1db6: 0xd079, 0x1db7: 0xd099, 0x1db8: 0x8bdd, 0x1db9: 0xd0b9, 0x1dba: 0xd0d9, 0x1dbb: 0xd0f9, - 0x1dbc: 0xd119, 0x1dbd: 0xd139, 0x1dbe: 0xd159, 0x1dbf: 0xd179, - // Block 0x77, offset 0x1dc0 - 0x1dc0: 0xd199, 0x1dc1: 0xd1b9, 0x1dc2: 0xd1d9, 0x1dc3: 0xd1f9, 0x1dc4: 0xd219, 0x1dc5: 0xd239, - 0x1dc6: 0xd239, 0x1dc7: 0xd259, 0x1dc8: 0xd279, 0x1dc9: 0xd299, 0x1dca: 0xd2b9, 0x1dcb: 0xd2d9, - 0x1dcc: 0xd2f9, 0x1dcd: 0xd319, 0x1dce: 0xd339, 0x1dcf: 0xd359, 0x1dd0: 0xd379, 0x1dd1: 0xd399, - 0x1dd2: 0xd3b9, 0x1dd3: 0xd3d9, 0x1dd4: 0xd3f9, 0x1dd5: 0xd419, 0x1dd6: 0xd439, 0x1dd7: 0xd459, - 0x1dd8: 0xd479, 0x1dd9: 0x8bfd, 0x1dda: 0xd499, 0x1ddb: 0xd4b9, 0x1ddc: 0xd4d9, 0x1ddd: 0xc309, - 0x1dde: 0xd4f9, 0x1ddf: 0xd519, 0x1de0: 0x8c1d, 0x1de1: 0x8c3d, 0x1de2: 0xd539, 0x1de3: 0xd559, - 0x1de4: 0xd579, 0x1de5: 0xd599, 0x1de6: 0xd5b9, 0x1de7: 0xd5d9, 0x1de8: 0x0040, 0x1de9: 0xd5f9, - 0x1dea: 0xd619, 0x1deb: 0xd619, 0x1dec: 0x8c5d, 0x1ded: 0xd639, 0x1dee: 0xd659, 0x1def: 0xd679, - 0x1df0: 0xd699, 0x1df1: 0x8c7d, 0x1df2: 0xd6b9, 0x1df3: 0xd6d9, 0x1df4: 0x0040, 0x1df5: 0xd6f9, - 0x1df6: 0xd719, 0x1df7: 0xd739, 0x1df8: 0xd759, 0x1df9: 0xd779, 0x1dfa: 0xd799, 0x1dfb: 0x8c9d, - 0x1dfc: 0xd7b9, 0x1dfd: 0x8cbd, 0x1dfe: 0xd7d9, 0x1dff: 0xd7f9, - // Block 0x78, offset 0x1e00 - 0x1e00: 0xd819, 0x1e01: 0xd839, 0x1e02: 0xd859, 0x1e03: 0xd879, 0x1e04: 0xd899, 0x1e05: 0xd8b9, - 0x1e06: 0xd8d9, 0x1e07: 0xd8f9, 0x1e08: 0xd919, 0x1e09: 0x8cdd, 0x1e0a: 0xd939, 0x1e0b: 0xd959, - 0x1e0c: 0xd979, 0x1e0d: 0xd999, 0x1e0e: 0xd9b9, 0x1e0f: 0x8cfd, 0x1e10: 0xd9d9, 0x1e11: 0x8d1d, - 0x1e12: 0x8d3d, 0x1e13: 0xd9f9, 0x1e14: 0xda19, 0x1e15: 0xda19, 0x1e16: 0xda39, 0x1e17: 0x8d5d, - 0x1e18: 0x8d7d, 0x1e19: 0xda59, 0x1e1a: 0xda79, 0x1e1b: 0xda99, 0x1e1c: 0xdab9, 0x1e1d: 0xdad9, - 0x1e1e: 0xdaf9, 0x1e1f: 0xdb19, 0x1e20: 0xdb39, 0x1e21: 0xdb59, 0x1e22: 0xdb79, 0x1e23: 0xdb99, - 0x1e24: 0x8d9d, 0x1e25: 0xdbb9, 0x1e26: 0xdbd9, 0x1e27: 0xdbf9, 0x1e28: 0xdc19, 0x1e29: 0xdbf9, - 0x1e2a: 0xdc39, 0x1e2b: 0xdc59, 0x1e2c: 0xdc79, 0x1e2d: 0xdc99, 0x1e2e: 0xdcb9, 0x1e2f: 0xdcd9, - 0x1e30: 0xdcf9, 0x1e31: 0xdd19, 0x1e32: 0xdd39, 0x1e33: 0xdd59, 0x1e34: 0xdd79, 0x1e35: 0xdd99, - 0x1e36: 0xddb9, 0x1e37: 0xddd9, 0x1e38: 0x8dbd, 0x1e39: 0xddf9, 0x1e3a: 0xde19, 0x1e3b: 0xde39, - 0x1e3c: 0xde59, 0x1e3d: 0xde79, 0x1e3e: 0x8ddd, 0x1e3f: 0xde99, - // Block 0x79, offset 0x1e40 - 0x1e40: 0xe599, 0x1e41: 0xe5b9, 0x1e42: 0xe5d9, 0x1e43: 0xe5f9, 0x1e44: 0xe619, 0x1e45: 0xe639, - 0x1e46: 0x8efd, 0x1e47: 0xe659, 0x1e48: 0xe679, 0x1e49: 0xe699, 0x1e4a: 0xe6b9, 0x1e4b: 0xe6d9, - 0x1e4c: 0xe6f9, 0x1e4d: 0x8f1d, 0x1e4e: 0xe719, 0x1e4f: 0xe739, 0x1e50: 0x8f3d, 0x1e51: 0x8f5d, - 0x1e52: 0xe759, 0x1e53: 0xe779, 0x1e54: 0xe799, 0x1e55: 0xe7b9, 0x1e56: 0xe7d9, 0x1e57: 0xe7f9, - 0x1e58: 0xe819, 0x1e59: 0xe839, 0x1e5a: 0xe859, 0x1e5b: 0x8f7d, 0x1e5c: 0xe879, 0x1e5d: 0x8f9d, - 0x1e5e: 0xe899, 0x1e5f: 0x0040, 0x1e60: 0xe8b9, 0x1e61: 0xe8d9, 0x1e62: 0xe8f9, 0x1e63: 0x8fbd, - 0x1e64: 0xe919, 0x1e65: 0xe939, 0x1e66: 0x8fdd, 0x1e67: 0x8ffd, 0x1e68: 0xe959, 0x1e69: 0xe979, - 0x1e6a: 0xe999, 0x1e6b: 0xe9b9, 0x1e6c: 0xe9d9, 0x1e6d: 0xe9d9, 0x1e6e: 0xe9f9, 0x1e6f: 0xea19, - 0x1e70: 0xea39, 0x1e71: 0xea59, 0x1e72: 0xea79, 0x1e73: 0xea99, 0x1e74: 0xeab9, 0x1e75: 0x901d, - 0x1e76: 0xead9, 0x1e77: 0x903d, 0x1e78: 0xeaf9, 0x1e79: 0x905d, 0x1e7a: 0xeb19, 0x1e7b: 0x907d, - 0x1e7c: 0x909d, 0x1e7d: 0x90bd, 0x1e7e: 0xeb39, 0x1e7f: 0xeb59, - // Block 0x7a, offset 0x1e80 - 0x1e80: 0xeb79, 0x1e81: 0x90dd, 0x1e82: 0x90fd, 0x1e83: 0x911d, 0x1e84: 0x913d, 0x1e85: 0xeb99, - 0x1e86: 0xebb9, 0x1e87: 0xebb9, 0x1e88: 0xebd9, 0x1e89: 0xebf9, 0x1e8a: 0xec19, 0x1e8b: 0xec39, - 0x1e8c: 0xec59, 0x1e8d: 0x915d, 0x1e8e: 0xec79, 0x1e8f: 0xec99, 0x1e90: 0xecb9, 0x1e91: 0xecd9, - 0x1e92: 0x917d, 0x1e93: 0xecf9, 0x1e94: 0x919d, 0x1e95: 0x91bd, 0x1e96: 0xed19, 0x1e97: 0xed39, - 0x1e98: 0xed59, 0x1e99: 0xed79, 0x1e9a: 0xed99, 0x1e9b: 0xedb9, 0x1e9c: 0x91dd, 0x1e9d: 0x91fd, - 0x1e9e: 0x921d, 0x1e9f: 0x0040, 0x1ea0: 0xedd9, 0x1ea1: 0x923d, 0x1ea2: 0xedf9, 0x1ea3: 0xee19, - 0x1ea4: 0xee39, 0x1ea5: 0x925d, 0x1ea6: 0xee59, 0x1ea7: 0xee79, 0x1ea8: 0xee99, 0x1ea9: 0xeeb9, - 0x1eaa: 0xeed9, 0x1eab: 0x927d, 0x1eac: 0xeef9, 0x1ead: 0xef19, 0x1eae: 0xef39, 0x1eaf: 0xef59, - 0x1eb0: 0xef79, 0x1eb1: 0xef99, 0x1eb2: 0x929d, 0x1eb3: 0x92bd, 0x1eb4: 0xefb9, 0x1eb5: 0x92dd, - 0x1eb6: 0xefd9, 0x1eb7: 0x92fd, 0x1eb8: 0xeff9, 0x1eb9: 0xf019, 0x1eba: 0xf039, 0x1ebb: 0x931d, - 0x1ebc: 0x933d, 0x1ebd: 0xf059, 0x1ebe: 0x935d, 0x1ebf: 0xf079, - // Block 0x7b, offset 0x1ec0 - 0x1ec0: 0xf6b9, 0x1ec1: 0xf6d9, 0x1ec2: 0xf6f9, 0x1ec3: 0xf719, 0x1ec4: 0xf739, 0x1ec5: 0x951d, - 0x1ec6: 0xf759, 0x1ec7: 0xf779, 0x1ec8: 0xf799, 0x1ec9: 0xf7b9, 0x1eca: 0xf7d9, 0x1ecb: 0x953d, - 0x1ecc: 0x955d, 0x1ecd: 0xf7f9, 0x1ece: 0xf819, 0x1ecf: 0xf839, 0x1ed0: 0xf859, 0x1ed1: 0xf879, - 0x1ed2: 0xf899, 0x1ed3: 0x957d, 0x1ed4: 0xf8b9, 0x1ed5: 0xf8d9, 0x1ed6: 0xf8f9, 0x1ed7: 0xf919, - 0x1ed8: 0x959d, 0x1ed9: 0x95bd, 0x1eda: 0xf939, 0x1edb: 0xf959, 0x1edc: 0xf979, 0x1edd: 0x95dd, - 0x1ede: 0xf999, 0x1edf: 0xf9b9, 0x1ee0: 0x6815, 0x1ee1: 0x95fd, 0x1ee2: 0xf9d9, 0x1ee3: 0xf9f9, - 0x1ee4: 0xfa19, 0x1ee5: 0x961d, 0x1ee6: 0xfa39, 0x1ee7: 0xfa59, 0x1ee8: 0xfa79, 0x1ee9: 0xfa99, - 0x1eea: 0xfab9, 0x1eeb: 0xfad9, 0x1eec: 0xfaf9, 0x1eed: 0x963d, 0x1eee: 0xfb19, 0x1eef: 0xfb39, - 0x1ef0: 0xfb59, 0x1ef1: 0x965d, 0x1ef2: 0xfb79, 0x1ef3: 0xfb99, 0x1ef4: 0xfbb9, 0x1ef5: 0xfbd9, - 0x1ef6: 0x7b35, 0x1ef7: 0x967d, 0x1ef8: 0xfbf9, 0x1ef9: 0xfc19, 0x1efa: 0xfc39, 0x1efb: 0x969d, - 0x1efc: 0xfc59, 0x1efd: 0x96bd, 0x1efe: 0xfc79, 0x1eff: 0xfc79, - // Block 0x7c, offset 0x1f00 - 0x1f00: 0xfc99, 0x1f01: 0x96dd, 0x1f02: 0xfcb9, 0x1f03: 0xfcd9, 0x1f04: 0xfcf9, 0x1f05: 0xfd19, - 0x1f06: 0xfd39, 0x1f07: 0xfd59, 0x1f08: 0xfd79, 0x1f09: 0x96fd, 0x1f0a: 0xfd99, 0x1f0b: 0xfdb9, - 0x1f0c: 0xfdd9, 0x1f0d: 0xfdf9, 0x1f0e: 0xfe19, 0x1f0f: 0xfe39, 0x1f10: 0x971d, 0x1f11: 0xfe59, - 0x1f12: 0x973d, 0x1f13: 0x975d, 0x1f14: 0x977d, 0x1f15: 0xfe79, 0x1f16: 0xfe99, 0x1f17: 0xfeb9, - 0x1f18: 0xfed9, 0x1f19: 0xfef9, 0x1f1a: 0xff19, 0x1f1b: 0xff39, 0x1f1c: 0xff59, 0x1f1d: 0x979d, - 0x1f1e: 0x0040, 0x1f1f: 0x0040, 0x1f20: 0x0040, 0x1f21: 0x0040, 0x1f22: 0x0040, 0x1f23: 0x0040, - 0x1f24: 0x0040, 0x1f25: 0x0040, 0x1f26: 0x0040, 0x1f27: 0x0040, 0x1f28: 0x0040, 0x1f29: 0x0040, - 0x1f2a: 0x0040, 0x1f2b: 0x0040, 0x1f2c: 0x0040, 0x1f2d: 0x0040, 0x1f2e: 0x0040, 0x1f2f: 0x0040, - 0x1f30: 0x0040, 0x1f31: 0x0040, 0x1f32: 0x0040, 0x1f33: 0x0040, 0x1f34: 0x0040, 0x1f35: 0x0040, - 0x1f36: 0x0040, 0x1f37: 0x0040, 0x1f38: 0x0040, 0x1f39: 0x0040, 0x1f3a: 0x0040, 0x1f3b: 0x0040, - 0x1f3c: 0x0040, 0x1f3d: 0x0040, 0x1f3e: 0x0040, 0x1f3f: 0x0040, -} - -// idnaIndex: 35 blocks, 2240 entries, 4480 bytes -// Block 0 is the zero block. -var idnaIndex = [2240]uint16{ - // Block 0x0, offset 0x0 - // Block 0x1, offset 0x40 - // Block 0x2, offset 0x80 - // Block 0x3, offset 0xc0 - 0xc2: 0x01, 0xc3: 0x7b, 0xc4: 0x02, 0xc5: 0x03, 0xc6: 0x04, 0xc7: 0x05, - 0xc8: 0x06, 0xc9: 0x7c, 0xca: 0x7d, 0xcb: 0x07, 0xcc: 0x7e, 0xcd: 0x08, 0xce: 0x09, 0xcf: 0x0a, - 0xd0: 0x7f, 0xd1: 0x0b, 0xd2: 0x0c, 0xd3: 0x0d, 0xd4: 0x0e, 0xd5: 0x80, 0xd6: 0x81, 0xd7: 0x82, - 0xd8: 0x0f, 0xd9: 0x83, 0xda: 0x84, 0xdb: 0x10, 0xdc: 0x11, 0xdd: 0x85, 0xde: 0x86, 0xdf: 0x87, - 0xe0: 0x02, 0xe1: 0x03, 0xe2: 0x04, 0xe3: 0x05, 0xe4: 0x06, 0xe5: 0x07, 0xe6: 0x07, 0xe7: 0x07, - 0xe8: 0x07, 0xe9: 0x08, 0xea: 0x09, 0xeb: 0x07, 0xec: 0x07, 0xed: 0x0a, 0xee: 0x0b, 0xef: 0x0c, - 0xf0: 0x1c, 0xf1: 0x1d, 0xf2: 0x1d, 0xf3: 0x1f, 0xf4: 0x20, - // Block 0x4, offset 0x100 - 0x120: 0x88, 0x121: 0x89, 0x122: 0x8a, 0x123: 0x8b, 0x124: 0x8c, 0x125: 0x12, 0x126: 0x13, 0x127: 0x14, - 0x128: 0x15, 0x129: 0x16, 0x12a: 0x17, 0x12b: 0x18, 0x12c: 0x19, 0x12d: 0x1a, 0x12e: 0x1b, 0x12f: 0x8d, - 0x130: 0x8e, 0x131: 0x1c, 0x132: 0x1d, 0x133: 0x1e, 0x134: 0x8f, 0x135: 0x1f, 0x136: 0x90, 0x137: 0x91, - 0x138: 0x92, 0x139: 0x93, 0x13a: 0x20, 0x13b: 0x94, 0x13c: 0x95, 0x13d: 0x21, 0x13e: 0x22, 0x13f: 0x96, - // Block 0x5, offset 0x140 - 0x140: 0x97, 0x141: 0x98, 0x142: 0x99, 0x143: 0x9a, 0x144: 0x9b, 0x145: 0x9c, 0x146: 0x9b, 0x147: 0x9b, - 0x148: 0x9d, 0x149: 0x9e, 0x14a: 0x9f, 0x14b: 0xa0, 0x14c: 0xa1, 0x14d: 0xa2, 0x14e: 0xa3, 0x14f: 0xa4, - 0x150: 0xa5, 0x151: 0x9d, 0x152: 0x9d, 0x153: 0x9d, 0x154: 0x9d, 0x155: 0x9d, 0x156: 0x9d, 0x157: 0x9d, - 0x158: 0x9d, 0x159: 0xa6, 0x15a: 0xa7, 0x15b: 0xa8, 0x15c: 0xa9, 0x15d: 0xaa, 0x15e: 0xab, 0x15f: 0xac, - 0x160: 0xad, 0x161: 0xae, 0x162: 0xaf, 0x163: 0xb0, 0x164: 0xb1, 0x165: 0xb2, 0x166: 0xb3, 0x167: 0xb4, - 0x168: 0xb5, 0x169: 0xb6, 0x16a: 0xb7, 0x16b: 0xb8, 0x16c: 0xb9, 0x16d: 0xba, 0x16e: 0xbb, 0x16f: 0xbc, - 0x170: 0xbd, 0x171: 0xbe, 0x172: 0xbf, 0x173: 0xc0, 0x174: 0x23, 0x175: 0x24, 0x176: 0x25, 0x177: 0xc1, - 0x178: 0x26, 0x179: 0x26, 0x17a: 0x27, 0x17b: 0x26, 0x17c: 0xc2, 0x17d: 0x28, 0x17e: 0x29, 0x17f: 0x2a, - // Block 0x6, offset 0x180 - 0x180: 0x2b, 0x181: 0x2c, 0x182: 0x2d, 0x183: 0xc3, 0x184: 0x2e, 0x185: 0x2f, 0x186: 0xc4, 0x187: 0x9b, - 0x188: 0xc5, 0x189: 0xc6, 0x18a: 0x9b, 0x18b: 0x9b, 0x18c: 0xc7, 0x18d: 0x9b, 0x18e: 0x9b, 0x18f: 0xc8, - 0x190: 0xc9, 0x191: 0x30, 0x192: 0x31, 0x193: 0x32, 0x194: 0x9b, 0x195: 0x9b, 0x196: 0x9b, 0x197: 0x9b, - 0x198: 0x9b, 0x199: 0x9b, 0x19a: 0x9b, 0x19b: 0x9b, 0x19c: 0x9b, 0x19d: 0x9b, 0x19e: 0x9b, 0x19f: 0x9b, - 0x1a0: 0x9b, 0x1a1: 0x9b, 0x1a2: 0x9b, 0x1a3: 0x9b, 0x1a4: 0x9b, 0x1a5: 0x9b, 0x1a6: 0x9b, 0x1a7: 0x9b, - 0x1a8: 0xca, 0x1a9: 0xcb, 0x1aa: 0x9b, 0x1ab: 0xcc, 0x1ac: 0x9b, 0x1ad: 0xcd, 0x1ae: 0xce, 0x1af: 0xcf, - 0x1b0: 0xd0, 0x1b1: 0x33, 0x1b2: 0x26, 0x1b3: 0x34, 0x1b4: 0xd1, 0x1b5: 0xd2, 0x1b6: 0xd3, 0x1b7: 0xd4, - 0x1b8: 0xd5, 0x1b9: 0xd6, 0x1ba: 0xd7, 0x1bb: 0xd8, 0x1bc: 0xd9, 0x1bd: 0xda, 0x1be: 0xdb, 0x1bf: 0x35, - // Block 0x7, offset 0x1c0 - 0x1c0: 0x36, 0x1c1: 0xdc, 0x1c2: 0xdd, 0x1c3: 0xde, 0x1c4: 0xdf, 0x1c5: 0x37, 0x1c6: 0x38, 0x1c7: 0xe0, - 0x1c8: 0xe1, 0x1c9: 0x39, 0x1ca: 0x3a, 0x1cb: 0x3b, 0x1cc: 0x3c, 0x1cd: 0x3d, 0x1ce: 0x3e, 0x1cf: 0x3f, - 0x1d0: 0x9d, 0x1d1: 0x9d, 0x1d2: 0x9d, 0x1d3: 0x9d, 0x1d4: 0x9d, 0x1d5: 0x9d, 0x1d6: 0x9d, 0x1d7: 0x9d, - 0x1d8: 0x9d, 0x1d9: 0x9d, 0x1da: 0x9d, 0x1db: 0x9d, 0x1dc: 0x9d, 0x1dd: 0x9d, 0x1de: 0x9d, 0x1df: 0x9d, - 0x1e0: 0x9d, 0x1e1: 0x9d, 0x1e2: 0x9d, 0x1e3: 0x9d, 0x1e4: 0x9d, 0x1e5: 0x9d, 0x1e6: 0x9d, 0x1e7: 0x9d, - 0x1e8: 0x9d, 0x1e9: 0x9d, 0x1ea: 0x9d, 0x1eb: 0x9d, 0x1ec: 0x9d, 0x1ed: 0x9d, 0x1ee: 0x9d, 0x1ef: 0x9d, - 0x1f0: 0x9d, 0x1f1: 0x9d, 0x1f2: 0x9d, 0x1f3: 0x9d, 0x1f4: 0x9d, 0x1f5: 0x9d, 0x1f6: 0x9d, 0x1f7: 0x9d, - 0x1f8: 0x9d, 0x1f9: 0x9d, 0x1fa: 0x9d, 0x1fb: 0x9d, 0x1fc: 0x9d, 0x1fd: 0x9d, 0x1fe: 0x9d, 0x1ff: 0x9d, - // Block 0x8, offset 0x200 - 0x200: 0x9d, 0x201: 0x9d, 0x202: 0x9d, 0x203: 0x9d, 0x204: 0x9d, 0x205: 0x9d, 0x206: 0x9d, 0x207: 0x9d, - 0x208: 0x9d, 0x209: 0x9d, 0x20a: 0x9d, 0x20b: 0x9d, 0x20c: 0x9d, 0x20d: 0x9d, 0x20e: 0x9d, 0x20f: 0x9d, - 0x210: 0x9d, 0x211: 0x9d, 0x212: 0x9d, 0x213: 0x9d, 0x214: 0x9d, 0x215: 0x9d, 0x216: 0x9d, 0x217: 0x9d, - 0x218: 0x9d, 0x219: 0x9d, 0x21a: 0x9d, 0x21b: 0x9d, 0x21c: 0x9d, 0x21d: 0x9d, 0x21e: 0x9d, 0x21f: 0x9d, - 0x220: 0x9d, 0x221: 0x9d, 0x222: 0x9d, 0x223: 0x9d, 0x224: 0x9d, 0x225: 0x9d, 0x226: 0x9d, 0x227: 0x9d, - 0x228: 0x9d, 0x229: 0x9d, 0x22a: 0x9d, 0x22b: 0x9d, 0x22c: 0x9d, 0x22d: 0x9d, 0x22e: 0x9d, 0x22f: 0x9d, - 0x230: 0x9d, 0x231: 0x9d, 0x232: 0x9d, 0x233: 0x9d, 0x234: 0x9d, 0x235: 0x9d, 0x236: 0xb0, 0x237: 0x9b, - 0x238: 0x9d, 0x239: 0x9d, 0x23a: 0x9d, 0x23b: 0x9d, 0x23c: 0x9d, 0x23d: 0x9d, 0x23e: 0x9d, 0x23f: 0x9d, - // Block 0x9, offset 0x240 - 0x240: 0x9d, 0x241: 0x9d, 0x242: 0x9d, 0x243: 0x9d, 0x244: 0x9d, 0x245: 0x9d, 0x246: 0x9d, 0x247: 0x9d, - 0x248: 0x9d, 0x249: 0x9d, 0x24a: 0x9d, 0x24b: 0x9d, 0x24c: 0x9d, 0x24d: 0x9d, 0x24e: 0x9d, 0x24f: 0x9d, - 0x250: 0x9d, 0x251: 0x9d, 0x252: 0x9d, 0x253: 0x9d, 0x254: 0x9d, 0x255: 0x9d, 0x256: 0x9d, 0x257: 0x9d, - 0x258: 0x9d, 0x259: 0x9d, 0x25a: 0x9d, 0x25b: 0x9d, 0x25c: 0x9d, 0x25d: 0x9d, 0x25e: 0x9d, 0x25f: 0x9d, - 0x260: 0x9d, 0x261: 0x9d, 0x262: 0x9d, 0x263: 0x9d, 0x264: 0x9d, 0x265: 0x9d, 0x266: 0x9d, 0x267: 0x9d, - 0x268: 0x9d, 0x269: 0x9d, 0x26a: 0x9d, 0x26b: 0x9d, 0x26c: 0x9d, 0x26d: 0x9d, 0x26e: 0x9d, 0x26f: 0x9d, - 0x270: 0x9d, 0x271: 0x9d, 0x272: 0x9d, 0x273: 0x9d, 0x274: 0x9d, 0x275: 0x9d, 0x276: 0x9d, 0x277: 0x9d, - 0x278: 0x9d, 0x279: 0x9d, 0x27a: 0x9d, 0x27b: 0x9d, 0x27c: 0x9d, 0x27d: 0x9d, 0x27e: 0x9d, 0x27f: 0x9d, - // Block 0xa, offset 0x280 - 0x280: 0x9d, 0x281: 0x9d, 0x282: 0x9d, 0x283: 0x9d, 0x284: 0x9d, 0x285: 0x9d, 0x286: 0x9d, 0x287: 0x9d, - 0x288: 0x9d, 0x289: 0x9d, 0x28a: 0x9d, 0x28b: 0x9d, 0x28c: 0x9d, 0x28d: 0x9d, 0x28e: 0x9d, 0x28f: 0x9d, - 0x290: 0x9d, 0x291: 0x9d, 0x292: 0x9d, 0x293: 0x9d, 0x294: 0x9d, 0x295: 0x9d, 0x296: 0x9d, 0x297: 0x9d, - 0x298: 0x9d, 0x299: 0x9d, 0x29a: 0x9d, 0x29b: 0x9d, 0x29c: 0x9d, 0x29d: 0x9d, 0x29e: 0x9d, 0x29f: 0x9d, - 0x2a0: 0x9d, 0x2a1: 0x9d, 0x2a2: 0x9d, 0x2a3: 0x9d, 0x2a4: 0x9d, 0x2a5: 0x9d, 0x2a6: 0x9d, 0x2a7: 0x9d, - 0x2a8: 0x9d, 0x2a9: 0x9d, 0x2aa: 0x9d, 0x2ab: 0x9d, 0x2ac: 0x9d, 0x2ad: 0x9d, 0x2ae: 0x9d, 0x2af: 0x9d, - 0x2b0: 0x9d, 0x2b1: 0x9d, 0x2b2: 0x9d, 0x2b3: 0x9d, 0x2b4: 0x9d, 0x2b5: 0x9d, 0x2b6: 0x9d, 0x2b7: 0x9d, - 0x2b8: 0x9d, 0x2b9: 0x9d, 0x2ba: 0x9d, 0x2bb: 0x9d, 0x2bc: 0x9d, 0x2bd: 0x9d, 0x2be: 0x9d, 0x2bf: 0xe2, - // Block 0xb, offset 0x2c0 - 0x2c0: 0x9d, 0x2c1: 0x9d, 0x2c2: 0x9d, 0x2c3: 0x9d, 0x2c4: 0x9d, 0x2c5: 0x9d, 0x2c6: 0x9d, 0x2c7: 0x9d, - 0x2c8: 0x9d, 0x2c9: 0x9d, 0x2ca: 0x9d, 0x2cb: 0x9d, 0x2cc: 0x9d, 0x2cd: 0x9d, 0x2ce: 0x9d, 0x2cf: 0x9d, - 0x2d0: 0x9d, 0x2d1: 0x9d, 0x2d2: 0xe3, 0x2d3: 0xe4, 0x2d4: 0x9d, 0x2d5: 0x9d, 0x2d6: 0x9d, 0x2d7: 0x9d, - 0x2d8: 0xe5, 0x2d9: 0x40, 0x2da: 0x41, 0x2db: 0xe6, 0x2dc: 0x42, 0x2dd: 0x43, 0x2de: 0x44, 0x2df: 0xe7, - 0x2e0: 0xe8, 0x2e1: 0xe9, 0x2e2: 0xea, 0x2e3: 0xeb, 0x2e4: 0xec, 0x2e5: 0xed, 0x2e6: 0xee, 0x2e7: 0xef, - 0x2e8: 0xf0, 0x2e9: 0xf1, 0x2ea: 0xf2, 0x2eb: 0xf3, 0x2ec: 0xf4, 0x2ed: 0xf5, 0x2ee: 0xf6, 0x2ef: 0xf7, - 0x2f0: 0x9d, 0x2f1: 0x9d, 0x2f2: 0x9d, 0x2f3: 0x9d, 0x2f4: 0x9d, 0x2f5: 0x9d, 0x2f6: 0x9d, 0x2f7: 0x9d, - 0x2f8: 0x9d, 0x2f9: 0x9d, 0x2fa: 0x9d, 0x2fb: 0x9d, 0x2fc: 0x9d, 0x2fd: 0x9d, 0x2fe: 0x9d, 0x2ff: 0x9d, - // Block 0xc, offset 0x300 - 0x300: 0x9d, 0x301: 0x9d, 0x302: 0x9d, 0x303: 0x9d, 0x304: 0x9d, 0x305: 0x9d, 0x306: 0x9d, 0x307: 0x9d, - 0x308: 0x9d, 0x309: 0x9d, 0x30a: 0x9d, 0x30b: 0x9d, 0x30c: 0x9d, 0x30d: 0x9d, 0x30e: 0x9d, 0x30f: 0x9d, - 0x310: 0x9d, 0x311: 0x9d, 0x312: 0x9d, 0x313: 0x9d, 0x314: 0x9d, 0x315: 0x9d, 0x316: 0x9d, 0x317: 0x9d, - 0x318: 0x9d, 0x319: 0x9d, 0x31a: 0x9d, 0x31b: 0x9d, 0x31c: 0x9d, 0x31d: 0x9d, 0x31e: 0xf8, 0x31f: 0xf9, - // Block 0xd, offset 0x340 - 0x340: 0xb8, 0x341: 0xb8, 0x342: 0xb8, 0x343: 0xb8, 0x344: 0xb8, 0x345: 0xb8, 0x346: 0xb8, 0x347: 0xb8, - 0x348: 0xb8, 0x349: 0xb8, 0x34a: 0xb8, 0x34b: 0xb8, 0x34c: 0xb8, 0x34d: 0xb8, 0x34e: 0xb8, 0x34f: 0xb8, - 0x350: 0xb8, 0x351: 0xb8, 0x352: 0xb8, 0x353: 0xb8, 0x354: 0xb8, 0x355: 0xb8, 0x356: 0xb8, 0x357: 0xb8, - 0x358: 0xb8, 0x359: 0xb8, 0x35a: 0xb8, 0x35b: 0xb8, 0x35c: 0xb8, 0x35d: 0xb8, 0x35e: 0xb8, 0x35f: 0xb8, - 0x360: 0xb8, 0x361: 0xb8, 0x362: 0xb8, 0x363: 0xb8, 0x364: 0xb8, 0x365: 0xb8, 0x366: 0xb8, 0x367: 0xb8, - 0x368: 0xb8, 0x369: 0xb8, 0x36a: 0xb8, 0x36b: 0xb8, 0x36c: 0xb8, 0x36d: 0xb8, 0x36e: 0xb8, 0x36f: 0xb8, - 0x370: 0xb8, 0x371: 0xb8, 0x372: 0xb8, 0x373: 0xb8, 0x374: 0xb8, 0x375: 0xb8, 0x376: 0xb8, 0x377: 0xb8, - 0x378: 0xb8, 0x379: 0xb8, 0x37a: 0xb8, 0x37b: 0xb8, 0x37c: 0xb8, 0x37d: 0xb8, 0x37e: 0xb8, 0x37f: 0xb8, - // Block 0xe, offset 0x380 - 0x380: 0xb8, 0x381: 0xb8, 0x382: 0xb8, 0x383: 0xb8, 0x384: 0xb8, 0x385: 0xb8, 0x386: 0xb8, 0x387: 0xb8, - 0x388: 0xb8, 0x389: 0xb8, 0x38a: 0xb8, 0x38b: 0xb8, 0x38c: 0xb8, 0x38d: 0xb8, 0x38e: 0xb8, 0x38f: 0xb8, - 0x390: 0xb8, 0x391: 0xb8, 0x392: 0xb8, 0x393: 0xb8, 0x394: 0xb8, 0x395: 0xb8, 0x396: 0xb8, 0x397: 0xb8, - 0x398: 0xb8, 0x399: 0xb8, 0x39a: 0xb8, 0x39b: 0xb8, 0x39c: 0xb8, 0x39d: 0xb8, 0x39e: 0xb8, 0x39f: 0xb8, - 0x3a0: 0xb8, 0x3a1: 0xb8, 0x3a2: 0xb8, 0x3a3: 0xb8, 0x3a4: 0xfa, 0x3a5: 0xfb, 0x3a6: 0xfc, 0x3a7: 0xfd, - 0x3a8: 0x45, 0x3a9: 0xfe, 0x3aa: 0xff, 0x3ab: 0x46, 0x3ac: 0x47, 0x3ad: 0x48, 0x3ae: 0x49, 0x3af: 0x4a, - 0x3b0: 0x100, 0x3b1: 0x4b, 0x3b2: 0x4c, 0x3b3: 0x4d, 0x3b4: 0x4e, 0x3b5: 0x4f, 0x3b6: 0x101, 0x3b7: 0x50, - 0x3b8: 0x51, 0x3b9: 0x52, 0x3ba: 0x53, 0x3bb: 0x54, 0x3bc: 0x55, 0x3bd: 0x56, 0x3be: 0x57, 0x3bf: 0x58, - // Block 0xf, offset 0x3c0 - 0x3c0: 0x102, 0x3c1: 0x103, 0x3c2: 0x9d, 0x3c3: 0x104, 0x3c4: 0x105, 0x3c5: 0x9b, 0x3c6: 0x106, 0x3c7: 0x107, - 0x3c8: 0xb8, 0x3c9: 0xb8, 0x3ca: 0x108, 0x3cb: 0x109, 0x3cc: 0x10a, 0x3cd: 0x10b, 0x3ce: 0x10c, 0x3cf: 0x10d, - 0x3d0: 0x10e, 0x3d1: 0x9d, 0x3d2: 0x10f, 0x3d3: 0x110, 0x3d4: 0x111, 0x3d5: 0x112, 0x3d6: 0xb8, 0x3d7: 0xb8, - 0x3d8: 0x9d, 0x3d9: 0x9d, 0x3da: 0x9d, 0x3db: 0x9d, 0x3dc: 0x113, 0x3dd: 0x114, 0x3de: 0xb8, 0x3df: 0xb8, - 0x3e0: 0x115, 0x3e1: 0x116, 0x3e2: 0x117, 0x3e3: 0x118, 0x3e4: 0x119, 0x3e5: 0xb8, 0x3e6: 0x11a, 0x3e7: 0x11b, - 0x3e8: 0x11c, 0x3e9: 0x11d, 0x3ea: 0x11e, 0x3eb: 0x59, 0x3ec: 0x11f, 0x3ed: 0x120, 0x3ee: 0x5a, 0x3ef: 0xb8, - 0x3f0: 0x9d, 0x3f1: 0x121, 0x3f2: 0x122, 0x3f3: 0x123, 0x3f4: 0xb8, 0x3f5: 0xb8, 0x3f6: 0xb8, 0x3f7: 0xb8, - 0x3f8: 0xb8, 0x3f9: 0x124, 0x3fa: 0xb8, 0x3fb: 0xb8, 0x3fc: 0xb8, 0x3fd: 0xb8, 0x3fe: 0xb8, 0x3ff: 0xb8, - // Block 0x10, offset 0x400 - 0x400: 0x125, 0x401: 0x126, 0x402: 0x127, 0x403: 0x128, 0x404: 0x129, 0x405: 0x12a, 0x406: 0x12b, 0x407: 0x12c, - 0x408: 0x12d, 0x409: 0xb8, 0x40a: 0x12e, 0x40b: 0x12f, 0x40c: 0x5b, 0x40d: 0x5c, 0x40e: 0xb8, 0x40f: 0xb8, - 0x410: 0x130, 0x411: 0x131, 0x412: 0x132, 0x413: 0x133, 0x414: 0xb8, 0x415: 0xb8, 0x416: 0x134, 0x417: 0x135, - 0x418: 0x136, 0x419: 0x137, 0x41a: 0x138, 0x41b: 0x139, 0x41c: 0x13a, 0x41d: 0xb8, 0x41e: 0xb8, 0x41f: 0xb8, - 0x420: 0xb8, 0x421: 0xb8, 0x422: 0x13b, 0x423: 0x13c, 0x424: 0xb8, 0x425: 0xb8, 0x426: 0xb8, 0x427: 0xb8, - 0x428: 0xb8, 0x429: 0xb8, 0x42a: 0xb8, 0x42b: 0x13d, 0x42c: 0xb8, 0x42d: 0xb8, 0x42e: 0xb8, 0x42f: 0xb8, - 0x430: 0x13e, 0x431: 0x13f, 0x432: 0x140, 0x433: 0xb8, 0x434: 0xb8, 0x435: 0xb8, 0x436: 0xb8, 0x437: 0xb8, - 0x438: 0xb8, 0x439: 0xb8, 0x43a: 0xb8, 0x43b: 0xb8, 0x43c: 0xb8, 0x43d: 0xb8, 0x43e: 0xb8, 0x43f: 0xb8, - // Block 0x11, offset 0x440 - 0x440: 0x9d, 0x441: 0x9d, 0x442: 0x9d, 0x443: 0x9d, 0x444: 0x9d, 0x445: 0x9d, 0x446: 0x9d, 0x447: 0x9d, - 0x448: 0x9d, 0x449: 0x9d, 0x44a: 0x9d, 0x44b: 0x9d, 0x44c: 0x9d, 0x44d: 0x9d, 0x44e: 0x141, 0x44f: 0xb8, - 0x450: 0x9b, 0x451: 0x142, 0x452: 0x9d, 0x453: 0x9d, 0x454: 0x9d, 0x455: 0x143, 0x456: 0xb8, 0x457: 0xb8, - 0x458: 0xb8, 0x459: 0xb8, 0x45a: 0xb8, 0x45b: 0xb8, 0x45c: 0xb8, 0x45d: 0xb8, 0x45e: 0xb8, 0x45f: 0xb8, - 0x460: 0xb8, 0x461: 0xb8, 0x462: 0xb8, 0x463: 0xb8, 0x464: 0xb8, 0x465: 0xb8, 0x466: 0xb8, 0x467: 0xb8, - 0x468: 0xb8, 0x469: 0xb8, 0x46a: 0xb8, 0x46b: 0xb8, 0x46c: 0xb8, 0x46d: 0xb8, 0x46e: 0xb8, 0x46f: 0xb8, - 0x470: 0xb8, 0x471: 0xb8, 0x472: 0xb8, 0x473: 0xb8, 0x474: 0xb8, 0x475: 0xb8, 0x476: 0xb8, 0x477: 0xb8, - 0x478: 0xb8, 0x479: 0xb8, 0x47a: 0xb8, 0x47b: 0xb8, 0x47c: 0xb8, 0x47d: 0xb8, 0x47e: 0xb8, 0x47f: 0xb8, - // Block 0x12, offset 0x480 - 0x480: 0x9d, 0x481: 0x9d, 0x482: 0x9d, 0x483: 0x9d, 0x484: 0x9d, 0x485: 0x9d, 0x486: 0x9d, 0x487: 0x9d, - 0x488: 0x9d, 0x489: 0x9d, 0x48a: 0x9d, 0x48b: 0x9d, 0x48c: 0x9d, 0x48d: 0x9d, 0x48e: 0x9d, 0x48f: 0x9d, - 0x490: 0x144, 0x491: 0xb8, 0x492: 0xb8, 0x493: 0xb8, 0x494: 0xb8, 0x495: 0xb8, 0x496: 0xb8, 0x497: 0xb8, - 0x498: 0xb8, 0x499: 0xb8, 0x49a: 0xb8, 0x49b: 0xb8, 0x49c: 0xb8, 0x49d: 0xb8, 0x49e: 0xb8, 0x49f: 0xb8, - 0x4a0: 0xb8, 0x4a1: 0xb8, 0x4a2: 0xb8, 0x4a3: 0xb8, 0x4a4: 0xb8, 0x4a5: 0xb8, 0x4a6: 0xb8, 0x4a7: 0xb8, - 0x4a8: 0xb8, 0x4a9: 0xb8, 0x4aa: 0xb8, 0x4ab: 0xb8, 0x4ac: 0xb8, 0x4ad: 0xb8, 0x4ae: 0xb8, 0x4af: 0xb8, - 0x4b0: 0xb8, 0x4b1: 0xb8, 0x4b2: 0xb8, 0x4b3: 0xb8, 0x4b4: 0xb8, 0x4b5: 0xb8, 0x4b6: 0xb8, 0x4b7: 0xb8, - 0x4b8: 0xb8, 0x4b9: 0xb8, 0x4ba: 0xb8, 0x4bb: 0xb8, 0x4bc: 0xb8, 0x4bd: 0xb8, 0x4be: 0xb8, 0x4bf: 0xb8, - // Block 0x13, offset 0x4c0 - 0x4c0: 0xb8, 0x4c1: 0xb8, 0x4c2: 0xb8, 0x4c3: 0xb8, 0x4c4: 0xb8, 0x4c5: 0xb8, 0x4c6: 0xb8, 0x4c7: 0xb8, - 0x4c8: 0xb8, 0x4c9: 0xb8, 0x4ca: 0xb8, 0x4cb: 0xb8, 0x4cc: 0xb8, 0x4cd: 0xb8, 0x4ce: 0xb8, 0x4cf: 0xb8, - 0x4d0: 0x9d, 0x4d1: 0x9d, 0x4d2: 0x9d, 0x4d3: 0x9d, 0x4d4: 0x9d, 0x4d5: 0x9d, 0x4d6: 0x9d, 0x4d7: 0x9d, - 0x4d8: 0x9d, 0x4d9: 0x145, 0x4da: 0xb8, 0x4db: 0xb8, 0x4dc: 0xb8, 0x4dd: 0xb8, 0x4de: 0xb8, 0x4df: 0xb8, - 0x4e0: 0xb8, 0x4e1: 0xb8, 0x4e2: 0xb8, 0x4e3: 0xb8, 0x4e4: 0xb8, 0x4e5: 0xb8, 0x4e6: 0xb8, 0x4e7: 0xb8, - 0x4e8: 0xb8, 0x4e9: 0xb8, 0x4ea: 0xb8, 0x4eb: 0xb8, 0x4ec: 0xb8, 0x4ed: 0xb8, 0x4ee: 0xb8, 0x4ef: 0xb8, - 0x4f0: 0xb8, 0x4f1: 0xb8, 0x4f2: 0xb8, 0x4f3: 0xb8, 0x4f4: 0xb8, 0x4f5: 0xb8, 0x4f6: 0xb8, 0x4f7: 0xb8, - 0x4f8: 0xb8, 0x4f9: 0xb8, 0x4fa: 0xb8, 0x4fb: 0xb8, 0x4fc: 0xb8, 0x4fd: 0xb8, 0x4fe: 0xb8, 0x4ff: 0xb8, - // Block 0x14, offset 0x500 - 0x500: 0xb8, 0x501: 0xb8, 0x502: 0xb8, 0x503: 0xb8, 0x504: 0xb8, 0x505: 0xb8, 0x506: 0xb8, 0x507: 0xb8, - 0x508: 0xb8, 0x509: 0xb8, 0x50a: 0xb8, 0x50b: 0xb8, 0x50c: 0xb8, 0x50d: 0xb8, 0x50e: 0xb8, 0x50f: 0xb8, - 0x510: 0xb8, 0x511: 0xb8, 0x512: 0xb8, 0x513: 0xb8, 0x514: 0xb8, 0x515: 0xb8, 0x516: 0xb8, 0x517: 0xb8, - 0x518: 0xb8, 0x519: 0xb8, 0x51a: 0xb8, 0x51b: 0xb8, 0x51c: 0xb8, 0x51d: 0xb8, 0x51e: 0xb8, 0x51f: 0xb8, - 0x520: 0x9d, 0x521: 0x9d, 0x522: 0x9d, 0x523: 0x9d, 0x524: 0x9d, 0x525: 0x9d, 0x526: 0x9d, 0x527: 0x9d, - 0x528: 0x13d, 0x529: 0x146, 0x52a: 0xb8, 0x52b: 0x147, 0x52c: 0x148, 0x52d: 0x149, 0x52e: 0x14a, 0x52f: 0xb8, - 0x530: 0xb8, 0x531: 0xb8, 0x532: 0xb8, 0x533: 0xb8, 0x534: 0xb8, 0x535: 0xb8, 0x536: 0xb8, 0x537: 0xb8, - 0x538: 0xb8, 0x539: 0xb8, 0x53a: 0xb8, 0x53b: 0xb8, 0x53c: 0x9d, 0x53d: 0x14b, 0x53e: 0x14c, 0x53f: 0x14d, - // Block 0x15, offset 0x540 - 0x540: 0x9d, 0x541: 0x9d, 0x542: 0x9d, 0x543: 0x9d, 0x544: 0x9d, 0x545: 0x9d, 0x546: 0x9d, 0x547: 0x9d, - 0x548: 0x9d, 0x549: 0x9d, 0x54a: 0x9d, 0x54b: 0x9d, 0x54c: 0x9d, 0x54d: 0x9d, 0x54e: 0x9d, 0x54f: 0x9d, - 0x550: 0x9d, 0x551: 0x9d, 0x552: 0x9d, 0x553: 0x9d, 0x554: 0x9d, 0x555: 0x9d, 0x556: 0x9d, 0x557: 0x9d, - 0x558: 0x9d, 0x559: 0x9d, 0x55a: 0x9d, 0x55b: 0x9d, 0x55c: 0x9d, 0x55d: 0x9d, 0x55e: 0x9d, 0x55f: 0x14e, - 0x560: 0x9d, 0x561: 0x9d, 0x562: 0x9d, 0x563: 0x9d, 0x564: 0x9d, 0x565: 0x9d, 0x566: 0x9d, 0x567: 0x9d, - 0x568: 0x9d, 0x569: 0x9d, 0x56a: 0x9d, 0x56b: 0x14f, 0x56c: 0xb8, 0x56d: 0xb8, 0x56e: 0xb8, 0x56f: 0xb8, - 0x570: 0xb8, 0x571: 0xb8, 0x572: 0xb8, 0x573: 0xb8, 0x574: 0xb8, 0x575: 0xb8, 0x576: 0xb8, 0x577: 0xb8, - 0x578: 0xb8, 0x579: 0xb8, 0x57a: 0xb8, 0x57b: 0xb8, 0x57c: 0xb8, 0x57d: 0xb8, 0x57e: 0xb8, 0x57f: 0xb8, - // Block 0x16, offset 0x580 - 0x580: 0x150, 0x581: 0xb8, 0x582: 0xb8, 0x583: 0xb8, 0x584: 0xb8, 0x585: 0xb8, 0x586: 0xb8, 0x587: 0xb8, - 0x588: 0xb8, 0x589: 0xb8, 0x58a: 0xb8, 0x58b: 0xb8, 0x58c: 0xb8, 0x58d: 0xb8, 0x58e: 0xb8, 0x58f: 0xb8, - 0x590: 0xb8, 0x591: 0xb8, 0x592: 0xb8, 0x593: 0xb8, 0x594: 0xb8, 0x595: 0xb8, 0x596: 0xb8, 0x597: 0xb8, - 0x598: 0xb8, 0x599: 0xb8, 0x59a: 0xb8, 0x59b: 0xb8, 0x59c: 0xb8, 0x59d: 0xb8, 0x59e: 0xb8, 0x59f: 0xb8, - 0x5a0: 0xb8, 0x5a1: 0xb8, 0x5a2: 0xb8, 0x5a3: 0xb8, 0x5a4: 0xb8, 0x5a5: 0xb8, 0x5a6: 0xb8, 0x5a7: 0xb8, - 0x5a8: 0xb8, 0x5a9: 0xb8, 0x5aa: 0xb8, 0x5ab: 0xb8, 0x5ac: 0xb8, 0x5ad: 0xb8, 0x5ae: 0xb8, 0x5af: 0xb8, - 0x5b0: 0x9d, 0x5b1: 0x151, 0x5b2: 0x152, 0x5b3: 0xb8, 0x5b4: 0xb8, 0x5b5: 0xb8, 0x5b6: 0xb8, 0x5b7: 0xb8, - 0x5b8: 0xb8, 0x5b9: 0xb8, 0x5ba: 0xb8, 0x5bb: 0xb8, 0x5bc: 0xb8, 0x5bd: 0xb8, 0x5be: 0xb8, 0x5bf: 0xb8, - // Block 0x17, offset 0x5c0 - 0x5c0: 0x9b, 0x5c1: 0x9b, 0x5c2: 0x9b, 0x5c3: 0x153, 0x5c4: 0x154, 0x5c5: 0x155, 0x5c6: 0x156, 0x5c7: 0x157, - 0x5c8: 0x9b, 0x5c9: 0x158, 0x5ca: 0xb8, 0x5cb: 0xb8, 0x5cc: 0x9b, 0x5cd: 0x159, 0x5ce: 0xb8, 0x5cf: 0xb8, - 0x5d0: 0x5d, 0x5d1: 0x5e, 0x5d2: 0x5f, 0x5d3: 0x60, 0x5d4: 0x61, 0x5d5: 0x62, 0x5d6: 0x63, 0x5d7: 0x64, - 0x5d8: 0x65, 0x5d9: 0x66, 0x5da: 0x67, 0x5db: 0x68, 0x5dc: 0x69, 0x5dd: 0x6a, 0x5de: 0x6b, 0x5df: 0x6c, - 0x5e0: 0x9b, 0x5e1: 0x9b, 0x5e2: 0x9b, 0x5e3: 0x9b, 0x5e4: 0x9b, 0x5e5: 0x9b, 0x5e6: 0x9b, 0x5e7: 0x9b, - 0x5e8: 0x15a, 0x5e9: 0x15b, 0x5ea: 0x15c, 0x5eb: 0xb8, 0x5ec: 0xb8, 0x5ed: 0xb8, 0x5ee: 0xb8, 0x5ef: 0xb8, - 0x5f0: 0xb8, 0x5f1: 0xb8, 0x5f2: 0xb8, 0x5f3: 0xb8, 0x5f4: 0xb8, 0x5f5: 0xb8, 0x5f6: 0xb8, 0x5f7: 0xb8, - 0x5f8: 0xb8, 0x5f9: 0xb8, 0x5fa: 0xb8, 0x5fb: 0xb8, 0x5fc: 0xb8, 0x5fd: 0xb8, 0x5fe: 0xb8, 0x5ff: 0xb8, - // Block 0x18, offset 0x600 - 0x600: 0x15d, 0x601: 0xb8, 0x602: 0xb8, 0x603: 0xb8, 0x604: 0xb8, 0x605: 0xb8, 0x606: 0xb8, 0x607: 0xb8, - 0x608: 0xb8, 0x609: 0xb8, 0x60a: 0xb8, 0x60b: 0xb8, 0x60c: 0xb8, 0x60d: 0xb8, 0x60e: 0xb8, 0x60f: 0xb8, - 0x610: 0xb8, 0x611: 0xb8, 0x612: 0xb8, 0x613: 0xb8, 0x614: 0xb8, 0x615: 0xb8, 0x616: 0xb8, 0x617: 0xb8, - 0x618: 0xb8, 0x619: 0xb8, 0x61a: 0xb8, 0x61b: 0xb8, 0x61c: 0xb8, 0x61d: 0xb8, 0x61e: 0xb8, 0x61f: 0xb8, - 0x620: 0x9d, 0x621: 0x9d, 0x622: 0x9d, 0x623: 0x15e, 0x624: 0x6d, 0x625: 0x15f, 0x626: 0xb8, 0x627: 0xb8, - 0x628: 0xb8, 0x629: 0xb8, 0x62a: 0xb8, 0x62b: 0xb8, 0x62c: 0xb8, 0x62d: 0xb8, 0x62e: 0xb8, 0x62f: 0xb8, - 0x630: 0xb8, 0x631: 0xb8, 0x632: 0xb8, 0x633: 0xb8, 0x634: 0xb8, 0x635: 0xb8, 0x636: 0xb8, 0x637: 0xb8, - 0x638: 0x6e, 0x639: 0x6f, 0x63a: 0x70, 0x63b: 0x160, 0x63c: 0xb8, 0x63d: 0xb8, 0x63e: 0xb8, 0x63f: 0xb8, - // Block 0x19, offset 0x640 - 0x640: 0x161, 0x641: 0x9b, 0x642: 0x162, 0x643: 0x163, 0x644: 0x71, 0x645: 0x72, 0x646: 0x164, 0x647: 0x165, - 0x648: 0x73, 0x649: 0x166, 0x64a: 0xb8, 0x64b: 0xb8, 0x64c: 0x9b, 0x64d: 0x9b, 0x64e: 0x9b, 0x64f: 0x9b, - 0x650: 0x9b, 0x651: 0x9b, 0x652: 0x9b, 0x653: 0x9b, 0x654: 0x9b, 0x655: 0x9b, 0x656: 0x9b, 0x657: 0x9b, - 0x658: 0x9b, 0x659: 0x9b, 0x65a: 0x9b, 0x65b: 0x167, 0x65c: 0x9b, 0x65d: 0x168, 0x65e: 0x9b, 0x65f: 0x169, - 0x660: 0x16a, 0x661: 0x16b, 0x662: 0x16c, 0x663: 0xb8, 0x664: 0x16d, 0x665: 0x16e, 0x666: 0x16f, 0x667: 0x170, - 0x668: 0xb8, 0x669: 0xb8, 0x66a: 0xb8, 0x66b: 0xb8, 0x66c: 0xb8, 0x66d: 0xb8, 0x66e: 0xb8, 0x66f: 0xb8, - 0x670: 0xb8, 0x671: 0xb8, 0x672: 0xb8, 0x673: 0xb8, 0x674: 0xb8, 0x675: 0xb8, 0x676: 0xb8, 0x677: 0xb8, - 0x678: 0xb8, 0x679: 0xb8, 0x67a: 0xb8, 0x67b: 0xb8, 0x67c: 0xb8, 0x67d: 0xb8, 0x67e: 0xb8, 0x67f: 0xb8, - // Block 0x1a, offset 0x680 - 0x680: 0x9d, 0x681: 0x9d, 0x682: 0x9d, 0x683: 0x9d, 0x684: 0x9d, 0x685: 0x9d, 0x686: 0x9d, 0x687: 0x9d, - 0x688: 0x9d, 0x689: 0x9d, 0x68a: 0x9d, 0x68b: 0x9d, 0x68c: 0x9d, 0x68d: 0x9d, 0x68e: 0x9d, 0x68f: 0x9d, - 0x690: 0x9d, 0x691: 0x9d, 0x692: 0x9d, 0x693: 0x9d, 0x694: 0x9d, 0x695: 0x9d, 0x696: 0x9d, 0x697: 0x9d, - 0x698: 0x9d, 0x699: 0x9d, 0x69a: 0x9d, 0x69b: 0x171, 0x69c: 0x9d, 0x69d: 0x9d, 0x69e: 0x9d, 0x69f: 0x9d, - 0x6a0: 0x9d, 0x6a1: 0x9d, 0x6a2: 0x9d, 0x6a3: 0x9d, 0x6a4: 0x9d, 0x6a5: 0x9d, 0x6a6: 0x9d, 0x6a7: 0x9d, - 0x6a8: 0x9d, 0x6a9: 0x9d, 0x6aa: 0x9d, 0x6ab: 0x9d, 0x6ac: 0x9d, 0x6ad: 0x9d, 0x6ae: 0x9d, 0x6af: 0x9d, - 0x6b0: 0x9d, 0x6b1: 0x9d, 0x6b2: 0x9d, 0x6b3: 0x9d, 0x6b4: 0x9d, 0x6b5: 0x9d, 0x6b6: 0x9d, 0x6b7: 0x9d, - 0x6b8: 0x9d, 0x6b9: 0x9d, 0x6ba: 0x9d, 0x6bb: 0x9d, 0x6bc: 0x9d, 0x6bd: 0x9d, 0x6be: 0x9d, 0x6bf: 0x9d, - // Block 0x1b, offset 0x6c0 - 0x6c0: 0x9d, 0x6c1: 0x9d, 0x6c2: 0x9d, 0x6c3: 0x9d, 0x6c4: 0x9d, 0x6c5: 0x9d, 0x6c6: 0x9d, 0x6c7: 0x9d, - 0x6c8: 0x9d, 0x6c9: 0x9d, 0x6ca: 0x9d, 0x6cb: 0x9d, 0x6cc: 0x9d, 0x6cd: 0x9d, 0x6ce: 0x9d, 0x6cf: 0x9d, - 0x6d0: 0x9d, 0x6d1: 0x9d, 0x6d2: 0x9d, 0x6d3: 0x9d, 0x6d4: 0x9d, 0x6d5: 0x9d, 0x6d6: 0x9d, 0x6d7: 0x9d, - 0x6d8: 0x9d, 0x6d9: 0x9d, 0x6da: 0x9d, 0x6db: 0x9d, 0x6dc: 0x172, 0x6dd: 0x9d, 0x6de: 0x9d, 0x6df: 0x9d, - 0x6e0: 0x173, 0x6e1: 0x9d, 0x6e2: 0x9d, 0x6e3: 0x9d, 0x6e4: 0x9d, 0x6e5: 0x9d, 0x6e6: 0x9d, 0x6e7: 0x9d, - 0x6e8: 0x9d, 0x6e9: 0x9d, 0x6ea: 0x9d, 0x6eb: 0x9d, 0x6ec: 0x9d, 0x6ed: 0x9d, 0x6ee: 0x9d, 0x6ef: 0x9d, - 0x6f0: 0x9d, 0x6f1: 0x9d, 0x6f2: 0x9d, 0x6f3: 0x9d, 0x6f4: 0x9d, 0x6f5: 0x9d, 0x6f6: 0x9d, 0x6f7: 0x9d, - 0x6f8: 0x9d, 0x6f9: 0x9d, 0x6fa: 0x9d, 0x6fb: 0x9d, 0x6fc: 0x9d, 0x6fd: 0x9d, 0x6fe: 0x9d, 0x6ff: 0x9d, - // Block 0x1c, offset 0x700 - 0x700: 0x9d, 0x701: 0x9d, 0x702: 0x9d, 0x703: 0x9d, 0x704: 0x9d, 0x705: 0x9d, 0x706: 0x9d, 0x707: 0x9d, - 0x708: 0x9d, 0x709: 0x9d, 0x70a: 0x9d, 0x70b: 0x9d, 0x70c: 0x9d, 0x70d: 0x9d, 0x70e: 0x9d, 0x70f: 0x9d, - 0x710: 0x9d, 0x711: 0x9d, 0x712: 0x9d, 0x713: 0x9d, 0x714: 0x9d, 0x715: 0x9d, 0x716: 0x9d, 0x717: 0x9d, - 0x718: 0x9d, 0x719: 0x9d, 0x71a: 0x9d, 0x71b: 0x9d, 0x71c: 0x9d, 0x71d: 0x9d, 0x71e: 0x9d, 0x71f: 0x9d, - 0x720: 0x9d, 0x721: 0x9d, 0x722: 0x9d, 0x723: 0x9d, 0x724: 0x9d, 0x725: 0x9d, 0x726: 0x9d, 0x727: 0x9d, - 0x728: 0x9d, 0x729: 0x9d, 0x72a: 0x9d, 0x72b: 0x9d, 0x72c: 0x9d, 0x72d: 0x9d, 0x72e: 0x9d, 0x72f: 0x9d, - 0x730: 0x9d, 0x731: 0x9d, 0x732: 0x9d, 0x733: 0x9d, 0x734: 0x9d, 0x735: 0x9d, 0x736: 0x9d, 0x737: 0x9d, - 0x738: 0x9d, 0x739: 0x9d, 0x73a: 0x174, 0x73b: 0xb8, 0x73c: 0xb8, 0x73d: 0xb8, 0x73e: 0xb8, 0x73f: 0xb8, - // Block 0x1d, offset 0x740 - 0x740: 0xb8, 0x741: 0xb8, 0x742: 0xb8, 0x743: 0xb8, 0x744: 0xb8, 0x745: 0xb8, 0x746: 0xb8, 0x747: 0xb8, - 0x748: 0xb8, 0x749: 0xb8, 0x74a: 0xb8, 0x74b: 0xb8, 0x74c: 0xb8, 0x74d: 0xb8, 0x74e: 0xb8, 0x74f: 0xb8, - 0x750: 0xb8, 0x751: 0xb8, 0x752: 0xb8, 0x753: 0xb8, 0x754: 0xb8, 0x755: 0xb8, 0x756: 0xb8, 0x757: 0xb8, - 0x758: 0xb8, 0x759: 0xb8, 0x75a: 0xb8, 0x75b: 0xb8, 0x75c: 0xb8, 0x75d: 0xb8, 0x75e: 0xb8, 0x75f: 0xb8, - 0x760: 0x74, 0x761: 0x75, 0x762: 0x76, 0x763: 0x175, 0x764: 0x77, 0x765: 0x78, 0x766: 0x176, 0x767: 0x79, - 0x768: 0x7a, 0x769: 0xb8, 0x76a: 0xb8, 0x76b: 0xb8, 0x76c: 0xb8, 0x76d: 0xb8, 0x76e: 0xb8, 0x76f: 0xb8, - 0x770: 0xb8, 0x771: 0xb8, 0x772: 0xb8, 0x773: 0xb8, 0x774: 0xb8, 0x775: 0xb8, 0x776: 0xb8, 0x777: 0xb8, - 0x778: 0xb8, 0x779: 0xb8, 0x77a: 0xb8, 0x77b: 0xb8, 0x77c: 0xb8, 0x77d: 0xb8, 0x77e: 0xb8, 0x77f: 0xb8, - // Block 0x1e, offset 0x780 - 0x790: 0x0d, 0x791: 0x0e, 0x792: 0x0f, 0x793: 0x10, 0x794: 0x11, 0x795: 0x0b, 0x796: 0x12, 0x797: 0x07, - 0x798: 0x13, 0x799: 0x0b, 0x79a: 0x0b, 0x79b: 0x14, 0x79c: 0x0b, 0x79d: 0x15, 0x79e: 0x16, 0x79f: 0x17, - 0x7a0: 0x07, 0x7a1: 0x07, 0x7a2: 0x07, 0x7a3: 0x07, 0x7a4: 0x07, 0x7a5: 0x07, 0x7a6: 0x07, 0x7a7: 0x07, - 0x7a8: 0x07, 0x7a9: 0x07, 0x7aa: 0x18, 0x7ab: 0x19, 0x7ac: 0x1a, 0x7ad: 0x0b, 0x7ae: 0x0b, 0x7af: 0x1b, - 0x7b0: 0x0b, 0x7b1: 0x0b, 0x7b2: 0x0b, 0x7b3: 0x0b, 0x7b4: 0x0b, 0x7b5: 0x0b, 0x7b6: 0x0b, 0x7b7: 0x0b, - 0x7b8: 0x0b, 0x7b9: 0x0b, 0x7ba: 0x0b, 0x7bb: 0x0b, 0x7bc: 0x0b, 0x7bd: 0x0b, 0x7be: 0x0b, 0x7bf: 0x0b, - // Block 0x1f, offset 0x7c0 - 0x7c0: 0x0b, 0x7c1: 0x0b, 0x7c2: 0x0b, 0x7c3: 0x0b, 0x7c4: 0x0b, 0x7c5: 0x0b, 0x7c6: 0x0b, 0x7c7: 0x0b, - 0x7c8: 0x0b, 0x7c9: 0x0b, 0x7ca: 0x0b, 0x7cb: 0x0b, 0x7cc: 0x0b, 0x7cd: 0x0b, 0x7ce: 0x0b, 0x7cf: 0x0b, - 0x7d0: 0x0b, 0x7d1: 0x0b, 0x7d2: 0x0b, 0x7d3: 0x0b, 0x7d4: 0x0b, 0x7d5: 0x0b, 0x7d6: 0x0b, 0x7d7: 0x0b, - 0x7d8: 0x0b, 0x7d9: 0x0b, 0x7da: 0x0b, 0x7db: 0x0b, 0x7dc: 0x0b, 0x7dd: 0x0b, 0x7de: 0x0b, 0x7df: 0x0b, - 0x7e0: 0x0b, 0x7e1: 0x0b, 0x7e2: 0x0b, 0x7e3: 0x0b, 0x7e4: 0x0b, 0x7e5: 0x0b, 0x7e6: 0x0b, 0x7e7: 0x0b, - 0x7e8: 0x0b, 0x7e9: 0x0b, 0x7ea: 0x0b, 0x7eb: 0x0b, 0x7ec: 0x0b, 0x7ed: 0x0b, 0x7ee: 0x0b, 0x7ef: 0x0b, - 0x7f0: 0x0b, 0x7f1: 0x0b, 0x7f2: 0x0b, 0x7f3: 0x0b, 0x7f4: 0x0b, 0x7f5: 0x0b, 0x7f6: 0x0b, 0x7f7: 0x0b, - 0x7f8: 0x0b, 0x7f9: 0x0b, 0x7fa: 0x0b, 0x7fb: 0x0b, 0x7fc: 0x0b, 0x7fd: 0x0b, 0x7fe: 0x0b, 0x7ff: 0x0b, - // Block 0x20, offset 0x800 - 0x800: 0x177, 0x801: 0x178, 0x802: 0xb8, 0x803: 0xb8, 0x804: 0x179, 0x805: 0x179, 0x806: 0x179, 0x807: 0x17a, - 0x808: 0xb8, 0x809: 0xb8, 0x80a: 0xb8, 0x80b: 0xb8, 0x80c: 0xb8, 0x80d: 0xb8, 0x80e: 0xb8, 0x80f: 0xb8, - 0x810: 0xb8, 0x811: 0xb8, 0x812: 0xb8, 0x813: 0xb8, 0x814: 0xb8, 0x815: 0xb8, 0x816: 0xb8, 0x817: 0xb8, - 0x818: 0xb8, 0x819: 0xb8, 0x81a: 0xb8, 0x81b: 0xb8, 0x81c: 0xb8, 0x81d: 0xb8, 0x81e: 0xb8, 0x81f: 0xb8, - 0x820: 0xb8, 0x821: 0xb8, 0x822: 0xb8, 0x823: 0xb8, 0x824: 0xb8, 0x825: 0xb8, 0x826: 0xb8, 0x827: 0xb8, - 0x828: 0xb8, 0x829: 0xb8, 0x82a: 0xb8, 0x82b: 0xb8, 0x82c: 0xb8, 0x82d: 0xb8, 0x82e: 0xb8, 0x82f: 0xb8, - 0x830: 0xb8, 0x831: 0xb8, 0x832: 0xb8, 0x833: 0xb8, 0x834: 0xb8, 0x835: 0xb8, 0x836: 0xb8, 0x837: 0xb8, - 0x838: 0xb8, 0x839: 0xb8, 0x83a: 0xb8, 0x83b: 0xb8, 0x83c: 0xb8, 0x83d: 0xb8, 0x83e: 0xb8, 0x83f: 0xb8, - // Block 0x21, offset 0x840 - 0x840: 0x0b, 0x841: 0x0b, 0x842: 0x0b, 0x843: 0x0b, 0x844: 0x0b, 0x845: 0x0b, 0x846: 0x0b, 0x847: 0x0b, - 0x848: 0x0b, 0x849: 0x0b, 0x84a: 0x0b, 0x84b: 0x0b, 0x84c: 0x0b, 0x84d: 0x0b, 0x84e: 0x0b, 0x84f: 0x0b, - 0x850: 0x0b, 0x851: 0x0b, 0x852: 0x0b, 0x853: 0x0b, 0x854: 0x0b, 0x855: 0x0b, 0x856: 0x0b, 0x857: 0x0b, - 0x858: 0x0b, 0x859: 0x0b, 0x85a: 0x0b, 0x85b: 0x0b, 0x85c: 0x0b, 0x85d: 0x0b, 0x85e: 0x0b, 0x85f: 0x0b, - 0x860: 0x1e, 0x861: 0x0b, 0x862: 0x0b, 0x863: 0x0b, 0x864: 0x0b, 0x865: 0x0b, 0x866: 0x0b, 0x867: 0x0b, - 0x868: 0x0b, 0x869: 0x0b, 0x86a: 0x0b, 0x86b: 0x0b, 0x86c: 0x0b, 0x86d: 0x0b, 0x86e: 0x0b, 0x86f: 0x0b, - 0x870: 0x0b, 0x871: 0x0b, 0x872: 0x0b, 0x873: 0x0b, 0x874: 0x0b, 0x875: 0x0b, 0x876: 0x0b, 0x877: 0x0b, - 0x878: 0x0b, 0x879: 0x0b, 0x87a: 0x0b, 0x87b: 0x0b, 0x87c: 0x0b, 0x87d: 0x0b, 0x87e: 0x0b, 0x87f: 0x0b, - // Block 0x22, offset 0x880 - 0x880: 0x0b, 0x881: 0x0b, 0x882: 0x0b, 0x883: 0x0b, 0x884: 0x0b, 0x885: 0x0b, 0x886: 0x0b, 0x887: 0x0b, - 0x888: 0x0b, 0x889: 0x0b, 0x88a: 0x0b, 0x88b: 0x0b, 0x88c: 0x0b, 0x88d: 0x0b, 0x88e: 0x0b, 0x88f: 0x0b, -} - -// idnaSparseOffset: 256 entries, 512 bytes -var idnaSparseOffset = []uint16{0x0, 0x8, 0x19, 0x25, 0x27, 0x2c, 0x34, 0x3f, 0x4b, 0x5c, 0x60, 0x6f, 0x74, 0x7b, 0x87, 0x95, 0xa3, 0xa8, 0xb1, 0xc1, 0xcf, 0xdc, 0xe8, 0xf9, 0x103, 0x10a, 0x117, 0x128, 0x12f, 0x13a, 0x149, 0x157, 0x161, 0x163, 0x167, 0x169, 0x175, 0x180, 0x188, 0x18e, 0x194, 0x199, 0x19e, 0x1a1, 0x1a5, 0x1ab, 0x1b0, 0x1bc, 0x1c6, 0x1cc, 0x1dd, 0x1e7, 0x1ea, 0x1f2, 0x1f5, 0x202, 0x20a, 0x20e, 0x215, 0x21d, 0x22d, 0x239, 0x23b, 0x245, 0x251, 0x25d, 0x269, 0x271, 0x276, 0x280, 0x291, 0x295, 0x2a0, 0x2a4, 0x2ad, 0x2b5, 0x2bb, 0x2c0, 0x2c3, 0x2c6, 0x2ca, 0x2d0, 0x2d4, 0x2d8, 0x2de, 0x2e5, 0x2eb, 0x2f3, 0x2fa, 0x305, 0x30f, 0x313, 0x316, 0x31c, 0x320, 0x322, 0x325, 0x327, 0x32a, 0x334, 0x337, 0x346, 0x34a, 0x34f, 0x352, 0x356, 0x35b, 0x360, 0x366, 0x36c, 0x37b, 0x381, 0x385, 0x394, 0x399, 0x3a1, 0x3ab, 0x3b6, 0x3be, 0x3cf, 0x3d8, 0x3e8, 0x3f5, 0x3ff, 0x404, 0x411, 0x415, 0x41a, 0x41c, 0x420, 0x422, 0x426, 0x42f, 0x435, 0x439, 0x449, 0x453, 0x458, 0x45b, 0x461, 0x468, 0x46d, 0x471, 0x477, 0x47c, 0x485, 0x48a, 0x490, 0x497, 0x49e, 0x4a5, 0x4a9, 0x4ae, 0x4b1, 0x4b6, 0x4c2, 0x4c8, 0x4cd, 0x4d4, 0x4dc, 0x4e1, 0x4e5, 0x4f5, 0x4fc, 0x500, 0x504, 0x50b, 0x50e, 0x511, 0x515, 0x519, 0x51f, 0x528, 0x534, 0x53b, 0x544, 0x54c, 0x553, 0x561, 0x56e, 0x57b, 0x584, 0x588, 0x596, 0x59e, 0x5a9, 0x5b2, 0x5b8, 0x5c0, 0x5c9, 0x5d3, 0x5d6, 0x5e2, 0x5e5, 0x5ea, 0x5ed, 0x5f7, 0x600, 0x60c, 0x60f, 0x614, 0x617, 0x61a, 0x61d, 0x624, 0x62b, 0x62f, 0x63a, 0x63d, 0x643, 0x648, 0x64c, 0x64f, 0x652, 0x655, 0x65a, 0x664, 0x667, 0x66b, 0x67a, 0x686, 0x68a, 0x68f, 0x694, 0x698, 0x69d, 0x6a6, 0x6b1, 0x6b7, 0x6bf, 0x6c3, 0x6c7, 0x6cd, 0x6d3, 0x6d8, 0x6db, 0x6e9, 0x6f0, 0x6f3, 0x6f6, 0x6fa, 0x700, 0x705, 0x70f, 0x714, 0x717, 0x71a, 0x71d, 0x720, 0x724, 0x727, 0x737, 0x748, 0x74d, 0x74f, 0x751} - -// idnaSparseValues: 1876 entries, 7504 bytes -var idnaSparseValues = [1876]valueRange{ - // Block 0x0, offset 0x0 - {value: 0x0000, lo: 0x07}, - {value: 0xe105, lo: 0x80, hi: 0x96}, - {value: 0x0018, lo: 0x97, hi: 0x97}, - {value: 0xe105, lo: 0x98, hi: 0x9e}, - {value: 0x001f, lo: 0x9f, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xb6}, - {value: 0x0018, lo: 0xb7, hi: 0xb7}, - {value: 0x0008, lo: 0xb8, hi: 0xbf}, - // Block 0x1, offset 0x8 - {value: 0x0000, lo: 0x10}, - {value: 0x0008, lo: 0x80, hi: 0x80}, - {value: 0xe01d, lo: 0x81, hi: 0x81}, - {value: 0x0008, lo: 0x82, hi: 0x82}, - {value: 0x0335, lo: 0x83, hi: 0x83}, - {value: 0x034d, lo: 0x84, hi: 0x84}, - {value: 0x0365, lo: 0x85, hi: 0x85}, - {value: 0xe00d, lo: 0x86, hi: 0x86}, - {value: 0x0008, lo: 0x87, hi: 0x87}, - {value: 0xe00d, lo: 0x88, hi: 0x88}, - {value: 0x0008, lo: 0x89, hi: 0x89}, - {value: 0xe00d, lo: 0x8a, hi: 0x8a}, - {value: 0x0008, lo: 0x8b, hi: 0x8b}, - {value: 0xe00d, lo: 0x8c, hi: 0x8c}, - {value: 0x0008, lo: 0x8d, hi: 0x8d}, - {value: 0xe00d, lo: 0x8e, hi: 0x8e}, - {value: 0x0008, lo: 0x8f, hi: 0xbf}, - // Block 0x2, offset 0x19 - {value: 0x0000, lo: 0x0b}, - {value: 0x0008, lo: 0x80, hi: 0xaf}, - {value: 0x0249, lo: 0xb0, hi: 0xb0}, - {value: 0x037d, lo: 0xb1, hi: 0xb1}, - {value: 0x0259, lo: 0xb2, hi: 0xb2}, - {value: 0x0269, lo: 0xb3, hi: 0xb3}, - {value: 0x034d, lo: 0xb4, hi: 0xb4}, - {value: 0x0395, lo: 0xb5, hi: 0xb5}, - {value: 0xe1bd, lo: 0xb6, hi: 0xb6}, - {value: 0x0279, lo: 0xb7, hi: 0xb7}, - {value: 0x0289, lo: 0xb8, hi: 0xb8}, - {value: 0x0008, lo: 0xb9, hi: 0xbf}, - // Block 0x3, offset 0x25 - {value: 0x0000, lo: 0x01}, - {value: 0x1308, lo: 0x80, hi: 0xbf}, - // Block 0x4, offset 0x27 - {value: 0x0000, lo: 0x04}, - {value: 0x03f5, lo: 0x80, hi: 0x8f}, - {value: 0xe105, lo: 0x90, hi: 0x9f}, - {value: 0x049d, lo: 0xa0, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xbf}, - // Block 0x5, offset 0x2c - {value: 0x0000, lo: 0x07}, - {value: 0xe185, lo: 0x80, hi: 0x8f}, - {value: 0x0545, lo: 0x90, hi: 0x96}, - {value: 0x0040, lo: 0x97, hi: 0x98}, - {value: 0x0008, lo: 0x99, hi: 0x99}, - {value: 0x0018, lo: 0x9a, hi: 0x9f}, - {value: 0x0040, lo: 0xa0, hi: 0xa0}, - {value: 0x0008, lo: 0xa1, hi: 0xbf}, - // Block 0x6, offset 0x34 - {value: 0x0000, lo: 0x0a}, - {value: 0x0008, lo: 0x80, hi: 0x86}, - {value: 0x0401, lo: 0x87, hi: 0x87}, - {value: 0x0040, lo: 0x88, hi: 0x88}, - {value: 0x0018, lo: 0x89, hi: 0x8a}, - {value: 0x0040, lo: 0x8b, hi: 0x8c}, - {value: 0x0018, lo: 0x8d, hi: 0x8f}, - {value: 0x0040, lo: 0x90, hi: 0x90}, - {value: 0x1308, lo: 0x91, hi: 0xbd}, - {value: 0x0018, lo: 0xbe, hi: 0xbe}, - {value: 0x1308, lo: 0xbf, hi: 0xbf}, - // Block 0x7, offset 0x3f - {value: 0x0000, lo: 0x0b}, - {value: 0x0018, lo: 0x80, hi: 0x80}, - {value: 0x1308, lo: 0x81, hi: 0x82}, - {value: 0x0018, lo: 0x83, hi: 0x83}, - {value: 0x1308, lo: 0x84, hi: 0x85}, - {value: 0x0018, lo: 0x86, hi: 0x86}, - {value: 0x1308, lo: 0x87, hi: 0x87}, - {value: 0x0040, lo: 0x88, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0xaa}, - {value: 0x0040, lo: 0xab, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xb4}, - {value: 0x0040, lo: 0xb5, hi: 0xbf}, - // Block 0x8, offset 0x4b - {value: 0x0000, lo: 0x10}, - {value: 0x0018, lo: 0x80, hi: 0x80}, - {value: 0x0208, lo: 0x81, hi: 0x87}, - {value: 0x0408, lo: 0x88, hi: 0x88}, - {value: 0x0208, lo: 0x89, hi: 0x8a}, - {value: 0x1308, lo: 0x8b, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xa9}, - {value: 0x0018, lo: 0xaa, hi: 0xad}, - {value: 0x0208, lo: 0xae, hi: 0xaf}, - {value: 0x1308, lo: 0xb0, hi: 0xb0}, - {value: 0x0408, lo: 0xb1, hi: 0xb3}, - {value: 0x0008, lo: 0xb4, hi: 0xb4}, - {value: 0x0429, lo: 0xb5, hi: 0xb5}, - {value: 0x0451, lo: 0xb6, hi: 0xb6}, - {value: 0x0479, lo: 0xb7, hi: 0xb7}, - {value: 0x04a1, lo: 0xb8, hi: 0xb8}, - {value: 0x0208, lo: 0xb9, hi: 0xbf}, - // Block 0x9, offset 0x5c - {value: 0x0000, lo: 0x03}, - {value: 0x0208, lo: 0x80, hi: 0x87}, - {value: 0x0408, lo: 0x88, hi: 0x99}, - {value: 0x0208, lo: 0x9a, hi: 0xbf}, - // Block 0xa, offset 0x60 - {value: 0x0000, lo: 0x0e}, - {value: 0x1308, lo: 0x80, hi: 0x8a}, - {value: 0x0040, lo: 0x8b, hi: 0x8c}, - {value: 0x0408, lo: 0x8d, hi: 0x8d}, - {value: 0x0208, lo: 0x8e, hi: 0x98}, - {value: 0x0408, lo: 0x99, hi: 0x9b}, - {value: 0x0208, lo: 0x9c, hi: 0xaa}, - {value: 0x0408, lo: 0xab, hi: 0xac}, - {value: 0x0208, lo: 0xad, hi: 0xb0}, - {value: 0x0408, lo: 0xb1, hi: 0xb1}, - {value: 0x0208, lo: 0xb2, hi: 0xb2}, - {value: 0x0408, lo: 0xb3, hi: 0xb4}, - {value: 0x0208, lo: 0xb5, hi: 0xb7}, - {value: 0x0408, lo: 0xb8, hi: 0xb9}, - {value: 0x0208, lo: 0xba, hi: 0xbf}, - // Block 0xb, offset 0x6f - {value: 0x0000, lo: 0x04}, - {value: 0x0008, lo: 0x80, hi: 0xa5}, - {value: 0x1308, lo: 0xa6, hi: 0xb0}, - {value: 0x0008, lo: 0xb1, hi: 0xb1}, - {value: 0x0040, lo: 0xb2, hi: 0xbf}, - // Block 0xc, offset 0x74 - {value: 0x0000, lo: 0x06}, - {value: 0x0008, lo: 0x80, hi: 0x89}, - {value: 0x0208, lo: 0x8a, hi: 0xaa}, - {value: 0x1308, lo: 0xab, hi: 0xb3}, - {value: 0x0008, lo: 0xb4, hi: 0xb5}, - {value: 0x0018, lo: 0xb6, hi: 0xba}, - {value: 0x0040, lo: 0xbb, hi: 0xbf}, - // Block 0xd, offset 0x7b - {value: 0x0000, lo: 0x0b}, - {value: 0x0008, lo: 0x80, hi: 0x95}, - {value: 0x1308, lo: 0x96, hi: 0x99}, - {value: 0x0008, lo: 0x9a, hi: 0x9a}, - {value: 0x1308, lo: 0x9b, hi: 0xa3}, - {value: 0x0008, lo: 0xa4, hi: 0xa4}, - {value: 0x1308, lo: 0xa5, hi: 0xa7}, - {value: 0x0008, lo: 0xa8, hi: 0xa8}, - {value: 0x1308, lo: 0xa9, hi: 0xad}, - {value: 0x0040, lo: 0xae, hi: 0xaf}, - {value: 0x0018, lo: 0xb0, hi: 0xbe}, - {value: 0x0040, lo: 0xbf, hi: 0xbf}, - // Block 0xe, offset 0x87 - {value: 0x0000, lo: 0x0d}, - {value: 0x0408, lo: 0x80, hi: 0x80}, - {value: 0x0208, lo: 0x81, hi: 0x85}, - {value: 0x0408, lo: 0x86, hi: 0x87}, - {value: 0x0208, lo: 0x88, hi: 0x88}, - {value: 0x0408, lo: 0x89, hi: 0x89}, - {value: 0x0208, lo: 0x8a, hi: 0x93}, - {value: 0x0408, lo: 0x94, hi: 0x94}, - {value: 0x0208, lo: 0x95, hi: 0x95}, - {value: 0x0008, lo: 0x96, hi: 0x98}, - {value: 0x1308, lo: 0x99, hi: 0x9b}, - {value: 0x0040, lo: 0x9c, hi: 0x9d}, - {value: 0x0018, lo: 0x9e, hi: 0x9e}, - {value: 0x0040, lo: 0x9f, hi: 0xbf}, - // Block 0xf, offset 0x95 - {value: 0x0000, lo: 0x0d}, - {value: 0x0040, lo: 0x80, hi: 0x9f}, - {value: 0x0208, lo: 0xa0, hi: 0xa9}, - {value: 0x0408, lo: 0xaa, hi: 0xac}, - {value: 0x0008, lo: 0xad, hi: 0xad}, - {value: 0x0408, lo: 0xae, hi: 0xae}, - {value: 0x0208, lo: 0xaf, hi: 0xb0}, - {value: 0x0408, lo: 0xb1, hi: 0xb2}, - {value: 0x0208, lo: 0xb3, hi: 0xb4}, - {value: 0x0040, lo: 0xb5, hi: 0xb5}, - {value: 0x0208, lo: 0xb6, hi: 0xb8}, - {value: 0x0408, lo: 0xb9, hi: 0xb9}, - {value: 0x0208, lo: 0xba, hi: 0xbd}, - {value: 0x0040, lo: 0xbe, hi: 0xbf}, - // Block 0x10, offset 0xa3 - {value: 0x0000, lo: 0x04}, - {value: 0x0040, lo: 0x80, hi: 0x93}, - {value: 0x1308, lo: 0x94, hi: 0xa1}, - {value: 0x0040, lo: 0xa2, hi: 0xa2}, - {value: 0x1308, lo: 0xa3, hi: 0xbf}, - // Block 0x11, offset 0xa8 - {value: 0x0000, lo: 0x08}, - {value: 0x1308, lo: 0x80, hi: 0x82}, - {value: 0x1008, lo: 0x83, hi: 0x83}, - {value: 0x0008, lo: 0x84, hi: 0xb9}, - {value: 0x1308, lo: 0xba, hi: 0xba}, - {value: 0x1008, lo: 0xbb, hi: 0xbb}, - {value: 0x1308, lo: 0xbc, hi: 0xbc}, - {value: 0x0008, lo: 0xbd, hi: 0xbd}, - {value: 0x1008, lo: 0xbe, hi: 0xbf}, - // Block 0x12, offset 0xb1 - {value: 0x0000, lo: 0x0f}, - {value: 0x1308, lo: 0x80, hi: 0x80}, - {value: 0x1008, lo: 0x81, hi: 0x82}, - {value: 0x0040, lo: 0x83, hi: 0x85}, - {value: 0x1008, lo: 0x86, hi: 0x88}, - {value: 0x0040, lo: 0x89, hi: 0x89}, - {value: 0x1008, lo: 0x8a, hi: 0x8c}, - {value: 0x1b08, lo: 0x8d, hi: 0x8d}, - {value: 0x0040, lo: 0x8e, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x90}, - {value: 0x0040, lo: 0x91, hi: 0x96}, - {value: 0x1008, lo: 0x97, hi: 0x97}, - {value: 0x0040, lo: 0x98, hi: 0xa5}, - {value: 0x0008, lo: 0xa6, hi: 0xaf}, - {value: 0x0018, lo: 0xb0, hi: 0xba}, - {value: 0x0040, lo: 0xbb, hi: 0xbf}, - // Block 0x13, offset 0xc1 - {value: 0x0000, lo: 0x0d}, - {value: 0x1308, lo: 0x80, hi: 0x80}, - {value: 0x1008, lo: 0x81, hi: 0x83}, - {value: 0x0040, lo: 0x84, hi: 0x84}, - {value: 0x0008, lo: 0x85, hi: 0x8c}, - {value: 0x0040, lo: 0x8d, hi: 0x8d}, - {value: 0x0008, lo: 0x8e, hi: 0x90}, - {value: 0x0040, lo: 0x91, hi: 0x91}, - {value: 0x0008, lo: 0x92, hi: 0xa8}, - {value: 0x0040, lo: 0xa9, hi: 0xa9}, - {value: 0x0008, lo: 0xaa, hi: 0xb9}, - {value: 0x0040, lo: 0xba, hi: 0xbc}, - {value: 0x0008, lo: 0xbd, hi: 0xbd}, - {value: 0x1308, lo: 0xbe, hi: 0xbf}, - // Block 0x14, offset 0xcf - {value: 0x0000, lo: 0x0c}, - {value: 0x0040, lo: 0x80, hi: 0x80}, - {value: 0x1308, lo: 0x81, hi: 0x81}, - {value: 0x1008, lo: 0x82, hi: 0x83}, - {value: 0x0040, lo: 0x84, hi: 0x84}, - {value: 0x0008, lo: 0x85, hi: 0x8c}, - {value: 0x0040, lo: 0x8d, hi: 0x8d}, - {value: 0x0008, lo: 0x8e, hi: 0x90}, - {value: 0x0040, lo: 0x91, hi: 0x91}, - {value: 0x0008, lo: 0x92, hi: 0xba}, - {value: 0x0040, lo: 0xbb, hi: 0xbc}, - {value: 0x0008, lo: 0xbd, hi: 0xbd}, - {value: 0x1008, lo: 0xbe, hi: 0xbf}, - // Block 0x15, offset 0xdc - {value: 0x0000, lo: 0x0b}, - {value: 0x0040, lo: 0x80, hi: 0x81}, - {value: 0x1008, lo: 0x82, hi: 0x83}, - {value: 0x0040, lo: 0x84, hi: 0x84}, - {value: 0x0008, lo: 0x85, hi: 0x96}, - {value: 0x0040, lo: 0x97, hi: 0x99}, - {value: 0x0008, lo: 0x9a, hi: 0xb1}, - {value: 0x0040, lo: 0xb2, hi: 0xb2}, - {value: 0x0008, lo: 0xb3, hi: 0xbb}, - {value: 0x0040, lo: 0xbc, hi: 0xbc}, - {value: 0x0008, lo: 0xbd, hi: 0xbd}, - {value: 0x0040, lo: 0xbe, hi: 0xbf}, - // Block 0x16, offset 0xe8 - {value: 0x0000, lo: 0x10}, - {value: 0x0008, lo: 0x80, hi: 0x86}, - {value: 0x0040, lo: 0x87, hi: 0x89}, - {value: 0x1b08, lo: 0x8a, hi: 0x8a}, - {value: 0x0040, lo: 0x8b, hi: 0x8e}, - {value: 0x1008, lo: 0x8f, hi: 0x91}, - {value: 0x1308, lo: 0x92, hi: 0x94}, - {value: 0x0040, lo: 0x95, hi: 0x95}, - {value: 0x1308, lo: 0x96, hi: 0x96}, - {value: 0x0040, lo: 0x97, hi: 0x97}, - {value: 0x1008, lo: 0x98, hi: 0x9f}, - {value: 0x0040, lo: 0xa0, hi: 0xa5}, - {value: 0x0008, lo: 0xa6, hi: 0xaf}, - {value: 0x0040, lo: 0xb0, hi: 0xb1}, - {value: 0x1008, lo: 0xb2, hi: 0xb3}, - {value: 0x0018, lo: 0xb4, hi: 0xb4}, - {value: 0x0040, lo: 0xb5, hi: 0xbf}, - // Block 0x17, offset 0xf9 - {value: 0x0000, lo: 0x09}, - {value: 0x0040, lo: 0x80, hi: 0x80}, - {value: 0x0008, lo: 0x81, hi: 0xb0}, - {value: 0x1308, lo: 0xb1, hi: 0xb1}, - {value: 0x0008, lo: 0xb2, hi: 0xb2}, - {value: 0x08f1, lo: 0xb3, hi: 0xb3}, - {value: 0x1308, lo: 0xb4, hi: 0xb9}, - {value: 0x1b08, lo: 0xba, hi: 0xba}, - {value: 0x0040, lo: 0xbb, hi: 0xbe}, - {value: 0x0018, lo: 0xbf, hi: 0xbf}, - // Block 0x18, offset 0x103 - {value: 0x0000, lo: 0x06}, - {value: 0x0008, lo: 0x80, hi: 0x86}, - {value: 0x1308, lo: 0x87, hi: 0x8e}, - {value: 0x0018, lo: 0x8f, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x99}, - {value: 0x0018, lo: 0x9a, hi: 0x9b}, - {value: 0x0040, lo: 0x9c, hi: 0xbf}, - // Block 0x19, offset 0x10a - {value: 0x0000, lo: 0x0c}, - {value: 0x0008, lo: 0x80, hi: 0x84}, - {value: 0x0040, lo: 0x85, hi: 0x85}, - {value: 0x0008, lo: 0x86, hi: 0x86}, - {value: 0x0040, lo: 0x87, hi: 0x87}, - {value: 0x1308, lo: 0x88, hi: 0x8d}, - {value: 0x0040, lo: 0x8e, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x99}, - {value: 0x0040, lo: 0x9a, hi: 0x9b}, - {value: 0x0961, lo: 0x9c, hi: 0x9c}, - {value: 0x0999, lo: 0x9d, hi: 0x9d}, - {value: 0x0008, lo: 0x9e, hi: 0x9f}, - {value: 0x0040, lo: 0xa0, hi: 0xbf}, - // Block 0x1a, offset 0x117 - {value: 0x0000, lo: 0x10}, - {value: 0x0008, lo: 0x80, hi: 0x80}, - {value: 0x0018, lo: 0x81, hi: 0x8a}, - {value: 0x0008, lo: 0x8b, hi: 0x8b}, - {value: 0xe03d, lo: 0x8c, hi: 0x8c}, - {value: 0x0018, lo: 0x8d, hi: 0x97}, - {value: 0x1308, lo: 0x98, hi: 0x99}, - {value: 0x0018, lo: 0x9a, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xa9}, - {value: 0x0018, lo: 0xaa, hi: 0xb4}, - {value: 0x1308, lo: 0xb5, hi: 0xb5}, - {value: 0x0018, lo: 0xb6, hi: 0xb6}, - {value: 0x1308, lo: 0xb7, hi: 0xb7}, - {value: 0x0018, lo: 0xb8, hi: 0xb8}, - {value: 0x1308, lo: 0xb9, hi: 0xb9}, - {value: 0x0018, lo: 0xba, hi: 0xbd}, - {value: 0x1008, lo: 0xbe, hi: 0xbf}, - // Block 0x1b, offset 0x128 - {value: 0x0000, lo: 0x06}, - {value: 0x0018, lo: 0x80, hi: 0x85}, - {value: 0x1308, lo: 0x86, hi: 0x86}, - {value: 0x0018, lo: 0x87, hi: 0x8c}, - {value: 0x0040, lo: 0x8d, hi: 0x8d}, - {value: 0x0018, lo: 0x8e, hi: 0x9a}, - {value: 0x0040, lo: 0x9b, hi: 0xbf}, - // Block 0x1c, offset 0x12f - {value: 0x0000, lo: 0x0a}, - {value: 0x0008, lo: 0x80, hi: 0xaa}, - {value: 0x1008, lo: 0xab, hi: 0xac}, - {value: 0x1308, lo: 0xad, hi: 0xb0}, - {value: 0x1008, lo: 0xb1, hi: 0xb1}, - {value: 0x1308, lo: 0xb2, hi: 0xb7}, - {value: 0x1008, lo: 0xb8, hi: 0xb8}, - {value: 0x1b08, lo: 0xb9, hi: 0xba}, - {value: 0x1008, lo: 0xbb, hi: 0xbc}, - {value: 0x1308, lo: 0xbd, hi: 0xbe}, - {value: 0x0008, lo: 0xbf, hi: 0xbf}, - // Block 0x1d, offset 0x13a - {value: 0x0000, lo: 0x0e}, - {value: 0x0008, lo: 0x80, hi: 0x89}, - {value: 0x0018, lo: 0x8a, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x95}, - {value: 0x1008, lo: 0x96, hi: 0x97}, - {value: 0x1308, lo: 0x98, hi: 0x99}, - {value: 0x0008, lo: 0x9a, hi: 0x9d}, - {value: 0x1308, lo: 0x9e, hi: 0xa0}, - {value: 0x0008, lo: 0xa1, hi: 0xa1}, - {value: 0x1008, lo: 0xa2, hi: 0xa4}, - {value: 0x0008, lo: 0xa5, hi: 0xa6}, - {value: 0x1008, lo: 0xa7, hi: 0xad}, - {value: 0x0008, lo: 0xae, hi: 0xb0}, - {value: 0x1308, lo: 0xb1, hi: 0xb4}, - {value: 0x0008, lo: 0xb5, hi: 0xbf}, - // Block 0x1e, offset 0x149 - {value: 0x0000, lo: 0x0d}, - {value: 0x0008, lo: 0x80, hi: 0x81}, - {value: 0x1308, lo: 0x82, hi: 0x82}, - {value: 0x1008, lo: 0x83, hi: 0x84}, - {value: 0x1308, lo: 0x85, hi: 0x86}, - {value: 0x1008, lo: 0x87, hi: 0x8c}, - {value: 0x1308, lo: 0x8d, hi: 0x8d}, - {value: 0x0008, lo: 0x8e, hi: 0x8e}, - {value: 0x1008, lo: 0x8f, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x99}, - {value: 0x1008, lo: 0x9a, hi: 0x9c}, - {value: 0x1308, lo: 0x9d, hi: 0x9d}, - {value: 0x0018, lo: 0x9e, hi: 0x9f}, - {value: 0x0040, lo: 0xa0, hi: 0xbf}, - // Block 0x1f, offset 0x157 - {value: 0x0000, lo: 0x09}, - {value: 0x0040, lo: 0x80, hi: 0x86}, - {value: 0x055d, lo: 0x87, hi: 0x87}, - {value: 0x0040, lo: 0x88, hi: 0x8c}, - {value: 0x055d, lo: 0x8d, hi: 0x8d}, - {value: 0x0040, lo: 0x8e, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0xba}, - {value: 0x0018, lo: 0xbb, hi: 0xbb}, - {value: 0xe105, lo: 0xbc, hi: 0xbc}, - {value: 0x0008, lo: 0xbd, hi: 0xbf}, - // Block 0x20, offset 0x161 - {value: 0x0000, lo: 0x01}, - {value: 0x0018, lo: 0x80, hi: 0xbf}, - // Block 0x21, offset 0x163 - {value: 0x0000, lo: 0x03}, - {value: 0x0018, lo: 0x80, hi: 0x9e}, - {value: 0x0040, lo: 0x9f, hi: 0xa0}, - {value: 0x0018, lo: 0xa1, hi: 0xbf}, - // Block 0x22, offset 0x167 - {value: 0x0000, lo: 0x01}, - {value: 0x0008, lo: 0x80, hi: 0xbf}, - // Block 0x23, offset 0x169 - {value: 0x0000, lo: 0x0b}, - {value: 0x0008, lo: 0x80, hi: 0x88}, - {value: 0x0040, lo: 0x89, hi: 0x89}, - {value: 0x0008, lo: 0x8a, hi: 0x8d}, - {value: 0x0040, lo: 0x8e, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x96}, - {value: 0x0040, lo: 0x97, hi: 0x97}, - {value: 0x0008, lo: 0x98, hi: 0x98}, - {value: 0x0040, lo: 0x99, hi: 0x99}, - {value: 0x0008, lo: 0x9a, hi: 0x9d}, - {value: 0x0040, lo: 0x9e, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xbf}, - // Block 0x24, offset 0x175 - {value: 0x0000, lo: 0x0a}, - {value: 0x0008, lo: 0x80, hi: 0x88}, - {value: 0x0040, lo: 0x89, hi: 0x89}, - {value: 0x0008, lo: 0x8a, hi: 0x8d}, - {value: 0x0040, lo: 0x8e, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0xb0}, - {value: 0x0040, lo: 0xb1, hi: 0xb1}, - {value: 0x0008, lo: 0xb2, hi: 0xb5}, - {value: 0x0040, lo: 0xb6, hi: 0xb7}, - {value: 0x0008, lo: 0xb8, hi: 0xbe}, - {value: 0x0040, lo: 0xbf, hi: 0xbf}, - // Block 0x25, offset 0x180 - {value: 0x0000, lo: 0x07}, - {value: 0x0008, lo: 0x80, hi: 0x80}, - {value: 0x0040, lo: 0x81, hi: 0x81}, - {value: 0x0008, lo: 0x82, hi: 0x85}, - {value: 0x0040, lo: 0x86, hi: 0x87}, - {value: 0x0008, lo: 0x88, hi: 0x96}, - {value: 0x0040, lo: 0x97, hi: 0x97}, - {value: 0x0008, lo: 0x98, hi: 0xbf}, - // Block 0x26, offset 0x188 - {value: 0x0000, lo: 0x05}, - {value: 0x0008, lo: 0x80, hi: 0x90}, - {value: 0x0040, lo: 0x91, hi: 0x91}, - {value: 0x0008, lo: 0x92, hi: 0x95}, - {value: 0x0040, lo: 0x96, hi: 0x97}, - {value: 0x0008, lo: 0x98, hi: 0xbf}, - // Block 0x27, offset 0x18e - {value: 0x0000, lo: 0x05}, - {value: 0x0008, lo: 0x80, hi: 0x9a}, - {value: 0x0040, lo: 0x9b, hi: 0x9c}, - {value: 0x1308, lo: 0x9d, hi: 0x9f}, - {value: 0x0018, lo: 0xa0, hi: 0xbc}, - {value: 0x0040, lo: 0xbd, hi: 0xbf}, - // Block 0x28, offset 0x194 - {value: 0x0000, lo: 0x04}, - {value: 0x0008, lo: 0x80, hi: 0x8f}, - {value: 0x0018, lo: 0x90, hi: 0x99}, - {value: 0x0040, lo: 0x9a, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xbf}, - // Block 0x29, offset 0x199 - {value: 0x0000, lo: 0x04}, - {value: 0x0008, lo: 0x80, hi: 0xb5}, - {value: 0x0040, lo: 0xb6, hi: 0xb7}, - {value: 0xe045, lo: 0xb8, hi: 0xbd}, - {value: 0x0040, lo: 0xbe, hi: 0xbf}, - // Block 0x2a, offset 0x19e - {value: 0x0000, lo: 0x02}, - {value: 0x0018, lo: 0x80, hi: 0x80}, - {value: 0x0008, lo: 0x81, hi: 0xbf}, - // Block 0x2b, offset 0x1a1 - {value: 0x0000, lo: 0x03}, - {value: 0x0008, lo: 0x80, hi: 0xac}, - {value: 0x0018, lo: 0xad, hi: 0xae}, - {value: 0x0008, lo: 0xaf, hi: 0xbf}, - // Block 0x2c, offset 0x1a5 - {value: 0x0000, lo: 0x05}, - {value: 0x0040, lo: 0x80, hi: 0x80}, - {value: 0x0008, lo: 0x81, hi: 0x9a}, - {value: 0x0018, lo: 0x9b, hi: 0x9c}, - {value: 0x0040, lo: 0x9d, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xbf}, - // Block 0x2d, offset 0x1ab - {value: 0x0000, lo: 0x04}, - {value: 0x0008, lo: 0x80, hi: 0xaa}, - {value: 0x0018, lo: 0xab, hi: 0xb0}, - {value: 0x0008, lo: 0xb1, hi: 0xb8}, - {value: 0x0040, lo: 0xb9, hi: 0xbf}, - // Block 0x2e, offset 0x1b0 - {value: 0x0000, lo: 0x0b}, - {value: 0x0008, lo: 0x80, hi: 0x8c}, - {value: 0x0040, lo: 0x8d, hi: 0x8d}, - {value: 0x0008, lo: 0x8e, hi: 0x91}, - {value: 0x1308, lo: 0x92, hi: 0x93}, - {value: 0x1b08, lo: 0x94, hi: 0x94}, - {value: 0x0040, lo: 0x95, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xb1}, - {value: 0x1308, lo: 0xb2, hi: 0xb3}, - {value: 0x1b08, lo: 0xb4, hi: 0xb4}, - {value: 0x0018, lo: 0xb5, hi: 0xb6}, - {value: 0x0040, lo: 0xb7, hi: 0xbf}, - // Block 0x2f, offset 0x1bc - {value: 0x0000, lo: 0x09}, - {value: 0x0008, lo: 0x80, hi: 0x91}, - {value: 0x1308, lo: 0x92, hi: 0x93}, - {value: 0x0040, lo: 0x94, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xac}, - {value: 0x0040, lo: 0xad, hi: 0xad}, - {value: 0x0008, lo: 0xae, hi: 0xb0}, - {value: 0x0040, lo: 0xb1, hi: 0xb1}, - {value: 0x1308, lo: 0xb2, hi: 0xb3}, - {value: 0x0040, lo: 0xb4, hi: 0xbf}, - // Block 0x30, offset 0x1c6 - {value: 0x0000, lo: 0x05}, - {value: 0x0008, lo: 0x80, hi: 0xb3}, - {value: 0x1340, lo: 0xb4, hi: 0xb5}, - {value: 0x1008, lo: 0xb6, hi: 0xb6}, - {value: 0x1308, lo: 0xb7, hi: 0xbd}, - {value: 0x1008, lo: 0xbe, hi: 0xbf}, - // Block 0x31, offset 0x1cc - {value: 0x0000, lo: 0x10}, - {value: 0x1008, lo: 0x80, hi: 0x85}, - {value: 0x1308, lo: 0x86, hi: 0x86}, - {value: 0x1008, lo: 0x87, hi: 0x88}, - {value: 0x1308, lo: 0x89, hi: 0x91}, - {value: 0x1b08, lo: 0x92, hi: 0x92}, - {value: 0x1308, lo: 0x93, hi: 0x93}, - {value: 0x0018, lo: 0x94, hi: 0x96}, - {value: 0x0008, lo: 0x97, hi: 0x97}, - {value: 0x0018, lo: 0x98, hi: 0x9b}, - {value: 0x0008, lo: 0x9c, hi: 0x9c}, - {value: 0x1308, lo: 0x9d, hi: 0x9d}, - {value: 0x0040, lo: 0x9e, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xa9}, - {value: 0x0040, lo: 0xaa, hi: 0xaf}, - {value: 0x0018, lo: 0xb0, hi: 0xb9}, - {value: 0x0040, lo: 0xba, hi: 0xbf}, - // Block 0x32, offset 0x1dd - {value: 0x0000, lo: 0x09}, - {value: 0x0018, lo: 0x80, hi: 0x85}, - {value: 0x0040, lo: 0x86, hi: 0x86}, - {value: 0x0218, lo: 0x87, hi: 0x87}, - {value: 0x0018, lo: 0x88, hi: 0x8a}, - {value: 0x13c0, lo: 0x8b, hi: 0x8d}, - {value: 0x0040, lo: 0x8e, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x99}, - {value: 0x0040, lo: 0x9a, hi: 0x9f}, - {value: 0x0208, lo: 0xa0, hi: 0xbf}, - // Block 0x33, offset 0x1e7 - {value: 0x0000, lo: 0x02}, - {value: 0x0208, lo: 0x80, hi: 0xb7}, - {value: 0x0040, lo: 0xb8, hi: 0xbf}, - // Block 0x34, offset 0x1ea - {value: 0x0000, lo: 0x07}, - {value: 0x0008, lo: 0x80, hi: 0x84}, - {value: 0x1308, lo: 0x85, hi: 0x86}, - {value: 0x0208, lo: 0x87, hi: 0xa8}, - {value: 0x1308, lo: 0xa9, hi: 0xa9}, - {value: 0x0208, lo: 0xaa, hi: 0xaa}, - {value: 0x0040, lo: 0xab, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xbf}, - // Block 0x35, offset 0x1f2 - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0xb5}, - {value: 0x0040, lo: 0xb6, hi: 0xbf}, - // Block 0x36, offset 0x1f5 - {value: 0x0000, lo: 0x0c}, - {value: 0x0008, lo: 0x80, hi: 0x9e}, - {value: 0x0040, lo: 0x9f, hi: 0x9f}, - {value: 0x1308, lo: 0xa0, hi: 0xa2}, - {value: 0x1008, lo: 0xa3, hi: 0xa6}, - {value: 0x1308, lo: 0xa7, hi: 0xa8}, - {value: 0x1008, lo: 0xa9, hi: 0xab}, - {value: 0x0040, lo: 0xac, hi: 0xaf}, - {value: 0x1008, lo: 0xb0, hi: 0xb1}, - {value: 0x1308, lo: 0xb2, hi: 0xb2}, - {value: 0x1008, lo: 0xb3, hi: 0xb8}, - {value: 0x1308, lo: 0xb9, hi: 0xbb}, - {value: 0x0040, lo: 0xbc, hi: 0xbf}, - // Block 0x37, offset 0x202 - {value: 0x0000, lo: 0x07}, - {value: 0x0018, lo: 0x80, hi: 0x80}, - {value: 0x0040, lo: 0x81, hi: 0x83}, - {value: 0x0018, lo: 0x84, hi: 0x85}, - {value: 0x0008, lo: 0x86, hi: 0xad}, - {value: 0x0040, lo: 0xae, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xb4}, - {value: 0x0040, lo: 0xb5, hi: 0xbf}, - // Block 0x38, offset 0x20a - {value: 0x0000, lo: 0x03}, - {value: 0x0008, lo: 0x80, hi: 0xab}, - {value: 0x0040, lo: 0xac, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xbf}, - // Block 0x39, offset 0x20e - {value: 0x0000, lo: 0x06}, - {value: 0x0008, lo: 0x80, hi: 0x89}, - {value: 0x0040, lo: 0x8a, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x99}, - {value: 0x0028, lo: 0x9a, hi: 0x9a}, - {value: 0x0040, lo: 0x9b, hi: 0x9d}, - {value: 0x0018, lo: 0x9e, hi: 0xbf}, - // Block 0x3a, offset 0x215 - {value: 0x0000, lo: 0x07}, - {value: 0x0008, lo: 0x80, hi: 0x96}, - {value: 0x1308, lo: 0x97, hi: 0x98}, - {value: 0x1008, lo: 0x99, hi: 0x9a}, - {value: 0x1308, lo: 0x9b, hi: 0x9b}, - {value: 0x0040, lo: 0x9c, hi: 0x9d}, - {value: 0x0018, lo: 0x9e, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xbf}, - // Block 0x3b, offset 0x21d - {value: 0x0000, lo: 0x0f}, - {value: 0x0008, lo: 0x80, hi: 0x94}, - {value: 0x1008, lo: 0x95, hi: 0x95}, - {value: 0x1308, lo: 0x96, hi: 0x96}, - {value: 0x1008, lo: 0x97, hi: 0x97}, - {value: 0x1308, lo: 0x98, hi: 0x9e}, - {value: 0x0040, lo: 0x9f, hi: 0x9f}, - {value: 0x1b08, lo: 0xa0, hi: 0xa0}, - {value: 0x1008, lo: 0xa1, hi: 0xa1}, - {value: 0x1308, lo: 0xa2, hi: 0xa2}, - {value: 0x1008, lo: 0xa3, hi: 0xa4}, - {value: 0x1308, lo: 0xa5, hi: 0xac}, - {value: 0x1008, lo: 0xad, hi: 0xb2}, - {value: 0x1308, lo: 0xb3, hi: 0xbc}, - {value: 0x0040, lo: 0xbd, hi: 0xbe}, - {value: 0x1308, lo: 0xbf, hi: 0xbf}, - // Block 0x3c, offset 0x22d - {value: 0x0000, lo: 0x0b}, - {value: 0x0008, lo: 0x80, hi: 0x89}, - {value: 0x0040, lo: 0x8a, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x99}, - {value: 0x0040, lo: 0x9a, hi: 0x9f}, - {value: 0x0018, lo: 0xa0, hi: 0xa6}, - {value: 0x0008, lo: 0xa7, hi: 0xa7}, - {value: 0x0018, lo: 0xa8, hi: 0xad}, - {value: 0x0040, lo: 0xae, hi: 0xaf}, - {value: 0x1308, lo: 0xb0, hi: 0xbd}, - {value: 0x1318, lo: 0xbe, hi: 0xbe}, - {value: 0x0040, lo: 0xbf, hi: 0xbf}, - // Block 0x3d, offset 0x239 - {value: 0x0000, lo: 0x01}, - {value: 0x0040, lo: 0x80, hi: 0xbf}, - // Block 0x3e, offset 0x23b - {value: 0x0000, lo: 0x09}, - {value: 0x1308, lo: 0x80, hi: 0x83}, - {value: 0x1008, lo: 0x84, hi: 0x84}, - {value: 0x0008, lo: 0x85, hi: 0xb3}, - {value: 0x1308, lo: 0xb4, hi: 0xb4}, - {value: 0x1008, lo: 0xb5, hi: 0xb5}, - {value: 0x1308, lo: 0xb6, hi: 0xba}, - {value: 0x1008, lo: 0xbb, hi: 0xbb}, - {value: 0x1308, lo: 0xbc, hi: 0xbc}, - {value: 0x1008, lo: 0xbd, hi: 0xbf}, - // Block 0x3f, offset 0x245 - {value: 0x0000, lo: 0x0b}, - {value: 0x1008, lo: 0x80, hi: 0x81}, - {value: 0x1308, lo: 0x82, hi: 0x82}, - {value: 0x1008, lo: 0x83, hi: 0x83}, - {value: 0x1808, lo: 0x84, hi: 0x84}, - {value: 0x0008, lo: 0x85, hi: 0x8b}, - {value: 0x0040, lo: 0x8c, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x99}, - {value: 0x0018, lo: 0x9a, hi: 0xaa}, - {value: 0x1308, lo: 0xab, hi: 0xb3}, - {value: 0x0018, lo: 0xb4, hi: 0xbc}, - {value: 0x0040, lo: 0xbd, hi: 0xbf}, - // Block 0x40, offset 0x251 - {value: 0x0000, lo: 0x0b}, - {value: 0x1308, lo: 0x80, hi: 0x81}, - {value: 0x1008, lo: 0x82, hi: 0x82}, - {value: 0x0008, lo: 0x83, hi: 0xa0}, - {value: 0x1008, lo: 0xa1, hi: 0xa1}, - {value: 0x1308, lo: 0xa2, hi: 0xa5}, - {value: 0x1008, lo: 0xa6, hi: 0xa7}, - {value: 0x1308, lo: 0xa8, hi: 0xa9}, - {value: 0x1808, lo: 0xaa, hi: 0xaa}, - {value: 0x1b08, lo: 0xab, hi: 0xab}, - {value: 0x1308, lo: 0xac, hi: 0xad}, - {value: 0x0008, lo: 0xae, hi: 0xbf}, - // Block 0x41, offset 0x25d - {value: 0x0000, lo: 0x0b}, - {value: 0x0008, lo: 0x80, hi: 0xa5}, - {value: 0x1308, lo: 0xa6, hi: 0xa6}, - {value: 0x1008, lo: 0xa7, hi: 0xa7}, - {value: 0x1308, lo: 0xa8, hi: 0xa9}, - {value: 0x1008, lo: 0xaa, hi: 0xac}, - {value: 0x1308, lo: 0xad, hi: 0xad}, - {value: 0x1008, lo: 0xae, hi: 0xae}, - {value: 0x1308, lo: 0xaf, hi: 0xb1}, - {value: 0x1808, lo: 0xb2, hi: 0xb3}, - {value: 0x0040, lo: 0xb4, hi: 0xbb}, - {value: 0x0018, lo: 0xbc, hi: 0xbf}, - // Block 0x42, offset 0x269 - {value: 0x0000, lo: 0x07}, - {value: 0x0008, lo: 0x80, hi: 0xa3}, - {value: 0x1008, lo: 0xa4, hi: 0xab}, - {value: 0x1308, lo: 0xac, hi: 0xb3}, - {value: 0x1008, lo: 0xb4, hi: 0xb5}, - {value: 0x1308, lo: 0xb6, hi: 0xb7}, - {value: 0x0040, lo: 0xb8, hi: 0xba}, - {value: 0x0018, lo: 0xbb, hi: 0xbf}, - // Block 0x43, offset 0x271 - {value: 0x0000, lo: 0x04}, - {value: 0x0008, lo: 0x80, hi: 0x89}, - {value: 0x0040, lo: 0x8a, hi: 0x8c}, - {value: 0x0008, lo: 0x8d, hi: 0xbd}, - {value: 0x0018, lo: 0xbe, hi: 0xbf}, - // Block 0x44, offset 0x276 - {value: 0x0000, lo: 0x09}, - {value: 0x0e29, lo: 0x80, hi: 0x80}, - {value: 0x0e41, lo: 0x81, hi: 0x81}, - {value: 0x0e59, lo: 0x82, hi: 0x82}, - {value: 0x0e71, lo: 0x83, hi: 0x83}, - {value: 0x0e89, lo: 0x84, hi: 0x85}, - {value: 0x0ea1, lo: 0x86, hi: 0x86}, - {value: 0x0eb9, lo: 0x87, hi: 0x87}, - {value: 0x057d, lo: 0x88, hi: 0x88}, - {value: 0x0040, lo: 0x89, hi: 0xbf}, - // Block 0x45, offset 0x280 - {value: 0x0000, lo: 0x10}, - {value: 0x0018, lo: 0x80, hi: 0x87}, - {value: 0x0040, lo: 0x88, hi: 0x8f}, - {value: 0x1308, lo: 0x90, hi: 0x92}, - {value: 0x0018, lo: 0x93, hi: 0x93}, - {value: 0x1308, lo: 0x94, hi: 0xa0}, - {value: 0x1008, lo: 0xa1, hi: 0xa1}, - {value: 0x1308, lo: 0xa2, hi: 0xa8}, - {value: 0x0008, lo: 0xa9, hi: 0xac}, - {value: 0x1308, lo: 0xad, hi: 0xad}, - {value: 0x0008, lo: 0xae, hi: 0xb1}, - {value: 0x1008, lo: 0xb2, hi: 0xb3}, - {value: 0x1308, lo: 0xb4, hi: 0xb4}, - {value: 0x0008, lo: 0xb5, hi: 0xb6}, - {value: 0x0040, lo: 0xb7, hi: 0xb7}, - {value: 0x1308, lo: 0xb8, hi: 0xb9}, - {value: 0x0040, lo: 0xba, hi: 0xbf}, - // Block 0x46, offset 0x291 - {value: 0x0000, lo: 0x03}, - {value: 0x1308, lo: 0x80, hi: 0xb5}, - {value: 0x0040, lo: 0xb6, hi: 0xba}, - {value: 0x1308, lo: 0xbb, hi: 0xbf}, - // Block 0x47, offset 0x295 - {value: 0x0000, lo: 0x0a}, - {value: 0x0008, lo: 0x80, hi: 0x87}, - {value: 0xe045, lo: 0x88, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x95}, - {value: 0x0040, lo: 0x96, hi: 0x97}, - {value: 0xe045, lo: 0x98, hi: 0x9d}, - {value: 0x0040, lo: 0x9e, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xa7}, - {value: 0xe045, lo: 0xa8, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xb7}, - {value: 0xe045, lo: 0xb8, hi: 0xbf}, - // Block 0x48, offset 0x2a0 - {value: 0x0000, lo: 0x03}, - {value: 0x0040, lo: 0x80, hi: 0x8f}, - {value: 0x1318, lo: 0x90, hi: 0xb0}, - {value: 0x0040, lo: 0xb1, hi: 0xbf}, - // Block 0x49, offset 0x2a4 - {value: 0x0000, lo: 0x08}, - {value: 0x0018, lo: 0x80, hi: 0x82}, - {value: 0x0040, lo: 0x83, hi: 0x83}, - {value: 0x0008, lo: 0x84, hi: 0x84}, - {value: 0x0018, lo: 0x85, hi: 0x88}, - {value: 0x24c1, lo: 0x89, hi: 0x89}, - {value: 0x0018, lo: 0x8a, hi: 0x8b}, - {value: 0x0040, lo: 0x8c, hi: 0x8f}, - {value: 0x0018, lo: 0x90, hi: 0xbf}, - // Block 0x4a, offset 0x2ad - {value: 0x0000, lo: 0x07}, - {value: 0x0018, lo: 0x80, hi: 0xab}, - {value: 0x24f1, lo: 0xac, hi: 0xac}, - {value: 0x2529, lo: 0xad, hi: 0xad}, - {value: 0x0018, lo: 0xae, hi: 0xae}, - {value: 0x2579, lo: 0xaf, hi: 0xaf}, - {value: 0x25b1, lo: 0xb0, hi: 0xb0}, - {value: 0x0018, lo: 0xb1, hi: 0xbf}, - // Block 0x4b, offset 0x2b5 - {value: 0x0000, lo: 0x05}, - {value: 0x0018, lo: 0x80, hi: 0x9f}, - {value: 0x0080, lo: 0xa0, hi: 0xa0}, - {value: 0x0018, lo: 0xa1, hi: 0xad}, - {value: 0x0080, lo: 0xae, hi: 0xaf}, - {value: 0x0018, lo: 0xb0, hi: 0xbf}, - // Block 0x4c, offset 0x2bb - {value: 0x0000, lo: 0x04}, - {value: 0x0018, lo: 0x80, hi: 0xa8}, - {value: 0x09c5, lo: 0xa9, hi: 0xa9}, - {value: 0x09e5, lo: 0xaa, hi: 0xaa}, - {value: 0x0018, lo: 0xab, hi: 0xbf}, - // Block 0x4d, offset 0x2c0 - {value: 0x0000, lo: 0x02}, - {value: 0x0018, lo: 0x80, hi: 0xbe}, - {value: 0x0040, lo: 0xbf, hi: 0xbf}, - // Block 0x4e, offset 0x2c3 - {value: 0x0000, lo: 0x02}, - {value: 0x0018, lo: 0x80, hi: 0xa6}, - {value: 0x0040, lo: 0xa7, hi: 0xbf}, - // Block 0x4f, offset 0x2c6 - {value: 0x0000, lo: 0x03}, - {value: 0x0018, lo: 0x80, hi: 0x8b}, - {value: 0x28c1, lo: 0x8c, hi: 0x8c}, - {value: 0x0018, lo: 0x8d, hi: 0xbf}, - // Block 0x50, offset 0x2ca - {value: 0x0000, lo: 0x05}, - {value: 0x0018, lo: 0x80, hi: 0xb3}, - {value: 0x0e66, lo: 0xb4, hi: 0xb4}, - {value: 0x292a, lo: 0xb5, hi: 0xb5}, - {value: 0x0e86, lo: 0xb6, hi: 0xb6}, - {value: 0x0018, lo: 0xb7, hi: 0xbf}, - // Block 0x51, offset 0x2d0 - {value: 0x0000, lo: 0x03}, - {value: 0x0018, lo: 0x80, hi: 0x9b}, - {value: 0x2941, lo: 0x9c, hi: 0x9c}, - {value: 0x0018, lo: 0x9d, hi: 0xbf}, - // Block 0x52, offset 0x2d4 - {value: 0x0000, lo: 0x03}, - {value: 0x0018, lo: 0x80, hi: 0xb3}, - {value: 0x0040, lo: 0xb4, hi: 0xb5}, - {value: 0x0018, lo: 0xb6, hi: 0xbf}, - // Block 0x53, offset 0x2d8 - {value: 0x0000, lo: 0x05}, - {value: 0x0018, lo: 0x80, hi: 0x95}, - {value: 0x0040, lo: 0x96, hi: 0x97}, - {value: 0x0018, lo: 0x98, hi: 0xb9}, - {value: 0x0040, lo: 0xba, hi: 0xbc}, - {value: 0x0018, lo: 0xbd, hi: 0xbf}, - // Block 0x54, offset 0x2de - {value: 0x0000, lo: 0x06}, - {value: 0x0018, lo: 0x80, hi: 0x88}, - {value: 0x0040, lo: 0x89, hi: 0x89}, - {value: 0x0018, lo: 0x8a, hi: 0x91}, - {value: 0x0040, lo: 0x92, hi: 0xab}, - {value: 0x0018, lo: 0xac, hi: 0xaf}, - {value: 0x0040, lo: 0xb0, hi: 0xbf}, - // Block 0x55, offset 0x2e5 - {value: 0x0000, lo: 0x05}, - {value: 0xe185, lo: 0x80, hi: 0x8f}, - {value: 0x03f5, lo: 0x90, hi: 0x9f}, - {value: 0x0ea5, lo: 0xa0, hi: 0xae}, - {value: 0x0040, lo: 0xaf, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xbf}, - // Block 0x56, offset 0x2eb - {value: 0x0000, lo: 0x07}, - {value: 0x0008, lo: 0x80, hi: 0xa5}, - {value: 0x0040, lo: 0xa6, hi: 0xa6}, - {value: 0x0008, lo: 0xa7, hi: 0xa7}, - {value: 0x0040, lo: 0xa8, hi: 0xac}, - {value: 0x0008, lo: 0xad, hi: 0xad}, - {value: 0x0040, lo: 0xae, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xbf}, - // Block 0x57, offset 0x2f3 - {value: 0x0000, lo: 0x06}, - {value: 0x0008, lo: 0x80, hi: 0xa7}, - {value: 0x0040, lo: 0xa8, hi: 0xae}, - {value: 0xe075, lo: 0xaf, hi: 0xaf}, - {value: 0x0018, lo: 0xb0, hi: 0xb0}, - {value: 0x0040, lo: 0xb1, hi: 0xbe}, - {value: 0x1b08, lo: 0xbf, hi: 0xbf}, - // Block 0x58, offset 0x2fa - {value: 0x0000, lo: 0x0a}, - {value: 0x0008, lo: 0x80, hi: 0x96}, - {value: 0x0040, lo: 0x97, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xa6}, - {value: 0x0040, lo: 0xa7, hi: 0xa7}, - {value: 0x0008, lo: 0xa8, hi: 0xae}, - {value: 0x0040, lo: 0xaf, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xb6}, - {value: 0x0040, lo: 0xb7, hi: 0xb7}, - {value: 0x0008, lo: 0xb8, hi: 0xbe}, - {value: 0x0040, lo: 0xbf, hi: 0xbf}, - // Block 0x59, offset 0x305 - {value: 0x0000, lo: 0x09}, - {value: 0x0008, lo: 0x80, hi: 0x86}, - {value: 0x0040, lo: 0x87, hi: 0x87}, - {value: 0x0008, lo: 0x88, hi: 0x8e}, - {value: 0x0040, lo: 0x8f, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x96}, - {value: 0x0040, lo: 0x97, hi: 0x97}, - {value: 0x0008, lo: 0x98, hi: 0x9e}, - {value: 0x0040, lo: 0x9f, hi: 0x9f}, - {value: 0x1308, lo: 0xa0, hi: 0xbf}, - // Block 0x5a, offset 0x30f - {value: 0x0000, lo: 0x03}, - {value: 0x0018, lo: 0x80, hi: 0xae}, - {value: 0x0008, lo: 0xaf, hi: 0xaf}, - {value: 0x0018, lo: 0xb0, hi: 0xbf}, - // Block 0x5b, offset 0x313 - {value: 0x0000, lo: 0x02}, - {value: 0x0018, lo: 0x80, hi: 0x84}, - {value: 0x0040, lo: 0x85, hi: 0xbf}, - // Block 0x5c, offset 0x316 - {value: 0x0000, lo: 0x05}, - {value: 0x0018, lo: 0x80, hi: 0x99}, - {value: 0x0040, lo: 0x9a, hi: 0x9a}, - {value: 0x0018, lo: 0x9b, hi: 0x9e}, - {value: 0x0edd, lo: 0x9f, hi: 0x9f}, - {value: 0x0018, lo: 0xa0, hi: 0xbf}, - // Block 0x5d, offset 0x31c - {value: 0x0000, lo: 0x03}, - {value: 0x0018, lo: 0x80, hi: 0xb2}, - {value: 0x0efd, lo: 0xb3, hi: 0xb3}, - {value: 0x0040, lo: 0xb4, hi: 0xbf}, - // Block 0x5e, offset 0x320 - {value: 0x0020, lo: 0x01}, - {value: 0x0f1d, lo: 0x80, hi: 0xbf}, - // Block 0x5f, offset 0x322 - {value: 0x0020, lo: 0x02}, - {value: 0x171d, lo: 0x80, hi: 0x8f}, - {value: 0x18fd, lo: 0x90, hi: 0xbf}, - // Block 0x60, offset 0x325 - {value: 0x0020, lo: 0x01}, - {value: 0x1efd, lo: 0x80, hi: 0xbf}, - // Block 0x61, offset 0x327 - {value: 0x0000, lo: 0x02}, - {value: 0x0040, lo: 0x80, hi: 0x80}, - {value: 0x0008, lo: 0x81, hi: 0xbf}, - // Block 0x62, offset 0x32a - {value: 0x0000, lo: 0x09}, - {value: 0x0008, lo: 0x80, hi: 0x96}, - {value: 0x0040, lo: 0x97, hi: 0x98}, - {value: 0x1308, lo: 0x99, hi: 0x9a}, - {value: 0x29e2, lo: 0x9b, hi: 0x9b}, - {value: 0x2a0a, lo: 0x9c, hi: 0x9c}, - {value: 0x0008, lo: 0x9d, hi: 0x9e}, - {value: 0x2a31, lo: 0x9f, hi: 0x9f}, - {value: 0x0018, lo: 0xa0, hi: 0xa0}, - {value: 0x0008, lo: 0xa1, hi: 0xbf}, - // Block 0x63, offset 0x334 - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0xbe}, - {value: 0x2a69, lo: 0xbf, hi: 0xbf}, - // Block 0x64, offset 0x337 - {value: 0x0000, lo: 0x0e}, - {value: 0x0040, lo: 0x80, hi: 0x84}, - {value: 0x0008, lo: 0x85, hi: 0xad}, - {value: 0x0040, lo: 0xae, hi: 0xb0}, - {value: 0x2a1d, lo: 0xb1, hi: 0xb1}, - {value: 0x2a3d, lo: 0xb2, hi: 0xb2}, - {value: 0x2a5d, lo: 0xb3, hi: 0xb3}, - {value: 0x2a7d, lo: 0xb4, hi: 0xb4}, - {value: 0x2a5d, lo: 0xb5, hi: 0xb5}, - {value: 0x2a9d, lo: 0xb6, hi: 0xb6}, - {value: 0x2abd, lo: 0xb7, hi: 0xb7}, - {value: 0x2add, lo: 0xb8, hi: 0xb9}, - {value: 0x2afd, lo: 0xba, hi: 0xbb}, - {value: 0x2b1d, lo: 0xbc, hi: 0xbd}, - {value: 0x2afd, lo: 0xbe, hi: 0xbf}, - // Block 0x65, offset 0x346 - {value: 0x0000, lo: 0x03}, - {value: 0x0018, lo: 0x80, hi: 0xa3}, - {value: 0x0040, lo: 0xa4, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xbf}, - // Block 0x66, offset 0x34a - {value: 0x0030, lo: 0x04}, - {value: 0x2aa2, lo: 0x80, hi: 0x9d}, - {value: 0x305a, lo: 0x9e, hi: 0x9e}, - {value: 0x0040, lo: 0x9f, hi: 0x9f}, - {value: 0x30a2, lo: 0xa0, hi: 0xbf}, - // Block 0x67, offset 0x34f - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0x95}, - {value: 0x0040, lo: 0x96, hi: 0xbf}, - // Block 0x68, offset 0x352 - {value: 0x0000, lo: 0x03}, - {value: 0x0008, lo: 0x80, hi: 0x8c}, - {value: 0x0040, lo: 0x8d, hi: 0x8f}, - {value: 0x0018, lo: 0x90, hi: 0xbf}, - // Block 0x69, offset 0x356 - {value: 0x0000, lo: 0x04}, - {value: 0x0018, lo: 0x80, hi: 0x86}, - {value: 0x0040, lo: 0x87, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0xbd}, - {value: 0x0018, lo: 0xbe, hi: 0xbf}, - // Block 0x6a, offset 0x35b - {value: 0x0000, lo: 0x04}, - {value: 0x0008, lo: 0x80, hi: 0x8c}, - {value: 0x0018, lo: 0x8d, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0xab}, - {value: 0x0040, lo: 0xac, hi: 0xbf}, - // Block 0x6b, offset 0x360 - {value: 0x0000, lo: 0x05}, - {value: 0x0008, lo: 0x80, hi: 0xa5}, - {value: 0x0018, lo: 0xa6, hi: 0xaf}, - {value: 0x1308, lo: 0xb0, hi: 0xb1}, - {value: 0x0018, lo: 0xb2, hi: 0xb7}, - {value: 0x0040, lo: 0xb8, hi: 0xbf}, - // Block 0x6c, offset 0x366 - {value: 0x0000, lo: 0x05}, - {value: 0x0040, lo: 0x80, hi: 0xb6}, - {value: 0x0008, lo: 0xb7, hi: 0xb7}, - {value: 0x2009, lo: 0xb8, hi: 0xb8}, - {value: 0x6e89, lo: 0xb9, hi: 0xb9}, - {value: 0x0008, lo: 0xba, hi: 0xbf}, - // Block 0x6d, offset 0x36c - {value: 0x0000, lo: 0x0e}, - {value: 0x0008, lo: 0x80, hi: 0x81}, - {value: 0x1308, lo: 0x82, hi: 0x82}, - {value: 0x0008, lo: 0x83, hi: 0x85}, - {value: 0x1b08, lo: 0x86, hi: 0x86}, - {value: 0x0008, lo: 0x87, hi: 0x8a}, - {value: 0x1308, lo: 0x8b, hi: 0x8b}, - {value: 0x0008, lo: 0x8c, hi: 0xa2}, - {value: 0x1008, lo: 0xa3, hi: 0xa4}, - {value: 0x1308, lo: 0xa5, hi: 0xa6}, - {value: 0x1008, lo: 0xa7, hi: 0xa7}, - {value: 0x0018, lo: 0xa8, hi: 0xab}, - {value: 0x0040, lo: 0xac, hi: 0xaf}, - {value: 0x0018, lo: 0xb0, hi: 0xb9}, - {value: 0x0040, lo: 0xba, hi: 0xbf}, - // Block 0x6e, offset 0x37b - {value: 0x0000, lo: 0x05}, - {value: 0x0208, lo: 0x80, hi: 0xb1}, - {value: 0x0108, lo: 0xb2, hi: 0xb2}, - {value: 0x0008, lo: 0xb3, hi: 0xb3}, - {value: 0x0018, lo: 0xb4, hi: 0xb7}, - {value: 0x0040, lo: 0xb8, hi: 0xbf}, - // Block 0x6f, offset 0x381 - {value: 0x0000, lo: 0x03}, - {value: 0x1008, lo: 0x80, hi: 0x81}, - {value: 0x0008, lo: 0x82, hi: 0xb3}, - {value: 0x1008, lo: 0xb4, hi: 0xbf}, - // Block 0x70, offset 0x385 - {value: 0x0000, lo: 0x0e}, - {value: 0x1008, lo: 0x80, hi: 0x83}, - {value: 0x1b08, lo: 0x84, hi: 0x84}, - {value: 0x1308, lo: 0x85, hi: 0x85}, - {value: 0x0040, lo: 0x86, hi: 0x8d}, - {value: 0x0018, lo: 0x8e, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x99}, - {value: 0x0040, lo: 0x9a, hi: 0x9f}, - {value: 0x1308, lo: 0xa0, hi: 0xb1}, - {value: 0x0008, lo: 0xb2, hi: 0xb7}, - {value: 0x0018, lo: 0xb8, hi: 0xba}, - {value: 0x0008, lo: 0xbb, hi: 0xbb}, - {value: 0x0018, lo: 0xbc, hi: 0xbc}, - {value: 0x0008, lo: 0xbd, hi: 0xbd}, - {value: 0x0040, lo: 0xbe, hi: 0xbf}, - // Block 0x71, offset 0x394 - {value: 0x0000, lo: 0x04}, - {value: 0x0008, lo: 0x80, hi: 0xa5}, - {value: 0x1308, lo: 0xa6, hi: 0xad}, - {value: 0x0018, lo: 0xae, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xbf}, - // Block 0x72, offset 0x399 - {value: 0x0000, lo: 0x07}, - {value: 0x0008, lo: 0x80, hi: 0x86}, - {value: 0x1308, lo: 0x87, hi: 0x91}, - {value: 0x1008, lo: 0x92, hi: 0x92}, - {value: 0x1808, lo: 0x93, hi: 0x93}, - {value: 0x0040, lo: 0x94, hi: 0x9e}, - {value: 0x0018, lo: 0x9f, hi: 0xbc}, - {value: 0x0040, lo: 0xbd, hi: 0xbf}, - // Block 0x73, offset 0x3a1 - {value: 0x0000, lo: 0x09}, - {value: 0x1308, lo: 0x80, hi: 0x82}, - {value: 0x1008, lo: 0x83, hi: 0x83}, - {value: 0x0008, lo: 0x84, hi: 0xb2}, - {value: 0x1308, lo: 0xb3, hi: 0xb3}, - {value: 0x1008, lo: 0xb4, hi: 0xb5}, - {value: 0x1308, lo: 0xb6, hi: 0xb9}, - {value: 0x1008, lo: 0xba, hi: 0xbb}, - {value: 0x1308, lo: 0xbc, hi: 0xbc}, - {value: 0x1008, lo: 0xbd, hi: 0xbf}, - // Block 0x74, offset 0x3ab - {value: 0x0000, lo: 0x0a}, - {value: 0x1808, lo: 0x80, hi: 0x80}, - {value: 0x0018, lo: 0x81, hi: 0x8d}, - {value: 0x0040, lo: 0x8e, hi: 0x8e}, - {value: 0x0008, lo: 0x8f, hi: 0x99}, - {value: 0x0040, lo: 0x9a, hi: 0x9d}, - {value: 0x0018, lo: 0x9e, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xa4}, - {value: 0x1308, lo: 0xa5, hi: 0xa5}, - {value: 0x0008, lo: 0xa6, hi: 0xbe}, - {value: 0x0040, lo: 0xbf, hi: 0xbf}, - // Block 0x75, offset 0x3b6 - {value: 0x0000, lo: 0x07}, - {value: 0x0008, lo: 0x80, hi: 0xa8}, - {value: 0x1308, lo: 0xa9, hi: 0xae}, - {value: 0x1008, lo: 0xaf, hi: 0xb0}, - {value: 0x1308, lo: 0xb1, hi: 0xb2}, - {value: 0x1008, lo: 0xb3, hi: 0xb4}, - {value: 0x1308, lo: 0xb5, hi: 0xb6}, - {value: 0x0040, lo: 0xb7, hi: 0xbf}, - // Block 0x76, offset 0x3be - {value: 0x0000, lo: 0x10}, - {value: 0x0008, lo: 0x80, hi: 0x82}, - {value: 0x1308, lo: 0x83, hi: 0x83}, - {value: 0x0008, lo: 0x84, hi: 0x8b}, - {value: 0x1308, lo: 0x8c, hi: 0x8c}, - {value: 0x1008, lo: 0x8d, hi: 0x8d}, - {value: 0x0040, lo: 0x8e, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x99}, - {value: 0x0040, lo: 0x9a, hi: 0x9b}, - {value: 0x0018, lo: 0x9c, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xb6}, - {value: 0x0018, lo: 0xb7, hi: 0xb9}, - {value: 0x0008, lo: 0xba, hi: 0xba}, - {value: 0x1008, lo: 0xbb, hi: 0xbb}, - {value: 0x1308, lo: 0xbc, hi: 0xbc}, - {value: 0x1008, lo: 0xbd, hi: 0xbd}, - {value: 0x0008, lo: 0xbe, hi: 0xbf}, - // Block 0x77, offset 0x3cf - {value: 0x0000, lo: 0x08}, - {value: 0x0008, lo: 0x80, hi: 0xaf}, - {value: 0x1308, lo: 0xb0, hi: 0xb0}, - {value: 0x0008, lo: 0xb1, hi: 0xb1}, - {value: 0x1308, lo: 0xb2, hi: 0xb4}, - {value: 0x0008, lo: 0xb5, hi: 0xb6}, - {value: 0x1308, lo: 0xb7, hi: 0xb8}, - {value: 0x0008, lo: 0xb9, hi: 0xbd}, - {value: 0x1308, lo: 0xbe, hi: 0xbf}, - // Block 0x78, offset 0x3d8 - {value: 0x0000, lo: 0x0f}, - {value: 0x0008, lo: 0x80, hi: 0x80}, - {value: 0x1308, lo: 0x81, hi: 0x81}, - {value: 0x0008, lo: 0x82, hi: 0x82}, - {value: 0x0040, lo: 0x83, hi: 0x9a}, - {value: 0x0008, lo: 0x9b, hi: 0x9d}, - {value: 0x0018, lo: 0x9e, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xaa}, - {value: 0x1008, lo: 0xab, hi: 0xab}, - {value: 0x1308, lo: 0xac, hi: 0xad}, - {value: 0x1008, lo: 0xae, hi: 0xaf}, - {value: 0x0018, lo: 0xb0, hi: 0xb1}, - {value: 0x0008, lo: 0xb2, hi: 0xb4}, - {value: 0x1008, lo: 0xb5, hi: 0xb5}, - {value: 0x1b08, lo: 0xb6, hi: 0xb6}, - {value: 0x0040, lo: 0xb7, hi: 0xbf}, - // Block 0x79, offset 0x3e8 - {value: 0x0000, lo: 0x0c}, - {value: 0x0040, lo: 0x80, hi: 0x80}, - {value: 0x0008, lo: 0x81, hi: 0x86}, - {value: 0x0040, lo: 0x87, hi: 0x88}, - {value: 0x0008, lo: 0x89, hi: 0x8e}, - {value: 0x0040, lo: 0x8f, hi: 0x90}, - {value: 0x0008, lo: 0x91, hi: 0x96}, - {value: 0x0040, lo: 0x97, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xa6}, - {value: 0x0040, lo: 0xa7, hi: 0xa7}, - {value: 0x0008, lo: 0xa8, hi: 0xae}, - {value: 0x0040, lo: 0xaf, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xbf}, - // Block 0x7a, offset 0x3f5 - {value: 0x0000, lo: 0x09}, - {value: 0x0008, lo: 0x80, hi: 0x9a}, - {value: 0x0018, lo: 0x9b, hi: 0x9b}, - {value: 0x4465, lo: 0x9c, hi: 0x9c}, - {value: 0x447d, lo: 0x9d, hi: 0x9d}, - {value: 0x2971, lo: 0x9e, hi: 0x9e}, - {value: 0xe06d, lo: 0x9f, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xa5}, - {value: 0x0040, lo: 0xa6, hi: 0xaf}, - {value: 0x4495, lo: 0xb0, hi: 0xbf}, - // Block 0x7b, offset 0x3ff - {value: 0x0000, lo: 0x04}, - {value: 0x44b5, lo: 0x80, hi: 0x8f}, - {value: 0x44d5, lo: 0x90, hi: 0x9f}, - {value: 0x44f5, lo: 0xa0, hi: 0xaf}, - {value: 0x44d5, lo: 0xb0, hi: 0xbf}, - // Block 0x7c, offset 0x404 - {value: 0x0000, lo: 0x0c}, - {value: 0x0008, lo: 0x80, hi: 0xa2}, - {value: 0x1008, lo: 0xa3, hi: 0xa4}, - {value: 0x1308, lo: 0xa5, hi: 0xa5}, - {value: 0x1008, lo: 0xa6, hi: 0xa7}, - {value: 0x1308, lo: 0xa8, hi: 0xa8}, - {value: 0x1008, lo: 0xa9, hi: 0xaa}, - {value: 0x0018, lo: 0xab, hi: 0xab}, - {value: 0x1008, lo: 0xac, hi: 0xac}, - {value: 0x1b08, lo: 0xad, hi: 0xad}, - {value: 0x0040, lo: 0xae, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xb9}, - {value: 0x0040, lo: 0xba, hi: 0xbf}, - // Block 0x7d, offset 0x411 - {value: 0x0000, lo: 0x03}, - {value: 0x0008, lo: 0x80, hi: 0xa3}, - {value: 0x0040, lo: 0xa4, hi: 0xaf}, - {value: 0x0018, lo: 0xb0, hi: 0xbf}, - // Block 0x7e, offset 0x415 - {value: 0x0000, lo: 0x04}, - {value: 0x0018, lo: 0x80, hi: 0x86}, - {value: 0x0040, lo: 0x87, hi: 0x8a}, - {value: 0x0018, lo: 0x8b, hi: 0xbb}, - {value: 0x0040, lo: 0xbc, hi: 0xbf}, - // Block 0x7f, offset 0x41a - {value: 0x0020, lo: 0x01}, - {value: 0x4515, lo: 0x80, hi: 0xbf}, - // Block 0x80, offset 0x41c - {value: 0x0020, lo: 0x03}, - {value: 0x4d15, lo: 0x80, hi: 0x94}, - {value: 0x4ad5, lo: 0x95, hi: 0x95}, - {value: 0x4fb5, lo: 0x96, hi: 0xbf}, - // Block 0x81, offset 0x420 - {value: 0x0020, lo: 0x01}, - {value: 0x54f5, lo: 0x80, hi: 0xbf}, - // Block 0x82, offset 0x422 - {value: 0x0020, lo: 0x03}, - {value: 0x5cf5, lo: 0x80, hi: 0x84}, - {value: 0x5655, lo: 0x85, hi: 0x85}, - {value: 0x5d95, lo: 0x86, hi: 0xbf}, - // Block 0x83, offset 0x426 - {value: 0x0020, lo: 0x08}, - {value: 0x6b55, lo: 0x80, hi: 0x8f}, - {value: 0x6d15, lo: 0x90, hi: 0x90}, - {value: 0x6d55, lo: 0x91, hi: 0xab}, - {value: 0x6ea1, lo: 0xac, hi: 0xac}, - {value: 0x70b5, lo: 0xad, hi: 0xad}, - {value: 0x0040, lo: 0xae, hi: 0xae}, - {value: 0x0040, lo: 0xaf, hi: 0xaf}, - {value: 0x70d5, lo: 0xb0, hi: 0xbf}, - // Block 0x84, offset 0x42f - {value: 0x0020, lo: 0x05}, - {value: 0x72d5, lo: 0x80, hi: 0xad}, - {value: 0x6535, lo: 0xae, hi: 0xae}, - {value: 0x7895, lo: 0xaf, hi: 0xb5}, - {value: 0x6f55, lo: 0xb6, hi: 0xb6}, - {value: 0x7975, lo: 0xb7, hi: 0xbf}, - // Block 0x85, offset 0x435 - {value: 0x0028, lo: 0x03}, - {value: 0x7c21, lo: 0x80, hi: 0x82}, - {value: 0x7be1, lo: 0x83, hi: 0x83}, - {value: 0x7c99, lo: 0x84, hi: 0xbf}, - // Block 0x86, offset 0x439 - {value: 0x0038, lo: 0x0f}, - {value: 0x9db1, lo: 0x80, hi: 0x83}, - {value: 0x9e59, lo: 0x84, hi: 0x85}, - {value: 0x9e91, lo: 0x86, hi: 0x87}, - {value: 0x9ec9, lo: 0x88, hi: 0x8f}, - {value: 0x0040, lo: 0x90, hi: 0x90}, - {value: 0x0040, lo: 0x91, hi: 0x91}, - {value: 0xa089, lo: 0x92, hi: 0x97}, - {value: 0xa1a1, lo: 0x98, hi: 0x9c}, - {value: 0xa281, lo: 0x9d, hi: 0xb3}, - {value: 0x9d41, lo: 0xb4, hi: 0xb4}, - {value: 0x9db1, lo: 0xb5, hi: 0xb5}, - {value: 0xa789, lo: 0xb6, hi: 0xbb}, - {value: 0xa869, lo: 0xbc, hi: 0xbc}, - {value: 0xa7f9, lo: 0xbd, hi: 0xbd}, - {value: 0xa8d9, lo: 0xbe, hi: 0xbf}, - // Block 0x87, offset 0x449 - {value: 0x0000, lo: 0x09}, - {value: 0x0008, lo: 0x80, hi: 0x8b}, - {value: 0x0040, lo: 0x8c, hi: 0x8c}, - {value: 0x0008, lo: 0x8d, hi: 0xa6}, - {value: 0x0040, lo: 0xa7, hi: 0xa7}, - {value: 0x0008, lo: 0xa8, hi: 0xba}, - {value: 0x0040, lo: 0xbb, hi: 0xbb}, - {value: 0x0008, lo: 0xbc, hi: 0xbd}, - {value: 0x0040, lo: 0xbe, hi: 0xbe}, - {value: 0x0008, lo: 0xbf, hi: 0xbf}, - // Block 0x88, offset 0x453 - {value: 0x0000, lo: 0x04}, - {value: 0x0008, lo: 0x80, hi: 0x8d}, - {value: 0x0040, lo: 0x8e, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x9d}, - {value: 0x0040, lo: 0x9e, hi: 0xbf}, - // Block 0x89, offset 0x458 - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0xba}, - {value: 0x0040, lo: 0xbb, hi: 0xbf}, - // Block 0x8a, offset 0x45b - {value: 0x0000, lo: 0x05}, - {value: 0x0018, lo: 0x80, hi: 0x82}, - {value: 0x0040, lo: 0x83, hi: 0x86}, - {value: 0x0018, lo: 0x87, hi: 0xb3}, - {value: 0x0040, lo: 0xb4, hi: 0xb6}, - {value: 0x0018, lo: 0xb7, hi: 0xbf}, - // Block 0x8b, offset 0x461 - {value: 0x0000, lo: 0x06}, - {value: 0x0018, lo: 0x80, hi: 0x8e}, - {value: 0x0040, lo: 0x8f, hi: 0x8f}, - {value: 0x0018, lo: 0x90, hi: 0x9b}, - {value: 0x0040, lo: 0x9c, hi: 0x9f}, - {value: 0x0018, lo: 0xa0, hi: 0xa0}, - {value: 0x0040, lo: 0xa1, hi: 0xbf}, - // Block 0x8c, offset 0x468 - {value: 0x0000, lo: 0x04}, - {value: 0x0040, lo: 0x80, hi: 0x8f}, - {value: 0x0018, lo: 0x90, hi: 0xbc}, - {value: 0x1308, lo: 0xbd, hi: 0xbd}, - {value: 0x0040, lo: 0xbe, hi: 0xbf}, - // Block 0x8d, offset 0x46d - {value: 0x0000, lo: 0x03}, - {value: 0x0008, lo: 0x80, hi: 0x9c}, - {value: 0x0040, lo: 0x9d, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xbf}, - // Block 0x8e, offset 0x471 - {value: 0x0000, lo: 0x05}, - {value: 0x0008, lo: 0x80, hi: 0x90}, - {value: 0x0040, lo: 0x91, hi: 0x9f}, - {value: 0x1308, lo: 0xa0, hi: 0xa0}, - {value: 0x0018, lo: 0xa1, hi: 0xbb}, - {value: 0x0040, lo: 0xbc, hi: 0xbf}, - // Block 0x8f, offset 0x477 - {value: 0x0000, lo: 0x04}, - {value: 0x0008, lo: 0x80, hi: 0x9f}, - {value: 0x0018, lo: 0xa0, hi: 0xa3}, - {value: 0x0040, lo: 0xa4, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xbf}, - // Block 0x90, offset 0x47c - {value: 0x0000, lo: 0x08}, - {value: 0x0008, lo: 0x80, hi: 0x80}, - {value: 0x0018, lo: 0x81, hi: 0x81}, - {value: 0x0008, lo: 0x82, hi: 0x89}, - {value: 0x0018, lo: 0x8a, hi: 0x8a}, - {value: 0x0040, lo: 0x8b, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0xb5}, - {value: 0x1308, lo: 0xb6, hi: 0xba}, - {value: 0x0040, lo: 0xbb, hi: 0xbf}, - // Block 0x91, offset 0x485 - {value: 0x0000, lo: 0x04}, - {value: 0x0008, lo: 0x80, hi: 0x9d}, - {value: 0x0040, lo: 0x9e, hi: 0x9e}, - {value: 0x0018, lo: 0x9f, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xbf}, - // Block 0x92, offset 0x48a - {value: 0x0000, lo: 0x05}, - {value: 0x0008, lo: 0x80, hi: 0x83}, - {value: 0x0040, lo: 0x84, hi: 0x87}, - {value: 0x0008, lo: 0x88, hi: 0x8f}, - {value: 0x0018, lo: 0x90, hi: 0x95}, - {value: 0x0040, lo: 0x96, hi: 0xbf}, - // Block 0x93, offset 0x490 - {value: 0x0000, lo: 0x06}, - {value: 0xe145, lo: 0x80, hi: 0x87}, - {value: 0xe1c5, lo: 0x88, hi: 0x8f}, - {value: 0xe145, lo: 0x90, hi: 0x97}, - {value: 0x8ad5, lo: 0x98, hi: 0x9f}, - {value: 0x8aed, lo: 0xa0, hi: 0xa7}, - {value: 0x0008, lo: 0xa8, hi: 0xbf}, - // Block 0x94, offset 0x497 - {value: 0x0000, lo: 0x06}, - {value: 0x0008, lo: 0x80, hi: 0x9d}, - {value: 0x0040, lo: 0x9e, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xa9}, - {value: 0x0040, lo: 0xaa, hi: 0xaf}, - {value: 0x8aed, lo: 0xb0, hi: 0xb7}, - {value: 0x8ad5, lo: 0xb8, hi: 0xbf}, - // Block 0x95, offset 0x49e - {value: 0x0000, lo: 0x06}, - {value: 0xe145, lo: 0x80, hi: 0x87}, - {value: 0xe1c5, lo: 0x88, hi: 0x8f}, - {value: 0xe145, lo: 0x90, hi: 0x93}, - {value: 0x0040, lo: 0x94, hi: 0x97}, - {value: 0x0008, lo: 0x98, hi: 0xbb}, - {value: 0x0040, lo: 0xbc, hi: 0xbf}, - // Block 0x96, offset 0x4a5 - {value: 0x0000, lo: 0x03}, - {value: 0x0008, lo: 0x80, hi: 0xa7}, - {value: 0x0040, lo: 0xa8, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xbf}, - // Block 0x97, offset 0x4a9 - {value: 0x0000, lo: 0x04}, - {value: 0x0008, lo: 0x80, hi: 0xa3}, - {value: 0x0040, lo: 0xa4, hi: 0xae}, - {value: 0x0018, lo: 0xaf, hi: 0xaf}, - {value: 0x0040, lo: 0xb0, hi: 0xbf}, - // Block 0x98, offset 0x4ae - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0xb6}, - {value: 0x0040, lo: 0xb7, hi: 0xbf}, - // Block 0x99, offset 0x4b1 - {value: 0x0000, lo: 0x04}, - {value: 0x0008, lo: 0x80, hi: 0x95}, - {value: 0x0040, lo: 0x96, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xa7}, - {value: 0x0040, lo: 0xa8, hi: 0xbf}, - // Block 0x9a, offset 0x4b6 - {value: 0x0000, lo: 0x0b}, - {value: 0x0008, lo: 0x80, hi: 0x85}, - {value: 0x0040, lo: 0x86, hi: 0x87}, - {value: 0x0008, lo: 0x88, hi: 0x88}, - {value: 0x0040, lo: 0x89, hi: 0x89}, - {value: 0x0008, lo: 0x8a, hi: 0xb5}, - {value: 0x0040, lo: 0xb6, hi: 0xb6}, - {value: 0x0008, lo: 0xb7, hi: 0xb8}, - {value: 0x0040, lo: 0xb9, hi: 0xbb}, - {value: 0x0008, lo: 0xbc, hi: 0xbc}, - {value: 0x0040, lo: 0xbd, hi: 0xbe}, - {value: 0x0008, lo: 0xbf, hi: 0xbf}, - // Block 0x9b, offset 0x4c2 - {value: 0x0000, lo: 0x05}, - {value: 0x0008, lo: 0x80, hi: 0x95}, - {value: 0x0040, lo: 0x96, hi: 0x96}, - {value: 0x0018, lo: 0x97, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xb6}, - {value: 0x0018, lo: 0xb7, hi: 0xbf}, - // Block 0x9c, offset 0x4c8 - {value: 0x0000, lo: 0x04}, - {value: 0x0008, lo: 0x80, hi: 0x9e}, - {value: 0x0040, lo: 0x9f, hi: 0xa6}, - {value: 0x0018, lo: 0xa7, hi: 0xaf}, - {value: 0x0040, lo: 0xb0, hi: 0xbf}, - // Block 0x9d, offset 0x4cd - {value: 0x0000, lo: 0x06}, - {value: 0x0040, lo: 0x80, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xb2}, - {value: 0x0040, lo: 0xb3, hi: 0xb3}, - {value: 0x0008, lo: 0xb4, hi: 0xb5}, - {value: 0x0040, lo: 0xb6, hi: 0xba}, - {value: 0x0018, lo: 0xbb, hi: 0xbf}, - // Block 0x9e, offset 0x4d4 - {value: 0x0000, lo: 0x07}, - {value: 0x0008, lo: 0x80, hi: 0x95}, - {value: 0x0018, lo: 0x96, hi: 0x9b}, - {value: 0x0040, lo: 0x9c, hi: 0x9e}, - {value: 0x0018, lo: 0x9f, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xb9}, - {value: 0x0040, lo: 0xba, hi: 0xbe}, - {value: 0x0018, lo: 0xbf, hi: 0xbf}, - // Block 0x9f, offset 0x4dc - {value: 0x0000, lo: 0x04}, - {value: 0x0008, lo: 0x80, hi: 0xb7}, - {value: 0x0040, lo: 0xb8, hi: 0xbb}, - {value: 0x0018, lo: 0xbc, hi: 0xbd}, - {value: 0x0008, lo: 0xbe, hi: 0xbf}, - // Block 0xa0, offset 0x4e1 - {value: 0x0000, lo: 0x03}, - {value: 0x0018, lo: 0x80, hi: 0x8f}, - {value: 0x0040, lo: 0x90, hi: 0x91}, - {value: 0x0018, lo: 0x92, hi: 0xbf}, - // Block 0xa1, offset 0x4e5 - {value: 0x0000, lo: 0x0f}, - {value: 0x0008, lo: 0x80, hi: 0x80}, - {value: 0x1308, lo: 0x81, hi: 0x83}, - {value: 0x0040, lo: 0x84, hi: 0x84}, - {value: 0x1308, lo: 0x85, hi: 0x86}, - {value: 0x0040, lo: 0x87, hi: 0x8b}, - {value: 0x1308, lo: 0x8c, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x93}, - {value: 0x0040, lo: 0x94, hi: 0x94}, - {value: 0x0008, lo: 0x95, hi: 0x97}, - {value: 0x0040, lo: 0x98, hi: 0x98}, - {value: 0x0008, lo: 0x99, hi: 0xb3}, - {value: 0x0040, lo: 0xb4, hi: 0xb7}, - {value: 0x1308, lo: 0xb8, hi: 0xba}, - {value: 0x0040, lo: 0xbb, hi: 0xbe}, - {value: 0x1b08, lo: 0xbf, hi: 0xbf}, - // Block 0xa2, offset 0x4f5 - {value: 0x0000, lo: 0x06}, - {value: 0x0018, lo: 0x80, hi: 0x87}, - {value: 0x0040, lo: 0x88, hi: 0x8f}, - {value: 0x0018, lo: 0x90, hi: 0x98}, - {value: 0x0040, lo: 0x99, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xbc}, - {value: 0x0018, lo: 0xbd, hi: 0xbf}, - // Block 0xa3, offset 0x4fc - {value: 0x0000, lo: 0x03}, - {value: 0x0008, lo: 0x80, hi: 0x9c}, - {value: 0x0018, lo: 0x9d, hi: 0x9f}, - {value: 0x0040, lo: 0xa0, hi: 0xbf}, - // Block 0xa4, offset 0x500 - {value: 0x0000, lo: 0x03}, - {value: 0x0008, lo: 0x80, hi: 0xb5}, - {value: 0x0040, lo: 0xb6, hi: 0xb8}, - {value: 0x0018, lo: 0xb9, hi: 0xbf}, - // Block 0xa5, offset 0x504 - {value: 0x0000, lo: 0x06}, - {value: 0x0008, lo: 0x80, hi: 0x95}, - {value: 0x0040, lo: 0x96, hi: 0x97}, - {value: 0x0018, lo: 0x98, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xb2}, - {value: 0x0040, lo: 0xb3, hi: 0xb7}, - {value: 0x0018, lo: 0xb8, hi: 0xbf}, - // Block 0xa6, offset 0x50b - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0x88}, - {value: 0x0040, lo: 0x89, hi: 0xbf}, - // Block 0xa7, offset 0x50e - {value: 0x0000, lo: 0x02}, - {value: 0x03dd, lo: 0x80, hi: 0xb2}, - {value: 0x0040, lo: 0xb3, hi: 0xbf}, - // Block 0xa8, offset 0x511 - {value: 0x0000, lo: 0x03}, - {value: 0x0008, lo: 0x80, hi: 0xb2}, - {value: 0x0040, lo: 0xb3, hi: 0xb9}, - {value: 0x0018, lo: 0xba, hi: 0xbf}, - // Block 0xa9, offset 0x515 - {value: 0x0000, lo: 0x03}, - {value: 0x0040, lo: 0x80, hi: 0x9f}, - {value: 0x0018, lo: 0xa0, hi: 0xbe}, - {value: 0x0040, lo: 0xbf, hi: 0xbf}, - // Block 0xaa, offset 0x519 - {value: 0x0000, lo: 0x05}, - {value: 0x1008, lo: 0x80, hi: 0x80}, - {value: 0x1308, lo: 0x81, hi: 0x81}, - {value: 0x1008, lo: 0x82, hi: 0x82}, - {value: 0x0008, lo: 0x83, hi: 0xb7}, - {value: 0x1308, lo: 0xb8, hi: 0xbf}, - // Block 0xab, offset 0x51f - {value: 0x0000, lo: 0x08}, - {value: 0x1308, lo: 0x80, hi: 0x85}, - {value: 0x1b08, lo: 0x86, hi: 0x86}, - {value: 0x0018, lo: 0x87, hi: 0x8d}, - {value: 0x0040, lo: 0x8e, hi: 0x91}, - {value: 0x0018, lo: 0x92, hi: 0xa5}, - {value: 0x0008, lo: 0xa6, hi: 0xaf}, - {value: 0x0040, lo: 0xb0, hi: 0xbe}, - {value: 0x1b08, lo: 0xbf, hi: 0xbf}, - // Block 0xac, offset 0x528 - {value: 0x0000, lo: 0x0b}, - {value: 0x1308, lo: 0x80, hi: 0x81}, - {value: 0x1008, lo: 0x82, hi: 0x82}, - {value: 0x0008, lo: 0x83, hi: 0xaf}, - {value: 0x1008, lo: 0xb0, hi: 0xb2}, - {value: 0x1308, lo: 0xb3, hi: 0xb6}, - {value: 0x1008, lo: 0xb7, hi: 0xb8}, - {value: 0x1b08, lo: 0xb9, hi: 0xb9}, - {value: 0x1308, lo: 0xba, hi: 0xba}, - {value: 0x0018, lo: 0xbb, hi: 0xbc}, - {value: 0x0340, lo: 0xbd, hi: 0xbd}, - {value: 0x0018, lo: 0xbe, hi: 0xbf}, - // Block 0xad, offset 0x534 - {value: 0x0000, lo: 0x06}, - {value: 0x0018, lo: 0x80, hi: 0x81}, - {value: 0x0040, lo: 0x82, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0xa8}, - {value: 0x0040, lo: 0xa9, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xb9}, - {value: 0x0040, lo: 0xba, hi: 0xbf}, - // Block 0xae, offset 0x53b - {value: 0x0000, lo: 0x08}, - {value: 0x1308, lo: 0x80, hi: 0x82}, - {value: 0x0008, lo: 0x83, hi: 0xa6}, - {value: 0x1308, lo: 0xa7, hi: 0xab}, - {value: 0x1008, lo: 0xac, hi: 0xac}, - {value: 0x1308, lo: 0xad, hi: 0xb2}, - {value: 0x1b08, lo: 0xb3, hi: 0xb4}, - {value: 0x0040, lo: 0xb5, hi: 0xb5}, - {value: 0x0008, lo: 0xb6, hi: 0xbf}, - // Block 0xaf, offset 0x544 - {value: 0x0000, lo: 0x07}, - {value: 0x0018, lo: 0x80, hi: 0x83}, - {value: 0x0040, lo: 0x84, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0xb2}, - {value: 0x1308, lo: 0xb3, hi: 0xb3}, - {value: 0x0018, lo: 0xb4, hi: 0xb5}, - {value: 0x0008, lo: 0xb6, hi: 0xb6}, - {value: 0x0040, lo: 0xb7, hi: 0xbf}, - // Block 0xb0, offset 0x54c - {value: 0x0000, lo: 0x06}, - {value: 0x1308, lo: 0x80, hi: 0x81}, - {value: 0x1008, lo: 0x82, hi: 0x82}, - {value: 0x0008, lo: 0x83, hi: 0xb2}, - {value: 0x1008, lo: 0xb3, hi: 0xb5}, - {value: 0x1308, lo: 0xb6, hi: 0xbe}, - {value: 0x1008, lo: 0xbf, hi: 0xbf}, - // Block 0xb1, offset 0x553 - {value: 0x0000, lo: 0x0d}, - {value: 0x1808, lo: 0x80, hi: 0x80}, - {value: 0x0008, lo: 0x81, hi: 0x84}, - {value: 0x0018, lo: 0x85, hi: 0x89}, - {value: 0x1308, lo: 0x8a, hi: 0x8c}, - {value: 0x0018, lo: 0x8d, hi: 0x8d}, - {value: 0x0040, lo: 0x8e, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x9a}, - {value: 0x0018, lo: 0x9b, hi: 0x9b}, - {value: 0x0008, lo: 0x9c, hi: 0x9c}, - {value: 0x0018, lo: 0x9d, hi: 0x9f}, - {value: 0x0040, lo: 0xa0, hi: 0xa0}, - {value: 0x0018, lo: 0xa1, hi: 0xb4}, - {value: 0x0040, lo: 0xb5, hi: 0xbf}, - // Block 0xb2, offset 0x561 - {value: 0x0000, lo: 0x0c}, - {value: 0x0008, lo: 0x80, hi: 0x91}, - {value: 0x0040, lo: 0x92, hi: 0x92}, - {value: 0x0008, lo: 0x93, hi: 0xab}, - {value: 0x1008, lo: 0xac, hi: 0xae}, - {value: 0x1308, lo: 0xaf, hi: 0xb1}, - {value: 0x1008, lo: 0xb2, hi: 0xb3}, - {value: 0x1308, lo: 0xb4, hi: 0xb4}, - {value: 0x1808, lo: 0xb5, hi: 0xb5}, - {value: 0x1308, lo: 0xb6, hi: 0xb7}, - {value: 0x0018, lo: 0xb8, hi: 0xbd}, - {value: 0x1308, lo: 0xbe, hi: 0xbe}, - {value: 0x0040, lo: 0xbf, hi: 0xbf}, - // Block 0xb3, offset 0x56e - {value: 0x0000, lo: 0x0c}, - {value: 0x0008, lo: 0x80, hi: 0x86}, - {value: 0x0040, lo: 0x87, hi: 0x87}, - {value: 0x0008, lo: 0x88, hi: 0x88}, - {value: 0x0040, lo: 0x89, hi: 0x89}, - {value: 0x0008, lo: 0x8a, hi: 0x8d}, - {value: 0x0040, lo: 0x8e, hi: 0x8e}, - {value: 0x0008, lo: 0x8f, hi: 0x9d}, - {value: 0x0040, lo: 0x9e, hi: 0x9e}, - {value: 0x0008, lo: 0x9f, hi: 0xa8}, - {value: 0x0018, lo: 0xa9, hi: 0xa9}, - {value: 0x0040, lo: 0xaa, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xbf}, - // Block 0xb4, offset 0x57b - {value: 0x0000, lo: 0x08}, - {value: 0x0008, lo: 0x80, hi: 0x9e}, - {value: 0x1308, lo: 0x9f, hi: 0x9f}, - {value: 0x1008, lo: 0xa0, hi: 0xa2}, - {value: 0x1308, lo: 0xa3, hi: 0xa9}, - {value: 0x1b08, lo: 0xaa, hi: 0xaa}, - {value: 0x0040, lo: 0xab, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xb9}, - {value: 0x0040, lo: 0xba, hi: 0xbf}, - // Block 0xb5, offset 0x584 - {value: 0x0000, lo: 0x03}, - {value: 0x0008, lo: 0x80, hi: 0xb4}, - {value: 0x1008, lo: 0xb5, hi: 0xb7}, - {value: 0x1308, lo: 0xb8, hi: 0xbf}, - // Block 0xb6, offset 0x588 - {value: 0x0000, lo: 0x0d}, - {value: 0x1008, lo: 0x80, hi: 0x81}, - {value: 0x1b08, lo: 0x82, hi: 0x82}, - {value: 0x1308, lo: 0x83, hi: 0x84}, - {value: 0x1008, lo: 0x85, hi: 0x85}, - {value: 0x1308, lo: 0x86, hi: 0x86}, - {value: 0x0008, lo: 0x87, hi: 0x8a}, - {value: 0x0018, lo: 0x8b, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x99}, - {value: 0x0040, lo: 0x9a, hi: 0x9a}, - {value: 0x0018, lo: 0x9b, hi: 0x9b}, - {value: 0x0040, lo: 0x9c, hi: 0x9c}, - {value: 0x0018, lo: 0x9d, hi: 0x9d}, - {value: 0x0040, lo: 0x9e, hi: 0xbf}, - // Block 0xb7, offset 0x596 - {value: 0x0000, lo: 0x07}, - {value: 0x0008, lo: 0x80, hi: 0xaf}, - {value: 0x1008, lo: 0xb0, hi: 0xb2}, - {value: 0x1308, lo: 0xb3, hi: 0xb8}, - {value: 0x1008, lo: 0xb9, hi: 0xb9}, - {value: 0x1308, lo: 0xba, hi: 0xba}, - {value: 0x1008, lo: 0xbb, hi: 0xbe}, - {value: 0x1308, lo: 0xbf, hi: 0xbf}, - // Block 0xb8, offset 0x59e - {value: 0x0000, lo: 0x0a}, - {value: 0x1308, lo: 0x80, hi: 0x80}, - {value: 0x1008, lo: 0x81, hi: 0x81}, - {value: 0x1b08, lo: 0x82, hi: 0x82}, - {value: 0x1308, lo: 0x83, hi: 0x83}, - {value: 0x0008, lo: 0x84, hi: 0x85}, - {value: 0x0018, lo: 0x86, hi: 0x86}, - {value: 0x0008, lo: 0x87, hi: 0x87}, - {value: 0x0040, lo: 0x88, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x99}, - {value: 0x0040, lo: 0x9a, hi: 0xbf}, - // Block 0xb9, offset 0x5a9 - {value: 0x0000, lo: 0x08}, - {value: 0x0008, lo: 0x80, hi: 0xae}, - {value: 0x1008, lo: 0xaf, hi: 0xb1}, - {value: 0x1308, lo: 0xb2, hi: 0xb5}, - {value: 0x0040, lo: 0xb6, hi: 0xb7}, - {value: 0x1008, lo: 0xb8, hi: 0xbb}, - {value: 0x1308, lo: 0xbc, hi: 0xbd}, - {value: 0x1008, lo: 0xbe, hi: 0xbe}, - {value: 0x1b08, lo: 0xbf, hi: 0xbf}, - // Block 0xba, offset 0x5b2 - {value: 0x0000, lo: 0x05}, - {value: 0x1308, lo: 0x80, hi: 0x80}, - {value: 0x0018, lo: 0x81, hi: 0x97}, - {value: 0x0008, lo: 0x98, hi: 0x9b}, - {value: 0x1308, lo: 0x9c, hi: 0x9d}, - {value: 0x0040, lo: 0x9e, hi: 0xbf}, - // Block 0xbb, offset 0x5b8 - {value: 0x0000, lo: 0x07}, - {value: 0x0008, lo: 0x80, hi: 0xaf}, - {value: 0x1008, lo: 0xb0, hi: 0xb2}, - {value: 0x1308, lo: 0xb3, hi: 0xba}, - {value: 0x1008, lo: 0xbb, hi: 0xbc}, - {value: 0x1308, lo: 0xbd, hi: 0xbd}, - {value: 0x1008, lo: 0xbe, hi: 0xbe}, - {value: 0x1b08, lo: 0xbf, hi: 0xbf}, - // Block 0xbc, offset 0x5c0 - {value: 0x0000, lo: 0x08}, - {value: 0x1308, lo: 0x80, hi: 0x80}, - {value: 0x0018, lo: 0x81, hi: 0x83}, - {value: 0x0008, lo: 0x84, hi: 0x84}, - {value: 0x0040, lo: 0x85, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x99}, - {value: 0x0040, lo: 0x9a, hi: 0x9f}, - {value: 0x0018, lo: 0xa0, hi: 0xac}, - {value: 0x0040, lo: 0xad, hi: 0xbf}, - // Block 0xbd, offset 0x5c9 - {value: 0x0000, lo: 0x09}, - {value: 0x0008, lo: 0x80, hi: 0xaa}, - {value: 0x1308, lo: 0xab, hi: 0xab}, - {value: 0x1008, lo: 0xac, hi: 0xac}, - {value: 0x1308, lo: 0xad, hi: 0xad}, - {value: 0x1008, lo: 0xae, hi: 0xaf}, - {value: 0x1308, lo: 0xb0, hi: 0xb5}, - {value: 0x1808, lo: 0xb6, hi: 0xb6}, - {value: 0x1308, lo: 0xb7, hi: 0xb7}, - {value: 0x0040, lo: 0xb8, hi: 0xbf}, - // Block 0xbe, offset 0x5d3 - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0x89}, - {value: 0x0040, lo: 0x8a, hi: 0xbf}, - // Block 0xbf, offset 0x5d6 - {value: 0x0000, lo: 0x0b}, - {value: 0x0008, lo: 0x80, hi: 0x99}, - {value: 0x0040, lo: 0x9a, hi: 0x9c}, - {value: 0x1308, lo: 0x9d, hi: 0x9f}, - {value: 0x1008, lo: 0xa0, hi: 0xa1}, - {value: 0x1308, lo: 0xa2, hi: 0xa5}, - {value: 0x1008, lo: 0xa6, hi: 0xa6}, - {value: 0x1308, lo: 0xa7, hi: 0xaa}, - {value: 0x1b08, lo: 0xab, hi: 0xab}, - {value: 0x0040, lo: 0xac, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xb9}, - {value: 0x0018, lo: 0xba, hi: 0xbf}, - // Block 0xc0, offset 0x5e2 - {value: 0x0000, lo: 0x02}, - {value: 0x0040, lo: 0x80, hi: 0x9f}, - {value: 0x049d, lo: 0xa0, hi: 0xbf}, - // Block 0xc1, offset 0x5e5 - {value: 0x0000, lo: 0x04}, - {value: 0x0008, lo: 0x80, hi: 0xa9}, - {value: 0x0018, lo: 0xaa, hi: 0xb2}, - {value: 0x0040, lo: 0xb3, hi: 0xbe}, - {value: 0x0008, lo: 0xbf, hi: 0xbf}, - // Block 0xc2, offset 0x5ea - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0xb8}, - {value: 0x0040, lo: 0xb9, hi: 0xbf}, - // Block 0xc3, offset 0x5ed - {value: 0x0000, lo: 0x09}, - {value: 0x0008, lo: 0x80, hi: 0x88}, - {value: 0x0040, lo: 0x89, hi: 0x89}, - {value: 0x0008, lo: 0x8a, hi: 0xae}, - {value: 0x1008, lo: 0xaf, hi: 0xaf}, - {value: 0x1308, lo: 0xb0, hi: 0xb6}, - {value: 0x0040, lo: 0xb7, hi: 0xb7}, - {value: 0x1308, lo: 0xb8, hi: 0xbd}, - {value: 0x1008, lo: 0xbe, hi: 0xbe}, - {value: 0x1b08, lo: 0xbf, hi: 0xbf}, - // Block 0xc4, offset 0x5f7 - {value: 0x0000, lo: 0x08}, - {value: 0x0008, lo: 0x80, hi: 0x80}, - {value: 0x0018, lo: 0x81, hi: 0x85}, - {value: 0x0040, lo: 0x86, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x99}, - {value: 0x0018, lo: 0x9a, hi: 0xac}, - {value: 0x0040, lo: 0xad, hi: 0xaf}, - {value: 0x0018, lo: 0xb0, hi: 0xb1}, - {value: 0x0008, lo: 0xb2, hi: 0xbf}, - // Block 0xc5, offset 0x600 - {value: 0x0000, lo: 0x0b}, - {value: 0x0008, lo: 0x80, hi: 0x8f}, - {value: 0x0040, lo: 0x90, hi: 0x91}, - {value: 0x1308, lo: 0x92, hi: 0xa7}, - {value: 0x0040, lo: 0xa8, hi: 0xa8}, - {value: 0x1008, lo: 0xa9, hi: 0xa9}, - {value: 0x1308, lo: 0xaa, hi: 0xb0}, - {value: 0x1008, lo: 0xb1, hi: 0xb1}, - {value: 0x1308, lo: 0xb2, hi: 0xb3}, - {value: 0x1008, lo: 0xb4, hi: 0xb4}, - {value: 0x1308, lo: 0xb5, hi: 0xb6}, - {value: 0x0040, lo: 0xb7, hi: 0xbf}, - // Block 0xc6, offset 0x60c - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0x99}, - {value: 0x0040, lo: 0x9a, hi: 0xbf}, - // Block 0xc7, offset 0x60f - {value: 0x0000, lo: 0x04}, - {value: 0x0018, lo: 0x80, hi: 0xae}, - {value: 0x0040, lo: 0xaf, hi: 0xaf}, - {value: 0x0018, lo: 0xb0, hi: 0xb4}, - {value: 0x0040, lo: 0xb5, hi: 0xbf}, - // Block 0xc8, offset 0x614 - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0x83}, - {value: 0x0040, lo: 0x84, hi: 0xbf}, - // Block 0xc9, offset 0x617 - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0xae}, - {value: 0x0040, lo: 0xaf, hi: 0xbf}, - // Block 0xca, offset 0x61a - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0x86}, - {value: 0x0040, lo: 0x87, hi: 0xbf}, - // Block 0xcb, offset 0x61d - {value: 0x0000, lo: 0x06}, - {value: 0x0008, lo: 0x80, hi: 0x9e}, - {value: 0x0040, lo: 0x9f, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xa9}, - {value: 0x0040, lo: 0xaa, hi: 0xad}, - {value: 0x0018, lo: 0xae, hi: 0xaf}, - {value: 0x0040, lo: 0xb0, hi: 0xbf}, - // Block 0xcc, offset 0x624 - {value: 0x0000, lo: 0x06}, - {value: 0x0040, lo: 0x80, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0xad}, - {value: 0x0040, lo: 0xae, hi: 0xaf}, - {value: 0x1308, lo: 0xb0, hi: 0xb4}, - {value: 0x0018, lo: 0xb5, hi: 0xb5}, - {value: 0x0040, lo: 0xb6, hi: 0xbf}, - // Block 0xcd, offset 0x62b - {value: 0x0000, lo: 0x03}, - {value: 0x0008, lo: 0x80, hi: 0xaf}, - {value: 0x1308, lo: 0xb0, hi: 0xb6}, - {value: 0x0018, lo: 0xb7, hi: 0xbf}, - // Block 0xce, offset 0x62f - {value: 0x0000, lo: 0x0a}, - {value: 0x0008, lo: 0x80, hi: 0x83}, - {value: 0x0018, lo: 0x84, hi: 0x85}, - {value: 0x0040, lo: 0x86, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x99}, - {value: 0x0040, lo: 0x9a, hi: 0x9a}, - {value: 0x0018, lo: 0x9b, hi: 0xa1}, - {value: 0x0040, lo: 0xa2, hi: 0xa2}, - {value: 0x0008, lo: 0xa3, hi: 0xb7}, - {value: 0x0040, lo: 0xb8, hi: 0xbc}, - {value: 0x0008, lo: 0xbd, hi: 0xbf}, - // Block 0xcf, offset 0x63a - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0x8f}, - {value: 0x0040, lo: 0x90, hi: 0xbf}, - // Block 0xd0, offset 0x63d - {value: 0x0000, lo: 0x05}, - {value: 0x0008, lo: 0x80, hi: 0x84}, - {value: 0x0040, lo: 0x85, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x90}, - {value: 0x1008, lo: 0x91, hi: 0xbe}, - {value: 0x0040, lo: 0xbf, hi: 0xbf}, - // Block 0xd1, offset 0x643 - {value: 0x0000, lo: 0x04}, - {value: 0x0040, lo: 0x80, hi: 0x8e}, - {value: 0x1308, lo: 0x8f, hi: 0x92}, - {value: 0x0008, lo: 0x93, hi: 0x9f}, - {value: 0x0040, lo: 0xa0, hi: 0xbf}, - // Block 0xd2, offset 0x648 - {value: 0x0000, lo: 0x03}, - {value: 0x0040, lo: 0x80, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xa0}, - {value: 0x0040, lo: 0xa1, hi: 0xbf}, - // Block 0xd3, offset 0x64c - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0xac}, - {value: 0x0040, lo: 0xad, hi: 0xbf}, - // Block 0xd4, offset 0x64f - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0xb2}, - {value: 0x0040, lo: 0xb3, hi: 0xbf}, - // Block 0xd5, offset 0x652 - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0x81}, - {value: 0x0040, lo: 0x82, hi: 0xbf}, - // Block 0xd6, offset 0x655 - {value: 0x0000, lo: 0x04}, - {value: 0x0008, lo: 0x80, hi: 0xaa}, - {value: 0x0040, lo: 0xab, hi: 0xaf}, - {value: 0x0008, lo: 0xb0, hi: 0xbc}, - {value: 0x0040, lo: 0xbd, hi: 0xbf}, - // Block 0xd7, offset 0x65a - {value: 0x0000, lo: 0x09}, - {value: 0x0008, lo: 0x80, hi: 0x88}, - {value: 0x0040, lo: 0x89, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x99}, - {value: 0x0040, lo: 0x9a, hi: 0x9b}, - {value: 0x0018, lo: 0x9c, hi: 0x9c}, - {value: 0x1308, lo: 0x9d, hi: 0x9e}, - {value: 0x0018, lo: 0x9f, hi: 0x9f}, - {value: 0x03c0, lo: 0xa0, hi: 0xa3}, - {value: 0x0040, lo: 0xa4, hi: 0xbf}, - // Block 0xd8, offset 0x664 - {value: 0x0000, lo: 0x02}, - {value: 0x0018, lo: 0x80, hi: 0xb5}, - {value: 0x0040, lo: 0xb6, hi: 0xbf}, - // Block 0xd9, offset 0x667 - {value: 0x0000, lo: 0x03}, - {value: 0x0018, lo: 0x80, hi: 0xa6}, - {value: 0x0040, lo: 0xa7, hi: 0xa8}, - {value: 0x0018, lo: 0xa9, hi: 0xbf}, - // Block 0xda, offset 0x66b - {value: 0x0000, lo: 0x0e}, - {value: 0x0018, lo: 0x80, hi: 0x9d}, - {value: 0xb5b9, lo: 0x9e, hi: 0x9e}, - {value: 0xb601, lo: 0x9f, hi: 0x9f}, - {value: 0xb649, lo: 0xa0, hi: 0xa0}, - {value: 0xb6b1, lo: 0xa1, hi: 0xa1}, - {value: 0xb719, lo: 0xa2, hi: 0xa2}, - {value: 0xb781, lo: 0xa3, hi: 0xa3}, - {value: 0xb7e9, lo: 0xa4, hi: 0xa4}, - {value: 0x1018, lo: 0xa5, hi: 0xa6}, - {value: 0x1318, lo: 0xa7, hi: 0xa9}, - {value: 0x0018, lo: 0xaa, hi: 0xac}, - {value: 0x1018, lo: 0xad, hi: 0xb2}, - {value: 0x0340, lo: 0xb3, hi: 0xba}, - {value: 0x1318, lo: 0xbb, hi: 0xbf}, - // Block 0xdb, offset 0x67a - {value: 0x0000, lo: 0x0b}, - {value: 0x1318, lo: 0x80, hi: 0x82}, - {value: 0x0018, lo: 0x83, hi: 0x84}, - {value: 0x1318, lo: 0x85, hi: 0x8b}, - {value: 0x0018, lo: 0x8c, hi: 0xa9}, - {value: 0x1318, lo: 0xaa, hi: 0xad}, - {value: 0x0018, lo: 0xae, hi: 0xba}, - {value: 0xb851, lo: 0xbb, hi: 0xbb}, - {value: 0xb899, lo: 0xbc, hi: 0xbc}, - {value: 0xb8e1, lo: 0xbd, hi: 0xbd}, - {value: 0xb949, lo: 0xbe, hi: 0xbe}, - {value: 0xb9b1, lo: 0xbf, hi: 0xbf}, - // Block 0xdc, offset 0x686 - {value: 0x0000, lo: 0x03}, - {value: 0xba19, lo: 0x80, hi: 0x80}, - {value: 0x0018, lo: 0x81, hi: 0xa8}, - {value: 0x0040, lo: 0xa9, hi: 0xbf}, - // Block 0xdd, offset 0x68a - {value: 0x0000, lo: 0x04}, - {value: 0x0018, lo: 0x80, hi: 0x81}, - {value: 0x1318, lo: 0x82, hi: 0x84}, - {value: 0x0018, lo: 0x85, hi: 0x85}, - {value: 0x0040, lo: 0x86, hi: 0xbf}, - // Block 0xde, offset 0x68f - {value: 0x0000, lo: 0x04}, - {value: 0x0018, lo: 0x80, hi: 0x96}, - {value: 0x0040, lo: 0x97, hi: 0x9f}, - {value: 0x0018, lo: 0xa0, hi: 0xb1}, - {value: 0x0040, lo: 0xb2, hi: 0xbf}, - // Block 0xdf, offset 0x694 - {value: 0x0000, lo: 0x03}, - {value: 0x1308, lo: 0x80, hi: 0xb6}, - {value: 0x0018, lo: 0xb7, hi: 0xba}, - {value: 0x1308, lo: 0xbb, hi: 0xbf}, - // Block 0xe0, offset 0x698 - {value: 0x0000, lo: 0x04}, - {value: 0x1308, lo: 0x80, hi: 0xac}, - {value: 0x0018, lo: 0xad, hi: 0xb4}, - {value: 0x1308, lo: 0xb5, hi: 0xb5}, - {value: 0x0018, lo: 0xb6, hi: 0xbf}, - // Block 0xe1, offset 0x69d - {value: 0x0000, lo: 0x08}, - {value: 0x0018, lo: 0x80, hi: 0x83}, - {value: 0x1308, lo: 0x84, hi: 0x84}, - {value: 0x0018, lo: 0x85, hi: 0x8b}, - {value: 0x0040, lo: 0x8c, hi: 0x9a}, - {value: 0x1308, lo: 0x9b, hi: 0x9f}, - {value: 0x0040, lo: 0xa0, hi: 0xa0}, - {value: 0x1308, lo: 0xa1, hi: 0xaf}, - {value: 0x0040, lo: 0xb0, hi: 0xbf}, - // Block 0xe2, offset 0x6a6 - {value: 0x0000, lo: 0x0a}, - {value: 0x1308, lo: 0x80, hi: 0x86}, - {value: 0x0040, lo: 0x87, hi: 0x87}, - {value: 0x1308, lo: 0x88, hi: 0x98}, - {value: 0x0040, lo: 0x99, hi: 0x9a}, - {value: 0x1308, lo: 0x9b, hi: 0xa1}, - {value: 0x0040, lo: 0xa2, hi: 0xa2}, - {value: 0x1308, lo: 0xa3, hi: 0xa4}, - {value: 0x0040, lo: 0xa5, hi: 0xa5}, - {value: 0x1308, lo: 0xa6, hi: 0xaa}, - {value: 0x0040, lo: 0xab, hi: 0xbf}, - // Block 0xe3, offset 0x6b1 - {value: 0x0000, lo: 0x05}, - {value: 0x0008, lo: 0x80, hi: 0x84}, - {value: 0x0040, lo: 0x85, hi: 0x86}, - {value: 0x0018, lo: 0x87, hi: 0x8f}, - {value: 0x1308, lo: 0x90, hi: 0x96}, - {value: 0x0040, lo: 0x97, hi: 0xbf}, - // Block 0xe4, offset 0x6b7 - {value: 0x0000, lo: 0x07}, - {value: 0x0208, lo: 0x80, hi: 0x83}, - {value: 0x1308, lo: 0x84, hi: 0x8a}, - {value: 0x0040, lo: 0x8b, hi: 0x8f}, - {value: 0x0008, lo: 0x90, hi: 0x99}, - {value: 0x0040, lo: 0x9a, hi: 0x9d}, - {value: 0x0018, lo: 0x9e, hi: 0x9f}, - {value: 0x0040, lo: 0xa0, hi: 0xbf}, - // Block 0xe5, offset 0x6bf - {value: 0x0000, lo: 0x03}, - {value: 0x0040, lo: 0x80, hi: 0xaf}, - {value: 0x0018, lo: 0xb0, hi: 0xb1}, - {value: 0x0040, lo: 0xb2, hi: 0xbf}, - // Block 0xe6, offset 0x6c3 - {value: 0x0000, lo: 0x03}, - {value: 0x0018, lo: 0x80, hi: 0xab}, - {value: 0x0040, lo: 0xac, hi: 0xaf}, - {value: 0x0018, lo: 0xb0, hi: 0xbf}, - // Block 0xe7, offset 0x6c7 - {value: 0x0000, lo: 0x05}, - {value: 0x0018, lo: 0x80, hi: 0x93}, - {value: 0x0040, lo: 0x94, hi: 0x9f}, - {value: 0x0018, lo: 0xa0, hi: 0xae}, - {value: 0x0040, lo: 0xaf, hi: 0xb0}, - {value: 0x0018, lo: 0xb1, hi: 0xbf}, - // Block 0xe8, offset 0x6cd - {value: 0x0000, lo: 0x05}, - {value: 0x0040, lo: 0x80, hi: 0x80}, - {value: 0x0018, lo: 0x81, hi: 0x8f}, - {value: 0x0040, lo: 0x90, hi: 0x90}, - {value: 0x0018, lo: 0x91, hi: 0xb5}, - {value: 0x0040, lo: 0xb6, hi: 0xbf}, - // Block 0xe9, offset 0x6d3 - {value: 0x0000, lo: 0x04}, - {value: 0x0018, lo: 0x80, hi: 0x8f}, - {value: 0xc1c1, lo: 0x90, hi: 0x90}, - {value: 0x0018, lo: 0x91, hi: 0xac}, - {value: 0x0040, lo: 0xad, hi: 0xbf}, - // Block 0xea, offset 0x6d8 - {value: 0x0000, lo: 0x02}, - {value: 0x0040, lo: 0x80, hi: 0xa5}, - {value: 0x0018, lo: 0xa6, hi: 0xbf}, - // Block 0xeb, offset 0x6db - {value: 0x0000, lo: 0x0d}, - {value: 0xc7e9, lo: 0x80, hi: 0x80}, - {value: 0xc839, lo: 0x81, hi: 0x81}, - {value: 0xc889, lo: 0x82, hi: 0x82}, - {value: 0xc8d9, lo: 0x83, hi: 0x83}, - {value: 0xc929, lo: 0x84, hi: 0x84}, - {value: 0xc979, lo: 0x85, hi: 0x85}, - {value: 0xc9c9, lo: 0x86, hi: 0x86}, - {value: 0xca19, lo: 0x87, hi: 0x87}, - {value: 0xca69, lo: 0x88, hi: 0x88}, - {value: 0x0040, lo: 0x89, hi: 0x8f}, - {value: 0xcab9, lo: 0x90, hi: 0x90}, - {value: 0xcad9, lo: 0x91, hi: 0x91}, - {value: 0x0040, lo: 0x92, hi: 0xbf}, - // Block 0xec, offset 0x6e9 - {value: 0x0000, lo: 0x06}, - {value: 0x0018, lo: 0x80, hi: 0x92}, - {value: 0x0040, lo: 0x93, hi: 0x9f}, - {value: 0x0018, lo: 0xa0, hi: 0xac}, - {value: 0x0040, lo: 0xad, hi: 0xaf}, - {value: 0x0018, lo: 0xb0, hi: 0xb6}, - {value: 0x0040, lo: 0xb7, hi: 0xbf}, - // Block 0xed, offset 0x6f0 - {value: 0x0000, lo: 0x02}, - {value: 0x0018, lo: 0x80, hi: 0xb3}, - {value: 0x0040, lo: 0xb4, hi: 0xbf}, - // Block 0xee, offset 0x6f3 - {value: 0x0000, lo: 0x02}, - {value: 0x0018, lo: 0x80, hi: 0x94}, - {value: 0x0040, lo: 0x95, hi: 0xbf}, - // Block 0xef, offset 0x6f6 - {value: 0x0000, lo: 0x03}, - {value: 0x0018, lo: 0x80, hi: 0x8b}, - {value: 0x0040, lo: 0x8c, hi: 0x8f}, - {value: 0x0018, lo: 0x90, hi: 0xbf}, - // Block 0xf0, offset 0x6fa - {value: 0x0000, lo: 0x05}, - {value: 0x0018, lo: 0x80, hi: 0x87}, - {value: 0x0040, lo: 0x88, hi: 0x8f}, - {value: 0x0018, lo: 0x90, hi: 0x99}, - {value: 0x0040, lo: 0x9a, hi: 0x9f}, - {value: 0x0018, lo: 0xa0, hi: 0xbf}, - // Block 0xf1, offset 0x700 - {value: 0x0000, lo: 0x04}, - {value: 0x0018, lo: 0x80, hi: 0x87}, - {value: 0x0040, lo: 0x88, hi: 0x8f}, - {value: 0x0018, lo: 0x90, hi: 0xad}, - {value: 0x0040, lo: 0xae, hi: 0xbf}, - // Block 0xf2, offset 0x705 - {value: 0x0000, lo: 0x09}, - {value: 0x0040, lo: 0x80, hi: 0x8f}, - {value: 0x0018, lo: 0x90, hi: 0x9e}, - {value: 0x0040, lo: 0x9f, hi: 0x9f}, - {value: 0x0018, lo: 0xa0, hi: 0xa7}, - {value: 0x0040, lo: 0xa8, hi: 0xaf}, - {value: 0x0018, lo: 0xb0, hi: 0xb0}, - {value: 0x0040, lo: 0xb1, hi: 0xb2}, - {value: 0x0018, lo: 0xb3, hi: 0xbe}, - {value: 0x0040, lo: 0xbf, hi: 0xbf}, - // Block 0xf3, offset 0x70f - {value: 0x0000, lo: 0x04}, - {value: 0x0018, lo: 0x80, hi: 0x8b}, - {value: 0x0040, lo: 0x8c, hi: 0x8f}, - {value: 0x0018, lo: 0x90, hi: 0x9e}, - {value: 0x0040, lo: 0x9f, hi: 0xbf}, - // Block 0xf4, offset 0x714 - {value: 0x0000, lo: 0x02}, - {value: 0x0018, lo: 0x80, hi: 0x91}, - {value: 0x0040, lo: 0x92, hi: 0xbf}, - // Block 0xf5, offset 0x717 - {value: 0x0000, lo: 0x02}, - {value: 0x0018, lo: 0x80, hi: 0x80}, - {value: 0x0040, lo: 0x81, hi: 0xbf}, - // Block 0xf6, offset 0x71a - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0x96}, - {value: 0x0040, lo: 0x97, hi: 0xbf}, - // Block 0xf7, offset 0x71d - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0xb4}, - {value: 0x0040, lo: 0xb5, hi: 0xbf}, - // Block 0xf8, offset 0x720 - {value: 0x0000, lo: 0x03}, - {value: 0x0008, lo: 0x80, hi: 0x9d}, - {value: 0x0040, lo: 0x9e, hi: 0x9f}, - {value: 0x0008, lo: 0xa0, hi: 0xbf}, - // Block 0xf9, offset 0x724 - {value: 0x0000, lo: 0x02}, - {value: 0x0008, lo: 0x80, hi: 0xa1}, - {value: 0x0040, lo: 0xa2, hi: 0xbf}, - // Block 0xfa, offset 0x727 - {value: 0x0020, lo: 0x0f}, - {value: 0xdeb9, lo: 0x80, hi: 0x89}, - {value: 0x8dfd, lo: 0x8a, hi: 0x8a}, - {value: 0xdff9, lo: 0x8b, hi: 0x9c}, - {value: 0x8e1d, lo: 0x9d, hi: 0x9d}, - {value: 0xe239, lo: 0x9e, hi: 0xa2}, - {value: 0x8e3d, lo: 0xa3, hi: 0xa3}, - {value: 0xe2d9, lo: 0xa4, hi: 0xab}, - {value: 0x7ed5, lo: 0xac, hi: 0xac}, - {value: 0xe3d9, lo: 0xad, hi: 0xaf}, - {value: 0x8e5d, lo: 0xb0, hi: 0xb0}, - {value: 0xe439, lo: 0xb1, hi: 0xb6}, - {value: 0x8e7d, lo: 0xb7, hi: 0xb9}, - {value: 0xe4f9, lo: 0xba, hi: 0xba}, - {value: 0x8edd, lo: 0xbb, hi: 0xbb}, - {value: 0xe519, lo: 0xbc, hi: 0xbf}, - // Block 0xfb, offset 0x737 - {value: 0x0020, lo: 0x10}, - {value: 0x937d, lo: 0x80, hi: 0x80}, - {value: 0xf099, lo: 0x81, hi: 0x86}, - {value: 0x939d, lo: 0x87, hi: 0x8a}, - {value: 0xd9f9, lo: 0x8b, hi: 0x8b}, - {value: 0xf159, lo: 0x8c, hi: 0x96}, - {value: 0x941d, lo: 0x97, hi: 0x97}, - {value: 0xf2b9, lo: 0x98, hi: 0xa3}, - {value: 0x943d, lo: 0xa4, hi: 0xa6}, - {value: 0xf439, lo: 0xa7, hi: 0xaa}, - {value: 0x949d, lo: 0xab, hi: 0xab}, - {value: 0xf4b9, lo: 0xac, hi: 0xac}, - {value: 0x94bd, lo: 0xad, hi: 0xad}, - {value: 0xf4d9, lo: 0xae, hi: 0xaf}, - {value: 0x94dd, lo: 0xb0, hi: 0xb1}, - {value: 0xf519, lo: 0xb2, hi: 0xbe}, - {value: 0x0040, lo: 0xbf, hi: 0xbf}, - // Block 0xfc, offset 0x748 - {value: 0x0000, lo: 0x04}, - {value: 0x0040, lo: 0x80, hi: 0x80}, - {value: 0x0340, lo: 0x81, hi: 0x81}, - {value: 0x0040, lo: 0x82, hi: 0x9f}, - {value: 0x0340, lo: 0xa0, hi: 0xbf}, - // Block 0xfd, offset 0x74d - {value: 0x0000, lo: 0x01}, - {value: 0x0340, lo: 0x80, hi: 0xbf}, - // Block 0xfe, offset 0x74f - {value: 0x0000, lo: 0x01}, - {value: 0x13c0, lo: 0x80, hi: 0xbf}, - // Block 0xff, offset 0x751 - {value: 0x0000, lo: 0x02}, - {value: 0x13c0, lo: 0x80, hi: 0xaf}, - {value: 0x0040, lo: 0xb0, hi: 0xbf}, -} - -// Total table size 41559 bytes (40KiB); checksum: F4A1FA4E diff --git a/vendor/golang.org/x/net/idna/trie.go b/vendor/golang.org/x/net/idna/trie.go deleted file mode 100644 index c4ef847e7..000000000 --- a/vendor/golang.org/x/net/idna/trie.go +++ /dev/null @@ -1,72 +0,0 @@ -// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. - -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package idna - -// appendMapping appends the mapping for the respective rune. isMapped must be -// true. A mapping is a categorization of a rune as defined in UTS #46. -func (c info) appendMapping(b []byte, s string) []byte { - index := int(c >> indexShift) - if c&xorBit == 0 { - s := mappings[index:] - return append(b, s[1:s[0]+1]...) - } - b = append(b, s...) - if c&inlineXOR == inlineXOR { - // TODO: support and handle two-byte inline masks - b[len(b)-1] ^= byte(index) - } else { - for p := len(b) - int(xorData[index]); p < len(b); p++ { - index++ - b[p] ^= xorData[index] - } - } - return b -} - -// Sparse block handling code. - -type valueRange struct { - value uint16 // header: value:stride - lo, hi byte // header: lo:n -} - -type sparseBlocks struct { - values []valueRange - offset []uint16 -} - -var idnaSparse = sparseBlocks{ - values: idnaSparseValues[:], - offset: idnaSparseOffset[:], -} - -// Don't use newIdnaTrie to avoid unconditional linking in of the table. -var trie = &idnaTrie{} - -// lookup determines the type of block n and looks up the value for b. -// For n < t.cutoff, the block is a simple lookup table. Otherwise, the block -// is a list of ranges with an accompanying value. Given a matching range r, -// the value for b is by r.value + (b - r.lo) * stride. -func (t *sparseBlocks) lookup(n uint32, b byte) uint16 { - offset := t.offset[n] - header := t.values[offset] - lo := offset + 1 - hi := lo + uint16(header.lo) - for lo < hi { - m := lo + (hi-lo)/2 - r := t.values[m] - if r.lo <= b && b <= r.hi { - return r.value + uint16(b-r.lo)*header.value - } - if b < r.lo { - hi = m - } else { - lo = m + 1 - } - } - return 0 -} diff --git a/vendor/golang.org/x/net/idna/trieval.go b/vendor/golang.org/x/net/idna/trieval.go deleted file mode 100644 index 63cb03b59..000000000 --- a/vendor/golang.org/x/net/idna/trieval.go +++ /dev/null @@ -1,114 +0,0 @@ -// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. - -package idna - -// This file contains definitions for interpreting the trie value of the idna -// trie generated by "go run gen*.go". It is shared by both the generator -// program and the resultant package. Sharing is achieved by the generator -// copying gen_trieval.go to trieval.go and changing what's above this comment. - -// info holds information from the IDNA mapping table for a single rune. It is -// the value returned by a trie lookup. In most cases, all information fits in -// a 16-bit value. For mappings, this value may contain an index into a slice -// with the mapped string. Such mappings can consist of the actual mapped value -// or an XOR pattern to be applied to the bytes of the UTF8 encoding of the -// input rune. This technique is used by the cases packages and reduces the -// table size significantly. -// -// The per-rune values have the following format: -// -// if mapped { -// if inlinedXOR { -// 15..13 inline XOR marker -// 12..11 unused -// 10..3 inline XOR mask -// } else { -// 15..3 index into xor or mapping table -// } -// } else { -// 15..13 unused -// 12 modifier (including virama) -// 11 virama modifier -// 10..8 joining type -// 7..3 category type -// } -// 2 use xor pattern -// 1..0 mapped category -// -// See the definitions below for a more detailed description of the various -// bits. -type info uint16 - -const ( - catSmallMask = 0x3 - catBigMask = 0xF8 - indexShift = 3 - xorBit = 0x4 // interpret the index as an xor pattern - inlineXOR = 0xE000 // These bits are set if the XOR pattern is inlined. - - joinShift = 8 - joinMask = 0x07 - - viramaModifier = 0x0800 - modifier = 0x1000 -) - -// A category corresponds to a category defined in the IDNA mapping table. -type category uint16 - -const ( - unknown category = 0 // not defined currently in unicode. - mapped category = 1 - disallowedSTD3Mapped category = 2 - deviation category = 3 -) - -const ( - valid category = 0x08 - validNV8 category = 0x18 - validXV8 category = 0x28 - disallowed category = 0x40 - disallowedSTD3Valid category = 0x80 - ignored category = 0xC0 -) - -// join types and additional rune information -const ( - joiningL = (iota + 1) - joiningD - joiningT - joiningR - - //the following types are derived during processing - joinZWJ - joinZWNJ - joinVirama - numJoinTypes -) - -func (c info) isMapped() bool { - return c&0x3 != 0 -} - -func (c info) category() category { - small := c & catSmallMask - if small != 0 { - return category(small) - } - return category(c & catBigMask) -} - -func (c info) joinType() info { - if c.isMapped() { - return 0 - } - return (c >> joinShift) & joinMask -} - -func (c info) isModifier() bool { - return c&(modifier|catSmallMask) == modifier -} - -func (c info) isViramaModifier() bool { - return c&(viramaModifier|catSmallMask) == viramaModifier -} diff --git a/vendor/golang.org/x/net/internal/iana/const.go b/vendor/golang.org/x/net/internal/iana/const.go deleted file mode 100644 index 3438a27c8..000000000 --- a/vendor/golang.org/x/net/internal/iana/const.go +++ /dev/null @@ -1,180 +0,0 @@ -// go generate gen.go -// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT - -// Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA). -package iana // import "golang.org/x/net/internal/iana" - -// Differentiated Services Field Codepoints (DSCP), Updated: 2013-06-25 -const ( - DiffServCS0 = 0x0 // CS0 - DiffServCS1 = 0x20 // CS1 - DiffServCS2 = 0x40 // CS2 - DiffServCS3 = 0x60 // CS3 - DiffServCS4 = 0x80 // CS4 - DiffServCS5 = 0xa0 // CS5 - DiffServCS6 = 0xc0 // CS6 - DiffServCS7 = 0xe0 // CS7 - DiffServAF11 = 0x28 // AF11 - DiffServAF12 = 0x30 // AF12 - DiffServAF13 = 0x38 // AF13 - DiffServAF21 = 0x48 // AF21 - DiffServAF22 = 0x50 // AF22 - DiffServAF23 = 0x58 // AF23 - DiffServAF31 = 0x68 // AF31 - DiffServAF32 = 0x70 // AF32 - DiffServAF33 = 0x78 // AF33 - DiffServAF41 = 0x88 // AF41 - DiffServAF42 = 0x90 // AF42 - DiffServAF43 = 0x98 // AF43 - DiffServEFPHB = 0xb8 // EF PHB - DiffServVOICEADMIT = 0xb0 // VOICE-ADMIT -) - -// IPv4 TOS Byte and IPv6 Traffic Class Octet, Updated: 2001-09-06 -const ( - NotECNTransport = 0x0 // Not-ECT (Not ECN-Capable Transport) - ECNTransport1 = 0x1 // ECT(1) (ECN-Capable Transport(1)) - ECNTransport0 = 0x2 // ECT(0) (ECN-Capable Transport(0)) - CongestionExperienced = 0x3 // CE (Congestion Experienced) -) - -// Protocol Numbers, Updated: 2015-10-06 -const ( - ProtocolIP = 0 // IPv4 encapsulation, pseudo protocol number - ProtocolHOPOPT = 0 // IPv6 Hop-by-Hop Option - ProtocolICMP = 1 // Internet Control Message - ProtocolIGMP = 2 // Internet Group Management - ProtocolGGP = 3 // Gateway-to-Gateway - ProtocolIPv4 = 4 // IPv4 encapsulation - ProtocolST = 5 // Stream - ProtocolTCP = 6 // Transmission Control - ProtocolCBT = 7 // CBT - ProtocolEGP = 8 // Exterior Gateway Protocol - ProtocolIGP = 9 // any private interior gateway (used by Cisco for their IGRP) - ProtocolBBNRCCMON = 10 // BBN RCC Monitoring - ProtocolNVPII = 11 // Network Voice Protocol - ProtocolPUP = 12 // PUP - ProtocolEMCON = 14 // EMCON - ProtocolXNET = 15 // Cross Net Debugger - ProtocolCHAOS = 16 // Chaos - ProtocolUDP = 17 // User Datagram - ProtocolMUX = 18 // Multiplexing - ProtocolDCNMEAS = 19 // DCN Measurement Subsystems - ProtocolHMP = 20 // Host Monitoring - ProtocolPRM = 21 // Packet Radio Measurement - ProtocolXNSIDP = 22 // XEROX NS IDP - ProtocolTRUNK1 = 23 // Trunk-1 - ProtocolTRUNK2 = 24 // Trunk-2 - ProtocolLEAF1 = 25 // Leaf-1 - ProtocolLEAF2 = 26 // Leaf-2 - ProtocolRDP = 27 // Reliable Data Protocol - ProtocolIRTP = 28 // Internet Reliable Transaction - ProtocolISOTP4 = 29 // ISO Transport Protocol Class 4 - ProtocolNETBLT = 30 // Bulk Data Transfer Protocol - ProtocolMFENSP = 31 // MFE Network Services Protocol - ProtocolMERITINP = 32 // MERIT Internodal Protocol - ProtocolDCCP = 33 // Datagram Congestion Control Protocol - Protocol3PC = 34 // Third Party Connect Protocol - ProtocolIDPR = 35 // Inter-Domain Policy Routing Protocol - ProtocolXTP = 36 // XTP - ProtocolDDP = 37 // Datagram Delivery Protocol - ProtocolIDPRCMTP = 38 // IDPR Control Message Transport Proto - ProtocolTPPP = 39 // TP++ Transport Protocol - ProtocolIL = 40 // IL Transport Protocol - ProtocolIPv6 = 41 // IPv6 encapsulation - ProtocolSDRP = 42 // Source Demand Routing Protocol - ProtocolIPv6Route = 43 // Routing Header for IPv6 - ProtocolIPv6Frag = 44 // Fragment Header for IPv6 - ProtocolIDRP = 45 // Inter-Domain Routing Protocol - ProtocolRSVP = 46 // Reservation Protocol - ProtocolGRE = 47 // Generic Routing Encapsulation - ProtocolDSR = 48 // Dynamic Source Routing Protocol - ProtocolBNA = 49 // BNA - ProtocolESP = 50 // Encap Security Payload - ProtocolAH = 51 // Authentication Header - ProtocolINLSP = 52 // Integrated Net Layer Security TUBA - ProtocolNARP = 54 // NBMA Address Resolution Protocol - ProtocolMOBILE = 55 // IP Mobility - ProtocolTLSP = 56 // Transport Layer Security Protocol using Kryptonet key management - ProtocolSKIP = 57 // SKIP - ProtocolIPv6ICMP = 58 // ICMP for IPv6 - ProtocolIPv6NoNxt = 59 // No Next Header for IPv6 - ProtocolIPv6Opts = 60 // Destination Options for IPv6 - ProtocolCFTP = 62 // CFTP - ProtocolSATEXPAK = 64 // SATNET and Backroom EXPAK - ProtocolKRYPTOLAN = 65 // Kryptolan - ProtocolRVD = 66 // MIT Remote Virtual Disk Protocol - ProtocolIPPC = 67 // Internet Pluribus Packet Core - ProtocolSATMON = 69 // SATNET Monitoring - ProtocolVISA = 70 // VISA Protocol - ProtocolIPCV = 71 // Internet Packet Core Utility - ProtocolCPNX = 72 // Computer Protocol Network Executive - ProtocolCPHB = 73 // Computer Protocol Heart Beat - ProtocolWSN = 74 // Wang Span Network - ProtocolPVP = 75 // Packet Video Protocol - ProtocolBRSATMON = 76 // Backroom SATNET Monitoring - ProtocolSUNND = 77 // SUN ND PROTOCOL-Temporary - ProtocolWBMON = 78 // WIDEBAND Monitoring - ProtocolWBEXPAK = 79 // WIDEBAND EXPAK - ProtocolISOIP = 80 // ISO Internet Protocol - ProtocolVMTP = 81 // VMTP - ProtocolSECUREVMTP = 82 // SECURE-VMTP - ProtocolVINES = 83 // VINES - ProtocolTTP = 84 // Transaction Transport Protocol - ProtocolIPTM = 84 // Internet Protocol Traffic Manager - ProtocolNSFNETIGP = 85 // NSFNET-IGP - ProtocolDGP = 86 // Dissimilar Gateway Protocol - ProtocolTCF = 87 // TCF - ProtocolEIGRP = 88 // EIGRP - ProtocolOSPFIGP = 89 // OSPFIGP - ProtocolSpriteRPC = 90 // Sprite RPC Protocol - ProtocolLARP = 91 // Locus Address Resolution Protocol - ProtocolMTP = 92 // Multicast Transport Protocol - ProtocolAX25 = 93 // AX.25 Frames - ProtocolIPIP = 94 // IP-within-IP Encapsulation Protocol - ProtocolSCCSP = 96 // Semaphore Communications Sec. Pro. - ProtocolETHERIP = 97 // Ethernet-within-IP Encapsulation - ProtocolENCAP = 98 // Encapsulation Header - ProtocolGMTP = 100 // GMTP - ProtocolIFMP = 101 // Ipsilon Flow Management Protocol - ProtocolPNNI = 102 // PNNI over IP - ProtocolPIM = 103 // Protocol Independent Multicast - ProtocolARIS = 104 // ARIS - ProtocolSCPS = 105 // SCPS - ProtocolQNX = 106 // QNX - ProtocolAN = 107 // Active Networks - ProtocolIPComp = 108 // IP Payload Compression Protocol - ProtocolSNP = 109 // Sitara Networks Protocol - ProtocolCompaqPeer = 110 // Compaq Peer Protocol - ProtocolIPXinIP = 111 // IPX in IP - ProtocolVRRP = 112 // Virtual Router Redundancy Protocol - ProtocolPGM = 113 // PGM Reliable Transport Protocol - ProtocolL2TP = 115 // Layer Two Tunneling Protocol - ProtocolDDX = 116 // D-II Data Exchange (DDX) - ProtocolIATP = 117 // Interactive Agent Transfer Protocol - ProtocolSTP = 118 // Schedule Transfer Protocol - ProtocolSRP = 119 // SpectraLink Radio Protocol - ProtocolUTI = 120 // UTI - ProtocolSMP = 121 // Simple Message Protocol - ProtocolPTP = 123 // Performance Transparency Protocol - ProtocolISIS = 124 // ISIS over IPv4 - ProtocolFIRE = 125 // FIRE - ProtocolCRTP = 126 // Combat Radio Transport Protocol - ProtocolCRUDP = 127 // Combat Radio User Datagram - ProtocolSSCOPMCE = 128 // SSCOPMCE - ProtocolIPLT = 129 // IPLT - ProtocolSPS = 130 // Secure Packet Shield - ProtocolPIPE = 131 // Private IP Encapsulation within IP - ProtocolSCTP = 132 // Stream Control Transmission Protocol - ProtocolFC = 133 // Fibre Channel - ProtocolRSVPE2EIGNORE = 134 // RSVP-E2E-IGNORE - ProtocolMobilityHeader = 135 // Mobility Header - ProtocolUDPLite = 136 // UDPLite - ProtocolMPLSinIP = 137 // MPLS-in-IP - ProtocolMANET = 138 // MANET Protocols - ProtocolHIP = 139 // Host Identity Protocol - ProtocolShim6 = 140 // Shim6 Protocol - ProtocolWESP = 141 // Wrapped Encapsulating Security Payload - ProtocolROHC = 142 // Robust Header Compression - ProtocolReserved = 255 // Reserved -) diff --git a/vendor/golang.org/x/net/internal/iana/gen.go b/vendor/golang.org/x/net/internal/iana/gen.go deleted file mode 100644 index 86c78b3bb..000000000 --- a/vendor/golang.org/x/net/internal/iana/gen.go +++ /dev/null @@ -1,293 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -//go:generate go run gen.go - -// This program generates internet protocol constants and tables by -// reading IANA protocol registries. -package main - -import ( - "bytes" - "encoding/xml" - "fmt" - "go/format" - "io" - "io/ioutil" - "net/http" - "os" - "strconv" - "strings" -) - -var registries = []struct { - url string - parse func(io.Writer, io.Reader) error -}{ - { - "http://www.iana.org/assignments/dscp-registry/dscp-registry.xml", - parseDSCPRegistry, - }, - { - "http://www.iana.org/assignments/ipv4-tos-byte/ipv4-tos-byte.xml", - parseTOSTCByte, - }, - { - "http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml", - parseProtocolNumbers, - }, -} - -func main() { - var bb bytes.Buffer - fmt.Fprintf(&bb, "// go generate gen.go\n") - fmt.Fprintf(&bb, "// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT\n\n") - fmt.Fprintf(&bb, "// Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA).\n") - fmt.Fprintf(&bb, `package iana // import "golang.org/x/net/internal/iana"`+"\n\n") - for _, r := range registries { - resp, err := http.Get(r.url) - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - fmt.Fprintf(os.Stderr, "got HTTP status code %v for %v\n", resp.StatusCode, r.url) - os.Exit(1) - } - if err := r.parse(&bb, resp.Body); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - fmt.Fprintf(&bb, "\n") - } - b, err := format.Source(bb.Bytes()) - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - if err := ioutil.WriteFile("const.go", b, 0644); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} - -func parseDSCPRegistry(w io.Writer, r io.Reader) error { - dec := xml.NewDecoder(r) - var dr dscpRegistry - if err := dec.Decode(&dr); err != nil { - return err - } - drs := dr.escape() - fmt.Fprintf(w, "// %s, Updated: %s\n", dr.Title, dr.Updated) - fmt.Fprintf(w, "const (\n") - for _, dr := range drs { - fmt.Fprintf(w, "DiffServ%s = %#x", dr.Name, dr.Value) - fmt.Fprintf(w, "// %s\n", dr.OrigName) - } - fmt.Fprintf(w, ")\n") - return nil -} - -type dscpRegistry struct { - XMLName xml.Name `xml:"registry"` - Title string `xml:"title"` - Updated string `xml:"updated"` - Note string `xml:"note"` - RegTitle string `xml:"registry>title"` - PoolRecords []struct { - Name string `xml:"name"` - Space string `xml:"space"` - } `xml:"registry>record"` - Records []struct { - Name string `xml:"name"` - Space string `xml:"space"` - } `xml:"registry>registry>record"` -} - -type canonDSCPRecord struct { - OrigName string - Name string - Value int -} - -func (drr *dscpRegistry) escape() []canonDSCPRecord { - drs := make([]canonDSCPRecord, len(drr.Records)) - sr := strings.NewReplacer( - "+", "", - "-", "", - "/", "", - ".", "", - " ", "", - ) - for i, dr := range drr.Records { - s := strings.TrimSpace(dr.Name) - drs[i].OrigName = s - drs[i].Name = sr.Replace(s) - n, err := strconv.ParseUint(dr.Space, 2, 8) - if err != nil { - continue - } - drs[i].Value = int(n) << 2 - } - return drs -} - -func parseTOSTCByte(w io.Writer, r io.Reader) error { - dec := xml.NewDecoder(r) - var ttb tosTCByte - if err := dec.Decode(&ttb); err != nil { - return err - } - trs := ttb.escape() - fmt.Fprintf(w, "// %s, Updated: %s\n", ttb.Title, ttb.Updated) - fmt.Fprintf(w, "const (\n") - for _, tr := range trs { - fmt.Fprintf(w, "%s = %#x", tr.Keyword, tr.Value) - fmt.Fprintf(w, "// %s\n", tr.OrigKeyword) - } - fmt.Fprintf(w, ")\n") - return nil -} - -type tosTCByte struct { - XMLName xml.Name `xml:"registry"` - Title string `xml:"title"` - Updated string `xml:"updated"` - Note string `xml:"note"` - RegTitle string `xml:"registry>title"` - Records []struct { - Binary string `xml:"binary"` - Keyword string `xml:"keyword"` - } `xml:"registry>record"` -} - -type canonTOSTCByteRecord struct { - OrigKeyword string - Keyword string - Value int -} - -func (ttb *tosTCByte) escape() []canonTOSTCByteRecord { - trs := make([]canonTOSTCByteRecord, len(ttb.Records)) - sr := strings.NewReplacer( - "Capable", "", - "(", "", - ")", "", - "+", "", - "-", "", - "/", "", - ".", "", - " ", "", - ) - for i, tr := range ttb.Records { - s := strings.TrimSpace(tr.Keyword) - trs[i].OrigKeyword = s - ss := strings.Split(s, " ") - if len(ss) > 1 { - trs[i].Keyword = strings.Join(ss[1:], " ") - } else { - trs[i].Keyword = ss[0] - } - trs[i].Keyword = sr.Replace(trs[i].Keyword) - n, err := strconv.ParseUint(tr.Binary, 2, 8) - if err != nil { - continue - } - trs[i].Value = int(n) - } - return trs -} - -func parseProtocolNumbers(w io.Writer, r io.Reader) error { - dec := xml.NewDecoder(r) - var pn protocolNumbers - if err := dec.Decode(&pn); err != nil { - return err - } - prs := pn.escape() - prs = append([]canonProtocolRecord{{ - Name: "IP", - Descr: "IPv4 encapsulation, pseudo protocol number", - Value: 0, - }}, prs...) - fmt.Fprintf(w, "// %s, Updated: %s\n", pn.Title, pn.Updated) - fmt.Fprintf(w, "const (\n") - for _, pr := range prs { - if pr.Name == "" { - continue - } - fmt.Fprintf(w, "Protocol%s = %d", pr.Name, pr.Value) - s := pr.Descr - if s == "" { - s = pr.OrigName - } - fmt.Fprintf(w, "// %s\n", s) - } - fmt.Fprintf(w, ")\n") - return nil -} - -type protocolNumbers struct { - XMLName xml.Name `xml:"registry"` - Title string `xml:"title"` - Updated string `xml:"updated"` - RegTitle string `xml:"registry>title"` - Note string `xml:"registry>note"` - Records []struct { - Value string `xml:"value"` - Name string `xml:"name"` - Descr string `xml:"description"` - } `xml:"registry>record"` -} - -type canonProtocolRecord struct { - OrigName string - Name string - Descr string - Value int -} - -func (pn *protocolNumbers) escape() []canonProtocolRecord { - prs := make([]canonProtocolRecord, len(pn.Records)) - sr := strings.NewReplacer( - "-in-", "in", - "-within-", "within", - "-over-", "over", - "+", "P", - "-", "", - "/", "", - ".", "", - " ", "", - ) - for i, pr := range pn.Records { - if strings.Contains(pr.Name, "Deprecated") || - strings.Contains(pr.Name, "deprecated") { - continue - } - prs[i].OrigName = pr.Name - s := strings.TrimSpace(pr.Name) - switch pr.Name { - case "ISIS over IPv4": - prs[i].Name = "ISIS" - case "manet": - prs[i].Name = "MANET" - default: - prs[i].Name = sr.Replace(s) - } - ss := strings.Split(pr.Descr, "\n") - for i := range ss { - ss[i] = strings.TrimSpace(ss[i]) - } - if len(ss) > 1 { - prs[i].Descr = strings.Join(ss, " ") - } else { - prs[i].Descr = ss[0] - } - prs[i].Value, _ = strconv.Atoi(pr.Value) - } - return prs -} diff --git a/vendor/golang.org/x/net/internal/netreflect/socket.go b/vendor/golang.org/x/net/internal/netreflect/socket.go deleted file mode 100644 index 1495b65f5..000000000 --- a/vendor/golang.org/x/net/internal/netreflect/socket.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.9 - -// Package netreflect implements run-time reflection for the -// facilities of net package. -// -// This package works only for Go 1.8 or below. -package netreflect - -import ( - "errors" - "net" -) - -var ( - errInvalidType = errors.New("invalid type") - errOpNoSupport = errors.New("operation not supported") -) - -// SocketOf returns the socket descriptor of c. -func SocketOf(c net.Conn) (uintptr, error) { - switch c.(type) { - case *net.TCPConn, *net.UDPConn, *net.IPConn, *net.UnixConn: - return socketOf(c) - default: - return 0, errInvalidType - } -} - -// PacketSocketOf returns the socket descriptor of c. -func PacketSocketOf(c net.PacketConn) (uintptr, error) { - switch c.(type) { - case *net.UDPConn, *net.IPConn, *net.UnixConn: - return socketOf(c.(net.Conn)) - default: - return 0, errInvalidType - } -} diff --git a/vendor/golang.org/x/net/internal/netreflect/socket_19.go b/vendor/golang.org/x/net/internal/netreflect/socket_19.go deleted file mode 100644 index 74df52e1a..000000000 --- a/vendor/golang.org/x/net/internal/netreflect/socket_19.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.9 - -package netreflect - -import ( - "errors" - "net" -) - -var ( - errInvalidType = errors.New("invalid type") - errOpNoSupport = errors.New("operation not supported") -) - -// SocketOf returns the socket descriptor of c. -func SocketOf(c net.Conn) (uintptr, error) { - switch c.(type) { - case *net.TCPConn, *net.UDPConn, *net.IPConn, *net.UnixConn: - return 0, errOpNoSupport - default: - return 0, errInvalidType - } -} - -// PacketSocketOf returns the socket descriptor of c. -func PacketSocketOf(c net.PacketConn) (uintptr, error) { - switch c.(type) { - case *net.UDPConn, *net.IPConn, *net.UnixConn: - return 0, errOpNoSupport - default: - return 0, errInvalidType - } -} diff --git a/vendor/golang.org/x/net/internal/netreflect/socket_posix.go b/vendor/golang.org/x/net/internal/netreflect/socket_posix.go deleted file mode 100644 index 410c0924d..000000000 --- a/vendor/golang.org/x/net/internal/netreflect/socket_posix.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.9 -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package netreflect - -import ( - "net" - "reflect" - "runtime" -) - -func socketOf(c net.Conn) (uintptr, error) { - v := reflect.ValueOf(c) - switch e := v.Elem(); e.Kind() { - case reflect.Struct: - fd := e.FieldByName("conn").FieldByName("fd") - switch e := fd.Elem(); e.Kind() { - case reflect.Struct: - sysfd := e.FieldByName("sysfd") - if runtime.GOOS == "windows" { - return uintptr(sysfd.Uint()), nil - } - return uintptr(sysfd.Int()), nil - } - } - return 0, errInvalidType -} diff --git a/vendor/golang.org/x/net/internal/netreflect/socket_stub.go b/vendor/golang.org/x/net/internal/netreflect/socket_stub.go deleted file mode 100644 index 17b20c478..000000000 --- a/vendor/golang.org/x/net/internal/netreflect/socket_stub.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.9 -// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows - -package netreflect - -import "net" - -func socketOf(c net.Conn) (uintptr, error) { return 0, errOpNoSupport } diff --git a/vendor/golang.org/x/net/internal/netreflect/socket_test.go b/vendor/golang.org/x/net/internal/netreflect/socket_test.go deleted file mode 100644 index b3aad0d92..000000000 --- a/vendor/golang.org/x/net/internal/netreflect/socket_test.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.9 -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package netreflect_test - -import ( - "net" - "os" - "testing" - - "golang.org/x/net/internal/netreflect" - "golang.org/x/net/internal/nettest" -) - -func TestSocketOf(t *testing.T) { - for _, network := range []string{"tcp", "unix", "unixpacket"} { - if !nettest.TestableNetwork(network) { - continue - } - ln, err := nettest.NewLocalListener(network) - if err != nil { - t.Error(err) - continue - } - defer func() { - path := ln.Addr().String() - ln.Close() - if network == "unix" || network == "unixpacket" { - os.Remove(path) - } - }() - c, err := net.Dial(ln.Addr().Network(), ln.Addr().String()) - if err != nil { - t.Error(err) - continue - } - defer c.Close() - if _, err := netreflect.SocketOf(c); err != nil { - t.Error(err) - continue - } - } -} - -func TestPacketSocketOf(t *testing.T) { - for _, network := range []string{"udp", "unixgram"} { - if !nettest.TestableNetwork(network) { - continue - } - c, err := nettest.NewLocalPacketListener(network) - if err != nil { - t.Error(err) - continue - } - defer c.Close() - if _, err := netreflect.PacketSocketOf(c); err != nil { - t.Error(err) - continue - } - } -} diff --git a/vendor/golang.org/x/net/internal/nettest/helper_bsd.go b/vendor/golang.org/x/net/internal/nettest/helper_bsd.go deleted file mode 100644 index a6e433b58..000000000 --- a/vendor/golang.org/x/net/internal/nettest/helper_bsd.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package nettest - -import ( - "runtime" - "strconv" - "strings" - "syscall" -) - -var darwinVersion int - -func init() { - if runtime.GOOS == "darwin" { - // See http://support.apple.com/kb/HT1633. - s, err := syscall.Sysctl("kern.osrelease") - if err != nil { - return - } - ss := strings.Split(s, ".") - if len(ss) == 0 { - return - } - darwinVersion, _ = strconv.Atoi(ss[0]) - } -} - -func supportsIPv6MulticastDeliveryOnLoopback() bool { - switch runtime.GOOS { - case "freebsd": - // See http://www.freebsd.org/cgi/query-pr.cgi?pr=180065. - // Even after the fix, it looks like the latest - // kernels don't deliver link-local scoped multicast - // packets correctly. - return false - case "darwin": - return !causesIPv6Crash() - default: - return true - } -} - -func causesIPv6Crash() bool { - // We see some kernel crash when running IPv6 with IP-level - // options on Darwin kernel version 12 or below. - // See golang.org/issues/17015. - return darwinVersion < 13 -} diff --git a/vendor/golang.org/x/net/internal/nettest/helper_nobsd.go b/vendor/golang.org/x/net/internal/nettest/helper_nobsd.go deleted file mode 100644 index bc7da5e0d..000000000 --- a/vendor/golang.org/x/net/internal/nettest/helper_nobsd.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build linux solaris - -package nettest - -func supportsIPv6MulticastDeliveryOnLoopback() bool { - return true -} - -func causesIPv6Crash() bool { - return false -} diff --git a/vendor/golang.org/x/net/internal/nettest/helper_posix.go b/vendor/golang.org/x/net/internal/nettest/helper_posix.go deleted file mode 100644 index 963ed9965..000000000 --- a/vendor/golang.org/x/net/internal/nettest/helper_posix.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package nettest - -import ( - "os" - "syscall" -) - -func protocolNotSupported(err error) bool { - switch err := err.(type) { - case syscall.Errno: - switch err { - case syscall.EPROTONOSUPPORT, syscall.ENOPROTOOPT: - return true - } - case *os.SyscallError: - switch err := err.Err.(type) { - case syscall.Errno: - switch err { - case syscall.EPROTONOSUPPORT, syscall.ENOPROTOOPT: - return true - } - } - } - return false -} diff --git a/vendor/golang.org/x/net/internal/nettest/helper_stub.go b/vendor/golang.org/x/net/internal/nettest/helper_stub.go deleted file mode 100644 index ea61b6f39..000000000 --- a/vendor/golang.org/x/net/internal/nettest/helper_stub.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package nettest - -import ( - "fmt" - "runtime" -) - -func maxOpenFiles() int { - return defaultMaxOpenFiles -} - -func supportsRawIPSocket() (string, bool) { - return fmt.Sprintf("not supported on %s", runtime.GOOS), false -} - -func supportsIPv6MulticastDeliveryOnLoopback() bool { - return false -} - -func causesIPv6Crash() bool { - return false -} - -func protocolNotSupported(err error) bool { - return false -} diff --git a/vendor/golang.org/x/net/internal/nettest/helper_unix.go b/vendor/golang.org/x/net/internal/nettest/helper_unix.go deleted file mode 100644 index ed13e448b..000000000 --- a/vendor/golang.org/x/net/internal/nettest/helper_unix.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package nettest - -import ( - "fmt" - "os" - "runtime" - "syscall" -) - -func maxOpenFiles() int { - var rlim syscall.Rlimit - if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlim); err != nil { - return defaultMaxOpenFiles - } - return int(rlim.Cur) -} - -func supportsRawIPSocket() (string, bool) { - if os.Getuid() != 0 { - return fmt.Sprintf("must be root on %s", runtime.GOOS), false - } - return "", true -} diff --git a/vendor/golang.org/x/net/internal/nettest/helper_windows.go b/vendor/golang.org/x/net/internal/nettest/helper_windows.go deleted file mode 100644 index 3dcb727c9..000000000 --- a/vendor/golang.org/x/net/internal/nettest/helper_windows.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package nettest - -import ( - "fmt" - "runtime" - "syscall" -) - -func maxOpenFiles() int { - return 4 * defaultMaxOpenFiles /* actually it's 16581375 */ -} - -func supportsRawIPSocket() (string, bool) { - // From http://msdn.microsoft.com/en-us/library/windows/desktop/ms740548.aspx: - // Note: To use a socket of type SOCK_RAW requires administrative privileges. - // Users running Winsock applications that use raw sockets must be a member of - // the Administrators group on the local computer, otherwise raw socket calls - // will fail with an error code of WSAEACCES. On Windows Vista and later, access - // for raw sockets is enforced at socket creation. In earlier versions of Windows, - // access for raw sockets is enforced during other socket operations. - s, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_RAW, 0) - if err == syscall.WSAEACCES { - return fmt.Sprintf("no access to raw socket allowed on %s", runtime.GOOS), false - } - if err != nil { - return err.Error(), false - } - syscall.Closesocket(s) - return "", true -} - -func supportsIPv6MulticastDeliveryOnLoopback() bool { - return true -} - -func causesIPv6Crash() bool { - return false -} diff --git a/vendor/golang.org/x/net/internal/nettest/interface.go b/vendor/golang.org/x/net/internal/nettest/interface.go deleted file mode 100644 index 8e6333afe..000000000 --- a/vendor/golang.org/x/net/internal/nettest/interface.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package nettest - -import "net" - -// IsMulticastCapable reports whether ifi is an IP multicast-capable -// network interface. Network must be "ip", "ip4" or "ip6". -func IsMulticastCapable(network string, ifi *net.Interface) (net.IP, bool) { - switch network { - case "ip", "ip4", "ip6": - default: - return nil, false - } - if ifi == nil || ifi.Flags&net.FlagUp == 0 || ifi.Flags&net.FlagMulticast == 0 { - return nil, false - } - return hasRoutableIP(network, ifi) -} - -// RoutedInterface returns a network interface that can route IP -// traffic and satisfies flags. It returns nil when an appropriate -// network interface is not found. Network must be "ip", "ip4" or -// "ip6". -func RoutedInterface(network string, flags net.Flags) *net.Interface { - switch network { - case "ip", "ip4", "ip6": - default: - return nil - } - ift, err := net.Interfaces() - if err != nil { - return nil - } - for _, ifi := range ift { - if ifi.Flags&flags != flags { - continue - } - if _, ok := hasRoutableIP(network, &ifi); !ok { - continue - } - return &ifi - } - return nil -} - -func hasRoutableIP(network string, ifi *net.Interface) (net.IP, bool) { - ifat, err := ifi.Addrs() - if err != nil { - return nil, false - } - for _, ifa := range ifat { - switch ifa := ifa.(type) { - case *net.IPAddr: - if ip := routableIP(network, ifa.IP); ip != nil { - return ip, true - } - case *net.IPNet: - if ip := routableIP(network, ifa.IP); ip != nil { - return ip, true - } - } - } - return nil, false -} - -func routableIP(network string, ip net.IP) net.IP { - if !ip.IsLoopback() && !ip.IsLinkLocalUnicast() && !ip.IsGlobalUnicast() { - return nil - } - switch network { - case "ip4": - if ip := ip.To4(); ip != nil { - return ip - } - case "ip6": - if ip.IsLoopback() { // addressing scope of the loopback address depends on each implementation - return nil - } - if ip := ip.To16(); ip != nil && ip.To4() == nil { - return ip - } - default: - if ip := ip.To4(); ip != nil { - return ip - } - if ip := ip.To16(); ip != nil { - return ip - } - } - return nil -} diff --git a/vendor/golang.org/x/net/internal/nettest/rlimit.go b/vendor/golang.org/x/net/internal/nettest/rlimit.go deleted file mode 100644 index bb34aec0b..000000000 --- a/vendor/golang.org/x/net/internal/nettest/rlimit.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package nettest - -const defaultMaxOpenFiles = 256 - -// MaxOpenFiles returns the maximum number of open files for the -// caller's process. -func MaxOpenFiles() int { return maxOpenFiles() } diff --git a/vendor/golang.org/x/net/internal/nettest/stack.go b/vendor/golang.org/x/net/internal/nettest/stack.go deleted file mode 100644 index cc92c035b..000000000 --- a/vendor/golang.org/x/net/internal/nettest/stack.go +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package nettest provides utilities for network testing. -package nettest // import "golang.org/x/net/internal/nettest" - -import ( - "fmt" - "io/ioutil" - "net" - "os" - "runtime" -) - -var ( - supportsIPv4 bool - supportsIPv6 bool -) - -func init() { - if ln, err := net.Listen("tcp4", "127.0.0.1:0"); err == nil { - ln.Close() - supportsIPv4 = true - } - if ln, err := net.Listen("tcp6", "[::1]:0"); err == nil { - ln.Close() - supportsIPv6 = true - } -} - -// SupportsIPv4 reports whether the platform supports IPv4 networking -// functionality. -func SupportsIPv4() bool { return supportsIPv4 } - -// SupportsIPv6 reports whether the platform supports IPv6 networking -// functionality. -func SupportsIPv6() bool { return supportsIPv6 } - -// SupportsRawIPSocket reports whether the platform supports raw IP -// sockets. -func SupportsRawIPSocket() (string, bool) { - return supportsRawIPSocket() -} - -// SupportsIPv6MulticastDeliveryOnLoopback reports whether the -// platform supports IPv6 multicast packet delivery on software -// loopback interface. -func SupportsIPv6MulticastDeliveryOnLoopback() bool { - return supportsIPv6MulticastDeliveryOnLoopback() -} - -// ProtocolNotSupported reports whether err is a protocol not -// supported error. -func ProtocolNotSupported(err error) bool { - return protocolNotSupported(err) -} - -// TestableNetwork reports whether network is testable on the current -// platform configuration. -func TestableNetwork(network string) bool { - // This is based on logic from standard library's - // net/platform_test.go. - switch network { - case "unix", "unixgram": - switch runtime.GOOS { - case "android", "nacl", "plan9", "windows": - return false - } - if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") { - return false - } - case "unixpacket": - switch runtime.GOOS { - case "android", "darwin", "freebsd", "nacl", "plan9", "windows": - return false - } - } - return true -} - -// NewLocalListener returns a listener which listens to a loopback IP -// address or local file system path. -// Network must be "tcp", "tcp4", "tcp6", "unix" or "unixpacket". -func NewLocalListener(network string) (net.Listener, error) { - switch network { - case "tcp": - if supportsIPv4 { - if ln, err := net.Listen("tcp4", "127.0.0.1:0"); err == nil { - return ln, nil - } - } - if supportsIPv6 { - return net.Listen("tcp6", "[::1]:0") - } - case "tcp4": - if supportsIPv4 { - return net.Listen("tcp4", "127.0.0.1:0") - } - case "tcp6": - if supportsIPv6 { - return net.Listen("tcp6", "[::1]:0") - } - case "unix", "unixpacket": - return net.Listen(network, localPath()) - } - return nil, fmt.Errorf("%s is not supported", network) -} - -// NewLocalPacketListener returns a packet listener which listens to a -// loopback IP address or local file system path. -// Network must be "udp", "udp4", "udp6" or "unixgram". -func NewLocalPacketListener(network string) (net.PacketConn, error) { - switch network { - case "udp": - if supportsIPv4 { - if c, err := net.ListenPacket("udp4", "127.0.0.1:0"); err == nil { - return c, nil - } - } - if supportsIPv6 { - return net.ListenPacket("udp6", "[::1]:0") - } - case "udp4": - if supportsIPv4 { - return net.ListenPacket("udp4", "127.0.0.1:0") - } - case "udp6": - if supportsIPv6 { - return net.ListenPacket("udp6", "[::1]:0") - } - case "unixgram": - return net.ListenPacket(network, localPath()) - } - return nil, fmt.Errorf("%s is not supported", network) -} - -func localPath() string { - f, err := ioutil.TempFile("", "nettest") - if err != nil { - panic(err) - } - path := f.Name() - f.Close() - os.Remove(path) - return path -} diff --git a/vendor/golang.org/x/net/internal/timeseries/timeseries.go b/vendor/golang.org/x/net/internal/timeseries/timeseries.go deleted file mode 100644 index 685f0e7ea..000000000 --- a/vendor/golang.org/x/net/internal/timeseries/timeseries.go +++ /dev/null @@ -1,525 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package timeseries implements a time series structure for stats collection. -package timeseries // import "golang.org/x/net/internal/timeseries" - -import ( - "fmt" - "log" - "time" -) - -const ( - timeSeriesNumBuckets = 64 - minuteHourSeriesNumBuckets = 60 -) - -var timeSeriesResolutions = []time.Duration{ - 1 * time.Second, - 10 * time.Second, - 1 * time.Minute, - 10 * time.Minute, - 1 * time.Hour, - 6 * time.Hour, - 24 * time.Hour, // 1 day - 7 * 24 * time.Hour, // 1 week - 4 * 7 * 24 * time.Hour, // 4 weeks - 16 * 7 * 24 * time.Hour, // 16 weeks -} - -var minuteHourSeriesResolutions = []time.Duration{ - 1 * time.Second, - 1 * time.Minute, -} - -// An Observable is a kind of data that can be aggregated in a time series. -type Observable interface { - Multiply(ratio float64) // Multiplies the data in self by a given ratio - Add(other Observable) // Adds the data from a different observation to self - Clear() // Clears the observation so it can be reused. - CopyFrom(other Observable) // Copies the contents of a given observation to self -} - -// Float attaches the methods of Observable to a float64. -type Float float64 - -// NewFloat returns a Float. -func NewFloat() Observable { - f := Float(0) - return &f -} - -// String returns the float as a string. -func (f *Float) String() string { return fmt.Sprintf("%g", f.Value()) } - -// Value returns the float's value. -func (f *Float) Value() float64 { return float64(*f) } - -func (f *Float) Multiply(ratio float64) { *f *= Float(ratio) } - -func (f *Float) Add(other Observable) { - o := other.(*Float) - *f += *o -} - -func (f *Float) Clear() { *f = 0 } - -func (f *Float) CopyFrom(other Observable) { - o := other.(*Float) - *f = *o -} - -// A Clock tells the current time. -type Clock interface { - Time() time.Time -} - -type defaultClock int - -var defaultClockInstance defaultClock - -func (defaultClock) Time() time.Time { return time.Now() } - -// Information kept per level. Each level consists of a circular list of -// observations. The start of the level may be derived from end and the -// len(buckets) * sizeInMillis. -type tsLevel struct { - oldest int // index to oldest bucketed Observable - newest int // index to newest bucketed Observable - end time.Time // end timestamp for this level - size time.Duration // duration of the bucketed Observable - buckets []Observable // collections of observations - provider func() Observable // used for creating new Observable -} - -func (l *tsLevel) Clear() { - l.oldest = 0 - l.newest = len(l.buckets) - 1 - l.end = time.Time{} - for i := range l.buckets { - if l.buckets[i] != nil { - l.buckets[i].Clear() - l.buckets[i] = nil - } - } -} - -func (l *tsLevel) InitLevel(size time.Duration, numBuckets int, f func() Observable) { - l.size = size - l.provider = f - l.buckets = make([]Observable, numBuckets) -} - -// Keeps a sequence of levels. Each level is responsible for storing data at -// a given resolution. For example, the first level stores data at a one -// minute resolution while the second level stores data at a one hour -// resolution. - -// Each level is represented by a sequence of buckets. Each bucket spans an -// interval equal to the resolution of the level. New observations are added -// to the last bucket. -type timeSeries struct { - provider func() Observable // make more Observable - numBuckets int // number of buckets in each level - levels []*tsLevel // levels of bucketed Observable - lastAdd time.Time // time of last Observable tracked - total Observable // convenient aggregation of all Observable - clock Clock // Clock for getting current time - pending Observable // observations not yet bucketed - pendingTime time.Time // what time are we keeping in pending - dirty bool // if there are pending observations -} - -// init initializes a level according to the supplied criteria. -func (ts *timeSeries) init(resolutions []time.Duration, f func() Observable, numBuckets int, clock Clock) { - ts.provider = f - ts.numBuckets = numBuckets - ts.clock = clock - ts.levels = make([]*tsLevel, len(resolutions)) - - for i := range resolutions { - if i > 0 && resolutions[i-1] >= resolutions[i] { - log.Print("timeseries: resolutions must be monotonically increasing") - break - } - newLevel := new(tsLevel) - newLevel.InitLevel(resolutions[i], ts.numBuckets, ts.provider) - ts.levels[i] = newLevel - } - - ts.Clear() -} - -// Clear removes all observations from the time series. -func (ts *timeSeries) Clear() { - ts.lastAdd = time.Time{} - ts.total = ts.resetObservation(ts.total) - ts.pending = ts.resetObservation(ts.pending) - ts.pendingTime = time.Time{} - ts.dirty = false - - for i := range ts.levels { - ts.levels[i].Clear() - } -} - -// Add records an observation at the current time. -func (ts *timeSeries) Add(observation Observable) { - ts.AddWithTime(observation, ts.clock.Time()) -} - -// AddWithTime records an observation at the specified time. -func (ts *timeSeries) AddWithTime(observation Observable, t time.Time) { - - smallBucketDuration := ts.levels[0].size - - if t.After(ts.lastAdd) { - ts.lastAdd = t - } - - if t.After(ts.pendingTime) { - ts.advance(t) - ts.mergePendingUpdates() - ts.pendingTime = ts.levels[0].end - ts.pending.CopyFrom(observation) - ts.dirty = true - } else if t.After(ts.pendingTime.Add(-1 * smallBucketDuration)) { - // The observation is close enough to go into the pending bucket. - // This compensates for clock skewing and small scheduling delays - // by letting the update stay in the fast path. - ts.pending.Add(observation) - ts.dirty = true - } else { - ts.mergeValue(observation, t) - } -} - -// mergeValue inserts the observation at the specified time in the past into all levels. -func (ts *timeSeries) mergeValue(observation Observable, t time.Time) { - for _, level := range ts.levels { - index := (ts.numBuckets - 1) - int(level.end.Sub(t)/level.size) - if 0 <= index && index < ts.numBuckets { - bucketNumber := (level.oldest + index) % ts.numBuckets - if level.buckets[bucketNumber] == nil { - level.buckets[bucketNumber] = level.provider() - } - level.buckets[bucketNumber].Add(observation) - } - } - ts.total.Add(observation) -} - -// mergePendingUpdates applies the pending updates into all levels. -func (ts *timeSeries) mergePendingUpdates() { - if ts.dirty { - ts.mergeValue(ts.pending, ts.pendingTime) - ts.pending = ts.resetObservation(ts.pending) - ts.dirty = false - } -} - -// advance cycles the buckets at each level until the latest bucket in -// each level can hold the time specified. -func (ts *timeSeries) advance(t time.Time) { - if !t.After(ts.levels[0].end) { - return - } - for i := 0; i < len(ts.levels); i++ { - level := ts.levels[i] - if !level.end.Before(t) { - break - } - - // If the time is sufficiently far, just clear the level and advance - // directly. - if !t.Before(level.end.Add(level.size * time.Duration(ts.numBuckets))) { - for _, b := range level.buckets { - ts.resetObservation(b) - } - level.end = time.Unix(0, (t.UnixNano()/level.size.Nanoseconds())*level.size.Nanoseconds()) - } - - for t.After(level.end) { - level.end = level.end.Add(level.size) - level.newest = level.oldest - level.oldest = (level.oldest + 1) % ts.numBuckets - ts.resetObservation(level.buckets[level.newest]) - } - - t = level.end - } -} - -// Latest returns the sum of the num latest buckets from the level. -func (ts *timeSeries) Latest(level, num int) Observable { - now := ts.clock.Time() - if ts.levels[0].end.Before(now) { - ts.advance(now) - } - - ts.mergePendingUpdates() - - result := ts.provider() - l := ts.levels[level] - index := l.newest - - for i := 0; i < num; i++ { - if l.buckets[index] != nil { - result.Add(l.buckets[index]) - } - if index == 0 { - index = ts.numBuckets - } - index-- - } - - return result -} - -// LatestBuckets returns a copy of the num latest buckets from level. -func (ts *timeSeries) LatestBuckets(level, num int) []Observable { - if level < 0 || level > len(ts.levels) { - log.Print("timeseries: bad level argument: ", level) - return nil - } - if num < 0 || num >= ts.numBuckets { - log.Print("timeseries: bad num argument: ", num) - return nil - } - - results := make([]Observable, num) - now := ts.clock.Time() - if ts.levels[0].end.Before(now) { - ts.advance(now) - } - - ts.mergePendingUpdates() - - l := ts.levels[level] - index := l.newest - - for i := 0; i < num; i++ { - result := ts.provider() - results[i] = result - if l.buckets[index] != nil { - result.CopyFrom(l.buckets[index]) - } - - if index == 0 { - index = ts.numBuckets - } - index -= 1 - } - return results -} - -// ScaleBy updates observations by scaling by factor. -func (ts *timeSeries) ScaleBy(factor float64) { - for _, l := range ts.levels { - for i := 0; i < ts.numBuckets; i++ { - l.buckets[i].Multiply(factor) - } - } - - ts.total.Multiply(factor) - ts.pending.Multiply(factor) -} - -// Range returns the sum of observations added over the specified time range. -// If start or finish times don't fall on bucket boundaries of the same -// level, then return values are approximate answers. -func (ts *timeSeries) Range(start, finish time.Time) Observable { - return ts.ComputeRange(start, finish, 1)[0] -} - -// Recent returns the sum of observations from the last delta. -func (ts *timeSeries) Recent(delta time.Duration) Observable { - now := ts.clock.Time() - return ts.Range(now.Add(-delta), now) -} - -// Total returns the total of all observations. -func (ts *timeSeries) Total() Observable { - ts.mergePendingUpdates() - return ts.total -} - -// ComputeRange computes a specified number of values into a slice using -// the observations recorded over the specified time period. The return -// values are approximate if the start or finish times don't fall on the -// bucket boundaries at the same level or if the number of buckets spanning -// the range is not an integral multiple of num. -func (ts *timeSeries) ComputeRange(start, finish time.Time, num int) []Observable { - if start.After(finish) { - log.Printf("timeseries: start > finish, %v>%v", start, finish) - return nil - } - - if num < 0 { - log.Printf("timeseries: num < 0, %v", num) - return nil - } - - results := make([]Observable, num) - - for _, l := range ts.levels { - if !start.Before(l.end.Add(-l.size * time.Duration(ts.numBuckets))) { - ts.extract(l, start, finish, num, results) - return results - } - } - - // Failed to find a level that covers the desired range. So just - // extract from the last level, even if it doesn't cover the entire - // desired range. - ts.extract(ts.levels[len(ts.levels)-1], start, finish, num, results) - - return results -} - -// RecentList returns the specified number of values in slice over the most -// recent time period of the specified range. -func (ts *timeSeries) RecentList(delta time.Duration, num int) []Observable { - if delta < 0 { - return nil - } - now := ts.clock.Time() - return ts.ComputeRange(now.Add(-delta), now, num) -} - -// extract returns a slice of specified number of observations from a given -// level over a given range. -func (ts *timeSeries) extract(l *tsLevel, start, finish time.Time, num int, results []Observable) { - ts.mergePendingUpdates() - - srcInterval := l.size - dstInterval := finish.Sub(start) / time.Duration(num) - dstStart := start - srcStart := l.end.Add(-srcInterval * time.Duration(ts.numBuckets)) - - srcIndex := 0 - - // Where should scanning start? - if dstStart.After(srcStart) { - advance := dstStart.Sub(srcStart) / srcInterval - srcIndex += int(advance) - srcStart = srcStart.Add(advance * srcInterval) - } - - // The i'th value is computed as show below. - // interval = (finish/start)/num - // i'th value = sum of observation in range - // [ start + i * interval, - // start + (i + 1) * interval ) - for i := 0; i < num; i++ { - results[i] = ts.resetObservation(results[i]) - dstEnd := dstStart.Add(dstInterval) - for srcIndex < ts.numBuckets && srcStart.Before(dstEnd) { - srcEnd := srcStart.Add(srcInterval) - if srcEnd.After(ts.lastAdd) { - srcEnd = ts.lastAdd - } - - if !srcEnd.Before(dstStart) { - srcValue := l.buckets[(srcIndex+l.oldest)%ts.numBuckets] - if !srcStart.Before(dstStart) && !srcEnd.After(dstEnd) { - // dst completely contains src. - if srcValue != nil { - results[i].Add(srcValue) - } - } else { - // dst partially overlaps src. - overlapStart := maxTime(srcStart, dstStart) - overlapEnd := minTime(srcEnd, dstEnd) - base := srcEnd.Sub(srcStart) - fraction := overlapEnd.Sub(overlapStart).Seconds() / base.Seconds() - - used := ts.provider() - if srcValue != nil { - used.CopyFrom(srcValue) - } - used.Multiply(fraction) - results[i].Add(used) - } - - if srcEnd.After(dstEnd) { - break - } - } - srcIndex++ - srcStart = srcStart.Add(srcInterval) - } - dstStart = dstStart.Add(dstInterval) - } -} - -// resetObservation clears the content so the struct may be reused. -func (ts *timeSeries) resetObservation(observation Observable) Observable { - if observation == nil { - observation = ts.provider() - } else { - observation.Clear() - } - return observation -} - -// TimeSeries tracks data at granularities from 1 second to 16 weeks. -type TimeSeries struct { - timeSeries -} - -// NewTimeSeries creates a new TimeSeries using the function provided for creating new Observable. -func NewTimeSeries(f func() Observable) *TimeSeries { - return NewTimeSeriesWithClock(f, defaultClockInstance) -} - -// NewTimeSeriesWithClock creates a new TimeSeries using the function provided for creating new Observable and the clock for -// assigning timestamps. -func NewTimeSeriesWithClock(f func() Observable, clock Clock) *TimeSeries { - ts := new(TimeSeries) - ts.timeSeries.init(timeSeriesResolutions, f, timeSeriesNumBuckets, clock) - return ts -} - -// MinuteHourSeries tracks data at granularities of 1 minute and 1 hour. -type MinuteHourSeries struct { - timeSeries -} - -// NewMinuteHourSeries creates a new MinuteHourSeries using the function provided for creating new Observable. -func NewMinuteHourSeries(f func() Observable) *MinuteHourSeries { - return NewMinuteHourSeriesWithClock(f, defaultClockInstance) -} - -// NewMinuteHourSeriesWithClock creates a new MinuteHourSeries using the function provided for creating new Observable and the clock for -// assigning timestamps. -func NewMinuteHourSeriesWithClock(f func() Observable, clock Clock) *MinuteHourSeries { - ts := new(MinuteHourSeries) - ts.timeSeries.init(minuteHourSeriesResolutions, f, - minuteHourSeriesNumBuckets, clock) - return ts -} - -func (ts *MinuteHourSeries) Minute() Observable { - return ts.timeSeries.Latest(0, 60) -} - -func (ts *MinuteHourSeries) Hour() Observable { - return ts.timeSeries.Latest(1, 60) -} - -func minTime(a, b time.Time) time.Time { - if a.Before(b) { - return a - } - return b -} - -func maxTime(a, b time.Time) time.Time { - if a.After(b) { - return a - } - return b -} diff --git a/vendor/golang.org/x/net/internal/timeseries/timeseries_test.go b/vendor/golang.org/x/net/internal/timeseries/timeseries_test.go deleted file mode 100644 index 66325a912..000000000 --- a/vendor/golang.org/x/net/internal/timeseries/timeseries_test.go +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package timeseries - -import ( - "math" - "testing" - "time" -) - -func isNear(x *Float, y float64, tolerance float64) bool { - return math.Abs(x.Value()-y) < tolerance -} - -func isApproximate(x *Float, y float64) bool { - return isNear(x, y, 1e-2) -} - -func checkApproximate(t *testing.T, o Observable, y float64) { - x := o.(*Float) - if !isApproximate(x, y) { - t.Errorf("Wanted %g, got %g", y, x.Value()) - } -} - -func checkNear(t *testing.T, o Observable, y, tolerance float64) { - x := o.(*Float) - if !isNear(x, y, tolerance) { - t.Errorf("Wanted %g +- %g, got %g", y, tolerance, x.Value()) - } -} - -var baseTime = time.Date(2013, 1, 1, 0, 0, 0, 0, time.UTC) - -func tu(s int64) time.Time { - return baseTime.Add(time.Duration(s) * time.Second) -} - -func tu2(s int64, ns int64) time.Time { - return baseTime.Add(time.Duration(s)*time.Second + time.Duration(ns)*time.Nanosecond) -} - -func TestBasicTimeSeries(t *testing.T) { - ts := NewTimeSeries(NewFloat) - fo := new(Float) - *fo = Float(10) - ts.AddWithTime(fo, tu(1)) - ts.AddWithTime(fo, tu(1)) - ts.AddWithTime(fo, tu(1)) - ts.AddWithTime(fo, tu(1)) - checkApproximate(t, ts.Range(tu(0), tu(1)), 40) - checkApproximate(t, ts.Total(), 40) - ts.AddWithTime(fo, tu(3)) - ts.AddWithTime(fo, tu(3)) - ts.AddWithTime(fo, tu(3)) - checkApproximate(t, ts.Range(tu(0), tu(2)), 40) - checkApproximate(t, ts.Range(tu(2), tu(4)), 30) - checkApproximate(t, ts.Total(), 70) - ts.AddWithTime(fo, tu(1)) - ts.AddWithTime(fo, tu(1)) - checkApproximate(t, ts.Range(tu(0), tu(2)), 60) - checkApproximate(t, ts.Range(tu(2), tu(4)), 30) - checkApproximate(t, ts.Total(), 90) - *fo = Float(100) - ts.AddWithTime(fo, tu(100)) - checkApproximate(t, ts.Range(tu(99), tu(100)), 100) - checkApproximate(t, ts.Range(tu(0), tu(4)), 36) - checkApproximate(t, ts.Total(), 190) - *fo = Float(10) - ts.AddWithTime(fo, tu(1)) - ts.AddWithTime(fo, tu(1)) - checkApproximate(t, ts.Range(tu(0), tu(4)), 44) - checkApproximate(t, ts.Range(tu(37), tu2(100, 100e6)), 100) - checkApproximate(t, ts.Range(tu(50), tu2(100, 100e6)), 100) - checkApproximate(t, ts.Range(tu(99), tu2(100, 100e6)), 100) - checkApproximate(t, ts.Total(), 210) - - for i, l := range ts.ComputeRange(tu(36), tu(100), 64) { - if i == 63 { - checkApproximate(t, l, 100) - } else { - checkApproximate(t, l, 0) - } - } - - checkApproximate(t, ts.Range(tu(0), tu(100)), 210) - checkApproximate(t, ts.Range(tu(10), tu(100)), 100) - - for i, l := range ts.ComputeRange(tu(0), tu(100), 100) { - if i < 10 { - checkApproximate(t, l, 11) - } else if i >= 90 { - checkApproximate(t, l, 10) - } else { - checkApproximate(t, l, 0) - } - } -} - -func TestFloat(t *testing.T) { - f := Float(1) - if g, w := f.String(), "1"; g != w { - t.Errorf("Float(1).String = %q; want %q", g, w) - } - f2 := Float(2) - var o Observable = &f2 - f.Add(o) - if g, w := f.Value(), 3.0; g != w { - t.Errorf("Float post-add = %v; want %v", g, w) - } - f.Multiply(2) - if g, w := f.Value(), 6.0; g != w { - t.Errorf("Float post-multiply = %v; want %v", g, w) - } - f.Clear() - if g, w := f.Value(), 0.0; g != w { - t.Errorf("Float post-clear = %v; want %v", g, w) - } - f.CopyFrom(&f2) - if g, w := f.Value(), 2.0; g != w { - t.Errorf("Float post-CopyFrom = %v; want %v", g, w) - } -} - -type mockClock struct { - time time.Time -} - -func (m *mockClock) Time() time.Time { return m.time } -func (m *mockClock) Set(t time.Time) { m.time = t } - -const buckets = 6 - -var testResolutions = []time.Duration{ - 10 * time.Second, // level holds one minute of observations - 100 * time.Second, // level holds ten minutes of observations - 10 * time.Minute, // level holds one hour of observations -} - -// TestTimeSeries uses a small number of buckets to force a higher -// error rate on approximations from the timeseries. -type TestTimeSeries struct { - timeSeries -} - -func TestExpectedErrorRate(t *testing.T) { - ts := new(TestTimeSeries) - fake := new(mockClock) - fake.Set(time.Now()) - ts.timeSeries.init(testResolutions, NewFloat, buckets, fake) - for i := 1; i <= 61*61; i++ { - fake.Set(fake.Time().Add(1 * time.Second)) - ob := Float(1) - ts.AddWithTime(&ob, fake.Time()) - - // The results should be accurate within one missing bucket (1/6) of the observations recorded. - checkNear(t, ts.Latest(0, buckets), min(float64(i), 60), 10) - checkNear(t, ts.Latest(1, buckets), min(float64(i), 600), 100) - checkNear(t, ts.Latest(2, buckets), min(float64(i), 3600), 600) - } -} - -func min(a, b float64) float64 { - if a < b { - return a - } - return b -} diff --git a/vendor/golang.org/x/net/ipv4/bpf_test.go b/vendor/golang.org/x/net/ipv4/bpf_test.go deleted file mode 100644 index b44da9054..000000000 --- a/vendor/golang.org/x/net/ipv4/bpf_test.go +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "net" - "runtime" - "testing" - "time" - - "golang.org/x/net/bpf" - "golang.org/x/net/ipv4" -) - -func TestBPF(t *testing.T) { - if runtime.GOOS != "linux" { - t.Skipf("not supported on %s", runtime.GOOS) - } - - l, err := net.ListenPacket("udp4", "127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - defer l.Close() - - p := ipv4.NewPacketConn(l) - - // This filter accepts UDP packets whose first payload byte is - // even. - prog, err := bpf.Assemble([]bpf.Instruction{ - // Load the first byte of the payload (skipping UDP header). - bpf.LoadAbsolute{Off: 8, Size: 1}, - // Select LSB of the byte. - bpf.ALUOpConstant{Op: bpf.ALUOpAnd, Val: 1}, - // Byte is even? - bpf.JumpIf{Cond: bpf.JumpEqual, Val: 0, SkipFalse: 1}, - // Accept. - bpf.RetConstant{Val: 4096}, - // Ignore. - bpf.RetConstant{Val: 0}, - }) - if err != nil { - t.Fatalf("compiling BPF: %s", err) - } - - if err = p.SetBPF(prog); err != nil { - t.Fatalf("attaching filter to Conn: %s", err) - } - - s, err := net.Dial("udp4", l.LocalAddr().String()) - if err != nil { - t.Fatal(err) - } - defer s.Close() - go func() { - for i := byte(0); i < 10; i++ { - s.Write([]byte{i}) - } - }() - - l.SetDeadline(time.Now().Add(2 * time.Second)) - seen := make([]bool, 5) - for { - var b [512]byte - n, _, err := l.ReadFrom(b[:]) - if err != nil { - t.Fatalf("reading from listener: %s", err) - } - if n != 1 { - t.Fatalf("unexpected packet length, want 1, got %d", n) - } - if b[0] >= 10 { - t.Fatalf("unexpected byte, want 0-9, got %d", b[0]) - } - if b[0]%2 != 0 { - t.Fatalf("got odd byte %d, wanted only even bytes", b[0]) - } - seen[b[0]/2] = true - - seenAll := true - for _, v := range seen { - if !v { - seenAll = false - break - } - } - if seenAll { - break - } - } -} diff --git a/vendor/golang.org/x/net/ipv4/bpfopt_linux.go b/vendor/golang.org/x/net/ipv4/bpfopt_linux.go deleted file mode 100644 index 2d626d924..000000000 --- a/vendor/golang.org/x/net/ipv4/bpfopt_linux.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "os" - "unsafe" - - "golang.org/x/net/bpf" - "golang.org/x/net/internal/netreflect" -) - -// SetBPF attaches a BPF program to the connection. -// -// Only supported on Linux. -func (c *dgramOpt) SetBPF(filter []bpf.RawInstruction) error { - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - prog := sockFProg{ - Len: uint16(len(filter)), - Filter: (*sockFilter)(unsafe.Pointer(&filter[0])), - } - return os.NewSyscallError("setsockopt", setsockopt(s, sysSOL_SOCKET, sysSO_ATTACH_FILTER, unsafe.Pointer(&prog), uint32(unsafe.Sizeof(prog)))) -} diff --git a/vendor/golang.org/x/net/ipv4/bpfopt_stub.go b/vendor/golang.org/x/net/ipv4/bpfopt_stub.go deleted file mode 100644 index c4a8481f0..000000000 --- a/vendor/golang.org/x/net/ipv4/bpfopt_stub.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !linux - -package ipv4 - -import "golang.org/x/net/bpf" - -// SetBPF attaches a BPF program to the connection. -// -// Only supported on Linux. -func (c *dgramOpt) SetBPF(filter []bpf.RawInstruction) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/control.go b/vendor/golang.org/x/net/ipv4/control.go deleted file mode 100644 index da4da2dd0..000000000 --- a/vendor/golang.org/x/net/ipv4/control.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "fmt" - "net" - "sync" -) - -type rawOpt struct { - sync.RWMutex - cflags ControlFlags -} - -func (c *rawOpt) set(f ControlFlags) { c.cflags |= f } -func (c *rawOpt) clear(f ControlFlags) { c.cflags &^= f } -func (c *rawOpt) isset(f ControlFlags) bool { return c.cflags&f != 0 } - -type ControlFlags uint - -const ( - FlagTTL ControlFlags = 1 << iota // pass the TTL on the received packet - FlagSrc // pass the source address on the received packet - FlagDst // pass the destination address on the received packet - FlagInterface // pass the interface index on the received packet -) - -// A ControlMessage represents per packet basis IP-level socket options. -type ControlMessage struct { - // Receiving socket options: SetControlMessage allows to - // receive the options from the protocol stack using ReadFrom - // method of PacketConn or RawConn. - // - // Specifying socket options: ControlMessage for WriteTo - // method of PacketConn or RawConn allows to send the options - // to the protocol stack. - // - TTL int // time-to-live, receiving only - Src net.IP // source address, specifying only - Dst net.IP // destination address, receiving only - IfIndex int // interface index, must be 1 <= value when specifying -} - -func (cm *ControlMessage) String() string { - if cm == nil { - return "" - } - return fmt.Sprintf("ttl=%d src=%v dst=%v ifindex=%d", cm.TTL, cm.Src, cm.Dst, cm.IfIndex) -} - -// Ancillary data socket options -const ( - ctlTTL = iota // header field - ctlSrc // header field - ctlDst // header field - ctlInterface // inbound or outbound interface - ctlPacketInfo // inbound or outbound packet path - ctlMax -) - -// A ctlOpt represents a binding for ancillary data socket option. -type ctlOpt struct { - name int // option name, must be equal or greater than 1 - length int // option length - marshal func([]byte, *ControlMessage) []byte - parse func(*ControlMessage, []byte) -} diff --git a/vendor/golang.org/x/net/ipv4/control_bsd.go b/vendor/golang.org/x/net/ipv4/control_bsd.go deleted file mode 100644 index 3f27f9945..000000000 --- a/vendor/golang.org/x/net/ipv4/control_bsd.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package ipv4 - -import ( - "net" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func marshalDst(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIP - m.Type = sysIP_RECVDSTADDR - m.SetLen(syscall.CmsgLen(net.IPv4len)) - return b[syscall.CmsgSpace(net.IPv4len):] -} - -func parseDst(cm *ControlMessage, b []byte) { - cm.Dst = b[:net.IPv4len] -} - -func marshalInterface(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIP - m.Type = sysIP_RECVIF - m.SetLen(syscall.CmsgLen(syscall.SizeofSockaddrDatalink)) - return b[syscall.CmsgSpace(syscall.SizeofSockaddrDatalink):] -} - -func parseInterface(cm *ControlMessage, b []byte) { - sadl := (*syscall.SockaddrDatalink)(unsafe.Pointer(&b[0])) - cm.IfIndex = int(sadl.Index) -} diff --git a/vendor/golang.org/x/net/ipv4/control_pktinfo.go b/vendor/golang.org/x/net/ipv4/control_pktinfo.go deleted file mode 100644 index 9ed977341..000000000 --- a/vendor/golang.org/x/net/ipv4/control_pktinfo.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin linux solaris - -package ipv4 - -import ( - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func marshalPacketInfo(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIP - m.Type = sysIP_PKTINFO - m.SetLen(syscall.CmsgLen(sizeofInetPktinfo)) - if cm != nil { - pi := (*inetPktinfo)(unsafe.Pointer(&b[syscall.CmsgLen(0)])) - if ip := cm.Src.To4(); ip != nil { - copy(pi.Spec_dst[:], ip) - } - if cm.IfIndex > 0 { - pi.setIfindex(cm.IfIndex) - } - } - return b[syscall.CmsgSpace(sizeofInetPktinfo):] -} - -func parsePacketInfo(cm *ControlMessage, b []byte) { - pi := (*inetPktinfo)(unsafe.Pointer(&b[0])) - cm.IfIndex = int(pi.Ifindex) - cm.Dst = pi.Addr[:] -} diff --git a/vendor/golang.org/x/net/ipv4/control_stub.go b/vendor/golang.org/x/net/ipv4/control_stub.go deleted file mode 100644 index 27e618bc2..000000000 --- a/vendor/golang.org/x/net/ipv4/control_stub.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package ipv4 - -func setControlMessage(s uintptr, opt *rawOpt, cf ControlFlags, on bool) error { - return errOpNoSupport -} - -func newControlMessage(opt *rawOpt) []byte { - return nil -} - -func parseControlMessage(b []byte) (*ControlMessage, error) { - return nil, errOpNoSupport -} - -func marshalControlMessage(cm *ControlMessage) []byte { - return nil -} diff --git a/vendor/golang.org/x/net/ipv4/control_unix.go b/vendor/golang.org/x/net/ipv4/control_unix.go deleted file mode 100644 index 25ef66192..000000000 --- a/vendor/golang.org/x/net/ipv4/control_unix.go +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package ipv4 - -import ( - "os" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func setControlMessage(s uintptr, opt *rawOpt, cf ControlFlags, on bool) error { - opt.Lock() - defer opt.Unlock() - if cf&FlagTTL != 0 && sockOpts[ssoReceiveTTL].name > 0 { - if err := setInt(s, &sockOpts[ssoReceiveTTL], boolint(on)); err != nil { - return err - } - if on { - opt.set(FlagTTL) - } else { - opt.clear(FlagTTL) - } - } - if sockOpts[ssoPacketInfo].name > 0 { - if cf&(FlagSrc|FlagDst|FlagInterface) != 0 { - if err := setInt(s, &sockOpts[ssoPacketInfo], boolint(on)); err != nil { - return err - } - if on { - opt.set(cf & (FlagSrc | FlagDst | FlagInterface)) - } else { - opt.clear(cf & (FlagSrc | FlagDst | FlagInterface)) - } - } - } else { - if cf&FlagDst != 0 && sockOpts[ssoReceiveDst].name > 0 { - if err := setInt(s, &sockOpts[ssoReceiveDst], boolint(on)); err != nil { - return err - } - if on { - opt.set(FlagDst) - } else { - opt.clear(FlagDst) - } - } - if cf&FlagInterface != 0 && sockOpts[ssoReceiveInterface].name > 0 { - if err := setInt(s, &sockOpts[ssoReceiveInterface], boolint(on)); err != nil { - return err - } - if on { - opt.set(FlagInterface) - } else { - opt.clear(FlagInterface) - } - } - } - return nil -} - -func newControlMessage(opt *rawOpt) (oob []byte) { - opt.RLock() - var l int - if opt.isset(FlagTTL) && ctlOpts[ctlTTL].name > 0 { - l += syscall.CmsgSpace(ctlOpts[ctlTTL].length) - } - if ctlOpts[ctlPacketInfo].name > 0 { - if opt.isset(FlagSrc | FlagDst | FlagInterface) { - l += syscall.CmsgSpace(ctlOpts[ctlPacketInfo].length) - } - } else { - if opt.isset(FlagDst) && ctlOpts[ctlDst].name > 0 { - l += syscall.CmsgSpace(ctlOpts[ctlDst].length) - } - if opt.isset(FlagInterface) && ctlOpts[ctlInterface].name > 0 { - l += syscall.CmsgSpace(ctlOpts[ctlInterface].length) - } - } - if l > 0 { - oob = make([]byte, l) - } - opt.RUnlock() - return -} - -func parseControlMessage(b []byte) (*ControlMessage, error) { - if len(b) == 0 { - return nil, nil - } - cmsgs, err := syscall.ParseSocketControlMessage(b) - if err != nil { - return nil, os.NewSyscallError("parse socket control message", err) - } - cm := &ControlMessage{} - for _, m := range cmsgs { - if m.Header.Level != iana.ProtocolIP { - continue - } - switch int(m.Header.Type) { - case ctlOpts[ctlTTL].name: - ctlOpts[ctlTTL].parse(cm, m.Data[:]) - case ctlOpts[ctlDst].name: - ctlOpts[ctlDst].parse(cm, m.Data[:]) - case ctlOpts[ctlInterface].name: - ctlOpts[ctlInterface].parse(cm, m.Data[:]) - case ctlOpts[ctlPacketInfo].name: - ctlOpts[ctlPacketInfo].parse(cm, m.Data[:]) - } - } - return cm, nil -} - -func marshalControlMessage(cm *ControlMessage) (oob []byte) { - if cm == nil { - return nil - } - var l int - pktinfo := false - if ctlOpts[ctlPacketInfo].name > 0 && (cm.Src.To4() != nil || cm.IfIndex > 0) { - pktinfo = true - l += syscall.CmsgSpace(ctlOpts[ctlPacketInfo].length) - } - if l > 0 { - oob = make([]byte, l) - b := oob - if pktinfo { - b = ctlOpts[ctlPacketInfo].marshal(b, cm) - } - } - return -} - -func marshalTTL(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIP - m.Type = sysIP_RECVTTL - m.SetLen(syscall.CmsgLen(1)) - return b[syscall.CmsgSpace(1):] -} - -func parseTTL(cm *ControlMessage, b []byte) { - cm.TTL = int(*(*byte)(unsafe.Pointer(&b[:1][0]))) -} diff --git a/vendor/golang.org/x/net/ipv4/control_windows.go b/vendor/golang.org/x/net/ipv4/control_windows.go deleted file mode 100644 index b27407db9..000000000 --- a/vendor/golang.org/x/net/ipv4/control_windows.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import "syscall" - -func setControlMessage(s uintptr, opt *rawOpt, cf ControlFlags, on bool) error { - // TODO(mikio): implement this - return syscall.EWINDOWS -} - -func newControlMessage(opt *rawOpt) []byte { - // TODO(mikio): implement this - return nil -} - -func parseControlMessage(b []byte) (*ControlMessage, error) { - // TODO(mikio): implement this - return nil, syscall.EWINDOWS -} - -func marshalControlMessage(cm *ControlMessage) []byte { - // TODO(mikio): implement this - return nil -} diff --git a/vendor/golang.org/x/net/ipv4/defs_darwin.go b/vendor/golang.org/x/net/ipv4/defs_darwin.go deleted file mode 100644 index c8f2e05b8..000000000 --- a/vendor/golang.org/x/net/ipv4/defs_darwin.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include - -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_STRIPHDR = C.IP_STRIPHDR - sysIP_RECVTTL = C.IP_RECVTTL - sysIP_BOUND_IF = C.IP_BOUND_IF - sysIP_PKTINFO = C.IP_PKTINFO - sysIP_RECVPKTINFO = C.IP_RECVPKTINFO - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - sysIP_MULTICAST_VIF = C.IP_MULTICAST_VIF - sysIP_MULTICAST_IFINDEX = C.IP_MULTICAST_IFINDEX - sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP - sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP - sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE - sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - - sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofInetPktinfo = C.sizeof_struct_in_pktinfo - - sizeofIPMreq = C.sizeof_struct_ip_mreq - sizeofIPMreqn = C.sizeof_struct_ip_mreqn - sizeofIPMreqSource = C.sizeof_struct_ip_mreq_source - sizeofGroupReq = C.sizeof_struct_group_req - sizeofGroupSourceReq = C.sizeof_struct_group_source_req -) - -type sockaddrStorage C.struct_sockaddr_storage - -type sockaddrInet C.struct_sockaddr_in - -type inetPktinfo C.struct_in_pktinfo - -type ipMreq C.struct_ip_mreq - -type ipMreqn C.struct_ip_mreqn - -type ipMreqSource C.struct_ip_mreq_source - -type groupReq C.struct_group_req - -type groupSourceReq C.struct_group_source_req diff --git a/vendor/golang.org/x/net/ipv4/defs_dragonfly.go b/vendor/golang.org/x/net/ipv4/defs_dragonfly.go deleted file mode 100644 index f30544ea2..000000000 --- a/vendor/golang.org/x/net/ipv4/defs_dragonfly.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_RECVTTL = C.IP_RECVTTL - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_MULTICAST_VIF = C.IP_MULTICAST_VIF - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - - sizeofIPMreq = C.sizeof_struct_ip_mreq -) - -type ipMreq C.struct_ip_mreq diff --git a/vendor/golang.org/x/net/ipv4/defs_freebsd.go b/vendor/golang.org/x/net/ipv4/defs_freebsd.go deleted file mode 100644 index 4dd57d865..000000000 --- a/vendor/golang.org/x/net/ipv4/defs_freebsd.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include - -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_SENDSRCADDR = C.IP_SENDSRCADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_ONESBCAST = C.IP_ONESBCAST - sysIP_BINDANY = C.IP_BINDANY - sysIP_RECVTTL = C.IP_RECVTTL - sysIP_MINTTL = C.IP_MINTTL - sysIP_DONTFRAG = C.IP_DONTFRAG - sysIP_RECVTOS = C.IP_RECVTOS - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - sysIP_MULTICAST_VIF = C.IP_MULTICAST_VIF - sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP - sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP - sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE - sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - - sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - - sizeofIPMreq = C.sizeof_struct_ip_mreq - sizeofIPMreqn = C.sizeof_struct_ip_mreqn - sizeofIPMreqSource = C.sizeof_struct_ip_mreq_source - sizeofGroupReq = C.sizeof_struct_group_req - sizeofGroupSourceReq = C.sizeof_struct_group_source_req -) - -type sockaddrStorage C.struct_sockaddr_storage - -type sockaddrInet C.struct_sockaddr_in - -type ipMreq C.struct_ip_mreq - -type ipMreqn C.struct_ip_mreqn - -type ipMreqSource C.struct_ip_mreq_source - -type groupReq C.struct_group_req - -type groupSourceReq C.struct_group_source_req diff --git a/vendor/golang.org/x/net/ipv4/defs_linux.go b/vendor/golang.org/x/net/ipv4/defs_linux.go deleted file mode 100644 index 31dfa093c..000000000 --- a/vendor/golang.org/x/net/ipv4/defs_linux.go +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include - -#include -#include -#include -#include -#include -*/ -import "C" - -const ( - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_ROUTER_ALERT = C.IP_ROUTER_ALERT - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_PKTINFO = C.IP_PKTINFO - sysIP_PKTOPTIONS = C.IP_PKTOPTIONS - sysIP_MTU_DISCOVER = C.IP_MTU_DISCOVER - sysIP_RECVERR = C.IP_RECVERR - sysIP_RECVTTL = C.IP_RECVTTL - sysIP_RECVTOS = C.IP_RECVTOS - sysIP_MTU = C.IP_MTU - sysIP_FREEBIND = C.IP_FREEBIND - sysIP_TRANSPARENT = C.IP_TRANSPARENT - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_ORIGDSTADDR = C.IP_ORIGDSTADDR - sysIP_RECVORIGDSTADDR = C.IP_RECVORIGDSTADDR - sysIP_MINTTL = C.IP_MINTTL - sysIP_NODEFRAG = C.IP_NODEFRAG - sysIP_UNICAST_IF = C.IP_UNICAST_IF - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE - sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE - sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP - sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP - sysIP_MSFILTER = C.IP_MSFILTER - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - sysMCAST_MSFILTER = C.MCAST_MSFILTER - sysIP_MULTICAST_ALL = C.IP_MULTICAST_ALL - - //sysIP_PMTUDISC_DONT = C.IP_PMTUDISC_DONT - //sysIP_PMTUDISC_WANT = C.IP_PMTUDISC_WANT - //sysIP_PMTUDISC_DO = C.IP_PMTUDISC_DO - //sysIP_PMTUDISC_PROBE = C.IP_PMTUDISC_PROBE - //sysIP_PMTUDISC_INTERFACE = C.IP_PMTUDISC_INTERFACE - //sysIP_PMTUDISC_OMIT = C.IP_PMTUDISC_OMIT - - sysICMP_FILTER = C.ICMP_FILTER - - sysSO_EE_ORIGIN_NONE = C.SO_EE_ORIGIN_NONE - sysSO_EE_ORIGIN_LOCAL = C.SO_EE_ORIGIN_LOCAL - sysSO_EE_ORIGIN_ICMP = C.SO_EE_ORIGIN_ICMP - sysSO_EE_ORIGIN_ICMP6 = C.SO_EE_ORIGIN_ICMP6 - sysSO_EE_ORIGIN_TXSTATUS = C.SO_EE_ORIGIN_TXSTATUS - sysSO_EE_ORIGIN_TIMESTAMPING = C.SO_EE_ORIGIN_TIMESTAMPING - - sysSOL_SOCKET = C.SOL_SOCKET - sysSO_ATTACH_FILTER = C.SO_ATTACH_FILTER - - sizeofKernelSockaddrStorage = C.sizeof_struct___kernel_sockaddr_storage - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofInetPktinfo = C.sizeof_struct_in_pktinfo - sizeofSockExtendedErr = C.sizeof_struct_sock_extended_err - - sizeofIPMreq = C.sizeof_struct_ip_mreq - sizeofIPMreqn = C.sizeof_struct_ip_mreqn - sizeofIPMreqSource = C.sizeof_struct_ip_mreq_source - sizeofGroupReq = C.sizeof_struct_group_req - sizeofGroupSourceReq = C.sizeof_struct_group_source_req - - sizeofICMPFilter = C.sizeof_struct_icmp_filter -) - -type kernelSockaddrStorage C.struct___kernel_sockaddr_storage - -type sockaddrInet C.struct_sockaddr_in - -type inetPktinfo C.struct_in_pktinfo - -type sockExtendedErr C.struct_sock_extended_err - -type ipMreq C.struct_ip_mreq - -type ipMreqn C.struct_ip_mreqn - -type ipMreqSource C.struct_ip_mreq_source - -type groupReq C.struct_group_req - -type groupSourceReq C.struct_group_source_req - -type icmpFilter C.struct_icmp_filter - -type sockFProg C.struct_sock_fprog - -type sockFilter C.struct_sock_filter diff --git a/vendor/golang.org/x/net/ipv4/defs_netbsd.go b/vendor/golang.org/x/net/ipv4/defs_netbsd.go deleted file mode 100644 index 8f8af1b89..000000000 --- a/vendor/golang.org/x/net/ipv4/defs_netbsd.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_RECVTTL = C.IP_RECVTTL - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - - sizeofIPMreq = C.sizeof_struct_ip_mreq -) - -type ipMreq C.struct_ip_mreq diff --git a/vendor/golang.org/x/net/ipv4/defs_openbsd.go b/vendor/golang.org/x/net/ipv4/defs_openbsd.go deleted file mode 100644 index 8f8af1b89..000000000 --- a/vendor/golang.org/x/net/ipv4/defs_openbsd.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_RECVTTL = C.IP_RECVTTL - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - - sizeofIPMreq = C.sizeof_struct_ip_mreq -) - -type ipMreq C.struct_ip_mreq diff --git a/vendor/golang.org/x/net/ipv4/defs_solaris.go b/vendor/golang.org/x/net/ipv4/defs_solaris.go deleted file mode 100644 index aeb33e9c8..000000000 --- a/vendor/golang.org/x/net/ipv4/defs_solaris.go +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include - -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_RECVSLLA = C.IP_RECVSLLA - sysIP_RECVTTL = C.IP_RECVTTL - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE - sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE - sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP - sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP - sysIP_NEXTHOP = C.IP_NEXTHOP - - sysIP_PKTINFO = C.IP_PKTINFO - sysIP_RECVPKTINFO = C.IP_RECVPKTINFO - sysIP_DONTFRAG = C.IP_DONTFRAG - - sysIP_BOUND_IF = C.IP_BOUND_IF - sysIP_UNSPEC_SRC = C.IP_UNSPEC_SRC - sysIP_BROADCAST_TTL = C.IP_BROADCAST_TTL - sysIP_DHCPINIT_IF = C.IP_DHCPINIT_IF - - sysIP_REUSEADDR = C.IP_REUSEADDR - sysIP_DONTROUTE = C.IP_DONTROUTE - sysIP_BROADCAST = C.IP_BROADCAST - - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - - sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofInetPktinfo = C.sizeof_struct_in_pktinfo - - sizeofIPMreq = C.sizeof_struct_ip_mreq - sizeofIPMreqSource = C.sizeof_struct_ip_mreq_source - sizeofGroupReq = C.sizeof_struct_group_req - sizeofGroupSourceReq = C.sizeof_struct_group_source_req -) - -type sockaddrStorage C.struct_sockaddr_storage - -type sockaddrInet C.struct_sockaddr_in - -type inetPktinfo C.struct_in_pktinfo - -type ipMreq C.struct_ip_mreq - -type ipMreqSource C.struct_ip_mreq_source - -type groupReq C.struct_group_req - -type groupSourceReq C.struct_group_source_req diff --git a/vendor/golang.org/x/net/ipv4/dgramopt_posix.go b/vendor/golang.org/x/net/ipv4/dgramopt_posix.go deleted file mode 100644 index fbc5df198..000000000 --- a/vendor/golang.org/x/net/ipv4/dgramopt_posix.go +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package ipv4 - -import ( - "net" - "syscall" - - "golang.org/x/net/internal/netreflect" -) - -// MulticastTTL returns the time-to-live field value for outgoing -// multicast packets. -func (c *dgramOpt) MulticastTTL() (int, error) { - if !c.ok() { - return 0, syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return 0, err - } - return getInt(s, &sockOpts[ssoMulticastTTL]) -} - -// SetMulticastTTL sets the time-to-live field value for future -// outgoing multicast packets. -func (c *dgramOpt) SetMulticastTTL(ttl int) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - return setInt(s, &sockOpts[ssoMulticastTTL], ttl) -} - -// MulticastInterface returns the default interface for multicast -// packet transmissions. -func (c *dgramOpt) MulticastInterface() (*net.Interface, error) { - if !c.ok() { - return nil, syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return nil, err - } - return getInterface(s, &sockOpts[ssoMulticastInterface]) -} - -// SetMulticastInterface sets the default interface for future -// multicast packet transmissions. -func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - return setInterface(s, &sockOpts[ssoMulticastInterface], ifi) -} - -// MulticastLoopback reports whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) MulticastLoopback() (bool, error) { - if !c.ok() { - return false, syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return false, err - } - on, err := getInt(s, &sockOpts[ssoMulticastLoopback]) - if err != nil { - return false, err - } - return on == 1, nil -} - -// SetMulticastLoopback sets whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) SetMulticastLoopback(on bool) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - return setInt(s, &sockOpts[ssoMulticastLoopback], boolint(on)) -} - -// JoinGroup joins the group address group on the interface ifi. -// By default all sources that can cast data to group are accepted. -// It's possible to mute and unmute data transmission from a specific -// source by using ExcludeSourceSpecificGroup and -// IncludeSourceSpecificGroup. -// JoinGroup uses the system assigned multicast interface when ifi is -// nil, although this is not recommended because the assignment -// depends on platforms and sometimes it might require routing -// configuration. -func (c *dgramOpt) JoinGroup(ifi *net.Interface, group net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - return setGroup(s, &sockOpts[ssoJoinGroup], ifi, grp) -} - -// LeaveGroup leaves the group address group on the interface ifi -// regardless of whether the group is any-source group or -// source-specific group. -func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - return setGroup(s, &sockOpts[ssoLeaveGroup], ifi, grp) -} - -// JoinSourceSpecificGroup joins the source-specific group comprising -// group and source on the interface ifi. -// JoinSourceSpecificGroup uses the system assigned multicast -// interface when ifi is nil, although this is not recommended because -// the assignment depends on platforms and sometimes it might require -// routing configuration. -func (c *dgramOpt) JoinSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP4(source) - if src == nil { - return errMissingAddress - } - return setSourceGroup(s, &sockOpts[ssoJoinSourceGroup], ifi, grp, src) -} - -// LeaveSourceSpecificGroup leaves the source-specific group on the -// interface ifi. -func (c *dgramOpt) LeaveSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP4(source) - if src == nil { - return errMissingAddress - } - return setSourceGroup(s, &sockOpts[ssoLeaveSourceGroup], ifi, grp, src) -} - -// ExcludeSourceSpecificGroup excludes the source-specific group from -// the already joined any-source groups by JoinGroup on the interface -// ifi. -func (c *dgramOpt) ExcludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP4(source) - if src == nil { - return errMissingAddress - } - return setSourceGroup(s, &sockOpts[ssoBlockSourceGroup], ifi, grp, src) -} - -// IncludeSourceSpecificGroup includes the excluded source-specific -// group by ExcludeSourceSpecificGroup again on the interface ifi. -func (c *dgramOpt) IncludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP4(source) - if src == nil { - return errMissingAddress - } - return setSourceGroup(s, &sockOpts[ssoUnblockSourceGroup], ifi, grp, src) -} - -// ICMPFilter returns an ICMP filter. -// Currently only Linux supports this. -func (c *dgramOpt) ICMPFilter() (*ICMPFilter, error) { - if !c.ok() { - return nil, syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return nil, err - } - return getICMPFilter(s, &sockOpts[ssoICMPFilter]) -} - -// SetICMPFilter deploys the ICMP filter. -// Currently only Linux supports this. -func (c *dgramOpt) SetICMPFilter(f *ICMPFilter) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - return setICMPFilter(s, &sockOpts[ssoICMPFilter], f) -} diff --git a/vendor/golang.org/x/net/ipv4/dgramopt_stub.go b/vendor/golang.org/x/net/ipv4/dgramopt_stub.go deleted file mode 100644 index f6b867f92..000000000 --- a/vendor/golang.org/x/net/ipv4/dgramopt_stub.go +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package ipv4 - -import "net" - -// MulticastTTL returns the time-to-live field value for outgoing -// multicast packets. -func (c *dgramOpt) MulticastTTL() (int, error) { - return 0, errOpNoSupport -} - -// SetMulticastTTL sets the time-to-live field value for future -// outgoing multicast packets. -func (c *dgramOpt) SetMulticastTTL(ttl int) error { - return errOpNoSupport -} - -// MulticastInterface returns the default interface for multicast -// packet transmissions. -func (c *dgramOpt) MulticastInterface() (*net.Interface, error) { - return nil, errOpNoSupport -} - -// SetMulticastInterface sets the default interface for future -// multicast packet transmissions. -func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error { - return errOpNoSupport -} - -// MulticastLoopback reports whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) MulticastLoopback() (bool, error) { - return false, errOpNoSupport -} - -// SetMulticastLoopback sets whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) SetMulticastLoopback(on bool) error { - return errOpNoSupport -} - -// JoinGroup joins the group address group on the interface ifi. -// By default all sources that can cast data to group are accepted. -// It's possible to mute and unmute data transmission from a specific -// source by using ExcludeSourceSpecificGroup and -// IncludeSourceSpecificGroup. -// JoinGroup uses the system assigned multicast interface when ifi is -// nil, although this is not recommended because the assignment -// depends on platforms and sometimes it might require routing -// configuration. -func (c *dgramOpt) JoinGroup(ifi *net.Interface, group net.Addr) error { - return errOpNoSupport -} - -// LeaveGroup leaves the group address group on the interface ifi -// regardless of whether the group is any-source group or -// source-specific group. -func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error { - return errOpNoSupport -} - -// JoinSourceSpecificGroup joins the source-specific group comprising -// group and source on the interface ifi. -// JoinSourceSpecificGroup uses the system assigned multicast -// interface when ifi is nil, although this is not recommended because -// the assignment depends on platforms and sometimes it might require -// routing configuration. -func (c *dgramOpt) JoinSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - return errOpNoSupport -} - -// LeaveSourceSpecificGroup leaves the source-specific group on the -// interface ifi. -func (c *dgramOpt) LeaveSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - return errOpNoSupport -} - -// ExcludeSourceSpecificGroup excludes the source-specific group from -// the already joined any-source groups by JoinGroup on the interface -// ifi. -func (c *dgramOpt) ExcludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - return errOpNoSupport -} - -// IncludeSourceSpecificGroup includes the excluded source-specific -// group by ExcludeSourceSpecificGroup again on the interface ifi. -func (c *dgramOpt) IncludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - return errOpNoSupport -} - -// ICMPFilter returns an ICMP filter. -// Currently only Linux supports this. -func (c *dgramOpt) ICMPFilter() (*ICMPFilter, error) { - return nil, errOpNoSupport -} - -// SetICMPFilter deploys the ICMP filter. -// Currently only Linux supports this. -func (c *dgramOpt) SetICMPFilter(f *ICMPFilter) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/doc.go b/vendor/golang.org/x/net/ipv4/doc.go deleted file mode 100644 index b43935a5a..000000000 --- a/vendor/golang.org/x/net/ipv4/doc.go +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package ipv4 implements IP-level socket options for the Internet -// Protocol version 4. -// -// The package provides IP-level socket options that allow -// manipulation of IPv4 facilities. -// -// The IPv4 protocol and basic host requirements for IPv4 are defined -// in RFC 791 and RFC 1122. -// Host extensions for multicasting and socket interface extensions -// for multicast source filters are defined in RFC 1112 and RFC 3678. -// IGMPv1, IGMPv2 and IGMPv3 are defined in RFC 1112, RFC 2236 and RFC -// 3376. -// Source-specific multicast is defined in RFC 4607. -// -// -// Unicasting -// -// The options for unicasting are available for net.TCPConn, -// net.UDPConn and net.IPConn which are created as network connections -// that use the IPv4 transport. When a single TCP connection carrying -// a data flow of multiple packets needs to indicate the flow is -// important, Conn is used to set the type-of-service field on the -// IPv4 header for each packet. -// -// ln, err := net.Listen("tcp4", "0.0.0.0:1024") -// if err != nil { -// // error handling -// } -// defer ln.Close() -// for { -// c, err := ln.Accept() -// if err != nil { -// // error handling -// } -// go func(c net.Conn) { -// defer c.Close() -// -// The outgoing packets will be labeled DiffServ assured forwarding -// class 1 low drop precedence, known as AF11 packets. -// -// if err := ipv4.NewConn(c).SetTOS(0x28); err != nil { -// // error handling -// } -// if _, err := c.Write(data); err != nil { -// // error handling -// } -// }(c) -// } -// -// -// Multicasting -// -// The options for multicasting are available for net.UDPConn and -// net.IPconn which are created as network connections that use the -// IPv4 transport. A few network facilities must be prepared before -// you begin multicasting, at a minimum joining network interfaces and -// multicast groups. -// -// en0, err := net.InterfaceByName("en0") -// if err != nil { -// // error handling -// } -// en1, err := net.InterfaceByIndex(911) -// if err != nil { -// // error handling -// } -// group := net.IPv4(224, 0, 0, 250) -// -// First, an application listens to an appropriate address with an -// appropriate service port. -// -// c, err := net.ListenPacket("udp4", "0.0.0.0:1024") -// if err != nil { -// // error handling -// } -// defer c.Close() -// -// Second, the application joins multicast groups, starts listening to -// the groups on the specified network interfaces. Note that the -// service port for transport layer protocol does not matter with this -// operation as joining groups affects only network and link layer -// protocols, such as IPv4 and Ethernet. -// -// p := ipv4.NewPacketConn(c) -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: group}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en1, &net.UDPAddr{IP: group}); err != nil { -// // error handling -// } -// -// The application might set per packet control message transmissions -// between the protocol stack within the kernel. When the application -// needs a destination address on an incoming packet, -// SetControlMessage of PacketConn is used to enable control message -// transmissions. -// -// if err := p.SetControlMessage(ipv4.FlagDst, true); err != nil { -// // error handling -// } -// -// The application could identify whether the received packets are -// of interest by using the control message that contains the -// destination address of the received packet. -// -// b := make([]byte, 1500) -// for { -// n, cm, src, err := p.ReadFrom(b) -// if err != nil { -// // error handling -// } -// if cm.Dst.IsMulticast() { -// if cm.Dst.Equal(group) { -// // joined group, do something -// } else { -// // unknown group, discard -// continue -// } -// } -// -// The application can also send both unicast and multicast packets. -// -// p.SetTOS(0x0) -// p.SetTTL(16) -// if _, err := p.WriteTo(data, nil, src); err != nil { -// // error handling -// } -// dst := &net.UDPAddr{IP: group, Port: 1024} -// for _, ifi := range []*net.Interface{en0, en1} { -// if err := p.SetMulticastInterface(ifi); err != nil { -// // error handling -// } -// p.SetMulticastTTL(2) -// if _, err := p.WriteTo(data, nil, dst); err != nil { -// // error handling -// } -// } -// } -// -// -// More multicasting -// -// An application that uses PacketConn or RawConn may join multiple -// multicast groups. For example, a UDP listener with port 1024 might -// join two different groups across over two different network -// interfaces by using: -// -// c, err := net.ListenPacket("udp4", "0.0.0.0:1024") -// if err != nil { -// // error handling -// } -// defer c.Close() -// p := ipv4.NewPacketConn(c) -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 248)}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 249)}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en1, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 249)}); err != nil { -// // error handling -// } -// -// It is possible for multiple UDP listeners that listen on the same -// UDP port to join the same multicast group. The net package will -// provide a socket that listens to a wildcard address with reusable -// UDP port when an appropriate multicast address prefix is passed to -// the net.ListenPacket or net.ListenUDP. -// -// c1, err := net.ListenPacket("udp4", "224.0.0.0:1024") -// if err != nil { -// // error handling -// } -// defer c1.Close() -// c2, err := net.ListenPacket("udp4", "224.0.0.0:1024") -// if err != nil { -// // error handling -// } -// defer c2.Close() -// p1 := ipv4.NewPacketConn(c1) -// if err := p1.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 248)}); err != nil { -// // error handling -// } -// p2 := ipv4.NewPacketConn(c2) -// if err := p2.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 248)}); err != nil { -// // error handling -// } -// -// Also it is possible for the application to leave or rejoin a -// multicast group on the network interface. -// -// if err := p.LeaveGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 248)}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 250)}); err != nil { -// // error handling -// } -// -// -// Source-specific multicasting -// -// An application that uses PacketConn or RawConn on IGMPv3 supported -// platform is able to join source-specific multicast groups. -// The application may use JoinSourceSpecificGroup and -// LeaveSourceSpecificGroup for the operation known as "include" mode, -// -// ssmgroup := net.UDPAddr{IP: net.IPv4(232, 7, 8, 9)} -// ssmsource := net.UDPAddr{IP: net.IPv4(192, 168, 0, 1)}) -// if err := p.JoinSourceSpecificGroup(en0, &ssmgroup, &ssmsource); err != nil { -// // error handling -// } -// if err := p.LeaveSourceSpecificGroup(en0, &ssmgroup, &ssmsource); err != nil { -// // error handling -// } -// -// or JoinGroup, ExcludeSourceSpecificGroup, -// IncludeSourceSpecificGroup and LeaveGroup for the operation known -// as "exclude" mode. -// -// exclsource := net.UDPAddr{IP: net.IPv4(192, 168, 0, 254)} -// if err := p.JoinGroup(en0, &ssmgroup); err != nil { -// // error handling -// } -// if err := p.ExcludeSourceSpecificGroup(en0, &ssmgroup, &exclsource); err != nil { -// // error handling -// } -// if err := p.LeaveGroup(en0, &ssmgroup); err != nil { -// // error handling -// } -// -// Note that it depends on each platform implementation what happens -// when an application which runs on IGMPv3 unsupported platform uses -// JoinSourceSpecificGroup and LeaveSourceSpecificGroup. -// In general the platform tries to fall back to conversations using -// IGMPv1 or IGMPv2 and starts to listen to multicast traffic. -// In the fallback case, ExcludeSourceSpecificGroup and -// IncludeSourceSpecificGroup may return an error. -package ipv4 // import "golang.org/x/net/ipv4" - -// BUG(mikio): This package is not implemented on NaCl and Plan 9. diff --git a/vendor/golang.org/x/net/ipv4/endpoint.go b/vendor/golang.org/x/net/ipv4/endpoint.go deleted file mode 100644 index 8f7e07ac4..000000000 --- a/vendor/golang.org/x/net/ipv4/endpoint.go +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "syscall" - "time" - - "golang.org/x/net/internal/netreflect" -) - -// BUG(mikio): On Windows, the JoinSourceSpecificGroup, -// LeaveSourceSpecificGroup, ExcludeSourceSpecificGroup and -// IncludeSourceSpecificGroup methods of PacketConn and RawConn are -// not implemented. - -// A Conn represents a network endpoint that uses the IPv4 transport. -// It is used to control basic IP-level socket options such as TOS and -// TTL. -type Conn struct { - genericOpt -} - -type genericOpt struct { - net.Conn -} - -func (c *genericOpt) ok() bool { return c != nil && c.Conn != nil } - -// NewConn returns a new Conn. -func NewConn(c net.Conn) *Conn { - return &Conn{ - genericOpt: genericOpt{Conn: c}, - } -} - -// A PacketConn represents a packet network endpoint that uses the -// IPv4 transport. It is used to control several IP-level socket -// options including multicasting. It also provides datagram based -// network I/O methods specific to the IPv4 and higher layer protocols -// such as UDP. -type PacketConn struct { - genericOpt - dgramOpt - payloadHandler -} - -type dgramOpt struct { - net.PacketConn -} - -func (c *dgramOpt) ok() bool { return c != nil && c.PacketConn != nil } - -// SetControlMessage sets the per packet IP-level socket options. -func (c *PacketConn) SetControlMessage(cf ControlFlags, on bool) error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.dgramOpt.PacketConn) - if err != nil { - return err - } - return setControlMessage(s, &c.payloadHandler.rawOpt, cf, on) -} - -// SetDeadline sets the read and write deadlines associated with the -// endpoint. -func (c *PacketConn) SetDeadline(t time.Time) error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - return c.payloadHandler.PacketConn.SetDeadline(t) -} - -// SetReadDeadline sets the read deadline associated with the -// endpoint. -func (c *PacketConn) SetReadDeadline(t time.Time) error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - return c.payloadHandler.PacketConn.SetReadDeadline(t) -} - -// SetWriteDeadline sets the write deadline associated with the -// endpoint. -func (c *PacketConn) SetWriteDeadline(t time.Time) error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - return c.payloadHandler.PacketConn.SetWriteDeadline(t) -} - -// Close closes the endpoint. -func (c *PacketConn) Close() error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - return c.payloadHandler.PacketConn.Close() -} - -// NewPacketConn returns a new PacketConn using c as its underlying -// transport. -func NewPacketConn(c net.PacketConn) *PacketConn { - p := &PacketConn{ - genericOpt: genericOpt{Conn: c.(net.Conn)}, - dgramOpt: dgramOpt{PacketConn: c}, - payloadHandler: payloadHandler{PacketConn: c}, - } - if _, ok := c.(*net.IPConn); ok && sockOpts[ssoStripHeader].name > 0 { - if s, err := netreflect.PacketSocketOf(c); err == nil { - setInt(s, &sockOpts[ssoStripHeader], boolint(true)) - } - } - return p -} - -// A RawConn represents a packet network endpoint that uses the IPv4 -// transport. It is used to control several IP-level socket options -// including IPv4 header manipulation. It also provides datagram -// based network I/O methods specific to the IPv4 and higher layer -// protocols that handle IPv4 datagram directly such as OSPF, GRE. -type RawConn struct { - genericOpt - dgramOpt - packetHandler -} - -// SetControlMessage sets the per packet IP-level socket options. -func (c *RawConn) SetControlMessage(cf ControlFlags, on bool) error { - if !c.packetHandler.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.dgramOpt.PacketConn) - if err != nil { - return err - } - return setControlMessage(s, &c.packetHandler.rawOpt, cf, on) -} - -// SetDeadline sets the read and write deadlines associated with the -// endpoint. -func (c *RawConn) SetDeadline(t time.Time) error { - if !c.packetHandler.ok() { - return syscall.EINVAL - } - return c.packetHandler.c.SetDeadline(t) -} - -// SetReadDeadline sets the read deadline associated with the -// endpoint. -func (c *RawConn) SetReadDeadline(t time.Time) error { - if !c.packetHandler.ok() { - return syscall.EINVAL - } - return c.packetHandler.c.SetReadDeadline(t) -} - -// SetWriteDeadline sets the write deadline associated with the -// endpoint. -func (c *RawConn) SetWriteDeadline(t time.Time) error { - if !c.packetHandler.ok() { - return syscall.EINVAL - } - return c.packetHandler.c.SetWriteDeadline(t) -} - -// Close closes the endpoint. -func (c *RawConn) Close() error { - if !c.packetHandler.ok() { - return syscall.EINVAL - } - return c.packetHandler.c.Close() -} - -// NewRawConn returns a new RawConn using c as its underlying -// transport. -func NewRawConn(c net.PacketConn) (*RawConn, error) { - r := &RawConn{ - genericOpt: genericOpt{Conn: c.(net.Conn)}, - dgramOpt: dgramOpt{PacketConn: c}, - packetHandler: packetHandler{c: c.(*net.IPConn)}, - } - s, err := netreflect.PacketSocketOf(c) - if err != nil { - return nil, err - } - if err := setInt(s, &sockOpts[ssoHeaderPrepend], boolint(true)); err != nil { - return nil, err - } - return r, nil -} diff --git a/vendor/golang.org/x/net/ipv4/example_test.go b/vendor/golang.org/x/net/ipv4/example_test.go deleted file mode 100644 index ddc7577e8..000000000 --- a/vendor/golang.org/x/net/ipv4/example_test.go +++ /dev/null @@ -1,224 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "fmt" - "log" - "net" - "os" - "runtime" - "time" - - "golang.org/x/net/icmp" - "golang.org/x/net/ipv4" -) - -func ExampleConn_markingTCP() { - ln, err := net.Listen("tcp", "0.0.0.0:1024") - if err != nil { - log.Fatal(err) - } - defer ln.Close() - - for { - c, err := ln.Accept() - if err != nil { - log.Fatal(err) - } - go func(c net.Conn) { - defer c.Close() - if c.RemoteAddr().(*net.TCPAddr).IP.To4() != nil { - p := ipv4.NewConn(c) - if err := p.SetTOS(0x28); err != nil { // DSCP AF11 - log.Fatal(err) - } - if err := p.SetTTL(128); err != nil { - log.Fatal(err) - } - } - if _, err := c.Write([]byte("HELLO-R-U-THERE-ACK")); err != nil { - log.Fatal(err) - } - }(c) - } -} - -func ExamplePacketConn_servingOneShotMulticastDNS() { - c, err := net.ListenPacket("udp4", "0.0.0.0:5353") // mDNS over UDP - if err != nil { - log.Fatal(err) - } - defer c.Close() - p := ipv4.NewPacketConn(c) - - en0, err := net.InterfaceByName("en0") - if err != nil { - log.Fatal(err) - } - mDNSLinkLocal := net.UDPAddr{IP: net.IPv4(224, 0, 0, 251)} - if err := p.JoinGroup(en0, &mDNSLinkLocal); err != nil { - log.Fatal(err) - } - defer p.LeaveGroup(en0, &mDNSLinkLocal) - if err := p.SetControlMessage(ipv4.FlagDst, true); err != nil { - log.Fatal(err) - } - - b := make([]byte, 1500) - for { - _, cm, peer, err := p.ReadFrom(b) - if err != nil { - log.Fatal(err) - } - if !cm.Dst.IsMulticast() || !cm.Dst.Equal(mDNSLinkLocal.IP) { - continue - } - answers := []byte("FAKE-MDNS-ANSWERS") // fake mDNS answers, you need to implement this - if _, err := p.WriteTo(answers, nil, peer); err != nil { - log.Fatal(err) - } - } -} - -func ExamplePacketConn_tracingIPPacketRoute() { - // Tracing an IP packet route to www.google.com. - - const host = "www.google.com" - ips, err := net.LookupIP(host) - if err != nil { - log.Fatal(err) - } - var dst net.IPAddr - for _, ip := range ips { - if ip.To4() != nil { - dst.IP = ip - fmt.Printf("using %v for tracing an IP packet route to %s\n", dst.IP, host) - break - } - } - if dst.IP == nil { - log.Fatal("no A record found") - } - - c, err := net.ListenPacket("ip4:1", "0.0.0.0") // ICMP for IPv4 - if err != nil { - log.Fatal(err) - } - defer c.Close() - p := ipv4.NewPacketConn(c) - - if err := p.SetControlMessage(ipv4.FlagTTL|ipv4.FlagSrc|ipv4.FlagDst|ipv4.FlagInterface, true); err != nil { - log.Fatal(err) - } - wm := icmp.Message{ - Type: ipv4.ICMPTypeEcho, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, - Data: []byte("HELLO-R-U-THERE"), - }, - } - - rb := make([]byte, 1500) - for i := 1; i <= 64; i++ { // up to 64 hops - wm.Body.(*icmp.Echo).Seq = i - wb, err := wm.Marshal(nil) - if err != nil { - log.Fatal(err) - } - if err := p.SetTTL(i); err != nil { - log.Fatal(err) - } - - // In the real world usually there are several - // multiple traffic-engineered paths for each hop. - // You may need to probe a few times to each hop. - begin := time.Now() - if _, err := p.WriteTo(wb, nil, &dst); err != nil { - log.Fatal(err) - } - if err := p.SetReadDeadline(time.Now().Add(3 * time.Second)); err != nil { - log.Fatal(err) - } - n, cm, peer, err := p.ReadFrom(rb) - if err != nil { - if err, ok := err.(net.Error); ok && err.Timeout() { - fmt.Printf("%v\t*\n", i) - continue - } - log.Fatal(err) - } - rm, err := icmp.ParseMessage(1, rb[:n]) - if err != nil { - log.Fatal(err) - } - rtt := time.Since(begin) - - // In the real world you need to determine whether the - // received message is yours using ControlMessage.Src, - // ControlMessage.Dst, icmp.Echo.ID and icmp.Echo.Seq. - switch rm.Type { - case ipv4.ICMPTypeTimeExceeded: - names, _ := net.LookupAddr(peer.String()) - fmt.Printf("%d\t%v %+v %v\n\t%+v\n", i, peer, names, rtt, cm) - case ipv4.ICMPTypeEchoReply: - names, _ := net.LookupAddr(peer.String()) - fmt.Printf("%d\t%v %+v %v\n\t%+v\n", i, peer, names, rtt, cm) - return - default: - log.Printf("unknown ICMP message: %+v\n", rm) - } - } -} - -func ExampleRawConn_advertisingOSPFHello() { - c, err := net.ListenPacket("ip4:89", "0.0.0.0") // OSPF for IPv4 - if err != nil { - log.Fatal(err) - } - defer c.Close() - r, err := ipv4.NewRawConn(c) - if err != nil { - log.Fatal(err) - } - - en0, err := net.InterfaceByName("en0") - if err != nil { - log.Fatal(err) - } - allSPFRouters := net.IPAddr{IP: net.IPv4(224, 0, 0, 5)} - if err := r.JoinGroup(en0, &allSPFRouters); err != nil { - log.Fatal(err) - } - defer r.LeaveGroup(en0, &allSPFRouters) - - hello := make([]byte, 24) // fake hello data, you need to implement this - ospf := make([]byte, 24) // fake ospf header, you need to implement this - ospf[0] = 2 // version 2 - ospf[1] = 1 // hello packet - ospf = append(ospf, hello...) - iph := &ipv4.Header{ - Version: ipv4.Version, - Len: ipv4.HeaderLen, - TOS: 0xc0, // DSCP CS6 - TotalLen: ipv4.HeaderLen + len(ospf), - TTL: 1, - Protocol: 89, - Dst: allSPFRouters.IP.To4(), - } - - var cm *ipv4.ControlMessage - switch runtime.GOOS { - case "darwin", "linux": - cm = &ipv4.ControlMessage{IfIndex: en0.Index} - default: - if err := r.SetMulticastInterface(en0); err != nil { - log.Fatal(err) - } - } - if err := r.WriteTo(iph, ospf, cm); err != nil { - log.Fatal(err) - } -} diff --git a/vendor/golang.org/x/net/ipv4/gen.go b/vendor/golang.org/x/net/ipv4/gen.go deleted file mode 100644 index ffb44fe68..000000000 --- a/vendor/golang.org/x/net/ipv4/gen.go +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -//go:generate go run gen.go - -// This program generates system adaptation constants and types, -// internet protocol constants and tables by reading template files -// and IANA protocol registries. -package main - -import ( - "bytes" - "encoding/xml" - "fmt" - "go/format" - "io" - "io/ioutil" - "net/http" - "os" - "os/exec" - "runtime" - "strconv" - "strings" -) - -func main() { - if err := genzsys(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - if err := geniana(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} - -func genzsys() error { - defs := "defs_" + runtime.GOOS + ".go" - f, err := os.Open(defs) - if err != nil { - if os.IsNotExist(err) { - return nil - } - return err - } - f.Close() - cmd := exec.Command("go", "tool", "cgo", "-godefs", defs) - b, err := cmd.Output() - if err != nil { - return err - } - b, err = format.Source(b) - if err != nil { - return err - } - zsys := "zsys_" + runtime.GOOS + ".go" - switch runtime.GOOS { - case "freebsd", "linux": - zsys = "zsys_" + runtime.GOOS + "_" + runtime.GOARCH + ".go" - } - if err := ioutil.WriteFile(zsys, b, 0644); err != nil { - return err - } - return nil -} - -var registries = []struct { - url string - parse func(io.Writer, io.Reader) error -}{ - { - "http://www.iana.org/assignments/icmp-parameters/icmp-parameters.xml", - parseICMPv4Parameters, - }, -} - -func geniana() error { - var bb bytes.Buffer - fmt.Fprintf(&bb, "// go generate gen.go\n") - fmt.Fprintf(&bb, "// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT\n\n") - fmt.Fprintf(&bb, "package ipv4\n\n") - for _, r := range registries { - resp, err := http.Get(r.url) - if err != nil { - return err - } - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("got HTTP status code %v for %v\n", resp.StatusCode, r.url) - } - if err := r.parse(&bb, resp.Body); err != nil { - return err - } - fmt.Fprintf(&bb, "\n") - } - b, err := format.Source(bb.Bytes()) - if err != nil { - return err - } - if err := ioutil.WriteFile("iana.go", b, 0644); err != nil { - return err - } - return nil -} - -func parseICMPv4Parameters(w io.Writer, r io.Reader) error { - dec := xml.NewDecoder(r) - var icp icmpv4Parameters - if err := dec.Decode(&icp); err != nil { - return err - } - prs := icp.escape() - fmt.Fprintf(w, "// %s, Updated: %s\n", icp.Title, icp.Updated) - fmt.Fprintf(w, "const (\n") - for _, pr := range prs { - if pr.Descr == "" { - continue - } - fmt.Fprintf(w, "ICMPType%s ICMPType = %d", pr.Descr, pr.Value) - fmt.Fprintf(w, "// %s\n", pr.OrigDescr) - } - fmt.Fprintf(w, ")\n\n") - fmt.Fprintf(w, "// %s, Updated: %s\n", icp.Title, icp.Updated) - fmt.Fprintf(w, "var icmpTypes = map[ICMPType]string{\n") - for _, pr := range prs { - if pr.Descr == "" { - continue - } - fmt.Fprintf(w, "%d: %q,\n", pr.Value, strings.ToLower(pr.OrigDescr)) - } - fmt.Fprintf(w, "}\n") - return nil -} - -type icmpv4Parameters struct { - XMLName xml.Name `xml:"registry"` - Title string `xml:"title"` - Updated string `xml:"updated"` - Registries []struct { - Title string `xml:"title"` - Records []struct { - Value string `xml:"value"` - Descr string `xml:"description"` - } `xml:"record"` - } `xml:"registry"` -} - -type canonICMPv4ParamRecord struct { - OrigDescr string - Descr string - Value int -} - -func (icp *icmpv4Parameters) escape() []canonICMPv4ParamRecord { - id := -1 - for i, r := range icp.Registries { - if strings.Contains(r.Title, "Type") || strings.Contains(r.Title, "type") { - id = i - break - } - } - if id < 0 { - return nil - } - prs := make([]canonICMPv4ParamRecord, len(icp.Registries[id].Records)) - sr := strings.NewReplacer( - "Messages", "", - "Message", "", - "ICMP", "", - "+", "P", - "-", "", - "/", "", - ".", "", - " ", "", - ) - for i, pr := range icp.Registries[id].Records { - if strings.Contains(pr.Descr, "Reserved") || - strings.Contains(pr.Descr, "Unassigned") || - strings.Contains(pr.Descr, "Deprecated") || - strings.Contains(pr.Descr, "Experiment") || - strings.Contains(pr.Descr, "experiment") { - continue - } - ss := strings.Split(pr.Descr, "\n") - if len(ss) > 1 { - prs[i].Descr = strings.Join(ss, " ") - } else { - prs[i].Descr = ss[0] - } - s := strings.TrimSpace(prs[i].Descr) - prs[i].OrigDescr = s - prs[i].Descr = sr.Replace(s) - prs[i].Value, _ = strconv.Atoi(pr.Value) - } - return prs -} diff --git a/vendor/golang.org/x/net/ipv4/genericopt_posix.go b/vendor/golang.org/x/net/ipv4/genericopt_posix.go deleted file mode 100644 index 58168b737..000000000 --- a/vendor/golang.org/x/net/ipv4/genericopt_posix.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package ipv4 - -import ( - "syscall" - - "golang.org/x/net/internal/netreflect" -) - -// TOS returns the type-of-service field value for outgoing packets. -func (c *genericOpt) TOS() (int, error) { - if !c.ok() { - return 0, syscall.EINVAL - } - s, err := netreflect.SocketOf(c.Conn) - if err != nil { - return 0, err - } - return getInt(s, &sockOpts[ssoTOS]) -} - -// SetTOS sets the type-of-service field value for future outgoing -// packets. -func (c *genericOpt) SetTOS(tos int) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.SocketOf(c.Conn) - if err != nil { - return err - } - return setInt(s, &sockOpts[ssoTOS], tos) -} - -// TTL returns the time-to-live field value for outgoing packets. -func (c *genericOpt) TTL() (int, error) { - if !c.ok() { - return 0, syscall.EINVAL - } - s, err := netreflect.SocketOf(c.Conn) - if err != nil { - return 0, err - } - return getInt(s, &sockOpts[ssoTTL]) -} - -// SetTTL sets the time-to-live field value for future outgoing -// packets. -func (c *genericOpt) SetTTL(ttl int) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.SocketOf(c.Conn) - if err != nil { - return err - } - return setInt(s, &sockOpts[ssoTTL], ttl) -} diff --git a/vendor/golang.org/x/net/ipv4/genericopt_stub.go b/vendor/golang.org/x/net/ipv4/genericopt_stub.go deleted file mode 100644 index 661a4d1ab..000000000 --- a/vendor/golang.org/x/net/ipv4/genericopt_stub.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package ipv4 - -// TOS returns the type-of-service field value for outgoing packets. -func (c *genericOpt) TOS() (int, error) { - return 0, errOpNoSupport -} - -// SetTOS sets the type-of-service field value for future outgoing -// packets. -func (c *genericOpt) SetTOS(tos int) error { - return errOpNoSupport -} - -// TTL returns the time-to-live field value for outgoing packets. -func (c *genericOpt) TTL() (int, error) { - return 0, errOpNoSupport -} - -// SetTTL sets the time-to-live field value for future outgoing -// packets. -func (c *genericOpt) SetTTL(ttl int) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/go19_test.go b/vendor/golang.org/x/net/ipv4/go19_test.go deleted file mode 100644 index 82a27b113..000000000 --- a/vendor/golang.org/x/net/ipv4/go19_test.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.9 - -package ipv4 - -func init() { - disableTests = true -} diff --git a/vendor/golang.org/x/net/ipv4/header.go b/vendor/golang.org/x/net/ipv4/header.go deleted file mode 100644 index 6dc26d43f..000000000 --- a/vendor/golang.org/x/net/ipv4/header.go +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "encoding/binary" - "fmt" - "net" - "runtime" - "syscall" -) - -const ( - Version = 4 // protocol version - HeaderLen = 20 // header length without extension headers - maxHeaderLen = 60 // sensible default, revisit if later RFCs define new usage of version and header length fields -) - -type HeaderFlags int - -const ( - MoreFragments HeaderFlags = 1 << iota // more fragments flag - DontFragment // don't fragment flag -) - -// A Header represents an IPv4 header. -type Header struct { - Version int // protocol version - Len int // header length - TOS int // type-of-service - TotalLen int // packet total length - ID int // identification - Flags HeaderFlags // flags - FragOff int // fragment offset - TTL int // time-to-live - Protocol int // next protocol - Checksum int // checksum - Src net.IP // source address - Dst net.IP // destination address - Options []byte // options, extension headers -} - -func (h *Header) String() string { - if h == nil { - return "" - } - return fmt.Sprintf("ver=%d hdrlen=%d tos=%#x totallen=%d id=%#x flags=%#x fragoff=%#x ttl=%d proto=%d cksum=%#x src=%v dst=%v", h.Version, h.Len, h.TOS, h.TotalLen, h.ID, h.Flags, h.FragOff, h.TTL, h.Protocol, h.Checksum, h.Src, h.Dst) -} - -// Marshal returns the binary encoding of the IPv4 header h. -func (h *Header) Marshal() ([]byte, error) { - if h == nil { - return nil, syscall.EINVAL - } - if h.Len < HeaderLen { - return nil, errHeaderTooShort - } - hdrlen := HeaderLen + len(h.Options) - b := make([]byte, hdrlen) - b[0] = byte(Version<<4 | (hdrlen >> 2 & 0x0f)) - b[1] = byte(h.TOS) - flagsAndFragOff := (h.FragOff & 0x1fff) | int(h.Flags<<13) - switch runtime.GOOS { - case "darwin", "dragonfly", "netbsd": - nativeEndian.PutUint16(b[2:4], uint16(h.TotalLen)) - nativeEndian.PutUint16(b[6:8], uint16(flagsAndFragOff)) - case "freebsd": - if freebsdVersion < 1100000 { - nativeEndian.PutUint16(b[2:4], uint16(h.TotalLen)) - nativeEndian.PutUint16(b[6:8], uint16(flagsAndFragOff)) - } else { - binary.BigEndian.PutUint16(b[2:4], uint16(h.TotalLen)) - binary.BigEndian.PutUint16(b[6:8], uint16(flagsAndFragOff)) - } - default: - binary.BigEndian.PutUint16(b[2:4], uint16(h.TotalLen)) - binary.BigEndian.PutUint16(b[6:8], uint16(flagsAndFragOff)) - } - binary.BigEndian.PutUint16(b[4:6], uint16(h.ID)) - b[8] = byte(h.TTL) - b[9] = byte(h.Protocol) - binary.BigEndian.PutUint16(b[10:12], uint16(h.Checksum)) - if ip := h.Src.To4(); ip != nil { - copy(b[12:16], ip[:net.IPv4len]) - } - if ip := h.Dst.To4(); ip != nil { - copy(b[16:20], ip[:net.IPv4len]) - } else { - return nil, errMissingAddress - } - if len(h.Options) > 0 { - copy(b[HeaderLen:], h.Options) - } - return b, nil -} - -// ParseHeader parses b as an IPv4 header. -func ParseHeader(b []byte) (*Header, error) { - if len(b) < HeaderLen { - return nil, errHeaderTooShort - } - hdrlen := int(b[0]&0x0f) << 2 - if hdrlen > len(b) { - return nil, errBufferTooShort - } - h := &Header{ - Version: int(b[0] >> 4), - Len: hdrlen, - TOS: int(b[1]), - ID: int(binary.BigEndian.Uint16(b[4:6])), - TTL: int(b[8]), - Protocol: int(b[9]), - Checksum: int(binary.BigEndian.Uint16(b[10:12])), - Src: net.IPv4(b[12], b[13], b[14], b[15]), - Dst: net.IPv4(b[16], b[17], b[18], b[19]), - } - switch runtime.GOOS { - case "darwin", "dragonfly", "netbsd": - h.TotalLen = int(nativeEndian.Uint16(b[2:4])) + hdrlen - h.FragOff = int(nativeEndian.Uint16(b[6:8])) - case "freebsd": - if freebsdVersion < 1100000 { - h.TotalLen = int(nativeEndian.Uint16(b[2:4])) - if freebsdVersion < 1000000 { - h.TotalLen += hdrlen - } - h.FragOff = int(nativeEndian.Uint16(b[6:8])) - } else { - h.TotalLen = int(binary.BigEndian.Uint16(b[2:4])) - h.FragOff = int(binary.BigEndian.Uint16(b[6:8])) - } - default: - h.TotalLen = int(binary.BigEndian.Uint16(b[2:4])) - h.FragOff = int(binary.BigEndian.Uint16(b[6:8])) - } - h.Flags = HeaderFlags(h.FragOff&0xe000) >> 13 - h.FragOff = h.FragOff & 0x1fff - if hdrlen-HeaderLen > 0 { - h.Options = make([]byte, hdrlen-HeaderLen) - copy(h.Options, b[HeaderLen:]) - } - return h, nil -} diff --git a/vendor/golang.org/x/net/ipv4/header_test.go b/vendor/golang.org/x/net/ipv4/header_test.go deleted file mode 100644 index cdf27fd03..000000000 --- a/vendor/golang.org/x/net/ipv4/header_test.go +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "bytes" - "encoding/binary" - "net" - "reflect" - "runtime" - "strings" - "testing" -) - -type headerTest struct { - wireHeaderFromKernel [HeaderLen]byte - wireHeaderToKernel [HeaderLen]byte - wireHeaderFromTradBSDKernel [HeaderLen]byte - wireHeaderToTradBSDKernel [HeaderLen]byte - wireHeaderFromFreeBSD10Kernel [HeaderLen]byte - wireHeaderToFreeBSD10Kernel [HeaderLen]byte - *Header -} - -var headerLittleEndianTest = headerTest{ - // TODO(mikio): Add platform dependent wire header formats when - // we support new platforms. - wireHeaderFromKernel: [HeaderLen]byte{ - 0x45, 0x01, 0xbe, 0xef, - 0xca, 0xfe, 0x45, 0xdc, - 0xff, 0x01, 0xde, 0xad, - 172, 16, 254, 254, - 192, 168, 0, 1, - }, - wireHeaderToKernel: [HeaderLen]byte{ - 0x45, 0x01, 0xbe, 0xef, - 0xca, 0xfe, 0x45, 0xdc, - 0xff, 0x01, 0xde, 0xad, - 172, 16, 254, 254, - 192, 168, 0, 1, - }, - wireHeaderFromTradBSDKernel: [HeaderLen]byte{ - 0x45, 0x01, 0xdb, 0xbe, - 0xca, 0xfe, 0xdc, 0x45, - 0xff, 0x01, 0xde, 0xad, - 172, 16, 254, 254, - 192, 168, 0, 1, - }, - wireHeaderToTradBSDKernel: [HeaderLen]byte{ - 0x45, 0x01, 0xef, 0xbe, - 0xca, 0xfe, 0xdc, 0x45, - 0xff, 0x01, 0xde, 0xad, - 172, 16, 254, 254, - 192, 168, 0, 1, - }, - wireHeaderFromFreeBSD10Kernel: [HeaderLen]byte{ - 0x45, 0x01, 0xef, 0xbe, - 0xca, 0xfe, 0xdc, 0x45, - 0xff, 0x01, 0xde, 0xad, - 172, 16, 254, 254, - 192, 168, 0, 1, - }, - wireHeaderToFreeBSD10Kernel: [HeaderLen]byte{ - 0x45, 0x01, 0xef, 0xbe, - 0xca, 0xfe, 0xdc, 0x45, - 0xff, 0x01, 0xde, 0xad, - 172, 16, 254, 254, - 192, 168, 0, 1, - }, - Header: &Header{ - Version: Version, - Len: HeaderLen, - TOS: 1, - TotalLen: 0xbeef, - ID: 0xcafe, - Flags: DontFragment, - FragOff: 1500, - TTL: 255, - Protocol: 1, - Checksum: 0xdead, - Src: net.IPv4(172, 16, 254, 254), - Dst: net.IPv4(192, 168, 0, 1), - }, -} - -func TestMarshalHeader(t *testing.T) { - tt := &headerLittleEndianTest - if nativeEndian != binary.LittleEndian { - t.Skip("no test for non-little endian machine yet") - } - - b, err := tt.Header.Marshal() - if err != nil { - t.Fatal(err) - } - var wh []byte - switch runtime.GOOS { - case "darwin", "dragonfly", "netbsd": - wh = tt.wireHeaderToTradBSDKernel[:] - case "freebsd": - switch { - case freebsdVersion < 1000000: - wh = tt.wireHeaderToTradBSDKernel[:] - case 1000000 <= freebsdVersion && freebsdVersion < 1100000: - wh = tt.wireHeaderToFreeBSD10Kernel[:] - default: - wh = tt.wireHeaderToKernel[:] - } - default: - wh = tt.wireHeaderToKernel[:] - } - if !bytes.Equal(b, wh) { - t.Fatalf("got %#v; want %#v", b, wh) - } -} - -func TestParseHeader(t *testing.T) { - tt := &headerLittleEndianTest - if nativeEndian != binary.LittleEndian { - t.Skip("no test for big endian machine yet") - } - - var wh []byte - switch runtime.GOOS { - case "darwin", "dragonfly", "netbsd": - wh = tt.wireHeaderFromTradBSDKernel[:] - case "freebsd": - switch { - case freebsdVersion < 1000000: - wh = tt.wireHeaderFromTradBSDKernel[:] - case 1000000 <= freebsdVersion && freebsdVersion < 1100000: - wh = tt.wireHeaderFromFreeBSD10Kernel[:] - default: - wh = tt.wireHeaderFromKernel[:] - } - default: - wh = tt.wireHeaderFromKernel[:] - } - h, err := ParseHeader(wh) - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(h, tt.Header) { - t.Fatalf("got %#v; want %#v", h, tt.Header) - } - s := h.String() - if strings.Contains(s, ",") { - t.Fatalf("should be space-separated values: %s", s) - } -} diff --git a/vendor/golang.org/x/net/ipv4/helper.go b/vendor/golang.org/x/net/ipv4/helper.go deleted file mode 100644 index 083897995..000000000 --- a/vendor/golang.org/x/net/ipv4/helper.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "encoding/binary" - "errors" - "net" - "unsafe" -) - -var ( - errMissingAddress = errors.New("missing address") - errMissingHeader = errors.New("missing header") - errHeaderTooShort = errors.New("header too short") - errBufferTooShort = errors.New("buffer too short") - errInvalidConnType = errors.New("invalid conn type") - errOpNoSupport = errors.New("operation not supported") - errNoSuchInterface = errors.New("no such interface") - errNoSuchMulticastInterface = errors.New("no such multicast interface") - - // See http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html. - freebsdVersion uint32 - - nativeEndian binary.ByteOrder -) - -func init() { - i := uint32(1) - b := (*[4]byte)(unsafe.Pointer(&i)) - if b[0] == 1 { - nativeEndian = binary.LittleEndian - } else { - nativeEndian = binary.BigEndian - } -} - -func boolint(b bool) int { - if b { - return 1 - } - return 0 -} - -func netAddrToIP4(a net.Addr) net.IP { - switch v := a.(type) { - case *net.UDPAddr: - if ip := v.IP.To4(); ip != nil { - return ip - } - case *net.IPAddr: - if ip := v.IP.To4(); ip != nil { - return ip - } - } - return nil -} diff --git a/vendor/golang.org/x/net/ipv4/iana.go b/vendor/golang.org/x/net/ipv4/iana.go deleted file mode 100644 index be10c9488..000000000 --- a/vendor/golang.org/x/net/ipv4/iana.go +++ /dev/null @@ -1,34 +0,0 @@ -// go generate gen.go -// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT - -package ipv4 - -// Internet Control Message Protocol (ICMP) Parameters, Updated: 2013-04-19 -const ( - ICMPTypeEchoReply ICMPType = 0 // Echo Reply - ICMPTypeDestinationUnreachable ICMPType = 3 // Destination Unreachable - ICMPTypeRedirect ICMPType = 5 // Redirect - ICMPTypeEcho ICMPType = 8 // Echo - ICMPTypeRouterAdvertisement ICMPType = 9 // Router Advertisement - ICMPTypeRouterSolicitation ICMPType = 10 // Router Solicitation - ICMPTypeTimeExceeded ICMPType = 11 // Time Exceeded - ICMPTypeParameterProblem ICMPType = 12 // Parameter Problem - ICMPTypeTimestamp ICMPType = 13 // Timestamp - ICMPTypeTimestampReply ICMPType = 14 // Timestamp Reply - ICMPTypePhoturis ICMPType = 40 // Photuris -) - -// Internet Control Message Protocol (ICMP) Parameters, Updated: 2013-04-19 -var icmpTypes = map[ICMPType]string{ - 0: "echo reply", - 3: "destination unreachable", - 5: "redirect", - 8: "echo", - 9: "router advertisement", - 10: "router solicitation", - 11: "time exceeded", - 12: "parameter problem", - 13: "timestamp", - 14: "timestamp reply", - 40: "photuris", -} diff --git a/vendor/golang.org/x/net/ipv4/icmp.go b/vendor/golang.org/x/net/ipv4/icmp.go deleted file mode 100644 index 097bea846..000000000 --- a/vendor/golang.org/x/net/ipv4/icmp.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import "golang.org/x/net/internal/iana" - -// An ICMPType represents a type of ICMP message. -type ICMPType int - -func (typ ICMPType) String() string { - s, ok := icmpTypes[typ] - if !ok { - return "" - } - return s -} - -// Protocol returns the ICMPv4 protocol number. -func (typ ICMPType) Protocol() int { - return iana.ProtocolICMP -} - -// An ICMPFilter represents an ICMP message filter for incoming -// packets. The filter belongs to a packet delivery path on a host and -// it cannot interact with forwarding packets or tunnel-outer packets. -// -// Note: RFC 2460 defines a reasonable role model and it works not -// only for IPv6 but IPv4. A node means a device that implements IP. -// A router means a node that forwards IP packets not explicitly -// addressed to itself, and a host means a node that is not a router. -type ICMPFilter struct { - icmpFilter -} - -// Accept accepts incoming ICMP packets including the type field value -// typ. -func (f *ICMPFilter) Accept(typ ICMPType) { - f.accept(typ) -} - -// Block blocks incoming ICMP packets including the type field value -// typ. -func (f *ICMPFilter) Block(typ ICMPType) { - f.block(typ) -} - -// SetAll sets the filter action to the filter. -func (f *ICMPFilter) SetAll(block bool) { - f.setAll(block) -} - -// WillBlock reports whether the ICMP type will be blocked. -func (f *ICMPFilter) WillBlock(typ ICMPType) bool { - return f.willBlock(typ) -} diff --git a/vendor/golang.org/x/net/ipv4/icmp_linux.go b/vendor/golang.org/x/net/ipv4/icmp_linux.go deleted file mode 100644 index 6e1c5c80a..000000000 --- a/vendor/golang.org/x/net/ipv4/icmp_linux.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -func (f *icmpFilter) accept(typ ICMPType) { - f.Data &^= 1 << (uint32(typ) & 31) -} - -func (f *icmpFilter) block(typ ICMPType) { - f.Data |= 1 << (uint32(typ) & 31) -} - -func (f *icmpFilter) setAll(block bool) { - if block { - f.Data = 1<<32 - 1 - } else { - f.Data = 0 - } -} - -func (f *icmpFilter) willBlock(typ ICMPType) bool { - return f.Data&(1<<(uint32(typ)&31)) != 0 -} diff --git a/vendor/golang.org/x/net/ipv4/icmp_stub.go b/vendor/golang.org/x/net/ipv4/icmp_stub.go deleted file mode 100644 index 21bb29ab3..000000000 --- a/vendor/golang.org/x/net/ipv4/icmp_stub.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !linux - -package ipv4 - -const sizeofICMPFilter = 0x0 - -type icmpFilter struct { -} - -func (f *icmpFilter) accept(typ ICMPType) { -} - -func (f *icmpFilter) block(typ ICMPType) { -} - -func (f *icmpFilter) setAll(block bool) { -} - -func (f *icmpFilter) willBlock(typ ICMPType) bool { - return false -} diff --git a/vendor/golang.org/x/net/ipv4/icmp_test.go b/vendor/golang.org/x/net/ipv4/icmp_test.go deleted file mode 100644 index 3324b54df..000000000 --- a/vendor/golang.org/x/net/ipv4/icmp_test.go +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "net" - "reflect" - "runtime" - "testing" - - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv4" -) - -var icmpStringTests = []struct { - in ipv4.ICMPType - out string -}{ - {ipv4.ICMPTypeDestinationUnreachable, "destination unreachable"}, - - {256, ""}, -} - -func TestICMPString(t *testing.T) { - for _, tt := range icmpStringTests { - s := tt.in.String() - if s != tt.out { - t.Errorf("got %s; want %s", s, tt.out) - } - } -} - -func TestICMPFilter(t *testing.T) { - switch runtime.GOOS { - case "linux": - default: - t.Skipf("not supported on %s", runtime.GOOS) - } - - var f ipv4.ICMPFilter - for _, toggle := range []bool{false, true} { - f.SetAll(toggle) - for _, typ := range []ipv4.ICMPType{ - ipv4.ICMPTypeDestinationUnreachable, - ipv4.ICMPTypeEchoReply, - ipv4.ICMPTypeTimeExceeded, - ipv4.ICMPTypeParameterProblem, - } { - f.Accept(typ) - if f.WillBlock(typ) { - t.Errorf("ipv4.ICMPFilter.Set(%v, false) failed", typ) - } - f.Block(typ) - if !f.WillBlock(typ) { - t.Errorf("ipv4.ICMPFilter.Set(%v, true) failed", typ) - } - } - } -} - -func TestSetICMPFilter(t *testing.T) { - switch runtime.GOOS { - case "linux": - default: - t.Skipf("not supported on %s", runtime.GOOS) - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - c, err := net.ListenPacket("ip4:icmp", "127.0.0.1") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - p := ipv4.NewPacketConn(c) - - var f ipv4.ICMPFilter - f.SetAll(true) - f.Accept(ipv4.ICMPTypeEcho) - f.Accept(ipv4.ICMPTypeEchoReply) - if err := p.SetICMPFilter(&f); err != nil { - t.Fatal(err) - } - kf, err := p.ICMPFilter() - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(kf, &f) { - t.Fatalf("got %#v; want %#v", kf, f) - } -} diff --git a/vendor/golang.org/x/net/ipv4/ipv4_test.go b/vendor/golang.org/x/net/ipv4/ipv4_test.go deleted file mode 100644 index 917299283..000000000 --- a/vendor/golang.org/x/net/ipv4/ipv4_test.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "fmt" - "os" - "testing" -) - -var disableTests = false - -func TestMain(m *testing.M) { - if disableTests { - fmt.Fprintf(os.Stderr, "ipv4 tests disabled in Go 1.9 until netreflect is fixed. (Issue 19051)\n") - os.Exit(0) - } - // call flag.Parse() here if TestMain uses flags - os.Exit(m.Run()) -} diff --git a/vendor/golang.org/x/net/ipv4/multicast_test.go b/vendor/golang.org/x/net/ipv4/multicast_test.go deleted file mode 100644 index bcf49736b..000000000 --- a/vendor/golang.org/x/net/ipv4/multicast_test.go +++ /dev/null @@ -1,334 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "bytes" - "net" - "os" - "runtime" - "testing" - "time" - - "golang.org/x/net/icmp" - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv4" -) - -var packetConnReadWriteMulticastUDPTests = []struct { - addr string - grp, src *net.UDPAddr -}{ - {"224.0.0.0:0", &net.UDPAddr{IP: net.IPv4(224, 0, 0, 254)}, nil}, // see RFC 4727 - - {"232.0.1.0:0", &net.UDPAddr{IP: net.IPv4(232, 0, 1, 254)}, &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771 -} - -func TestPacketConnReadWriteMulticastUDP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagMulticast|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - for _, tt := range packetConnReadWriteMulticastUDPTests { - c, err := net.ListenPacket("udp4", tt.addr) - if err != nil { - t.Fatal(err) - } - defer c.Close() - - grp := *tt.grp - grp.Port = c.LocalAddr().(*net.UDPAddr).Port - p := ipv4.NewPacketConn(c) - defer p.Close() - if tt.src == nil { - if err := p.JoinGroup(ifi, &grp); err != nil { - t.Fatal(err) - } - defer p.LeaveGroup(ifi, &grp) - } else { - if err := p.JoinSourceSpecificGroup(ifi, &grp, tt.src); err != nil { - switch runtime.GOOS { - case "freebsd", "linux": - default: // platforms that don't support IGMPv2/3 fail here - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - defer p.LeaveSourceSpecificGroup(ifi, &grp, tt.src) - } - if err := p.SetMulticastInterface(ifi); err != nil { - t.Fatal(err) - } - if _, err := p.MulticastInterface(); err != nil { - t.Fatal(err) - } - if err := p.SetMulticastLoopback(true); err != nil { - t.Fatal(err) - } - if _, err := p.MulticastLoopback(); err != nil { - t.Fatal(err) - } - cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface - wb := []byte("HELLO-R-U-THERE") - - for i, toggle := range []bool{true, false, true} { - if err := p.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - if err := p.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil { - t.Fatal(err) - } - p.SetMulticastTTL(i + 1) - if n, err := p.WriteTo(wb, nil, &grp); err != nil { - t.Fatal(err) - } else if n != len(wb) { - t.Fatalf("got %v; want %v", n, len(wb)) - } - rb := make([]byte, 128) - if n, _, _, err := p.ReadFrom(rb); err != nil { - t.Fatal(err) - } else if !bytes.Equal(rb[:n], wb) { - t.Fatalf("got %v; want %v", rb[:n], wb) - } - } - } -} - -var packetConnReadWriteMulticastICMPTests = []struct { - grp, src *net.IPAddr -}{ - {&net.IPAddr{IP: net.IPv4(224, 0, 0, 254)}, nil}, // see RFC 4727 - - {&net.IPAddr{IP: net.IPv4(232, 0, 1, 254)}, &net.IPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771 -} - -func TestPacketConnReadWriteMulticastICMP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagMulticast|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - for _, tt := range packetConnReadWriteMulticastICMPTests { - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - p := ipv4.NewPacketConn(c) - defer p.Close() - if tt.src == nil { - if err := p.JoinGroup(ifi, tt.grp); err != nil { - t.Fatal(err) - } - defer p.LeaveGroup(ifi, tt.grp) - } else { - if err := p.JoinSourceSpecificGroup(ifi, tt.grp, tt.src); err != nil { - switch runtime.GOOS { - case "freebsd", "linux": - default: // platforms that don't support IGMPv2/3 fail here - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - defer p.LeaveSourceSpecificGroup(ifi, tt.grp, tt.src) - } - if err := p.SetMulticastInterface(ifi); err != nil { - t.Fatal(err) - } - if _, err := p.MulticastInterface(); err != nil { - t.Fatal(err) - } - if err := p.SetMulticastLoopback(true); err != nil { - t.Fatal(err) - } - if _, err := p.MulticastLoopback(); err != nil { - t.Fatal(err) - } - cf := ipv4.FlagDst | ipv4.FlagInterface - if runtime.GOOS != "solaris" { - // Solaris never allows to modify ICMP properties. - cf |= ipv4.FlagTTL - } - - for i, toggle := range []bool{true, false, true} { - wb, err := (&icmp.Message{ - Type: ipv4.ICMPTypeEcho, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, Seq: i + 1, - Data: []byte("HELLO-R-U-THERE"), - }, - }).Marshal(nil) - if err != nil { - t.Fatal(err) - } - if err := p.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - if err := p.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil { - t.Fatal(err) - } - p.SetMulticastTTL(i + 1) - if n, err := p.WriteTo(wb, nil, tt.grp); err != nil { - t.Fatal(err) - } else if n != len(wb) { - t.Fatalf("got %v; want %v", n, len(wb)) - } - rb := make([]byte, 128) - if n, _, _, err := p.ReadFrom(rb); err != nil { - t.Fatal(err) - } else { - m, err := icmp.ParseMessage(iana.ProtocolICMP, rb[:n]) - if err != nil { - t.Fatal(err) - } - switch { - case m.Type == ipv4.ICMPTypeEchoReply && m.Code == 0: // net.inet.icmp.bmcastecho=1 - case m.Type == ipv4.ICMPTypeEcho && m.Code == 0: // net.inet.icmp.bmcastecho=0 - default: - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv4.ICMPTypeEchoReply, 0) - } - } - } - } -} - -var rawConnReadWriteMulticastICMPTests = []struct { - grp, src *net.IPAddr -}{ - {&net.IPAddr{IP: net.IPv4(224, 0, 0, 254)}, nil}, // see RFC 4727 - - {&net.IPAddr{IP: net.IPv4(232, 0, 1, 254)}, &net.IPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771 -} - -func TestRawConnReadWriteMulticastICMP(t *testing.T) { - if testing.Short() { - t.Skip("to avoid external network") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagMulticast|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - for _, tt := range rawConnReadWriteMulticastICMPTests { - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - r, err := ipv4.NewRawConn(c) - if err != nil { - t.Fatal(err) - } - defer r.Close() - if tt.src == nil { - if err := r.JoinGroup(ifi, tt.grp); err != nil { - t.Fatal(err) - } - defer r.LeaveGroup(ifi, tt.grp) - } else { - if err := r.JoinSourceSpecificGroup(ifi, tt.grp, tt.src); err != nil { - switch runtime.GOOS { - case "freebsd", "linux": - default: // platforms that don't support IGMPv2/3 fail here - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - defer r.LeaveSourceSpecificGroup(ifi, tt.grp, tt.src) - } - if err := r.SetMulticastInterface(ifi); err != nil { - t.Fatal(err) - } - if _, err := r.MulticastInterface(); err != nil { - t.Fatal(err) - } - if err := r.SetMulticastLoopback(true); err != nil { - t.Fatal(err) - } - if _, err := r.MulticastLoopback(); err != nil { - t.Fatal(err) - } - cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface - - for i, toggle := range []bool{true, false, true} { - wb, err := (&icmp.Message{ - Type: ipv4.ICMPTypeEcho, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, Seq: i + 1, - Data: []byte("HELLO-R-U-THERE"), - }, - }).Marshal(nil) - if err != nil { - t.Fatal(err) - } - wh := &ipv4.Header{ - Version: ipv4.Version, - Len: ipv4.HeaderLen, - TOS: i + 1, - TotalLen: ipv4.HeaderLen + len(wb), - Protocol: 1, - Dst: tt.grp.IP, - } - if err := r.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - if err := r.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil { - t.Fatal(err) - } - r.SetMulticastTTL(i + 1) - if err := r.WriteTo(wh, wb, nil); err != nil { - t.Fatal(err) - } - rb := make([]byte, ipv4.HeaderLen+128) - if rh, b, _, err := r.ReadFrom(rb); err != nil { - t.Fatal(err) - } else { - m, err := icmp.ParseMessage(iana.ProtocolICMP, b) - if err != nil { - t.Fatal(err) - } - switch { - case (rh.Dst.IsLoopback() || rh.Dst.IsLinkLocalUnicast() || rh.Dst.IsGlobalUnicast()) && m.Type == ipv4.ICMPTypeEchoReply && m.Code == 0: // net.inet.icmp.bmcastecho=1 - case rh.Dst.IsMulticast() && m.Type == ipv4.ICMPTypeEcho && m.Code == 0: // net.inet.icmp.bmcastecho=0 - default: - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv4.ICMPTypeEchoReply, 0) - } - } - } - } -} diff --git a/vendor/golang.org/x/net/ipv4/multicastlistener_test.go b/vendor/golang.org/x/net/ipv4/multicastlistener_test.go deleted file mode 100644 index a0c24b55b..000000000 --- a/vendor/golang.org/x/net/ipv4/multicastlistener_test.go +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "net" - "runtime" - "testing" - - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv4" -) - -var udpMultipleGroupListenerTests = []net.Addr{ - &net.UDPAddr{IP: net.IPv4(224, 0, 0, 249)}, // see RFC 4727 - &net.UDPAddr{IP: net.IPv4(224, 0, 0, 250)}, - &net.UDPAddr{IP: net.IPv4(224, 0, 0, 254)}, -} - -func TestUDPSinglePacketConnWithMultipleGroupListeners(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if testing.Short() { - t.Skip("to avoid external network") - } - - for _, gaddr := range udpMultipleGroupListenerTests { - c, err := net.ListenPacket("udp4", "0.0.0.0:0") // wildcard address with no reusable port - if err != nil { - t.Fatal(err) - } - defer c.Close() - - p := ipv4.NewPacketConn(c) - var mift []*net.Interface - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - if _, ok := nettest.IsMulticastCapable("ip4", &ifi); !ok { - continue - } - if err := p.JoinGroup(&ifi, gaddr); err != nil { - t.Fatal(err) - } - mift = append(mift, &ift[i]) - } - for _, ifi := range mift { - if err := p.LeaveGroup(ifi, gaddr); err != nil { - t.Fatal(err) - } - } - } -} - -func TestUDPMultiplePacketConnWithMultipleGroupListeners(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if testing.Short() { - t.Skip("to avoid external network") - } - - for _, gaddr := range udpMultipleGroupListenerTests { - c1, err := net.ListenPacket("udp4", "224.0.0.0:1024") // wildcard address with reusable port - if err != nil { - t.Fatal(err) - } - defer c1.Close() - - c2, err := net.ListenPacket("udp4", "224.0.0.0:1024") // wildcard address with reusable port - if err != nil { - t.Fatal(err) - } - defer c2.Close() - - var ps [2]*ipv4.PacketConn - ps[0] = ipv4.NewPacketConn(c1) - ps[1] = ipv4.NewPacketConn(c2) - var mift []*net.Interface - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - if _, ok := nettest.IsMulticastCapable("ip4", &ifi); !ok { - continue - } - for _, p := range ps { - if err := p.JoinGroup(&ifi, gaddr); err != nil { - t.Fatal(err) - } - } - mift = append(mift, &ift[i]) - } - for _, ifi := range mift { - for _, p := range ps { - if err := p.LeaveGroup(ifi, gaddr); err != nil { - t.Fatal(err) - } - } - } - } -} - -func TestUDPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if testing.Short() { - t.Skip("to avoid external network") - } - - gaddr := net.IPAddr{IP: net.IPv4(224, 0, 0, 254)} // see RFC 4727 - type ml struct { - c *ipv4.PacketConn - ifi *net.Interface - } - var mlt []*ml - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - ip, ok := nettest.IsMulticastCapable("ip4", &ifi) - if !ok { - continue - } - c, err := net.ListenPacket("udp4", ip.String()+":"+"1024") // unicast address with non-reusable port - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv4.NewPacketConn(c) - if err := p.JoinGroup(&ifi, &gaddr); err != nil { - t.Fatal(err) - } - mlt = append(mlt, &ml{p, &ift[i]}) - } - for _, m := range mlt { - if err := m.c.LeaveGroup(m.ifi, &gaddr); err != nil { - t.Fatal(err) - } - } -} - -func TestIPSingleRawConnWithSingleGroupListener(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if testing.Short() { - t.Skip("to avoid external network") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0") // wildcard address - if err != nil { - t.Fatal(err) - } - defer c.Close() - - r, err := ipv4.NewRawConn(c) - if err != nil { - t.Fatal(err) - } - gaddr := net.IPAddr{IP: net.IPv4(224, 0, 0, 254)} // see RFC 4727 - var mift []*net.Interface - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - if _, ok := nettest.IsMulticastCapable("ip4", &ifi); !ok { - continue - } - if err := r.JoinGroup(&ifi, &gaddr); err != nil { - t.Fatal(err) - } - mift = append(mift, &ift[i]) - } - for _, ifi := range mift { - if err := r.LeaveGroup(ifi, &gaddr); err != nil { - t.Fatal(err) - } - } -} - -func TestIPPerInterfaceSingleRawConnWithSingleGroupListener(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if testing.Short() { - t.Skip("to avoid external network") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - gaddr := net.IPAddr{IP: net.IPv4(224, 0, 0, 254)} // see RFC 4727 - type ml struct { - c *ipv4.RawConn - ifi *net.Interface - } - var mlt []*ml - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - ip, ok := nettest.IsMulticastCapable("ip4", &ifi) - if !ok { - continue - } - c, err := net.ListenPacket("ip4:253", ip.String()) // unicast address - if err != nil { - t.Fatal(err) - } - defer c.Close() - r, err := ipv4.NewRawConn(c) - if err != nil { - t.Fatal(err) - } - if err := r.JoinGroup(&ifi, &gaddr); err != nil { - t.Fatal(err) - } - mlt = append(mlt, &ml{r, &ift[i]}) - } - for _, m := range mlt { - if err := m.c.LeaveGroup(m.ifi, &gaddr); err != nil { - t.Fatal(err) - } - } -} diff --git a/vendor/golang.org/x/net/ipv4/multicastsockopt_test.go b/vendor/golang.org/x/net/ipv4/multicastsockopt_test.go deleted file mode 100644 index f7efac24c..000000000 --- a/vendor/golang.org/x/net/ipv4/multicastsockopt_test.go +++ /dev/null @@ -1,195 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "net" - "runtime" - "testing" - - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv4" -) - -var packetConnMulticastSocketOptionTests = []struct { - net, proto, addr string - grp, src net.Addr -}{ - {"udp4", "", "224.0.0.0:0", &net.UDPAddr{IP: net.IPv4(224, 0, 0, 249)}, nil}, // see RFC 4727 - {"ip4", ":icmp", "0.0.0.0", &net.IPAddr{IP: net.IPv4(224, 0, 0, 250)}, nil}, // see RFC 4727 - - {"udp4", "", "232.0.0.0:0", &net.UDPAddr{IP: net.IPv4(232, 0, 1, 249)}, &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771 - {"ip4", ":icmp", "0.0.0.0", &net.IPAddr{IP: net.IPv4(232, 0, 1, 250)}, &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771 -} - -func TestPacketConnMulticastSocketOptions(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9": - t.Skipf("not supported on %s", runtime.GOOS) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagMulticast|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - m, ok := nettest.SupportsRawIPSocket() - for _, tt := range packetConnMulticastSocketOptionTests { - if tt.net == "ip4" && !ok { - t.Log(m) - continue - } - c, err := net.ListenPacket(tt.net+tt.proto, tt.addr) - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv4.NewPacketConn(c) - defer p.Close() - - if tt.src == nil { - testMulticastSocketOptions(t, p, ifi, tt.grp) - } else { - testSourceSpecificMulticastSocketOptions(t, p, ifi, tt.grp, tt.src) - } - } -} - -var rawConnMulticastSocketOptionTests = []struct { - grp, src net.Addr -}{ - {&net.IPAddr{IP: net.IPv4(224, 0, 0, 250)}, nil}, // see RFC 4727 - - {&net.IPAddr{IP: net.IPv4(232, 0, 1, 250)}, &net.IPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771 -} - -func TestRawConnMulticastSocketOptions(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9": - t.Skipf("not supported on %s", runtime.GOOS) - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagMulticast|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - for _, tt := range rawConnMulticastSocketOptionTests { - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - r, err := ipv4.NewRawConn(c) - if err != nil { - t.Fatal(err) - } - defer r.Close() - - if tt.src == nil { - testMulticastSocketOptions(t, r, ifi, tt.grp) - } else { - testSourceSpecificMulticastSocketOptions(t, r, ifi, tt.grp, tt.src) - } - } -} - -type testIPv4MulticastConn interface { - MulticastTTL() (int, error) - SetMulticastTTL(ttl int) error - MulticastLoopback() (bool, error) - SetMulticastLoopback(bool) error - JoinGroup(*net.Interface, net.Addr) error - LeaveGroup(*net.Interface, net.Addr) error - JoinSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error - LeaveSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error - ExcludeSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error - IncludeSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error -} - -func testMulticastSocketOptions(t *testing.T, c testIPv4MulticastConn, ifi *net.Interface, grp net.Addr) { - const ttl = 255 - if err := c.SetMulticastTTL(ttl); err != nil { - t.Error(err) - return - } - if v, err := c.MulticastTTL(); err != nil { - t.Error(err) - return - } else if v != ttl { - t.Errorf("got %v; want %v", v, ttl) - return - } - - for _, toggle := range []bool{true, false} { - if err := c.SetMulticastLoopback(toggle); err != nil { - t.Error(err) - return - } - if v, err := c.MulticastLoopback(); err != nil { - t.Error(err) - return - } else if v != toggle { - t.Errorf("got %v; want %v", v, toggle) - return - } - } - - if err := c.JoinGroup(ifi, grp); err != nil { - t.Error(err) - return - } - if err := c.LeaveGroup(ifi, grp); err != nil { - t.Error(err) - return - } -} - -func testSourceSpecificMulticastSocketOptions(t *testing.T, c testIPv4MulticastConn, ifi *net.Interface, grp, src net.Addr) { - // MCAST_JOIN_GROUP -> MCAST_BLOCK_SOURCE -> MCAST_UNBLOCK_SOURCE -> MCAST_LEAVE_GROUP - if err := c.JoinGroup(ifi, grp); err != nil { - t.Error(err) - return - } - if err := c.ExcludeSourceSpecificGroup(ifi, grp, src); err != nil { - switch runtime.GOOS { - case "freebsd", "linux": - default: // platforms that don't support IGMPv2/3 fail here - t.Logf("not supported on %s", runtime.GOOS) - return - } - t.Error(err) - return - } - if err := c.IncludeSourceSpecificGroup(ifi, grp, src); err != nil { - t.Error(err) - return - } - if err := c.LeaveGroup(ifi, grp); err != nil { - t.Error(err) - return - } - - // MCAST_JOIN_SOURCE_GROUP -> MCAST_LEAVE_SOURCE_GROUP - if err := c.JoinSourceSpecificGroup(ifi, grp, src); err != nil { - t.Error(err) - return - } - if err := c.LeaveSourceSpecificGroup(ifi, grp, src); err != nil { - t.Error(err) - return - } - - // MCAST_JOIN_SOURCE_GROUP -> MCAST_LEAVE_GROUP - if err := c.JoinSourceSpecificGroup(ifi, grp, src); err != nil { - t.Error(err) - return - } - if err := c.LeaveGroup(ifi, grp); err != nil { - t.Error(err) - return - } -} diff --git a/vendor/golang.org/x/net/ipv4/packet.go b/vendor/golang.org/x/net/ipv4/packet.go deleted file mode 100644 index d43723ca9..000000000 --- a/vendor/golang.org/x/net/ipv4/packet.go +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "syscall" -) - -// BUG(mikio): On Windows, the ReadFrom and WriteTo methods of RawConn -// are not implemented. - -// A packetHandler represents the IPv4 datagram handler. -type packetHandler struct { - c *net.IPConn - rawOpt -} - -func (c *packetHandler) ok() bool { return c != nil && c.c != nil } - -// ReadFrom reads an IPv4 datagram from the endpoint c, copying the -// datagram into b. It returns the received datagram as the IPv4 -// header h, the payload p and the control message cm. -func (c *packetHandler) ReadFrom(b []byte) (h *Header, p []byte, cm *ControlMessage, err error) { - if !c.ok() { - return nil, nil, nil, syscall.EINVAL - } - oob := newControlMessage(&c.rawOpt) - n, oobn, _, src, err := c.c.ReadMsgIP(b, oob) - if err != nil { - return nil, nil, nil, err - } - var hs []byte - if hs, p, err = slicePacket(b[:n]); err != nil { - return nil, nil, nil, err - } - if h, err = ParseHeader(hs); err != nil { - return nil, nil, nil, err - } - if cm, err = parseControlMessage(oob[:oobn]); err != nil { - return nil, nil, nil, err - } - if src != nil && cm != nil { - cm.Src = src.IP - } - return -} - -func slicePacket(b []byte) (h, p []byte, err error) { - if len(b) < HeaderLen { - return nil, nil, errHeaderTooShort - } - hdrlen := int(b[0]&0x0f) << 2 - return b[:hdrlen], b[hdrlen:], nil -} - -// WriteTo writes an IPv4 datagram through the endpoint c, copying the -// datagram from the IPv4 header h and the payload p. The control -// message cm allows the datagram path and the outgoing interface to be -// specified. Currently only Darwin and Linux support this. The cm -// may be nil if control of the outgoing datagram is not required. -// -// The IPv4 header h must contain appropriate fields that include: -// -// Version = -// Len = -// TOS = -// TotalLen = -// ID = platform sets an appropriate value if ID is zero -// FragOff = -// TTL = -// Protocol = -// Checksum = platform sets an appropriate value if Checksum is zero -// Src = platform sets an appropriate value if Src is nil -// Dst = -// Options = optional -func (c *packetHandler) WriteTo(h *Header, p []byte, cm *ControlMessage) error { - if !c.ok() { - return syscall.EINVAL - } - oob := marshalControlMessage(cm) - wh, err := h.Marshal() - if err != nil { - return err - } - dst := &net.IPAddr{} - if cm != nil { - if ip := cm.Dst.To4(); ip != nil { - dst.IP = ip - } - } - if dst.IP == nil { - dst.IP = h.Dst - } - wh = append(wh, p...) - _, _, err = c.c.WriteMsgIP(wh, oob, dst) - return err -} diff --git a/vendor/golang.org/x/net/ipv4/payload.go b/vendor/golang.org/x/net/ipv4/payload.go deleted file mode 100644 index be130e424..000000000 --- a/vendor/golang.org/x/net/ipv4/payload.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import "net" - -// BUG(mikio): On Windows, the ControlMessage for ReadFrom and WriteTo -// methods of PacketConn is not implemented. - -// A payloadHandler represents the IPv4 datagram payload handler. -type payloadHandler struct { - net.PacketConn - rawOpt -} - -func (c *payloadHandler) ok() bool { return c != nil && c.PacketConn != nil } diff --git a/vendor/golang.org/x/net/ipv4/payload_cmsg.go b/vendor/golang.org/x/net/ipv4/payload_cmsg.go deleted file mode 100644 index 5e6e55c20..000000000 --- a/vendor/golang.org/x/net/ipv4/payload_cmsg.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !plan9,!windows - -package ipv4 - -import ( - "net" - "syscall" -) - -// ReadFrom reads a payload of the received IPv4 datagram, from the -// endpoint c, copying the payload into b. It returns the number of -// bytes copied into b, the control message cm and the source address -// src of the received datagram. -func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) { - if !c.ok() { - return 0, nil, nil, syscall.EINVAL - } - oob := newControlMessage(&c.rawOpt) - var oobn int - switch c := c.PacketConn.(type) { - case *net.UDPConn: - if n, oobn, _, src, err = c.ReadMsgUDP(b, oob); err != nil { - return 0, nil, nil, err - } - case *net.IPConn: - if sockOpts[ssoStripHeader].name > 0 { - if n, oobn, _, src, err = c.ReadMsgIP(b, oob); err != nil { - return 0, nil, nil, err - } - } else { - nb := make([]byte, maxHeaderLen+len(b)) - if n, oobn, _, src, err = c.ReadMsgIP(nb, oob); err != nil { - return 0, nil, nil, err - } - hdrlen := int(nb[0]&0x0f) << 2 - copy(b, nb[hdrlen:]) - n -= hdrlen - } - default: - return 0, nil, nil, errInvalidConnType - } - if cm, err = parseControlMessage(oob[:oobn]); err != nil { - return 0, nil, nil, err - } - if cm != nil { - cm.Src = netAddrToIP4(src) - } - return -} - -// WriteTo writes a payload of the IPv4 datagram, to the destination -// address dst through the endpoint c, copying the payload from b. It -// returns the number of bytes written. The control message cm allows -// the datagram path and the outgoing interface to be specified. -// Currently only Darwin and Linux support this. The cm may be nil if -// control of the outgoing datagram is not required. -func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) { - if !c.ok() { - return 0, syscall.EINVAL - } - oob := marshalControlMessage(cm) - if dst == nil { - return 0, errMissingAddress - } - switch c := c.PacketConn.(type) { - case *net.UDPConn: - n, _, err = c.WriteMsgUDP(b, oob, dst.(*net.UDPAddr)) - case *net.IPConn: - n, _, err = c.WriteMsgIP(b, oob, dst.(*net.IPAddr)) - default: - return 0, errInvalidConnType - } - if err != nil { - return 0, err - } - return -} diff --git a/vendor/golang.org/x/net/ipv4/payload_nocmsg.go b/vendor/golang.org/x/net/ipv4/payload_nocmsg.go deleted file mode 100644 index 6f9d5b0ef..000000000 --- a/vendor/golang.org/x/net/ipv4/payload_nocmsg.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build plan9 windows - -package ipv4 - -import ( - "net" - "syscall" -) - -// ReadFrom reads a payload of the received IPv4 datagram, from the -// endpoint c, copying the payload into b. It returns the number of -// bytes copied into b, the control message cm and the source address -// src of the received datagram. -func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) { - if !c.ok() { - return 0, nil, nil, syscall.EINVAL - } - if n, src, err = c.PacketConn.ReadFrom(b); err != nil { - return 0, nil, nil, err - } - return -} - -// WriteTo writes a payload of the IPv4 datagram, to the destination -// address dst through the endpoint c, copying the payload from b. It -// returns the number of bytes written. The control message cm allows -// the datagram path and the outgoing interface to be specified. -// Currently only Darwin and Linux support this. The cm may be nil if -// control of the outgoing datagram is not required. -func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) { - if !c.ok() { - return 0, syscall.EINVAL - } - if dst == nil { - return 0, errMissingAddress - } - return c.PacketConn.WriteTo(b, dst) -} diff --git a/vendor/golang.org/x/net/ipv4/readwrite_test.go b/vendor/golang.org/x/net/ipv4/readwrite_test.go deleted file mode 100644 index a2384b8f9..000000000 --- a/vendor/golang.org/x/net/ipv4/readwrite_test.go +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "bytes" - "net" - "runtime" - "strings" - "sync" - "testing" - - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv4" -) - -func benchmarkUDPListener() (net.PacketConn, net.Addr, error) { - c, err := net.ListenPacket("udp4", "127.0.0.1:0") - if err != nil { - return nil, nil, err - } - dst, err := net.ResolveUDPAddr("udp4", c.LocalAddr().String()) - if err != nil { - c.Close() - return nil, nil, err - } - return c, dst, nil -} - -func BenchmarkReadWriteNetUDP(b *testing.B) { - c, dst, err := benchmarkUDPListener() - if err != nil { - b.Fatal(err) - } - defer c.Close() - - wb, rb := []byte("HELLO-R-U-THERE"), make([]byte, 128) - b.ResetTimer() - for i := 0; i < b.N; i++ { - benchmarkReadWriteNetUDP(b, c, wb, rb, dst) - } -} - -func benchmarkReadWriteNetUDP(b *testing.B, c net.PacketConn, wb, rb []byte, dst net.Addr) { - if _, err := c.WriteTo(wb, dst); err != nil { - b.Fatal(err) - } - if _, _, err := c.ReadFrom(rb); err != nil { - b.Fatal(err) - } -} - -func BenchmarkReadWriteIPv4UDP(b *testing.B) { - c, dst, err := benchmarkUDPListener() - if err != nil { - b.Fatal(err) - } - defer c.Close() - - p := ipv4.NewPacketConn(c) - defer p.Close() - cf := ipv4.FlagTTL | ipv4.FlagInterface - if err := p.SetControlMessage(cf, true); err != nil { - b.Fatal(err) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback) - - wb, rb := []byte("HELLO-R-U-THERE"), make([]byte, 128) - b.ResetTimer() - for i := 0; i < b.N; i++ { - benchmarkReadWriteIPv4UDP(b, p, wb, rb, dst, ifi) - } -} - -func benchmarkReadWriteIPv4UDP(b *testing.B, p *ipv4.PacketConn, wb, rb []byte, dst net.Addr, ifi *net.Interface) { - cm := ipv4.ControlMessage{TTL: 1} - if ifi != nil { - cm.IfIndex = ifi.Index - } - if n, err := p.WriteTo(wb, &cm, dst); err != nil { - b.Fatal(err) - } else if n != len(wb) { - b.Fatalf("got %v; want %v", n, len(wb)) - } - if _, _, _, err := p.ReadFrom(rb); err != nil { - b.Fatal(err) - } -} - -func TestPacketConnConcurrentReadWriteUnicastUDP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - - c, err := net.ListenPacket("udp4", "127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv4.NewPacketConn(c) - defer p.Close() - - dst, err := net.ResolveUDPAddr("udp4", c.LocalAddr().String()) - if err != nil { - t.Fatal(err) - } - - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback) - cf := ipv4.FlagTTL | ipv4.FlagSrc | ipv4.FlagDst | ipv4.FlagInterface - wb := []byte("HELLO-R-U-THERE") - - if err := p.SetControlMessage(cf, true); err != nil { // probe before test - if nettest.ProtocolNotSupported(err) { - t.Skipf("not supported on %s", runtime.GOOS) - } - t.Fatal(err) - } - - var wg sync.WaitGroup - reader := func() { - defer wg.Done() - rb := make([]byte, 128) - if n, cm, _, err := p.ReadFrom(rb); err != nil { - t.Error(err) - return - } else if !bytes.Equal(rb[:n], wb) { - t.Errorf("got %v; want %v", rb[:n], wb) - return - } else { - s := cm.String() - if strings.Contains(s, ",") { - t.Errorf("should be space-separated values: %s", s) - } - } - } - writer := func(toggle bool) { - defer wg.Done() - cm := ipv4.ControlMessage{ - Src: net.IPv4(127, 0, 0, 1), - } - if ifi != nil { - cm.IfIndex = ifi.Index - } - if err := p.SetControlMessage(cf, toggle); err != nil { - t.Error(err) - return - } - if n, err := p.WriteTo(wb, &cm, dst); err != nil { - t.Error(err) - return - } else if n != len(wb) { - t.Errorf("short write: %v", n) - return - } - } - - const N = 10 - wg.Add(N) - for i := 0; i < N; i++ { - go reader() - } - wg.Add(2 * N) - for i := 0; i < 2*N; i++ { - go writer(i%2 != 0) - } - wg.Add(N) - for i := 0; i < N; i++ { - go reader() - } - wg.Wait() -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt.go b/vendor/golang.org/x/net/ipv4/sockopt.go deleted file mode 100644 index ace37d30f..000000000 --- a/vendor/golang.org/x/net/ipv4/sockopt.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -// Sticky socket options -const ( - ssoTOS = iota // header field for unicast packet - ssoTTL // header field for unicast packet - ssoMulticastTTL // header field for multicast packet - ssoMulticastInterface // outbound interface for multicast packet - ssoMulticastLoopback // loopback for multicast packet - ssoReceiveTTL // header field on received packet - ssoReceiveDst // header field on received packet - ssoReceiveInterface // inbound interface on received packet - ssoPacketInfo // incbound or outbound packet path - ssoHeaderPrepend // ipv4 header prepend - ssoStripHeader // strip ipv4 header - ssoICMPFilter // icmp filter - ssoJoinGroup // any-source multicast - ssoLeaveGroup // any-source multicast - ssoJoinSourceGroup // source-specific multicast - ssoLeaveSourceGroup // source-specific multicast - ssoBlockSourceGroup // any-source or source-specific multicast - ssoUnblockSourceGroup // any-source or source-specific multicast - ssoMax -) - -// Sticky socket option value types -const ( - ssoTypeByte = iota + 1 - ssoTypeInt - ssoTypeInterface - ssoTypeICMPFilter - ssoTypeIPMreq - ssoTypeIPMreqn - ssoTypeGroupReq - ssoTypeGroupSourceReq -) - -// A sockOpt represents a binding for sticky socket option. -type sockOpt struct { - name int // option name, must be equal or greater than 1 - typ int // option value type, must be equal or greater than 1 -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_asmreq.go b/vendor/golang.org/x/net/ipv4/sockopt_asmreq.go deleted file mode 100644 index 8092f1db0..000000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_asmreq.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd solaris windows - -package ipv4 - -import "net" - -func setIPMreqInterface(mreq *ipMreq, ifi *net.Interface) error { - if ifi == nil { - return nil - } - ifat, err := ifi.Addrs() - if err != nil { - return err - } - for _, ifa := range ifat { - switch ifa := ifa.(type) { - case *net.IPAddr: - if ip := ifa.IP.To4(); ip != nil { - copy(mreq.Interface[:], ip) - return nil - } - case *net.IPNet: - if ip := ifa.IP.To4(); ip != nil { - copy(mreq.Interface[:], ip) - return nil - } - } - } - return errNoSuchInterface -} - -func netIP4ToInterface(ip net.IP) (*net.Interface, error) { - ift, err := net.Interfaces() - if err != nil { - return nil, err - } - for _, ifi := range ift { - ifat, err := ifi.Addrs() - if err != nil { - return nil, err - } - for _, ifa := range ifat { - switch ifa := ifa.(type) { - case *net.IPAddr: - if ip.Equal(ifa.IP) { - return &ifi, nil - } - case *net.IPNet: - if ip.Equal(ifa.IP) { - return &ifi, nil - } - } - } - } - return nil, errNoSuchInterface -} - -func netInterfaceToIP4(ifi *net.Interface) (net.IP, error) { - if ifi == nil { - return net.IPv4zero.To4(), nil - } - ifat, err := ifi.Addrs() - if err != nil { - return nil, err - } - for _, ifa := range ifat { - switch ifa := ifa.(type) { - case *net.IPAddr: - if ip := ifa.IP.To4(); ip != nil { - return ip, nil - } - case *net.IPNet: - if ip := ifa.IP.To4(); ip != nil { - return ip, nil - } - } - } - return nil, errNoSuchInterface -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_asmreq_posix.go b/vendor/golang.org/x/net/ipv4/sockopt_asmreq_posix.go deleted file mode 100644 index 2259a3903..000000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_asmreq_posix.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd solaris windows - -package ipv4 - -import ( - "net" - "os" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func setsockoptIPMreq(s uintptr, name int, ifi *net.Interface, grp net.IP) error { - mreq := ipMreq{Multiaddr: [4]byte{grp[0], grp[1], grp[2], grp[3]}} - if err := setIPMreqInterface(&mreq, ifi); err != nil { - return err - } - return os.NewSyscallError("setsockopt", setsockopt(s, iana.ProtocolIP, name, unsafe.Pointer(&mreq), sizeofIPMreq)) -} - -func getsockoptInterface(s uintptr, name int) (*net.Interface, error) { - var b [4]byte - l := uint32(4) - if err := getsockopt(s, iana.ProtocolIP, name, unsafe.Pointer(&b[0]), &l); err != nil { - return nil, os.NewSyscallError("getsockopt", err) - } - ifi, err := netIP4ToInterface(net.IPv4(b[0], b[1], b[2], b[3])) - if err != nil { - return nil, err - } - return ifi, nil -} - -func setsockoptInterface(s uintptr, name int, ifi *net.Interface) error { - ip, err := netInterfaceToIP4(ifi) - if err != nil { - return err - } - var b [4]byte - copy(b[:], ip) - return os.NewSyscallError("setsockopt", setsockopt(s, iana.ProtocolIP, name, unsafe.Pointer(&b[0]), uint32(4))) -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_asmreq_stub.go b/vendor/golang.org/x/net/ipv4/sockopt_asmreq_stub.go deleted file mode 100644 index e655635ec..000000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_asmreq_stub.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!dragonfly,!freebsd,!netbsd,!openbsd,!solaris,!windows - -package ipv4 - -import "net" - -func setsockoptIPMreq(s uintptr, name int, ifi *net.Interface, grp net.IP) error { - return errOpNoSupport -} - -func getsockoptInterface(s uintptr, name int) (*net.Interface, error) { - return nil, errOpNoSupport -} - -func setsockoptInterface(s uintptr, name int, ifi *net.Interface) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_asmreqn_stub.go b/vendor/golang.org/x/net/ipv4/sockopt_asmreqn_stub.go deleted file mode 100644 index 0c7f0f816..000000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_asmreqn_stub.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!freebsd,!linux - -package ipv4 - -import "net" - -func getsockoptIPMreqn(s uintptr, name int) (*net.Interface, error) { - return nil, errOpNoSupport -} - -func setsockoptIPMreqn(s uintptr, name int, ifi *net.Interface, grp net.IP) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_asmreqn_unix.go b/vendor/golang.org/x/net/ipv4/sockopt_asmreqn_unix.go deleted file mode 100644 index 92daffb0d..000000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_asmreqn_unix.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin freebsd linux - -package ipv4 - -import ( - "net" - "os" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func getsockoptIPMreqn(s uintptr, name int) (*net.Interface, error) { - var mreqn ipMreqn - l := uint32(sizeofIPMreqn) - if err := getsockopt(s, iana.ProtocolIP, name, unsafe.Pointer(&mreqn), &l); err != nil { - return nil, os.NewSyscallError("getsockopt", err) - } - if mreqn.Ifindex == 0 { - return nil, nil - } - ifi, err := net.InterfaceByIndex(int(mreqn.Ifindex)) - if err != nil { - return nil, err - } - return ifi, nil -} - -func setsockoptIPMreqn(s uintptr, name int, ifi *net.Interface, grp net.IP) error { - var mreqn ipMreqn - if ifi != nil { - mreqn.Ifindex = int32(ifi.Index) - } - if grp != nil { - mreqn.Multiaddr = [4]byte{grp[0], grp[1], grp[2], grp[3]} - } - return os.NewSyscallError("setsockopt", setsockopt(s, iana.ProtocolIP, name, unsafe.Pointer(&mreqn), sizeofIPMreqn)) -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_posix.go b/vendor/golang.org/x/net/ipv4/sockopt_posix.go deleted file mode 100644 index d80680373..000000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_posix.go +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package ipv4 - -import ( - "net" - "os" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func getInt(s uintptr, opt *sockOpt) (int, error) { - if opt.name < 1 || (opt.typ != ssoTypeByte && opt.typ != ssoTypeInt) { - return 0, errOpNoSupport - } - var i int32 - var b byte - p := unsafe.Pointer(&i) - l := uint32(4) - if opt.typ == ssoTypeByte { - p = unsafe.Pointer(&b) - l = 1 - } - if err := getsockopt(s, iana.ProtocolIP, opt.name, p, &l); err != nil { - return 0, os.NewSyscallError("getsockopt", err) - } - if opt.typ == ssoTypeByte { - return int(b), nil - } - return int(i), nil -} - -func setInt(s uintptr, opt *sockOpt, v int) error { - if opt.name < 1 || (opt.typ != ssoTypeByte && opt.typ != ssoTypeInt) { - return errOpNoSupport - } - i := int32(v) - var b byte - p := unsafe.Pointer(&i) - l := uint32(4) - if opt.typ == ssoTypeByte { - b = byte(v) - p = unsafe.Pointer(&b) - l = 1 - } - return os.NewSyscallError("setsockopt", setsockopt(s, iana.ProtocolIP, opt.name, p, l)) -} - -func getInterface(s uintptr, opt *sockOpt) (*net.Interface, error) { - if opt.name < 1 { - return nil, errOpNoSupport - } - switch opt.typ { - case ssoTypeInterface: - return getsockoptInterface(s, opt.name) - case ssoTypeIPMreqn: - return getsockoptIPMreqn(s, opt.name) - default: - return nil, errOpNoSupport - } -} - -func setInterface(s uintptr, opt *sockOpt, ifi *net.Interface) error { - if opt.name < 1 { - return errOpNoSupport - } - switch opt.typ { - case ssoTypeInterface: - return setsockoptInterface(s, opt.name, ifi) - case ssoTypeIPMreqn: - return setsockoptIPMreqn(s, opt.name, ifi, nil) - default: - return errOpNoSupport - } -} - -func getICMPFilter(s uintptr, opt *sockOpt) (*ICMPFilter, error) { - if opt.name < 1 || opt.typ != ssoTypeICMPFilter { - return nil, errOpNoSupport - } - var f ICMPFilter - l := uint32(sizeofICMPFilter) - if err := getsockopt(s, iana.ProtocolReserved, opt.name, unsafe.Pointer(&f.icmpFilter), &l); err != nil { - return nil, os.NewSyscallError("getsockopt", err) - } - return &f, nil -} - -func setICMPFilter(s uintptr, opt *sockOpt, f *ICMPFilter) error { - if opt.name < 1 || opt.typ != ssoTypeICMPFilter { - return errOpNoSupport - } - return os.NewSyscallError("setsockopt", setsockopt(s, iana.ProtocolReserved, opt.name, unsafe.Pointer(&f.icmpFilter), sizeofICMPFilter)) -} - -func setGroup(s uintptr, opt *sockOpt, ifi *net.Interface, grp net.IP) error { - if opt.name < 1 { - return errOpNoSupport - } - switch opt.typ { - case ssoTypeIPMreq: - return setsockoptIPMreq(s, opt.name, ifi, grp) - case ssoTypeIPMreqn: - return setsockoptIPMreqn(s, opt.name, ifi, grp) - case ssoTypeGroupReq: - return setsockoptGroupReq(s, opt.name, ifi, grp) - default: - return errOpNoSupport - } -} - -func setSourceGroup(s uintptr, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error { - if opt.name < 1 || opt.typ != ssoTypeGroupSourceReq { - return errOpNoSupport - } - return setsockoptGroupSourceReq(s, opt.name, ifi, grp, src) -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_ssmreq_stub.go b/vendor/golang.org/x/net/ipv4/sockopt_ssmreq_stub.go deleted file mode 100644 index 02873962e..000000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_ssmreq_stub.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!freebsd,!linux,!solaris - -package ipv4 - -import "net" - -func setsockoptGroupReq(s uintptr, name int, ifi *net.Interface, grp net.IP) error { - return errOpNoSupport -} - -func setsockoptGroupSourceReq(s uintptr, name int, ifi *net.Interface, grp, src net.IP) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_ssmreq_unix.go b/vendor/golang.org/x/net/ipv4/sockopt_ssmreq_unix.go deleted file mode 100644 index c9af55b91..000000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_ssmreq_unix.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin freebsd linux solaris - -package ipv4 - -import ( - "net" - "os" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -var freebsd32o64 bool - -func setsockoptGroupReq(s uintptr, name int, ifi *net.Interface, grp net.IP) error { - var gr groupReq - if ifi != nil { - gr.Interface = uint32(ifi.Index) - } - gr.setGroup(grp) - var p unsafe.Pointer - var l uint32 - if freebsd32o64 { - var d [sizeofGroupReq + 4]byte - s := (*[sizeofGroupReq]byte)(unsafe.Pointer(&gr)) - copy(d[:4], s[:4]) - copy(d[8:], s[4:]) - p = unsafe.Pointer(&d[0]) - l = sizeofGroupReq + 4 - } else { - p = unsafe.Pointer(&gr) - l = sizeofGroupReq - } - return os.NewSyscallError("setsockopt", setsockopt(s, iana.ProtocolIP, name, p, l)) -} - -func setsockoptGroupSourceReq(s uintptr, name int, ifi *net.Interface, grp, src net.IP) error { - var gsr groupSourceReq - if ifi != nil { - gsr.Interface = uint32(ifi.Index) - } - gsr.setSourceGroup(grp, src) - var p unsafe.Pointer - var l uint32 - if freebsd32o64 { - var d [sizeofGroupSourceReq + 4]byte - s := (*[sizeofGroupSourceReq]byte)(unsafe.Pointer(&gsr)) - copy(d[:4], s[:4]) - copy(d[8:], s[4:]) - p = unsafe.Pointer(&d[0]) - l = sizeofGroupSourceReq + 4 - } else { - p = unsafe.Pointer(&gsr) - l = sizeofGroupSourceReq - } - return os.NewSyscallError("setsockopt", setsockopt(s, iana.ProtocolIP, name, p, l)) -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_stub.go b/vendor/golang.org/x/net/ipv4/sockopt_stub.go deleted file mode 100644 index 4ff609917..000000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_stub.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package ipv4 - -func setInt(s uintptr, opt *sockOpt, v int) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/sys_bsd.go b/vendor/golang.org/x/net/ipv4/sys_bsd.go deleted file mode 100644 index 203033db0..000000000 --- a/vendor/golang.org/x/net/ipv4/sys_bsd.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build dragonfly netbsd - -package ipv4 - -import ( - "net" - "syscall" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTOS: {sysIP_TOS, ssoTypeInt}, - ssoTTL: {sysIP_TTL, ssoTypeInt}, - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeByte}, - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt}, - ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt}, - ssoReceiveDst: {sysIP_RECVDSTADDR, ssoTypeInt}, - ssoReceiveInterface: {sysIP_RECVIF, ssoTypeInt}, - ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt}, - ssoJoinGroup: {sysIP_ADD_MEMBERSHIP, ssoTypeIPMreq}, - ssoLeaveGroup: {sysIP_DROP_MEMBERSHIP, ssoTypeIPMreq}, - } -) diff --git a/vendor/golang.org/x/net/ipv4/sys_darwin.go b/vendor/golang.org/x/net/ipv4/sys_darwin.go deleted file mode 100644 index abfffca87..000000000 --- a/vendor/golang.org/x/net/ipv4/sys_darwin.go +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "strconv" - "strings" - "syscall" - "unsafe" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTOS: {sysIP_TOS, ssoTypeInt}, - ssoTTL: {sysIP_TTL, ssoTypeInt}, - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeByte}, - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt}, - ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt}, - ssoReceiveDst: {sysIP_RECVDSTADDR, ssoTypeInt}, - ssoReceiveInterface: {sysIP_RECVIF, ssoTypeInt}, - ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt}, - ssoStripHeader: {sysIP_STRIPHDR, ssoTypeInt}, - ssoJoinGroup: {sysIP_ADD_MEMBERSHIP, ssoTypeIPMreq}, - ssoLeaveGroup: {sysIP_DROP_MEMBERSHIP, ssoTypeIPMreq}, - } -) - -func init() { - // Seems like kern.osreldate is veiled on latest OS X. We use - // kern.osrelease instead. - s, err := syscall.Sysctl("kern.osrelease") - if err != nil { - return - } - ss := strings.Split(s, ".") - if len(ss) == 0 { - return - } - // The IP_PKTINFO and protocol-independent multicast API were - // introduced in OS X 10.7 (Darwin 11). But it looks like - // those features require OS X 10.8 (Darwin 12) or above. - // See http://support.apple.com/kb/HT1633. - if mjver, err := strconv.Atoi(ss[0]); err != nil || mjver < 12 { - return - } - ctlOpts[ctlPacketInfo].name = sysIP_PKTINFO - ctlOpts[ctlPacketInfo].length = sizeofInetPktinfo - ctlOpts[ctlPacketInfo].marshal = marshalPacketInfo - ctlOpts[ctlPacketInfo].parse = parsePacketInfo - sockOpts[ssoPacketInfo].name = sysIP_RECVPKTINFO - sockOpts[ssoPacketInfo].typ = ssoTypeInt - sockOpts[ssoMulticastInterface].typ = ssoTypeIPMreqn - sockOpts[ssoJoinGroup].name = sysMCAST_JOIN_GROUP - sockOpts[ssoJoinGroup].typ = ssoTypeGroupReq - sockOpts[ssoLeaveGroup].name = sysMCAST_LEAVE_GROUP - sockOpts[ssoLeaveGroup].typ = ssoTypeGroupReq - sockOpts[ssoJoinSourceGroup].name = sysMCAST_JOIN_SOURCE_GROUP - sockOpts[ssoJoinSourceGroup].typ = ssoTypeGroupSourceReq - sockOpts[ssoLeaveSourceGroup].name = sysMCAST_LEAVE_SOURCE_GROUP - sockOpts[ssoLeaveSourceGroup].typ = ssoTypeGroupSourceReq - sockOpts[ssoBlockSourceGroup].name = sysMCAST_BLOCK_SOURCE - sockOpts[ssoBlockSourceGroup].typ = ssoTypeGroupSourceReq - sockOpts[ssoUnblockSourceGroup].name = sysMCAST_UNBLOCK_SOURCE - sockOpts[ssoUnblockSourceGroup].typ = ssoTypeGroupSourceReq -} - -func (pi *inetPktinfo) setIfindex(i int) { - pi.Ifindex = uint32(i) -} - -func (gr *groupReq) setGroup(grp net.IP) { - sa := (*sockaddrInet)(unsafe.Pointer(uintptr(unsafe.Pointer(gr)) + 4)) - sa.Len = sizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) -} - -func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sockaddrInet)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 4)) - sa.Len = sizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) - sa = (*sockaddrInet)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 132)) - sa.Len = sizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv4/sys_freebsd.go b/vendor/golang.org/x/net/ipv4/sys_freebsd.go deleted file mode 100644 index fceffe98e..000000000 --- a/vendor/golang.org/x/net/ipv4/sys_freebsd.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "runtime" - "strings" - "syscall" - "unsafe" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTOS: {sysIP_TOS, ssoTypeInt}, - ssoTTL: {sysIP_TTL, ssoTypeInt}, - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeByte}, - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt}, - ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt}, - ssoReceiveDst: {sysIP_RECVDSTADDR, ssoTypeInt}, - ssoReceiveInterface: {sysIP_RECVIF, ssoTypeInt}, - ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt}, - ssoJoinGroup: {sysMCAST_JOIN_GROUP, ssoTypeGroupReq}, - ssoLeaveGroup: {sysMCAST_LEAVE_GROUP, ssoTypeGroupReq}, - ssoJoinSourceGroup: {sysMCAST_JOIN_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {sysMCAST_LEAVE_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {sysMCAST_BLOCK_SOURCE, ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {sysMCAST_UNBLOCK_SOURCE, ssoTypeGroupSourceReq}, - } -) - -func init() { - freebsdVersion, _ = syscall.SysctlUint32("kern.osreldate") - if freebsdVersion >= 1000000 { - sockOpts[ssoMulticastInterface].typ = ssoTypeIPMreqn - } - if runtime.GOOS == "freebsd" && runtime.GOARCH == "386" { - archs, _ := syscall.Sysctl("kern.supported_archs") - for _, s := range strings.Fields(archs) { - if s == "amd64" { - freebsd32o64 = true - break - } - } - } -} - -func (gr *groupReq) setGroup(grp net.IP) { - sa := (*sockaddrInet)(unsafe.Pointer(&gr.Group)) - sa.Len = sizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) -} - -func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sockaddrInet)(unsafe.Pointer(&gsr.Group)) - sa.Len = sizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) - sa = (*sockaddrInet)(unsafe.Pointer(&gsr.Source)) - sa.Len = sizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv4/sys_linux.go b/vendor/golang.org/x/net/ipv4/sys_linux.go deleted file mode 100644 index c6c2a5067..000000000 --- a/vendor/golang.org/x/net/ipv4/sys_linux.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "syscall" - "unsafe" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_TTL, 1, marshalTTL, parseTTL}, - ctlPacketInfo: {sysIP_PKTINFO, sizeofInetPktinfo, marshalPacketInfo, parsePacketInfo}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTOS: {sysIP_TOS, ssoTypeInt}, - ssoTTL: {sysIP_TTL, ssoTypeInt}, - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeInt}, - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeIPMreqn}, - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt}, - ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt}, - ssoPacketInfo: {sysIP_PKTINFO, ssoTypeInt}, - ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt}, - ssoICMPFilter: {sysICMP_FILTER, ssoTypeICMPFilter}, - ssoJoinGroup: {sysMCAST_JOIN_GROUP, ssoTypeGroupReq}, - ssoLeaveGroup: {sysMCAST_LEAVE_GROUP, ssoTypeGroupReq}, - ssoJoinSourceGroup: {sysMCAST_JOIN_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {sysMCAST_LEAVE_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {sysMCAST_BLOCK_SOURCE, ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {sysMCAST_UNBLOCK_SOURCE, ssoTypeGroupSourceReq}, - } -) - -func (pi *inetPktinfo) setIfindex(i int) { - pi.Ifindex = int32(i) -} - -func (gr *groupReq) setGroup(grp net.IP) { - sa := (*sockaddrInet)(unsafe.Pointer(&gr.Group)) - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) -} - -func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sockaddrInet)(unsafe.Pointer(&gsr.Group)) - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) - sa = (*sockaddrInet)(unsafe.Pointer(&gsr.Source)) - sa.Family = syscall.AF_INET - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv4/sys_linux_386.s b/vendor/golang.org/x/net/ipv4/sys_linux_386.s deleted file mode 100644 index b85551a5c..000000000 --- a/vendor/golang.org/x/net/ipv4/sys_linux_386.s +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#include "textflag.h" - -TEXT ·socketcall(SB),NOSPLIT,$0-36 - JMP syscall·socketcall(SB) diff --git a/vendor/golang.org/x/net/ipv4/sys_openbsd.go b/vendor/golang.org/x/net/ipv4/sys_openbsd.go deleted file mode 100644 index d78083a28..000000000 --- a/vendor/golang.org/x/net/ipv4/sys_openbsd.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "syscall" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTOS: {sysIP_TOS, ssoTypeInt}, - ssoTTL: {sysIP_TTL, ssoTypeInt}, - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeByte}, - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeByte}, - ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt}, - ssoReceiveDst: {sysIP_RECVDSTADDR, ssoTypeInt}, - ssoReceiveInterface: {sysIP_RECVIF, ssoTypeInt}, - ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt}, - ssoJoinGroup: {sysIP_ADD_MEMBERSHIP, ssoTypeIPMreq}, - ssoLeaveGroup: {sysIP_DROP_MEMBERSHIP, ssoTypeIPMreq}, - } -) diff --git a/vendor/golang.org/x/net/ipv4/sys_solaris.go b/vendor/golang.org/x/net/ipv4/sys_solaris.go deleted file mode 100644 index 879f39e0a..000000000 --- a/vendor/golang.org/x/net/ipv4/sys_solaris.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "syscall" - "unsafe" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 4, marshalTTL, parseTTL}, - ctlPacketInfo: {sysIP_PKTINFO, sizeofInetPktinfo, marshalPacketInfo, parsePacketInfo}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTOS: {sysIP_TOS, ssoTypeInt}, - ssoTTL: {sysIP_TTL, ssoTypeInt}, - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeByte}, - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeByte}, - ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt}, - ssoPacketInfo: {sysIP_RECVPKTINFO, ssoTypeInt}, - ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt}, - ssoJoinGroup: {sysMCAST_JOIN_GROUP, ssoTypeGroupReq}, - ssoLeaveGroup: {sysMCAST_LEAVE_GROUP, ssoTypeGroupReq}, - ssoJoinSourceGroup: {sysMCAST_JOIN_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {sysMCAST_LEAVE_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {sysMCAST_BLOCK_SOURCE, ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {sysMCAST_UNBLOCK_SOURCE, ssoTypeGroupSourceReq}, - } -) - -func (pi *inetPktinfo) setIfindex(i int) { - pi.Ifindex = uint32(i) -} - -func (gr *groupReq) setGroup(grp net.IP) { - sa := (*sockaddrInet)(unsafe.Pointer(uintptr(unsafe.Pointer(gr)) + 4)) - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) -} - -func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sockaddrInet)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 4)) - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) - sa = (*sockaddrInet)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 260)) - sa.Family = syscall.AF_INET - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv4/sys_solaris_amd64.s b/vendor/golang.org/x/net/ipv4/sys_solaris_amd64.s deleted file mode 100644 index 39d76af79..000000000 --- a/vendor/golang.org/x/net/ipv4/sys_solaris_amd64.s +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#include "textflag.h" - -TEXT ·sysvicall6(SB),NOSPLIT,$0-88 - JMP syscall·sysvicall6(SB) diff --git a/vendor/golang.org/x/net/ipv4/sys_stub.go b/vendor/golang.org/x/net/ipv4/sys_stub.go deleted file mode 100644 index d6dd812fd..000000000 --- a/vendor/golang.org/x/net/ipv4/sys_stub.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package ipv4 - -var ( - ctlOpts = [ctlMax]ctlOpt{} - - sockOpts = [ssoMax]sockOpt{} -) diff --git a/vendor/golang.org/x/net/ipv4/sys_windows.go b/vendor/golang.org/x/net/ipv4/sys_windows.go deleted file mode 100644 index fac00bda8..000000000 --- a/vendor/golang.org/x/net/ipv4/sys_windows.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -const ( - // See ws2tcpip.h. - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_DONTFRAGMENT = 0xe - sysIP_ADD_SOURCE_MEMBERSHIP = 0xf - sysIP_DROP_SOURCE_MEMBERSHIP = 0x10 - sysIP_PKTINFO = 0x13 - - sizeofInetPktinfo = 0x8 - sizeofIPMreq = 0x8 - sizeofIPMreqSource = 0xc -) - -type inetPktinfo struct { - Addr [4]byte - Ifindex int32 -} - -type ipMreq struct { - Multiaddr [4]byte - Interface [4]byte -} - -type ipMreqSource struct { - Multiaddr [4]byte - Sourceaddr [4]byte - Interface [4]byte -} - -// See http://msdn.microsoft.com/en-us/library/windows/desktop/ms738586(v=vs.85).aspx -var ( - ctlOpts = [ctlMax]ctlOpt{} - - sockOpts = [ssoMax]sockOpt{ - ssoTOS: {sysIP_TOS, ssoTypeInt}, - ssoTTL: {sysIP_TTL, ssoTypeInt}, - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeInt}, - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt}, - ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt}, - ssoJoinGroup: {sysIP_ADD_MEMBERSHIP, ssoTypeIPMreq}, - ssoLeaveGroup: {sysIP_DROP_MEMBERSHIP, ssoTypeIPMreq}, - } -) - -func (pi *inetPktinfo) setIfindex(i int) { - pi.Ifindex = int32(i) -} diff --git a/vendor/golang.org/x/net/ipv4/syscall_linux_386.go b/vendor/golang.org/x/net/ipv4/syscall_linux_386.go deleted file mode 100644 index 84f60bfb2..000000000 --- a/vendor/golang.org/x/net/ipv4/syscall_linux_386.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "syscall" - "unsafe" -) - -const ( - sysGETSOCKOPT = 0xf - sysSETSOCKOPT = 0xe -) - -func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) - -func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error { - if _, errno := socketcall(sysGETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 { - return error(errno) - } - return nil -} - -func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error { - if _, errno := socketcall(sysSETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 { - return error(errno) - } - return nil -} diff --git a/vendor/golang.org/x/net/ipv4/syscall_solaris.go b/vendor/golang.org/x/net/ipv4/syscall_solaris.go deleted file mode 100644 index 8b0e1e447..000000000 --- a/vendor/golang.org/x/net/ipv4/syscall_solaris.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "syscall" - "unsafe" -) - -//go:cgo_import_dynamic libc___xnet_getsockopt __xnet_getsockopt "libsocket.so" -//go:cgo_import_dynamic libc_setsockopt setsockopt "libsocket.so" - -//go:linkname procGetsockopt libc___xnet_getsockopt -//go:linkname procSetsockopt libc_setsockopt - -var ( - procGetsockopt uintptr - procSetsockopt uintptr -) - -func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (uintptr, uintptr, syscall.Errno) - -func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error { - _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procGetsockopt)), 5, s, uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0) - if errno != 0 { - return error(errno) - } - return nil -} - -func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error { - if _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procSetsockopt)), 5, s, uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 { - return error(errno) - } - return nil -} diff --git a/vendor/golang.org/x/net/ipv4/syscall_unix.go b/vendor/golang.org/x/net/ipv4/syscall_unix.go deleted file mode 100644 index d952763f5..000000000 --- a/vendor/golang.org/x/net/ipv4/syscall_unix.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux,!386 netbsd openbsd - -package ipv4 - -import ( - "syscall" - "unsafe" -) - -func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error { - if _, _, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 { - return error(errno) - } - return nil -} - -func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error { - if _, _, errno := syscall.Syscall6(syscall.SYS_SETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 { - return error(errno) - } - return nil -} diff --git a/vendor/golang.org/x/net/ipv4/syscall_windows.go b/vendor/golang.org/x/net/ipv4/syscall_windows.go deleted file mode 100644 index 0f42d22eb..000000000 --- a/vendor/golang.org/x/net/ipv4/syscall_windows.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "syscall" - "unsafe" -) - -func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error { - return syscall.Getsockopt(syscall.Handle(s), int32(level), int32(name), (*byte)(v), (*int32)(unsafe.Pointer(l))) -} - -func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error { - return syscall.Setsockopt(syscall.Handle(s), int32(level), int32(name), (*byte)(v), int32(l)) -} diff --git a/vendor/golang.org/x/net/ipv4/unicast_test.go b/vendor/golang.org/x/net/ipv4/unicast_test.go deleted file mode 100644 index bce8763f7..000000000 --- a/vendor/golang.org/x/net/ipv4/unicast_test.go +++ /dev/null @@ -1,250 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "bytes" - "net" - "os" - "runtime" - "testing" - "time" - - "golang.org/x/net/icmp" - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv4" -) - -func TestPacketConnReadWriteUnicastUDP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - c, err := net.ListenPacket("udp4", "127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - dst, err := net.ResolveUDPAddr("udp4", c.LocalAddr().String()) - if err != nil { - t.Fatal(err) - } - p := ipv4.NewPacketConn(c) - defer p.Close() - cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface - wb := []byte("HELLO-R-U-THERE") - - for i, toggle := range []bool{true, false, true} { - if err := p.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - p.SetTTL(i + 1) - if err := p.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if n, err := p.WriteTo(wb, nil, dst); err != nil { - t.Fatal(err) - } else if n != len(wb) { - t.Fatalf("got %v; want %v", n, len(wb)) - } - rb := make([]byte, 128) - if err := p.SetReadDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if n, _, _, err := p.ReadFrom(rb); err != nil { - t.Fatal(err) - } else if !bytes.Equal(rb[:n], wb) { - t.Fatalf("got %v; want %v", rb[:n], wb) - } - } -} - -func TestPacketConnReadWriteUnicastICMP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - dst, err := net.ResolveIPAddr("ip4", "127.0.0.1") - if err != nil { - t.Fatal(err) - } - p := ipv4.NewPacketConn(c) - defer p.Close() - cf := ipv4.FlagDst | ipv4.FlagInterface - if runtime.GOOS != "solaris" { - // Solaris never allows to modify ICMP properties. - cf |= ipv4.FlagTTL - } - - for i, toggle := range []bool{true, false, true} { - wb, err := (&icmp.Message{ - Type: ipv4.ICMPTypeEcho, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, Seq: i + 1, - Data: []byte("HELLO-R-U-THERE"), - }, - }).Marshal(nil) - if err != nil { - t.Fatal(err) - } - if err := p.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - p.SetTTL(i + 1) - if err := p.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if n, err := p.WriteTo(wb, nil, dst); err != nil { - t.Fatal(err) - } else if n != len(wb) { - t.Fatalf("got %v; want %v", n, len(wb)) - } - rb := make([]byte, 128) - loop: - if err := p.SetReadDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if n, _, _, err := p.ReadFrom(rb); err != nil { - switch runtime.GOOS { - case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } else { - m, err := icmp.ParseMessage(iana.ProtocolICMP, rb[:n]) - if err != nil { - t.Fatal(err) - } - if runtime.GOOS == "linux" && m.Type == ipv4.ICMPTypeEcho { - // On Linux we must handle own sent packets. - goto loop - } - if m.Type != ipv4.ICMPTypeEchoReply || m.Code != 0 { - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv4.ICMPTypeEchoReply, 0) - } - } - } -} - -func TestRawConnReadWriteUnicastICMP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - dst, err := net.ResolveIPAddr("ip4", "127.0.0.1") - if err != nil { - t.Fatal(err) - } - r, err := ipv4.NewRawConn(c) - if err != nil { - t.Fatal(err) - } - defer r.Close() - cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface - - for i, toggle := range []bool{true, false, true} { - wb, err := (&icmp.Message{ - Type: ipv4.ICMPTypeEcho, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, Seq: i + 1, - Data: []byte("HELLO-R-U-THERE"), - }, - }).Marshal(nil) - if err != nil { - t.Fatal(err) - } - wh := &ipv4.Header{ - Version: ipv4.Version, - Len: ipv4.HeaderLen, - TOS: i + 1, - TotalLen: ipv4.HeaderLen + len(wb), - TTL: i + 1, - Protocol: 1, - Dst: dst.IP, - } - if err := r.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - if err := r.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if err := r.WriteTo(wh, wb, nil); err != nil { - t.Fatal(err) - } - rb := make([]byte, ipv4.HeaderLen+128) - loop: - if err := r.SetReadDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if _, b, _, err := r.ReadFrom(rb); err != nil { - switch runtime.GOOS { - case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } else { - m, err := icmp.ParseMessage(iana.ProtocolICMP, b) - if err != nil { - t.Fatal(err) - } - if runtime.GOOS == "linux" && m.Type == ipv4.ICMPTypeEcho { - // On Linux we must handle own sent packets. - goto loop - } - if m.Type != ipv4.ICMPTypeEchoReply || m.Code != 0 { - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv4.ICMPTypeEchoReply, 0) - } - } - } -} diff --git a/vendor/golang.org/x/net/ipv4/unicastsockopt_test.go b/vendor/golang.org/x/net/ipv4/unicastsockopt_test.go deleted file mode 100644 index db5213b91..000000000 --- a/vendor/golang.org/x/net/ipv4/unicastsockopt_test.go +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "net" - "runtime" - "testing" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv4" -) - -func TestConnUnicastSocketOptions(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - ln, err := net.Listen("tcp4", "127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - defer ln.Close() - - errc := make(chan error, 1) - go func() { - c, err := ln.Accept() - if err != nil { - errc <- err - return - } - errc <- c.Close() - }() - - c, err := net.Dial("tcp4", ln.Addr().String()) - if err != nil { - t.Fatal(err) - } - defer c.Close() - - testUnicastSocketOptions(t, ipv4.NewConn(c)) - - if err := <-errc; err != nil { - t.Errorf("server: %v", err) - } -} - -var packetConnUnicastSocketOptionTests = []struct { - net, proto, addr string -}{ - {"udp4", "", "127.0.0.1:0"}, - {"ip4", ":icmp", "127.0.0.1"}, -} - -func TestPacketConnUnicastSocketOptions(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - m, ok := nettest.SupportsRawIPSocket() - for _, tt := range packetConnUnicastSocketOptionTests { - if tt.net == "ip4" && !ok { - t.Log(m) - continue - } - c, err := net.ListenPacket(tt.net+tt.proto, tt.addr) - if err != nil { - t.Fatal(err) - } - defer c.Close() - - testUnicastSocketOptions(t, ipv4.NewPacketConn(c)) - } -} - -func TestRawConnUnicastSocketOptions(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - c, err := net.ListenPacket("ip4:icmp", "127.0.0.1") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - r, err := ipv4.NewRawConn(c) - if err != nil { - t.Fatal(err) - } - - testUnicastSocketOptions(t, r) -} - -type testIPv4UnicastConn interface { - TOS() (int, error) - SetTOS(int) error - TTL() (int, error) - SetTTL(int) error -} - -func testUnicastSocketOptions(t *testing.T, c testIPv4UnicastConn) { - tos := iana.DiffServCS0 | iana.NotECNTransport - switch runtime.GOOS { - case "windows": - // IP_TOS option is supported on Windows 8 and beyond. - t.Skipf("not supported on %s", runtime.GOOS) - } - - if err := c.SetTOS(tos); err != nil { - t.Fatal(err) - } - if v, err := c.TOS(); err != nil { - t.Fatal(err) - } else if v != tos { - t.Fatalf("got %v; want %v", v, tos) - } - const ttl = 255 - if err := c.SetTTL(ttl); err != nil { - t.Fatal(err) - } - if v, err := c.TTL(); err != nil { - t.Fatal(err) - } else if v != ttl { - t.Fatalf("got %v; want %v", v, ttl) - } -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_darwin.go b/vendor/golang.org/x/net/ipv4/zsys_darwin.go deleted file mode 100644 index c07cc883f..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_darwin.go +++ /dev/null @@ -1,99 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_darwin.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x14 - sysIP_STRIPHDR = 0x17 - sysIP_RECVTTL = 0x18 - sysIP_BOUND_IF = 0x19 - sysIP_PKTINFO = 0x1a - sysIP_RECVPKTINFO = 0x1a - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_MULTICAST_VIF = 0xe - sysIP_MULTICAST_IFINDEX = 0x42 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 - sysIP_BLOCK_SOURCE = 0x48 - sysIP_UNBLOCK_SOURCE = 0x49 - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 -) - -type sockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type inetPktinfo struct { - Ifindex uint32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr [4]byte /* in_addr */ - Sourceaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [128]byte -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [128]byte - Pad_cgo_1 [128]byte -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go b/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go deleted file mode 100644 index c4365e9e7..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go +++ /dev/null @@ -1,31 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_dragonfly.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x14 - sysIP_RECVTTL = 0x41 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_MULTICAST_VIF = 0xe - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - - sizeofIPMreq = 0x8 -) - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go b/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go deleted file mode 100644 index 8c4aec94c..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go +++ /dev/null @@ -1,93 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_SENDSRCADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x14 - sysIP_ONESBCAST = 0x17 - sysIP_BINDANY = 0x18 - sysIP_RECVTTL = 0x41 - sysIP_MINTTL = 0x42 - sysIP_DONTFRAG = 0x43 - sysIP_RECVTOS = 0x44 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_MULTICAST_VIF = 0xe - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 - sysIP_BLOCK_SOURCE = 0x48 - sysIP_UNBLOCK_SOURCE = 0x49 - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 -) - -type sockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr [4]byte /* in_addr */ - Sourceaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type groupReq struct { - Interface uint32 - Group sockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group sockaddrStorage - Source sockaddrStorage -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go b/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go deleted file mode 100644 index 4b10b7c57..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go +++ /dev/null @@ -1,95 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_SENDSRCADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x14 - sysIP_ONESBCAST = 0x17 - sysIP_BINDANY = 0x18 - sysIP_RECVTTL = 0x41 - sysIP_MINTTL = 0x42 - sysIP_DONTFRAG = 0x43 - sysIP_RECVTOS = 0x44 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_MULTICAST_VIF = 0xe - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 - sysIP_BLOCK_SOURCE = 0x48 - sysIP_UNBLOCK_SOURCE = 0x49 - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 -) - -type sockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr [4]byte /* in_addr */ - Sourceaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sockaddrStorage - Source sockaddrStorage -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go b/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go deleted file mode 100644 index 4b10b7c57..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go +++ /dev/null @@ -1,95 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_SENDSRCADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x14 - sysIP_ONESBCAST = 0x17 - sysIP_BINDANY = 0x18 - sysIP_RECVTTL = 0x41 - sysIP_MINTTL = 0x42 - sysIP_DONTFRAG = 0x43 - sysIP_RECVTOS = 0x44 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_MULTICAST_VIF = 0xe - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 - sysIP_BLOCK_SOURCE = 0x48 - sysIP_UNBLOCK_SOURCE = 0x49 - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 -) - -type sockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr [4]byte /* in_addr */ - Sourceaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sockaddrStorage - Source sockaddrStorage -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_386.go b/vendor/golang.org/x/net/ipv4/zsys_linux_386.go deleted file mode 100644 index 4da672013..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_386.go +++ /dev/null @@ -1,146 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 - - sizeofICMPFilter = 0x4 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go b/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go deleted file mode 100644 index 65945bbd0..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go +++ /dev/null @@ -1,148 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPFilter = 0x4 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go b/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go deleted file mode 100644 index 4da672013..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go +++ /dev/null @@ -1,146 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 - - sizeofICMPFilter = 0x4 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go b/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go deleted file mode 100644 index 65945bbd0..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go +++ /dev/null @@ -1,148 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPFilter = 0x4 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_mips.go b/vendor/golang.org/x/net/ipv4/zsys_linux_mips.go deleted file mode 100644 index 4da672013..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_mips.go +++ /dev/null @@ -1,146 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 - - sizeofICMPFilter = 0x4 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go b/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go deleted file mode 100644 index 65945bbd0..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go +++ /dev/null @@ -1,148 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPFilter = 0x4 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go b/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go deleted file mode 100644 index 65945bbd0..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go +++ /dev/null @@ -1,148 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPFilter = 0x4 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_mipsle.go b/vendor/golang.org/x/net/ipv4/zsys_linux_mipsle.go deleted file mode 100644 index 4da672013..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_mipsle.go +++ /dev/null @@ -1,146 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 - - sizeofICMPFilter = 0x4 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_ppc.go b/vendor/golang.org/x/net/ipv4/zsys_linux_ppc.go deleted file mode 100644 index b825a18e9..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_ppc.go +++ /dev/null @@ -1,146 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 - - sizeofICMPFilter = 0x4 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]uint8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go b/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go deleted file mode 100644 index 65945bbd0..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go +++ /dev/null @@ -1,148 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPFilter = 0x4 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go b/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go deleted file mode 100644 index 65945bbd0..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go +++ /dev/null @@ -1,148 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPFilter = 0x4 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go b/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go deleted file mode 100644 index 65945bbd0..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go +++ /dev/null @@ -1,148 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPFilter = 0x4 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_netbsd.go b/vendor/golang.org/x/net/ipv4/zsys_netbsd.go deleted file mode 100644 index fd3624d93..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_netbsd.go +++ /dev/null @@ -1,30 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_netbsd.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x14 - sysIP_RECVTTL = 0x17 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - - sizeofIPMreq = 0x8 -) - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_openbsd.go b/vendor/golang.org/x/net/ipv4/zsys_openbsd.go deleted file mode 100644 index 12f36be75..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_openbsd.go +++ /dev/null @@ -1,30 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_openbsd.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x1e - sysIP_RECVTTL = 0x1f - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - - sizeofIPMreq = 0x8 -) - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_solaris.go b/vendor/golang.org/x/net/ipv4/zsys_solaris.go deleted file mode 100644 index 0a3875cc4..000000000 --- a/vendor/golang.org/x/net/ipv4/zsys_solaris.go +++ /dev/null @@ -1,100 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_solaris.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x9 - sysIP_RECVSLLA = 0xa - sysIP_RECVTTL = 0xb - - sysIP_MULTICAST_IF = 0x10 - sysIP_MULTICAST_TTL = 0x11 - sysIP_MULTICAST_LOOP = 0x12 - sysIP_ADD_MEMBERSHIP = 0x13 - sysIP_DROP_MEMBERSHIP = 0x14 - sysIP_BLOCK_SOURCE = 0x15 - sysIP_UNBLOCK_SOURCE = 0x16 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x17 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x18 - sysIP_NEXTHOP = 0x19 - - sysIP_PKTINFO = 0x1a - sysIP_RECVPKTINFO = 0x1a - sysIP_DONTFRAG = 0x1b - - sysIP_BOUND_IF = 0x41 - sysIP_UNSPEC_SRC = 0x42 - sysIP_BROADCAST_TTL = 0x43 - sysIP_DHCPINIT_IF = 0x45 - - sysIP_REUSEADDR = 0x104 - sysIP_DONTROUTE = 0x105 - sysIP_BROADCAST = 0x106 - - sysMCAST_JOIN_GROUP = 0x29 - sysMCAST_LEAVE_GROUP = 0x2a - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_JOIN_SOURCE_GROUP = 0x2d - sysMCAST_LEAVE_SOURCE_GROUP = 0x2e - - sizeofSockaddrStorage = 0x100 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - - sizeofIPMreq = 0x8 - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x104 - sizeofGroupSourceReq = 0x204 -) - -type sockaddrStorage struct { - Family uint16 - X_ss_pad1 [6]int8 - X_ss_align float64 - X_ss_pad2 [240]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type inetPktinfo struct { - Ifindex uint32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqSource struct { - Multiaddr [4]byte /* in_addr */ - Sourceaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [256]byte -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [256]byte - Pad_cgo_1 [256]byte -} diff --git a/vendor/golang.org/x/net/ipv6/bpf_test.go b/vendor/golang.org/x/net/ipv6/bpf_test.go deleted file mode 100644 index 8253e1f42..000000000 --- a/vendor/golang.org/x/net/ipv6/bpf_test.go +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "net" - "runtime" - "testing" - "time" - - "golang.org/x/net/bpf" - "golang.org/x/net/ipv6" -) - -func TestBPF(t *testing.T) { - if runtime.GOOS != "linux" { - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - l, err := net.ListenPacket("udp6", "[::1]:0") - if err != nil { - t.Fatal(err) - } - defer l.Close() - - p := ipv6.NewPacketConn(l) - - // This filter accepts UDP packets whose first payload byte is - // even. - prog, err := bpf.Assemble([]bpf.Instruction{ - // Load the first byte of the payload (skipping UDP header). - bpf.LoadAbsolute{Off: 8, Size: 1}, - // Select LSB of the byte. - bpf.ALUOpConstant{Op: bpf.ALUOpAnd, Val: 1}, - // Byte is even? - bpf.JumpIf{Cond: bpf.JumpEqual, Val: 0, SkipFalse: 1}, - // Accept. - bpf.RetConstant{Val: 4096}, - // Ignore. - bpf.RetConstant{Val: 0}, - }) - if err != nil { - t.Fatalf("compiling BPF: %s", err) - } - - if err = p.SetBPF(prog); err != nil { - t.Fatalf("attaching filter to Conn: %s", err) - } - - s, err := net.Dial("udp6", l.LocalAddr().String()) - if err != nil { - t.Fatal(err) - } - defer s.Close() - go func() { - for i := byte(0); i < 10; i++ { - s.Write([]byte{i}) - } - }() - - l.SetDeadline(time.Now().Add(2 * time.Second)) - seen := make([]bool, 5) - for { - var b [512]byte - n, _, err := l.ReadFrom(b[:]) - if err != nil { - t.Fatalf("reading from listener: %s", err) - } - if n != 1 { - t.Fatalf("unexpected packet length, want 1, got %d", n) - } - if b[0] >= 10 { - t.Fatalf("unexpected byte, want 0-9, got %d", b[0]) - } - if b[0]%2 != 0 { - t.Fatalf("got odd byte %d, wanted only even bytes", b[0]) - } - seen[b[0]/2] = true - - seenAll := true - for _, v := range seen { - if !v { - seenAll = false - break - } - } - if seenAll { - break - } - } -} diff --git a/vendor/golang.org/x/net/ipv6/bpfopt_linux.go b/vendor/golang.org/x/net/ipv6/bpfopt_linux.go deleted file mode 100644 index daf7ea853..000000000 --- a/vendor/golang.org/x/net/ipv6/bpfopt_linux.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "os" - "unsafe" - - "golang.org/x/net/bpf" - "golang.org/x/net/internal/netreflect" -) - -// SetBPF attaches a BPF program to the connection. -// -// Only supported on Linux. -func (c *dgramOpt) SetBPF(filter []bpf.RawInstruction) error { - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - prog := sockFProg{ - Len: uint16(len(filter)), - Filter: (*sockFilter)(unsafe.Pointer(&filter[0])), - } - return os.NewSyscallError("setsockopt", setsockopt(s, sysSOL_SOCKET, sysSO_ATTACH_FILTER, unsafe.Pointer(&prog), uint32(unsafe.Sizeof(prog)))) -} diff --git a/vendor/golang.org/x/net/ipv6/bpfopt_stub.go b/vendor/golang.org/x/net/ipv6/bpfopt_stub.go deleted file mode 100644 index 2e4de5f0d..000000000 --- a/vendor/golang.org/x/net/ipv6/bpfopt_stub.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !linux - -package ipv6 - -import "golang.org/x/net/bpf" - -// SetBPF attaches a BPF program to the connection. -// -// Only supported on Linux. -func (c *dgramOpt) SetBPF(filter []bpf.RawInstruction) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv6/control.go b/vendor/golang.org/x/net/ipv6/control.go deleted file mode 100644 index 674628d3f..000000000 --- a/vendor/golang.org/x/net/ipv6/control.go +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "fmt" - "net" - "sync" -) - -// Note that RFC 3542 obsoletes RFC 2292 but OS X Snow Leopard and the -// former still support RFC 2292 only. Please be aware that almost -// all protocol implementations prohibit using a combination of RFC -// 2292 and RFC 3542 for some practical reasons. - -type rawOpt struct { - sync.RWMutex - cflags ControlFlags -} - -func (c *rawOpt) set(f ControlFlags) { c.cflags |= f } -func (c *rawOpt) clear(f ControlFlags) { c.cflags &^= f } -func (c *rawOpt) isset(f ControlFlags) bool { return c.cflags&f != 0 } - -// A ControlFlags represents per packet basis IP-level socket option -// control flags. -type ControlFlags uint - -const ( - FlagTrafficClass ControlFlags = 1 << iota // pass the traffic class on the received packet - FlagHopLimit // pass the hop limit on the received packet - FlagSrc // pass the source address on the received packet - FlagDst // pass the destination address on the received packet - FlagInterface // pass the interface index on the received packet - FlagPathMTU // pass the path MTU on the received packet path -) - -const flagPacketInfo = FlagDst | FlagInterface - -// A ControlMessage represents per packet basis IP-level socket -// options. -type ControlMessage struct { - // Receiving socket options: SetControlMessage allows to - // receive the options from the protocol stack using ReadFrom - // method of PacketConn. - // - // Specifying socket options: ControlMessage for WriteTo - // method of PacketConn allows to send the options to the - // protocol stack. - // - TrafficClass int // traffic class, must be 1 <= value <= 255 when specifying - HopLimit int // hop limit, must be 1 <= value <= 255 when specifying - Src net.IP // source address, specifying only - Dst net.IP // destination address, receiving only - IfIndex int // interface index, must be 1 <= value when specifying - NextHop net.IP // next hop address, specifying only - MTU int // path MTU, receiving only -} - -func (cm *ControlMessage) String() string { - if cm == nil { - return "" - } - return fmt.Sprintf("tclass=%#x hoplim=%d src=%v dst=%v ifindex=%d nexthop=%v mtu=%d", cm.TrafficClass, cm.HopLimit, cm.Src, cm.Dst, cm.IfIndex, cm.NextHop, cm.MTU) -} - -// Ancillary data socket options -const ( - ctlTrafficClass = iota // header field - ctlHopLimit // header field - ctlPacketInfo // inbound or outbound packet path - ctlNextHop // nexthop - ctlPathMTU // path mtu - ctlMax -) - -// A ctlOpt represents a binding for ancillary data socket option. -type ctlOpt struct { - name int // option name, must be equal or greater than 1 - length int // option length - marshal func([]byte, *ControlMessage) []byte - parse func(*ControlMessage, []byte) -} diff --git a/vendor/golang.org/x/net/ipv6/control_rfc2292_unix.go b/vendor/golang.org/x/net/ipv6/control_rfc2292_unix.go deleted file mode 100644 index d1693af1f..000000000 --- a/vendor/golang.org/x/net/ipv6/control_rfc2292_unix.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin - -package ipv6 - -import ( - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func marshal2292HopLimit(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIPv6 - m.Type = sysIPV6_2292HOPLIMIT - m.SetLen(syscall.CmsgLen(4)) - if cm != nil { - data := b[syscall.CmsgLen(0):] - nativeEndian.PutUint32(data[:4], uint32(cm.HopLimit)) - } - return b[syscall.CmsgSpace(4):] -} - -func marshal2292PacketInfo(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIPv6 - m.Type = sysIPV6_2292PKTINFO - m.SetLen(syscall.CmsgLen(sizeofInet6Pktinfo)) - if cm != nil { - pi := (*inet6Pktinfo)(unsafe.Pointer(&b[syscall.CmsgLen(0)])) - if ip := cm.Src.To16(); ip != nil && ip.To4() == nil { - copy(pi.Addr[:], ip) - } - if cm.IfIndex > 0 { - pi.setIfindex(cm.IfIndex) - } - } - return b[syscall.CmsgSpace(sizeofInet6Pktinfo):] -} - -func marshal2292NextHop(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIPv6 - m.Type = sysIPV6_2292NEXTHOP - m.SetLen(syscall.CmsgLen(sizeofSockaddrInet6)) - if cm != nil { - sa := (*sockaddrInet6)(unsafe.Pointer(&b[syscall.CmsgLen(0)])) - sa.setSockaddr(cm.NextHop, cm.IfIndex) - } - return b[syscall.CmsgSpace(sizeofSockaddrInet6):] -} diff --git a/vendor/golang.org/x/net/ipv6/control_rfc3542_unix.go b/vendor/golang.org/x/net/ipv6/control_rfc3542_unix.go deleted file mode 100644 index 2800df4bc..000000000 --- a/vendor/golang.org/x/net/ipv6/control_rfc3542_unix.go +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package ipv6 - -import ( - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func marshalTrafficClass(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIPv6 - m.Type = sysIPV6_TCLASS - m.SetLen(syscall.CmsgLen(4)) - if cm != nil { - data := b[syscall.CmsgLen(0):] - nativeEndian.PutUint32(data[:4], uint32(cm.TrafficClass)) - } - return b[syscall.CmsgSpace(4):] -} - -func parseTrafficClass(cm *ControlMessage, b []byte) { - cm.TrafficClass = int(nativeEndian.Uint32(b[:4])) -} - -func marshalHopLimit(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIPv6 - m.Type = sysIPV6_HOPLIMIT - m.SetLen(syscall.CmsgLen(4)) - if cm != nil { - data := b[syscall.CmsgLen(0):] - nativeEndian.PutUint32(data[:4], uint32(cm.HopLimit)) - } - return b[syscall.CmsgSpace(4):] -} - -func parseHopLimit(cm *ControlMessage, b []byte) { - cm.HopLimit = int(nativeEndian.Uint32(b[:4])) -} - -func marshalPacketInfo(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIPv6 - m.Type = sysIPV6_PKTINFO - m.SetLen(syscall.CmsgLen(sizeofInet6Pktinfo)) - if cm != nil { - pi := (*inet6Pktinfo)(unsafe.Pointer(&b[syscall.CmsgLen(0)])) - if ip := cm.Src.To16(); ip != nil && ip.To4() == nil { - copy(pi.Addr[:], ip) - } - if cm.IfIndex > 0 { - pi.setIfindex(cm.IfIndex) - } - } - return b[syscall.CmsgSpace(sizeofInet6Pktinfo):] -} - -func parsePacketInfo(cm *ControlMessage, b []byte) { - pi := (*inet6Pktinfo)(unsafe.Pointer(&b[0])) - cm.Dst = pi.Addr[:] - cm.IfIndex = int(pi.Ifindex) -} - -func marshalNextHop(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIPv6 - m.Type = sysIPV6_NEXTHOP - m.SetLen(syscall.CmsgLen(sizeofSockaddrInet6)) - if cm != nil { - sa := (*sockaddrInet6)(unsafe.Pointer(&b[syscall.CmsgLen(0)])) - sa.setSockaddr(cm.NextHop, cm.IfIndex) - } - return b[syscall.CmsgSpace(sizeofSockaddrInet6):] -} - -func parseNextHop(cm *ControlMessage, b []byte) { -} - -func marshalPathMTU(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIPv6 - m.Type = sysIPV6_PATHMTU - m.SetLen(syscall.CmsgLen(sizeofIPv6Mtuinfo)) - return b[syscall.CmsgSpace(sizeofIPv6Mtuinfo):] -} - -func parsePathMTU(cm *ControlMessage, b []byte) { - mi := (*ipv6Mtuinfo)(unsafe.Pointer(&b[0])) - cm.Dst = mi.Addr.Addr[:] - cm.IfIndex = int(mi.Addr.Scope_id) - cm.MTU = int(mi.Mtu) -} diff --git a/vendor/golang.org/x/net/ipv6/control_stub.go b/vendor/golang.org/x/net/ipv6/control_stub.go deleted file mode 100644 index 24b40a82d..000000000 --- a/vendor/golang.org/x/net/ipv6/control_stub.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package ipv6 - -func setControlMessage(s uintptr, opt *rawOpt, cf ControlFlags, on bool) error { - return errOpNoSupport -} - -func newControlMessage(opt *rawOpt) (oob []byte) { - return nil -} - -func parseControlMessage(b []byte) (*ControlMessage, error) { - return nil, errOpNoSupport -} - -func marshalControlMessage(cm *ControlMessage) (oob []byte) { - return nil -} diff --git a/vendor/golang.org/x/net/ipv6/control_unix.go b/vendor/golang.org/x/net/ipv6/control_unix.go deleted file mode 100644 index 7bd421053..000000000 --- a/vendor/golang.org/x/net/ipv6/control_unix.go +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package ipv6 - -import ( - "os" - "syscall" - - "golang.org/x/net/internal/iana" -) - -func setControlMessage(s uintptr, opt *rawOpt, cf ControlFlags, on bool) error { - opt.Lock() - defer opt.Unlock() - if cf&FlagTrafficClass != 0 && sockOpts[ssoReceiveTrafficClass].name > 0 { - if err := setInt(s, &sockOpts[ssoReceiveTrafficClass], boolint(on)); err != nil { - return err - } - if on { - opt.set(FlagTrafficClass) - } else { - opt.clear(FlagTrafficClass) - } - } - if cf&FlagHopLimit != 0 && sockOpts[ssoReceiveHopLimit].name > 0 { - if err := setInt(s, &sockOpts[ssoReceiveHopLimit], boolint(on)); err != nil { - return err - } - if on { - opt.set(FlagHopLimit) - } else { - opt.clear(FlagHopLimit) - } - } - if cf&flagPacketInfo != 0 && sockOpts[ssoReceivePacketInfo].name > 0 { - if err := setInt(s, &sockOpts[ssoReceivePacketInfo], boolint(on)); err != nil { - return err - } - if on { - opt.set(cf & flagPacketInfo) - } else { - opt.clear(cf & flagPacketInfo) - } - } - if cf&FlagPathMTU != 0 && sockOpts[ssoReceivePathMTU].name > 0 { - if err := setInt(s, &sockOpts[ssoReceivePathMTU], boolint(on)); err != nil { - return err - } - if on { - opt.set(FlagPathMTU) - } else { - opt.clear(FlagPathMTU) - } - } - return nil -} - -func newControlMessage(opt *rawOpt) (oob []byte) { - opt.RLock() - var l int - if opt.isset(FlagTrafficClass) && ctlOpts[ctlTrafficClass].name > 0 { - l += syscall.CmsgSpace(ctlOpts[ctlTrafficClass].length) - } - if opt.isset(FlagHopLimit) && ctlOpts[ctlHopLimit].name > 0 { - l += syscall.CmsgSpace(ctlOpts[ctlHopLimit].length) - } - if opt.isset(flagPacketInfo) && ctlOpts[ctlPacketInfo].name > 0 { - l += syscall.CmsgSpace(ctlOpts[ctlPacketInfo].length) - } - if opt.isset(FlagPathMTU) && ctlOpts[ctlPathMTU].name > 0 { - l += syscall.CmsgSpace(ctlOpts[ctlPathMTU].length) - } - if l > 0 { - oob = make([]byte, l) - } - opt.RUnlock() - return -} - -func parseControlMessage(b []byte) (*ControlMessage, error) { - if len(b) == 0 { - return nil, nil - } - cmsgs, err := syscall.ParseSocketControlMessage(b) - if err != nil { - return nil, os.NewSyscallError("parse socket control message", err) - } - cm := &ControlMessage{} - for _, m := range cmsgs { - if m.Header.Level != iana.ProtocolIPv6 { - continue - } - switch int(m.Header.Type) { - case ctlOpts[ctlTrafficClass].name: - ctlOpts[ctlTrafficClass].parse(cm, m.Data[:]) - case ctlOpts[ctlHopLimit].name: - ctlOpts[ctlHopLimit].parse(cm, m.Data[:]) - case ctlOpts[ctlPacketInfo].name: - ctlOpts[ctlPacketInfo].parse(cm, m.Data[:]) - case ctlOpts[ctlPathMTU].name: - ctlOpts[ctlPathMTU].parse(cm, m.Data[:]) - } - } - return cm, nil -} - -func marshalControlMessage(cm *ControlMessage) (oob []byte) { - if cm == nil { - return - } - var l int - tclass := false - if ctlOpts[ctlTrafficClass].name > 0 && cm.TrafficClass > 0 { - tclass = true - l += syscall.CmsgSpace(ctlOpts[ctlTrafficClass].length) - } - hoplimit := false - if ctlOpts[ctlHopLimit].name > 0 && cm.HopLimit > 0 { - hoplimit = true - l += syscall.CmsgSpace(ctlOpts[ctlHopLimit].length) - } - pktinfo := false - if ctlOpts[ctlPacketInfo].name > 0 && (cm.Src.To16() != nil && cm.Src.To4() == nil || cm.IfIndex > 0) { - pktinfo = true - l += syscall.CmsgSpace(ctlOpts[ctlPacketInfo].length) - } - nexthop := false - if ctlOpts[ctlNextHop].name > 0 && cm.NextHop.To16() != nil && cm.NextHop.To4() == nil { - nexthop = true - l += syscall.CmsgSpace(ctlOpts[ctlNextHop].length) - } - if l > 0 { - oob = make([]byte, l) - b := oob - if tclass { - b = ctlOpts[ctlTrafficClass].marshal(b, cm) - } - if hoplimit { - b = ctlOpts[ctlHopLimit].marshal(b, cm) - } - if pktinfo { - b = ctlOpts[ctlPacketInfo].marshal(b, cm) - } - if nexthop { - b = ctlOpts[ctlNextHop].marshal(b, cm) - } - } - return -} diff --git a/vendor/golang.org/x/net/ipv6/control_windows.go b/vendor/golang.org/x/net/ipv6/control_windows.go deleted file mode 100644 index feef6ab86..000000000 --- a/vendor/golang.org/x/net/ipv6/control_windows.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import "syscall" - -func setControlMessage(s uintptr, opt *rawOpt, cf ControlFlags, on bool) error { - // TODO(mikio): implement this - return syscall.EWINDOWS -} - -func newControlMessage(opt *rawOpt) (oob []byte) { - // TODO(mikio): implement this - return nil -} - -func parseControlMessage(b []byte) (*ControlMessage, error) { - // TODO(mikio): implement this - return nil, syscall.EWINDOWS -} - -func marshalControlMessage(cm *ControlMessage) (oob []byte) { - // TODO(mikio): implement this - return nil -} diff --git a/vendor/golang.org/x/net/ipv6/defs_darwin.go b/vendor/golang.org/x/net/ipv6/defs_darwin.go deleted file mode 100644 index 55ddc116f..000000000 --- a/vendor/golang.org/x/net/ipv6/defs_darwin.go +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package ipv6 - -/* -#define __APPLE_USE_RFC_3542 -#include -#include -*/ -import "C" - -const ( - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP - - sysIPV6_PORTRANGE = C.IPV6_PORTRANGE - sysICMP6_FILTER = C.ICMP6_FILTER - sysIPV6_2292PKTINFO = C.IPV6_2292PKTINFO - sysIPV6_2292HOPLIMIT = C.IPV6_2292HOPLIMIT - sysIPV6_2292NEXTHOP = C.IPV6_2292NEXTHOP - sysIPV6_2292HOPOPTS = C.IPV6_2292HOPOPTS - sysIPV6_2292DSTOPTS = C.IPV6_2292DSTOPTS - sysIPV6_2292RTHDR = C.IPV6_2292RTHDR - - sysIPV6_2292PKTOPTIONS = C.IPV6_2292PKTOPTIONS - - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM - sysIPV6_V6ONLY = C.IPV6_V6ONLY - - sysIPV6_IPSEC_POLICY = C.IPV6_IPSEC_POLICY - - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS - sysIPV6_TCLASS = C.IPV6_TCLASS - - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS - - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO - - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS - - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU - - sysIPV6_PATHMTU = C.IPV6_PATHMTU - - sysIPV6_PKTINFO = C.IPV6_PKTINFO - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS - sysIPV6_RTHDR = C.IPV6_RTHDR - - sysIPV6_AUTOFLOWLABEL = C.IPV6_AUTOFLOWLABEL - - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG - - sysIPV6_PREFER_TEMPADDR = C.IPV6_PREFER_TEMPADDR - - sysIPV6_MSFILTER = C.IPV6_MSFILTER - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - - sysIPV6_BOUND_IF = C.IPV6_BOUND_IF - - sysIPV6_PORTRANGE_DEFAULT = C.IPV6_PORTRANGE_DEFAULT - sysIPV6_PORTRANGE_HIGH = C.IPV6_PORTRANGE_HIGH - sysIPV6_PORTRANGE_LOW = C.IPV6_PORTRANGE_LOW - - sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - sizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - sizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo - - sizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - sizeofGroupReq = C.sizeof_struct_group_req - sizeofGroupSourceReq = C.sizeof_struct_group_source_req - - sizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -type sockaddrStorage C.struct_sockaddr_storage - -type sockaddrInet6 C.struct_sockaddr_in6 - -type inet6Pktinfo C.struct_in6_pktinfo - -type ipv6Mtuinfo C.struct_ip6_mtuinfo - -type ipv6Mreq C.struct_ipv6_mreq - -type icmpv6Filter C.struct_icmp6_filter - -type groupReq C.struct_group_req - -type groupSourceReq C.struct_group_source_req diff --git a/vendor/golang.org/x/net/ipv6/defs_dragonfly.go b/vendor/golang.org/x/net/ipv6/defs_dragonfly.go deleted file mode 100644 index a4c383a51..000000000 --- a/vendor/golang.org/x/net/ipv6/defs_dragonfly.go +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package ipv6 - -/* -#include -#include - -#include -#include -*/ -import "C" - -const ( - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP - sysIPV6_PORTRANGE = C.IPV6_PORTRANGE - sysICMP6_FILTER = C.ICMP6_FILTER - - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM - sysIPV6_V6ONLY = C.IPV6_V6ONLY - - sysIPV6_IPSEC_POLICY = C.IPV6_IPSEC_POLICY - - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS - - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU - - sysIPV6_PATHMTU = C.IPV6_PATHMTU - - sysIPV6_PKTINFO = C.IPV6_PKTINFO - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS - sysIPV6_RTHDR = C.IPV6_RTHDR - - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS - - sysIPV6_AUTOFLOWLABEL = C.IPV6_AUTOFLOWLABEL - - sysIPV6_TCLASS = C.IPV6_TCLASS - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG - - sysIPV6_PREFER_TEMPADDR = C.IPV6_PREFER_TEMPADDR - - sysIPV6_PORTRANGE_DEFAULT = C.IPV6_PORTRANGE_DEFAULT - sysIPV6_PORTRANGE_HIGH = C.IPV6_PORTRANGE_HIGH - sysIPV6_PORTRANGE_LOW = C.IPV6_PORTRANGE_LOW - - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - sizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - sizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo - - sizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - - sizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -type sockaddrInet6 C.struct_sockaddr_in6 - -type inet6Pktinfo C.struct_in6_pktinfo - -type ipv6Mtuinfo C.struct_ip6_mtuinfo - -type ipv6Mreq C.struct_ipv6_mreq - -type icmpv6Filter C.struct_icmp6_filter diff --git a/vendor/golang.org/x/net/ipv6/defs_freebsd.go b/vendor/golang.org/x/net/ipv6/defs_freebsd.go deleted file mode 100644 index 53e625389..000000000 --- a/vendor/golang.org/x/net/ipv6/defs_freebsd.go +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package ipv6 - -/* -#include -#include - -#include -#include -*/ -import "C" - -const ( - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP - sysIPV6_PORTRANGE = C.IPV6_PORTRANGE - sysICMP6_FILTER = C.ICMP6_FILTER - - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM - sysIPV6_V6ONLY = C.IPV6_V6ONLY - - sysIPV6_IPSEC_POLICY = C.IPV6_IPSEC_POLICY - - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS - - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS - - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU - - sysIPV6_PATHMTU = C.IPV6_PATHMTU - - sysIPV6_PKTINFO = C.IPV6_PKTINFO - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS - sysIPV6_RTHDR = C.IPV6_RTHDR - - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS - - sysIPV6_AUTOFLOWLABEL = C.IPV6_AUTOFLOWLABEL - - sysIPV6_TCLASS = C.IPV6_TCLASS - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG - - sysIPV6_PREFER_TEMPADDR = C.IPV6_PREFER_TEMPADDR - - sysIPV6_BINDANY = C.IPV6_BINDANY - - sysIPV6_MSFILTER = C.IPV6_MSFILTER - - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - - sysIPV6_PORTRANGE_DEFAULT = C.IPV6_PORTRANGE_DEFAULT - sysIPV6_PORTRANGE_HIGH = C.IPV6_PORTRANGE_HIGH - sysIPV6_PORTRANGE_LOW = C.IPV6_PORTRANGE_LOW - - sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - sizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - sizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo - - sizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - sizeofGroupReq = C.sizeof_struct_group_req - sizeofGroupSourceReq = C.sizeof_struct_group_source_req - - sizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -type sockaddrStorage C.struct_sockaddr_storage - -type sockaddrInet6 C.struct_sockaddr_in6 - -type inet6Pktinfo C.struct_in6_pktinfo - -type ipv6Mtuinfo C.struct_ip6_mtuinfo - -type ipv6Mreq C.struct_ipv6_mreq - -type groupReq C.struct_group_req - -type groupSourceReq C.struct_group_source_req - -type icmpv6Filter C.struct_icmp6_filter diff --git a/vendor/golang.org/x/net/ipv6/defs_linux.go b/vendor/golang.org/x/net/ipv6/defs_linux.go deleted file mode 100644 index 8a967fd21..000000000 --- a/vendor/golang.org/x/net/ipv6/defs_linux.go +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package ipv6 - -/* -#include -#include -#include -#include -#include -#include -*/ -import "C" - -const ( - sysIPV6_ADDRFORM = C.IPV6_ADDRFORM - sysIPV6_2292PKTINFO = C.IPV6_2292PKTINFO - sysIPV6_2292HOPOPTS = C.IPV6_2292HOPOPTS - sysIPV6_2292DSTOPTS = C.IPV6_2292DSTOPTS - sysIPV6_2292RTHDR = C.IPV6_2292RTHDR - sysIPV6_2292PKTOPTIONS = C.IPV6_2292PKTOPTIONS - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM - sysIPV6_2292HOPLIMIT = C.IPV6_2292HOPLIMIT - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP - sysIPV6_FLOWINFO = C.IPV6_FLOWINFO - - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP - sysIPV6_ADD_MEMBERSHIP = C.IPV6_ADD_MEMBERSHIP - sysIPV6_DROP_MEMBERSHIP = C.IPV6_DROP_MEMBERSHIP - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - sysMCAST_MSFILTER = C.MCAST_MSFILTER - sysIPV6_ROUTER_ALERT = C.IPV6_ROUTER_ALERT - sysIPV6_MTU_DISCOVER = C.IPV6_MTU_DISCOVER - sysIPV6_MTU = C.IPV6_MTU - sysIPV6_RECVERR = C.IPV6_RECVERR - sysIPV6_V6ONLY = C.IPV6_V6ONLY - sysIPV6_JOIN_ANYCAST = C.IPV6_JOIN_ANYCAST - sysIPV6_LEAVE_ANYCAST = C.IPV6_LEAVE_ANYCAST - - //sysIPV6_PMTUDISC_DONT = C.IPV6_PMTUDISC_DONT - //sysIPV6_PMTUDISC_WANT = C.IPV6_PMTUDISC_WANT - //sysIPV6_PMTUDISC_DO = C.IPV6_PMTUDISC_DO - //sysIPV6_PMTUDISC_PROBE = C.IPV6_PMTUDISC_PROBE - //sysIPV6_PMTUDISC_INTERFACE = C.IPV6_PMTUDISC_INTERFACE - //sysIPV6_PMTUDISC_OMIT = C.IPV6_PMTUDISC_OMIT - - sysIPV6_FLOWLABEL_MGR = C.IPV6_FLOWLABEL_MGR - sysIPV6_FLOWINFO_SEND = C.IPV6_FLOWINFO_SEND - - sysIPV6_IPSEC_POLICY = C.IPV6_IPSEC_POLICY - sysIPV6_XFRM_POLICY = C.IPV6_XFRM_POLICY - - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO - sysIPV6_PKTINFO = C.IPV6_PKTINFO - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR - sysIPV6_RTHDR = C.IPV6_RTHDR - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU - sysIPV6_PATHMTU = C.IPV6_PATHMTU - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG - - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS - sysIPV6_TCLASS = C.IPV6_TCLASS - - sysIPV6_ADDR_PREFERENCES = C.IPV6_ADDR_PREFERENCES - - sysIPV6_PREFER_SRC_TMP = C.IPV6_PREFER_SRC_TMP - sysIPV6_PREFER_SRC_PUBLIC = C.IPV6_PREFER_SRC_PUBLIC - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = C.IPV6_PREFER_SRC_PUBTMP_DEFAULT - sysIPV6_PREFER_SRC_COA = C.IPV6_PREFER_SRC_COA - sysIPV6_PREFER_SRC_HOME = C.IPV6_PREFER_SRC_HOME - sysIPV6_PREFER_SRC_CGA = C.IPV6_PREFER_SRC_CGA - sysIPV6_PREFER_SRC_NONCGA = C.IPV6_PREFER_SRC_NONCGA - - sysIPV6_MINHOPCOUNT = C.IPV6_MINHOPCOUNT - - sysIPV6_ORIGDSTADDR = C.IPV6_ORIGDSTADDR - sysIPV6_RECVORIGDSTADDR = C.IPV6_RECVORIGDSTADDR - sysIPV6_TRANSPARENT = C.IPV6_TRANSPARENT - sysIPV6_UNICAST_IF = C.IPV6_UNICAST_IF - - sysICMPV6_FILTER = C.ICMPV6_FILTER - - sysICMPV6_FILTER_BLOCK = C.ICMPV6_FILTER_BLOCK - sysICMPV6_FILTER_PASS = C.ICMPV6_FILTER_PASS - sysICMPV6_FILTER_BLOCKOTHERS = C.ICMPV6_FILTER_BLOCKOTHERS - sysICMPV6_FILTER_PASSONLY = C.ICMPV6_FILTER_PASSONLY - - sysSOL_SOCKET = C.SOL_SOCKET - sysSO_ATTACH_FILTER = C.SO_ATTACH_FILTER - - sizeofKernelSockaddrStorage = C.sizeof_struct___kernel_sockaddr_storage - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - sizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - sizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo - sizeofIPv6FlowlabelReq = C.sizeof_struct_in6_flowlabel_req - - sizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - sizeofGroupReq = C.sizeof_struct_group_req - sizeofGroupSourceReq = C.sizeof_struct_group_source_req - - sizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -type kernelSockaddrStorage C.struct___kernel_sockaddr_storage - -type sockaddrInet6 C.struct_sockaddr_in6 - -type inet6Pktinfo C.struct_in6_pktinfo - -type ipv6Mtuinfo C.struct_ip6_mtuinfo - -type ipv6FlowlabelReq C.struct_in6_flowlabel_req - -type ipv6Mreq C.struct_ipv6_mreq - -type groupReq C.struct_group_req - -type groupSourceReq C.struct_group_source_req - -type icmpv6Filter C.struct_icmp6_filter - -type sockFProg C.struct_sock_fprog - -type sockFilter C.struct_sock_filter diff --git a/vendor/golang.org/x/net/ipv6/defs_netbsd.go b/vendor/golang.org/x/net/ipv6/defs_netbsd.go deleted file mode 100644 index be9ceb9cc..000000000 --- a/vendor/golang.org/x/net/ipv6/defs_netbsd.go +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package ipv6 - -/* -#include -#include - -#include -#include -*/ -import "C" - -const ( - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP - sysIPV6_PORTRANGE = C.IPV6_PORTRANGE - sysICMP6_FILTER = C.ICMP6_FILTER - - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM - sysIPV6_V6ONLY = C.IPV6_V6ONLY - - sysIPV6_IPSEC_POLICY = C.IPV6_IPSEC_POLICY - - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS - - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS - - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU - sysIPV6_PATHMTU = C.IPV6_PATHMTU - - sysIPV6_PKTINFO = C.IPV6_PKTINFO - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS - sysIPV6_RTHDR = C.IPV6_RTHDR - - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS - - sysIPV6_TCLASS = C.IPV6_TCLASS - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG - - sysIPV6_PORTRANGE_DEFAULT = C.IPV6_PORTRANGE_DEFAULT - sysIPV6_PORTRANGE_HIGH = C.IPV6_PORTRANGE_HIGH - sysIPV6_PORTRANGE_LOW = C.IPV6_PORTRANGE_LOW - - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - sizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - sizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo - - sizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - - sizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -type sockaddrInet6 C.struct_sockaddr_in6 - -type inet6Pktinfo C.struct_in6_pktinfo - -type ipv6Mtuinfo C.struct_ip6_mtuinfo - -type ipv6Mreq C.struct_ipv6_mreq - -type icmpv6Filter C.struct_icmp6_filter diff --git a/vendor/golang.org/x/net/ipv6/defs_openbsd.go b/vendor/golang.org/x/net/ipv6/defs_openbsd.go deleted file mode 100644 index 177ddf87d..000000000 --- a/vendor/golang.org/x/net/ipv6/defs_openbsd.go +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package ipv6 - -/* -#include -#include - -#include -#include -*/ -import "C" - -const ( - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP - sysIPV6_PORTRANGE = C.IPV6_PORTRANGE - sysICMP6_FILTER = C.ICMP6_FILTER - - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM - sysIPV6_V6ONLY = C.IPV6_V6ONLY - - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS - - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS - - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU - - sysIPV6_PATHMTU = C.IPV6_PATHMTU - - sysIPV6_PKTINFO = C.IPV6_PKTINFO - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS - sysIPV6_RTHDR = C.IPV6_RTHDR - - sysIPV6_AUTH_LEVEL = C.IPV6_AUTH_LEVEL - sysIPV6_ESP_TRANS_LEVEL = C.IPV6_ESP_TRANS_LEVEL - sysIPV6_ESP_NETWORK_LEVEL = C.IPV6_ESP_NETWORK_LEVEL - sysIPSEC6_OUTSA = C.IPSEC6_OUTSA - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS - - sysIPV6_AUTOFLOWLABEL = C.IPV6_AUTOFLOWLABEL - sysIPV6_IPCOMP_LEVEL = C.IPV6_IPCOMP_LEVEL - - sysIPV6_TCLASS = C.IPV6_TCLASS - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG - sysIPV6_PIPEX = C.IPV6_PIPEX - - sysIPV6_RTABLE = C.IPV6_RTABLE - - sysIPV6_PORTRANGE_DEFAULT = C.IPV6_PORTRANGE_DEFAULT - sysIPV6_PORTRANGE_HIGH = C.IPV6_PORTRANGE_HIGH - sysIPV6_PORTRANGE_LOW = C.IPV6_PORTRANGE_LOW - - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - sizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - sizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo - - sizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - - sizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -type sockaddrInet6 C.struct_sockaddr_in6 - -type inet6Pktinfo C.struct_in6_pktinfo - -type ipv6Mtuinfo C.struct_ip6_mtuinfo - -type ipv6Mreq C.struct_ipv6_mreq - -type icmpv6Filter C.struct_icmp6_filter diff --git a/vendor/golang.org/x/net/ipv6/defs_solaris.go b/vendor/golang.org/x/net/ipv6/defs_solaris.go deleted file mode 100644 index 0f8ce2b46..000000000 --- a/vendor/golang.org/x/net/ipv6/defs_solaris.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package ipv6 - -/* -#include - -#include -#include -*/ -import "C" - -const ( - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP - - sysIPV6_PKTINFO = C.IPV6_PKTINFO - - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS - - sysIPV6_RTHDR = C.IPV6_RTHDR - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS - - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS - - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR - - sysIPV6_RECVRTHDRDSTOPTS = C.IPV6_RECVRTHDRDSTOPTS - - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG - sysIPV6_SEC_OPT = C.IPV6_SEC_OPT - sysIPV6_SRC_PREFERENCES = C.IPV6_SRC_PREFERENCES - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU - sysIPV6_PATHMTU = C.IPV6_PATHMTU - sysIPV6_TCLASS = C.IPV6_TCLASS - sysIPV6_V6ONLY = C.IPV6_V6ONLY - - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS - - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - - sysIPV6_PREFER_SRC_HOME = C.IPV6_PREFER_SRC_HOME - sysIPV6_PREFER_SRC_COA = C.IPV6_PREFER_SRC_COA - sysIPV6_PREFER_SRC_PUBLIC = C.IPV6_PREFER_SRC_PUBLIC - sysIPV6_PREFER_SRC_TMP = C.IPV6_PREFER_SRC_TMP - sysIPV6_PREFER_SRC_NONCGA = C.IPV6_PREFER_SRC_NONCGA - sysIPV6_PREFER_SRC_CGA = C.IPV6_PREFER_SRC_CGA - - sysIPV6_PREFER_SRC_MIPMASK = C.IPV6_PREFER_SRC_MIPMASK - sysIPV6_PREFER_SRC_MIPDEFAULT = C.IPV6_PREFER_SRC_MIPDEFAULT - sysIPV6_PREFER_SRC_TMPMASK = C.IPV6_PREFER_SRC_TMPMASK - sysIPV6_PREFER_SRC_TMPDEFAULT = C.IPV6_PREFER_SRC_TMPDEFAULT - sysIPV6_PREFER_SRC_CGAMASK = C.IPV6_PREFER_SRC_CGAMASK - sysIPV6_PREFER_SRC_CGADEFAULT = C.IPV6_PREFER_SRC_CGADEFAULT - - sysIPV6_PREFER_SRC_MASK = C.IPV6_PREFER_SRC_MASK - - sysIPV6_PREFER_SRC_DEFAULT = C.IPV6_PREFER_SRC_DEFAULT - - sysIPV6_BOUND_IF = C.IPV6_BOUND_IF - sysIPV6_UNSPEC_SRC = C.IPV6_UNSPEC_SRC - - sysICMP6_FILTER = C.ICMP6_FILTER - - sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - sizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - sizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo - - sizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - sizeofGroupReq = C.sizeof_struct_group_req - sizeofGroupSourceReq = C.sizeof_struct_group_source_req - - sizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -type sockaddrStorage C.struct_sockaddr_storage - -type sockaddrInet6 C.struct_sockaddr_in6 - -type inet6Pktinfo C.struct_in6_pktinfo - -type ipv6Mtuinfo C.struct_ip6_mtuinfo - -type ipv6Mreq C.struct_ipv6_mreq - -type groupReq C.struct_group_req - -type groupSourceReq C.struct_group_source_req - -type icmpv6Filter C.struct_icmp6_filter diff --git a/vendor/golang.org/x/net/ipv6/dgramopt_posix.go b/vendor/golang.org/x/net/ipv6/dgramopt_posix.go deleted file mode 100644 index a448cbaa5..000000000 --- a/vendor/golang.org/x/net/ipv6/dgramopt_posix.go +++ /dev/null @@ -1,290 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package ipv6 - -import ( - "net" - "syscall" - - "golang.org/x/net/internal/netreflect" -) - -// MulticastHopLimit returns the hop limit field value for outgoing -// multicast packets. -func (c *dgramOpt) MulticastHopLimit() (int, error) { - if !c.ok() { - return 0, syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return 0, err - } - return getInt(s, &sockOpts[ssoMulticastHopLimit]) -} - -// SetMulticastHopLimit sets the hop limit field value for future -// outgoing multicast packets. -func (c *dgramOpt) SetMulticastHopLimit(hoplim int) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - return setInt(s, &sockOpts[ssoMulticastHopLimit], hoplim) -} - -// MulticastInterface returns the default interface for multicast -// packet transmissions. -func (c *dgramOpt) MulticastInterface() (*net.Interface, error) { - if !c.ok() { - return nil, syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return nil, err - } - return getInterface(s, &sockOpts[ssoMulticastInterface]) -} - -// SetMulticastInterface sets the default interface for future -// multicast packet transmissions. -func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - return setInterface(s, &sockOpts[ssoMulticastInterface], ifi) -} - -// MulticastLoopback reports whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) MulticastLoopback() (bool, error) { - if !c.ok() { - return false, syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return false, err - } - on, err := getInt(s, &sockOpts[ssoMulticastLoopback]) - if err != nil { - return false, err - } - return on == 1, nil -} - -// SetMulticastLoopback sets whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) SetMulticastLoopback(on bool) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - return setInt(s, &sockOpts[ssoMulticastLoopback], boolint(on)) -} - -// JoinGroup joins the group address group on the interface ifi. -// By default all sources that can cast data to group are accepted. -// It's possible to mute and unmute data transmission from a specific -// source by using ExcludeSourceSpecificGroup and -// IncludeSourceSpecificGroup. -// JoinGroup uses the system assigned multicast interface when ifi is -// nil, although this is not recommended because the assignment -// depends on platforms and sometimes it might require routing -// configuration. -func (c *dgramOpt) JoinGroup(ifi *net.Interface, group net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - grp := netAddrToIP16(group) - if grp == nil { - return errMissingAddress - } - return setGroup(s, &sockOpts[ssoJoinGroup], ifi, grp) -} - -// LeaveGroup leaves the group address group on the interface ifi -// regardless of whether the group is any-source group or -// source-specific group. -func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - grp := netAddrToIP16(group) - if grp == nil { - return errMissingAddress - } - return setGroup(s, &sockOpts[ssoLeaveGroup], ifi, grp) -} - -// JoinSourceSpecificGroup joins the source-specific group comprising -// group and source on the interface ifi. -// JoinSourceSpecificGroup uses the system assigned multicast -// interface when ifi is nil, although this is not recommended because -// the assignment depends on platforms and sometimes it might require -// routing configuration. -func (c *dgramOpt) JoinSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - grp := netAddrToIP16(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP16(source) - if src == nil { - return errMissingAddress - } - return setSourceGroup(s, &sockOpts[ssoJoinSourceGroup], ifi, grp, src) -} - -// LeaveSourceSpecificGroup leaves the source-specific group on the -// interface ifi. -func (c *dgramOpt) LeaveSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - grp := netAddrToIP16(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP16(source) - if src == nil { - return errMissingAddress - } - return setSourceGroup(s, &sockOpts[ssoLeaveSourceGroup], ifi, grp, src) -} - -// ExcludeSourceSpecificGroup excludes the source-specific group from -// the already joined any-source groups by JoinGroup on the interface -// ifi. -func (c *dgramOpt) ExcludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - grp := netAddrToIP16(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP16(source) - if src == nil { - return errMissingAddress - } - return setSourceGroup(s, &sockOpts[ssoBlockSourceGroup], ifi, grp, src) -} - -// IncludeSourceSpecificGroup includes the excluded source-specific -// group by ExcludeSourceSpecificGroup again on the interface ifi. -func (c *dgramOpt) IncludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - grp := netAddrToIP16(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP16(source) - if src == nil { - return errMissingAddress - } - return setSourceGroup(s, &sockOpts[ssoUnblockSourceGroup], ifi, grp, src) -} - -// Checksum reports whether the kernel will compute, store or verify a -// checksum for both incoming and outgoing packets. If on is true, it -// returns an offset in bytes into the data of where the checksum -// field is located. -func (c *dgramOpt) Checksum() (on bool, offset int, err error) { - if !c.ok() { - return false, 0, syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return false, 0, err - } - offset, err = getInt(s, &sockOpts[ssoChecksum]) - if err != nil { - return false, 0, err - } - if offset < 0 { - return false, 0, nil - } - return true, offset, nil -} - -// SetChecksum enables the kernel checksum processing. If on is ture, -// the offset should be an offset in bytes into the data of where the -// checksum field is located. -func (c *dgramOpt) SetChecksum(on bool, offset int) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - if !on { - offset = -1 - } - return setInt(s, &sockOpts[ssoChecksum], offset) -} - -// ICMPFilter returns an ICMP filter. -func (c *dgramOpt) ICMPFilter() (*ICMPFilter, error) { - if !c.ok() { - return nil, syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return nil, err - } - return getICMPFilter(s, &sockOpts[ssoICMPFilter]) -} - -// SetICMPFilter deploys the ICMP filter. -func (c *dgramOpt) SetICMPFilter(f *ICMPFilter) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.PacketConn) - if err != nil { - return err - } - return setICMPFilter(s, &sockOpts[ssoICMPFilter], f) -} diff --git a/vendor/golang.org/x/net/ipv6/dgramopt_stub.go b/vendor/golang.org/x/net/ipv6/dgramopt_stub.go deleted file mode 100644 index 82b0686ae..000000000 --- a/vendor/golang.org/x/net/ipv6/dgramopt_stub.go +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package ipv6 - -import "net" - -// MulticastHopLimit returns the hop limit field value for outgoing -// multicast packets. -func (c *dgramOpt) MulticastHopLimit() (int, error) { - return 0, errOpNoSupport -} - -// SetMulticastHopLimit sets the hop limit field value for future -// outgoing multicast packets. -func (c *dgramOpt) SetMulticastHopLimit(hoplim int) error { - return errOpNoSupport -} - -// MulticastInterface returns the default interface for multicast -// packet transmissions. -func (c *dgramOpt) MulticastInterface() (*net.Interface, error) { - return nil, errOpNoSupport -} - -// SetMulticastInterface sets the default interface for future -// multicast packet transmissions. -func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error { - return errOpNoSupport -} - -// MulticastLoopback reports whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) MulticastLoopback() (bool, error) { - return false, errOpNoSupport -} - -// SetMulticastLoopback sets whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) SetMulticastLoopback(on bool) error { - return errOpNoSupport -} - -// JoinGroup joins the group address group on the interface ifi. -// By default all sources that can cast data to group are accepted. -// It's possible to mute and unmute data transmission from a specific -// source by using ExcludeSourceSpecificGroup and -// IncludeSourceSpecificGroup. -// JoinGroup uses the system assigned multicast interface when ifi is -// nil, although this is not recommended because the assignment -// depends on platforms and sometimes it might require routing -// configuration. -func (c *dgramOpt) JoinGroup(ifi *net.Interface, group net.Addr) error { - return errOpNoSupport -} - -// LeaveGroup leaves the group address group on the interface ifi -// regardless of whether the group is any-source group or -// source-specific group. -func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error { - return errOpNoSupport -} - -// JoinSourceSpecificGroup joins the source-specific group comprising -// group and source on the interface ifi. -// JoinSourceSpecificGroup uses the system assigned multicast -// interface when ifi is nil, although this is not recommended because -// the assignment depends on platforms and sometimes it might require -// routing configuration. -func (c *dgramOpt) JoinSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - return errOpNoSupport -} - -// LeaveSourceSpecificGroup leaves the source-specific group on the -// interface ifi. -func (c *dgramOpt) LeaveSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - return errOpNoSupport -} - -// ExcludeSourceSpecificGroup excludes the source-specific group from -// the already joined any-source groups by JoinGroup on the interface -// ifi. -func (c *dgramOpt) ExcludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - return errOpNoSupport -} - -// IncludeSourceSpecificGroup includes the excluded source-specific -// group by ExcludeSourceSpecificGroup again on the interface ifi. -func (c *dgramOpt) IncludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - return errOpNoSupport -} - -// Checksum reports whether the kernel will compute, store or verify a -// checksum for both incoming and outgoing packets. If on is true, it -// returns an offset in bytes into the data of where the checksum -// field is located. -func (c *dgramOpt) Checksum() (on bool, offset int, err error) { - return false, 0, errOpNoSupport -} - -// SetChecksum enables the kernel checksum processing. If on is ture, -// the offset should be an offset in bytes into the data of where the -// checksum field is located. -func (c *dgramOpt) SetChecksum(on bool, offset int) error { - return errOpNoSupport -} - -// ICMPFilter returns an ICMP filter. -func (c *dgramOpt) ICMPFilter() (*ICMPFilter, error) { - return nil, errOpNoSupport -} - -// SetICMPFilter deploys the ICMP filter. -func (c *dgramOpt) SetICMPFilter(f *ICMPFilter) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv6/doc.go b/vendor/golang.org/x/net/ipv6/doc.go deleted file mode 100644 index eaa24c580..000000000 --- a/vendor/golang.org/x/net/ipv6/doc.go +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package ipv6 implements IP-level socket options for the Internet -// Protocol version 6. -// -// The package provides IP-level socket options that allow -// manipulation of IPv6 facilities. -// -// The IPv6 protocol is defined in RFC 2460. -// Socket interface extensions are defined in RFC 3493, RFC 3542 and -// RFC 3678. -// MLDv1 and MLDv2 are defined in RFC 2710 and RFC 3810. -// Source-specific multicast is defined in RFC 4607. -// -// On Darwin, this package requires OS X Mavericks version 10.9 or -// above, or equivalent. -// -// -// Unicasting -// -// The options for unicasting are available for net.TCPConn, -// net.UDPConn and net.IPConn which are created as network connections -// that use the IPv6 transport. When a single TCP connection carrying -// a data flow of multiple packets needs to indicate the flow is -// important, Conn is used to set the traffic class field on the IPv6 -// header for each packet. -// -// ln, err := net.Listen("tcp6", "[::]:1024") -// if err != nil { -// // error handling -// } -// defer ln.Close() -// for { -// c, err := ln.Accept() -// if err != nil { -// // error handling -// } -// go func(c net.Conn) { -// defer c.Close() -// -// The outgoing packets will be labeled DiffServ assured forwarding -// class 1 low drop precedence, known as AF11 packets. -// -// if err := ipv6.NewConn(c).SetTrafficClass(0x28); err != nil { -// // error handling -// } -// if _, err := c.Write(data); err != nil { -// // error handling -// } -// }(c) -// } -// -// -// Multicasting -// -// The options for multicasting are available for net.UDPConn and -// net.IPconn which are created as network connections that use the -// IPv6 transport. A few network facilities must be prepared before -// you begin multicasting, at a minimum joining network interfaces and -// multicast groups. -// -// en0, err := net.InterfaceByName("en0") -// if err != nil { -// // error handling -// } -// en1, err := net.InterfaceByIndex(911) -// if err != nil { -// // error handling -// } -// group := net.ParseIP("ff02::114") -// -// First, an application listens to an appropriate address with an -// appropriate service port. -// -// c, err := net.ListenPacket("udp6", "[::]:1024") -// if err != nil { -// // error handling -// } -// defer c.Close() -// -// Second, the application joins multicast groups, starts listening to -// the groups on the specified network interfaces. Note that the -// service port for transport layer protocol does not matter with this -// operation as joining groups affects only network and link layer -// protocols, such as IPv6 and Ethernet. -// -// p := ipv6.NewPacketConn(c) -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: group}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en1, &net.UDPAddr{IP: group}); err != nil { -// // error handling -// } -// -// The application might set per packet control message transmissions -// between the protocol stack within the kernel. When the application -// needs a destination address on an incoming packet, -// SetControlMessage of PacketConn is used to enable control message -// transmissions. -// -// if err := p.SetControlMessage(ipv6.FlagDst, true); err != nil { -// // error handling -// } -// -// The application could identify whether the received packets are -// of interest by using the control message that contains the -// destination address of the received packet. -// -// b := make([]byte, 1500) -// for { -// n, rcm, src, err := p.ReadFrom(b) -// if err != nil { -// // error handling -// } -// if rcm.Dst.IsMulticast() { -// if rcm.Dst.Equal(group) { -// // joined group, do something -// } else { -// // unknown group, discard -// continue -// } -// } -// -// The application can also send both unicast and multicast packets. -// -// p.SetTrafficClass(0x0) -// p.SetHopLimit(16) -// if _, err := p.WriteTo(data[:n], nil, src); err != nil { -// // error handling -// } -// dst := &net.UDPAddr{IP: group, Port: 1024} -// wcm := ipv6.ControlMessage{TrafficClass: 0xe0, HopLimit: 1} -// for _, ifi := range []*net.Interface{en0, en1} { -// wcm.IfIndex = ifi.Index -// if _, err := p.WriteTo(data[:n], &wcm, dst); err != nil { -// // error handling -// } -// } -// } -// -// -// More multicasting -// -// An application that uses PacketConn may join multiple multicast -// groups. For example, a UDP listener with port 1024 might join two -// different groups across over two different network interfaces by -// using: -// -// c, err := net.ListenPacket("udp6", "[::]:1024") -// if err != nil { -// // error handling -// } -// defer c.Close() -// p := ipv6.NewPacketConn(c) -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff02::1:114")}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff02::2:114")}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en1, &net.UDPAddr{IP: net.ParseIP("ff02::2:114")}); err != nil { -// // error handling -// } -// -// It is possible for multiple UDP listeners that listen on the same -// UDP port to join the same multicast group. The net package will -// provide a socket that listens to a wildcard address with reusable -// UDP port when an appropriate multicast address prefix is passed to -// the net.ListenPacket or net.ListenUDP. -// -// c1, err := net.ListenPacket("udp6", "[ff02::]:1024") -// if err != nil { -// // error handling -// } -// defer c1.Close() -// c2, err := net.ListenPacket("udp6", "[ff02::]:1024") -// if err != nil { -// // error handling -// } -// defer c2.Close() -// p1 := ipv6.NewPacketConn(c1) -// if err := p1.JoinGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff02::114")}); err != nil { -// // error handling -// } -// p2 := ipv6.NewPacketConn(c2) -// if err := p2.JoinGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff02::114")}); err != nil { -// // error handling -// } -// -// Also it is possible for the application to leave or rejoin a -// multicast group on the network interface. -// -// if err := p.LeaveGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff02::114")}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff01::114")}); err != nil { -// // error handling -// } -// -// -// Source-specific multicasting -// -// An application that uses PacketConn on MLDv2 supported platform is -// able to join source-specific multicast groups. -// The application may use JoinSourceSpecificGroup and -// LeaveSourceSpecificGroup for the operation known as "include" mode, -// -// ssmgroup := net.UDPAddr{IP: net.ParseIP("ff32::8000:9")} -// ssmsource := net.UDPAddr{IP: net.ParseIP("fe80::cafe")} -// if err := p.JoinSourceSpecificGroup(en0, &ssmgroup, &ssmsource); err != nil { -// // error handling -// } -// if err := p.LeaveSourceSpecificGroup(en0, &ssmgroup, &ssmsource); err != nil { -// // error handling -// } -// -// or JoinGroup, ExcludeSourceSpecificGroup, -// IncludeSourceSpecificGroup and LeaveGroup for the operation known -// as "exclude" mode. -// -// exclsource := net.UDPAddr{IP: net.ParseIP("fe80::dead")} -// if err := p.JoinGroup(en0, &ssmgroup); err != nil { -// // error handling -// } -// if err := p.ExcludeSourceSpecificGroup(en0, &ssmgroup, &exclsource); err != nil { -// // error handling -// } -// if err := p.LeaveGroup(en0, &ssmgroup); err != nil { -// // error handling -// } -// -// Note that it depends on each platform implementation what happens -// when an application which runs on MLDv2 unsupported platform uses -// JoinSourceSpecificGroup and LeaveSourceSpecificGroup. -// In general the platform tries to fall back to conversations using -// MLDv1 and starts to listen to multicast traffic. -// In the fallback case, ExcludeSourceSpecificGroup and -// IncludeSourceSpecificGroup may return an error. -package ipv6 // import "golang.org/x/net/ipv6" - -// BUG(mikio): This package is not implemented on NaCl and Plan 9. diff --git a/vendor/golang.org/x/net/ipv6/endpoint.go b/vendor/golang.org/x/net/ipv6/endpoint.go deleted file mode 100644 index ce0b0ce27..000000000 --- a/vendor/golang.org/x/net/ipv6/endpoint.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "net" - "syscall" - "time" - - "golang.org/x/net/internal/netreflect" -) - -// BUG(mikio): On Windows, the JoinSourceSpecificGroup, -// LeaveSourceSpecificGroup, ExcludeSourceSpecificGroup and -// IncludeSourceSpecificGroup methods of PacketConn are not -// implemented. - -// A Conn represents a network endpoint that uses IPv6 transport. -// It allows to set basic IP-level socket options such as traffic -// class and hop limit. -type Conn struct { - genericOpt -} - -type genericOpt struct { - net.Conn -} - -func (c *genericOpt) ok() bool { return c != nil && c.Conn != nil } - -// PathMTU returns a path MTU value for the destination associated -// with the endpoint. -func (c *Conn) PathMTU() (int, error) { - if !c.genericOpt.ok() { - return 0, syscall.EINVAL - } - s, err := netreflect.SocketOf(c.genericOpt.Conn) - if err != nil { - return 0, err - } - _, mtu, err := getMTUInfo(s, &sockOpts[ssoPathMTU]) - if err != nil { - return 0, err - } - return mtu, nil -} - -// NewConn returns a new Conn. -func NewConn(c net.Conn) *Conn { - return &Conn{ - genericOpt: genericOpt{Conn: c}, - } -} - -// A PacketConn represents a packet network endpoint that uses IPv6 -// transport. It is used to control several IP-level socket options -// including IPv6 header manipulation. It also provides datagram -// based network I/O methods specific to the IPv6 and higher layer -// protocols such as OSPF, GRE, and UDP. -type PacketConn struct { - genericOpt - dgramOpt - payloadHandler -} - -type dgramOpt struct { - net.PacketConn -} - -func (c *dgramOpt) ok() bool { return c != nil && c.PacketConn != nil } - -// SetControlMessage allows to receive the per packet basis IP-level -// socket options. -func (c *PacketConn) SetControlMessage(cf ControlFlags, on bool) error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - s, err := netreflect.PacketSocketOf(c.dgramOpt.PacketConn) - if err != nil { - return err - } - return setControlMessage(s, &c.payloadHandler.rawOpt, cf, on) -} - -// SetDeadline sets the read and write deadlines associated with the -// endpoint. -func (c *PacketConn) SetDeadline(t time.Time) error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - return c.payloadHandler.SetDeadline(t) -} - -// SetReadDeadline sets the read deadline associated with the -// endpoint. -func (c *PacketConn) SetReadDeadline(t time.Time) error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - return c.payloadHandler.SetReadDeadline(t) -} - -// SetWriteDeadline sets the write deadline associated with the -// endpoint. -func (c *PacketConn) SetWriteDeadline(t time.Time) error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - return c.payloadHandler.SetWriteDeadline(t) -} - -// Close closes the endpoint. -func (c *PacketConn) Close() error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - return c.payloadHandler.Close() -} - -// NewPacketConn returns a new PacketConn using c as its underlying -// transport. -func NewPacketConn(c net.PacketConn) *PacketConn { - return &PacketConn{ - genericOpt: genericOpt{Conn: c.(net.Conn)}, - dgramOpt: dgramOpt{PacketConn: c}, - payloadHandler: payloadHandler{PacketConn: c}, - } -} diff --git a/vendor/golang.org/x/net/ipv6/example_test.go b/vendor/golang.org/x/net/ipv6/example_test.go deleted file mode 100644 index e761aa2a1..000000000 --- a/vendor/golang.org/x/net/ipv6/example_test.go +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "fmt" - "log" - "net" - "os" - "time" - - "golang.org/x/net/icmp" - "golang.org/x/net/ipv6" -) - -func ExampleConn_markingTCP() { - ln, err := net.Listen("tcp", "[::]:1024") - if err != nil { - log.Fatal(err) - } - defer ln.Close() - - for { - c, err := ln.Accept() - if err != nil { - log.Fatal(err) - } - go func(c net.Conn) { - defer c.Close() - if c.RemoteAddr().(*net.TCPAddr).IP.To16() != nil && c.RemoteAddr().(*net.TCPAddr).IP.To4() == nil { - p := ipv6.NewConn(c) - if err := p.SetTrafficClass(0x28); err != nil { // DSCP AF11 - log.Fatal(err) - } - if err := p.SetHopLimit(128); err != nil { - log.Fatal(err) - } - } - if _, err := c.Write([]byte("HELLO-R-U-THERE-ACK")); err != nil { - log.Fatal(err) - } - }(c) - } -} - -func ExamplePacketConn_servingOneShotMulticastDNS() { - c, err := net.ListenPacket("udp6", "[::]:5353") // mDNS over UDP - if err != nil { - log.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - - en0, err := net.InterfaceByName("en0") - if err != nil { - log.Fatal(err) - } - mDNSLinkLocal := net.UDPAddr{IP: net.ParseIP("ff02::fb")} - if err := p.JoinGroup(en0, &mDNSLinkLocal); err != nil { - log.Fatal(err) - } - defer p.LeaveGroup(en0, &mDNSLinkLocal) - if err := p.SetControlMessage(ipv6.FlagDst|ipv6.FlagInterface, true); err != nil { - log.Fatal(err) - } - - var wcm ipv6.ControlMessage - b := make([]byte, 1500) - for { - _, rcm, peer, err := p.ReadFrom(b) - if err != nil { - log.Fatal(err) - } - if !rcm.Dst.IsMulticast() || !rcm.Dst.Equal(mDNSLinkLocal.IP) { - continue - } - wcm.IfIndex = rcm.IfIndex - answers := []byte("FAKE-MDNS-ANSWERS") // fake mDNS answers, you need to implement this - if _, err := p.WriteTo(answers, &wcm, peer); err != nil { - log.Fatal(err) - } - } -} - -func ExamplePacketConn_tracingIPPacketRoute() { - // Tracing an IP packet route to www.google.com. - - const host = "www.google.com" - ips, err := net.LookupIP(host) - if err != nil { - log.Fatal(err) - } - var dst net.IPAddr - for _, ip := range ips { - if ip.To16() != nil && ip.To4() == nil { - dst.IP = ip - fmt.Printf("using %v for tracing an IP packet route to %s\n", dst.IP, host) - break - } - } - if dst.IP == nil { - log.Fatal("no AAAA record found") - } - - c, err := net.ListenPacket("ip6:58", "::") // ICMP for IPv6 - if err != nil { - log.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - - if err := p.SetControlMessage(ipv6.FlagHopLimit|ipv6.FlagSrc|ipv6.FlagDst|ipv6.FlagInterface, true); err != nil { - log.Fatal(err) - } - wm := icmp.Message{ - Type: ipv6.ICMPTypeEchoRequest, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, - Data: []byte("HELLO-R-U-THERE"), - }, - } - var f ipv6.ICMPFilter - f.SetAll(true) - f.Accept(ipv6.ICMPTypeTimeExceeded) - f.Accept(ipv6.ICMPTypeEchoReply) - if err := p.SetICMPFilter(&f); err != nil { - log.Fatal(err) - } - - var wcm ipv6.ControlMessage - rb := make([]byte, 1500) - for i := 1; i <= 64; i++ { // up to 64 hops - wm.Body.(*icmp.Echo).Seq = i - wb, err := wm.Marshal(nil) - if err != nil { - log.Fatal(err) - } - - // In the real world usually there are several - // multiple traffic-engineered paths for each hop. - // You may need to probe a few times to each hop. - begin := time.Now() - wcm.HopLimit = i - if _, err := p.WriteTo(wb, &wcm, &dst); err != nil { - log.Fatal(err) - } - if err := p.SetReadDeadline(time.Now().Add(3 * time.Second)); err != nil { - log.Fatal(err) - } - n, rcm, peer, err := p.ReadFrom(rb) - if err != nil { - if err, ok := err.(net.Error); ok && err.Timeout() { - fmt.Printf("%v\t*\n", i) - continue - } - log.Fatal(err) - } - rm, err := icmp.ParseMessage(58, rb[:n]) - if err != nil { - log.Fatal(err) - } - rtt := time.Since(begin) - - // In the real world you need to determine whether the - // received message is yours using ControlMessage.Src, - // ControlMesage.Dst, icmp.Echo.ID and icmp.Echo.Seq. - switch rm.Type { - case ipv6.ICMPTypeTimeExceeded: - names, _ := net.LookupAddr(peer.String()) - fmt.Printf("%d\t%v %+v %v\n\t%+v\n", i, peer, names, rtt, rcm) - case ipv6.ICMPTypeEchoReply: - names, _ := net.LookupAddr(peer.String()) - fmt.Printf("%d\t%v %+v %v\n\t%+v\n", i, peer, names, rtt, rcm) - return - } - } -} - -func ExamplePacketConn_advertisingOSPFHello() { - c, err := net.ListenPacket("ip6:89", "::") // OSPF for IPv6 - if err != nil { - log.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - - en0, err := net.InterfaceByName("en0") - if err != nil { - log.Fatal(err) - } - allSPFRouters := net.IPAddr{IP: net.ParseIP("ff02::5")} - if err := p.JoinGroup(en0, &allSPFRouters); err != nil { - log.Fatal(err) - } - defer p.LeaveGroup(en0, &allSPFRouters) - - hello := make([]byte, 24) // fake hello data, you need to implement this - ospf := make([]byte, 16) // fake ospf header, you need to implement this - ospf[0] = 3 // version 3 - ospf[1] = 1 // hello packet - ospf = append(ospf, hello...) - if err := p.SetChecksum(true, 12); err != nil { - log.Fatal(err) - } - - cm := ipv6.ControlMessage{ - TrafficClass: 0xc0, // DSCP CS6 - HopLimit: 1, - IfIndex: en0.Index, - } - if _, err := p.WriteTo(ospf, &cm, &allSPFRouters); err != nil { - log.Fatal(err) - } -} diff --git a/vendor/golang.org/x/net/ipv6/gen.go b/vendor/golang.org/x/net/ipv6/gen.go deleted file mode 100644 index 41886ec72..000000000 --- a/vendor/golang.org/x/net/ipv6/gen.go +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -//go:generate go run gen.go - -// This program generates system adaptation constants and types, -// internet protocol constants and tables by reading template files -// and IANA protocol registries. -package main - -import ( - "bytes" - "encoding/xml" - "fmt" - "go/format" - "io" - "io/ioutil" - "net/http" - "os" - "os/exec" - "runtime" - "strconv" - "strings" -) - -func main() { - if err := genzsys(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - if err := geniana(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} - -func genzsys() error { - defs := "defs_" + runtime.GOOS + ".go" - f, err := os.Open(defs) - if err != nil { - if os.IsNotExist(err) { - return nil - } - return err - } - f.Close() - cmd := exec.Command("go", "tool", "cgo", "-godefs", defs) - b, err := cmd.Output() - if err != nil { - return err - } - b, err = format.Source(b) - if err != nil { - return err - } - zsys := "zsys_" + runtime.GOOS + ".go" - switch runtime.GOOS { - case "freebsd", "linux": - zsys = "zsys_" + runtime.GOOS + "_" + runtime.GOARCH + ".go" - } - if err := ioutil.WriteFile(zsys, b, 0644); err != nil { - return err - } - return nil -} - -var registries = []struct { - url string - parse func(io.Writer, io.Reader) error -}{ - { - "http://www.iana.org/assignments/icmpv6-parameters/icmpv6-parameters.xml", - parseICMPv6Parameters, - }, -} - -func geniana() error { - var bb bytes.Buffer - fmt.Fprintf(&bb, "// go generate gen.go\n") - fmt.Fprintf(&bb, "// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT\n\n") - fmt.Fprintf(&bb, "package ipv6\n\n") - for _, r := range registries { - resp, err := http.Get(r.url) - if err != nil { - return err - } - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("got HTTP status code %v for %v\n", resp.StatusCode, r.url) - } - if err := r.parse(&bb, resp.Body); err != nil { - return err - } - fmt.Fprintf(&bb, "\n") - } - b, err := format.Source(bb.Bytes()) - if err != nil { - return err - } - if err := ioutil.WriteFile("iana.go", b, 0644); err != nil { - return err - } - return nil -} - -func parseICMPv6Parameters(w io.Writer, r io.Reader) error { - dec := xml.NewDecoder(r) - var icp icmpv6Parameters - if err := dec.Decode(&icp); err != nil { - return err - } - prs := icp.escape() - fmt.Fprintf(w, "// %s, Updated: %s\n", icp.Title, icp.Updated) - fmt.Fprintf(w, "const (\n") - for _, pr := range prs { - if pr.Name == "" { - continue - } - fmt.Fprintf(w, "ICMPType%s ICMPType = %d", pr.Name, pr.Value) - fmt.Fprintf(w, "// %s\n", pr.OrigName) - } - fmt.Fprintf(w, ")\n\n") - fmt.Fprintf(w, "// %s, Updated: %s\n", icp.Title, icp.Updated) - fmt.Fprintf(w, "var icmpTypes = map[ICMPType]string{\n") - for _, pr := range prs { - if pr.Name == "" { - continue - } - fmt.Fprintf(w, "%d: %q,\n", pr.Value, strings.ToLower(pr.OrigName)) - } - fmt.Fprintf(w, "}\n") - return nil -} - -type icmpv6Parameters struct { - XMLName xml.Name `xml:"registry"` - Title string `xml:"title"` - Updated string `xml:"updated"` - Registries []struct { - Title string `xml:"title"` - Records []struct { - Value string `xml:"value"` - Name string `xml:"name"` - } `xml:"record"` - } `xml:"registry"` -} - -type canonICMPv6ParamRecord struct { - OrigName string - Name string - Value int -} - -func (icp *icmpv6Parameters) escape() []canonICMPv6ParamRecord { - id := -1 - for i, r := range icp.Registries { - if strings.Contains(r.Title, "Type") || strings.Contains(r.Title, "type") { - id = i - break - } - } - if id < 0 { - return nil - } - prs := make([]canonICMPv6ParamRecord, len(icp.Registries[id].Records)) - sr := strings.NewReplacer( - "Messages", "", - "Message", "", - "ICMP", "", - "+", "P", - "-", "", - "/", "", - ".", "", - " ", "", - ) - for i, pr := range icp.Registries[id].Records { - if strings.Contains(pr.Name, "Reserved") || - strings.Contains(pr.Name, "Unassigned") || - strings.Contains(pr.Name, "Deprecated") || - strings.Contains(pr.Name, "Experiment") || - strings.Contains(pr.Name, "experiment") { - continue - } - ss := strings.Split(pr.Name, "\n") - if len(ss) > 1 { - prs[i].Name = strings.Join(ss, " ") - } else { - prs[i].Name = ss[0] - } - s := strings.TrimSpace(prs[i].Name) - prs[i].OrigName = s - prs[i].Name = sr.Replace(s) - prs[i].Value, _ = strconv.Atoi(pr.Value) - } - return prs -} diff --git a/vendor/golang.org/x/net/ipv6/genericopt_posix.go b/vendor/golang.org/x/net/ipv6/genericopt_posix.go deleted file mode 100644 index 0a8d9883d..000000000 --- a/vendor/golang.org/x/net/ipv6/genericopt_posix.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package ipv6 - -import ( - "syscall" - - "golang.org/x/net/internal/netreflect" -) - -// TrafficClass returns the traffic class field value for outgoing -// packets. -func (c *genericOpt) TrafficClass() (int, error) { - if !c.ok() { - return 0, syscall.EINVAL - } - s, err := netreflect.SocketOf(c.Conn) - if err != nil { - return 0, err - } - return getInt(s, &sockOpts[ssoTrafficClass]) -} - -// SetTrafficClass sets the traffic class field value for future -// outgoing packets. -func (c *genericOpt) SetTrafficClass(tclass int) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.SocketOf(c.Conn) - if err != nil { - return err - } - return setInt(s, &sockOpts[ssoTrafficClass], tclass) -} - -// HopLimit returns the hop limit field value for outgoing packets. -func (c *genericOpt) HopLimit() (int, error) { - if !c.ok() { - return 0, syscall.EINVAL - } - s, err := netreflect.SocketOf(c.Conn) - if err != nil { - return 0, err - } - return getInt(s, &sockOpts[ssoHopLimit]) -} - -// SetHopLimit sets the hop limit field value for future outgoing -// packets. -func (c *genericOpt) SetHopLimit(hoplim int) error { - if !c.ok() { - return syscall.EINVAL - } - s, err := netreflect.SocketOf(c.Conn) - if err != nil { - return err - } - return setInt(s, &sockOpts[ssoHopLimit], hoplim) -} diff --git a/vendor/golang.org/x/net/ipv6/genericopt_stub.go b/vendor/golang.org/x/net/ipv6/genericopt_stub.go deleted file mode 100644 index 9dfc57dae..000000000 --- a/vendor/golang.org/x/net/ipv6/genericopt_stub.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package ipv6 - -// TrafficClass returns the traffic class field value for outgoing -// packets. -func (c *genericOpt) TrafficClass() (int, error) { - return 0, errOpNoSupport -} - -// SetTrafficClass sets the traffic class field value for future -// outgoing packets. -func (c *genericOpt) SetTrafficClass(tclass int) error { - return errOpNoSupport -} - -// HopLimit returns the hop limit field value for outgoing packets. -func (c *genericOpt) HopLimit() (int, error) { - return 0, errOpNoSupport -} - -// SetHopLimit sets the hop limit field value for future outgoing -// packets. -func (c *genericOpt) SetHopLimit(hoplim int) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv6/go19_test.go b/vendor/golang.org/x/net/ipv6/go19_test.go deleted file mode 100644 index c7cb057d2..000000000 --- a/vendor/golang.org/x/net/ipv6/go19_test.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.9 - -package ipv6 - -func init() { - disableTests = true -} diff --git a/vendor/golang.org/x/net/ipv6/header.go b/vendor/golang.org/x/net/ipv6/header.go deleted file mode 100644 index e05cb08b2..000000000 --- a/vendor/golang.org/x/net/ipv6/header.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "encoding/binary" - "fmt" - "net" -) - -const ( - Version = 6 // protocol version - HeaderLen = 40 // header length -) - -// A Header represents an IPv6 base header. -type Header struct { - Version int // protocol version - TrafficClass int // traffic class - FlowLabel int // flow label - PayloadLen int // payload length - NextHeader int // next header - HopLimit int // hop limit - Src net.IP // source address - Dst net.IP // destination address -} - -func (h *Header) String() string { - if h == nil { - return "" - } - return fmt.Sprintf("ver=%d tclass=%#x flowlbl=%#x payloadlen=%d nxthdr=%d hoplim=%d src=%v dst=%v", h.Version, h.TrafficClass, h.FlowLabel, h.PayloadLen, h.NextHeader, h.HopLimit, h.Src, h.Dst) -} - -// ParseHeader parses b as an IPv6 base header. -func ParseHeader(b []byte) (*Header, error) { - if len(b) < HeaderLen { - return nil, errHeaderTooShort - } - h := &Header{ - Version: int(b[0]) >> 4, - TrafficClass: int(b[0]&0x0f)<<4 | int(b[1])>>4, - FlowLabel: int(b[1]&0x0f)<<16 | int(b[2])<<8 | int(b[3]), - PayloadLen: int(binary.BigEndian.Uint16(b[4:6])), - NextHeader: int(b[6]), - HopLimit: int(b[7]), - } - h.Src = make(net.IP, net.IPv6len) - copy(h.Src, b[8:24]) - h.Dst = make(net.IP, net.IPv6len) - copy(h.Dst, b[24:40]) - return h, nil -} diff --git a/vendor/golang.org/x/net/ipv6/header_test.go b/vendor/golang.org/x/net/ipv6/header_test.go deleted file mode 100644 index ca11dc23d..000000000 --- a/vendor/golang.org/x/net/ipv6/header_test.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "net" - "reflect" - "strings" - "testing" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/ipv6" -) - -var ( - wireHeaderFromKernel = [ipv6.HeaderLen]byte{ - 0x69, 0x8b, 0xee, 0xf1, - 0xca, 0xfe, 0x2c, 0x01, - 0x20, 0x01, 0x0d, 0xb8, - 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x20, 0x01, 0x0d, 0xb8, - 0x00, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - } - - testHeader = &ipv6.Header{ - Version: ipv6.Version, - TrafficClass: iana.DiffServAF43, - FlowLabel: 0xbeef1, - PayloadLen: 0xcafe, - NextHeader: iana.ProtocolIPv6Frag, - HopLimit: 1, - Src: net.ParseIP("2001:db8:1::1"), - Dst: net.ParseIP("2001:db8:2::1"), - } -) - -func TestParseHeader(t *testing.T) { - h, err := ipv6.ParseHeader(wireHeaderFromKernel[:]) - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(h, testHeader) { - t.Fatalf("got %#v; want %#v", h, testHeader) - } - s := h.String() - if strings.Contains(s, ",") { - t.Fatalf("should be space-separated values: %s", s) - } -} diff --git a/vendor/golang.org/x/net/ipv6/helper.go b/vendor/golang.org/x/net/ipv6/helper.go deleted file mode 100644 index 7a42e5860..000000000 --- a/vendor/golang.org/x/net/ipv6/helper.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "encoding/binary" - "errors" - "net" - "unsafe" -) - -var ( - errMissingAddress = errors.New("missing address") - errHeaderTooShort = errors.New("header too short") - errInvalidConnType = errors.New("invalid conn type") - errOpNoSupport = errors.New("operation not supported") - errNoSuchInterface = errors.New("no such interface") - - nativeEndian binary.ByteOrder -) - -func init() { - i := uint32(1) - b := (*[4]byte)(unsafe.Pointer(&i)) - if b[0] == 1 { - nativeEndian = binary.LittleEndian - } else { - nativeEndian = binary.BigEndian - } -} - -func boolint(b bool) int { - if b { - return 1 - } - return 0 -} - -func netAddrToIP16(a net.Addr) net.IP { - switch v := a.(type) { - case *net.UDPAddr: - if ip := v.IP.To16(); ip != nil && ip.To4() == nil { - return ip - } - case *net.IPAddr: - if ip := v.IP.To16(); ip != nil && ip.To4() == nil { - return ip - } - } - return nil -} diff --git a/vendor/golang.org/x/net/ipv6/iana.go b/vendor/golang.org/x/net/ipv6/iana.go deleted file mode 100644 index 3c6214fb6..000000000 --- a/vendor/golang.org/x/net/ipv6/iana.go +++ /dev/null @@ -1,82 +0,0 @@ -// go generate gen.go -// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT - -package ipv6 - -// Internet Control Message Protocol version 6 (ICMPv6) Parameters, Updated: 2015-07-07 -const ( - ICMPTypeDestinationUnreachable ICMPType = 1 // Destination Unreachable - ICMPTypePacketTooBig ICMPType = 2 // Packet Too Big - ICMPTypeTimeExceeded ICMPType = 3 // Time Exceeded - ICMPTypeParameterProblem ICMPType = 4 // Parameter Problem - ICMPTypeEchoRequest ICMPType = 128 // Echo Request - ICMPTypeEchoReply ICMPType = 129 // Echo Reply - ICMPTypeMulticastListenerQuery ICMPType = 130 // Multicast Listener Query - ICMPTypeMulticastListenerReport ICMPType = 131 // Multicast Listener Report - ICMPTypeMulticastListenerDone ICMPType = 132 // Multicast Listener Done - ICMPTypeRouterSolicitation ICMPType = 133 // Router Solicitation - ICMPTypeRouterAdvertisement ICMPType = 134 // Router Advertisement - ICMPTypeNeighborSolicitation ICMPType = 135 // Neighbor Solicitation - ICMPTypeNeighborAdvertisement ICMPType = 136 // Neighbor Advertisement - ICMPTypeRedirect ICMPType = 137 // Redirect Message - ICMPTypeRouterRenumbering ICMPType = 138 // Router Renumbering - ICMPTypeNodeInformationQuery ICMPType = 139 // ICMP Node Information Query - ICMPTypeNodeInformationResponse ICMPType = 140 // ICMP Node Information Response - ICMPTypeInverseNeighborDiscoverySolicitation ICMPType = 141 // Inverse Neighbor Discovery Solicitation Message - ICMPTypeInverseNeighborDiscoveryAdvertisement ICMPType = 142 // Inverse Neighbor Discovery Advertisement Message - ICMPTypeVersion2MulticastListenerReport ICMPType = 143 // Version 2 Multicast Listener Report - ICMPTypeHomeAgentAddressDiscoveryRequest ICMPType = 144 // Home Agent Address Discovery Request Message - ICMPTypeHomeAgentAddressDiscoveryReply ICMPType = 145 // Home Agent Address Discovery Reply Message - ICMPTypeMobilePrefixSolicitation ICMPType = 146 // Mobile Prefix Solicitation - ICMPTypeMobilePrefixAdvertisement ICMPType = 147 // Mobile Prefix Advertisement - ICMPTypeCertificationPathSolicitation ICMPType = 148 // Certification Path Solicitation Message - ICMPTypeCertificationPathAdvertisement ICMPType = 149 // Certification Path Advertisement Message - ICMPTypeMulticastRouterAdvertisement ICMPType = 151 // Multicast Router Advertisement - ICMPTypeMulticastRouterSolicitation ICMPType = 152 // Multicast Router Solicitation - ICMPTypeMulticastRouterTermination ICMPType = 153 // Multicast Router Termination - ICMPTypeFMIPv6 ICMPType = 154 // FMIPv6 Messages - ICMPTypeRPLControl ICMPType = 155 // RPL Control Message - ICMPTypeILNPv6LocatorUpdate ICMPType = 156 // ILNPv6 Locator Update Message - ICMPTypeDuplicateAddressRequest ICMPType = 157 // Duplicate Address Request - ICMPTypeDuplicateAddressConfirmation ICMPType = 158 // Duplicate Address Confirmation - ICMPTypeMPLControl ICMPType = 159 // MPL Control Message -) - -// Internet Control Message Protocol version 6 (ICMPv6) Parameters, Updated: 2015-07-07 -var icmpTypes = map[ICMPType]string{ - 1: "destination unreachable", - 2: "packet too big", - 3: "time exceeded", - 4: "parameter problem", - 128: "echo request", - 129: "echo reply", - 130: "multicast listener query", - 131: "multicast listener report", - 132: "multicast listener done", - 133: "router solicitation", - 134: "router advertisement", - 135: "neighbor solicitation", - 136: "neighbor advertisement", - 137: "redirect message", - 138: "router renumbering", - 139: "icmp node information query", - 140: "icmp node information response", - 141: "inverse neighbor discovery solicitation message", - 142: "inverse neighbor discovery advertisement message", - 143: "version 2 multicast listener report", - 144: "home agent address discovery request message", - 145: "home agent address discovery reply message", - 146: "mobile prefix solicitation", - 147: "mobile prefix advertisement", - 148: "certification path solicitation message", - 149: "certification path advertisement message", - 151: "multicast router advertisement", - 152: "multicast router solicitation", - 153: "multicast router termination", - 154: "fmipv6 messages", - 155: "rpl control message", - 156: "ilnpv6 locator update message", - 157: "duplicate address request", - 158: "duplicate address confirmation", - 159: "mpl control message", -} diff --git a/vendor/golang.org/x/net/ipv6/icmp.go b/vendor/golang.org/x/net/ipv6/icmp.go deleted file mode 100644 index ff21d1071..000000000 --- a/vendor/golang.org/x/net/ipv6/icmp.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import "golang.org/x/net/internal/iana" - -// BUG(mikio): On Windows, methods related to ICMPFilter are not -// implemented. - -// An ICMPType represents a type of ICMP message. -type ICMPType int - -func (typ ICMPType) String() string { - s, ok := icmpTypes[typ] - if !ok { - return "" - } - return s -} - -// Protocol returns the ICMPv6 protocol number. -func (typ ICMPType) Protocol() int { - return iana.ProtocolIPv6ICMP -} - -// An ICMPFilter represents an ICMP message filter for incoming -// packets. The filter belongs to a packet delivery path on a host and -// it cannot interact with forwarding packets or tunnel-outer packets. -// -// Note: RFC 2460 defines a reasonable role model. A node means a -// device that implements IP. A router means a node that forwards IP -// packets not explicitly addressed to itself, and a host means a node -// that is not a router. -type ICMPFilter struct { - icmpv6Filter -} - -// Accept accepts incoming ICMP packets including the type field value -// typ. -func (f *ICMPFilter) Accept(typ ICMPType) { - f.accept(typ) -} - -// Block blocks incoming ICMP packets including the type field value -// typ. -func (f *ICMPFilter) Block(typ ICMPType) { - f.block(typ) -} - -// SetAll sets the filter action to the filter. -func (f *ICMPFilter) SetAll(block bool) { - f.setAll(block) -} - -// WillBlock reports whether the ICMP type will be blocked. -func (f *ICMPFilter) WillBlock(typ ICMPType) bool { - return f.willBlock(typ) -} diff --git a/vendor/golang.org/x/net/ipv6/icmp_bsd.go b/vendor/golang.org/x/net/ipv6/icmp_bsd.go deleted file mode 100644 index e1a791de4..000000000 --- a/vendor/golang.org/x/net/ipv6/icmp_bsd.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package ipv6 - -func (f *icmpv6Filter) accept(typ ICMPType) { - f.Filt[typ>>5] |= 1 << (uint32(typ) & 31) -} - -func (f *icmpv6Filter) block(typ ICMPType) { - f.Filt[typ>>5] &^= 1 << (uint32(typ) & 31) -} - -func (f *icmpv6Filter) setAll(block bool) { - for i := range f.Filt { - if block { - f.Filt[i] = 0 - } else { - f.Filt[i] = 1<<32 - 1 - } - } -} - -func (f *icmpv6Filter) willBlock(typ ICMPType) bool { - return f.Filt[typ>>5]&(1<<(uint32(typ)&31)) == 0 -} diff --git a/vendor/golang.org/x/net/ipv6/icmp_linux.go b/vendor/golang.org/x/net/ipv6/icmp_linux.go deleted file mode 100644 index 647f6b44f..000000000 --- a/vendor/golang.org/x/net/ipv6/icmp_linux.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -func (f *icmpv6Filter) accept(typ ICMPType) { - f.Data[typ>>5] &^= 1 << (uint32(typ) & 31) -} - -func (f *icmpv6Filter) block(typ ICMPType) { - f.Data[typ>>5] |= 1 << (uint32(typ) & 31) -} - -func (f *icmpv6Filter) setAll(block bool) { - for i := range f.Data { - if block { - f.Data[i] = 1<<32 - 1 - } else { - f.Data[i] = 0 - } - } -} - -func (f *icmpv6Filter) willBlock(typ ICMPType) bool { - return f.Data[typ>>5]&(1<<(uint32(typ)&31)) != 0 -} diff --git a/vendor/golang.org/x/net/ipv6/icmp_solaris.go b/vendor/golang.org/x/net/ipv6/icmp_solaris.go deleted file mode 100644 index 7c23bb1cf..000000000 --- a/vendor/golang.org/x/net/ipv6/icmp_solaris.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -func (f *icmpv6Filter) accept(typ ICMPType) { - f.X__icmp6_filt[typ>>5] |= 1 << (uint32(typ) & 31) -} - -func (f *icmpv6Filter) block(typ ICMPType) { - f.X__icmp6_filt[typ>>5] &^= 1 << (uint32(typ) & 31) -} - -func (f *icmpv6Filter) setAll(block bool) { - for i := range f.X__icmp6_filt { - if block { - f.X__icmp6_filt[i] = 0 - } else { - f.X__icmp6_filt[i] = 1<<32 - 1 - } - } -} - -func (f *icmpv6Filter) willBlock(typ ICMPType) bool { - return f.X__icmp6_filt[typ>>5]&(1<<(uint32(typ)&31)) == 0 -} diff --git a/vendor/golang.org/x/net/ipv6/icmp_stub.go b/vendor/golang.org/x/net/ipv6/icmp_stub.go deleted file mode 100644 index 3cd84e195..000000000 --- a/vendor/golang.org/x/net/ipv6/icmp_stub.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package ipv6 - -type icmpv6Filter struct { -} - -func (f *icmpv6Filter) accept(typ ICMPType) { -} - -func (f *icmpv6Filter) block(typ ICMPType) { -} - -func (f *icmpv6Filter) setAll(block bool) { -} - -func (f *icmpv6Filter) willBlock(typ ICMPType) bool { - return false -} diff --git a/vendor/golang.org/x/net/ipv6/icmp_test.go b/vendor/golang.org/x/net/ipv6/icmp_test.go deleted file mode 100644 index d8e9675dc..000000000 --- a/vendor/golang.org/x/net/ipv6/icmp_test.go +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "net" - "reflect" - "runtime" - "testing" - - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv6" -) - -var icmpStringTests = []struct { - in ipv6.ICMPType - out string -}{ - {ipv6.ICMPTypeDestinationUnreachable, "destination unreachable"}, - - {256, ""}, -} - -func TestICMPString(t *testing.T) { - for _, tt := range icmpStringTests { - s := tt.in.String() - if s != tt.out { - t.Errorf("got %s; want %s", s, tt.out) - } - } -} - -func TestICMPFilter(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - - var f ipv6.ICMPFilter - for _, toggle := range []bool{false, true} { - f.SetAll(toggle) - for _, typ := range []ipv6.ICMPType{ - ipv6.ICMPTypeDestinationUnreachable, - ipv6.ICMPTypeEchoReply, - ipv6.ICMPTypeNeighborSolicitation, - ipv6.ICMPTypeDuplicateAddressConfirmation, - } { - f.Accept(typ) - if f.WillBlock(typ) { - t.Errorf("ipv6.ICMPFilter.Set(%v, false) failed", typ) - } - f.Block(typ) - if !f.WillBlock(typ) { - t.Errorf("ipv6.ICMPFilter.Set(%v, true) failed", typ) - } - } - } -} - -func TestSetICMPFilter(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - c, err := net.ListenPacket("ip6:ipv6-icmp", "::1") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - p := ipv6.NewPacketConn(c) - - var f ipv6.ICMPFilter - f.SetAll(true) - f.Accept(ipv6.ICMPTypeEchoRequest) - f.Accept(ipv6.ICMPTypeEchoReply) - if err := p.SetICMPFilter(&f); err != nil { - t.Fatal(err) - } - kf, err := p.ICMPFilter() - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(kf, &f) { - t.Fatalf("got %#v; want %#v", kf, f) - } -} diff --git a/vendor/golang.org/x/net/ipv6/icmp_windows.go b/vendor/golang.org/x/net/ipv6/icmp_windows.go deleted file mode 100644 index 443cd0736..000000000 --- a/vendor/golang.org/x/net/ipv6/icmp_windows.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -func (f *icmpv6Filter) accept(typ ICMPType) { - // TODO(mikio): implement this -} - -func (f *icmpv6Filter) block(typ ICMPType) { - // TODO(mikio): implement this -} - -func (f *icmpv6Filter) setAll(block bool) { - // TODO(mikio): implement this -} - -func (f *icmpv6Filter) willBlock(typ ICMPType) bool { - // TODO(mikio): implement this - return false -} diff --git a/vendor/golang.org/x/net/ipv6/ipv6_test.go b/vendor/golang.org/x/net/ipv6/ipv6_test.go deleted file mode 100644 index 8d2d23542..000000000 --- a/vendor/golang.org/x/net/ipv6/ipv6_test.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "fmt" - "os" - "testing" -) - -var disableTests = false - -func TestMain(m *testing.M) { - if disableTests { - fmt.Fprintf(os.Stderr, "ipv6 tests disabled in Go 1.9 until netreflect is fixed (Issue 19051)\n") - os.Exit(0) - } - // call flag.Parse() here if TestMain uses flags - os.Exit(m.Run()) -} diff --git a/vendor/golang.org/x/net/ipv6/mocktransponder_test.go b/vendor/golang.org/x/net/ipv6/mocktransponder_test.go deleted file mode 100644 index 6efe56c68..000000000 --- a/vendor/golang.org/x/net/ipv6/mocktransponder_test.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "net" - "testing" -) - -func connector(t *testing.T, network, addr string, done chan<- bool) { - defer func() { done <- true }() - - c, err := net.Dial(network, addr) - if err != nil { - t.Error(err) - return - } - c.Close() -} - -func acceptor(t *testing.T, ln net.Listener, done chan<- bool) { - defer func() { done <- true }() - - c, err := ln.Accept() - if err != nil { - t.Error(err) - return - } - c.Close() -} diff --git a/vendor/golang.org/x/net/ipv6/multicast_test.go b/vendor/golang.org/x/net/ipv6/multicast_test.go deleted file mode 100644 index 69a21cd38..000000000 --- a/vendor/golang.org/x/net/ipv6/multicast_test.go +++ /dev/null @@ -1,264 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "bytes" - "net" - "os" - "runtime" - "testing" - "time" - - "golang.org/x/net/icmp" - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv6" -) - -var packetConnReadWriteMulticastUDPTests = []struct { - addr string - grp, src *net.UDPAddr -}{ - {"[ff02::]:0", &net.UDPAddr{IP: net.ParseIP("ff02::114")}, nil}, // see RFC 4727 - - {"[ff30::8000:0]:0", &net.UDPAddr{IP: net.ParseIP("ff30::8000:1")}, &net.UDPAddr{IP: net.IPv6loopback}}, // see RFC 5771 -} - -func TestPacketConnReadWriteMulticastUDP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - if !nettest.SupportsIPv6MulticastDeliveryOnLoopback() { - t.Skipf("multicast delivery doesn't work correctly on %s", runtime.GOOS) - } - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagMulticast|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - for _, tt := range packetConnReadWriteMulticastUDPTests { - c, err := net.ListenPacket("udp6", tt.addr) - if err != nil { - t.Fatal(err) - } - defer c.Close() - - grp := *tt.grp - grp.Port = c.LocalAddr().(*net.UDPAddr).Port - p := ipv6.NewPacketConn(c) - defer p.Close() - if tt.src == nil { - if err := p.JoinGroup(ifi, &grp); err != nil { - t.Fatal(err) - } - defer p.LeaveGroup(ifi, &grp) - } else { - if err := p.JoinSourceSpecificGroup(ifi, &grp, tt.src); err != nil { - switch runtime.GOOS { - case "freebsd", "linux": - default: // platforms that don't support MLDv2 fail here - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - defer p.LeaveSourceSpecificGroup(ifi, &grp, tt.src) - } - if err := p.SetMulticastInterface(ifi); err != nil { - t.Fatal(err) - } - if _, err := p.MulticastInterface(); err != nil { - t.Fatal(err) - } - if err := p.SetMulticastLoopback(true); err != nil { - t.Fatal(err) - } - if _, err := p.MulticastLoopback(); err != nil { - t.Fatal(err) - } - - cm := ipv6.ControlMessage{ - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced, - Src: net.IPv6loopback, - IfIndex: ifi.Index, - } - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU - wb := []byte("HELLO-R-U-THERE") - - for i, toggle := range []bool{true, false, true} { - if err := p.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - if err := p.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil { - t.Fatal(err) - } - cm.HopLimit = i + 1 - if n, err := p.WriteTo(wb, &cm, &grp); err != nil { - t.Fatal(err) - } else if n != len(wb) { - t.Fatal(err) - } - rb := make([]byte, 128) - if n, _, _, err := p.ReadFrom(rb); err != nil { - t.Fatal(err) - } else if !bytes.Equal(rb[:n], wb) { - t.Fatalf("got %v; want %v", rb[:n], wb) - } - } - } -} - -var packetConnReadWriteMulticastICMPTests = []struct { - grp, src *net.IPAddr -}{ - {&net.IPAddr{IP: net.ParseIP("ff02::114")}, nil}, // see RFC 4727 - - {&net.IPAddr{IP: net.ParseIP("ff30::8000:1")}, &net.IPAddr{IP: net.IPv6loopback}}, // see RFC 5771 -} - -func TestPacketConnReadWriteMulticastICMP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - if !nettest.SupportsIPv6MulticastDeliveryOnLoopback() { - t.Skipf("multicast delivery doesn't work correctly on %s", runtime.GOOS) - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagMulticast|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - for _, tt := range packetConnReadWriteMulticastICMPTests { - c, err := net.ListenPacket("ip6:ipv6-icmp", "::") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - pshicmp := icmp.IPv6PseudoHeader(c.LocalAddr().(*net.IPAddr).IP, tt.grp.IP) - p := ipv6.NewPacketConn(c) - defer p.Close() - if tt.src == nil { - if err := p.JoinGroup(ifi, tt.grp); err != nil { - t.Fatal(err) - } - defer p.LeaveGroup(ifi, tt.grp) - } else { - if err := p.JoinSourceSpecificGroup(ifi, tt.grp, tt.src); err != nil { - switch runtime.GOOS { - case "freebsd", "linux": - default: // platforms that don't support MLDv2 fail here - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - defer p.LeaveSourceSpecificGroup(ifi, tt.grp, tt.src) - } - if err := p.SetMulticastInterface(ifi); err != nil { - t.Fatal(err) - } - if _, err := p.MulticastInterface(); err != nil { - t.Fatal(err) - } - if err := p.SetMulticastLoopback(true); err != nil { - t.Fatal(err) - } - if _, err := p.MulticastLoopback(); err != nil { - t.Fatal(err) - } - - cm := ipv6.ControlMessage{ - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced, - Src: net.IPv6loopback, - IfIndex: ifi.Index, - } - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU - - var f ipv6.ICMPFilter - f.SetAll(true) - f.Accept(ipv6.ICMPTypeEchoReply) - if err := p.SetICMPFilter(&f); err != nil { - t.Fatal(err) - } - - var psh []byte - for i, toggle := range []bool{true, false, true} { - if toggle { - psh = nil - if err := p.SetChecksum(true, 2); err != nil { - // Solaris never allows to - // modify ICMP properties. - if runtime.GOOS != "solaris" { - t.Fatal(err) - } - } - } else { - psh = pshicmp - // Some platforms never allow to - // disable the kernel checksum - // processing. - p.SetChecksum(false, -1) - } - wb, err := (&icmp.Message{ - Type: ipv6.ICMPTypeEchoRequest, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, Seq: i + 1, - Data: []byte("HELLO-R-U-THERE"), - }, - }).Marshal(psh) - if err != nil { - t.Fatal(err) - } - if err := p.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - if err := p.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil { - t.Fatal(err) - } - cm.HopLimit = i + 1 - if n, err := p.WriteTo(wb, &cm, tt.grp); err != nil { - t.Fatal(err) - } else if n != len(wb) { - t.Fatalf("got %v; want %v", n, len(wb)) - } - rb := make([]byte, 128) - if n, _, _, err := p.ReadFrom(rb); err != nil { - switch runtime.GOOS { - case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } else { - if m, err := icmp.ParseMessage(iana.ProtocolIPv6ICMP, rb[:n]); err != nil { - t.Fatal(err) - } else if m.Type != ipv6.ICMPTypeEchoReply || m.Code != 0 { - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv6.ICMPTypeEchoReply, 0) - } - } - } - } -} diff --git a/vendor/golang.org/x/net/ipv6/multicastlistener_test.go b/vendor/golang.org/x/net/ipv6/multicastlistener_test.go deleted file mode 100644 index 044db157b..000000000 --- a/vendor/golang.org/x/net/ipv6/multicastlistener_test.go +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "fmt" - "net" - "runtime" - "testing" - - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv6" -) - -var udpMultipleGroupListenerTests = []net.Addr{ - &net.UDPAddr{IP: net.ParseIP("ff02::114")}, // see RFC 4727 - &net.UDPAddr{IP: net.ParseIP("ff02::1:114")}, - &net.UDPAddr{IP: net.ParseIP("ff02::2:114")}, -} - -func TestUDPSinglePacketConnWithMultipleGroupListeners(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - for _, gaddr := range udpMultipleGroupListenerTests { - c, err := net.ListenPacket("udp6", "[::]:0") // wildcard address with non-reusable port - if err != nil { - t.Fatal(err) - } - defer c.Close() - - p := ipv6.NewPacketConn(c) - var mift []*net.Interface - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - if _, ok := nettest.IsMulticastCapable("ip6", &ifi); !ok { - continue - } - if err := p.JoinGroup(&ifi, gaddr); err != nil { - t.Fatal(err) - } - mift = append(mift, &ift[i]) - } - for _, ifi := range mift { - if err := p.LeaveGroup(ifi, gaddr); err != nil { - t.Fatal(err) - } - } - } -} - -func TestUDPMultiplePacketConnWithMultipleGroupListeners(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - for _, gaddr := range udpMultipleGroupListenerTests { - c1, err := net.ListenPacket("udp6", "[ff02::]:1024") // wildcard address with reusable port - if err != nil { - t.Fatal(err) - } - defer c1.Close() - - c2, err := net.ListenPacket("udp6", "[ff02::]:1024") // wildcard address with reusable port - if err != nil { - t.Fatal(err) - } - defer c2.Close() - - var ps [2]*ipv6.PacketConn - ps[0] = ipv6.NewPacketConn(c1) - ps[1] = ipv6.NewPacketConn(c2) - var mift []*net.Interface - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - if _, ok := nettest.IsMulticastCapable("ip6", &ifi); !ok { - continue - } - for _, p := range ps { - if err := p.JoinGroup(&ifi, gaddr); err != nil { - t.Fatal(err) - } - } - mift = append(mift, &ift[i]) - } - for _, ifi := range mift { - for _, p := range ps { - if err := p.LeaveGroup(ifi, gaddr); err != nil { - t.Fatal(err) - } - } - } - } -} - -func TestUDPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - gaddr := net.IPAddr{IP: net.ParseIP("ff02::114")} // see RFC 4727 - type ml struct { - c *ipv6.PacketConn - ifi *net.Interface - } - var mlt []*ml - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - ip, ok := nettest.IsMulticastCapable("ip6", &ifi) - if !ok { - continue - } - c, err := net.ListenPacket("udp6", fmt.Sprintf("[%s%%%s]:1024", ip.String(), ifi.Name)) // unicast address with non-reusable port - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - if err := p.JoinGroup(&ifi, &gaddr); err != nil { - t.Fatal(err) - } - mlt = append(mlt, &ml{p, &ift[i]}) - } - for _, m := range mlt { - if err := m.c.LeaveGroup(m.ifi, &gaddr); err != nil { - t.Fatal(err) - } - } -} - -func TestIPSinglePacketConnWithSingleGroupListener(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - c, err := net.ListenPacket("ip6:ipv6-icmp", "::") // wildcard address - if err != nil { - t.Fatal(err) - } - defer c.Close() - - p := ipv6.NewPacketConn(c) - gaddr := net.IPAddr{IP: net.ParseIP("ff02::114")} // see RFC 4727 - var mift []*net.Interface - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - if _, ok := nettest.IsMulticastCapable("ip6", &ifi); !ok { - continue - } - if err := p.JoinGroup(&ifi, &gaddr); err != nil { - t.Fatal(err) - } - mift = append(mift, &ift[i]) - } - for _, ifi := range mift { - if err := p.LeaveGroup(ifi, &gaddr); err != nil { - t.Fatal(err) - } - } -} - -func TestIPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) { - switch runtime.GOOS { - case "darwin", "dragonfly", "openbsd": // platforms that return fe80::1%lo0: bind: can't assign requested address - t.Skipf("not supported on %s", runtime.GOOS) - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - gaddr := net.IPAddr{IP: net.ParseIP("ff02::114")} // see RFC 4727 - type ml struct { - c *ipv6.PacketConn - ifi *net.Interface - } - var mlt []*ml - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - ip, ok := nettest.IsMulticastCapable("ip6", &ifi) - if !ok { - continue - } - c, err := net.ListenPacket("ip6:ipv6-icmp", fmt.Sprintf("%s%%%s", ip.String(), ifi.Name)) // unicast address - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - if err := p.JoinGroup(&ifi, &gaddr); err != nil { - t.Fatal(err) - } - mlt = append(mlt, &ml{p, &ift[i]}) - } - for _, m := range mlt { - if err := m.c.LeaveGroup(m.ifi, &gaddr); err != nil { - t.Fatal(err) - } - } -} diff --git a/vendor/golang.org/x/net/ipv6/multicastsockopt_test.go b/vendor/golang.org/x/net/ipv6/multicastsockopt_test.go deleted file mode 100644 index 9e6b902d7..000000000 --- a/vendor/golang.org/x/net/ipv6/multicastsockopt_test.go +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "net" - "runtime" - "testing" - - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv6" -) - -var packetConnMulticastSocketOptionTests = []struct { - net, proto, addr string - grp, src net.Addr -}{ - {"udp6", "", "[ff02::]:0", &net.UDPAddr{IP: net.ParseIP("ff02::114")}, nil}, // see RFC 4727 - {"ip6", ":ipv6-icmp", "::", &net.IPAddr{IP: net.ParseIP("ff02::115")}, nil}, // see RFC 4727 - - {"udp6", "", "[ff30::8000:0]:0", &net.UDPAddr{IP: net.ParseIP("ff30::8000:1")}, &net.UDPAddr{IP: net.IPv6loopback}}, // see RFC 5771 - {"ip6", ":ipv6-icmp", "::", &net.IPAddr{IP: net.ParseIP("ff30::8000:2")}, &net.IPAddr{IP: net.IPv6loopback}}, // see RFC 5771 -} - -func TestPacketConnMulticastSocketOptions(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagMulticast|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - m, ok := nettest.SupportsRawIPSocket() - for _, tt := range packetConnMulticastSocketOptionTests { - if tt.net == "ip6" && !ok { - t.Log(m) - continue - } - c, err := net.ListenPacket(tt.net+tt.proto, tt.addr) - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - defer p.Close() - - if tt.src == nil { - testMulticastSocketOptions(t, p, ifi, tt.grp) - } else { - testSourceSpecificMulticastSocketOptions(t, p, ifi, tt.grp, tt.src) - } - } -} - -type testIPv6MulticastConn interface { - MulticastHopLimit() (int, error) - SetMulticastHopLimit(ttl int) error - MulticastLoopback() (bool, error) - SetMulticastLoopback(bool) error - JoinGroup(*net.Interface, net.Addr) error - LeaveGroup(*net.Interface, net.Addr) error - JoinSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error - LeaveSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error - ExcludeSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error - IncludeSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error -} - -func testMulticastSocketOptions(t *testing.T, c testIPv6MulticastConn, ifi *net.Interface, grp net.Addr) { - const hoplim = 255 - if err := c.SetMulticastHopLimit(hoplim); err != nil { - t.Error(err) - return - } - if v, err := c.MulticastHopLimit(); err != nil { - t.Error(err) - return - } else if v != hoplim { - t.Errorf("got %v; want %v", v, hoplim) - return - } - - for _, toggle := range []bool{true, false} { - if err := c.SetMulticastLoopback(toggle); err != nil { - t.Error(err) - return - } - if v, err := c.MulticastLoopback(); err != nil { - t.Error(err) - return - } else if v != toggle { - t.Errorf("got %v; want %v", v, toggle) - return - } - } - - if err := c.JoinGroup(ifi, grp); err != nil { - t.Error(err) - return - } - if err := c.LeaveGroup(ifi, grp); err != nil { - t.Error(err) - return - } -} - -func testSourceSpecificMulticastSocketOptions(t *testing.T, c testIPv6MulticastConn, ifi *net.Interface, grp, src net.Addr) { - // MCAST_JOIN_GROUP -> MCAST_BLOCK_SOURCE -> MCAST_UNBLOCK_SOURCE -> MCAST_LEAVE_GROUP - if err := c.JoinGroup(ifi, grp); err != nil { - t.Error(err) - return - } - if err := c.ExcludeSourceSpecificGroup(ifi, grp, src); err != nil { - switch runtime.GOOS { - case "freebsd", "linux": - default: // platforms that don't support MLDv2 fail here - t.Logf("not supported on %s", runtime.GOOS) - return - } - t.Error(err) - return - } - if err := c.IncludeSourceSpecificGroup(ifi, grp, src); err != nil { - t.Error(err) - return - } - if err := c.LeaveGroup(ifi, grp); err != nil { - t.Error(err) - return - } - - // MCAST_JOIN_SOURCE_GROUP -> MCAST_LEAVE_SOURCE_GROUP - if err := c.JoinSourceSpecificGroup(ifi, grp, src); err != nil { - t.Error(err) - return - } - if err := c.LeaveSourceSpecificGroup(ifi, grp, src); err != nil { - t.Error(err) - return - } - - // MCAST_JOIN_SOURCE_GROUP -> MCAST_LEAVE_GROUP - if err := c.JoinSourceSpecificGroup(ifi, grp, src); err != nil { - t.Error(err) - return - } - if err := c.LeaveGroup(ifi, grp); err != nil { - t.Error(err) - return - } -} diff --git a/vendor/golang.org/x/net/ipv6/payload.go b/vendor/golang.org/x/net/ipv6/payload.go deleted file mode 100644 index d9f822510..000000000 --- a/vendor/golang.org/x/net/ipv6/payload.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import "net" - -// BUG(mikio): On Windows, the ControlMessage for ReadFrom and WriteTo -// methods of PacketConn is not implemented. - -// A payloadHandler represents the IPv6 datagram payload handler. -type payloadHandler struct { - net.PacketConn - rawOpt -} - -func (c *payloadHandler) ok() bool { return c != nil && c.PacketConn != nil } diff --git a/vendor/golang.org/x/net/ipv6/payload_cmsg.go b/vendor/golang.org/x/net/ipv6/payload_cmsg.go deleted file mode 100644 index e853c8059..000000000 --- a/vendor/golang.org/x/net/ipv6/payload_cmsg.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !nacl,!plan9,!windows - -package ipv6 - -import ( - "net" - "syscall" -) - -// ReadFrom reads a payload of the received IPv6 datagram, from the -// endpoint c, copying the payload into b. It returns the number of -// bytes copied into b, the control message cm and the source address -// src of the received datagram. -func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) { - if !c.ok() { - return 0, nil, nil, syscall.EINVAL - } - oob := newControlMessage(&c.rawOpt) - var oobn int - switch c := c.PacketConn.(type) { - case *net.UDPConn: - if n, oobn, _, src, err = c.ReadMsgUDP(b, oob); err != nil { - return 0, nil, nil, err - } - case *net.IPConn: - if n, oobn, _, src, err = c.ReadMsgIP(b, oob); err != nil { - return 0, nil, nil, err - } - default: - return 0, nil, nil, errInvalidConnType - } - if cm, err = parseControlMessage(oob[:oobn]); err != nil { - return 0, nil, nil, err - } - if cm != nil { - cm.Src = netAddrToIP16(src) - } - return -} - -// WriteTo writes a payload of the IPv6 datagram, to the destination -// address dst through the endpoint c, copying the payload from b. It -// returns the number of bytes written. The control message cm allows -// the IPv6 header fields and the datagram path to be specified. The -// cm may be nil if control of the outgoing datagram is not required. -func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) { - if !c.ok() { - return 0, syscall.EINVAL - } - oob := marshalControlMessage(cm) - if dst == nil { - return 0, errMissingAddress - } - switch c := c.PacketConn.(type) { - case *net.UDPConn: - n, _, err = c.WriteMsgUDP(b, oob, dst.(*net.UDPAddr)) - case *net.IPConn: - n, _, err = c.WriteMsgIP(b, oob, dst.(*net.IPAddr)) - default: - return 0, errInvalidConnType - } - if err != nil { - return 0, err - } - return -} diff --git a/vendor/golang.org/x/net/ipv6/payload_nocmsg.go b/vendor/golang.org/x/net/ipv6/payload_nocmsg.go deleted file mode 100644 index 99a43542b..000000000 --- a/vendor/golang.org/x/net/ipv6/payload_nocmsg.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 windows - -package ipv6 - -import ( - "net" - "syscall" -) - -// ReadFrom reads a payload of the received IPv6 datagram, from the -// endpoint c, copying the payload into b. It returns the number of -// bytes copied into b, the control message cm and the source address -// src of the received datagram. -func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) { - if !c.ok() { - return 0, nil, nil, syscall.EINVAL - } - if n, src, err = c.PacketConn.ReadFrom(b); err != nil { - return 0, nil, nil, err - } - return -} - -// WriteTo writes a payload of the IPv6 datagram, to the destination -// address dst through the endpoint c, copying the payload from b. It -// returns the number of bytes written. The control message cm allows -// the IPv6 header fields and the datagram path to be specified. The -// cm may be nil if control of the outgoing datagram is not required. -func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) { - if !c.ok() { - return 0, syscall.EINVAL - } - if dst == nil { - return 0, errMissingAddress - } - return c.PacketConn.WriteTo(b, dst) -} diff --git a/vendor/golang.org/x/net/ipv6/readwrite_test.go b/vendor/golang.org/x/net/ipv6/readwrite_test.go deleted file mode 100644 index 41f59be5a..000000000 --- a/vendor/golang.org/x/net/ipv6/readwrite_test.go +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "bytes" - "net" - "runtime" - "strings" - "sync" - "testing" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv6" -) - -func benchmarkUDPListener() (net.PacketConn, net.Addr, error) { - c, err := net.ListenPacket("udp6", "[::1]:0") - if err != nil { - return nil, nil, err - } - dst, err := net.ResolveUDPAddr("udp6", c.LocalAddr().String()) - if err != nil { - c.Close() - return nil, nil, err - } - return c, dst, nil -} - -func BenchmarkReadWriteNetUDP(b *testing.B) { - if !supportsIPv6 { - b.Skip("ipv6 is not supported") - } - - c, dst, err := benchmarkUDPListener() - if err != nil { - b.Fatal(err) - } - defer c.Close() - - wb, rb := []byte("HELLO-R-U-THERE"), make([]byte, 128) - b.ResetTimer() - for i := 0; i < b.N; i++ { - benchmarkReadWriteNetUDP(b, c, wb, rb, dst) - } -} - -func benchmarkReadWriteNetUDP(b *testing.B, c net.PacketConn, wb, rb []byte, dst net.Addr) { - if _, err := c.WriteTo(wb, dst); err != nil { - b.Fatal(err) - } - if _, _, err := c.ReadFrom(rb); err != nil { - b.Fatal(err) - } -} - -func BenchmarkReadWriteIPv6UDP(b *testing.B) { - if !supportsIPv6 { - b.Skip("ipv6 is not supported") - } - - c, dst, err := benchmarkUDPListener() - if err != nil { - b.Fatal(err) - } - defer c.Close() - - p := ipv6.NewPacketConn(c) - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU - if err := p.SetControlMessage(cf, true); err != nil { - b.Fatal(err) - } - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagLoopback) - - wb, rb := []byte("HELLO-R-U-THERE"), make([]byte, 128) - b.ResetTimer() - for i := 0; i < b.N; i++ { - benchmarkReadWriteIPv6UDP(b, p, wb, rb, dst, ifi) - } -} - -func benchmarkReadWriteIPv6UDP(b *testing.B, p *ipv6.PacketConn, wb, rb []byte, dst net.Addr, ifi *net.Interface) { - cm := ipv6.ControlMessage{ - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced, - HopLimit: 1, - } - if ifi != nil { - cm.IfIndex = ifi.Index - } - if n, err := p.WriteTo(wb, &cm, dst); err != nil { - b.Fatal(err) - } else if n != len(wb) { - b.Fatalf("got %v; want %v", n, len(wb)) - } - if _, _, _, err := p.ReadFrom(rb); err != nil { - b.Fatal(err) - } -} - -func TestPacketConnConcurrentReadWriteUnicastUDP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - c, err := net.ListenPacket("udp6", "[::1]:0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - defer p.Close() - - dst, err := net.ResolveUDPAddr("udp6", c.LocalAddr().String()) - if err != nil { - t.Fatal(err) - } - - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagLoopback) - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU - wb := []byte("HELLO-R-U-THERE") - - if err := p.SetControlMessage(cf, true); err != nil { // probe before test - if nettest.ProtocolNotSupported(err) { - t.Skipf("not supported on %s", runtime.GOOS) - } - t.Fatal(err) - } - - var wg sync.WaitGroup - reader := func() { - defer wg.Done() - rb := make([]byte, 128) - if n, cm, _, err := p.ReadFrom(rb); err != nil { - t.Error(err) - return - } else if !bytes.Equal(rb[:n], wb) { - t.Errorf("got %v; want %v", rb[:n], wb) - return - } else { - s := cm.String() - if strings.Contains(s, ",") { - t.Errorf("should be space-separated values: %s", s) - } - } - } - writer := func(toggle bool) { - defer wg.Done() - cm := ipv6.ControlMessage{ - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced, - Src: net.IPv6loopback, - } - if ifi != nil { - cm.IfIndex = ifi.Index - } - if err := p.SetControlMessage(cf, toggle); err != nil { - t.Error(err) - return - } - if n, err := p.WriteTo(wb, &cm, dst); err != nil { - t.Error(err) - return - } else if n != len(wb) { - t.Errorf("got %v; want %v", n, len(wb)) - return - } - } - - const N = 10 - wg.Add(N) - for i := 0; i < N; i++ { - go reader() - } - wg.Add(2 * N) - for i := 0; i < 2*N; i++ { - go writer(i%2 != 0) - } - wg.Add(N) - for i := 0; i < N; i++ { - go reader() - } - wg.Wait() -} diff --git a/vendor/golang.org/x/net/ipv6/sockopt.go b/vendor/golang.org/x/net/ipv6/sockopt.go deleted file mode 100644 index f0cfc2f94..000000000 --- a/vendor/golang.org/x/net/ipv6/sockopt.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -// Sticky socket options -const ( - ssoTrafficClass = iota // header field for unicast packet, RFC 3542 - ssoHopLimit // header field for unicast packet, RFC 3493 - ssoMulticastInterface // outbound interface for multicast packet, RFC 3493 - ssoMulticastHopLimit // header field for multicast packet, RFC 3493 - ssoMulticastLoopback // loopback for multicast packet, RFC 3493 - ssoReceiveTrafficClass // header field on received packet, RFC 3542 - ssoReceiveHopLimit // header field on received packet, RFC 2292 or 3542 - ssoReceivePacketInfo // incbound or outbound packet path, RFC 2292 or 3542 - ssoReceivePathMTU // path mtu, RFC 3542 - ssoPathMTU // path mtu, RFC 3542 - ssoChecksum // packet checksum, RFC 2292 or 3542 - ssoICMPFilter // icmp filter, RFC 2292 or 3542 - ssoJoinGroup // any-source multicast, RFC 3493 - ssoLeaveGroup // any-source multicast, RFC 3493 - ssoJoinSourceGroup // source-specific multicast - ssoLeaveSourceGroup // source-specific multicast - ssoBlockSourceGroup // any-source or source-specific multicast - ssoUnblockSourceGroup // any-source or source-specific multicast - ssoMax -) - -// Sticky socket option value types -const ( - ssoTypeInt = iota + 1 - ssoTypeInterface - ssoTypeICMPFilter - ssoTypeMTUInfo - ssoTypeIPMreq - ssoTypeGroupReq - ssoTypeGroupSourceReq -) - -// A sockOpt represents a binding for sticky socket option. -type sockOpt struct { - level int // option level - name int // option name, must be equal or greater than 1 - typ int // option value type, must be equal or greater than 1 -} diff --git a/vendor/golang.org/x/net/ipv6/sockopt_asmreq_posix.go b/vendor/golang.org/x/net/ipv6/sockopt_asmreq_posix.go deleted file mode 100644 index cd36739df..000000000 --- a/vendor/golang.org/x/net/ipv6/sockopt_asmreq_posix.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package ipv6 - -import ( - "net" - "os" - "unsafe" -) - -func setsockoptIPMreq(s uintptr, opt *sockOpt, ifi *net.Interface, grp net.IP) error { - var mreq ipv6Mreq - copy(mreq.Multiaddr[:], grp) - if ifi != nil { - mreq.setIfindex(ifi.Index) - } - return os.NewSyscallError("setsockopt", setsockopt(s, opt.level, opt.name, unsafe.Pointer(&mreq), sizeofIPv6Mreq)) -} diff --git a/vendor/golang.org/x/net/ipv6/sockopt_posix.go b/vendor/golang.org/x/net/ipv6/sockopt_posix.go deleted file mode 100644 index e0a3fa693..000000000 --- a/vendor/golang.org/x/net/ipv6/sockopt_posix.go +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package ipv6 - -import ( - "net" - "os" - "unsafe" -) - -func getInt(s uintptr, opt *sockOpt) (int, error) { - if opt.name < 1 || opt.typ != ssoTypeInt { - return 0, errOpNoSupport - } - var i int32 - l := uint32(4) - if err := getsockopt(s, opt.level, opt.name, unsafe.Pointer(&i), &l); err != nil { - return 0, os.NewSyscallError("getsockopt", err) - } - return int(i), nil -} - -func setInt(s uintptr, opt *sockOpt, v int) error { - if opt.name < 1 || opt.typ != ssoTypeInt { - return errOpNoSupport - } - i := int32(v) - return os.NewSyscallError("setsockopt", setsockopt(s, opt.level, opt.name, unsafe.Pointer(&i), 4)) -} - -func getInterface(s uintptr, opt *sockOpt) (*net.Interface, error) { - if opt.name < 1 || opt.typ != ssoTypeInterface { - return nil, errOpNoSupport - } - var i int32 - l := uint32(4) - if err := getsockopt(s, opt.level, opt.name, unsafe.Pointer(&i), &l); err != nil { - return nil, os.NewSyscallError("getsockopt", err) - } - if i == 0 { - return nil, nil - } - ifi, err := net.InterfaceByIndex(int(i)) - if err != nil { - return nil, err - } - return ifi, nil -} - -func setInterface(s uintptr, opt *sockOpt, ifi *net.Interface) error { - if opt.name < 1 || opt.typ != ssoTypeInterface { - return errOpNoSupport - } - var i int32 - if ifi != nil { - i = int32(ifi.Index) - } - return os.NewSyscallError("setsockopt", setsockopt(s, opt.level, opt.name, unsafe.Pointer(&i), 4)) -} - -func getICMPFilter(s uintptr, opt *sockOpt) (*ICMPFilter, error) { - if opt.name < 1 || opt.typ != ssoTypeICMPFilter { - return nil, errOpNoSupport - } - var f ICMPFilter - l := uint32(sizeofICMPv6Filter) - if err := getsockopt(s, opt.level, opt.name, unsafe.Pointer(&f.icmpv6Filter), &l); err != nil { - return nil, os.NewSyscallError("getsockopt", err) - } - return &f, nil -} - -func setICMPFilter(s uintptr, opt *sockOpt, f *ICMPFilter) error { - if opt.name < 1 || opt.typ != ssoTypeICMPFilter { - return errOpNoSupport - } - return os.NewSyscallError("setsockopt", setsockopt(s, opt.level, opt.name, unsafe.Pointer(&f.icmpv6Filter), sizeofICMPv6Filter)) -} - -func getMTUInfo(s uintptr, opt *sockOpt) (*net.Interface, int, error) { - if opt.name < 1 || opt.typ != ssoTypeMTUInfo { - return nil, 0, errOpNoSupport - } - var mi ipv6Mtuinfo - l := uint32(sizeofIPv6Mtuinfo) - if err := getsockopt(s, opt.level, opt.name, unsafe.Pointer(&mi), &l); err != nil { - return nil, 0, os.NewSyscallError("getsockopt", err) - } - if mi.Addr.Scope_id == 0 { - return nil, int(mi.Mtu), nil - } - ifi, err := net.InterfaceByIndex(int(mi.Addr.Scope_id)) - if err != nil { - return nil, 0, err - } - return ifi, int(mi.Mtu), nil -} - -func setGroup(s uintptr, opt *sockOpt, ifi *net.Interface, grp net.IP) error { - if opt.name < 1 { - return errOpNoSupport - } - switch opt.typ { - case ssoTypeIPMreq: - return setsockoptIPMreq(s, opt, ifi, grp) - case ssoTypeGroupReq: - return setsockoptGroupReq(s, opt, ifi, grp) - default: - return errOpNoSupport - } -} - -func setSourceGroup(s uintptr, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error { - if opt.name < 1 || opt.typ != ssoTypeGroupSourceReq { - return errOpNoSupport - } - return setsockoptGroupSourceReq(s, opt, ifi, grp, src) -} diff --git a/vendor/golang.org/x/net/ipv6/sockopt_ssmreq_stub.go b/vendor/golang.org/x/net/ipv6/sockopt_ssmreq_stub.go deleted file mode 100644 index 1a8829092..000000000 --- a/vendor/golang.org/x/net/ipv6/sockopt_ssmreq_stub.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!freebsd,!linux,!solaris - -package ipv6 - -import "net" - -func setsockoptGroupReq(s uintptr, opt *sockOpt, ifi *net.Interface, grp net.IP) error { - return errOpNoSupport -} - -func setsockoptGroupSourceReq(s uintptr, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv6/sockopt_ssmreq_unix.go b/vendor/golang.org/x/net/ipv6/sockopt_ssmreq_unix.go deleted file mode 100644 index f3668aefc..000000000 --- a/vendor/golang.org/x/net/ipv6/sockopt_ssmreq_unix.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin freebsd linux solaris - -package ipv6 - -import ( - "net" - "os" - "unsafe" -) - -var freebsd32o64 bool - -func setsockoptGroupReq(s uintptr, opt *sockOpt, ifi *net.Interface, grp net.IP) error { - var gr groupReq - if ifi != nil { - gr.Interface = uint32(ifi.Index) - } - gr.setGroup(grp) - var p unsafe.Pointer - var l uint32 - if freebsd32o64 { - var d [sizeofGroupReq + 4]byte - s := (*[sizeofGroupReq]byte)(unsafe.Pointer(&gr)) - copy(d[:4], s[:4]) - copy(d[8:], s[4:]) - p = unsafe.Pointer(&d[0]) - l = sizeofGroupReq + 4 - } else { - p = unsafe.Pointer(&gr) - l = sizeofGroupReq - } - return os.NewSyscallError("setsockopt", setsockopt(s, opt.level, opt.name, p, l)) -} - -func setsockoptGroupSourceReq(s uintptr, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error { - var gsr groupSourceReq - if ifi != nil { - gsr.Interface = uint32(ifi.Index) - } - gsr.setSourceGroup(grp, src) - var p unsafe.Pointer - var l uint32 - if freebsd32o64 { - var d [sizeofGroupSourceReq + 4]byte - s := (*[sizeofGroupSourceReq]byte)(unsafe.Pointer(&gsr)) - copy(d[:4], s[:4]) - copy(d[8:], s[4:]) - p = unsafe.Pointer(&d[0]) - l = sizeofGroupSourceReq + 4 - } else { - p = unsafe.Pointer(&gsr) - l = sizeofGroupSourceReq - } - return os.NewSyscallError("setsockopt", setsockopt(s, opt.level, opt.name, p, l)) -} diff --git a/vendor/golang.org/x/net/ipv6/sockopt_stub.go b/vendor/golang.org/x/net/ipv6/sockopt_stub.go deleted file mode 100644 index 6d59a00c2..000000000 --- a/vendor/golang.org/x/net/ipv6/sockopt_stub.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package ipv6 - -import "net" - -func getMTUInfo(s uintptr, opt *sockOpt) (*net.Interface, int, error) { - return nil, 0, errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv6/sockopt_test.go b/vendor/golang.org/x/net/ipv6/sockopt_test.go deleted file mode 100644 index 774338dbf..000000000 --- a/vendor/golang.org/x/net/ipv6/sockopt_test.go +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "fmt" - "net" - "runtime" - "testing" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv6" -) - -var supportsIPv6 bool = nettest.SupportsIPv6() - -func TestConnInitiatorPathMTU(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - ln, err := net.Listen("tcp6", "[::1]:0") - if err != nil { - t.Fatal(err) - } - defer ln.Close() - - done := make(chan bool) - go acceptor(t, ln, done) - - c, err := net.Dial("tcp6", ln.Addr().String()) - if err != nil { - t.Fatal(err) - } - defer c.Close() - - if pmtu, err := ipv6.NewConn(c).PathMTU(); err != nil { - switch runtime.GOOS { - case "darwin": // older darwin kernels don't support IPV6_PATHMTU option - t.Logf("not supported on %s", runtime.GOOS) - default: - t.Fatal(err) - } - } else { - t.Logf("path mtu for %v: %v", c.RemoteAddr(), pmtu) - } - - <-done -} - -func TestConnResponderPathMTU(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - ln, err := net.Listen("tcp6", "[::1]:0") - if err != nil { - t.Fatal(err) - } - defer ln.Close() - - done := make(chan bool) - go connector(t, "tcp6", ln.Addr().String(), done) - - c, err := ln.Accept() - if err != nil { - t.Fatal(err) - } - defer c.Close() - - if pmtu, err := ipv6.NewConn(c).PathMTU(); err != nil { - switch runtime.GOOS { - case "darwin": // older darwin kernels don't support IPV6_PATHMTU option - t.Logf("not supported on %s", runtime.GOOS) - default: - t.Fatal(err) - } - } else { - t.Logf("path mtu for %v: %v", c.RemoteAddr(), pmtu) - } - - <-done -} - -func TestPacketConnChecksum(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - c, err := net.ListenPacket(fmt.Sprintf("ip6:%d", iana.ProtocolOSPFIGP), "::") // OSPF for IPv6 - if err != nil { - t.Fatal(err) - } - defer c.Close() - - p := ipv6.NewPacketConn(c) - offset := 12 // see RFC 5340 - - for _, toggle := range []bool{false, true} { - if err := p.SetChecksum(toggle, offset); err != nil { - if toggle { - t.Fatalf("ipv6.PacketConn.SetChecksum(%v, %v) failed: %v", toggle, offset, err) - } else { - // Some platforms never allow to disable the kernel - // checksum processing. - t.Logf("ipv6.PacketConn.SetChecksum(%v, %v) failed: %v", toggle, offset, err) - } - } - if on, offset, err := p.Checksum(); err != nil { - t.Fatal(err) - } else { - t.Logf("kernel checksum processing enabled=%v, offset=%v", on, offset) - } - } -} diff --git a/vendor/golang.org/x/net/ipv6/sys_bsd.go b/vendor/golang.org/x/net/ipv6/sys_bsd.go deleted file mode 100644 index c22f8ac63..000000000 --- a/vendor/golang.org/x/net/ipv6/sys_bsd.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build dragonfly netbsd openbsd - -package ipv6 - -import ( - "net" - "syscall" - - "golang.org/x/net/internal/iana" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTrafficClass: {sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, - ctlHopLimit: {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, - ctlPacketInfo: {sysIPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, - ctlNextHop: {sysIPV6_NEXTHOP, sizeofSockaddrInet6, marshalNextHop, parseNextHop}, - ctlPathMTU: {sysIPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTrafficClass: {iana.ProtocolIPv6, sysIPV6_TCLASS, ssoTypeInt}, - ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt}, - ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt}, - ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt}, - ssoReceiveTrafficClass: {iana.ProtocolIPv6, sysIPV6_RECVTCLASS, ssoTypeInt}, - ssoReceiveHopLimit: {iana.ProtocolIPv6, sysIPV6_RECVHOPLIMIT, ssoTypeInt}, - ssoReceivePacketInfo: {iana.ProtocolIPv6, sysIPV6_RECVPKTINFO, ssoTypeInt}, - ssoReceivePathMTU: {iana.ProtocolIPv6, sysIPV6_RECVPATHMTU, ssoTypeInt}, - ssoPathMTU: {iana.ProtocolIPv6, sysIPV6_PATHMTU, ssoTypeMTUInfo}, - ssoChecksum: {iana.ProtocolIPv6, sysIPV6_CHECKSUM, ssoTypeInt}, - ssoICMPFilter: {iana.ProtocolIPv6ICMP, sysICMP6_FILTER, ssoTypeICMPFilter}, - ssoJoinGroup: {iana.ProtocolIPv6, sysIPV6_JOIN_GROUP, ssoTypeIPMreq}, - ssoLeaveGroup: {iana.ProtocolIPv6, sysIPV6_LEAVE_GROUP, ssoTypeIPMreq}, - } -) - -func (sa *sockaddrInet6) setSockaddr(ip net.IP, i int) { - sa.Len = sizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], ip) - sa.Scope_id = uint32(i) -} - -func (pi *inet6Pktinfo) setIfindex(i int) { - pi.Ifindex = uint32(i) -} - -func (mreq *ipv6Mreq) setIfindex(i int) { - mreq.Interface = uint32(i) -} diff --git a/vendor/golang.org/x/net/ipv6/sys_darwin.go b/vendor/golang.org/x/net/ipv6/sys_darwin.go deleted file mode 100644 index ffcc9d4c4..000000000 --- a/vendor/golang.org/x/net/ipv6/sys_darwin.go +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "net" - "strconv" - "strings" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlHopLimit: {sysIPV6_2292HOPLIMIT, 4, marshal2292HopLimit, parseHopLimit}, - ctlPacketInfo: {sysIPV6_2292PKTINFO, sizeofInet6Pktinfo, marshal2292PacketInfo, parsePacketInfo}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt}, - ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt}, - ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt}, - ssoReceiveHopLimit: {iana.ProtocolIPv6, sysIPV6_2292HOPLIMIT, ssoTypeInt}, - ssoReceivePacketInfo: {iana.ProtocolIPv6, sysIPV6_2292PKTINFO, ssoTypeInt}, - ssoChecksum: {iana.ProtocolIPv6, sysIPV6_CHECKSUM, ssoTypeInt}, - ssoICMPFilter: {iana.ProtocolIPv6ICMP, sysICMP6_FILTER, ssoTypeICMPFilter}, - ssoJoinGroup: {iana.ProtocolIPv6, sysIPV6_JOIN_GROUP, ssoTypeIPMreq}, - ssoLeaveGroup: {iana.ProtocolIPv6, sysIPV6_LEAVE_GROUP, ssoTypeIPMreq}, - } -) - -func init() { - // Seems like kern.osreldate is veiled on latest OS X. We use - // kern.osrelease instead. - s, err := syscall.Sysctl("kern.osrelease") - if err != nil { - return - } - ss := strings.Split(s, ".") - if len(ss) == 0 { - return - } - // The IP_PKTINFO and protocol-independent multicast API were - // introduced in OS X 10.7 (Darwin 11). But it looks like - // those features require OS X 10.8 (Darwin 12) or above. - // See http://support.apple.com/kb/HT1633. - if mjver, err := strconv.Atoi(ss[0]); err != nil || mjver < 12 { - return - } - ctlOpts[ctlTrafficClass] = ctlOpt{sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass} - ctlOpts[ctlHopLimit] = ctlOpt{sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit} - ctlOpts[ctlPacketInfo] = ctlOpt{sysIPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo} - ctlOpts[ctlNextHop] = ctlOpt{sysIPV6_NEXTHOP, sizeofSockaddrInet6, marshalNextHop, parseNextHop} - ctlOpts[ctlPathMTU] = ctlOpt{sysIPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU} - sockOpts[ssoTrafficClass] = sockOpt{iana.ProtocolIPv6, sysIPV6_TCLASS, ssoTypeInt} - sockOpts[ssoReceiveTrafficClass] = sockOpt{iana.ProtocolIPv6, sysIPV6_RECVTCLASS, ssoTypeInt} - sockOpts[ssoReceiveHopLimit] = sockOpt{iana.ProtocolIPv6, sysIPV6_RECVHOPLIMIT, ssoTypeInt} - sockOpts[ssoReceivePacketInfo] = sockOpt{iana.ProtocolIPv6, sysIPV6_RECVPKTINFO, ssoTypeInt} - sockOpts[ssoReceivePathMTU] = sockOpt{iana.ProtocolIPv6, sysIPV6_RECVPATHMTU, ssoTypeInt} - sockOpts[ssoPathMTU] = sockOpt{iana.ProtocolIPv6, sysIPV6_PATHMTU, ssoTypeMTUInfo} - sockOpts[ssoJoinGroup] = sockOpt{iana.ProtocolIPv6, sysMCAST_JOIN_GROUP, ssoTypeGroupReq} - sockOpts[ssoLeaveGroup] = sockOpt{iana.ProtocolIPv6, sysMCAST_LEAVE_GROUP, ssoTypeGroupReq} - sockOpts[ssoJoinSourceGroup] = sockOpt{iana.ProtocolIPv6, sysMCAST_JOIN_SOURCE_GROUP, ssoTypeGroupSourceReq} - sockOpts[ssoLeaveSourceGroup] = sockOpt{iana.ProtocolIPv6, sysMCAST_LEAVE_SOURCE_GROUP, ssoTypeGroupSourceReq} - sockOpts[ssoBlockSourceGroup] = sockOpt{iana.ProtocolIPv6, sysMCAST_BLOCK_SOURCE, ssoTypeGroupSourceReq} - sockOpts[ssoUnblockSourceGroup] = sockOpt{iana.ProtocolIPv6, sysMCAST_UNBLOCK_SOURCE, ssoTypeGroupSourceReq} -} - -func (sa *sockaddrInet6) setSockaddr(ip net.IP, i int) { - sa.Len = sizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], ip) - sa.Scope_id = uint32(i) -} - -func (pi *inet6Pktinfo) setIfindex(i int) { - pi.Ifindex = uint32(i) -} - -func (mreq *ipv6Mreq) setIfindex(i int) { - mreq.Interface = uint32(i) -} - -func (gr *groupReq) setGroup(grp net.IP) { - sa := (*sockaddrInet6)(unsafe.Pointer(uintptr(unsafe.Pointer(gr)) + 4)) - sa.Len = sizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], grp) -} - -func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sockaddrInet6)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 4)) - sa.Len = sizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], grp) - sa = (*sockaddrInet6)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 132)) - sa.Len = sizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv6/sys_freebsd.go b/vendor/golang.org/x/net/ipv6/sys_freebsd.go deleted file mode 100644 index fd5204beb..000000000 --- a/vendor/golang.org/x/net/ipv6/sys_freebsd.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "net" - "runtime" - "strings" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTrafficClass: {sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, - ctlHopLimit: {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, - ctlPacketInfo: {sysIPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, - ctlNextHop: {sysIPV6_NEXTHOP, sizeofSockaddrInet6, marshalNextHop, parseNextHop}, - ctlPathMTU: {sysIPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTrafficClass: {iana.ProtocolIPv6, sysIPV6_TCLASS, ssoTypeInt}, - ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt}, - ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt}, - ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt}, - ssoReceiveTrafficClass: {iana.ProtocolIPv6, sysIPV6_RECVTCLASS, ssoTypeInt}, - ssoReceiveHopLimit: {iana.ProtocolIPv6, sysIPV6_RECVHOPLIMIT, ssoTypeInt}, - ssoReceivePacketInfo: {iana.ProtocolIPv6, sysIPV6_RECVPKTINFO, ssoTypeInt}, - ssoReceivePathMTU: {iana.ProtocolIPv6, sysIPV6_RECVPATHMTU, ssoTypeInt}, - ssoPathMTU: {iana.ProtocolIPv6, sysIPV6_PATHMTU, ssoTypeMTUInfo}, - ssoChecksum: {iana.ProtocolIPv6, sysIPV6_CHECKSUM, ssoTypeInt}, - ssoICMPFilter: {iana.ProtocolIPv6ICMP, sysICMP6_FILTER, ssoTypeICMPFilter}, - ssoJoinGroup: {iana.ProtocolIPv6, sysMCAST_JOIN_GROUP, ssoTypeGroupReq}, - ssoLeaveGroup: {iana.ProtocolIPv6, sysMCAST_LEAVE_GROUP, ssoTypeGroupReq}, - ssoJoinSourceGroup: {iana.ProtocolIPv6, sysMCAST_JOIN_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {iana.ProtocolIPv6, sysMCAST_LEAVE_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {iana.ProtocolIPv6, sysMCAST_BLOCK_SOURCE, ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {iana.ProtocolIPv6, sysMCAST_UNBLOCK_SOURCE, ssoTypeGroupSourceReq}, - } -) - -func init() { - if runtime.GOOS == "freebsd" && runtime.GOARCH == "386" { - archs, _ := syscall.Sysctl("kern.supported_archs") - for _, s := range strings.Fields(archs) { - if s == "amd64" { - freebsd32o64 = true - break - } - } - } -} - -func (sa *sockaddrInet6) setSockaddr(ip net.IP, i int) { - sa.Len = sizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], ip) - sa.Scope_id = uint32(i) -} - -func (pi *inet6Pktinfo) setIfindex(i int) { - pi.Ifindex = uint32(i) -} - -func (mreq *ipv6Mreq) setIfindex(i int) { - mreq.Interface = uint32(i) -} - -func (gr *groupReq) setGroup(grp net.IP) { - sa := (*sockaddrInet6)(unsafe.Pointer(&gr.Group)) - sa.Len = sizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], grp) -} - -func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sockaddrInet6)(unsafe.Pointer(&gsr.Group)) - sa.Len = sizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], grp) - sa = (*sockaddrInet6)(unsafe.Pointer(&gsr.Source)) - sa.Len = sizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv6/sys_linux.go b/vendor/golang.org/x/net/ipv6/sys_linux.go deleted file mode 100644 index 42f5f7853..000000000 --- a/vendor/golang.org/x/net/ipv6/sys_linux.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "net" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTrafficClass: {sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, - ctlHopLimit: {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, - ctlPacketInfo: {sysIPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, - ctlPathMTU: {sysIPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTrafficClass: {iana.ProtocolIPv6, sysIPV6_TCLASS, ssoTypeInt}, - ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt}, - ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt}, - ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt}, - ssoReceiveTrafficClass: {iana.ProtocolIPv6, sysIPV6_RECVTCLASS, ssoTypeInt}, - ssoReceiveHopLimit: {iana.ProtocolIPv6, sysIPV6_RECVHOPLIMIT, ssoTypeInt}, - ssoReceivePacketInfo: {iana.ProtocolIPv6, sysIPV6_RECVPKTINFO, ssoTypeInt}, - ssoReceivePathMTU: {iana.ProtocolIPv6, sysIPV6_RECVPATHMTU, ssoTypeInt}, - ssoPathMTU: {iana.ProtocolIPv6, sysIPV6_PATHMTU, ssoTypeMTUInfo}, - ssoChecksum: {iana.ProtocolReserved, sysIPV6_CHECKSUM, ssoTypeInt}, - ssoICMPFilter: {iana.ProtocolIPv6ICMP, sysICMPV6_FILTER, ssoTypeICMPFilter}, - ssoJoinGroup: {iana.ProtocolIPv6, sysMCAST_JOIN_GROUP, ssoTypeGroupReq}, - ssoLeaveGroup: {iana.ProtocolIPv6, sysMCAST_LEAVE_GROUP, ssoTypeGroupReq}, - ssoJoinSourceGroup: {iana.ProtocolIPv6, sysMCAST_JOIN_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {iana.ProtocolIPv6, sysMCAST_LEAVE_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {iana.ProtocolIPv6, sysMCAST_BLOCK_SOURCE, ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {iana.ProtocolIPv6, sysMCAST_UNBLOCK_SOURCE, ssoTypeGroupSourceReq}, - } -) - -func (sa *sockaddrInet6) setSockaddr(ip net.IP, i int) { - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], ip) - sa.Scope_id = uint32(i) -} - -func (pi *inet6Pktinfo) setIfindex(i int) { - pi.Ifindex = int32(i) -} - -func (mreq *ipv6Mreq) setIfindex(i int) { - mreq.Ifindex = int32(i) -} - -func (gr *groupReq) setGroup(grp net.IP) { - sa := (*sockaddrInet6)(unsafe.Pointer(&gr.Group)) - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], grp) -} - -func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sockaddrInet6)(unsafe.Pointer(&gsr.Group)) - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], grp) - sa = (*sockaddrInet6)(unsafe.Pointer(&gsr.Source)) - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv6/sys_linux_386.s b/vendor/golang.org/x/net/ipv6/sys_linux_386.s deleted file mode 100644 index b85551a5c..000000000 --- a/vendor/golang.org/x/net/ipv6/sys_linux_386.s +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#include "textflag.h" - -TEXT ·socketcall(SB),NOSPLIT,$0-36 - JMP syscall·socketcall(SB) diff --git a/vendor/golang.org/x/net/ipv6/sys_solaris.go b/vendor/golang.org/x/net/ipv6/sys_solaris.go deleted file mode 100644 index 9bd2d66fd..000000000 --- a/vendor/golang.org/x/net/ipv6/sys_solaris.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "net" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTrafficClass: {sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, - ctlHopLimit: {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, - ctlPacketInfo: {sysIPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, - ctlNextHop: {sysIPV6_NEXTHOP, sizeofSockaddrInet6, marshalNextHop, parseNextHop}, - ctlPathMTU: {sysIPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTrafficClass: {iana.ProtocolIPv6, sysIPV6_TCLASS, ssoTypeInt}, - ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt}, - ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt}, - ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt}, - ssoReceiveTrafficClass: {iana.ProtocolIPv6, sysIPV6_RECVTCLASS, ssoTypeInt}, - ssoReceiveHopLimit: {iana.ProtocolIPv6, sysIPV6_RECVHOPLIMIT, ssoTypeInt}, - ssoReceivePacketInfo: {iana.ProtocolIPv6, sysIPV6_RECVPKTINFO, ssoTypeInt}, - ssoReceivePathMTU: {iana.ProtocolIPv6, sysIPV6_RECVPATHMTU, ssoTypeInt}, - ssoPathMTU: {iana.ProtocolIPv6, sysIPV6_PATHMTU, ssoTypeMTUInfo}, - ssoChecksum: {iana.ProtocolIPv6, sysIPV6_CHECKSUM, ssoTypeInt}, - ssoICMPFilter: {iana.ProtocolIPv6ICMP, sysICMP6_FILTER, ssoTypeICMPFilter}, - ssoJoinGroup: {iana.ProtocolIPv6, sysMCAST_JOIN_GROUP, ssoTypeGroupReq}, - ssoLeaveGroup: {iana.ProtocolIPv6, sysMCAST_LEAVE_GROUP, ssoTypeGroupReq}, - ssoJoinSourceGroup: {iana.ProtocolIPv6, sysMCAST_JOIN_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {iana.ProtocolIPv6, sysMCAST_LEAVE_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {iana.ProtocolIPv6, sysMCAST_BLOCK_SOURCE, ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {iana.ProtocolIPv6, sysMCAST_UNBLOCK_SOURCE, ssoTypeGroupSourceReq}, - } -) - -func (sa *sockaddrInet6) setSockaddr(ip net.IP, i int) { - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], ip) - sa.Scope_id = uint32(i) -} - -func (pi *inet6Pktinfo) setIfindex(i int) { - pi.Ifindex = uint32(i) -} - -func (mreq *ipv6Mreq) setIfindex(i int) { - mreq.Interface = uint32(i) -} - -func (gr *groupReq) setGroup(grp net.IP) { - sa := (*sockaddrInet6)(unsafe.Pointer(uintptr(unsafe.Pointer(gr)) + 4)) - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], grp) -} - -func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sockaddrInet6)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 4)) - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], grp) - sa = (*sockaddrInet6)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 260)) - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv6/sys_solaris_amd64.s b/vendor/golang.org/x/net/ipv6/sys_solaris_amd64.s deleted file mode 100644 index 39d76af79..000000000 --- a/vendor/golang.org/x/net/ipv6/sys_solaris_amd64.s +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#include "textflag.h" - -TEXT ·sysvicall6(SB),NOSPLIT,$0-88 - JMP syscall·sysvicall6(SB) diff --git a/vendor/golang.org/x/net/ipv6/sys_stub.go b/vendor/golang.org/x/net/ipv6/sys_stub.go deleted file mode 100644 index 7663bfc09..000000000 --- a/vendor/golang.org/x/net/ipv6/sys_stub.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package ipv6 - -var ( - ctlOpts = [ctlMax]ctlOpt{} - - sockOpts = [ssoMax]sockOpt{} -) diff --git a/vendor/golang.org/x/net/ipv6/sys_windows.go b/vendor/golang.org/x/net/ipv6/sys_windows.go deleted file mode 100644 index 003c507d5..000000000 --- a/vendor/golang.org/x/net/ipv6/sys_windows.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "net" - "syscall" - - "golang.org/x/net/internal/iana" -) - -const ( - // See ws2tcpip.h. - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - sysIPV6_PKTINFO = 0x13 - - sizeofSockaddrInet6 = 0x1c - - sizeofIPv6Mreq = 0x14 - sizeofIPv6Mtuinfo = 0x20 - sizeofICMPv6Filter = 0 -) - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type icmpv6Filter struct { - // TODO(mikio): implement this -} - -var ( - ctlOpts = [ctlMax]ctlOpt{} - - sockOpts = [ssoMax]sockOpt{ - ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt}, - ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt}, - ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt}, - ssoJoinGroup: {iana.ProtocolIPv6, sysIPV6_JOIN_GROUP, ssoTypeIPMreq}, - ssoLeaveGroup: {iana.ProtocolIPv6, sysIPV6_LEAVE_GROUP, ssoTypeIPMreq}, - } -) - -func (sa *sockaddrInet6) setSockaddr(ip net.IP, i int) { - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], ip) - sa.Scope_id = uint32(i) -} - -func (mreq *ipv6Mreq) setIfindex(i int) { - mreq.Interface = uint32(i) -} diff --git a/vendor/golang.org/x/net/ipv6/syscall_linux_386.go b/vendor/golang.org/x/net/ipv6/syscall_linux_386.go deleted file mode 100644 index 5184dbe88..000000000 --- a/vendor/golang.org/x/net/ipv6/syscall_linux_386.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "syscall" - "unsafe" -) - -const ( - sysGETSOCKOPT = 0xf - sysSETSOCKOPT = 0xe -) - -func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) - -func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error { - if _, errno := socketcall(sysGETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 { - return error(errno) - } - return nil -} - -func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error { - if _, errno := socketcall(sysSETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 { - return error(errno) - } - return nil -} diff --git a/vendor/golang.org/x/net/ipv6/syscall_solaris.go b/vendor/golang.org/x/net/ipv6/syscall_solaris.go deleted file mode 100644 index 2a5c8ee47..000000000 --- a/vendor/golang.org/x/net/ipv6/syscall_solaris.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "syscall" - "unsafe" -) - -//go:cgo_import_dynamic libc___xnet_getsockopt __xnet_getsockopt "libsocket.so" -//go:cgo_import_dynamic libc_setsockopt setsockopt "libsocket.so" - -//go:linkname procGetsockopt libc___xnet_getsockopt -//go:linkname procSetsockopt libc_setsockopt - -var ( - procGetsockopt uintptr - procSetsockopt uintptr -) - -func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (uintptr, uintptr, syscall.Errno) - -func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error { - _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procGetsockopt)), 5, s, uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0) - if errno != 0 { - return error(errno) - } - return nil -} - -func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error { - if _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procSetsockopt)), 5, s, uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 { - return error(errno) - } - return nil -} diff --git a/vendor/golang.org/x/net/ipv6/syscall_unix.go b/vendor/golang.org/x/net/ipv6/syscall_unix.go deleted file mode 100644 index 58a75b528..000000000 --- a/vendor/golang.org/x/net/ipv6/syscall_unix.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux,!386 netbsd openbsd - -package ipv6 - -import ( - "syscall" - "unsafe" -) - -func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error { - if _, _, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 { - return error(errno) - } - return nil -} - -func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error { - if _, _, errno := syscall.Syscall6(syscall.SYS_SETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 { - return error(errno) - } - return nil -} diff --git a/vendor/golang.org/x/net/ipv6/syscall_windows.go b/vendor/golang.org/x/net/ipv6/syscall_windows.go deleted file mode 100644 index c1f649d38..000000000 --- a/vendor/golang.org/x/net/ipv6/syscall_windows.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "syscall" - "unsafe" -) - -func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error { - return syscall.Getsockopt(syscall.Handle(s), int32(level), int32(name), (*byte)(v), (*int32)(unsafe.Pointer(l))) -} - -func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error { - return syscall.Setsockopt(syscall.Handle(s), int32(level), int32(name), (*byte)(v), int32(l)) -} diff --git a/vendor/golang.org/x/net/ipv6/unicast_test.go b/vendor/golang.org/x/net/ipv6/unicast_test.go deleted file mode 100644 index 406d07128..000000000 --- a/vendor/golang.org/x/net/ipv6/unicast_test.go +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "bytes" - "net" - "os" - "runtime" - "testing" - "time" - - "golang.org/x/net/icmp" - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv6" -) - -func TestPacketConnReadWriteUnicastUDP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - c, err := net.ListenPacket("udp6", "[::1]:0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - defer p.Close() - - dst, err := net.ResolveUDPAddr("udp6", c.LocalAddr().String()) - if err != nil { - t.Fatal(err) - } - - cm := ipv6.ControlMessage{ - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced, - Src: net.IPv6loopback, - } - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagLoopback) - if ifi != nil { - cm.IfIndex = ifi.Index - } - wb := []byte("HELLO-R-U-THERE") - - for i, toggle := range []bool{true, false, true} { - if err := p.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Skipf("not supported on %s", runtime.GOOS) - } - t.Fatal(err) - } - cm.HopLimit = i + 1 - if err := p.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if n, err := p.WriteTo(wb, &cm, dst); err != nil { - t.Fatal(err) - } else if n != len(wb) { - t.Fatalf("got %v; want %v", n, len(wb)) - } - rb := make([]byte, 128) - if err := p.SetReadDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if n, _, _, err := p.ReadFrom(rb); err != nil { - t.Fatal(err) - } else if !bytes.Equal(rb[:n], wb) { - t.Fatalf("got %v; want %v", rb[:n], wb) - } - } -} - -func TestPacketConnReadWriteUnicastICMP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - c, err := net.ListenPacket("ip6:ipv6-icmp", "::1") - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - defer p.Close() - - dst, err := net.ResolveIPAddr("ip6", "::1") - if err != nil { - t.Fatal(err) - } - - pshicmp := icmp.IPv6PseudoHeader(c.LocalAddr().(*net.IPAddr).IP, dst.IP) - cm := ipv6.ControlMessage{ - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced, - Src: net.IPv6loopback, - } - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagLoopback) - if ifi != nil { - cm.IfIndex = ifi.Index - } - - var f ipv6.ICMPFilter - f.SetAll(true) - f.Accept(ipv6.ICMPTypeEchoReply) - if err := p.SetICMPFilter(&f); err != nil { - t.Fatal(err) - } - - var psh []byte - for i, toggle := range []bool{true, false, true} { - if toggle { - psh = nil - if err := p.SetChecksum(true, 2); err != nil { - // Solaris never allows to modify - // ICMP properties. - if runtime.GOOS != "solaris" { - t.Fatal(err) - } - } - } else { - psh = pshicmp - // Some platforms never allow to disable the - // kernel checksum processing. - p.SetChecksum(false, -1) - } - wb, err := (&icmp.Message{ - Type: ipv6.ICMPTypeEchoRequest, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, Seq: i + 1, - Data: []byte("HELLO-R-U-THERE"), - }, - }).Marshal(psh) - if err != nil { - t.Fatal(err) - } - if err := p.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Skipf("not supported on %s", runtime.GOOS) - } - t.Fatal(err) - } - cm.HopLimit = i + 1 - if err := p.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if n, err := p.WriteTo(wb, &cm, dst); err != nil { - t.Fatal(err) - } else if n != len(wb) { - t.Fatalf("got %v; want %v", n, len(wb)) - } - rb := make([]byte, 128) - if err := p.SetReadDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if n, _, _, err := p.ReadFrom(rb); err != nil { - switch runtime.GOOS { - case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } else { - if m, err := icmp.ParseMessage(iana.ProtocolIPv6ICMP, rb[:n]); err != nil { - t.Fatal(err) - } else if m.Type != ipv6.ICMPTypeEchoReply || m.Code != 0 { - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv6.ICMPTypeEchoReply, 0) - } - } - } -} diff --git a/vendor/golang.org/x/net/ipv6/unicastsockopt_test.go b/vendor/golang.org/x/net/ipv6/unicastsockopt_test.go deleted file mode 100644 index e175dccf5..000000000 --- a/vendor/golang.org/x/net/ipv6/unicastsockopt_test.go +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "net" - "runtime" - "testing" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv6" -) - -func TestConnUnicastSocketOptions(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - ln, err := net.Listen("tcp6", "[::1]:0") - if err != nil { - t.Fatal(err) - } - defer ln.Close() - - errc := make(chan error, 1) - go func() { - c, err := ln.Accept() - if err != nil { - errc <- err - return - } - errc <- c.Close() - }() - - c, err := net.Dial("tcp6", ln.Addr().String()) - if err != nil { - t.Fatal(err) - } - defer c.Close() - - testUnicastSocketOptions(t, ipv6.NewConn(c)) - - if err := <-errc; err != nil { - t.Errorf("server: %v", err) - } -} - -var packetConnUnicastSocketOptionTests = []struct { - net, proto, addr string -}{ - {"udp6", "", "[::1]:0"}, - {"ip6", ":ipv6-icmp", "::1"}, -} - -func TestPacketConnUnicastSocketOptions(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - m, ok := nettest.SupportsRawIPSocket() - for _, tt := range packetConnUnicastSocketOptionTests { - if tt.net == "ip6" && !ok { - t.Log(m) - continue - } - c, err := net.ListenPacket(tt.net+tt.proto, tt.addr) - if err != nil { - t.Fatal(err) - } - defer c.Close() - - testUnicastSocketOptions(t, ipv6.NewPacketConn(c)) - } -} - -type testIPv6UnicastConn interface { - TrafficClass() (int, error) - SetTrafficClass(int) error - HopLimit() (int, error) - SetHopLimit(int) error -} - -func testUnicastSocketOptions(t *testing.T, c testIPv6UnicastConn) { - tclass := iana.DiffServCS0 | iana.NotECNTransport - if err := c.SetTrafficClass(tclass); err != nil { - switch runtime.GOOS { - case "darwin": // older darwin kernels don't support IPV6_TCLASS option - t.Logf("not supported on %s", runtime.GOOS) - goto next - } - t.Fatal(err) - } - if v, err := c.TrafficClass(); err != nil { - t.Fatal(err) - } else if v != tclass { - t.Fatalf("got %v; want %v", v, tclass) - } - -next: - hoplim := 255 - if err := c.SetHopLimit(hoplim); err != nil { - t.Fatal(err) - } - if v, err := c.HopLimit(); err != nil { - t.Fatal(err) - } else if v != hoplim { - t.Fatalf("got %v; want %v", v, hoplim) - } -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_darwin.go b/vendor/golang.org/x/net/ipv6/zsys_darwin.go deleted file mode 100644 index 6aab1dfab..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_darwin.go +++ /dev/null @@ -1,131 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_darwin.go - -package ipv6 - -const ( - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - - sysIPV6_PORTRANGE = 0xe - sysICMP6_FILTER = 0x12 - sysIPV6_2292PKTINFO = 0x13 - sysIPV6_2292HOPLIMIT = 0x14 - sysIPV6_2292NEXTHOP = 0x15 - sysIPV6_2292HOPOPTS = 0x16 - sysIPV6_2292DSTOPTS = 0x17 - sysIPV6_2292RTHDR = 0x18 - - sysIPV6_2292PKTOPTIONS = 0x19 - - sysIPV6_CHECKSUM = 0x1a - sysIPV6_V6ONLY = 0x1b - - sysIPV6_IPSEC_POLICY = 0x1c - - sysIPV6_RECVTCLASS = 0x23 - sysIPV6_TCLASS = 0x24 - - sysIPV6_RTHDRDSTOPTS = 0x39 - - sysIPV6_RECVPKTINFO = 0x3d - - sysIPV6_RECVHOPLIMIT = 0x25 - sysIPV6_RECVRTHDR = 0x26 - sysIPV6_RECVHOPOPTS = 0x27 - sysIPV6_RECVDSTOPTS = 0x28 - - sysIPV6_USE_MIN_MTU = 0x2a - sysIPV6_RECVPATHMTU = 0x2b - - sysIPV6_PATHMTU = 0x2c - - sysIPV6_PKTINFO = 0x2e - sysIPV6_HOPLIMIT = 0x2f - sysIPV6_NEXTHOP = 0x30 - sysIPV6_HOPOPTS = 0x31 - sysIPV6_DSTOPTS = 0x32 - sysIPV6_RTHDR = 0x33 - - sysIPV6_AUTOFLOWLABEL = 0x3b - - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_PREFER_TEMPADDR = 0x3f - - sysIPV6_MSFILTER = 0x4a - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sysIPV6_BOUND_IF = 0x7d - - sysIPV6_PORTRANGE_DEFAULT = 0x0 - sysIPV6_PORTRANGE_HIGH = 0x1 - sysIPV6_PORTRANGE_LOW = 0x2 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - - sizeofIPv6Mreq = 0x14 - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 - - sizeofICMPv6Filter = 0x20 -) - -type sockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex uint32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -type icmpv6Filter struct { - Filt [8]uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [128]byte -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [128]byte - Pad_cgo_1 [128]byte -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_dragonfly.go b/vendor/golang.org/x/net/ipv6/zsys_dragonfly.go deleted file mode 100644 index d2de804d8..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_dragonfly.go +++ /dev/null @@ -1,88 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_dragonfly.go - -package ipv6 - -const ( - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - sysIPV6_PORTRANGE = 0xe - sysICMP6_FILTER = 0x12 - - sysIPV6_CHECKSUM = 0x1a - sysIPV6_V6ONLY = 0x1b - - sysIPV6_IPSEC_POLICY = 0x1c - - sysIPV6_RTHDRDSTOPTS = 0x23 - sysIPV6_RECVPKTINFO = 0x24 - sysIPV6_RECVHOPLIMIT = 0x25 - sysIPV6_RECVRTHDR = 0x26 - sysIPV6_RECVHOPOPTS = 0x27 - sysIPV6_RECVDSTOPTS = 0x28 - - sysIPV6_USE_MIN_MTU = 0x2a - sysIPV6_RECVPATHMTU = 0x2b - - sysIPV6_PATHMTU = 0x2c - - sysIPV6_PKTINFO = 0x2e - sysIPV6_HOPLIMIT = 0x2f - sysIPV6_NEXTHOP = 0x30 - sysIPV6_HOPOPTS = 0x31 - sysIPV6_DSTOPTS = 0x32 - sysIPV6_RTHDR = 0x33 - - sysIPV6_RECVTCLASS = 0x39 - - sysIPV6_AUTOFLOWLABEL = 0x3b - - sysIPV6_TCLASS = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_PREFER_TEMPADDR = 0x3f - - sysIPV6_PORTRANGE_DEFAULT = 0x0 - sysIPV6_PORTRANGE_HIGH = 0x1 - sysIPV6_PORTRANGE_LOW = 0x2 - - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - - sizeofIPv6Mreq = 0x14 - - sizeofICMPv6Filter = 0x20 -) - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex uint32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -type icmpv6Filter struct { - Filt [8]uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_freebsd_386.go b/vendor/golang.org/x/net/ipv6/zsys_freebsd_386.go deleted file mode 100644 index 919e572d4..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_freebsd_386.go +++ /dev/null @@ -1,122 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package ipv6 - -const ( - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - sysIPV6_PORTRANGE = 0xe - sysICMP6_FILTER = 0x12 - - sysIPV6_CHECKSUM = 0x1a - sysIPV6_V6ONLY = 0x1b - - sysIPV6_IPSEC_POLICY = 0x1c - - sysIPV6_RTHDRDSTOPTS = 0x23 - - sysIPV6_RECVPKTINFO = 0x24 - sysIPV6_RECVHOPLIMIT = 0x25 - sysIPV6_RECVRTHDR = 0x26 - sysIPV6_RECVHOPOPTS = 0x27 - sysIPV6_RECVDSTOPTS = 0x28 - - sysIPV6_USE_MIN_MTU = 0x2a - sysIPV6_RECVPATHMTU = 0x2b - - sysIPV6_PATHMTU = 0x2c - - sysIPV6_PKTINFO = 0x2e - sysIPV6_HOPLIMIT = 0x2f - sysIPV6_NEXTHOP = 0x30 - sysIPV6_HOPOPTS = 0x31 - sysIPV6_DSTOPTS = 0x32 - sysIPV6_RTHDR = 0x33 - - sysIPV6_RECVTCLASS = 0x39 - - sysIPV6_AUTOFLOWLABEL = 0x3b - - sysIPV6_TCLASS = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_PREFER_TEMPADDR = 0x3f - - sysIPV6_BINDANY = 0x40 - - sysIPV6_MSFILTER = 0x4a - - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sysIPV6_PORTRANGE_DEFAULT = 0x0 - sysIPV6_PORTRANGE_HIGH = 0x1 - sysIPV6_PORTRANGE_LOW = 0x2 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - - sizeofIPv6Mreq = 0x14 - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 - - sizeofICMPv6Filter = 0x20 -) - -type sockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex uint32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -type groupReq struct { - Interface uint32 - Group sockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group sockaddrStorage - Source sockaddrStorage -} - -type icmpv6Filter struct { - Filt [8]uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_freebsd_amd64.go b/vendor/golang.org/x/net/ipv6/zsys_freebsd_amd64.go deleted file mode 100644 index cb8141f9c..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_freebsd_amd64.go +++ /dev/null @@ -1,124 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package ipv6 - -const ( - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - sysIPV6_PORTRANGE = 0xe - sysICMP6_FILTER = 0x12 - - sysIPV6_CHECKSUM = 0x1a - sysIPV6_V6ONLY = 0x1b - - sysIPV6_IPSEC_POLICY = 0x1c - - sysIPV6_RTHDRDSTOPTS = 0x23 - - sysIPV6_RECVPKTINFO = 0x24 - sysIPV6_RECVHOPLIMIT = 0x25 - sysIPV6_RECVRTHDR = 0x26 - sysIPV6_RECVHOPOPTS = 0x27 - sysIPV6_RECVDSTOPTS = 0x28 - - sysIPV6_USE_MIN_MTU = 0x2a - sysIPV6_RECVPATHMTU = 0x2b - - sysIPV6_PATHMTU = 0x2c - - sysIPV6_PKTINFO = 0x2e - sysIPV6_HOPLIMIT = 0x2f - sysIPV6_NEXTHOP = 0x30 - sysIPV6_HOPOPTS = 0x31 - sysIPV6_DSTOPTS = 0x32 - sysIPV6_RTHDR = 0x33 - - sysIPV6_RECVTCLASS = 0x39 - - sysIPV6_AUTOFLOWLABEL = 0x3b - - sysIPV6_TCLASS = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_PREFER_TEMPADDR = 0x3f - - sysIPV6_BINDANY = 0x40 - - sysIPV6_MSFILTER = 0x4a - - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sysIPV6_PORTRANGE_DEFAULT = 0x0 - sysIPV6_PORTRANGE_HIGH = 0x1 - sysIPV6_PORTRANGE_LOW = 0x2 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - - sizeofIPv6Mreq = 0x14 - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPv6Filter = 0x20 -) - -type sockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex uint32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sockaddrStorage - Source sockaddrStorage -} - -type icmpv6Filter struct { - Filt [8]uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm.go b/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm.go deleted file mode 100644 index cb8141f9c..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm.go +++ /dev/null @@ -1,124 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package ipv6 - -const ( - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - sysIPV6_PORTRANGE = 0xe - sysICMP6_FILTER = 0x12 - - sysIPV6_CHECKSUM = 0x1a - sysIPV6_V6ONLY = 0x1b - - sysIPV6_IPSEC_POLICY = 0x1c - - sysIPV6_RTHDRDSTOPTS = 0x23 - - sysIPV6_RECVPKTINFO = 0x24 - sysIPV6_RECVHOPLIMIT = 0x25 - sysIPV6_RECVRTHDR = 0x26 - sysIPV6_RECVHOPOPTS = 0x27 - sysIPV6_RECVDSTOPTS = 0x28 - - sysIPV6_USE_MIN_MTU = 0x2a - sysIPV6_RECVPATHMTU = 0x2b - - sysIPV6_PATHMTU = 0x2c - - sysIPV6_PKTINFO = 0x2e - sysIPV6_HOPLIMIT = 0x2f - sysIPV6_NEXTHOP = 0x30 - sysIPV6_HOPOPTS = 0x31 - sysIPV6_DSTOPTS = 0x32 - sysIPV6_RTHDR = 0x33 - - sysIPV6_RECVTCLASS = 0x39 - - sysIPV6_AUTOFLOWLABEL = 0x3b - - sysIPV6_TCLASS = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_PREFER_TEMPADDR = 0x3f - - sysIPV6_BINDANY = 0x40 - - sysIPV6_MSFILTER = 0x4a - - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sysIPV6_PORTRANGE_DEFAULT = 0x0 - sysIPV6_PORTRANGE_HIGH = 0x1 - sysIPV6_PORTRANGE_LOW = 0x2 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - - sizeofIPv6Mreq = 0x14 - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPv6Filter = 0x20 -) - -type sockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex uint32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sockaddrStorage - Source sockaddrStorage -} - -type icmpv6Filter struct { - Filt [8]uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_386.go b/vendor/golang.org/x/net/ipv6/zsys_linux_386.go deleted file mode 100644 index f5a410945..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_386.go +++ /dev/null @@ -1,168 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv6 - -const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - sizeofIPv6FlowlabelReq = 0x20 - - sizeofIPv6Mreq = 0x14 - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 - - sizeofICMPv6Filter = 0x20 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type groupReq struct { - Interface uint32 - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpv6Filter struct { - Data [8]uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_amd64.go b/vendor/golang.org/x/net/ipv6/zsys_linux_amd64.go deleted file mode 100644 index f9376b65c..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_amd64.go +++ /dev/null @@ -1,170 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv6 - -const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - sizeofIPv6FlowlabelReq = 0x20 - - sizeofIPv6Mreq = 0x14 - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPv6Filter = 0x20 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpv6Filter struct { - Data [8]uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_arm.go b/vendor/golang.org/x/net/ipv6/zsys_linux_arm.go deleted file mode 100644 index f5a410945..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_arm.go +++ /dev/null @@ -1,168 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv6 - -const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - sizeofIPv6FlowlabelReq = 0x20 - - sizeofIPv6Mreq = 0x14 - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 - - sizeofICMPv6Filter = 0x20 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type groupReq struct { - Interface uint32 - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpv6Filter struct { - Data [8]uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_arm64.go b/vendor/golang.org/x/net/ipv6/zsys_linux_arm64.go deleted file mode 100644 index f9376b65c..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_arm64.go +++ /dev/null @@ -1,170 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv6 - -const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - sizeofIPv6FlowlabelReq = 0x20 - - sizeofIPv6Mreq = 0x14 - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPv6Filter = 0x20 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpv6Filter struct { - Data [8]uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_mips.go b/vendor/golang.org/x/net/ipv6/zsys_linux_mips.go deleted file mode 100644 index f5a410945..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_mips.go +++ /dev/null @@ -1,168 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv6 - -const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - sizeofIPv6FlowlabelReq = 0x20 - - sizeofIPv6Mreq = 0x14 - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 - - sizeofICMPv6Filter = 0x20 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type groupReq struct { - Interface uint32 - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpv6Filter struct { - Data [8]uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_mips64.go b/vendor/golang.org/x/net/ipv6/zsys_linux_mips64.go deleted file mode 100644 index f9376b65c..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_mips64.go +++ /dev/null @@ -1,170 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv6 - -const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - sizeofIPv6FlowlabelReq = 0x20 - - sizeofIPv6Mreq = 0x14 - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPv6Filter = 0x20 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpv6Filter struct { - Data [8]uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_mips64le.go b/vendor/golang.org/x/net/ipv6/zsys_linux_mips64le.go deleted file mode 100644 index f9376b65c..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_mips64le.go +++ /dev/null @@ -1,170 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv6 - -const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - sizeofIPv6FlowlabelReq = 0x20 - - sizeofIPv6Mreq = 0x14 - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPv6Filter = 0x20 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpv6Filter struct { - Data [8]uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_mipsle.go b/vendor/golang.org/x/net/ipv6/zsys_linux_mipsle.go deleted file mode 100644 index f5a410945..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_mipsle.go +++ /dev/null @@ -1,168 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv6 - -const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - sizeofIPv6FlowlabelReq = 0x20 - - sizeofIPv6Mreq = 0x14 - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 - - sizeofICMPv6Filter = 0x20 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type groupReq struct { - Interface uint32 - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpv6Filter struct { - Data [8]uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_ppc.go b/vendor/golang.org/x/net/ipv6/zsys_linux_ppc.go deleted file mode 100644 index be2dbd666..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_ppc.go +++ /dev/null @@ -1,168 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv6 - -const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - sizeofIPv6FlowlabelReq = 0x20 - - sizeofIPv6Mreq = 0x14 - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 - - sizeofICMPv6Filter = 0x20 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]uint8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type groupReq struct { - Interface uint32 - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpv6Filter struct { - Data [8]uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64.go b/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64.go deleted file mode 100644 index f9376b65c..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64.go +++ /dev/null @@ -1,170 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv6 - -const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - sizeofIPv6FlowlabelReq = 0x20 - - sizeofIPv6Mreq = 0x14 - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPv6Filter = 0x20 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpv6Filter struct { - Data [8]uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64le.go b/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64le.go deleted file mode 100644 index f9376b65c..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64le.go +++ /dev/null @@ -1,170 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv6 - -const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - sizeofIPv6FlowlabelReq = 0x20 - - sizeofIPv6Mreq = 0x14 - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPv6Filter = 0x20 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpv6Filter struct { - Data [8]uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_s390x.go b/vendor/golang.org/x/net/ipv6/zsys_linux_s390x.go deleted file mode 100644 index f9376b65c..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_s390x.go +++ /dev/null @@ -1,170 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv6 - -const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - sizeofIPv6FlowlabelReq = 0x20 - - sizeofIPv6Mreq = 0x14 - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPv6Filter = 0x20 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpv6Filter struct { - Data [8]uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_netbsd.go b/vendor/golang.org/x/net/ipv6/zsys_netbsd.go deleted file mode 100644 index bcada13b7..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_netbsd.go +++ /dev/null @@ -1,84 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_netbsd.go - -package ipv6 - -const ( - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - sysIPV6_PORTRANGE = 0xe - sysICMP6_FILTER = 0x12 - - sysIPV6_CHECKSUM = 0x1a - sysIPV6_V6ONLY = 0x1b - - sysIPV6_IPSEC_POLICY = 0x1c - - sysIPV6_RTHDRDSTOPTS = 0x23 - - sysIPV6_RECVPKTINFO = 0x24 - sysIPV6_RECVHOPLIMIT = 0x25 - sysIPV6_RECVRTHDR = 0x26 - sysIPV6_RECVHOPOPTS = 0x27 - sysIPV6_RECVDSTOPTS = 0x28 - - sysIPV6_USE_MIN_MTU = 0x2a - sysIPV6_RECVPATHMTU = 0x2b - sysIPV6_PATHMTU = 0x2c - - sysIPV6_PKTINFO = 0x2e - sysIPV6_HOPLIMIT = 0x2f - sysIPV6_NEXTHOP = 0x30 - sysIPV6_HOPOPTS = 0x31 - sysIPV6_DSTOPTS = 0x32 - sysIPV6_RTHDR = 0x33 - - sysIPV6_RECVTCLASS = 0x39 - - sysIPV6_TCLASS = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_PORTRANGE_DEFAULT = 0x0 - sysIPV6_PORTRANGE_HIGH = 0x1 - sysIPV6_PORTRANGE_LOW = 0x2 - - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - - sizeofIPv6Mreq = 0x14 - - sizeofICMPv6Filter = 0x20 -) - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex uint32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -type icmpv6Filter struct { - Filt [8]uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_openbsd.go b/vendor/golang.org/x/net/ipv6/zsys_openbsd.go deleted file mode 100644 index 86cf3c637..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_openbsd.go +++ /dev/null @@ -1,93 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_openbsd.go - -package ipv6 - -const ( - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - sysIPV6_PORTRANGE = 0xe - sysICMP6_FILTER = 0x12 - - sysIPV6_CHECKSUM = 0x1a - sysIPV6_V6ONLY = 0x1b - - sysIPV6_RTHDRDSTOPTS = 0x23 - - sysIPV6_RECVPKTINFO = 0x24 - sysIPV6_RECVHOPLIMIT = 0x25 - sysIPV6_RECVRTHDR = 0x26 - sysIPV6_RECVHOPOPTS = 0x27 - sysIPV6_RECVDSTOPTS = 0x28 - - sysIPV6_USE_MIN_MTU = 0x2a - sysIPV6_RECVPATHMTU = 0x2b - - sysIPV6_PATHMTU = 0x2c - - sysIPV6_PKTINFO = 0x2e - sysIPV6_HOPLIMIT = 0x2f - sysIPV6_NEXTHOP = 0x30 - sysIPV6_HOPOPTS = 0x31 - sysIPV6_DSTOPTS = 0x32 - sysIPV6_RTHDR = 0x33 - - sysIPV6_AUTH_LEVEL = 0x35 - sysIPV6_ESP_TRANS_LEVEL = 0x36 - sysIPV6_ESP_NETWORK_LEVEL = 0x37 - sysIPSEC6_OUTSA = 0x38 - sysIPV6_RECVTCLASS = 0x39 - - sysIPV6_AUTOFLOWLABEL = 0x3b - sysIPV6_IPCOMP_LEVEL = 0x3c - - sysIPV6_TCLASS = 0x3d - sysIPV6_DONTFRAG = 0x3e - sysIPV6_PIPEX = 0x3f - - sysIPV6_RTABLE = 0x1021 - - sysIPV6_PORTRANGE_DEFAULT = 0x0 - sysIPV6_PORTRANGE_HIGH = 0x1 - sysIPV6_PORTRANGE_LOW = 0x2 - - sizeofSockaddrInet6 = 0x1c - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x20 - - sizeofIPv6Mreq = 0x14 - - sizeofICMPv6Filter = 0x20 -) - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex uint32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -type icmpv6Filter struct { - Filt [8]uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_solaris.go b/vendor/golang.org/x/net/ipv6/zsys_solaris.go deleted file mode 100644 index cf1837dd2..000000000 --- a/vendor/golang.org/x/net/ipv6/zsys_solaris.go +++ /dev/null @@ -1,131 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_solaris.go - -package ipv6 - -const ( - sysIPV6_UNICAST_HOPS = 0x5 - sysIPV6_MULTICAST_IF = 0x6 - sysIPV6_MULTICAST_HOPS = 0x7 - sysIPV6_MULTICAST_LOOP = 0x8 - sysIPV6_JOIN_GROUP = 0x9 - sysIPV6_LEAVE_GROUP = 0xa - - sysIPV6_PKTINFO = 0xb - - sysIPV6_HOPLIMIT = 0xc - sysIPV6_NEXTHOP = 0xd - sysIPV6_HOPOPTS = 0xe - sysIPV6_DSTOPTS = 0xf - - sysIPV6_RTHDR = 0x10 - sysIPV6_RTHDRDSTOPTS = 0x11 - - sysIPV6_RECVPKTINFO = 0x12 - sysIPV6_RECVHOPLIMIT = 0x13 - sysIPV6_RECVHOPOPTS = 0x14 - - sysIPV6_RECVRTHDR = 0x16 - - sysIPV6_RECVRTHDRDSTOPTS = 0x17 - - sysIPV6_CHECKSUM = 0x18 - sysIPV6_RECVTCLASS = 0x19 - sysIPV6_USE_MIN_MTU = 0x20 - sysIPV6_DONTFRAG = 0x21 - sysIPV6_SEC_OPT = 0x22 - sysIPV6_SRC_PREFERENCES = 0x23 - sysIPV6_RECVPATHMTU = 0x24 - sysIPV6_PATHMTU = 0x25 - sysIPV6_TCLASS = 0x26 - sysIPV6_V6ONLY = 0x27 - - sysIPV6_RECVDSTOPTS = 0x28 - - sysMCAST_JOIN_GROUP = 0x29 - sysMCAST_LEAVE_GROUP = 0x2a - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_JOIN_SOURCE_GROUP = 0x2d - sysMCAST_LEAVE_SOURCE_GROUP = 0x2e - - sysIPV6_PREFER_SRC_HOME = 0x1 - sysIPV6_PREFER_SRC_COA = 0x2 - sysIPV6_PREFER_SRC_PUBLIC = 0x4 - sysIPV6_PREFER_SRC_TMP = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x10 - sysIPV6_PREFER_SRC_CGA = 0x20 - - sysIPV6_PREFER_SRC_MIPMASK = 0x3 - sysIPV6_PREFER_SRC_MIPDEFAULT = 0x1 - sysIPV6_PREFER_SRC_TMPMASK = 0xc - sysIPV6_PREFER_SRC_TMPDEFAULT = 0x4 - sysIPV6_PREFER_SRC_CGAMASK = 0x30 - sysIPV6_PREFER_SRC_CGADEFAULT = 0x10 - - sysIPV6_PREFER_SRC_MASK = 0x3f - - sysIPV6_PREFER_SRC_DEFAULT = 0x15 - - sysIPV6_BOUND_IF = 0x41 - sysIPV6_UNSPEC_SRC = 0x42 - - sysICMP6_FILTER = 0x1 - - sizeofSockaddrStorage = 0x100 - sizeofSockaddrInet6 = 0x20 - sizeofInet6Pktinfo = 0x14 - sizeofIPv6Mtuinfo = 0x24 - - sizeofIPv6Mreq = 0x14 - sizeofGroupReq = 0x104 - sizeofGroupSourceReq = 0x204 - - sizeofICMPv6Filter = 0x20 -) - -type sockaddrStorage struct { - Family uint16 - X_ss_pad1 [6]int8 - X_ss_align float64 - X_ss_pad2 [240]int8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 - X__sin6_src_id uint32 -} - -type inet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex uint32 -} - -type ipv6Mtuinfo struct { - Addr sockaddrInet6 - Mtu uint32 -} - -type ipv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [256]byte -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [256]byte - Pad_cgo_1 [256]byte -} - -type icmpv6Filter struct { - X__icmp6_filt [8]uint32 -} diff --git a/vendor/golang.org/x/net/lex/httplex/httplex.go b/vendor/golang.org/x/net/lex/httplex/httplex.go deleted file mode 100644 index 20f2b8940..000000000 --- a/vendor/golang.org/x/net/lex/httplex/httplex.go +++ /dev/null @@ -1,351 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package httplex contains rules around lexical matters of various -// HTTP-related specifications. -// -// This package is shared by the standard library (which vendors it) -// and x/net/http2. It comes with no API stability promise. -package httplex - -import ( - "net" - "strings" - "unicode/utf8" - - "golang.org/x/net/idna" -) - -var isTokenTable = [127]bool{ - '!': true, - '#': true, - '$': true, - '%': true, - '&': true, - '\'': true, - '*': true, - '+': true, - '-': true, - '.': true, - '0': true, - '1': true, - '2': true, - '3': true, - '4': true, - '5': true, - '6': true, - '7': true, - '8': true, - '9': true, - 'A': true, - 'B': true, - 'C': true, - 'D': true, - 'E': true, - 'F': true, - 'G': true, - 'H': true, - 'I': true, - 'J': true, - 'K': true, - 'L': true, - 'M': true, - 'N': true, - 'O': true, - 'P': true, - 'Q': true, - 'R': true, - 'S': true, - 'T': true, - 'U': true, - 'W': true, - 'V': true, - 'X': true, - 'Y': true, - 'Z': true, - '^': true, - '_': true, - '`': true, - 'a': true, - 'b': true, - 'c': true, - 'd': true, - 'e': true, - 'f': true, - 'g': true, - 'h': true, - 'i': true, - 'j': true, - 'k': true, - 'l': true, - 'm': true, - 'n': true, - 'o': true, - 'p': true, - 'q': true, - 'r': true, - 's': true, - 't': true, - 'u': true, - 'v': true, - 'w': true, - 'x': true, - 'y': true, - 'z': true, - '|': true, - '~': true, -} - -func IsTokenRune(r rune) bool { - i := int(r) - return i < len(isTokenTable) && isTokenTable[i] -} - -func isNotToken(r rune) bool { - return !IsTokenRune(r) -} - -// HeaderValuesContainsToken reports whether any string in values -// contains the provided token, ASCII case-insensitively. -func HeaderValuesContainsToken(values []string, token string) bool { - for _, v := range values { - if headerValueContainsToken(v, token) { - return true - } - } - return false -} - -// isOWS reports whether b is an optional whitespace byte, as defined -// by RFC 7230 section 3.2.3. -func isOWS(b byte) bool { return b == ' ' || b == '\t' } - -// trimOWS returns x with all optional whitespace removes from the -// beginning and end. -func trimOWS(x string) string { - // TODO: consider using strings.Trim(x, " \t") instead, - // if and when it's fast enough. See issue 10292. - // But this ASCII-only code will probably always beat UTF-8 - // aware code. - for len(x) > 0 && isOWS(x[0]) { - x = x[1:] - } - for len(x) > 0 && isOWS(x[len(x)-1]) { - x = x[:len(x)-1] - } - return x -} - -// headerValueContainsToken reports whether v (assumed to be a -// 0#element, in the ABNF extension described in RFC 7230 section 7) -// contains token amongst its comma-separated tokens, ASCII -// case-insensitively. -func headerValueContainsToken(v string, token string) bool { - v = trimOWS(v) - if comma := strings.IndexByte(v, ','); comma != -1 { - return tokenEqual(trimOWS(v[:comma]), token) || headerValueContainsToken(v[comma+1:], token) - } - return tokenEqual(v, token) -} - -// lowerASCII returns the ASCII lowercase version of b. -func lowerASCII(b byte) byte { - if 'A' <= b && b <= 'Z' { - return b + ('a' - 'A') - } - return b -} - -// tokenEqual reports whether t1 and t2 are equal, ASCII case-insensitively. -func tokenEqual(t1, t2 string) bool { - if len(t1) != len(t2) { - return false - } - for i, b := range t1 { - if b >= utf8.RuneSelf { - // No UTF-8 or non-ASCII allowed in tokens. - return false - } - if lowerASCII(byte(b)) != lowerASCII(t2[i]) { - return false - } - } - return true -} - -// isLWS reports whether b is linear white space, according -// to http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 -// LWS = [CRLF] 1*( SP | HT ) -func isLWS(b byte) bool { return b == ' ' || b == '\t' } - -// isCTL reports whether b is a control byte, according -// to http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 -// CTL = -func isCTL(b byte) bool { - const del = 0x7f // a CTL - return b < ' ' || b == del -} - -// ValidHeaderFieldName reports whether v is a valid HTTP/1.x header name. -// HTTP/2 imposes the additional restriction that uppercase ASCII -// letters are not allowed. -// -// RFC 7230 says: -// header-field = field-name ":" OWS field-value OWS -// field-name = token -// token = 1*tchar -// tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / -// "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA -func ValidHeaderFieldName(v string) bool { - if len(v) == 0 { - return false - } - for _, r := range v { - if !IsTokenRune(r) { - return false - } - } - return true -} - -// ValidHostHeader reports whether h is a valid host header. -func ValidHostHeader(h string) bool { - // The latest spec is actually this: - // - // http://tools.ietf.org/html/rfc7230#section-5.4 - // Host = uri-host [ ":" port ] - // - // Where uri-host is: - // http://tools.ietf.org/html/rfc3986#section-3.2.2 - // - // But we're going to be much more lenient for now and just - // search for any byte that's not a valid byte in any of those - // expressions. - for i := 0; i < len(h); i++ { - if !validHostByte[h[i]] { - return false - } - } - return true -} - -// See the validHostHeader comment. -var validHostByte = [256]bool{ - '0': true, '1': true, '2': true, '3': true, '4': true, '5': true, '6': true, '7': true, - '8': true, '9': true, - - 'a': true, 'b': true, 'c': true, 'd': true, 'e': true, 'f': true, 'g': true, 'h': true, - 'i': true, 'j': true, 'k': true, 'l': true, 'm': true, 'n': true, 'o': true, 'p': true, - 'q': true, 'r': true, 's': true, 't': true, 'u': true, 'v': true, 'w': true, 'x': true, - 'y': true, 'z': true, - - 'A': true, 'B': true, 'C': true, 'D': true, 'E': true, 'F': true, 'G': true, 'H': true, - 'I': true, 'J': true, 'K': true, 'L': true, 'M': true, 'N': true, 'O': true, 'P': true, - 'Q': true, 'R': true, 'S': true, 'T': true, 'U': true, 'V': true, 'W': true, 'X': true, - 'Y': true, 'Z': true, - - '!': true, // sub-delims - '$': true, // sub-delims - '%': true, // pct-encoded (and used in IPv6 zones) - '&': true, // sub-delims - '(': true, // sub-delims - ')': true, // sub-delims - '*': true, // sub-delims - '+': true, // sub-delims - ',': true, // sub-delims - '-': true, // unreserved - '.': true, // unreserved - ':': true, // IPv6address + Host expression's optional port - ';': true, // sub-delims - '=': true, // sub-delims - '[': true, - '\'': true, // sub-delims - ']': true, - '_': true, // unreserved - '~': true, // unreserved -} - -// ValidHeaderFieldValue reports whether v is a valid "field-value" according to -// http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2 : -// -// message-header = field-name ":" [ field-value ] -// field-value = *( field-content | LWS ) -// field-content = -// -// http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 : -// -// TEXT = -// LWS = [CRLF] 1*( SP | HT ) -// CTL = -// -// RFC 7230 says: -// field-value = *( field-content / obs-fold ) -// obj-fold = N/A to http2, and deprecated -// field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] -// field-vchar = VCHAR / obs-text -// obs-text = %x80-FF -// VCHAR = "any visible [USASCII] character" -// -// http2 further says: "Similarly, HTTP/2 allows header field values -// that are not valid. While most of the values that can be encoded -// will not alter header field parsing, carriage return (CR, ASCII -// 0xd), line feed (LF, ASCII 0xa), and the zero character (NUL, ASCII -// 0x0) might be exploited by an attacker if they are translated -// verbatim. Any request or response that contains a character not -// permitted in a header field value MUST be treated as malformed -// (Section 8.1.2.6). Valid characters are defined by the -// field-content ABNF rule in Section 3.2 of [RFC7230]." -// -// This function does not (yet?) properly handle the rejection of -// strings that begin or end with SP or HTAB. -func ValidHeaderFieldValue(v string) bool { - for i := 0; i < len(v); i++ { - b := v[i] - if isCTL(b) && !isLWS(b) { - return false - } - } - return true -} - -func isASCII(s string) bool { - for i := 0; i < len(s); i++ { - if s[i] >= utf8.RuneSelf { - return false - } - } - return true -} - -// PunycodeHostPort returns the IDNA Punycode version -// of the provided "host" or "host:port" string. -func PunycodeHostPort(v string) (string, error) { - if isASCII(v) { - return v, nil - } - - host, port, err := net.SplitHostPort(v) - if err != nil { - // The input 'v' argument was just a "host" argument, - // without a port. This error should not be returned - // to the caller. - host = v - port = "" - } - host, err = idna.ToASCII(host) - if err != nil { - // Non-UTF-8? Not representable in Punycode, in any - // case. - return "", err - } - if port == "" { - return host, nil - } - return net.JoinHostPort(host, port), nil -} diff --git a/vendor/golang.org/x/net/lex/httplex/httplex_test.go b/vendor/golang.org/x/net/lex/httplex/httplex_test.go deleted file mode 100644 index f47adc939..000000000 --- a/vendor/golang.org/x/net/lex/httplex/httplex_test.go +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package httplex - -import ( - "testing" -) - -func isChar(c rune) bool { return c <= 127 } - -func isCtl(c rune) bool { return c <= 31 || c == 127 } - -func isSeparator(c rune) bool { - switch c { - case '(', ')', '<', '>', '@', ',', ';', ':', '\\', '"', '/', '[', ']', '?', '=', '{', '}', ' ', '\t': - return true - } - return false -} - -func TestIsToken(t *testing.T) { - for i := 0; i <= 130; i++ { - r := rune(i) - expected := isChar(r) && !isCtl(r) && !isSeparator(r) - if IsTokenRune(r) != expected { - t.Errorf("isToken(0x%x) = %v", r, !expected) - } - } -} - -func TestHeaderValuesContainsToken(t *testing.T) { - tests := []struct { - vals []string - token string - want bool - }{ - { - vals: []string{"foo"}, - token: "foo", - want: true, - }, - { - vals: []string{"bar", "foo"}, - token: "foo", - want: true, - }, - { - vals: []string{"foo"}, - token: "FOO", - want: true, - }, - { - vals: []string{"foo"}, - token: "bar", - want: false, - }, - { - vals: []string{" foo "}, - token: "FOO", - want: true, - }, - { - vals: []string{"foo,bar"}, - token: "FOO", - want: true, - }, - { - vals: []string{"bar,foo,bar"}, - token: "FOO", - want: true, - }, - { - vals: []string{"bar , foo"}, - token: "FOO", - want: true, - }, - { - vals: []string{"foo ,bar "}, - token: "FOO", - want: true, - }, - { - vals: []string{"bar, foo ,bar"}, - token: "FOO", - want: true, - }, - { - vals: []string{"bar , foo"}, - token: "FOO", - want: true, - }, - } - for _, tt := range tests { - got := HeaderValuesContainsToken(tt.vals, tt.token) - if got != tt.want { - t.Errorf("headerValuesContainsToken(%q, %q) = %v; want %v", tt.vals, tt.token, got, tt.want) - } - } -} - -func TestPunycodeHostPort(t *testing.T) { - tests := []struct { - in, want string - }{ - {"www.google.com", "www.google.com"}, - {"гофер.рф", "xn--c1ae0ajs.xn--p1ai"}, - {"bücher.de", "xn--bcher-kva.de"}, - {"bücher.de:8080", "xn--bcher-kva.de:8080"}, - {"[1::6]:8080", "[1::6]:8080"}, - } - for _, tt := range tests { - got, err := PunycodeHostPort(tt.in) - if tt.want != got || err != nil { - t.Errorf("PunycodeHostPort(%q) = %q, %v, want %q, nil", tt.in, got, err, tt.want) - } - } -} diff --git a/vendor/golang.org/x/net/lif/address.go b/vendor/golang.org/x/net/lif/address.go deleted file mode 100644 index afb957fd8..000000000 --- a/vendor/golang.org/x/net/lif/address.go +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build solaris - -package lif - -import ( - "errors" - "unsafe" -) - -// An Addr represents an address associated with packet routing. -type Addr interface { - // Family returns an address family. - Family() int -} - -// An Inet4Addr represents an internet address for IPv4. -type Inet4Addr struct { - IP [4]byte // IP address - PrefixLen int // address prefix length -} - -// Family implements the Family method of Addr interface. -func (a *Inet4Addr) Family() int { return sysAF_INET } - -// An Inet6Addr represents an internet address for IPv6. -type Inet6Addr struct { - IP [16]byte // IP address - PrefixLen int // address prefix length - ZoneID int // zone identifier -} - -// Family implements the Family method of Addr interface. -func (a *Inet6Addr) Family() int { return sysAF_INET6 } - -// Addrs returns a list of interface addresses. -// -// The provided af must be an address family and name must be a data -// link name. The zero value of af or name means a wildcard. -func Addrs(af int, name string) ([]Addr, error) { - eps, err := newEndpoints(af) - if len(eps) == 0 { - return nil, err - } - defer func() { - for _, ep := range eps { - ep.close() - } - }() - lls, err := links(eps, name) - if len(lls) == 0 { - return nil, err - } - var as []Addr - for _, ll := range lls { - var lifr lifreq - for i := 0; i < len(ll.Name); i++ { - lifr.Name[i] = int8(ll.Name[i]) - } - for _, ep := range eps { - ioc := int64(sysSIOCGLIFADDR) - err := ioctl(ep.s, uintptr(ioc), unsafe.Pointer(&lifr)) - if err != nil { - continue - } - sa := (*sockaddrStorage)(unsafe.Pointer(&lifr.Lifru[0])) - l := int(nativeEndian.Uint32(lifr.Lifru1[:4])) - if l == 0 { - continue - } - switch sa.Family { - case sysAF_INET: - a := &Inet4Addr{PrefixLen: l} - copy(a.IP[:], lifr.Lifru[4:8]) - as = append(as, a) - case sysAF_INET6: - a := &Inet6Addr{PrefixLen: l, ZoneID: int(nativeEndian.Uint32(lifr.Lifru[24:28]))} - copy(a.IP[:], lifr.Lifru[8:24]) - as = append(as, a) - } - } - } - return as, nil -} - -func parseLinkAddr(b []byte) ([]byte, error) { - nlen, alen, slen := int(b[1]), int(b[2]), int(b[3]) - l := 4 + nlen + alen + slen - if len(b) < l { - return nil, errors.New("invalid address") - } - b = b[4:] - var addr []byte - if nlen > 0 { - b = b[nlen:] - } - if alen > 0 { - addr = make([]byte, alen) - copy(addr, b[:alen]) - } - return addr, nil -} diff --git a/vendor/golang.org/x/net/lif/address_test.go b/vendor/golang.org/x/net/lif/address_test.go deleted file mode 100644 index a25f10b67..000000000 --- a/vendor/golang.org/x/net/lif/address_test.go +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build solaris - -package lif - -import ( - "fmt" - "testing" -) - -type addrFamily int - -func (af addrFamily) String() string { - switch af { - case sysAF_UNSPEC: - return "unspec" - case sysAF_INET: - return "inet4" - case sysAF_INET6: - return "inet6" - default: - return fmt.Sprintf("%d", af) - } -} - -const hexDigit = "0123456789abcdef" - -type llAddr []byte - -func (a llAddr) String() string { - if len(a) == 0 { - return "" - } - buf := make([]byte, 0, len(a)*3-1) - for i, b := range a { - if i > 0 { - buf = append(buf, ':') - } - buf = append(buf, hexDigit[b>>4]) - buf = append(buf, hexDigit[b&0xF]) - } - return string(buf) -} - -type ipAddr []byte - -func (a ipAddr) String() string { - if len(a) == 0 { - return "" - } - if len(a) == 4 { - return fmt.Sprintf("%d.%d.%d.%d", a[0], a[1], a[2], a[3]) - } - if len(a) == 16 { - return fmt.Sprintf("%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]) - } - s := make([]byte, len(a)*2) - for i, tn := range a { - s[i*2], s[i*2+1] = hexDigit[tn>>4], hexDigit[tn&0xf] - } - return string(s) -} - -func (a *Inet4Addr) String() string { - return fmt.Sprintf("(%s %s %d)", addrFamily(a.Family()), ipAddr(a.IP[:]), a.PrefixLen) -} - -func (a *Inet6Addr) String() string { - return fmt.Sprintf("(%s %s %d %d)", addrFamily(a.Family()), ipAddr(a.IP[:]), a.PrefixLen, a.ZoneID) -} - -type addrPack struct { - af int - as []Addr -} - -func addrPacks() ([]addrPack, error) { - var lastErr error - var aps []addrPack - for _, af := range [...]int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} { - as, err := Addrs(af, "") - if err != nil { - lastErr = err - continue - } - aps = append(aps, addrPack{af: af, as: as}) - } - return aps, lastErr -} - -func TestAddrs(t *testing.T) { - aps, err := addrPacks() - if len(aps) == 0 && err != nil { - t.Fatal(err) - } - lps, err := linkPacks() - if len(lps) == 0 && err != nil { - t.Fatal(err) - } - for _, lp := range lps { - n := 0 - for _, ll := range lp.lls { - as, err := Addrs(lp.af, ll.Name) - if err != nil { - t.Fatal(lp.af, ll.Name, err) - } - t.Logf("af=%s name=%s %v", addrFamily(lp.af), ll.Name, as) - n += len(as) - } - for _, ap := range aps { - if ap.af != lp.af { - continue - } - if n != len(ap.as) { - t.Errorf("af=%s got %d; want %d", addrFamily(lp.af), n, len(ap.as)) - continue - } - } - } -} diff --git a/vendor/golang.org/x/net/lif/binary.go b/vendor/golang.org/x/net/lif/binary.go deleted file mode 100644 index 738a94f42..000000000 --- a/vendor/golang.org/x/net/lif/binary.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build solaris - -package lif - -// This file contains duplicates of encoding/binary package. -// -// This package is supposed to be used by the net package of standard -// library. Therefore the package set used in the package must be the -// same as net package. - -var ( - littleEndian binaryLittleEndian - bigEndian binaryBigEndian -) - -type binaryByteOrder interface { - Uint16([]byte) uint16 - Uint32([]byte) uint32 - Uint64([]byte) uint64 - PutUint16([]byte, uint16) - PutUint32([]byte, uint32) - PutUint64([]byte, uint64) -} - -type binaryLittleEndian struct{} - -func (binaryLittleEndian) Uint16(b []byte) uint16 { - _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808 - return uint16(b[0]) | uint16(b[1])<<8 -} - -func (binaryLittleEndian) PutUint16(b []byte, v uint16) { - _ = b[1] // early bounds check to guarantee safety of writes below - b[0] = byte(v) - b[1] = byte(v >> 8) -} - -func (binaryLittleEndian) Uint32(b []byte) uint32 { - _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 - return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 -} - -func (binaryLittleEndian) PutUint32(b []byte, v uint32) { - _ = b[3] // early bounds check to guarantee safety of writes below - b[0] = byte(v) - b[1] = byte(v >> 8) - b[2] = byte(v >> 16) - b[3] = byte(v >> 24) -} - -func (binaryLittleEndian) Uint64(b []byte) uint64 { - _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 - return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | - uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 -} - -func (binaryLittleEndian) PutUint64(b []byte, v uint64) { - _ = b[7] // early bounds check to guarantee safety of writes below - b[0] = byte(v) - b[1] = byte(v >> 8) - b[2] = byte(v >> 16) - b[3] = byte(v >> 24) - b[4] = byte(v >> 32) - b[5] = byte(v >> 40) - b[6] = byte(v >> 48) - b[7] = byte(v >> 56) -} - -type binaryBigEndian struct{} - -func (binaryBigEndian) Uint16(b []byte) uint16 { - _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808 - return uint16(b[1]) | uint16(b[0])<<8 -} - -func (binaryBigEndian) PutUint16(b []byte, v uint16) { - _ = b[1] // early bounds check to guarantee safety of writes below - b[0] = byte(v >> 8) - b[1] = byte(v) -} - -func (binaryBigEndian) Uint32(b []byte) uint32 { - _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 - return uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24 -} - -func (binaryBigEndian) PutUint32(b []byte, v uint32) { - _ = b[3] // early bounds check to guarantee safety of writes below - b[0] = byte(v >> 24) - b[1] = byte(v >> 16) - b[2] = byte(v >> 8) - b[3] = byte(v) -} - -func (binaryBigEndian) Uint64(b []byte) uint64 { - _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 - return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 | - uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56 -} - -func (binaryBigEndian) PutUint64(b []byte, v uint64) { - _ = b[7] // early bounds check to guarantee safety of writes below - b[0] = byte(v >> 56) - b[1] = byte(v >> 48) - b[2] = byte(v >> 40) - b[3] = byte(v >> 32) - b[4] = byte(v >> 24) - b[5] = byte(v >> 16) - b[6] = byte(v >> 8) - b[7] = byte(v) -} diff --git a/vendor/golang.org/x/net/lif/defs_solaris.go b/vendor/golang.org/x/net/lif/defs_solaris.go deleted file mode 100644 index 8b84ba5e3..000000000 --- a/vendor/golang.org/x/net/lif/defs_solaris.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package lif - -/* -#include -#include - -#include -#include -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_INET6 = C.AF_INET6 - - sysSOCK_DGRAM = C.SOCK_DGRAM -) - -type sockaddrStorage C.struct_sockaddr_storage - -const ( - sysLIFC_NOXMIT = C.LIFC_NOXMIT - sysLIFC_EXTERNAL_SOURCE = C.LIFC_EXTERNAL_SOURCE - sysLIFC_TEMPORARY = C.LIFC_TEMPORARY - sysLIFC_ALLZONES = C.LIFC_ALLZONES - sysLIFC_UNDER_IPMP = C.LIFC_UNDER_IPMP - sysLIFC_ENABLED = C.LIFC_ENABLED - - sysSIOCGLIFADDR = C.SIOCGLIFADDR - sysSIOCGLIFDSTADDR = C.SIOCGLIFDSTADDR - sysSIOCGLIFFLAGS = C.SIOCGLIFFLAGS - sysSIOCGLIFMTU = C.SIOCGLIFMTU - sysSIOCGLIFNETMASK = C.SIOCGLIFNETMASK - sysSIOCGLIFMETRIC = C.SIOCGLIFMETRIC - sysSIOCGLIFNUM = C.SIOCGLIFNUM - sysSIOCGLIFINDEX = C.SIOCGLIFINDEX - sysSIOCGLIFSUBNET = C.SIOCGLIFSUBNET - sysSIOCGLIFLNKINFO = C.SIOCGLIFLNKINFO - sysSIOCGLIFCONF = C.SIOCGLIFCONF - sysSIOCGLIFHWADDR = C.SIOCGLIFHWADDR -) - -const ( - sysIFF_UP = C.IFF_UP - sysIFF_BROADCAST = C.IFF_BROADCAST - sysIFF_DEBUG = C.IFF_DEBUG - sysIFF_LOOPBACK = C.IFF_LOOPBACK - sysIFF_POINTOPOINT = C.IFF_POINTOPOINT - sysIFF_NOTRAILERS = C.IFF_NOTRAILERS - sysIFF_RUNNING = C.IFF_RUNNING - sysIFF_NOARP = C.IFF_NOARP - sysIFF_PROMISC = C.IFF_PROMISC - sysIFF_ALLMULTI = C.IFF_ALLMULTI - sysIFF_INTELLIGENT = C.IFF_INTELLIGENT - sysIFF_MULTICAST = C.IFF_MULTICAST - sysIFF_MULTI_BCAST = C.IFF_MULTI_BCAST - sysIFF_UNNUMBERED = C.IFF_UNNUMBERED - sysIFF_PRIVATE = C.IFF_PRIVATE -) - -const ( - sizeofLifnum = C.sizeof_struct_lifnum - sizeofLifreq = C.sizeof_struct_lifreq - sizeofLifconf = C.sizeof_struct_lifconf - sizeofLifIfinfoReq = C.sizeof_struct_lif_ifinfo_req -) - -type sysLifnum C.struct_lifnum - -type lifreq C.struct_lifreq - -type lifconf C.struct_lifconf - -type lifIfinfoReq C.struct_lif_ifinfo_req - -const ( - sysIFT_IPV4 = C.IFT_IPV4 - sysIFT_IPV6 = C.IFT_IPV6 - sysIFT_6TO4 = C.IFT_6TO4 -) diff --git a/vendor/golang.org/x/net/lif/lif.go b/vendor/golang.org/x/net/lif/lif.go deleted file mode 100644 index 6e81f81f1..000000000 --- a/vendor/golang.org/x/net/lif/lif.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build solaris - -// Package lif provides basic functions for the manipulation of -// logical network interfaces and interface addresses on Solaris. -// -// The package supports Solaris 11 or above. -package lif - -import "syscall" - -type endpoint struct { - af int - s uintptr -} - -func (ep *endpoint) close() error { - return syscall.Close(int(ep.s)) -} - -func newEndpoints(af int) ([]endpoint, error) { - var lastErr error - var eps []endpoint - afs := []int{sysAF_INET, sysAF_INET6} - if af != sysAF_UNSPEC { - afs = []int{af} - } - for _, af := range afs { - s, err := syscall.Socket(af, sysSOCK_DGRAM, 0) - if err != nil { - lastErr = err - continue - } - eps = append(eps, endpoint{af: af, s: uintptr(s)}) - } - if len(eps) == 0 { - return nil, lastErr - } - return eps, nil -} diff --git a/vendor/golang.org/x/net/lif/link.go b/vendor/golang.org/x/net/lif/link.go deleted file mode 100644 index fce6b2147..000000000 --- a/vendor/golang.org/x/net/lif/link.go +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build solaris - -package lif - -import "unsafe" - -// A Link represents logical data link information. -// -// It also represents base information for logical network interface. -// On Solaris, each logical network interface represents network layer -// adjacency information and the interface has a only single network -// address or address pair for tunneling. It's usual that multiple -// logical network interfaces share the same logical data link. -type Link struct { - Name string // name, equivalent to IP interface name - Index int // index, equivalent to IP interface index - Type int // type - Flags int // flags - MTU int // maximum transmission unit, basically link MTU but may differ between IP address families - Addr []byte // address -} - -func (ll *Link) fetch(s uintptr) { - var lifr lifreq - for i := 0; i < len(ll.Name); i++ { - lifr.Name[i] = int8(ll.Name[i]) - } - ioc := int64(sysSIOCGLIFINDEX) - if err := ioctl(s, uintptr(ioc), unsafe.Pointer(&lifr)); err == nil { - ll.Index = int(nativeEndian.Uint32(lifr.Lifru[:4])) - } - ioc = int64(sysSIOCGLIFFLAGS) - if err := ioctl(s, uintptr(ioc), unsafe.Pointer(&lifr)); err == nil { - ll.Flags = int(nativeEndian.Uint64(lifr.Lifru[:8])) - } - ioc = int64(sysSIOCGLIFMTU) - if err := ioctl(s, uintptr(ioc), unsafe.Pointer(&lifr)); err == nil { - ll.MTU = int(nativeEndian.Uint32(lifr.Lifru[:4])) - } - switch ll.Type { - case sysIFT_IPV4, sysIFT_IPV6, sysIFT_6TO4: - default: - ioc = int64(sysSIOCGLIFHWADDR) - if err := ioctl(s, uintptr(ioc), unsafe.Pointer(&lifr)); err == nil { - ll.Addr, _ = parseLinkAddr(lifr.Lifru[4:]) - } - } -} - -// Links returns a list of logical data links. -// -// The provided af must be an address family and name must be a data -// link name. The zero value of af or name means a wildcard. -func Links(af int, name string) ([]Link, error) { - eps, err := newEndpoints(af) - if len(eps) == 0 { - return nil, err - } - defer func() { - for _, ep := range eps { - ep.close() - } - }() - return links(eps, name) -} - -func links(eps []endpoint, name string) ([]Link, error) { - var lls []Link - lifn := sysLifnum{Flags: sysLIFC_NOXMIT | sysLIFC_TEMPORARY | sysLIFC_ALLZONES | sysLIFC_UNDER_IPMP} - lifc := lifconf{Flags: sysLIFC_NOXMIT | sysLIFC_TEMPORARY | sysLIFC_ALLZONES | sysLIFC_UNDER_IPMP} - for _, ep := range eps { - lifn.Family = uint16(ep.af) - ioc := int64(sysSIOCGLIFNUM) - if err := ioctl(ep.s, uintptr(ioc), unsafe.Pointer(&lifn)); err != nil { - continue - } - if lifn.Count == 0 { - continue - } - b := make([]byte, lifn.Count*sizeofLifreq) - lifc.Family = uint16(ep.af) - lifc.Len = lifn.Count * sizeofLifreq - if len(lifc.Lifcu) == 8 { - nativeEndian.PutUint64(lifc.Lifcu[:], uint64(uintptr(unsafe.Pointer(&b[0])))) - } else { - nativeEndian.PutUint32(lifc.Lifcu[:], uint32(uintptr(unsafe.Pointer(&b[0])))) - } - ioc = int64(sysSIOCGLIFCONF) - if err := ioctl(ep.s, uintptr(ioc), unsafe.Pointer(&lifc)); err != nil { - continue - } - nb := make([]byte, 32) // see LIFNAMSIZ in net/if.h - for i := 0; i < int(lifn.Count); i++ { - lifr := (*lifreq)(unsafe.Pointer(&b[i*sizeofLifreq])) - for i := 0; i < 32; i++ { - if lifr.Name[i] == 0 { - nb = nb[:i] - break - } - nb[i] = byte(lifr.Name[i]) - } - llname := string(nb) - nb = nb[:32] - if isDupLink(lls, llname) || name != "" && name != llname { - continue - } - ll := Link{Name: llname, Type: int(lifr.Type)} - ll.fetch(ep.s) - lls = append(lls, ll) - } - } - return lls, nil -} - -func isDupLink(lls []Link, name string) bool { - for _, ll := range lls { - if ll.Name == name { - return true - } - } - return false -} diff --git a/vendor/golang.org/x/net/lif/link_test.go b/vendor/golang.org/x/net/lif/link_test.go deleted file mode 100644 index 0cb9b95c6..000000000 --- a/vendor/golang.org/x/net/lif/link_test.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build solaris - -package lif - -import ( - "fmt" - "testing" -) - -func (ll *Link) String() string { - return fmt.Sprintf("name=%s index=%d type=%d flags=%#x mtu=%d addr=%v", ll.Name, ll.Index, ll.Type, ll.Flags, ll.MTU, llAddr(ll.Addr)) -} - -type linkPack struct { - af int - lls []Link -} - -func linkPacks() ([]linkPack, error) { - var lastErr error - var lps []linkPack - for _, af := range [...]int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} { - lls, err := Links(af, "") - if err != nil { - lastErr = err - continue - } - lps = append(lps, linkPack{af: af, lls: lls}) - } - return lps, lastErr -} - -func TestLinks(t *testing.T) { - lps, err := linkPacks() - if len(lps) == 0 && err != nil { - t.Fatal(err) - } - for _, lp := range lps { - n := 0 - for _, sll := range lp.lls { - lls, err := Links(lp.af, sll.Name) - if err != nil { - t.Fatal(lp.af, sll.Name, err) - } - for _, ll := range lls { - if ll.Name != sll.Name || ll.Index != sll.Index { - t.Errorf("af=%s got %v; want %v", addrFamily(lp.af), &ll, &sll) - continue - } - t.Logf("af=%s name=%s %v", addrFamily(lp.af), sll.Name, &ll) - n++ - } - } - if n != len(lp.lls) { - t.Errorf("af=%s got %d; want %d", addrFamily(lp.af), n, len(lp.lls)) - continue - } - } -} diff --git a/vendor/golang.org/x/net/lif/sys.go b/vendor/golang.org/x/net/lif/sys.go deleted file mode 100644 index c896041b7..000000000 --- a/vendor/golang.org/x/net/lif/sys.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build solaris - -package lif - -import "unsafe" - -var nativeEndian binaryByteOrder - -func init() { - i := uint32(1) - b := (*[4]byte)(unsafe.Pointer(&i)) - if b[0] == 1 { - nativeEndian = littleEndian - } else { - nativeEndian = bigEndian - } -} diff --git a/vendor/golang.org/x/net/lif/sys_solaris_amd64.s b/vendor/golang.org/x/net/lif/sys_solaris_amd64.s deleted file mode 100644 index 39d76af79..000000000 --- a/vendor/golang.org/x/net/lif/sys_solaris_amd64.s +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#include "textflag.h" - -TEXT ·sysvicall6(SB),NOSPLIT,$0-88 - JMP syscall·sysvicall6(SB) diff --git a/vendor/golang.org/x/net/lif/syscall.go b/vendor/golang.org/x/net/lif/syscall.go deleted file mode 100644 index aadab2e14..000000000 --- a/vendor/golang.org/x/net/lif/syscall.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build solaris - -package lif - -import ( - "syscall" - "unsafe" -) - -//go:cgo_import_dynamic libc_ioctl ioctl "libc.so" - -//go:linkname procIoctl libc_ioctl - -var procIoctl uintptr - -func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (uintptr, uintptr, syscall.Errno) - -func ioctl(s, ioc uintptr, arg unsafe.Pointer) error { - _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procIoctl)), 3, s, ioc, uintptr(arg), 0, 0, 0) - if errno != 0 { - return error(errno) - } - return nil -} diff --git a/vendor/golang.org/x/net/lif/zsys_solaris_amd64.go b/vendor/golang.org/x/net/lif/zsys_solaris_amd64.go deleted file mode 100644 index 94231c49c..000000000 --- a/vendor/golang.org/x/net/lif/zsys_solaris_amd64.go +++ /dev/null @@ -1,103 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_solaris.go - -package lif - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0x1a - - sysSOCK_DGRAM = 0x1 -) - -type sockaddrStorage struct { - Family uint16 - X_ss_pad1 [6]int8 - X_ss_align float64 - X_ss_pad2 [240]int8 -} - -const ( - sysLIFC_NOXMIT = 0x1 - sysLIFC_EXTERNAL_SOURCE = 0x2 - sysLIFC_TEMPORARY = 0x4 - sysLIFC_ALLZONES = 0x8 - sysLIFC_UNDER_IPMP = 0x10 - sysLIFC_ENABLED = 0x20 - - sysSIOCGLIFADDR = -0x3f87968f - sysSIOCGLIFDSTADDR = -0x3f87968d - sysSIOCGLIFFLAGS = -0x3f87968b - sysSIOCGLIFMTU = -0x3f879686 - sysSIOCGLIFNETMASK = -0x3f879683 - sysSIOCGLIFMETRIC = -0x3f879681 - sysSIOCGLIFNUM = -0x3ff3967e - sysSIOCGLIFINDEX = -0x3f87967b - sysSIOCGLIFSUBNET = -0x3f879676 - sysSIOCGLIFLNKINFO = -0x3f879674 - sysSIOCGLIFCONF = -0x3fef965b - sysSIOCGLIFHWADDR = -0x3f879640 -) - -const ( - sysIFF_UP = 0x1 - sysIFF_BROADCAST = 0x2 - sysIFF_DEBUG = 0x4 - sysIFF_LOOPBACK = 0x8 - sysIFF_POINTOPOINT = 0x10 - sysIFF_NOTRAILERS = 0x20 - sysIFF_RUNNING = 0x40 - sysIFF_NOARP = 0x80 - sysIFF_PROMISC = 0x100 - sysIFF_ALLMULTI = 0x200 - sysIFF_INTELLIGENT = 0x400 - sysIFF_MULTICAST = 0x800 - sysIFF_MULTI_BCAST = 0x1000 - sysIFF_UNNUMBERED = 0x2000 - sysIFF_PRIVATE = 0x8000 -) - -const ( - sizeofLifnum = 0xc - sizeofLifreq = 0x178 - sizeofLifconf = 0x18 - sizeofLifIfinfoReq = 0x10 -) - -type sysLifnum struct { - Family uint16 - Pad_cgo_0 [2]byte - Flags int32 - Count int32 -} - -type lifreq struct { - Name [32]int8 - Lifru1 [4]byte - Type uint32 - Lifru [336]byte -} - -type lifconf struct { - Family uint16 - Pad_cgo_0 [2]byte - Flags int32 - Len int32 - Pad_cgo_1 [4]byte - Lifcu [8]byte -} - -type lifIfinfoReq struct { - Maxhops uint8 - Pad_cgo_0 [3]byte - Reachtime uint32 - Reachretrans uint32 - Maxmtu uint32 -} - -const ( - sysIFT_IPV4 = 0xc8 - sysIFT_IPV6 = 0xc9 - sysIFT_6TO4 = 0xca -) diff --git a/vendor/golang.org/x/net/nettest/conntest.go b/vendor/golang.org/x/net/nettest/conntest.go deleted file mode 100644 index f5b0b7bcf..000000000 --- a/vendor/golang.org/x/net/nettest/conntest.go +++ /dev/null @@ -1,452 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package nettest provides utilities for network testing. -package nettest - -import ( - "bytes" - "encoding/binary" - "io" - "io/ioutil" - "math/rand" - "net" - "sync" - "testing" - "time" -) - -var ( - aLongTimeAgo = time.Unix(233431200, 0) - neverTimeout = time.Time{} -) - -// MakePipe creates a connection between two endpoints and returns the pair -// as c1 and c2, such that anything written to c1 is read by c2 and vice-versa. -// The stop function closes all resources, including c1, c2, and the underlying -// net.Listener (if there is one), and should not be nil. -type MakePipe func() (c1, c2 net.Conn, stop func(), err error) - -// TestConn tests that a net.Conn implementation properly satisfies the interface. -// The tests should not produce any false positives, but may experience -// false negatives. Thus, some issues may only be detected when the test is -// run multiple times. For maximal effectiveness, run the tests under the -// race detector. -func TestConn(t *testing.T, mp MakePipe) { - testConn(t, mp) -} - -type connTester func(t *testing.T, c1, c2 net.Conn) - -func timeoutWrapper(t *testing.T, mp MakePipe, f connTester) { - c1, c2, stop, err := mp() - if err != nil { - t.Fatalf("unable to make pipe: %v", err) - } - var once sync.Once - defer once.Do(func() { stop() }) - timer := time.AfterFunc(time.Minute, func() { - once.Do(func() { - t.Error("test timed out; terminating pipe") - stop() - }) - }) - defer timer.Stop() - f(t, c1, c2) -} - -// testBasicIO tests that the data sent on c1 is properly received on c2. -func testBasicIO(t *testing.T, c1, c2 net.Conn) { - want := make([]byte, 1<<20) - rand.New(rand.NewSource(0)).Read(want) - - dataCh := make(chan []byte) - go func() { - rd := bytes.NewReader(want) - if err := chunkedCopy(c1, rd); err != nil { - t.Errorf("unexpected c1.Write error: %v", err) - } - if err := c1.Close(); err != nil { - t.Errorf("unexpected c1.Close error: %v", err) - } - }() - - go func() { - wr := new(bytes.Buffer) - if err := chunkedCopy(wr, c2); err != nil { - t.Errorf("unexpected c2.Read error: %v", err) - } - if err := c2.Close(); err != nil { - t.Errorf("unexpected c2.Close error: %v", err) - } - dataCh <- wr.Bytes() - }() - - if got := <-dataCh; !bytes.Equal(got, want) { - t.Errorf("transmitted data differs") - } -} - -// testPingPong tests that the two endpoints can synchronously send data to -// each other in a typical request-response pattern. -func testPingPong(t *testing.T, c1, c2 net.Conn) { - var wg sync.WaitGroup - defer wg.Wait() - - pingPonger := func(c net.Conn) { - defer wg.Done() - buf := make([]byte, 8) - var prev uint64 - for { - if _, err := io.ReadFull(c, buf); err != nil { - if err == io.EOF { - break - } - t.Errorf("unexpected Read error: %v", err) - } - - v := binary.LittleEndian.Uint64(buf) - binary.LittleEndian.PutUint64(buf, v+1) - if prev != 0 && prev+2 != v { - t.Errorf("mismatching value: got %d, want %d", v, prev+2) - } - prev = v - if v == 1000 { - break - } - - if _, err := c.Write(buf); err != nil { - t.Errorf("unexpected Write error: %v", err) - break - } - } - if err := c.Close(); err != nil { - t.Errorf("unexpected Close error: %v", err) - } - } - - wg.Add(2) - go pingPonger(c1) - go pingPonger(c2) - - // Start off the chain reaction. - if _, err := c1.Write(make([]byte, 8)); err != nil { - t.Errorf("unexpected c1.Write error: %v", err) - } -} - -// testRacyRead tests that it is safe to mutate the input Read buffer -// immediately after cancelation has occurred. -func testRacyRead(t *testing.T, c1, c2 net.Conn) { - go chunkedCopy(c2, rand.New(rand.NewSource(0))) - - var wg sync.WaitGroup - defer wg.Wait() - - c1.SetReadDeadline(time.Now().Add(time.Millisecond)) - for i := 0; i < 10; i++ { - wg.Add(1) - go func() { - defer wg.Done() - - b1 := make([]byte, 1024) - b2 := make([]byte, 1024) - for j := 0; j < 100; j++ { - _, err := c1.Read(b1) - copy(b1, b2) // Mutate b1 to trigger potential race - if err != nil { - checkForTimeoutError(t, err) - c1.SetReadDeadline(time.Now().Add(time.Millisecond)) - } - } - }() - } -} - -// testRacyWrite tests that it is safe to mutate the input Write buffer -// immediately after cancelation has occurred. -func testRacyWrite(t *testing.T, c1, c2 net.Conn) { - go chunkedCopy(ioutil.Discard, c2) - - var wg sync.WaitGroup - defer wg.Wait() - - c1.SetWriteDeadline(time.Now().Add(time.Millisecond)) - for i := 0; i < 10; i++ { - wg.Add(1) - go func() { - defer wg.Done() - - b1 := make([]byte, 1024) - b2 := make([]byte, 1024) - for j := 0; j < 100; j++ { - _, err := c1.Write(b1) - copy(b1, b2) // Mutate b1 to trigger potential race - if err != nil { - checkForTimeoutError(t, err) - c1.SetWriteDeadline(time.Now().Add(time.Millisecond)) - } - } - }() - } -} - -// testReadTimeout tests that Read timeouts do not affect Write. -func testReadTimeout(t *testing.T, c1, c2 net.Conn) { - go chunkedCopy(ioutil.Discard, c2) - - c1.SetReadDeadline(aLongTimeAgo) - _, err := c1.Read(make([]byte, 1024)) - checkForTimeoutError(t, err) - if _, err := c1.Write(make([]byte, 1024)); err != nil { - t.Errorf("unexpected Write error: %v", err) - } -} - -// testWriteTimeout tests that Write timeouts do not affect Read. -func testWriteTimeout(t *testing.T, c1, c2 net.Conn) { - go chunkedCopy(c2, rand.New(rand.NewSource(0))) - - c1.SetWriteDeadline(aLongTimeAgo) - _, err := c1.Write(make([]byte, 1024)) - checkForTimeoutError(t, err) - if _, err := c1.Read(make([]byte, 1024)); err != nil { - t.Errorf("unexpected Read error: %v", err) - } -} - -// testPastTimeout tests that a deadline set in the past immediately times out -// Read and Write requests. -func testPastTimeout(t *testing.T, c1, c2 net.Conn) { - go chunkedCopy(c2, c2) - - testRoundtrip(t, c1) - - c1.SetDeadline(aLongTimeAgo) - n, err := c1.Write(make([]byte, 1024)) - if n != 0 { - t.Errorf("unexpected Write count: got %d, want 0", n) - } - checkForTimeoutError(t, err) - n, err = c1.Read(make([]byte, 1024)) - if n != 0 { - t.Errorf("unexpected Read count: got %d, want 0", n) - } - checkForTimeoutError(t, err) - - testRoundtrip(t, c1) -} - -// testPresentTimeout tests that a deadline set while there are pending -// Read and Write operations immediately times out those operations. -func testPresentTimeout(t *testing.T, c1, c2 net.Conn) { - var wg sync.WaitGroup - defer wg.Wait() - wg.Add(3) - - deadlineSet := make(chan bool, 1) - go func() { - defer wg.Done() - time.Sleep(100 * time.Millisecond) - deadlineSet <- true - c1.SetReadDeadline(aLongTimeAgo) - c1.SetWriteDeadline(aLongTimeAgo) - }() - go func() { - defer wg.Done() - n, err := c1.Read(make([]byte, 1024)) - if n != 0 { - t.Errorf("unexpected Read count: got %d, want 0", n) - } - checkForTimeoutError(t, err) - if len(deadlineSet) == 0 { - t.Error("Read timed out before deadline is set") - } - }() - go func() { - defer wg.Done() - var err error - for err == nil { - _, err = c1.Write(make([]byte, 1024)) - } - checkForTimeoutError(t, err) - if len(deadlineSet) == 0 { - t.Error("Write timed out before deadline is set") - } - }() -} - -// testFutureTimeout tests that a future deadline will eventually time out -// Read and Write operations. -func testFutureTimeout(t *testing.T, c1, c2 net.Conn) { - var wg sync.WaitGroup - wg.Add(2) - - c1.SetDeadline(time.Now().Add(100 * time.Millisecond)) - go func() { - defer wg.Done() - _, err := c1.Read(make([]byte, 1024)) - checkForTimeoutError(t, err) - }() - go func() { - defer wg.Done() - var err error - for err == nil { - _, err = c1.Write(make([]byte, 1024)) - } - checkForTimeoutError(t, err) - }() - wg.Wait() - - go chunkedCopy(c2, c2) - resyncConn(t, c1) - testRoundtrip(t, c1) -} - -// testCloseTimeout tests that calling Close immediately times out pending -// Read and Write operations. -func testCloseTimeout(t *testing.T, c1, c2 net.Conn) { - go chunkedCopy(c2, c2) - - var wg sync.WaitGroup - defer wg.Wait() - wg.Add(3) - - // Test for cancelation upon connection closure. - c1.SetDeadline(neverTimeout) - go func() { - defer wg.Done() - time.Sleep(100 * time.Millisecond) - c1.Close() - }() - go func() { - defer wg.Done() - var err error - buf := make([]byte, 1024) - for err == nil { - _, err = c1.Read(buf) - } - }() - go func() { - defer wg.Done() - var err error - buf := make([]byte, 1024) - for err == nil { - _, err = c1.Write(buf) - } - }() -} - -// testConcurrentMethods tests that the methods of net.Conn can safely -// be called concurrently. -func testConcurrentMethods(t *testing.T, c1, c2 net.Conn) { - go chunkedCopy(c2, c2) - - // The results of the calls may be nonsensical, but this should - // not trigger a race detector warning. - var wg sync.WaitGroup - for i := 0; i < 100; i++ { - wg.Add(7) - go func() { - defer wg.Done() - c1.Read(make([]byte, 1024)) - }() - go func() { - defer wg.Done() - c1.Write(make([]byte, 1024)) - }() - go func() { - defer wg.Done() - c1.SetDeadline(time.Now().Add(10 * time.Millisecond)) - }() - go func() { - defer wg.Done() - c1.SetReadDeadline(aLongTimeAgo) - }() - go func() { - defer wg.Done() - c1.SetWriteDeadline(aLongTimeAgo) - }() - go func() { - defer wg.Done() - c1.LocalAddr() - }() - go func() { - defer wg.Done() - c1.RemoteAddr() - }() - } - wg.Wait() // At worst, the deadline is set 10ms into the future - - resyncConn(t, c1) - testRoundtrip(t, c1) -} - -// checkForTimeoutError checks that the error satisfies the Error interface -// and that Timeout returns true. -func checkForTimeoutError(t *testing.T, err error) { - if nerr, ok := err.(net.Error); ok { - if !nerr.Timeout() { - t.Errorf("err.Timeout() = false, want true") - } - } else { - t.Errorf("got %T, want net.Error", err) - } -} - -// testRoundtrip writes something into c and reads it back. -// It assumes that everything written into c is echoed back to itself. -func testRoundtrip(t *testing.T, c net.Conn) { - if err := c.SetDeadline(neverTimeout); err != nil { - t.Errorf("roundtrip SetDeadline error: %v", err) - } - - const s = "Hello, world!" - buf := []byte(s) - if _, err := c.Write(buf); err != nil { - t.Errorf("roundtrip Write error: %v", err) - } - if _, err := io.ReadFull(c, buf); err != nil { - t.Errorf("roundtrip Read error: %v", err) - } - if string(buf) != s { - t.Errorf("roundtrip data mismatch: got %q, want %q", buf, s) - } -} - -// resyncConn resynchronizes the connection into a sane state. -// It assumes that everything written into c is echoed back to itself. -// It assumes that 0xff is not currently on the wire or in the read buffer. -func resyncConn(t *testing.T, c net.Conn) { - c.SetDeadline(neverTimeout) - errCh := make(chan error) - go func() { - _, err := c.Write([]byte{0xff}) - errCh <- err - }() - buf := make([]byte, 1024) - for { - n, err := c.Read(buf) - if n > 0 && bytes.IndexByte(buf[:n], 0xff) == n-1 { - break - } - if err != nil { - t.Errorf("unexpected Read error: %v", err) - break - } - } - if err := <-errCh; err != nil { - t.Errorf("unexpected Write error: %v", err) - } -} - -// chunkedCopy copies from r to w in fixed-width chunks to avoid -// causing a Write that exceeds the maximum packet size for packet-based -// connections like "unixpacket". -// We assume that the maximum packet size is at least 1024. -func chunkedCopy(w io.Writer, r io.Reader) error { - b := make([]byte, 1024) - _, err := io.CopyBuffer(struct{ io.Writer }{w}, struct{ io.Reader }{r}, b) - return err -} diff --git a/vendor/golang.org/x/net/nettest/conntest_go16.go b/vendor/golang.org/x/net/nettest/conntest_go16.go deleted file mode 100644 index 4cbf48e35..000000000 --- a/vendor/golang.org/x/net/nettest/conntest_go16.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.7 - -package nettest - -import "testing" - -func testConn(t *testing.T, mp MakePipe) { - // Avoid using subtests on Go 1.6 and below. - timeoutWrapper(t, mp, testBasicIO) - timeoutWrapper(t, mp, testPingPong) - timeoutWrapper(t, mp, testRacyRead) - timeoutWrapper(t, mp, testRacyWrite) - timeoutWrapper(t, mp, testReadTimeout) - timeoutWrapper(t, mp, testWriteTimeout) - timeoutWrapper(t, mp, testPastTimeout) - timeoutWrapper(t, mp, testPresentTimeout) - timeoutWrapper(t, mp, testFutureTimeout) - timeoutWrapper(t, mp, testCloseTimeout) - timeoutWrapper(t, mp, testConcurrentMethods) -} diff --git a/vendor/golang.org/x/net/nettest/conntest_go17.go b/vendor/golang.org/x/net/nettest/conntest_go17.go deleted file mode 100644 index fa039f03f..000000000 --- a/vendor/golang.org/x/net/nettest/conntest_go17.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.7 - -package nettest - -import "testing" - -func testConn(t *testing.T, mp MakePipe) { - // Use subtests on Go 1.7 and above since it is better organized. - t.Run("BasicIO", func(t *testing.T) { timeoutWrapper(t, mp, testBasicIO) }) - t.Run("PingPong", func(t *testing.T) { timeoutWrapper(t, mp, testPingPong) }) - t.Run("RacyRead", func(t *testing.T) { timeoutWrapper(t, mp, testRacyRead) }) - t.Run("RacyWrite", func(t *testing.T) { timeoutWrapper(t, mp, testRacyWrite) }) - t.Run("ReadTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testReadTimeout) }) - t.Run("WriteTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testWriteTimeout) }) - t.Run("PastTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testPastTimeout) }) - t.Run("PresentTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testPresentTimeout) }) - t.Run("FutureTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testFutureTimeout) }) - t.Run("CloseTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testCloseTimeout) }) - t.Run("ConcurrentMethods", func(t *testing.T) { timeoutWrapper(t, mp, testConcurrentMethods) }) -} diff --git a/vendor/golang.org/x/net/nettest/conntest_test.go b/vendor/golang.org/x/net/nettest/conntest_test.go deleted file mode 100644 index 9f9453fb5..000000000 --- a/vendor/golang.org/x/net/nettest/conntest_test.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.8 - -package nettest - -import ( - "net" - "os" - "runtime" - "testing" - - "golang.org/x/net/internal/nettest" -) - -func TestTestConn(t *testing.T) { - tests := []struct{ name, network string }{ - {"TCP", "tcp"}, - {"UnixPipe", "unix"}, - {"UnixPacketPipe", "unixpacket"}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if !nettest.TestableNetwork(tt.network) { - t.Skipf("not supported on %s", runtime.GOOS) - } - - mp := func() (c1, c2 net.Conn, stop func(), err error) { - ln, err := nettest.NewLocalListener(tt.network) - if err != nil { - return nil, nil, nil, err - } - - // Start a connection between two endpoints. - var err1, err2 error - done := make(chan bool) - go func() { - c2, err2 = ln.Accept() - close(done) - }() - c1, err1 = net.Dial(ln.Addr().Network(), ln.Addr().String()) - <-done - - stop = func() { - if err1 == nil { - c1.Close() - } - if err2 == nil { - c2.Close() - } - ln.Close() - switch tt.network { - case "unix", "unixpacket": - os.Remove(ln.Addr().String()) - } - } - - switch { - case err1 != nil: - stop() - return nil, nil, nil, err1 - case err2 != nil: - stop() - return nil, nil, nil, err2 - default: - return c1, c2, stop, nil - } - } - - TestConn(t, mp) - }) - } -} diff --git a/vendor/golang.org/x/net/netutil/listen.go b/vendor/golang.org/x/net/netutil/listen.go deleted file mode 100644 index 56f43bf65..000000000 --- a/vendor/golang.org/x/net/netutil/listen.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package netutil provides network utility functions, complementing the more -// common ones in the net package. -package netutil // import "golang.org/x/net/netutil" - -import ( - "net" - "sync" -) - -// LimitListener returns a Listener that accepts at most n simultaneous -// connections from the provided Listener. -func LimitListener(l net.Listener, n int) net.Listener { - return &limitListener{l, make(chan struct{}, n)} -} - -type limitListener struct { - net.Listener - sem chan struct{} -} - -func (l *limitListener) acquire() { l.sem <- struct{}{} } -func (l *limitListener) release() { <-l.sem } - -func (l *limitListener) Accept() (net.Conn, error) { - l.acquire() - c, err := l.Listener.Accept() - if err != nil { - l.release() - return nil, err - } - return &limitListenerConn{Conn: c, release: l.release}, nil -} - -type limitListenerConn struct { - net.Conn - releaseOnce sync.Once - release func() -} - -func (l *limitListenerConn) Close() error { - err := l.Conn.Close() - l.releaseOnce.Do(l.release) - return err -} diff --git a/vendor/golang.org/x/net/netutil/listen_test.go b/vendor/golang.org/x/net/netutil/listen_test.go deleted file mode 100644 index 5e07d7bea..000000000 --- a/vendor/golang.org/x/net/netutil/listen_test.go +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package netutil - -import ( - "errors" - "fmt" - "io" - "io/ioutil" - "net" - "net/http" - "sync" - "sync/atomic" - "testing" - "time" - - "golang.org/x/net/internal/nettest" -) - -func TestLimitListener(t *testing.T) { - const max = 5 - attempts := (nettest.MaxOpenFiles() - max) / 2 - if attempts > 256 { // maximum length of accept queue is 128 by default - attempts = 256 - } - - l, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - defer l.Close() - l = LimitListener(l, max) - - var open int32 - go http.Serve(l, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if n := atomic.AddInt32(&open, 1); n > max { - t.Errorf("%d open connections, want <= %d", n, max) - } - defer atomic.AddInt32(&open, -1) - time.Sleep(10 * time.Millisecond) - fmt.Fprint(w, "some body") - })) - - var wg sync.WaitGroup - var failed int32 - for i := 0; i < attempts; i++ { - wg.Add(1) - go func() { - defer wg.Done() - c := http.Client{Timeout: 3 * time.Second} - r, err := c.Get("http://" + l.Addr().String()) - if err != nil { - t.Log(err) - atomic.AddInt32(&failed, 1) - return - } - defer r.Body.Close() - io.Copy(ioutil.Discard, r.Body) - }() - } - wg.Wait() - - // We expect some Gets to fail as the kernel's accept queue is filled, - // but most should succeed. - if int(failed) >= attempts/2 { - t.Errorf("%d requests failed within %d attempts", failed, attempts) - } -} - -type errorListener struct { - net.Listener -} - -func (errorListener) Accept() (net.Conn, error) { - return nil, errFake -} - -var errFake = errors.New("fake error from errorListener") - -// This used to hang. -func TestLimitListenerError(t *testing.T) { - donec := make(chan bool, 1) - go func() { - const n = 2 - ll := LimitListener(errorListener{}, n) - for i := 0; i < n+1; i++ { - _, err := ll.Accept() - if err != errFake { - t.Fatalf("Accept error = %v; want errFake", err) - } - } - donec <- true - }() - select { - case <-donec: - case <-time.After(5 * time.Second): - t.Fatal("timeout. deadlock?") - } -} diff --git a/vendor/golang.org/x/net/proxy/direct.go b/vendor/golang.org/x/net/proxy/direct.go deleted file mode 100644 index 4c5ad88b1..000000000 --- a/vendor/golang.org/x/net/proxy/direct.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package proxy - -import ( - "net" -) - -type direct struct{} - -// Direct is a direct proxy: one that makes network connections directly. -var Direct = direct{} - -func (direct) Dial(network, addr string) (net.Conn, error) { - return net.Dial(network, addr) -} diff --git a/vendor/golang.org/x/net/proxy/per_host.go b/vendor/golang.org/x/net/proxy/per_host.go deleted file mode 100644 index f540b196f..000000000 --- a/vendor/golang.org/x/net/proxy/per_host.go +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package proxy - -import ( - "net" - "strings" -) - -// A PerHost directs connections to a default Dialer unless the hostname -// requested matches one of a number of exceptions. -type PerHost struct { - def, bypass Dialer - - bypassNetworks []*net.IPNet - bypassIPs []net.IP - bypassZones []string - bypassHosts []string -} - -// NewPerHost returns a PerHost Dialer that directs connections to either -// defaultDialer or bypass, depending on whether the connection matches one of -// the configured rules. -func NewPerHost(defaultDialer, bypass Dialer) *PerHost { - return &PerHost{ - def: defaultDialer, - bypass: bypass, - } -} - -// Dial connects to the address addr on the given network through either -// defaultDialer or bypass. -func (p *PerHost) Dial(network, addr string) (c net.Conn, err error) { - host, _, err := net.SplitHostPort(addr) - if err != nil { - return nil, err - } - - return p.dialerForRequest(host).Dial(network, addr) -} - -func (p *PerHost) dialerForRequest(host string) Dialer { - if ip := net.ParseIP(host); ip != nil { - for _, net := range p.bypassNetworks { - if net.Contains(ip) { - return p.bypass - } - } - for _, bypassIP := range p.bypassIPs { - if bypassIP.Equal(ip) { - return p.bypass - } - } - return p.def - } - - for _, zone := range p.bypassZones { - if strings.HasSuffix(host, zone) { - return p.bypass - } - if host == zone[1:] { - // For a zone "example.com", we match "example.com" - // too. - return p.bypass - } - } - for _, bypassHost := range p.bypassHosts { - if bypassHost == host { - return p.bypass - } - } - return p.def -} - -// AddFromString parses a string that contains comma-separated values -// specifying hosts that should use the bypass proxy. Each value is either an -// IP address, a CIDR range, a zone (*.example.com) or a hostname -// (localhost). A best effort is made to parse the string and errors are -// ignored. -func (p *PerHost) AddFromString(s string) { - hosts := strings.Split(s, ",") - for _, host := range hosts { - host = strings.TrimSpace(host) - if len(host) == 0 { - continue - } - if strings.Contains(host, "/") { - // We assume that it's a CIDR address like 127.0.0.0/8 - if _, net, err := net.ParseCIDR(host); err == nil { - p.AddNetwork(net) - } - continue - } - if ip := net.ParseIP(host); ip != nil { - p.AddIP(ip) - continue - } - if strings.HasPrefix(host, "*.") { - p.AddZone(host[1:]) - continue - } - p.AddHost(host) - } -} - -// AddIP specifies an IP address that will use the bypass proxy. Note that -// this will only take effect if a literal IP address is dialed. A connection -// to a named host will never match an IP. -func (p *PerHost) AddIP(ip net.IP) { - p.bypassIPs = append(p.bypassIPs, ip) -} - -// AddNetwork specifies an IP range that will use the bypass proxy. Note that -// this will only take effect if a literal IP address is dialed. A connection -// to a named host will never match. -func (p *PerHost) AddNetwork(net *net.IPNet) { - p.bypassNetworks = append(p.bypassNetworks, net) -} - -// AddZone specifies a DNS suffix that will use the bypass proxy. A zone of -// "example.com" matches "example.com" and all of its subdomains. -func (p *PerHost) AddZone(zone string) { - if strings.HasSuffix(zone, ".") { - zone = zone[:len(zone)-1] - } - if !strings.HasPrefix(zone, ".") { - zone = "." + zone - } - p.bypassZones = append(p.bypassZones, zone) -} - -// AddHost specifies a hostname that will use the bypass proxy. -func (p *PerHost) AddHost(host string) { - if strings.HasSuffix(host, ".") { - host = host[:len(host)-1] - } - p.bypassHosts = append(p.bypassHosts, host) -} diff --git a/vendor/golang.org/x/net/proxy/per_host_test.go b/vendor/golang.org/x/net/proxy/per_host_test.go deleted file mode 100644 index a7d809571..000000000 --- a/vendor/golang.org/x/net/proxy/per_host_test.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package proxy - -import ( - "errors" - "net" - "reflect" - "testing" -) - -type recordingProxy struct { - addrs []string -} - -func (r *recordingProxy) Dial(network, addr string) (net.Conn, error) { - r.addrs = append(r.addrs, addr) - return nil, errors.New("recordingProxy") -} - -func TestPerHost(t *testing.T) { - var def, bypass recordingProxy - perHost := NewPerHost(&def, &bypass) - perHost.AddFromString("localhost,*.zone,127.0.0.1,10.0.0.1/8,1000::/16") - - expectedDef := []string{ - "example.com:123", - "1.2.3.4:123", - "[1001::]:123", - } - expectedBypass := []string{ - "localhost:123", - "zone:123", - "foo.zone:123", - "127.0.0.1:123", - "10.1.2.3:123", - "[1000::]:123", - } - - for _, addr := range expectedDef { - perHost.Dial("tcp", addr) - } - for _, addr := range expectedBypass { - perHost.Dial("tcp", addr) - } - - if !reflect.DeepEqual(expectedDef, def.addrs) { - t.Errorf("Hosts which went to the default proxy didn't match. Got %v, want %v", def.addrs, expectedDef) - } - if !reflect.DeepEqual(expectedBypass, bypass.addrs) { - t.Errorf("Hosts which went to the bypass proxy didn't match. Got %v, want %v", bypass.addrs, expectedBypass) - } -} diff --git a/vendor/golang.org/x/net/proxy/proxy.go b/vendor/golang.org/x/net/proxy/proxy.go deleted file mode 100644 index 78a8b7bee..000000000 --- a/vendor/golang.org/x/net/proxy/proxy.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package proxy provides support for a variety of protocols to proxy network -// data. -package proxy // import "golang.org/x/net/proxy" - -import ( - "errors" - "net" - "net/url" - "os" -) - -// A Dialer is a means to establish a connection. -type Dialer interface { - // Dial connects to the given address via the proxy. - Dial(network, addr string) (c net.Conn, err error) -} - -// Auth contains authentication parameters that specific Dialers may require. -type Auth struct { - User, Password string -} - -// FromEnvironment returns the dialer specified by the proxy related variables in -// the environment. -func FromEnvironment() Dialer { - allProxy := os.Getenv("all_proxy") - if len(allProxy) == 0 { - return Direct - } - - proxyURL, err := url.Parse(allProxy) - if err != nil { - return Direct - } - proxy, err := FromURL(proxyURL, Direct) - if err != nil { - return Direct - } - - noProxy := os.Getenv("no_proxy") - if len(noProxy) == 0 { - return proxy - } - - perHost := NewPerHost(proxy, Direct) - perHost.AddFromString(noProxy) - return perHost -} - -// proxySchemes is a map from URL schemes to a function that creates a Dialer -// from a URL with such a scheme. -var proxySchemes map[string]func(*url.URL, Dialer) (Dialer, error) - -// RegisterDialerType takes a URL scheme and a function to generate Dialers from -// a URL with that scheme and a forwarding Dialer. Registered schemes are used -// by FromURL. -func RegisterDialerType(scheme string, f func(*url.URL, Dialer) (Dialer, error)) { - if proxySchemes == nil { - proxySchemes = make(map[string]func(*url.URL, Dialer) (Dialer, error)) - } - proxySchemes[scheme] = f -} - -// FromURL returns a Dialer given a URL specification and an underlying -// Dialer for it to make network requests. -func FromURL(u *url.URL, forward Dialer) (Dialer, error) { - var auth *Auth - if u.User != nil { - auth = new(Auth) - auth.User = u.User.Username() - if p, ok := u.User.Password(); ok { - auth.Password = p - } - } - - switch u.Scheme { - case "socks5": - return SOCKS5("tcp", u.Host, auth, forward) - } - - // If the scheme doesn't match any of the built-in schemes, see if it - // was registered by another package. - if proxySchemes != nil { - if f, ok := proxySchemes[u.Scheme]; ok { - return f(u, forward) - } - } - - return nil, errors.New("proxy: unknown scheme: " + u.Scheme) -} diff --git a/vendor/golang.org/x/net/proxy/proxy_test.go b/vendor/golang.org/x/net/proxy/proxy_test.go deleted file mode 100644 index c19a5c063..000000000 --- a/vendor/golang.org/x/net/proxy/proxy_test.go +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package proxy - -import ( - "io" - "net" - "net/url" - "strconv" - "sync" - "testing" -) - -func TestFromURL(t *testing.T) { - endSystem, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatalf("net.Listen failed: %v", err) - } - defer endSystem.Close() - gateway, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatalf("net.Listen failed: %v", err) - } - defer gateway.Close() - - var wg sync.WaitGroup - wg.Add(1) - go socks5Gateway(t, gateway, endSystem, socks5Domain, &wg) - - url, err := url.Parse("socks5://user:password@" + gateway.Addr().String()) - if err != nil { - t.Fatalf("url.Parse failed: %v", err) - } - proxy, err := FromURL(url, Direct) - if err != nil { - t.Fatalf("FromURL failed: %v", err) - } - _, port, err := net.SplitHostPort(endSystem.Addr().String()) - if err != nil { - t.Fatalf("net.SplitHostPort failed: %v", err) - } - if c, err := proxy.Dial("tcp", "localhost:"+port); err != nil { - t.Fatalf("FromURL.Dial failed: %v", err) - } else { - c.Close() - } - - wg.Wait() -} - -func TestSOCKS5(t *testing.T) { - endSystem, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatalf("net.Listen failed: %v", err) - } - defer endSystem.Close() - gateway, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatalf("net.Listen failed: %v", err) - } - defer gateway.Close() - - var wg sync.WaitGroup - wg.Add(1) - go socks5Gateway(t, gateway, endSystem, socks5IP4, &wg) - - proxy, err := SOCKS5("tcp", gateway.Addr().String(), nil, Direct) - if err != nil { - t.Fatalf("SOCKS5 failed: %v", err) - } - if c, err := proxy.Dial("tcp", endSystem.Addr().String()); err != nil { - t.Fatalf("SOCKS5.Dial failed: %v", err) - } else { - c.Close() - } - - wg.Wait() -} - -func socks5Gateway(t *testing.T, gateway, endSystem net.Listener, typ byte, wg *sync.WaitGroup) { - defer wg.Done() - - c, err := gateway.Accept() - if err != nil { - t.Errorf("net.Listener.Accept failed: %v", err) - return - } - defer c.Close() - - b := make([]byte, 32) - var n int - if typ == socks5Domain { - n = 4 - } else { - n = 3 - } - if _, err := io.ReadFull(c, b[:n]); err != nil { - t.Errorf("io.ReadFull failed: %v", err) - return - } - if _, err := c.Write([]byte{socks5Version, socks5AuthNone}); err != nil { - t.Errorf("net.Conn.Write failed: %v", err) - return - } - if typ == socks5Domain { - n = 16 - } else { - n = 10 - } - if _, err := io.ReadFull(c, b[:n]); err != nil { - t.Errorf("io.ReadFull failed: %v", err) - return - } - if b[0] != socks5Version || b[1] != socks5Connect || b[2] != 0x00 || b[3] != typ { - t.Errorf("got an unexpected packet: %#02x %#02x %#02x %#02x", b[0], b[1], b[2], b[3]) - return - } - if typ == socks5Domain { - copy(b[:5], []byte{socks5Version, 0x00, 0x00, socks5Domain, 9}) - b = append(b, []byte("localhost")...) - } else { - copy(b[:4], []byte{socks5Version, 0x00, 0x00, socks5IP4}) - } - host, port, err := net.SplitHostPort(endSystem.Addr().String()) - if err != nil { - t.Errorf("net.SplitHostPort failed: %v", err) - return - } - b = append(b, []byte(net.ParseIP(host).To4())...) - p, err := strconv.Atoi(port) - if err != nil { - t.Errorf("strconv.Atoi failed: %v", err) - return - } - b = append(b, []byte{byte(p >> 8), byte(p)}...) - if _, err := c.Write(b); err != nil { - t.Errorf("net.Conn.Write failed: %v", err) - return - } -} diff --git a/vendor/golang.org/x/net/proxy/socks5.go b/vendor/golang.org/x/net/proxy/socks5.go deleted file mode 100644 index 973f57f19..000000000 --- a/vendor/golang.org/x/net/proxy/socks5.go +++ /dev/null @@ -1,213 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package proxy - -import ( - "errors" - "io" - "net" - "strconv" -) - -// SOCKS5 returns a Dialer that makes SOCKSv5 connections to the given address -// with an optional username and password. See RFC 1928. -func SOCKS5(network, addr string, auth *Auth, forward Dialer) (Dialer, error) { - s := &socks5{ - network: network, - addr: addr, - forward: forward, - } - if auth != nil { - s.user = auth.User - s.password = auth.Password - } - - return s, nil -} - -type socks5 struct { - user, password string - network, addr string - forward Dialer -} - -const socks5Version = 5 - -const ( - socks5AuthNone = 0 - socks5AuthPassword = 2 -) - -const socks5Connect = 1 - -const ( - socks5IP4 = 1 - socks5Domain = 3 - socks5IP6 = 4 -) - -var socks5Errors = []string{ - "", - "general failure", - "connection forbidden", - "network unreachable", - "host unreachable", - "connection refused", - "TTL expired", - "command not supported", - "address type not supported", -} - -// Dial connects to the address addr on the network net via the SOCKS5 proxy. -func (s *socks5) Dial(network, addr string) (net.Conn, error) { - switch network { - case "tcp", "tcp6", "tcp4": - default: - return nil, errors.New("proxy: no support for SOCKS5 proxy connections of type " + network) - } - - conn, err := s.forward.Dial(s.network, s.addr) - if err != nil { - return nil, err - } - if err := s.connect(conn, addr); err != nil { - conn.Close() - return nil, err - } - return conn, nil -} - -// connect takes an existing connection to a socks5 proxy server, -// and commands the server to extend that connection to target, -// which must be a canonical address with a host and port. -func (s *socks5) connect(conn net.Conn, target string) error { - host, portStr, err := net.SplitHostPort(target) - if err != nil { - return err - } - - port, err := strconv.Atoi(portStr) - if err != nil { - return errors.New("proxy: failed to parse port number: " + portStr) - } - if port < 1 || port > 0xffff { - return errors.New("proxy: port number out of range: " + portStr) - } - - // the size here is just an estimate - buf := make([]byte, 0, 6+len(host)) - - buf = append(buf, socks5Version) - if len(s.user) > 0 && len(s.user) < 256 && len(s.password) < 256 { - buf = append(buf, 2 /* num auth methods */, socks5AuthNone, socks5AuthPassword) - } else { - buf = append(buf, 1 /* num auth methods */, socks5AuthNone) - } - - if _, err := conn.Write(buf); err != nil { - return errors.New("proxy: failed to write greeting to SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - if _, err := io.ReadFull(conn, buf[:2]); err != nil { - return errors.New("proxy: failed to read greeting from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - if buf[0] != 5 { - return errors.New("proxy: SOCKS5 proxy at " + s.addr + " has unexpected version " + strconv.Itoa(int(buf[0]))) - } - if buf[1] == 0xff { - return errors.New("proxy: SOCKS5 proxy at " + s.addr + " requires authentication") - } - - if buf[1] == socks5AuthPassword { - buf = buf[:0] - buf = append(buf, 1 /* password protocol version */) - buf = append(buf, uint8(len(s.user))) - buf = append(buf, s.user...) - buf = append(buf, uint8(len(s.password))) - buf = append(buf, s.password...) - - if _, err := conn.Write(buf); err != nil { - return errors.New("proxy: failed to write authentication request to SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - if _, err := io.ReadFull(conn, buf[:2]); err != nil { - return errors.New("proxy: failed to read authentication reply from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - if buf[1] != 0 { - return errors.New("proxy: SOCKS5 proxy at " + s.addr + " rejected username/password") - } - } - - buf = buf[:0] - buf = append(buf, socks5Version, socks5Connect, 0 /* reserved */) - - if ip := net.ParseIP(host); ip != nil { - if ip4 := ip.To4(); ip4 != nil { - buf = append(buf, socks5IP4) - ip = ip4 - } else { - buf = append(buf, socks5IP6) - } - buf = append(buf, ip...) - } else { - if len(host) > 255 { - return errors.New("proxy: destination hostname too long: " + host) - } - buf = append(buf, socks5Domain) - buf = append(buf, byte(len(host))) - buf = append(buf, host...) - } - buf = append(buf, byte(port>>8), byte(port)) - - if _, err := conn.Write(buf); err != nil { - return errors.New("proxy: failed to write connect request to SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - if _, err := io.ReadFull(conn, buf[:4]); err != nil { - return errors.New("proxy: failed to read connect reply from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - failure := "unknown error" - if int(buf[1]) < len(socks5Errors) { - failure = socks5Errors[buf[1]] - } - - if len(failure) > 0 { - return errors.New("proxy: SOCKS5 proxy at " + s.addr + " failed to connect: " + failure) - } - - bytesToDiscard := 0 - switch buf[3] { - case socks5IP4: - bytesToDiscard = net.IPv4len - case socks5IP6: - bytesToDiscard = net.IPv6len - case socks5Domain: - _, err := io.ReadFull(conn, buf[:1]) - if err != nil { - return errors.New("proxy: failed to read domain length from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - bytesToDiscard = int(buf[0]) - default: - return errors.New("proxy: got unknown address type " + strconv.Itoa(int(buf[3])) + " from SOCKS5 proxy at " + s.addr) - } - - if cap(buf) < bytesToDiscard { - buf = make([]byte, bytesToDiscard) - } else { - buf = buf[:bytesToDiscard] - } - if _, err := io.ReadFull(conn, buf); err != nil { - return errors.New("proxy: failed to read address from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - // Also need to discard the port number - if _, err := io.ReadFull(conn, buf[:2]); err != nil { - return errors.New("proxy: failed to read port from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - return nil -} diff --git a/vendor/golang.org/x/net/publicsuffix/gen.go b/vendor/golang.org/x/net/publicsuffix/gen.go deleted file mode 100644 index a2d499529..000000000 --- a/vendor/golang.org/x/net/publicsuffix/gen.go +++ /dev/null @@ -1,713 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package main - -// This program generates table.go and table_test.go based on the authoritative -// public suffix list at https://publicsuffix.org/list/effective_tld_names.dat -// -// The version is derived from -// https://api.github.com/repos/publicsuffix/list/commits?path=public_suffix_list.dat -// and a human-readable form is at -// https://github.com/publicsuffix/list/commits/master/public_suffix_list.dat -// -// To fetch a particular git revision, such as 5c70ccd250, pass -// -url "https://raw.githubusercontent.com/publicsuffix/list/5c70ccd250/public_suffix_list.dat" -// and -version "an explicit version string". - -import ( - "bufio" - "bytes" - "flag" - "fmt" - "go/format" - "io" - "io/ioutil" - "net/http" - "os" - "regexp" - "sort" - "strings" - - "golang.org/x/net/idna" -) - -const ( - // These sum of these four values must be no greater than 32. - nodesBitsChildren = 9 - nodesBitsICANN = 1 - nodesBitsTextOffset = 15 - nodesBitsTextLength = 6 - - // These sum of these four values must be no greater than 32. - childrenBitsWildcard = 1 - childrenBitsNodeType = 2 - childrenBitsHi = 14 - childrenBitsLo = 14 -) - -var ( - maxChildren int - maxTextOffset int - maxTextLength int - maxHi uint32 - maxLo uint32 -) - -func max(a, b int) int { - if a < b { - return b - } - return a -} - -func u32max(a, b uint32) uint32 { - if a < b { - return b - } - return a -} - -const ( - nodeTypeNormal = 0 - nodeTypeException = 1 - nodeTypeParentOnly = 2 - numNodeType = 3 -) - -func nodeTypeStr(n int) string { - switch n { - case nodeTypeNormal: - return "+" - case nodeTypeException: - return "!" - case nodeTypeParentOnly: - return "o" - } - panic("unreachable") -} - -const ( - defaultURL = "https://publicsuffix.org/list/effective_tld_names.dat" - gitCommitURL = "https://api.github.com/repos/publicsuffix/list/commits?path=public_suffix_list.dat" -) - -var ( - labelEncoding = map[string]uint32{} - labelsList = []string{} - labelsMap = map[string]bool{} - rules = []string{} - - // validSuffixRE is used to check that the entries in the public suffix - // list are in canonical form (after Punycode encoding). Specifically, - // capital letters are not allowed. - validSuffixRE = regexp.MustCompile(`^[a-z0-9_\!\*\-\.]+$`) - - shaRE = regexp.MustCompile(`"sha":"([^"]+)"`) - dateRE = regexp.MustCompile(`"committer":{[^{]+"date":"([^"]+)"`) - - comments = flag.Bool("comments", false, "generate table.go comments, for debugging") - subset = flag.Bool("subset", false, "generate only a subset of the full table, for debugging") - url = flag.String("url", defaultURL, "URL of the publicsuffix.org list. If empty, stdin is read instead") - v = flag.Bool("v", false, "verbose output (to stderr)") - version = flag.String("version", "", "the effective_tld_names.dat version") -) - -func main() { - if err := main1(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} - -func main1() error { - flag.Parse() - if nodesBitsTextLength+nodesBitsTextOffset+nodesBitsICANN+nodesBitsChildren > 32 { - return fmt.Errorf("not enough bits to encode the nodes table") - } - if childrenBitsLo+childrenBitsHi+childrenBitsNodeType+childrenBitsWildcard > 32 { - return fmt.Errorf("not enough bits to encode the children table") - } - if *version == "" { - if *url != defaultURL { - return fmt.Errorf("-version was not specified, and the -url is not the default one") - } - sha, date, err := gitCommit() - if err != nil { - return err - } - *version = fmt.Sprintf("publicsuffix.org's public_suffix_list.dat, git revision %s (%s)", sha, date) - } - var r io.Reader = os.Stdin - if *url != "" { - res, err := http.Get(*url) - if err != nil { - return err - } - if res.StatusCode != http.StatusOK { - return fmt.Errorf("bad GET status for %s: %d", *url, res.Status) - } - r = res.Body - defer res.Body.Close() - } - - var root node - icann := false - br := bufio.NewReader(r) - for { - s, err := br.ReadString('\n') - if err != nil { - if err == io.EOF { - break - } - return err - } - s = strings.TrimSpace(s) - if strings.Contains(s, "BEGIN ICANN DOMAINS") { - icann = true - continue - } - if strings.Contains(s, "END ICANN DOMAINS") { - icann = false - continue - } - if s == "" || strings.HasPrefix(s, "//") { - continue - } - s, err = idna.ToASCII(s) - if err != nil { - return err - } - if !validSuffixRE.MatchString(s) { - return fmt.Errorf("bad publicsuffix.org list data: %q", s) - } - - if *subset { - switch { - case s == "ac.jp" || strings.HasSuffix(s, ".ac.jp"): - case s == "ak.us" || strings.HasSuffix(s, ".ak.us"): - case s == "ao" || strings.HasSuffix(s, ".ao"): - case s == "ar" || strings.HasSuffix(s, ".ar"): - case s == "arpa" || strings.HasSuffix(s, ".arpa"): - case s == "cy" || strings.HasSuffix(s, ".cy"): - case s == "dyndns.org" || strings.HasSuffix(s, ".dyndns.org"): - case s == "jp": - case s == "kobe.jp" || strings.HasSuffix(s, ".kobe.jp"): - case s == "kyoto.jp" || strings.HasSuffix(s, ".kyoto.jp"): - case s == "om" || strings.HasSuffix(s, ".om"): - case s == "uk" || strings.HasSuffix(s, ".uk"): - case s == "uk.com" || strings.HasSuffix(s, ".uk.com"): - case s == "tw" || strings.HasSuffix(s, ".tw"): - case s == "zw" || strings.HasSuffix(s, ".zw"): - case s == "xn--p1ai" || strings.HasSuffix(s, ".xn--p1ai"): - // xn--p1ai is Russian-Cyrillic "рф". - default: - continue - } - } - - rules = append(rules, s) - - nt, wildcard := nodeTypeNormal, false - switch { - case strings.HasPrefix(s, "*."): - s, nt = s[2:], nodeTypeParentOnly - wildcard = true - case strings.HasPrefix(s, "!"): - s, nt = s[1:], nodeTypeException - } - labels := strings.Split(s, ".") - for n, i := &root, len(labels)-1; i >= 0; i-- { - label := labels[i] - n = n.child(label) - if i == 0 { - if nt != nodeTypeParentOnly && n.nodeType == nodeTypeParentOnly { - n.nodeType = nt - } - n.icann = n.icann && icann - n.wildcard = n.wildcard || wildcard - } - labelsMap[label] = true - } - } - labelsList = make([]string, 0, len(labelsMap)) - for label := range labelsMap { - labelsList = append(labelsList, label) - } - sort.Strings(labelsList) - - if err := generate(printReal, &root, "table.go"); err != nil { - return err - } - if err := generate(printTest, &root, "table_test.go"); err != nil { - return err - } - return nil -} - -func generate(p func(io.Writer, *node) error, root *node, filename string) error { - buf := new(bytes.Buffer) - if err := p(buf, root); err != nil { - return err - } - b, err := format.Source(buf.Bytes()) - if err != nil { - return err - } - return ioutil.WriteFile(filename, b, 0644) -} - -func gitCommit() (sha, date string, retErr error) { - res, err := http.Get(gitCommitURL) - if err != nil { - return "", "", err - } - if res.StatusCode != http.StatusOK { - return "", "", fmt.Errorf("bad GET status for %s: %d", gitCommitURL, res.Status) - } - defer res.Body.Close() - b, err := ioutil.ReadAll(res.Body) - if err != nil { - return "", "", err - } - if m := shaRE.FindSubmatch(b); m != nil { - sha = string(m[1]) - } - if m := dateRE.FindSubmatch(b); m != nil { - date = string(m[1]) - } - if sha == "" || date == "" { - retErr = fmt.Errorf("could not find commit SHA and date in %s", gitCommitURL) - } - return sha, date, retErr -} - -func printTest(w io.Writer, n *node) error { - fmt.Fprintf(w, "// generated by go run gen.go; DO NOT EDIT\n\n") - fmt.Fprintf(w, "package publicsuffix\n\nvar rules = [...]string{\n") - for _, rule := range rules { - fmt.Fprintf(w, "%q,\n", rule) - } - fmt.Fprintf(w, "}\n\nvar nodeLabels = [...]string{\n") - if err := n.walk(w, printNodeLabel); err != nil { - return err - } - fmt.Fprintf(w, "}\n") - return nil -} - -func printReal(w io.Writer, n *node) error { - const header = `// generated by go run gen.go; DO NOT EDIT - -package publicsuffix - -const version = %q - -const ( - nodesBitsChildren = %d - nodesBitsICANN = %d - nodesBitsTextOffset = %d - nodesBitsTextLength = %d - - childrenBitsWildcard = %d - childrenBitsNodeType = %d - childrenBitsHi = %d - childrenBitsLo = %d -) - -const ( - nodeTypeNormal = %d - nodeTypeException = %d - nodeTypeParentOnly = %d -) - -// numTLD is the number of top level domains. -const numTLD = %d - -` - fmt.Fprintf(w, header, *version, - nodesBitsChildren, nodesBitsICANN, nodesBitsTextOffset, nodesBitsTextLength, - childrenBitsWildcard, childrenBitsNodeType, childrenBitsHi, childrenBitsLo, - nodeTypeNormal, nodeTypeException, nodeTypeParentOnly, len(n.children)) - - text := combineText(labelsList) - if text == "" { - return fmt.Errorf("internal error: makeText returned no text") - } - for _, label := range labelsList { - offset, length := strings.Index(text, label), len(label) - if offset < 0 { - return fmt.Errorf("internal error: could not find %q in text %q", label, text) - } - maxTextOffset, maxTextLength = max(maxTextOffset, offset), max(maxTextLength, length) - if offset >= 1<= 1< 64 { - n, plus = 64, " +" - } - fmt.Fprintf(w, "%q%s\n", text[:n], plus) - text = text[n:] - } - - if err := n.walk(w, assignIndexes); err != nil { - return err - } - - fmt.Fprintf(w, ` - -// nodes is the list of nodes. Each node is represented as a uint32, which -// encodes the node's children, wildcard bit and node type (as an index into -// the children array), ICANN bit and text. -// -// If the table was generated with the -comments flag, there is a //-comment -// after each node's data. In it is the nodes-array indexes of the children, -// formatted as (n0x1234-n0x1256), with * denoting the wildcard bit. The -// nodeType is printed as + for normal, ! for exception, and o for parent-only -// nodes that have children but don't match a domain label in their own right. -// An I denotes an ICANN domain. -// -// The layout within the uint32, from MSB to LSB, is: -// [%2d bits] unused -// [%2d bits] children index -// [%2d bits] ICANN bit -// [%2d bits] text index -// [%2d bits] text length -var nodes = [...]uint32{ -`, - 32-nodesBitsChildren-nodesBitsICANN-nodesBitsTextOffset-nodesBitsTextLength, - nodesBitsChildren, nodesBitsICANN, nodesBitsTextOffset, nodesBitsTextLength) - if err := n.walk(w, printNode); err != nil { - return err - } - fmt.Fprintf(w, `} - -// children is the list of nodes' children, the parent's wildcard bit and the -// parent's node type. If a node has no children then their children index -// will be in the range [0, 6), depending on the wildcard bit and node type. -// -// The layout within the uint32, from MSB to LSB, is: -// [%2d bits] unused -// [%2d bits] wildcard bit -// [%2d bits] node type -// [%2d bits] high nodes index (exclusive) of children -// [%2d bits] low nodes index (inclusive) of children -var children=[...]uint32{ -`, - 32-childrenBitsWildcard-childrenBitsNodeType-childrenBitsHi-childrenBitsLo, - childrenBitsWildcard, childrenBitsNodeType, childrenBitsHi, childrenBitsLo) - for i, c := range childrenEncoding { - s := "---------------" - lo := c & (1<> childrenBitsLo) & (1<>(childrenBitsLo+childrenBitsHi)) & (1<>(childrenBitsLo+childrenBitsHi+childrenBitsNodeType) != 0 - if *comments { - fmt.Fprintf(w, "0x%08x, // c0x%04x (%s)%s %s\n", - c, i, s, wildcardStr(wildcard), nodeTypeStr(nodeType)) - } else { - fmt.Fprintf(w, "0x%x,\n", c) - } - } - fmt.Fprintf(w, "}\n\n") - fmt.Fprintf(w, "// max children %d (capacity %d)\n", maxChildren, 1<= 1<= 1<= 1< 0 && ss[0] == "" { - ss = ss[1:] - } - return ss -} - -// crush combines a list of strings, taking advantage of overlaps. It returns a -// single string that contains each input string as a substring. -func crush(ss []string) string { - maxLabelLen := 0 - for _, s := range ss { - if maxLabelLen < len(s) { - maxLabelLen = len(s) - } - } - - for prefixLen := maxLabelLen; prefixLen > 0; prefixLen-- { - prefixes := makePrefixMap(ss, prefixLen) - for i, s := range ss { - if len(s) <= prefixLen { - continue - } - mergeLabel(ss, i, prefixLen, prefixes) - } - } - - return strings.Join(ss, "") -} - -// mergeLabel merges the label at ss[i] with the first available matching label -// in prefixMap, where the last "prefixLen" characters in ss[i] match the first -// "prefixLen" characters in the matching label. -// It will merge ss[i] repeatedly until no more matches are available. -// All matching labels merged into ss[i] are replaced by "". -func mergeLabel(ss []string, i, prefixLen int, prefixes prefixMap) { - s := ss[i] - suffix := s[len(s)-prefixLen:] - for _, j := range prefixes[suffix] { - // Empty strings mean "already used." Also avoid merging with self. - if ss[j] == "" || i == j { - continue - } - if *v { - fmt.Fprintf(os.Stderr, "%d-length overlap at (%4d,%4d): %q and %q share %q\n", - prefixLen, i, j, ss[i], ss[j], suffix) - } - ss[i] += ss[j][prefixLen:] - ss[j] = "" - // ss[i] has a new suffix, so merge again if possible. - // Note: we only have to merge again at the same prefix length. Shorter - // prefix lengths will be handled in the next iteration of crush's for loop. - // Can there be matches for longer prefix lengths, introduced by the merge? - // I believe that any such matches would by necessity have been eliminated - // during substring removal or merged at a higher prefix length. For - // instance, in crush("abc", "cde", "bcdef"), combining "abc" and "cde" - // would yield "abcde", which could be merged with "bcdef." However, in - // practice "cde" would already have been elimintated by removeSubstrings. - mergeLabel(ss, i, prefixLen, prefixes) - return - } -} - -// prefixMap maps from a prefix to a list of strings containing that prefix. The -// list of strings is represented as indexes into a slice of strings stored -// elsewhere. -type prefixMap map[string][]int - -// makePrefixMap constructs a prefixMap from a slice of strings. -func makePrefixMap(ss []string, prefixLen int) prefixMap { - prefixes := make(prefixMap) - for i, s := range ss { - // We use < rather than <= because if a label matches on a prefix equal to - // its full length, that's actually a substring match handled by - // removeSubstrings. - if prefixLen < len(s) { - prefix := s[:prefixLen] - prefixes[prefix] = append(prefixes[prefix], i) - } - } - - return prefixes -} diff --git a/vendor/golang.org/x/net/publicsuffix/list.go b/vendor/golang.org/x/net/publicsuffix/list.go deleted file mode 100644 index 8bbf3bcd7..000000000 --- a/vendor/golang.org/x/net/publicsuffix/list.go +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:generate go run gen.go - -// Package publicsuffix provides a public suffix list based on data from -// http://publicsuffix.org/. A public suffix is one under which Internet users -// can directly register names. -package publicsuffix // import "golang.org/x/net/publicsuffix" - -// TODO: specify case sensitivity and leading/trailing dot behavior for -// func PublicSuffix and func EffectiveTLDPlusOne. - -import ( - "fmt" - "net/http/cookiejar" - "strings" -) - -// List implements the cookiejar.PublicSuffixList interface by calling the -// PublicSuffix function. -var List cookiejar.PublicSuffixList = list{} - -type list struct{} - -func (list) PublicSuffix(domain string) string { - ps, _ := PublicSuffix(domain) - return ps -} - -func (list) String() string { - return version -} - -// PublicSuffix returns the public suffix of the domain using a copy of the -// publicsuffix.org database compiled into the library. -// -// icann is whether the public suffix is managed by the Internet Corporation -// for Assigned Names and Numbers. If not, the public suffix is privately -// managed. For example, foo.org and foo.co.uk are ICANN domains, -// foo.dyndns.org and foo.blogspot.co.uk are private domains. -// -// Use cases for distinguishing ICANN domains like foo.com from private -// domains like foo.appspot.com can be found at -// https://wiki.mozilla.org/Public_Suffix_List/Use_Cases -func PublicSuffix(domain string) (publicSuffix string, icann bool) { - lo, hi := uint32(0), uint32(numTLD) - s, suffix, wildcard := domain, len(domain), false -loop: - for { - dot := strings.LastIndex(s, ".") - if wildcard { - suffix = 1 + dot - } - if lo == hi { - break - } - f := find(s[1+dot:], lo, hi) - if f == notFound { - break - } - - u := nodes[f] >> (nodesBitsTextOffset + nodesBitsTextLength) - icann = u&(1<>= nodesBitsICANN - u = children[u&(1<>= childrenBitsLo - hi = u & (1<>= childrenBitsHi - switch u & (1<>= childrenBitsNodeType - wildcard = u&(1<>= nodesBitsTextLength - offset := x & (1< len(b[j]) -} - -// eTLDPlusOneTestCases come from -// https://github.com/publicsuffix/list/blob/master/tests/test_psl.txt -var eTLDPlusOneTestCases = []struct { - domain, want string -}{ - // Empty input. - {"", ""}, - // Unlisted TLD. - {"example", ""}, - {"example.example", "example.example"}, - {"b.example.example", "example.example"}, - {"a.b.example.example", "example.example"}, - // TLD with only 1 rule. - {"biz", ""}, - {"domain.biz", "domain.biz"}, - {"b.domain.biz", "domain.biz"}, - {"a.b.domain.biz", "domain.biz"}, - // TLD with some 2-level rules. - {"com", ""}, - {"example.com", "example.com"}, - {"b.example.com", "example.com"}, - {"a.b.example.com", "example.com"}, - {"uk.com", ""}, - {"example.uk.com", "example.uk.com"}, - {"b.example.uk.com", "example.uk.com"}, - {"a.b.example.uk.com", "example.uk.com"}, - {"test.ac", "test.ac"}, - // TLD with only 1 (wildcard) rule. - {"mm", ""}, - {"c.mm", ""}, - {"b.c.mm", "b.c.mm"}, - {"a.b.c.mm", "b.c.mm"}, - // More complex TLD. - {"jp", ""}, - {"test.jp", "test.jp"}, - {"www.test.jp", "test.jp"}, - {"ac.jp", ""}, - {"test.ac.jp", "test.ac.jp"}, - {"www.test.ac.jp", "test.ac.jp"}, - {"kyoto.jp", ""}, - {"test.kyoto.jp", "test.kyoto.jp"}, - {"ide.kyoto.jp", ""}, - {"b.ide.kyoto.jp", "b.ide.kyoto.jp"}, - {"a.b.ide.kyoto.jp", "b.ide.kyoto.jp"}, - {"c.kobe.jp", ""}, - {"b.c.kobe.jp", "b.c.kobe.jp"}, - {"a.b.c.kobe.jp", "b.c.kobe.jp"}, - {"city.kobe.jp", "city.kobe.jp"}, - {"www.city.kobe.jp", "city.kobe.jp"}, - // TLD with a wildcard rule and exceptions. - {"ck", ""}, - {"test.ck", ""}, - {"b.test.ck", "b.test.ck"}, - {"a.b.test.ck", "b.test.ck"}, - {"www.ck", "www.ck"}, - {"www.www.ck", "www.ck"}, - // US K12. - {"us", ""}, - {"test.us", "test.us"}, - {"www.test.us", "test.us"}, - {"ak.us", ""}, - {"test.ak.us", "test.ak.us"}, - {"www.test.ak.us", "test.ak.us"}, - {"k12.ak.us", ""}, - {"test.k12.ak.us", "test.k12.ak.us"}, - {"www.test.k12.ak.us", "test.k12.ak.us"}, - // Punycoded IDN labels - {"xn--85x722f.com.cn", "xn--85x722f.com.cn"}, - {"xn--85x722f.xn--55qx5d.cn", "xn--85x722f.xn--55qx5d.cn"}, - {"www.xn--85x722f.xn--55qx5d.cn", "xn--85x722f.xn--55qx5d.cn"}, - {"shishi.xn--55qx5d.cn", "shishi.xn--55qx5d.cn"}, - {"xn--55qx5d.cn", ""}, - {"xn--85x722f.xn--fiqs8s", "xn--85x722f.xn--fiqs8s"}, - {"www.xn--85x722f.xn--fiqs8s", "xn--85x722f.xn--fiqs8s"}, - {"shishi.xn--fiqs8s", "shishi.xn--fiqs8s"}, - {"xn--fiqs8s", ""}, -} - -func TestEffectiveTLDPlusOne(t *testing.T) { - for _, tc := range eTLDPlusOneTestCases { - got, _ := EffectiveTLDPlusOne(tc.domain) - if got != tc.want { - t.Errorf("%q: got %q, want %q", tc.domain, got, tc.want) - } - } -} diff --git a/vendor/golang.org/x/net/publicsuffix/table.go b/vendor/golang.org/x/net/publicsuffix/table.go deleted file mode 100644 index 5db1e6986..000000000 --- a/vendor/golang.org/x/net/publicsuffix/table.go +++ /dev/null @@ -1,9093 +0,0 @@ -// generated by go run gen.go; DO NOT EDIT - -package publicsuffix - -const version = "publicsuffix.org's public_suffix_list.dat, git revision 45a2bf8ef3e22000fbe4bfa5f9252db41d777001 (2017-01-18T01:04:06Z)" - -const ( - nodesBitsChildren = 9 - nodesBitsICANN = 1 - nodesBitsTextOffset = 15 - nodesBitsTextLength = 6 - - childrenBitsWildcard = 1 - childrenBitsNodeType = 2 - childrenBitsHi = 14 - childrenBitsLo = 14 -) - -const ( - nodeTypeNormal = 0 - nodeTypeException = 1 - nodeTypeParentOnly = 2 -) - -// numTLD is the number of top level domains. -const numTLD = 1554 - -// Text is the combined text of all labels. -const text = "bikedagestangeorgeorgiaxagrocerybnikahokutobishimaizuruhreportar" + - "nobrzegyptianaturalhistorymuseumcentereviewskrakoweddinggfarmers" + - "einexus-2bilbaogakievenesalangenikiiyamanouchikuhokuryugasakitau" + - "rayasudabillustrationikkoebenhavnikolaevennodessagamiharabiomuta" + - "shinainfinitintuitattoolsztynsettlersalondonetskarpaczeladzjcbre" + - "mangerbirdartcenterprisesakikuchikuseikarugapartmentsaltdalimoli" + - "serniabirkenesoddtangenovaravennagasukeverbankaruizawabirthplace" + - "vje-og-hornnesalvadordalibabajddarchaeologyusuisserveexchangebja" + - "rkoyuufcfanikonantanangerbjerkreimbalsanagochihayaakasakawaharau" + - "malopolskanlandds3-us-west-1bjugninohekinannestadrangedalindasda" + - "burblockbusternidray-dnsupdaterbloombergbauerninomiyakonojosoyro" + - "rosalzburgjovikarumaifarmsteadraydnsamegawabloxcmsamnangerblueda" + - "ncebmoattachmentsamsclubindalindesnesamsungladell-ogliastraderbm" + - "sandvikcoromantovalle-d-aostatic-accessanfranciscofreakunemurora" + - "ngeiseiyoichiropracticasinordre-landrivelandrobaknoluoktabuseekl" + - "ogesurancertmgretachikawakkanaibetsubamericanfamilydscloudcontro" + - "lledekafjordrudunsangoppdalivornobmweirbnpparibaselburglassassin" + - "ationalheritagematsubarakawagoebnrwfarsundupontariobonnirasakinu" + - "yamashinashikitchenishiazainvestmentsanjournalismailillesandefjo" + - "rdurbanamexhibitionishigobookingliwicebootsannanishiharaboschaef" + - "flerdalomzaporizhzhegurinzais-a-bulls-fanishiizunazukis-a-candid" + - "atebostikasaokamiminersannohelplfinancialorenskoglobalashovhachi" + - "nohedmarkashibatakasakiyokawarabostonakijinsekikogentinglobodoes" + - "-itvedestrandurhamburglogowhalingloppenzaogashimadachicagoboatsa" + - "nokashiharabotanicalgardenishikatakayamatta-varjjataxihuanishika" + - "tsuragithubusercontentgoryuzawabotanicgardenishikawazukamitondab" + - "ayashiogamagoriziabotanybouncemerckmsdnipropetrovskjakdnepropetr" + - "ovskiervaapsteiermarkashiwarabounty-fullensakerrypropertiesantab" + - "arbaraboutiquebecngmbhartiffanybozentsujiiebradescorporationishi" + - "merabrandywinevalleybrasiliabresciabrindisibenikebristoloslocalh" + - "istoryggeelvinckashiwazakiyosatokashikiyosemitebritishcolumbialo" + - "wiezachpomorskienishinomiyashironobroadcastlefrakkestadvrcambrid" + - "gestonextdirectjeldsundvrdnsantacruzsantafedextraspacekitagataji" + - "rittogoldpoint2thisamitsukebroadwaybroke-itjmaxxxboxenapponazure" + - "-mobilebrokerbronnoysundwgminakamichiharabrothermesaverdeatnurem" + - "bergmodellingmxfinitybrowsersafetymarketsanukis-a-catererbrumund" + - "dalotenkawabrunelasticbeanstalkasukabedzin-the-bandaikawachinaga" + - "noharamcoalaskanittedallasalleasinglest-mon-blogueurovisionthewi" + - "fiat-band-campaniabrusselsaotomemergencyberlevagangaviikanonjis-" + - "a-celticsfanishinoomotegobruxellesapodlasiellakasamatsudovre-eik" + - "erbryanskjervoyagebrynewhampshirebungoonordlandyndns-at-workingg" + - "roupalacebuskerudinewjerseybuzenishinoshimattelefonicarbonia-igl" + - "esias-carboniaiglesiascarboniabuzzlgrimstadyndns-blogdnsapporobw" + - "hoswhokksundyndns-freebox-ostrowiecateringebuilderschmidtre-gaul" + - "dalottebzhitomirumalselvendrellottokonamegatakasugais-a-chefashi" + - "onishiokoppegardyndns-homednsardegnamsskoganeis-a-conservativefs" + - "nillfjordyndns-ipaleocondoshichinohealth-carereformitakeharaconf" + - "erenceconstructionconsuladoesntexistanbullensvanguardyndns-wikin" + - "dlegokasells-for-lessaudaconsultanthropologyconsultingvolluxuryc" + - "ontactoyookanmakiwakunigamifunecontemporaryarteducationalchikugo" + - "doharuovatoyosatoyakokonoecontractorskenconventureshinodesashibe" + - "tsuikinderoycookingchannelblagdenesnaaseralingenkainanaejrietisa" + - "latinabenonichernihivanovodkagoshimalvikasumigaurawa-mazowszexjc" + - "palermomahachijorpelandyndns-mailouvreisenishitosashimizunaminam" + - "iashigaracoolkuszkoladbrokesauheradyndns-workisboringrpamperedch" + - "efastlylbaltimore-og-romsdalwaysdatabaseballangenoamishirasatoch" + - "igiessenebakkeshibechambagriculturennebudejjudygarlandigitalavan" + - "genavigationavuotnaklodzkodairamusementarumizusawabruzzoologyeon" + - "gbuk12cooperaunitemasekatsushikabeeldengeluidyndns1copenhagencyc" + - "lopedichernivtsiciliacorsicagliarightathomeftpanamacorvettenriku" + - "zentakataitogliattiresavannahgacosenzaganquannakadomaritimekeepi" + - "ngatlantaijis-a-financialadvisor-aurdaluzerncosidnsfor-better-th" + - "anawawildlifedjeffersoncostumedio-campidano-mediocampidanomedioc" + - "ouchpotatofriesaves-the-whalessandria-trani-barletta-andriatrani" + - "barlettaandriacouncilvivano-frankivskatsuyamasfjordencouponsavon" + - "aplesaxocoursesbschokoladencq-acranbrookuwanalyticscholarshipsch" + - "oolcreditcardynnschulezajskydivingruecreditunioncremonashorokana" + - "iecrewilliamhillcricketrzyncrimeastcoastaldefencecrotonewyorkshi" + - "recipesaro-urbino-pesarourbinopesaromasvuotnaharimamurogawacrown" + - "providercrsvpanasonichernovtsykkylvenetogakushimotoganewportllig" + - "atjxn--0trq7p7nnishiwakis-a-cpadoval-daostavalleycruiseschwarzgw" + - "angjuegoshikiminokamoenairtraffichiryukyuragifuchungbukasuyaltak" + - "ashimaseratis-a-cubicle-slavellinowtvalleaostatoilowiczest-le-pa" + - "trondheimmobilienissandnessjoenissayokoshibahikariwanumatakazaki" + - "s-a-democratkmaxxn--11b4c3dyndns-office-on-the-webcampobassociat" + - "esardiniacryptonomichigangwoncuisinellahppiacenzakopanerairguard" + - "ynv6culturalcentertainmentoyotaris-a-geekgalaxycuneocupcakecxn--" + - "1ctwolominamatakkokaminokawanishiaizubangecymrussiacyonabarulsan" + - "doycyouthdfcbankaufenfiguerestaurantoyotomiyazakis-a-greenfilate" + - "liafilminamiawajikis-a-guruslivinghistoryfinalfinancefineartscie" + - "ntistoragefinlandfinnoyfirebaseapparliamentoyotsukaidownloadfire" + - "nzefirestonefirmdaleirfjordfishingolffanscjohnsonfitjarqhachioji" + - "yahikobeatscotlandfitnessettlementoyourafjalerflesbergushikamifu" + - "ranoshiroomuraflickragerotikakamigaharaflightscrapper-siteflirfl" + - "ogintogurafloraflorencefloridavvesiidazaifudaigojomedizinhistori" + - "schescrappingxn--1lqs71dfloristanohatakahamaniwakuratexascolipic" + - "enord-aurdalipayflorogerserveftparmaflowerservegame-serversaille" + - "servehalflifestyleflynnhubambleclercartoonartdecoldwarmiamibugat" + - "tipschlesisches3-us-west-2fndfoodnetworkshoppingfor-ourfor-somee" + - "thnologyfor-theaterforexrothruherecreationforgotdnservehttparoch" + - "erkasyno-dservehumourforli-cesena-forlicesenaforlikescandynamic-" + - "dnserveirchitachinakagawatchandclockaszubyforsaleirvikazoforsand" + - "asuoloftoystre-slidrettozawafortmissoulair-traffic-controlleyfor" + - "tworthachirogatakahatakaishimogosenforuminamibosogndalfosneserve" + - "minecraftozsdev-myqnapcloudcontrolappspotagerfotaruis-a-hard-wor" + - "kerfoxfordedyn-ip24freeboxoservemp3utilitiesquarezzoologicalvink" + - "lein-addrammenuernbergdyniabogadocscbnl-o-g-i-nativeamericananti" + - "ques3-ap-northeast-1kappchizippodhaleangaviikadenadexeterepbodyn" + - "athomebuilt3l3p0rtargets-itargiving12000emmafanconagawakayamadri" + - "dvagsoyericssonyoursidealerimo-i-ranaamesjevuemielno-ip6freemaso" + - "nryfreiburgfreightcminamidaitomangotsukisosakitagawafreseniuscou" + - "ntryestateofdelawaredstonefribourgfriuli-v-giuliafriuli-ve-giuli" + - "afriuli-vegiuliafriuli-venezia-giuliafriuli-veneziagiuliafriuli-" + - "vgiuliafriuliv-giuliafriulive-giuliafriulivegiuliafriulivenezia-" + - "giuliafriuliveneziagiuliafriulivgiuliafrlfroganservep2parservepi" + - "cservequakefrognfrolandfrom-akrehamnfrom-alfrom-arfrom-azwinbana" + - "narepublicasadelamonedatsunanjoburgjerstadotsuruokakegawasnesodd" + - "enmarkhangelskiptveterinairealtychyattorneyagawalmartatamotors3-" + - "ap-south-1from-capebretonamiastapleservesarcasmatartanddesignfro" + - "m-collectionfrom-ctrani-andria-barletta-trani-andriafrom-dchitos" + - "etogitsuldalucaniafrom-defenseljordfrom-flanderservicesettsurgeo" + - "nshalloffamemorialfrom-gausdalfrom-higashiagatsumagoizumizakiraf" + - "rom-iafrom-idfrom-ilfrom-incheonfrom-ksevastopolefrom-kyowariasa" + - "hikawafrom-lajollamericanexpressexyfrom-mannortonsbergfrom-mdfro" + - "m-megurokunohealthcareersevenassisicilyfrom-midoris-a-hunterfrom" + - "-mnfrom-mochizukirkenesewindmillfrom-msfranziskanerdpolicefrom-m" + - "tnfrom-nchloefrom-ndfrom-nefrom-nhktraniandriabarlettatraniandri" + - "afrom-njelenia-gorafrom-nminamiechizenfrom-nvalled-aostavangerfr" + - "om-nyfrom-ohkurafrom-oketohmansionshangrilanciafrom-orfrom-pader" + - "bornfrom-pratohnoshoooshikamaishimodatextileitungsenfrom-ris-a-k" + - "nightpointtokaizukameokameyamatotakadafrom-schoenbrunnfrom-sdfro" + - "m-tnfrom-txn--1qqw23afrom-utazuerichardlillehammerfeste-ipartis-" + - "a-landscaperfrom-vaksdalfrom-vtranoyfrom-wafrom-wielunnerfrom-wv" + - "alledaostavernfrom-wyfrosinonefrostalowa-wolawafroyahababyglandf" + - "stcgroupartnersharis-a-lawyerfujiiderafujikawaguchikonefujiminoh" + - "tawaramotoineppubolognakanotoddenfujinomiyadafujiokayamanxn--2m4" + - "a15efujisatoshonairportland-4-salernoboribetsucksharpartshawaiij" + - "imarugame-hostrodawarafujisawafujishiroishidakabiratoridegreefuj" + - "itsurugashimamateramodalenfujixeroxn--30rr7yfujiyoshidafukayabea" + - "rdubaiduckdnshellaspeziafukuchiyamadafukudominichocolatelevision" + - "issedaluccapitalonewmexicoffeedbackplaneapplinzis-a-designerimar" + - "umorimachidafukuis-a-liberalfukumitsubishigakirovogradoyfukuokaz" + - "akiryuohadanotaireshimojis-a-libertarianfukuroishikarikaturindal" + - "fukusakisarazurewebsiteshikagamiishibukawafukuyamagatakaharustka" + - "noyakagefunabashiriuchinadafunagatakahashimamakishiwadafunahashi" + - "kamiamakusatsumasendaisennangonohejis-a-linux-useranishiaritabas" + - "hijonawatefundaciofuoiskujukuriyamaoris-a-llamarylandfuosskoczow" + - "indowshimokawafurnituredumbrellanbibaidarfurubiraquarelleborkang" + - "erfurudonostiaarpartyfurukawairtelecityeatshimokitayamafusodegau" + - "rafussaikisofukushimapasadenamsosnowiechofunatorientexpressarluc" + - "ernefutabayamaguchinomigawafutboldlygoingnowhere-for-moregontrai" + - "lroadfuttsurugimperiafuturehostingfuturemailingfvgfyis-a-musicia" + - "nfylkesbiblackfridayfyresdalhangglidinghangoutsystemscloudfrontd" + - "oorhannanmokuizumodenakasatsunais-a-painteractivegarsheis-a-pats" + - "fanhannotteroyhanyuzenhapmirhareidsbergenharstadharvestcelebrati" + - "onhasamarnardalhasaminami-alpssells-itransportransurlhashbanghas" + - "udahasura-appassenger-associationhasvikazunohatogayahoohatoyamaz" + - "akitahiroshimarriottrapaniimimatakatoris-a-personaltrainerhatsuk" + - "aichikaiseis-a-photographerokuappaviancargodaddynaliascoli-picen" + - "oipirangamvikddielddanuorrissagaeroclubmedecincinnationwidealsta" + - "haugesunderseaportsinfolldalabamagasakishimabarackmazehattfjelld" + - "alhayashimamotobungotakadapliernewhollandhazuminobusellsyourhome" + - "goodshimotsumahboehringerikehelsinkitakamiizumisanofidelitysvard" + - "ollshinichinanhembygdsforbundhemneshinjournalistjohnhemsedalhepf" + - "orgeherokussldheroyhgtvallee-aosteroyhigashichichibunkyonanaoshi" + - "mageandsoundandvisionhigashihiroshimanehigashiizumozakitakatakam" + - "oriokalmykiahigashikagawahigashikagurasoedahigashikawakitaaikita" + - "kyushuaiahigashikurumeiwamarshallstatebankfhappouhigashimatsushi" + - "maritimodernhigashimatsuyamakitaakitadaitoigawahigashimurayamamo" + - "torcycleshinjukumanohigashinarusembokukitamidsundhigashinehigash" + - "iomihachimanchesterhigashiosakasayamanakakogawahigashishirakawam" + - "atakanabeautydalhigashisumiyoshikawaminamiaikitamotosumitakagild" + - "eskaliszhigashitsunowruzhgorodeohigashiurausukitanakagusukumodum" + - "inamiiselectravelchannelhigashiyamatokoriyamanashifteditchyourip" + - "fizerhigashiyodogawahigashiyoshinogaris-a-playerhiraizumisatohob" + - "by-sitehirakatashinagawahiranais-a-republicancerresearchaeologic" + - "aliforniahirarahiratsukagawahirayaitakanezawahistorichouseshinka" + - "migotoyohashimotoshimahitachiomiyaginankokubunjis-a-rockstaracho" + - "wicehitachiotagooglecodespotravelersinsurancehitraeumtgeradeloit" + - "tevadsoccertificationhjartdalhjelmelandholeckobierzyceholidayhom" + - "eipgfoggiahomelinkhakassiahomelinuxn--32vp30haebaruminamifuranoh" + - "omeofficehomesecuritymaceratakaokaluganskodjejuifminamiizukamiok" + - "amikitayamatsuris-a-socialistmein-vigorgehomesecuritypccwinnersh" + - "inshinotsurgeryhomesenseminehomeunixn--3bst00minamimakis-a-soxfa" + - "nhondahoneywellbeingzonehongopocznosegawahonjyoitakarazukamakura" + - "zakitashiobarahornindalhorseoulminamiminowahortendofinternet-dns" + - "hinshirohospitalhoteleshintokushimahotmailhoyangerhoylandetroits" + - "kolelhumanitieshintomikasaharahurdalhurumajis-a-studentalhyllest" + - "adhyogoris-a-teacherkassymantechnologyhyugawarahyundaiwafunehzch" + - "onanbuildingripescaravantaajlchoyodobashichikashukujitawarajlljm" + - "pharmacienshirakofuefukihaboromskoguchikuzenjnjeonnamerikawauejo" + - "yokaichibahcavuotnagaranzannefrankfurtrentino-alto-adigejpmorgan" + - "jpnjprshiranukamogawajuniperjurkoshunantokigawakosugekotohiradom" + - "ainsureggiocalabriakotourakouhokutamakis-an-artisteinkjerusalemb" + - "roiderykounosupplieshiraokanagawakouyamashikokuchuokouzushimasoy" + - "kozagawakozakis-an-engineeringkpnkppspdnshiratakahagivestbytomar" + - "idagawassamukawataricohdatingkrasnodarkredirectmeldalkristiansan" + - "dcatshishikuis-an-entertainerkristiansundkrodsheradkrokstadelval" + - "daostarostwodzislawioshisognekryminamisanrikubetsupportrentino-a" + - "ltoadigekumatorinokumejimasudakumenanyokkaichirurgiens-dentistes" + - "-en-francekunisakis-bykunitachiarailwaykunitomigusukumamotoyamas" + - "sa-carrara-massacarraramassabusinessebyklegallocus-1kunneppulawy" + - "kunstsammlungkunstunddesignkuokgrouphdkureggioemiliaromagnakayam" + - "atsumaebashikshacknetrentino-s-tirollagrigentomologyeonggiehtavu" + - "oatnagaivuotnagaokakyotambabia-goracleaningkurgankurobelaudibleb" + - "timnetzkurogimilanokuroisoftwarendalenugkuromatsunais-certifiedo" + - "gawarabikomaezakirunorthwesternmutualkurotakikawasakis-foundatio" + - "nkushirogawakusupplykutchanelkutnokuzumakis-gonekvafjordkvalsund" + - "kvamfamberkeleykvanangenkvinesdalkvinnheradkviteseidskogkvitsoyk" + - "wpspiegelkzmissilevangermisugitokorozawamitourismolancastermitoy" + - "oakemiuramiyazumiyotamanomjondalenmlbfanmonmouthagebostadmonster" + - "monticellombardiamondshisuifuelveruminamitanemontrealestatefarme" + - "quipmentrentino-stirolmonza-brianzaporizhzhiamonza-e-della-brian" + - "zapposhitaramamonzabrianzaptokuyamatsusakahoginowaniihamatamakaw" + - "ajimarburgmonzaebrianzaramonzaedellabrianzamoparachutingmordovia" + - "jessheiminamiuonumatsumotofukemoriyamatsushigemoriyoshimilitarym" + - "ormoneymoroyamatsuuramortgagemoscowitdkmpspbarcelonagasakijobser" + - "verisignieznord-odalaziobihirosakikamijimassnasaarlandd-dnshome-" + - "webservercellikes-piedmontblancomeeres3-ap-southeast-1moseushist" + - "orymosjoenmoskeneshizukuishimofusaitamatsukuris-into-gamessinats" + - "ukigatakasagotembaixadamosshizuokananporovigotpantheonsitemosvik" + - "nx-serveronakatsugawamoteginozawaonsenmoviemovistargardmtpchrist" + - "masakikugawatchesarufutsunomiyawakasaikaitakoelniyodogawamtranby" + - "muenstermugithubcloudusercontentrentino-sud-tirolmuikamisatokama" + - "chippubetsubetsugarumukochikushinonsenergymulhouservebeermunakat" + - "anemuncieszynmuosattemuphiladelphiaareadmyblogsitemurmanskolobrz" + - "egersundmurotorcraftrentino-sudtirolmusashimurayamatsuzakis-leet" + - "rdmusashinoharamuseetrentino-sued-tirolmuseumverenigingmutsuzawa" + - "mutuellewismillermy-vigorlicemy-wanggouvicenzamyactivedirectorym" + - "yasustor-elvdalmycdn77-securechtrainingmydissentrentino-suedtiro" + - "lmydrobofagemydshoujis-lostre-toteneis-a-techietis-a-therapistoi" + - "amyeffectrentinoa-adigemyfirewallonieruchomoscienceandindustrynm" + - "yfritzmyftpaccesshowamyfusionmyhome-serverrankoshigayamelhusgard" + - "enmykolaivaolbia-tempio-olbiatempioolbialystokkepnogiftshowtimet" + - "eorapphilatelymymediapchromedicaltanissettairamyokohamamatsudamy" + - "pepsongdalenviknakanojohanamakinoharamypetshriramlidlugolekagami" + - "nogatagajobojis-not-certifieducatorahimeshimakanegasakinkobayash" + - "ikaoirminamiogunicomcastresistancemyphotoshibahccavuotnagareyama" + - "lborkdalvdalcesienarashinomypsxn--3e0b707emysecuritycamerakermys" + - "hopblocksigdalmyvnchryslerpictetrentinoaadigepicturesimple-urlpi" + - "emontepilotsirdalpimientaketomisatolgapinkomakiyosunndalpioneerp" + - "ippuphoenixn--3oq18vl8pn36apiszpittsburghofauskedsmokorsetagayas" + - "ells-for-ulvikautokeinopiwatepizzapkomatsushimashikizunokunimiho" + - "boleslawiechristiansburgriwataraidyndns-picsarpsborgroks-thisaya" + - "manobeokakudamatsueplanetariuminamiyamashirokawanabellevuelosang" + - "elesjaguarchitecturealtorlandplantationplantslingplatforminanopl" + - "aystationplazaplchungnamdalseidfjordyndns-remotewdyndns-serverda" + - "luroyplombardynamisches-dnslupskomforbarclaycards3-website-ap-no" + - "rtheast-1plumbingopmnpodzonepohlpoivronpokerpokrovskommunalforbu" + - "ndpolitiendapolkowicepoltavalle-aostathellexusdecorativeartsnoas" + - "aitomobellunorddalpomorzeszowithgoogleapisa-hockeynutsiracusakat" + - "akinouepordenonepornporsangerporsanguidelmenhorstalbansokanazawa" + - "porsgrunnanpoznanpraxis-a-bookkeeperugiaprdpreservationpresidiop" + - "rgmrprimeloyalistockholmestrandprincipeprivatizehealthinsurancep" + - "rochowiceproductionsokndalprofbsbxn--1lqs03nprogressivegasiaproj" + - "ectrentinoalto-adigepromombetsurfbx-ostrowwlkpmgulenpropertyprot" + - "ectionprotonetrentinoaltoadigeprudentialpruszkowithyoutubentleyp" + - "rzeworskogptplusterpvtrentinos-tirolpwchurchaseljeepostfoldnavyp" + - "zqldqponqslgbtrentinostirolquicksytesolarssonqvcirclegnicafedera" + - "tionstufftoread-booksnesolundbeckommunestuttgartrentoyokawasusak" + - "is-slickharkovalleeaosteigensusonosuzakaneyamazoesuzukaniepcesuz" + - "ukis-uberleetrentino-a-adigesvalbardunloppacificircustomersveios" + - "velvikomvuxn--3ds443gsvizzeraswedenswidnicarrierswiebodzindianap" + - "olis-a-bloggerswiftcoversicherungswinoujscienceandhistoryswisshi" + - "kis-very-badaddjamisonsynology-dsolutionsolognetuscanytushuissie" + - "r-justicetuvalle-daostaticsootuxfamilyvenneslaskerrylogisticsopo" + - "trentinosud-tirolvestfoldvestnesor-odalvestre-slidreamhostersor-" + - "varangervestre-totennishiawakuravestvagoyvevelstadvibo-valentiav" + - "ibovalentiavideovillaskoyabearalvahkihokumakogengerdalpha-myqnap" + - "cloudapplebesbydgoszczecinemakeupowiathletajimabariakembuchikuma" + - "gayagawakuyabukicks-assedicitadeliveryvinnicartiervinnytsiavipsi" + - "naapphonefossilkomaganevirginiavirtualvirtueeldomeindianmarketin" + - "gvirtuelvisakegawavistaprinternationalfirearmsorfoldviterboltroa" + - "ndinosaurepaircraftrevisohughesomavivoldavlaanderenvladikavkazim" + - "ierz-dolnyvladimirvlogoiphotographysiovolkswagentsorreisahayakaw" + - "akamiichikawamisatotalvologdanskongsvingervolvolkenkundenvolyngd" + - "alvossevangenvotevotingvotoyonakagyokutoursortlandworldworse-tha" + - "ndawowiwatsukiyonowritesthisblogsytewroclawloclawekoninjavald-ao" + - "starnbergwtciticatholicheltenham-radio-opencraftranagatorodoywtf" + - "bxosciencecentersciencehistorywuozuwwwmflabsorumincommbanklabudh" + - "abikinokawabarthagakhanamigawawzmiuwajimaxn--4gq48lf9jetztrentin" + - "o-aadigexn--4it168dxn--4it797konsulatrobeepilepsydneyxn--4pvxsou" + - "thcarolinazawaxn--54b7fta0ccivilizationxn--55qw42gxn--55qx5dxn--" + - "5js045dxn--5rtp49civilwarmanagementmpalmspringsakerxn--5rtq34kon" + - "yvelolxn--5su34j936bgsgxn--5tzm5gxn--6btw5axn--6frz82gxn--6orx2r" + - "xn--6qq986b3xlxn--7t0a264claimsasayamaxn--80adxhksouthwestfalenx" + - "n--80ao21axn--80aqecdr1axn--80asehdbarefootballooningjesdalillyo" + - "mbondiscountysnes3-website-ap-southeast-2xn--80aswgxn--80audneda" + - "lnxn--8ltr62kooris-an-actorxn--8pvr4uxn--8y0a063axn--90a3academy" + - "-firewall-gatewayxn--90aishobaraomoriguchiharahkkeravjuedischesa" + - "peakebayernrtrogstadxn--90azhytomyrxn--9dbhblg6dietcimdbargainst" + - "itutelemarkaratsuginamikatagamiharuconnectatarantottoribestadisc" + - "overyomitanobirastronomy-gatewayokosukanzakiwienaturalsciencesna" + - "turelles3-ap-southeast-2xn--9dbq2axn--9et52uxn--9krt00axn--andy-" + - "iraxn--aroport-byanaizuxn--asky-iraxn--aurskog-hland-jnbarreauct" + - "ionayorovnobninskarelianceu-1xn--avery-yuasakuhokkaidontexistein" + - "geekopervikhmelnitskiyamashikexn--b-5gaxn--b4w605ferdxn--bck1b9a" + - "5dre4clickatowicexn--bdddj-mrabdxn--bearalvhki-y4axn--berlevg-jx" + - "axn--bhcavuotna-s4axn--bhccavuotna-k7axn--bidr-5nachikatsuuraxn-" + - "-bievt-0qa2xn--bjarky-fyandexn--3pxu8konskowolayangroupharmacysh" + - "iraois-an-accountantshinyoshitomiokamitsuexn--bjddar-ptamayufuet" + - "tertdasnetzxn--blt-elabourxn--bmlo-graingerxn--bod-2naroyxn--brn" + - "ny-wuaccident-investigation-aptibleaseating-organicbcn-north-1xn" + - "--brnnysund-m8accident-prevention-webhopenairbusantiquest-a-la-m" + - "aisondre-landebudapest-a-la-masionionjukudoyamagazineat-urlxn--b" + - "rum-voagatromsakakinokiaxn--btsfjord-9zaxn--c1avgxn--c2br7gxn--c" + - "3s14mintelligencexn--cck2b3barrel-of-knowledgemologicallyngenvir" + - "onmentalconservationflfanfshostrolekamisunagawaugustowadaegubs3-" + - "ca-central-1xn--cg4bkis-very-evillagexn--ciqpnxn--clchc0ea0b2g2a" + - "9gcdn77-sslattumisakis-into-carshioyanagawaxn--comunicaes-v6a2ox" + - "n--correios-e-telecomunicaes-ghc29axn--czr694barrell-of-knowledg" + - "eologyonagoyaukraanghkeymachineustarhubalestrandabergamoareke164" + - "xn--czrs0tromsojaworznoxn--czru2dxn--czrw28bashkiriaurskog-holan" + - "droverhalla-speziaeroportalaheadjudaicaaarborteaches-yogasawarac" + - "ingroks-theatree12xn--d1acj3basilicataniaustevollarvikarasjokara" + - "suyamarylhurstjordalshalsenaturbruksgymnaturhistorisches3-eu-cen" + - "tral-1xn--d1alfaromeoxn--d1atrusteexn--d5qv7z876clinichernigover" + - "nmentjometlifeinsurancexn--davvenjrga-y4axn--djrs72d6uyxn--djty4" + - "koryokamikawanehonbetsurutaharaxn--dnna-grajewolterskluwerxn--dr" + - "bak-wuaxn--dyry-iraxn--e1a4cliniquenoharaxn--eckvdtc9dxn--efvn9s" + - "owaxn--efvy88haibarakitahatakamatsukawaxn--ehqz56nxn--elqq16hair" + - "-surveillancexn--estv75gxn--eveni-0qa01gaxn--f6qx53axn--fct429ko" + - "saigawaxn--fhbeiarnxn--finny-yuaxn--fiq228c5hspjelkavikomonoxn--" + - "fiq64basketballfinanzgoraustinnatuurwetenschappenaumburgjemnes3-" + - "eu-west-1xn--fiqs8spreadbettingxn--fiqz9spydebergxn--fjord-lraxn" + - "--fjq720axn--fl-ziaxn--flor-jraxn--flw351exn--fpcrj9c3dxn--frde-" + - "grandrapidsrlxn--frna-woaraisaijotrvarggatritonxn--frya-hraxn--f" + - "zc2c9e2clintonoshoesaseboknowsitallutskypexn--fzys8d69uvgmailxn-" + - "-g2xx48clothingrondarxn--gckr3f0fermobilyxn--gecrj9cloudnsdojoet" + - "suwanouchikujogaszczytnore-og-uvdaluxembourgrongaxn--ggaviika-8y" + - "a47hakatanotogawaxn--gildeskl-g0axn--givuotna-8yaotsurreyxn--gjv" + - "ik-wuaxn--gk3at1exn--gls-elacaixaxn--gmq050is-very-goodhandsonxn" + - "--gmqw5axn--h-2failxn--h1aeghakodatexn--h2brj9cnsaskatchewanxn--" + - "hbmer-xqaxn--hcesuolo-7ya35batodayonaguniversityoriikariyakumold" + - "eltaiwanairlinedre-eikerxn--hery-iraxn--hgebostad-g3axn--hmmrfea" + - "sta-s4acctrysiljan-mayenxn--hnefoss-q1axn--hobl-iraxn--holtlen-h" + - "xaxn--hpmir-xqaxn--hxt814exn--hyanger-q1axn--hylandet-54axn--i1b" + - "6b1a6a2exn--imr513nxn--indery-fyasakaiminatoyonezawaxn--io0a7is-" + - "very-nicexn--j1aeferraraxn--j1amhakonexn--j6w193gxn--jlq61u9w7ba" + - "tsfjordishakotankarlsoyoshiokarasjohkamikoaniikappugliaustraliai" + - "sondriodejaneirochesterhcloudfunctions3-external-1xn--jlster-bya" + - "sugis-very-sweetpepperxn--jrpeland-54axn--jvr189misasaguris-into" + - "-cartoonshirahamatonbetsurnadalxn--k7yn95exn--karmy-yuaxn--kbrq7" + - "oxn--kcrx77d1x4axn--kfjord-iuaxn--klbu-woaxn--klt787dxn--kltp7dx" + - "n--kltx9axn--klty5xn--42c2d9axn--koluokta-7ya57hakubadajozorahol" + - "taleniwaizumiotsukumiyamazonawsabaerobaticketshimonosekikawaxn--" + - "kprw13dxn--kpry57dxn--kpu716ferrarivnexn--kput3is-with-thebandoo" + - "mdnsiskinkyotobetsumidatlantichoseiroumuenchenisshingugexn--krag" + - "er-gyasuokanraxn--kranghke-b0axn--krdsherad-m8axn--krehamn-dxaxn" + - "--krjohka-hwab49jevnakershuscultureggio-emilia-romagnakatombetsu" + - "my-routerxn--ksnes-uuaxn--kvfjord-nxaxn--kvitsy-fyatomitamamurax" + - "n--kvnangen-k0axn--l-1fairwindsrtrentinosudtirolxn--l1accenturek" + - "lamborghiniizaxn--laheadju-7yatsukanumazuryxn--langevg-jxaxn--lc" + - "vr32dxn--ldingen-q1axn--leagaviika-52bauhausposts-and-telecommun" + - "icationsncfdivtasvuodnakaiwamizawaustrheimatunduhrennesoyokotebi" + - "nagisochildrensgardenaustdalavagiskebinorfolkebibleikangerxn--le" + - "sund-huaxn--lgbbat1ad8jewelryxn--lgrd-poacoachampionshiphoptobam" + - "agentositelekommunikationlinebraskaunjargallupinbbcaseihichisobe" + - "tsuitainairforceoceanographics3-website-eu-west-1xn--lhppi-xqaxn" + - "--linds-pramericanartulangevagrarboretumbriamallamaintenancechir" + - "ealminnesotaketakatsukis-into-animelbournexn--lns-qlansrvareserv" + - "eblogspotrentinosued-tirolxn--loabt-0qaxn--lrdal-sraxn--lrenskog" + - "-54axn--lt-liacntoyonoxn--lten-granexn--lury-iraxn--mely-iraxn--" + - "merker-kuaxn--mgb2ddestordalxn--mgb9awbferreroticanonoichinomiya" + - "kexn--mgba3a3ejtunesomnaritakurashikis-savedunetbankharkivguccip" + - "rianiigataishinomakimobetsuliguriaxn--mgba3a4f16axn--mgba3a4fran" + - "amizuholdingsmileksvikosakaerodromegalsacebetsukubankhmelnytskyi" + - "vanylvenicexn--mgba7c0bbn0axn--mgbaakc7dvfetsundynvpnxn--mgbaam7" + - "a8hakuis-a-nascarfanxn--mgbab2bdxn--mgbai9a5eva00bbtateshinanoma" + - "chintaifun-dnsaliaskimitsubatamicable-modembetsukuibigawauthorda" + - "landroiddnskingjerdrumckinseyokozebizenakaniikawatanaguraetnagah" + - "amaroygardendoftheinternetflixilovecollegefantasyleaguernseyboml" + - "oans3-ap-northeast-2xn--mgbai9azgqp6jewishartgalleryxn--mgbayh7g" + - "padualstackspace-to-rentalstomakomaibaraxn--mgbb9fbpobanazawaxn-" + - "-mgbbh1a71exn--mgbc0a9azcgxn--mgbca7dzdoxn--mgberp4a5d4a87gxn--m" + - "gberp4a5d4arxn--mgbi4ecexposedxn--mgbpl2fhskleppiagetmyiphilipsy" + - "nology-diskstationxn--mgbqly7c0a67fbcolonialwilliamsburgrossetou" + - "chijiwadellogliastradingroundhandlingroznyxn--mgbqly7cvafredriks" + - "tadtvstoreitrentinosuedtirolxn--mgbt3dhdxn--mgbtf8flatangerxn--m" + - "gbtx2bbvacationswatch-and-clockerxn--mgbx4cd0abbottunkongsbergxn" + - "--mix082fgunmarcheaparisor-fronxn--mix891fhvalerxn--mjndalen-64a" + - "xn--mk0axindustriesteambulancexn--mk1bu44coloradoplateaudioxn--m" + - "kru45isleofmandalxn--mlatvuopmi-s4axn--mli-tlanxesstorfjordxn--m" + - "lselv-iuaxn--moreke-juaxn--mori-qsakuragawaxn--mosjen-eyatsushir" + - "oxn--mot-tlapyxn--mre-og-romsdal-qqbeppublishproxyzgorzeleccolog" + - "newspaperxn--msy-ula0hakusandiegoodyearthadselfipassagenshimonit" + - "ayanagitlaborxn--mtta-vrjjat-k7afamilycompanycolumbusheyxn--muos" + - "t-0qaxn--mxtq1misawaxn--ngbc5azdxn--ngbe9e0axn--ngbrxn--45brj9ci" + - "vilaviationxn--nit225koseis-an-actresshiojirishirifujiedaxn--nme" + - "sjevuemie-tcbalatinord-frontierxn--nnx388axn--nodexn--nqv7fs00em" + - "axn--nry-yla5gxn--ntso0iqx3axn--ntsq17gxn--nttery-byaeservecount" + - "erstrikexn--nvuotna-hwaxn--nyqy26axn--o1achattanooganordreisa-ge" + - "ekosherbrookegawaxn--o3cw4haldenxn--od0algxn--od0aq3bernuorockar" + - "tuzyukibmdivttasvuotnakamagayachts3-website-sa-east-1xn--ogbpf8f" + - "lekkefjordxn--oppegrd-ixaxn--ostery-fyawaraxn--osyro-wuaxn--p1ac" + - "fidonnakamuratajimicrolightinguovdageaidnunzenxn--p1aissmarterth" + - "anyouxn--pbt977communitysfjordyndns-weberlincolnxn--pgbs0dhlxn--" + - "porsgu-sta26fieldyroyrvikinguitarschweizparaglidingujolsterxn--p" + - "ssu33lxn--pssy2uxn--q9jyb4comobaraxn--qcka1pmcdonaldstpetersburg" + - "xn--qqqt11misconfusedxn--qxamuneuestreamsterdamnserverbaniaxn--r" + - "ady-iraxn--rdal-poaxn--rde-ulaquilancashirehabmerxn--rdy-0nabari" + - "wchoshibuyachiyodavvenjargaulardalukowiiheyaizuwakamatsubushikus" + - "akadogawaxn--rennesy-v1axn--rhkkervju-01aflakstadaokagakibichuox" + - "n--rholt-mragowoodsidexn--rhqv96gxn--rht27zxn--rht3dxn--rht61exn" + - "--risa-5narusawaxn--risr-iraxn--rland-uuaxn--rlingen-mxaxn--rmsk" + - "og-byawatahamaxn--rny31halsaintlouis-a-anarchistoireggio-calabri" + - "axn--rovu88beskidyn-vpncasertaipeiheijiinetnedalimanowarudautomo" + - "tivecodyn-o-saurlandes3-fips-us-gov-west-1xn--rros-granvindafjor" + - "dxn--rskog-uuaxn--rst-0narutokyotangovturystykannamihamadaxn--rs" + - "ta-francaiseharaxn--ryken-vuaxn--ryrvik-byaxn--s-1faitheguardian" + - "xn--s9brj9comparemarkerryhotelsassaris-a-doctorayxn--sandnessjen" + - "-ogbizxn--sandy-yuaxn--seral-lraxn--ses554gxn--sgne-gratangenxn-" + - "-skierv-utazaskvolloabathsbcompute-1xn--skjervy-v1axn--skjk-soax" + - "n--sknit-yqaxn--sknland-fxaxn--slat-5narviikamishihoronobeauxart" + - "sandcraftstudioxn--slt-elabbvieeexn--smla-hraxn--smna-gratis-a-b" + - "ruinsfanxn--snase-nraxn--sndre-land-0cbstudyndns-at-homedepotenz" + - "amamicrosoftbankomorotsukaminoyamaxunusualpersonxn--snes-poaxn--" + - "snsa-roaxn--sr-aurdal-l8axn--sr-fron-q1axn--sr-odal-q1axn--sr-va" + - "ranger-ggbestbuyshouses3-website-us-east-1xn--srfold-byaxn--srre" + - "isa-q1axn--srum-grazxn--stfold-9xaxn--stjrdal-s1axn--stjrdalshal" + - "sen-sqbetainaboxfusejnynysadodgeometre-experts-comptables3-websi" + - "te-us-west-1xn--stre-toten-zcbieigersundiyukuhashimoichinosekiga" + - "harautoscanadaejeonbukaratehimeji234xn--t60b56axn--tckweathercha" + - "nnelxn--tiq49xqyjfkhersonxn--tjme-hraxn--tn0agrinet-freakstuff-4" + - "-salexn--tnsberg-q1axn--tor131oxn--trany-yuaxn--trgstad-r1axn--t" + - "rna-woaxn--troms-zuaxn--tysvr-vraxn--uc0atvaroyxn--uc0ay4axn--ui" + - "st22hammarfeastafricapetownnews-stagingxn--uisz3gxn--unjrga-rtao" + - "baokinawashirosatochiokinoshimalatvuopmiasakuchinotsuchiurakawal" + - "brzycharternopilawalesundxn--unup4yxn--uuwu58axn--vads-jraxn--va" + - "rd-jraxn--vegrshei-c0axn--vermgensberater-ctbielawalterxn--vermg" + - "ensberatung-pwbiellaakesvuemielecceu-2xn--vestvgy-ixa6oxn--vg-yi" + - "abcgxn--vgan-qoaxn--vgsy-qoa0jgoraxn--vgu402computerhistoryofsci" + - "ence-fictionxn--vhquvbarclays3-website-ap-southeast-1xn--vler-qo" + - "axn--vre-eiker-k8axn--vrggt-xqadxn--vry-yla5gxn--vuq861bieszczad" + - "ygeyachimataikikonaioirasebastopologyeongnamegawakeisenbahnhlfan" + - "hs3-website-us-west-2xn--w4r85el8fhu5dnraxn--w4rs40lxn--wcvs22dx" + - "n--wgbh1comsecuritytacticsatxn--1ck2e1balsfjordgcahcesuolodingen" + - "aval-d-aosta-valleyolasitemrxn--wgbl6axn--xhq521bievatmallorcada" + - "quesakuraiitatebayashiibaghdadultateyamaveroykenglanddnss3-sa-ea" + - "st-1xn--xkc2al3hye2axn--xkc2dl3a5ee0hamurakamigoriginshimosuwalk" + - "is-a-nurservebbshimotsukexn--y9a3aquariumishimatsunoxn--yer-znar" + - "vikoshimizumakis-an-anarchistoricalsocietyxn--yfro4i67oxn--ygard" + - "en-p1axn--ygbi2ammxn--45q11civilisationxn--ystre-slidre-ujbifuka" + - "gawarszawashingtondclkarmoyurihonjoyentatsunoceanographiquevents" + - "akyotanabeneventoeidsvollimitednpagefrontappagespeedmobilizerodd" + - "avocatanzarowegroweibolzanordkappgafanpachigasakidsmynasushiobar" + - "agusarts3-us-east-2xn--zbx025dxn--zf0ao64axn--zf0avxn--4gbrimini" + - "ngxn--zfr164bihorologyusuharavoues3-us-gov-west-1xperiaxz" - -// nodes is the list of nodes. Each node is represented as a uint32, which -// encodes the node's children, wildcard bit and node type (as an index into -// the children array), ICANN bit and text. -// -// If the table was generated with the -comments flag, there is a //-comment -// after each node's data. In it is the nodes-array indexes of the children, -// formatted as (n0x1234-n0x1256), with * denoting the wildcard bit. The -// nodeType is printed as + for normal, ! for exception, and o for parent-only -// nodes that have children but don't match a domain label in their own right. -// An I denotes an ICANN domain. -// -// The layout within the uint32, from MSB to LSB, is: -// [ 1 bits] unused -// [ 9 bits] children index -// [ 1 bits] ICANN bit -// [15 bits] text index -// [ 6 bits] text length -var nodes = [...]uint32{ - 0x32f983, - 0x28a344, - 0x30e286, - 0x371b43, - 0x371b46, - 0x394646, - 0x3a5003, - 0x367844, - 0x260687, - 0x30dec8, - 0x1a04cc2, - 0x316e47, - 0x355d89, - 0x32228a, - 0x32228b, - 0x22eec3, - 0x28fac6, - 0x2327c5, - 0x1e04e02, - 0x217c04, - 0x2a90c3, - 0x3ac705, - 0x2203942, - 0x329e03, - 0x26957c4, - 0x368e05, - 0x2a10182, - 0x3787ce, - 0x253343, - 0x3a03c6, - 0x2e00142, - 0x30e407, - 0x23ae46, - 0x3200c42, - 0x22a343, - 0x254b04, - 0x325a86, - 0x35c208, - 0x28a706, - 0x21ad04, - 0x3601442, - 0x332309, - 0x207587, - 0x256286, - 0x339309, - 0x29d788, - 0x328d44, - 0x364906, - 0x36b606, - 0x3a02942, - 0x27144f, - 0x20f94e, - 0x2131c4, - 0x2c6085, - 0x367745, - 0x385989, - 0x241a89, - 0x368047, - 0x23c9c6, - 0x273a43, - 0x3e02342, - 0x2df283, - 0x205aca, - 0x221d83, - 0x303145, - 0x289c02, - 0x289c09, - 0x4200f82, - 0x203d84, - 0x2250c6, - 0x2eb205, - 0x34cbc4, - 0x4a04c04, - 0x205283, - 0x231ac4, - 0x4e02e02, - 0x209f04, - 0x52f4e04, - 0x24ae0a, - 0x5601342, - 0x303907, - 0x26b8c8, - 0x6202f82, - 0x31cf07, - 0x2c2e04, - 0x2c2e07, - 0x373d85, - 0x357a47, - 0x367e06, - 0x2e8384, - 0x39c0c5, - 0x294847, - 0x7206cc2, - 0x34f703, - 0x200582, - 0x200583, - 0x76125c2, - 0x221ec5, - 0x7a02302, - 0x27bd84, - 0x2810c5, - 0x213107, - 0x269f0e, - 0x224bc4, - 0x206a84, - 0x211503, - 0x2ceac9, - 0x2ed94b, - 0x3a6548, - 0x3148c8, - 0x318dc8, - 0x237908, - 0x33914a, - 0x357947, - 0x318146, - 0x7ea4fc2, - 0x35bc03, - 0x366c43, - 0x371144, - 0x3a5043, - 0x324cc3, - 0x171f542, - 0x8203682, - 0x252185, - 0x2a11c6, - 0x2d6d44, - 0x2f6e07, - 0x382986, - 0x319dc4, - 0x398247, - 0x20f7c3, - 0x86c8902, - 0x8b124c2, - 0x8e1c502, - 0x21c506, - 0x9200002, - 0x359b85, - 0x320a83, - 0x200004, - 0x2ee344, - 0x2ee345, - 0x203e43, - 0x9768883, - 0x9a07f42, - 0x28e245, - 0x28e24b, - 0x2d0686, - 0x20a0cb, - 0x225b04, - 0x20a7c9, - 0x20be84, - 0x9e0c0c2, - 0x20cf83, - 0x210843, - 0x1600802, - 0x260903, - 0x2109ca, - 0xa211cc2, - 0x217e85, - 0x2983ca, - 0x2dc184, - 0x369f03, - 0x315044, - 0x213643, - 0x213644, - 0x213647, - 0x213985, - 0x213e05, - 0x2150c6, - 0x2167c6, - 0x2182c3, - 0x21c188, - 0x221c43, - 0xa601082, - 0x21cac8, - 0x21ff0b, - 0x2216c8, - 0x2221c6, - 0x222a47, - 0x226488, - 0xb2413c2, - 0xb6c2fc2, - 0x326388, - 0x257ec7, - 0x22bac5, - 0x22bac8, - 0x2bf708, - 0x3871c3, - 0x22a784, - 0x371182, - 0xba2af82, - 0xbe5ba02, - 0xc62c1c2, - 0x22c1c3, - 0xca0e542, - 0x367803, - 0x2f8e04, - 0x218443, - 0x328d04, - 0x25fe4b, - 0x21fe43, - 0x2e4d06, - 0x226284, - 0x2a5a8e, - 0x361c05, - 0x3a04c8, - 0x282247, - 0x28224a, - 0x229d03, - 0x2b3447, - 0x2edb05, - 0x22ea44, - 0x272486, - 0x272487, - 0x32b704, - 0x304ac7, - 0x26a244, - 0x35bc84, - 0x35bc86, - 0x386904, - 0x20e546, - 0x223c83, - 0x22b888, - 0x30c3c8, - 0x24e2c3, - 0x2608c3, - 0x204f04, - 0x395943, - 0xce0d882, - 0xd2db442, - 0x20c043, - 0x201806, - 0x35c383, - 0x28bfc4, - 0xd6081c2, - 0x2081c3, - 0x358243, - 0x219942, - 0xda02ac2, - 0x2c55c6, - 0x2334c7, - 0x2f7a85, - 0x37da44, - 0x3723c5, - 0x367007, - 0x274205, - 0x2d3e89, - 0x2e0586, - 0x2e5488, - 0x2f7986, - 0xde0db42, - 0x362f48, - 0x2f8bc6, - 0x20db45, - 0x304687, - 0x30c2c4, - 0x30c2c5, - 0x28a8c4, - 0x28a8c8, - 0xe20a182, - 0xe60c502, - 0x313646, - 0x2c28c8, - 0x31f145, - 0x332c06, - 0x3356c8, - 0x33e1c8, - 0xea0fd45, - 0xee0c504, - 0x2958c7, - 0xf20bbc2, - 0xf61c402, - 0x1060d1c2, - 0x35aa45, - 0x2a8505, - 0x282606, - 0x3698c7, - 0x376ec7, - 0x10ed0783, - 0x2e3447, - 0x30dc88, - 0x3823c9, - 0x378987, - 0x390287, - 0x3a5b08, - 0x3aa206, - 0x22e546, - 0x22f18c, - 0x230b0a, - 0x230fc7, - 0x23268b, - 0x233307, - 0x23330e, - 0x236244, - 0x23a184, - 0x23b547, - 0x264f47, - 0x240d46, - 0x240d47, - 0x241207, - 0x18a20802, - 0x2420c6, - 0x2420ca, - 0x24294b, - 0x243407, - 0x244ec5, - 0x245203, - 0x246c46, - 0x246c47, - 0x241c43, - 0x18e38702, - 0x24b74a, - 0x19356fc2, - 0x196acdc2, - 0x19a4cec2, - 0x19e26982, - 0x24da85, - 0x24e0c4, - 0x1a604d02, - 0x209f85, - 0x294ac3, - 0x20bf85, - 0x237804, - 0x20a684, - 0x2ba5c6, - 0x26a546, - 0x28e443, - 0x3b1484, - 0x209383, - 0x1aa03b02, - 0x263544, - 0x263546, - 0x295e45, - 0x27fdc6, - 0x304788, - 0x20cb44, - 0x2a8e88, - 0x343fc5, - 0x24a108, - 0x2b1cc6, - 0x2bddc7, - 0x26cdc4, - 0x26cdc6, - 0x25e303, - 0x382e43, - 0x2c9388, - 0x318bc4, - 0x238d47, - 0x220246, - 0x2dad89, - 0x315108, - 0x319f08, - 0x349184, - 0x39b9c3, - 0x23e342, - 0x1ba34682, - 0x1be16102, - 0x3b2783, - 0x1c204a42, - 0x2607c4, - 0x390a46, - 0x39a6c5, - 0x2a4383, - 0x232004, - 0x2b6f47, - 0x26aa43, - 0x250d08, - 0x20e8c5, - 0x370083, - 0x281045, - 0x281184, - 0x2fb8c6, - 0x210384, - 0x211a46, - 0x213046, - 0x263004, - 0x21fd83, - 0x2225c3, - 0x1c604e42, - 0x377905, - 0x222e03, - 0x1ca1c3c2, - 0x22f143, - 0x210085, - 0x231b83, - 0x231b89, - 0x1ce07d02, - 0x1d601142, - 0x28d9c5, - 0x21a746, - 0x2d6906, - 0x2b94c8, - 0x2b94cb, - 0x20538b, - 0x2f7c85, - 0x2e1045, - 0x2c9fc9, - 0x1600742, - 0x2631c8, - 0x206044, - 0x1de001c2, - 0x25fa83, - 0x1e665106, - 0x20f088, - 0x1ea04782, - 0x233ec8, - 0x1ee01742, - 0x225c4a, - 0x1f2d0e43, - 0x3b1e86, - 0x206988, - 0x207d48, - 0x39a9c6, - 0x36d5c7, - 0x271647, - 0x220b0a, - 0x2dc204, - 0x3423c4, - 0x355589, - 0x1fb8fc85, - 0x20fb46, - 0x208203, - 0x251944, - 0x201e44, - 0x201e47, - 0x22cec7, - 0x237044, - 0x220a45, - 0x2826c8, - 0x350707, - 0x3619c7, - 0x1fe041c2, - 0x226004, - 0x298cc8, - 0x381004, - 0x24f0c4, - 0x24fa45, - 0x24fb87, - 0x215809, - 0x2505c4, - 0x2510c9, - 0x251308, - 0x2516c4, - 0x2516c7, - 0x20251c43, - 0x252487, - 0x16101c2, - 0x179d442, - 0x253386, - 0x2539c7, - 0x253e84, - 0x255607, - 0x256907, - 0x257483, - 0x2abc02, - 0x229c02, - 0x258743, - 0x258744, - 0x25874b, - 0x3149c8, - 0x25f184, - 0x2594c5, - 0x25ba87, - 0x25d8c5, - 0x2c4dca, - 0x25f0c3, - 0x2060da42, - 0x22b484, - 0x264d09, - 0x268983, - 0x268a47, - 0x28ee89, - 0x37b5c8, - 0x2d8483, - 0x27ff47, - 0x280689, - 0x2316c3, - 0x288284, - 0x289389, - 0x28c6c6, - 0x28dc83, - 0x2023c2, - 0x24ca43, - 0x36ab47, - 0x2bfa85, - 0x35ba06, - 0x256bc4, - 0x2d1d45, - 0x205a83, - 0x218506, - 0x20a9c2, - 0x391084, - 0x22ad02, - 0x22ad03, - 0x20a00182, - 0x29b083, - 0x216c44, - 0x216c47, - 0x200306, - 0x201e02, - 0x20e01dc2, - 0x21e184, - 0x2123b882, - 0x21600502, - 0x2dfcc4, - 0x2dfcc5, - 0x2b9cc5, - 0x262746, - 0x21a0ca82, - 0x20ca85, - 0x210d85, - 0x225883, - 0x215c06, - 0x216dc5, - 0x21c482, - 0x33de05, - 0x21c484, - 0x2230c3, - 0x223303, - 0x21e097c2, - 0x294a47, - 0x221144, - 0x221149, - 0x251844, - 0x228903, - 0x341cc9, - 0x3777c8, - 0x2a8384, - 0x2a8386, - 0x210503, - 0x259b43, - 0x332ec3, - 0x222ebc02, - 0x30eb82, - 0x22600642, - 0x3238c8, - 0x35c588, - 0x394d86, - 0x24ed45, - 0x2b32c5, - 0x200647, - 0x228fc5, - 0x2630c2, - 0x22a9a502, - 0x1614502, - 0x38fe08, - 0x362e85, - 0x351d04, - 0x2f18c5, - 0x3836c7, - 0x24f5c4, - 0x246f82, - 0x22e01182, - 0x336f04, - 0x2173c7, - 0x28e9c7, - 0x357a04, - 0x298383, - 0x24e204, - 0x24e208, - 0x22e886, - 0x27230a, - 0x2156c4, - 0x298708, - 0x259784, - 0x222b46, - 0x29a4c4, - 0x35ad46, - 0x221409, - 0x25b287, - 0x234483, - 0x23274842, - 0x274843, - 0x20c2c2, - 0x23651b02, - 0x2f0b06, - 0x364148, - 0x2a9d87, - 0x395d09, - 0x297f09, - 0x2ab245, - 0x2ad3c9, - 0x2ae045, - 0x2ae189, - 0x2af5c5, - 0x2b0208, - 0x27f284, - 0x23a8d6c7, - 0x294403, - 0x2b0407, - 0x390646, - 0x2b08c7, - 0x2a6d45, - 0x2a7f83, - 0x23e00dc2, - 0x392604, - 0x2423b8c2, - 0x264403, - 0x24618d82, - 0x307646, - 0x26b845, - 0x2b2bc7, - 0x37f183, - 0x324c44, - 0x2138c3, - 0x2386c3, - 0x24a0a3c2, - 0x25201a02, - 0x394744, - 0x2abbc3, - 0x38c985, - 0x226d85, - 0x25602282, - 0x25e00bc2, - 0x280286, - 0x318d04, - 0x2491c4, - 0x2491ca, - 0x26601d42, - 0x37324a, - 0x204148, - 0x26a964c4, - 0x201d43, - 0x25ff43, - 0x318f09, - 0x2a8909, - 0x2b7046, - 0x26e04303, - 0x328145, - 0x30664d, - 0x204306, - 0x21268b, - 0x27203482, - 0x295048, - 0x27e1c282, - 0x282051c2, - 0x37aa85, - 0x28600b02, - 0x2a3147, - 0x212b87, - 0x201503, - 0x22f848, - 0x28a02f02, - 0x202f04, - 0x217043, - 0x38d045, - 0x386fc3, - 0x2eb106, - 0x30bdc4, - 0x204ec3, - 0x234f83, - 0x28e07042, - 0x2f7c04, - 0x30ed45, - 0x35a587, - 0x27dbc3, - 0x2b36c3, - 0x2b3ec3, - 0x1621ac2, - 0x2b3f83, - 0x2b4b03, - 0x2920ae42, - 0x2cee84, - 0x26a746, - 0x33c7c3, - 0x2b4f83, - 0x296b5e02, - 0x2b5e08, - 0x2b60c4, - 0x2470c6, - 0x2b6547, - 0x24e3c6, - 0x295304, - 0x37200082, - 0x39050b, - 0x2ffbce, - 0x21bb0f, - 0x29da43, - 0x37a4ca02, - 0x166b142, - 0x37e02442, - 0x29c243, - 0x2472c3, - 0x233106, - 0x22ff46, - 0x212307, - 0x31aa84, - 0x3821a882, - 0x3860ec02, - 0x2d4ac5, - 0x2e88c7, - 0x37e046, - 0x38a82882, - 0x2f5b04, - 0x2b9783, - 0x38e01b02, - 0x39352883, - 0x2ba984, - 0x2c06c9, - 0x16c6fc2, - 0x39642682, - 0x351245, - 0x39ac7242, - 0x39e02682, - 0x341687, - 0x2364c9, - 0x35600b, - 0x271405, - 0x2c7c89, - 0x276a46, - 0x2d06c7, - 0x3a2092c4, - 0x32ef49, - 0x374b07, - 0x2255c7, - 0x234003, - 0x37b386, - 0x30f887, - 0x265383, - 0x27c5c6, - 0x3aa022c2, - 0x3ae31e02, - 0x220443, - 0x324845, - 0x257747, - 0x21fac6, - 0x2bfa05, - 0x230044, - 0x2efa45, - 0x2f8284, - 0x3b205e82, - 0x349f07, - 0x2e1c44, - 0x23e244, - 0x33328d, - 0x257249, - 0x381588, - 0x25ac04, - 0x314e85, - 0x3b2607, - 0x205e84, - 0x382a47, - 0x20c705, - 0x3b6aa384, - 0x36dec5, - 0x267644, - 0x24f706, - 0x3696c5, - 0x3ba24742, - 0x369fc4, - 0x369fc5, - 0x3716c6, - 0x2bfb45, - 0x25c104, - 0x3120c3, - 0x204986, - 0x22c085, - 0x22c785, - 0x3697c4, - 0x215743, - 0x21574c, - 0x3be8d002, - 0x3c2045c2, - 0x3c605d82, - 0x205d83, - 0x205d84, - 0x3ca032c2, - 0x2f9648, - 0x35bac5, - 0x33f884, - 0x230e46, - 0x3ce073c2, - 0x3d20fc42, - 0x3d600c02, - 0x321e85, - 0x262ec6, - 0x20b484, - 0x325fc6, - 0x3036c6, - 0x202983, - 0x3db1164a, - 0x264785, - 0x28b4c3, - 0x223886, - 0x305e09, - 0x223887, - 0x293308, - 0x29d649, - 0x248108, - 0x229a46, - 0x208843, - 0x3de017c2, - 0x384b03, - 0x384b09, - 0x368548, - 0x3e2513c2, - 0x3e601f02, - 0x22d603, - 0x2e0405, - 0x258f44, - 0x35e849, - 0x226784, - 0x26f288, - 0x205c03, - 0x2602c4, - 0x2784c3, - 0x21a788, - 0x3331c7, - 0x3ea0f302, - 0x2432c2, - 0x257d85, - 0x3960c9, - 0x20fbc3, - 0x281ac4, - 0x328104, - 0x219e03, - 0x28380a, - 0x3ef73102, - 0x3f2c0202, - 0x2c8883, - 0x374fc3, - 0x1649202, - 0x262a43, - 0x3f60bcc2, - 0x3fa05f02, - 0x3fe22044, - 0x222046, - 0x33e8c6, - 0x277844, - 0x2474c3, - 0x39bc83, - 0x235143, - 0x242cc6, - 0x2ce085, - 0x2c8e47, - 0x2d0589, - 0x2ccac5, - 0x2cdfc6, - 0x2ce548, - 0x2ce746, - 0x245bc4, - 0x29ef8b, - 0x2d3983, - 0x2d3985, - 0x2d3ac8, - 0x226302, - 0x341982, - 0x4024db02, - 0x4060b602, - 0x21a8c3, - 0x40a73fc2, - 0x273fc3, - 0x2d3dc4, - 0x2d4e43, - 0x41201682, - 0x41601686, - 0x2c47c6, - 0x2da008, - 0x41a95242, - 0x41e10882, - 0x42223342, - 0x4265e402, - 0x42a14202, - 0x42e01302, - 0x234103, - 0x261c05, - 0x32d1c6, - 0x43213184, - 0x295c4a, - 0x201306, - 0x2f7ec4, - 0x269ec3, - 0x43e0c002, - 0x202082, - 0x231743, - 0x44204ac3, - 0x362b47, - 0x3695c7, - 0x45a58847, - 0x32d747, - 0x228543, - 0x2977ca, - 0x377004, - 0x220144, - 0x22014a, - 0x202085, - 0x45e04182, - 0x3294c3, - 0x462002c2, - 0x2104c3, - 0x274803, - 0x46a00842, - 0x2e33c4, - 0x21db44, - 0x208285, - 0x30bd05, - 0x249406, - 0x249786, - 0x46e09282, - 0x47201002, - 0x3274c5, - 0x2c44d2, - 0x271ac6, - 0x248803, - 0x2a2486, - 0x248805, - 0x1610a02, - 0x4f611802, - 0x3522c3, - 0x211803, - 0x278203, - 0x4fa11f82, - 0x378ac3, - 0x4fe14602, - 0x200a83, - 0x2ceec8, - 0x24a843, - 0x24a846, - 0x3a1087, - 0x321b06, - 0x321b0b, - 0x2f7e07, - 0x392404, - 0x50603ec2, - 0x364805, - 0x50a04a83, - 0x239f83, - 0x326805, - 0x35b5c3, - 0x35b5c6, - 0x26334a, - 0x2774c3, - 0x23ad04, - 0x2c2806, - 0x20df46, - 0x50e00383, - 0x324b07, - 0x28bb8d, - 0x3adbc7, - 0x2a0685, - 0x250b46, - 0x22c0c3, - 0x52a15e43, - 0x52e04c82, - 0x3b2804, - 0x236d8c, - 0x245309, - 0x24bcc7, - 0x3724c5, - 0x268d84, - 0x27c1c8, - 0x27ed05, - 0x5328a405, - 0x377c09, - 0x256343, - 0x2acd44, - 0x53617902, - 0x21aac3, - 0x53a99f82, - 0x2a3fc6, - 0x16aa082, - 0x53e943c2, - 0x321d88, - 0x2c08c3, - 0x36de07, - 0x305105, - 0x2943c5, - 0x30860b, - 0x2e3906, - 0x308806, - 0x36dbc6, - 0x268f84, - 0x2e5686, - 0x2e5b48, - 0x23e943, - 0x23cf83, - 0x23cf84, - 0x2e6984, - 0x2e6e07, - 0x2e8745, - 0x542e8882, - 0x54606ec2, - 0x206ec5, - 0x2a4a84, - 0x2ebf8b, - 0x2ee248, - 0x2f7304, - 0x290602, - 0x54eb6042, - 0x38c543, - 0x2ee704, - 0x2ee9c5, - 0x2ef087, - 0x2f1404, - 0x2f7cc4, - 0x552054c2, - 0x35d209, - 0x2f2445, - 0x2716c5, - 0x2f3105, - 0x5561aa03, - 0x2f4244, - 0x2f424b, - 0x2f4684, - 0x2f4b0b, - 0x2f5505, - 0x21bc4a, - 0x2f5d08, - 0x2f5f0a, - 0x2f6783, - 0x2f678a, - 0x55a1b282, - 0x55e01202, - 0x26a103, - 0x562f7902, - 0x2f7903, - 0x5673aa42, - 0x56b21202, - 0x2f8104, - 0x21c2c6, - 0x325d05, - 0x2f8b43, - 0x32ff46, - 0x30c845, - 0x2e9784, - 0x56e00e02, - 0x2d7904, - 0x2c9c4a, - 0x2eb487, - 0x26b686, - 0x244007, - 0x236ec3, - 0x265488, - 0x28954b, - 0x386a45, - 0x235905, - 0x235906, - 0x370204, - 0x31d488, - 0x215a83, - 0x2b5984, - 0x36b507, - 0x307206, - 0x200e06, - 0x2a58ca, - 0x24e684, - 0x24e68a, - 0x57201946, - 0x201947, - 0x259547, - 0x279804, - 0x279809, - 0x2ba485, - 0x23b80b, - 0x2769c3, - 0x211c03, - 0x2a3f43, - 0x22ec44, - 0x57600682, - 0x259f06, - 0x2a7d05, - 0x2a26c5, - 0x2564c6, - 0x2531c4, - 0x57a01f82, - 0x245244, - 0x57e00d42, - 0x200d44, - 0x224303, - 0x58211842, - 0x3398c3, - 0x2478c6, - 0x58602602, - 0x2cfb88, - 0x223704, - 0x223706, - 0x375846, - 0x25bb44, - 0x204905, - 0x20c408, - 0x20c907, - 0x20d007, - 0x20d00f, - 0x298bc6, - 0x227843, - 0x227844, - 0x28be84, - 0x210e83, - 0x222c84, - 0x241104, - 0x58a36b82, - 0x28e183, - 0x241383, - 0x58e0c4c2, - 0x22a543, - 0x260883, - 0x213e8a, - 0x22bc87, - 0x241c8c, - 0x241f46, - 0x242406, - 0x246dc7, - 0x592ddb07, - 0x251a09, - 0x21cc04, - 0x252284, - 0x59609f42, - 0x59a01702, - 0x2a5c86, - 0x324904, - 0x2db5c6, - 0x2ab348, - 0x20eec4, - 0x2a3186, - 0x2d68c5, - 0x26ebc8, - 0x205583, - 0x272605, - 0x273583, - 0x2717c3, - 0x2717c4, - 0x273983, - 0x59edeec2, - 0x5a200b42, - 0x276889, - 0x27ec05, - 0x27ee04, - 0x281305, - 0x212504, - 0x2c1247, - 0x33d3c5, - 0x258a04, - 0x258a08, - 0x2dc3c6, - 0x2de404, - 0x2dfdc8, - 0x2e1a87, - 0x5a60e5c2, - 0x305304, - 0x210f44, - 0x2257c7, - 0x5aa53d84, - 0x249682, - 0x5ae01ac2, - 0x21b083, - 0x351144, - 0x242643, - 0x33d945, - 0x5b21de42, - 0x2ebb05, - 0x212bc2, - 0x381dc5, - 0x364305, - 0x5b60c842, - 0x3581c4, - 0x5ba06342, - 0x2a9146, - 0x2ac506, - 0x396208, - 0x2c3608, - 0x3075c4, - 0x2f8905, - 0x2fe809, - 0x2e10c4, - 0x263304, - 0x20aec3, - 0x5be20c45, - 0x2c7087, - 0x25e944, - 0x33a48d, - 0x33c282, - 0x33c283, - 0x355783, - 0x5c200202, - 0x388b45, - 0x26c747, - 0x2a7e04, - 0x32d807, - 0x29d849, - 0x2c9d89, - 0x248ac7, - 0x243843, - 0x27c008, - 0x2f33c9, - 0x2500c7, - 0x370145, - 0x385886, - 0x394246, - 0x3959c5, - 0x257345, - 0x5c603102, - 0x27eb05, - 0x2b8308, - 0x2c5386, - 0x2bcc07, - 0x2f5744, - 0x2ad207, - 0x2faf46, - 0x5ca2fb02, - 0x3713c6, - 0x2fd38a, - 0x2fde45, - 0x5cee4742, - 0x5d245702, - 0x30fbc6, - 0x2b25c8, - 0x5d68eb87, - 0x5da04602, - 0x20edc3, - 0x38c706, - 0x2246c4, - 0x3a0f46, - 0x262446, - 0x26bd0a, - 0x319a45, - 0x204446, - 0x218c83, - 0x218c84, - 0x205302, - 0x30c283, - 0x5de05dc2, - 0x2ce903, - 0x3734c4, - 0x2b2704, - 0x2b270a, - 0x229b03, - 0x28a7c8, - 0x229b0a, - 0x23a407, - 0x301446, - 0x2a9004, - 0x296e42, - 0x219542, - 0x5e206e42, - 0x24e1c3, - 0x259307, - 0x330207, - 0x38fd4b, - 0x28a2c4, - 0x34f9c7, - 0x2ef186, - 0x21c607, - 0x258004, - 0x23c445, - 0x2c17c5, - 0x5e620382, - 0x221a86, - 0x246043, - 0x24a2c2, - 0x24a2c6, - 0x5ea04802, - 0x5ee05bc2, - 0x3abd45, - 0x5f222e82, - 0x5f600a42, - 0x343745, - 0x38e6c5, - 0x204505, - 0x270ac3, - 0x390b05, - 0x2e39c7, - 0x309445, - 0x30a985, - 0x3a05c4, - 0x24c646, - 0x25c1c4, - 0x5fa03382, - 0x6060ce05, - 0x36f447, - 0x2db7c8, - 0x2a32c6, - 0x2a32cd, - 0x2a86c9, - 0x2a86d2, - 0x332705, - 0x33c843, - 0x60a044c2, - 0x2f6d84, - 0x204383, - 0x3623c5, - 0x2fed85, - 0x60e17082, - 0x3700c3, - 0x6124d082, - 0x616c3142, - 0x61a18dc2, - 0x364c05, - 0x329ec3, - 0x319888, - 0x61e02d82, - 0x62206902, - 0x2e3386, - 0x34398a, - 0x272243, - 0x25c083, - 0x2ed703, - 0x62e016c2, - 0x71211fc2, - 0x71a19682, - 0x206602, - 0x3711c9, - 0x2c6404, - 0x22fb48, - 0x71ef8b82, - 0x72202502, - 0x2f4d45, - 0x232ac8, - 0x2cf008, - 0x2fd54c, - 0x23bd83, - 0x267002, - 0x726019c2, - 0x2ccf46, - 0x3022c5, - 0x239103, - 0x383586, - 0x302406, - 0x21e2c3, - 0x304ec3, - 0x3055c6, - 0x306204, - 0x225d46, - 0x2d3b45, - 0x30648a, - 0x240544, - 0x307884, - 0x307a4a, - 0x72a037c2, - 0x234605, - 0x30898a, - 0x309a85, - 0x30a344, - 0x30a446, - 0x30a5c4, - 0x228306, - 0x72e39342, - 0x2eadc6, - 0x3a2445, - 0x26bb87, - 0x3a3c46, - 0x246fc4, - 0x2da807, - 0x311586, - 0x25b5c5, - 0x2d4287, - 0x39cd87, - 0x39cd8e, - 0x24abc6, - 0x382905, - 0x285407, - 0x201c43, - 0x201c47, - 0x3b3445, - 0x2108c4, - 0x211882, - 0x22afc7, - 0x31ab04, - 0x22fec4, - 0x24314b, - 0x21d283, - 0x288fc7, - 0x21d284, - 0x2ace07, - 0x2824c3, - 0x334b4d, - 0x389388, - 0x228e04, - 0x258905, - 0x30ac85, - 0x30b0c3, - 0x73201a82, - 0x30c243, - 0x30cf43, - 0x221c04, - 0x280785, - 0x223387, - 0x218d06, - 0x373203, - 0x24a40b, - 0x3aa70b, - 0x27928b, - 0x28088a, - 0x2ad8cb, - 0x2fc28b, - 0x2e478c, - 0x2e7291, - 0x32170a, - 0x34e48b, - 0x379d0b, - 0x3b048a, - 0x3b4cca, - 0x30ea4d, - 0x31038e, - 0x3109cb, - 0x310c8a, - 0x312191, - 0x3125ca, - 0x312acb, - 0x31300e, - 0x31398c, - 0x313fcb, - 0x31428e, - 0x31460c, - 0x315a4a, - 0x31694c, - 0x73716c4a, - 0x317449, - 0x31b60a, - 0x31b88a, - 0x31bb0b, - 0x31e9ce, - 0x31ed51, - 0x327a09, - 0x327c4a, - 0x32844b, - 0x32a30a, - 0x32ab96, - 0x32c8cb, - 0x32e00a, - 0x32e5ca, - 0x33048b, - 0x332189, - 0x3354c9, - 0x335a4d, - 0x3360cb, - 0x33734b, - 0x337d0b, - 0x3381c9, - 0x33880e, - 0x338f0a, - 0x33a24a, - 0x33a7ca, - 0x33af8b, - 0x33b7cb, - 0x33ba8d, - 0x33cecd, - 0x33da90, - 0x33df4b, - 0x33e54c, - 0x33ea4b, - 0x34118b, - 0x34290b, - 0x3463cb, - 0x346e4f, - 0x34720b, - 0x347d0a, - 0x348249, - 0x348609, - 0x34898b, - 0x348c4e, - 0x34b98b, - 0x34d04f, - 0x34ff0b, - 0x3501cb, - 0x35048b, - 0x35098a, - 0x355c09, - 0x35a20f, - 0x36128c, - 0x36170c, - 0x36208e, - 0x36388f, - 0x363c4e, - 0x3652d0, - 0x3656cf, - 0x365d4e, - 0x36650c, - 0x366812, - 0x36a511, - 0x36ad0e, - 0x36ba0e, - 0x36bf4e, - 0x36c2cf, - 0x36c68e, - 0x36ca13, - 0x36ced1, - 0x36d30e, - 0x36d78c, - 0x36e493, - 0x36fa90, - 0x37070c, - 0x370a0c, - 0x370ecb, - 0x37184e, - 0x371f8b, - 0x3727cb, - 0x37378c, - 0x37914a, - 0x37950c, - 0x37980c, - 0x379b09, - 0x37b7cb, - 0x37ba88, - 0x37bc89, - 0x37bc8f, - 0x37d5cb, - 0x37e44a, - 0x37fd4c, - 0x380e09, - 0x381b88, - 0x38214b, - 0x382c0b, - 0x38418a, - 0x38440b, - 0x38488c, - 0x385548, - 0x38958b, - 0x38c04b, - 0x39000b, - 0x39180b, - 0x39c90b, - 0x39cbc9, - 0x39d10d, - 0x3a264a, - 0x3a3597, - 0x3a3dd8, - 0x3a6309, - 0x3a7b4b, - 0x3a9554, - 0x3a9a4b, - 0x3a9fca, - 0x3ab70a, - 0x3ab98b, - 0x3ad110, - 0x3ad511, - 0x3ae64a, - 0x3afa8d, - 0x3b018d, - 0x3b508b, - 0x3b5c46, - 0x221b83, - 0x73b76c03, - 0x37f706, - 0x292c85, - 0x396787, - 0x3215c6, - 0x1639f02, - 0x2b3809, - 0x32fd44, - 0x2e0bc8, - 0x24e103, - 0x2f6cc7, - 0x241b82, - 0x2b2c03, - 0x73e06c82, - 0x2cb006, - 0x2cc544, - 0x3b2e84, - 0x2616c3, - 0x2616c5, - 0x746c7282, - 0x74aae504, - 0x279747, - 0x1669e02, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x20abc3, - 0x204cc2, - 0x15f048, - 0x20d1c2, - 0x332ec3, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x213e83, - 0x324156, - 0x325393, - 0x34f849, - 0x2957c8, - 0x364689, - 0x308b06, - 0x336f50, - 0x25c9d3, - 0x3072c8, - 0x344207, - 0x27e407, - 0x2475ca, - 0x373549, - 0x239789, - 0x29258b, - 0x367e06, - 0x314aca, - 0x2221c6, - 0x32f943, - 0x294985, - 0x22b888, - 0x2a920d, - 0x35ab0c, - 0x3a2107, - 0x379f8d, - 0x20c504, - 0x22ef0a, - 0x23064a, - 0x230b0a, - 0x20fe87, - 0x240387, - 0x243084, - 0x26cdc6, - 0x3aab84, - 0x2e26c8, - 0x2267c9, - 0x2b94c6, - 0x2b94c8, - 0x24c34d, - 0x2c9fc9, - 0x207d48, - 0x271647, - 0x2f8e8a, - 0x2539c6, - 0x2642c7, - 0x2c96c4, - 0x28e807, - 0x332eca, - 0x36f5ce, - 0x228fc5, - 0x28e70b, - 0x262089, - 0x2a8909, - 0x2129c7, - 0x29998a, - 0x225707, - 0x2ffd09, - 0x326b48, - 0x35dc4b, - 0x2e0405, - 0x38144a, - 0x223109, - 0x23908a, - 0x2ccb4b, - 0x383a0b, - 0x292315, - 0x2e6185, - 0x2716c5, - 0x2f424a, - 0x25980a, - 0x261e07, - 0x21d743, - 0x2a5c08, - 0x2d828a, - 0x223706, - 0x24ff09, - 0x26ebc8, - 0x2de404, - 0x242649, - 0x2c3608, - 0x2b1c07, - 0x20ce06, - 0x36f447, - 0x293cc7, - 0x242ac5, - 0x228e0c, - 0x258905, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x20d1c2, - 0x2d0783, - 0x204ac3, - 0x20abc3, - 0x200383, - 0x2d0783, - 0x204ac3, - 0x24a843, - 0x200383, - 0x15f048, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x15f048, - 0x20d1c2, - 0x2000c2, - 0x230d42, - 0x202f02, - 0x202382, - 0x261e82, - 0x46d0783, - 0x231b83, - 0x2135c3, - 0x332ec3, - 0x204303, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x201383, - 0x15f048, - 0x32df04, - 0x260087, - 0x263d43, - 0x37aa84, - 0x214543, - 0x212a43, - 0x332ec3, - 0x13ecc7, - 0x204cc2, - 0x168883, - 0x5a0d1c2, - 0x8d54d, - 0x8d88d, - 0x230d42, - 0x964c4, - 0x200382, - 0x5e963c8, - 0xf39c4, - 0x15f048, - 0x14020c2, - 0x1509cc6, - 0x20e443, - 0x26ae03, - 0x66d0783, - 0x22ef04, - 0x6a31b83, - 0x6f32ec3, - 0x20a3c2, - 0x2964c4, - 0x204ac3, - 0x2fc883, - 0x201882, - 0x200383, - 0x21c802, - 0x2f8043, - 0x202602, - 0x203f83, - 0x26ec83, - 0x206d02, - 0x15f048, - 0x20e443, - 0x2fc883, - 0x201882, - 0x2f8043, - 0x202602, - 0x203f83, - 0x26ec83, - 0x206d02, - 0x2f8043, - 0x202602, - 0x203f83, - 0x26ec83, - 0x206d02, - 0x2d0783, - 0x368883, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x2964c4, - 0x204303, - 0x20fbc3, - 0x213184, - 0x204ac3, - 0x200383, - 0x210582, - 0x21aa03, - 0x15f048, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x368883, - 0x20d1c2, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x2964c4, - 0x204ac3, - 0x200383, - 0x370145, - 0x217082, - 0x204cc2, - 0x15f048, - 0x1491b48, - 0x332ec3, - 0x2461c1, - 0x2096c1, - 0x202201, - 0x209441, - 0x24a5c1, - 0x27e081, - 0x24c0c1, - 0x2462c1, - 0x2e7481, - 0x30ed01, - 0x200141, - 0x200001, - 0x15f048, - 0x200701, - 0x200101, - 0x2000c1, - 0x201e41, - 0x200181, - 0x200941, - 0x200041, - 0x204ec1, - 0x200081, - 0x201481, - 0x200c01, - 0x2002c1, - 0x200381, - 0x200e81, - 0x21c2c1, - 0x2003c1, - 0x200201, - 0x200241, - 0x200a01, - 0x2019c1, - 0x201a81, - 0x2005c1, - 0x2007c1, - 0x200cc1, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x20d1c2, - 0x2d0783, - 0x231b83, - 0x200382, - 0x200383, - 0x13ecc7, - 0xfcc7, - 0x28b86, - 0x3dcca, - 0x8cc48, - 0x58dc8, - 0x59207, - 0x62a46, - 0xde185, - 0x63c85, - 0x177ac6, - 0x125886, - 0x24ae04, - 0x31cdc7, - 0x15f048, - 0x2da904, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x2d0783, - 0x231b83, - 0x2135c3, - 0x332ec3, - 0x204303, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x217082, - 0x2c8dc3, - 0x21fd43, - 0x200603, - 0x202942, - 0x251d43, - 0x205283, - 0x21e743, - 0x200001, - 0x203e43, - 0x225b04, - 0x37f1c3, - 0x318cc3, - 0x21c403, - 0x360383, - 0xaad0783, - 0x23a184, - 0x21c3c3, - 0x22f143, - 0x231b83, - 0x2318c3, - 0x23a943, - 0x2a85c3, - 0x318c43, - 0x233ec3, - 0x201e43, - 0x253f84, - 0x2abc02, - 0x258683, - 0x25eb43, - 0x27bfc3, - 0x262883, - 0x201dc3, - 0x332ec3, - 0x208803, - 0x209e43, - 0x204143, - 0x210203, - 0x2ff083, - 0xae30043, - 0x2b1083, - 0x2113c3, - 0x22d603, - 0x20fbc3, - 0x226302, - 0x201683, - 0x204ac3, - 0x160abc3, - 0x27d643, - 0x20ff03, - 0x216ec3, - 0x200383, - 0x3b37c3, - 0x21aa03, - 0x241f03, - 0x304f43, - 0x2f8203, - 0x30c845, - 0x2202c3, - 0x2f8243, - 0x35ed83, - 0x218c84, - 0x265203, - 0x311883, - 0x2d8fc3, - 0x201383, - 0x217082, - 0x23bd83, - 0x308484, - 0x22fec4, - 0x22a843, - 0x15f048, - 0x4cc2, - 0x1442, - 0x2942, - 0x5ac2, - 0x2302, - 0x702, - 0x4e242, - 0x1c2, - 0x8a42, - 0xc02, - 0xf302, - 0xb602, - 0x73fc2, - 0x4c82, - 0x61e82, - 0x17902, - 0x3cf82, - 0x54c2, - 0x18b82, - 0xfc2, - 0x682, - 0x1bb82, - 0x1f82, - 0xc4c2, - 0x1702, - 0x20c42, - 0xa42, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x20d1c2, - 0x200383, - 0xc2d0783, - 0x332ec3, - 0x20fbc3, - 0x20dc42, - 0x15f048, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x6c82, - 0x2031c2, - 0x24ac42, - 0x15f048, - 0xd1c2, - 0x233482, - 0x208842, - 0x22f942, - 0x204182, - 0x209282, - 0x63c85, - 0x204702, - 0x201882, - 0x211f82, - 0x2034c2, - 0x217902, - 0x384982, - 0x201ac2, - 0x245742, - 0x13ecc7, - 0x169a8d, - 0xde209, - 0x56bcb, - 0xe3888, - 0x55109, - 0x332ec3, - 0x15f048, - 0x15f048, - 0x59b46, - 0x204cc2, - 0x24ae04, - 0x20d1c2, - 0x2d0783, - 0x2000c2, - 0x231b83, - 0x208a42, - 0x2da904, - 0x204303, - 0x2513c2, - 0x204ac3, - 0x200382, - 0x200383, - 0x2716c6, - 0x31c0cf, - 0x70d8c3, - 0x15f048, - 0x20d1c2, - 0x2135c3, - 0x332ec3, - 0x20fbc3, - 0x155afcb, - 0xde548, - 0x14ff507, - 0x13ecc7, - 0x20d1c2, - 0x2d0783, - 0x332ec3, - 0x204ac3, - 0x204cc2, - 0x200902, - 0x207f42, - 0xfad0783, - 0x2416c2, - 0x231b83, - 0x2101c2, - 0x22ad02, - 0x332ec3, - 0x2630c2, - 0x255302, - 0x2ae4c2, - 0x203742, - 0x291e02, - 0x209902, - 0x200b82, - 0x274842, - 0x258142, - 0x251b02, - 0x2b36c2, - 0x242602, - 0x246082, - 0x263c42, - 0x20fbc3, - 0x205f02, - 0x204ac3, - 0x231302, - 0x27de02, - 0x200383, - 0x251dc2, - 0x20c4c2, - 0x209f42, - 0x200b42, - 0x20c842, - 0x2e4742, - 0x220382, - 0x24d082, - 0x234f42, - 0x310c8a, - 0x347d0a, - 0x37e80a, - 0x3b5dc2, - 0x2046c2, - 0x204e82, - 0xff4f589, - 0x10324d0a, - 0x15926c7, - 0x1410c43, - 0x243d0, - 0x9402, - 0x24fe44, - 0x10ad0783, - 0x231b83, - 0x251304, - 0x332ec3, - 0x2964c4, - 0x204303, - 0x20fbc3, - 0x204ac3, - 0x20abc3, - 0x200383, - 0x2202c3, - 0x24abc3, - 0x15f048, - 0x14629c4, - 0x614c5, - 0x5f88a, - 0x1168c2, - 0x1a03c6, - 0x102d11, - 0x1134f589, - 0x61548, - 0x82a08, - 0x5e887, - 0xf82, - 0x19a18a, - 0x2ac47, - 0x15f048, - 0x10b708, - 0xbac7, - 0x16c1b74b, - 0x1082, - 0x15de87, - 0xdb4a, - 0x5e58f, - 0xfd4f, - 0x1c402, - 0xd1c2, - 0xa8508, - 0x185b0a, - 0x1681c8, - 0x3b02, - 0x5e30f, - 0xa3d4b, - 0x1672c8, - 0x13edc7, - 0x15104a, - 0x2f64b, - 0x11dd09, - 0x150f47, - 0x100c4c, - 0x1b3c47, - 0x18d18a, - 0x94b88, - 0x195a8e, - 0x28b8e, - 0x2aa8b, - 0x2b2cb, - 0x2d3cb, - 0x2e209, - 0x3558b, - 0x4a68d, - 0xe984b, - 0xec8cd, - 0xecc4d, - 0x18274a, - 0x2fd0b, - 0x3688b, - 0x42305, - 0x14243d0, - 0x125d8f, - 0x1264cf, - 0x48dcd, - 0x25910, - 0x1742, - 0x17203988, - 0xfb48, - 0x176f4745, - 0x505cb, - 0x117050, - 0x57488, - 0x2b48a, - 0x5f4c9, - 0x695c7, - 0x69907, - 0x69ac7, - 0x6c287, - 0x6d307, - 0x6dd07, - 0x6e487, - 0x6e8c7, - 0x6f487, - 0x6f787, - 0x6ffc7, - 0x70187, - 0x70347, - 0x70507, - 0x70807, - 0x70c47, - 0x718c7, - 0x71d87, - 0x729c7, - 0x72f07, - 0x730c7, - 0x73807, - 0x73e87, - 0x74087, - 0x74347, - 0x74507, - 0x746c7, - 0x75047, - 0x754c7, - 0x75987, - 0x76147, - 0x76407, - 0x76bc7, - 0x76d87, - 0x77107, - 0x77d07, - 0x78987, - 0x78d87, - 0x78f47, - 0x79107, - 0x79547, - 0x7a307, - 0x7a607, - 0x7a907, - 0x7aac7, - 0x7ae47, - 0x7b387, - 0xa9c2, - 0x4c94a, - 0x16dc87, - 0x178d528b, - 0x14d5296, - 0x19151, - 0xf080a, - 0xa838a, - 0x59b46, - 0xd2acb, - 0x642, - 0x2e891, - 0x94609, - 0x9a109, - 0x74842, - 0xa4f4a, - 0xaa689, - 0xab24f, - 0xaca4e, - 0xad708, - 0x18d82, - 0x15da89, - 0x18b88e, - 0xfd08c, - 0xf254f, - 0x146ce, - 0x23b4c, - 0x2ccc9, - 0x2db51, - 0x465c8, - 0x482d2, - 0x49fcd, - 0x82bcd, - 0x19090b, - 0x3d2d5, - 0x4c809, - 0x4ec0a, - 0x4f489, - 0x5ecd0, - 0x72c4b, - 0x79f4f, - 0x7c48b, - 0x8340c, - 0x84610, - 0x8894a, - 0x8dd0d, - 0x16618e, - 0x1ae00a, - 0x8f7cc, - 0x93994, - 0x94291, - 0xa494b, - 0xa578f, - 0xa7bcd, - 0xac3ce, - 0xb1acc, - 0xb220c, - 0xdc90b, - 0xdcc0e, - 0x122110, - 0x11640b, - 0x17a64d, - 0x1af38f, - 0xb798c, - 0xb934e, - 0xbb311, - 0xc3ccc, - 0xc5a47, - 0x15e58d, - 0x12b50c, - 0x14be50, - 0xd1b4d, - 0xd8e47, - 0xe2350, - 0xfa008, - 0xfb08b, - 0x150bcf, - 0x17de88, - 0xf0a0d, - 0x181d50, - 0x17fb1846, - 0xb6003, - 0x1b02, - 0xd0309, - 0x5ac0a, - 0x1084c6, - 0x180dff49, - 0x13203, - 0xdab91, - 0xdafc9, - 0xdc047, - 0x5e40b, - 0xe4a90, - 0xe4f4c, - 0xe5385, - 0x126cc8, - 0x19dc0a, - 0x129607, - 0x1002, - 0x12464a, - 0x25e49, - 0x3a20a, - 0x8eacf, - 0x44f4b, - 0x1b280c, - 0x1b2ad2, - 0xaa085, - 0x2124a, - 0x186f2fc5, - 0x17698c, - 0x121203, - 0x184982, - 0xf86ca, - 0x96b88, - 0xeca88, - 0x14a587, - 0xd42, - 0x2602, - 0x3f390, - 0x1702, - 0x1aa2cf, - 0x177ac6, - 0x301ce, - 0xe7fcb, - 0x1ae208, - 0xd6c09, - 0x17cd92, - 0x7c0d, - 0x56608, - 0x56a89, - 0x5700d, - 0x59c89, - 0x5a28b, - 0x5b088, - 0x5f6c8, - 0x68bc8, - 0x68e49, - 0x6904a, - 0x6c8cc, - 0xe5d0a, - 0x104f87, - 0x16b2cd, - 0xf910b, - 0x12fb4c, - 0x1a05d0, - 0x6902, - 0x1968cd, - 0x16c2, - 0x11fc2, - 0x104eca, - 0xf070a, - 0xf6bcb, - 0x36a4c, - 0x10b48e, - 0x21ccd, - 0x1ab488, - 0x6c82, - 0x1166118e, - 0x11f6a18e, - 0x1266c00a, - 0x12ed0a0e, - 0x137156ce, - 0x13f2a00c, - 0x15926c7, - 0x15926c9, - 0x1410c43, - 0x14731e8c, - 0x14f3a009, - 0x1409402, - 0x610d1, - 0x16a0d1, - 0x6bf4d, - 0xd0951, - 0x11b1d1, - 0x129f4f, - 0x131dcf, - 0x139f4c, - 0x14a94d, - 0x18d555, - 0x1ace0c, - 0x1b41cc, - 0x1b5850, - 0x940c, - 0x5838c, - 0xedc19, - 0x1a6719, - 0x115419, - 0x15c754, - 0x17f854, - 0x198594, - 0x19ae14, - 0x1a9054, - 0x1577fb09, - 0x15d98849, - 0x167b4289, - 0x11b6b089, - 0x9402, - 0x1236b089, - 0x9402, - 0xedc0a, - 0x9402, - 0x12b6b089, - 0x9402, - 0xedc0a, - 0x9402, - 0x1336b089, - 0x9402, - 0x13b6b089, - 0x9402, - 0x1436b089, - 0x9402, - 0xedc0a, - 0x9402, - 0x14b6b089, - 0x9402, - 0xedc0a, - 0x9402, - 0x1536b089, - 0x9402, - 0x15b6b089, - 0x9402, - 0x1636b089, - 0x9402, - 0x16b6b089, - 0x9402, - 0xedc0a, - 0x9402, - 0x102d05, - 0x19a184, - 0x11d644, - 0x1a4884, - 0xbfc04, - 0x2144, - 0x5e884, - 0x1482283, - 0x1420183, - 0xffd84, - 0x1542b83, - 0x1742, - 0x21cc3, - 0x204cc2, - 0x20d1c2, - 0x2000c2, - 0x2041c2, - 0x208a42, - 0x200382, - 0x202602, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204143, - 0x204ac3, - 0x200383, - 0x15f048, - 0x2d0783, - 0x231b83, - 0x204ac3, - 0x200383, - 0x3b943, - 0x332ec3, - 0x204cc2, - 0x368883, - 0x1a2d0783, - 0x20ef47, - 0x332ec3, - 0x205d83, - 0x213184, - 0x204ac3, - 0x200383, - 0x25084a, - 0x2716c5, - 0x21aa03, - 0x205bc2, - 0x15f048, - 0x15f048, - 0xd1c2, - 0x11f0c2, - 0x15dfc5, - 0x15f048, - 0xd0783, - 0x1ae3db07, - 0xcfd46, - 0x1b1acd05, - 0xcfe07, - 0xa54a, - 0xa408, - 0xb747, - 0x5f2c8, - 0x18c407, - 0xed30f, - 0x3ab07, - 0x165bc6, - 0x117050, - 0x122f0f, - 0x108544, - 0x1b4cfece, - 0xafd0c, - 0x11de8a, - 0xac687, - 0x12d54a, - 0x60989, - 0xc2f4a, - 0x77a8a, - 0x1084c6, - 0xac74a, - 0x11a58a, - 0x154009, - 0xda448, - 0xda746, - 0xde74d, - 0xb9905, - 0x5a107, - 0x16df94, - 0xfe58b, - 0x16710a, - 0xa8bcd, - 0x28b83, - 0x28b83, - 0x28b86, - 0x28b83, - 0x168883, - 0x15f048, - 0xd1c2, - 0x51304, - 0x8cdc3, - 0x170145, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x205283, - 0x2d0783, - 0x231b83, - 0x2135c3, - 0x332ec3, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x29a2c3, - 0x24abc3, - 0x205283, - 0x24ae04, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x209103, - 0x2d0783, - 0x231b83, - 0x2041c3, - 0x2135c3, - 0x332ec3, - 0x2964c4, - 0x23a0c3, - 0x22d603, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x21aa03, - 0x38c743, - 0x1d2d0783, - 0x231b83, - 0x2c3ec3, - 0x332ec3, - 0x2075c3, - 0x22d603, - 0x200383, - 0x2054c3, - 0x343c44, - 0x15f048, - 0x1dad0783, - 0x231b83, - 0x2ad7c3, - 0x332ec3, - 0x20fbc3, - 0x213184, - 0x204ac3, - 0x200383, - 0x21d7c3, - 0x15f048, - 0x1e2d0783, - 0x231b83, - 0x2135c3, - 0x20abc3, - 0x200383, - 0x15f048, - 0x15926c7, - 0x368883, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x2964c4, - 0x213184, - 0x204ac3, - 0x200383, - 0x13ecc7, - 0x16e1cb, - 0xdb3c4, - 0xb9905, - 0x1491b48, - 0xae2cd, - 0x1f68a405, - 0x192c4, - 0x1a5c3, - 0x367fc5, - 0x15f048, - 0x1d202, - 0x2803, - 0xf7286, - 0x32f448, - 0x304507, - 0x24ae04, - 0x3b3006, - 0x3b5706, - 0x15f048, - 0x310683, - 0x2384c9, - 0x2bdad5, - 0xbdadf, - 0x2d0783, - 0x39a9d2, - 0xf5806, - 0x10cfc5, - 0x2b48a, - 0x5f4c9, - 0x39a78f, - 0x2da904, - 0x20f345, - 0x2fee50, - 0x2959c7, - 0x20abc3, - 0x2842c8, - 0x1257c6, - 0x2b400a, - 0x200e84, - 0x2f2a03, - 0x2716c6, - 0x205bc2, - 0x26b44b, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x2f74c3, - 0x20d1c2, - 0x204ac3, - 0x200383, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x200383, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x205d83, - 0x223103, - 0x200383, - 0x20d1c2, - 0x2d0783, - 0x231b83, - 0x204ac3, - 0x200383, - 0x204cc2, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x24ae04, - 0x2d0783, - 0x231b83, - 0x222044, - 0x204ac3, - 0x200383, - 0x15f048, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x2d0783, - 0x231b83, - 0x2135c3, - 0x209e43, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x20d1c2, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x15f048, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x262fc3, - 0x1e303, - 0x5d83, - 0x204ac3, - 0x200383, - 0x310c8a, - 0x32a949, - 0x34184b, - 0x341f8a, - 0x347d0a, - 0x356e8b, - 0x37300a, - 0x37914a, - 0x37e80a, - 0x37ea8b, - 0x39d949, - 0x39f84a, - 0x39fbcb, - 0x3a9d0b, - 0x3b4a8a, - 0x2d0783, - 0x231b83, - 0x2135c3, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x10c9c9, - 0x15f048, - 0x2d0783, - 0x2695c4, - 0x200c82, - 0x213184, - 0x3ac705, - 0x205283, - 0x24ae04, - 0x2d0783, - 0x23a184, - 0x231b83, - 0x251304, - 0x2da904, - 0x2964c4, - 0x22d603, - 0x204ac3, - 0x200383, - 0x293ac5, - 0x209103, - 0x21aa03, - 0x22c6c3, - 0x258a04, - 0x262904, - 0x35d705, - 0x15f048, - 0x306e44, - 0x20e546, - 0x28a8c4, - 0x20d1c2, - 0x361ac7, - 0x253587, - 0x24f0c4, - 0x25d8c5, - 0x2d1d45, - 0x2b0405, - 0x2964c4, - 0x23cfc8, - 0x33f306, - 0x311f48, - 0x227b05, - 0x2e0405, - 0x377004, - 0x200383, - 0x2f39c4, - 0x355f46, - 0x2717c3, - 0x258a04, - 0x291a45, - 0x363644, - 0x234e84, - 0x205bc2, - 0x25e206, - 0x392206, - 0x3022c5, - 0x204cc2, - 0x368883, - 0x24e0d1c2, - 0x232dc4, - 0x208a42, - 0x20fbc3, - 0x25e402, - 0x204ac3, - 0x200382, - 0x213e83, - 0x24abc3, - 0x15f048, - 0x15f048, - 0x332ec3, - 0x204cc2, - 0x25a0d1c2, - 0x332ec3, - 0x2702c3, - 0x23a0c3, - 0x32bc44, - 0x204ac3, - 0x200383, - 0x15f048, - 0x204cc2, - 0x2620d1c2, - 0x2d0783, - 0x204ac3, - 0x200383, - 0x682, - 0x2044c2, - 0x217082, - 0x205d83, - 0x2ec383, - 0x204cc2, - 0x15f048, - 0x13ecc7, - 0x20d1c2, - 0x231b83, - 0x251304, - 0x202743, - 0x332ec3, - 0x209e43, - 0x20fbc3, - 0x204ac3, - 0x2183c3, - 0x200383, - 0x21d743, - 0x1286d3, - 0x12cb54, - 0x13ecc7, - 0x1fd86, - 0x5ae0b, - 0x28b86, - 0x58c07, - 0x130089, - 0xe9cca, - 0x8cb0d, - 0x16978c, - 0x13d64a, - 0x63c85, - 0xa588, - 0x177ac6, - 0x125886, - 0x201742, - 0x827cc, - 0x19a347, - 0x23551, - 0x2d0783, - 0x5f245, - 0x102c4, - 0x274341c6, - 0x19146, - 0x178146, - 0x920ca, - 0xb2f03, - 0x27a5c984, - 0x130045, - 0xa383, - 0xd2b8c, - 0xf6188, - 0xbaf48, - 0xa3bc9, - 0x20c48, - 0x141dd06, - 0xfbc88, - 0x5e884, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x204cc2, - 0x20d1c2, - 0x332ec3, - 0x20a3c2, - 0x204ac3, - 0x200383, - 0x213e83, - 0x36388f, - 0x363c4e, - 0x15f048, - 0x2d0783, - 0x4cd07, - 0x231b83, - 0x332ec3, - 0x204303, - 0x204ac3, - 0x200383, - 0x21d0c3, - 0x239c47, - 0x200142, - 0x2c1949, - 0x201442, - 0x23f68b, - 0x2b5b8a, - 0x2bcfc9, - 0x200282, - 0x262b46, - 0x26d615, - 0x23f7d5, - 0x274a13, - 0x23fd53, - 0x202342, - 0x20d605, - 0x3ab1cc, - 0x24698b, - 0x29a745, - 0x205ac2, - 0x289c02, - 0x386746, - 0x200f82, - 0x25fb86, - 0x294d0d, - 0x255dcc, - 0x224444, - 0x201342, - 0x203782, - 0x248688, - 0x202302, - 0x208886, - 0x303bc4, - 0x26d7d5, - 0x274b93, - 0x210b83, - 0x33070a, - 0x2f0187, - 0x3b2209, - 0x32dc47, - 0x3124c2, - 0x200002, - 0x3a4386, - 0x20a0c2, - 0x15f048, - 0x200802, - 0x211cc2, - 0x27d407, - 0x3b3507, - 0x21c7c5, - 0x201082, - 0x21d707, - 0x21d8c8, - 0x2413c2, - 0x2c2fc2, - 0x22c1c2, - 0x20e542, - 0x23b688, - 0x218443, - 0x2b72c8, - 0x2e078d, - 0x21fe43, - 0x226288, - 0x23e88f, - 0x23ec4e, - 0x24ac8a, - 0x229d11, - 0x22a190, - 0x2bf0cd, - 0x2bf40c, - 0x38c5c7, - 0x330887, - 0x3b30c9, - 0x204f02, - 0x200702, - 0x25a6cc, - 0x25a9cb, - 0x202ac2, - 0x2dcac6, - 0x20db42, - 0x20c502, - 0x21c402, - 0x20d1c2, - 0x384684, - 0x23c7c7, - 0x220802, - 0x242c07, - 0x243c47, - 0x2271c2, - 0x20e482, - 0x24cbc5, - 0x204d02, - 0x20cb4e, - 0x36f1cd, - 0x231b83, - 0x353a0e, - 0x2c0b8d, - 0x3ab643, - 0x201842, - 0x206744, - 0x208182, - 0x220a42, - 0x33e805, - 0x348447, - 0x372202, - 0x2041c2, - 0x250f07, - 0x2543c8, - 0x2abc02, - 0x2aa106, - 0x25a54c, - 0x25a88b, - 0x20da42, - 0x26588f, - 0x265c50, - 0x26604f, - 0x266415, - 0x266954, - 0x266e4e, - 0x2671ce, - 0x26754f, - 0x26790e, - 0x267c94, - 0x268193, - 0x26864d, - 0x27b549, - 0x28dbc3, - 0x200182, - 0x237b85, - 0x206506, - 0x208a42, - 0x21a2c7, - 0x332ec3, - 0x200642, - 0x36edc8, - 0x229f51, - 0x22a390, - 0x200bc2, - 0x28d387, - 0x200b02, - 0x205fc7, - 0x201b02, - 0x32f249, - 0x386707, - 0x281408, - 0x234006, - 0x2cf4c3, - 0x2cf4c5, - 0x231e02, - 0x204842, - 0x3a4785, - 0x376e05, - 0x205e82, - 0x245f43, - 0x3636c7, - 0x210687, - 0x204982, - 0x3aae04, - 0x214183, - 0x2c9209, - 0x2ed188, - 0x205d82, - 0x2032c2, - 0x26e2c7, - 0x282185, - 0x2ab548, - 0x20d2c7, - 0x216143, - 0x372306, - 0x2bef4d, - 0x2bf2cc, - 0x280346, - 0x208842, - 0x2017c2, - 0x201f02, - 0x23e70f, - 0x23eb0e, - 0x2d1dc7, - 0x203cc2, - 0x2c3345, - 0x2c3346, - 0x20bcc2, - 0x205f02, - 0x28f406, - 0x205f03, - 0x205f06, - 0x2ca585, - 0x2ca58d, - 0x2cab55, - 0x2cb38c, - 0x2cc28d, - 0x2cc652, - 0x20b602, - 0x273fc2, - 0x201302, - 0x240fc6, - 0x2fcf46, - 0x201002, - 0x206586, - 0x211f82, - 0x37edc5, - 0x202382, - 0x20cc89, - 0x2df2cc, - 0x2df60b, - 0x200382, - 0x255688, - 0x213a02, - 0x204c82, - 0x246746, - 0x36b005, - 0x235007, - 0x2567c5, - 0x294805, - 0x24cd82, - 0x20a642, - 0x217902, - 0x2f2847, - 0x24410d, - 0x24448c, - 0x2b3387, - 0x2aa082, - 0x23cf82, - 0x24ba48, - 0x2d0488, - 0x2e5f88, - 0x2f09c4, - 0x2dce87, - 0x2ee483, - 0x2b6042, - 0x200e82, - 0x2f11c9, - 0x395e87, - 0x2054c2, - 0x277245, - 0x201202, - 0x26a102, - 0x349c43, - 0x349c46, - 0x2f74c2, - 0x2f7fc2, - 0x201402, - 0x3b3fc6, - 0x206687, - 0x207842, - 0x200e02, - 0x38bc8f, - 0x35384d, - 0x2b714e, - 0x2c0a0c, - 0x2003c2, - 0x205502, - 0x233e45, - 0x3b4e86, - 0x201ec2, - 0x200fc2, - 0x200682, - 0x20d244, - 0x2e0604, - 0x2d29c6, - 0x202602, - 0x27e787, - 0x22d703, - 0x22d708, - 0x24b048, - 0x390787, - 0x240ec6, - 0x20e5c2, - 0x23b383, - 0x23b387, - 0x272846, - 0x2e4385, - 0x2f0d48, - 0x206342, - 0x34a007, - 0x220c42, - 0x33c282, - 0x203b82, - 0x2dbe09, - 0x22fb02, - 0x200242, - 0x240183, - 0x319ac7, - 0x2018c2, - 0x2df44c, - 0x2df74b, - 0x2803c6, - 0x20a2c5, - 0x222e82, - 0x200a42, - 0x2bd306, - 0x235b83, - 0x39c147, - 0x23bb02, - 0x203382, - 0x26d495, - 0x23f995, - 0x2748d3, - 0x23fed3, - 0x2934c7, - 0x2b5948, - 0x2fb310, - 0x30ee4f, - 0x2b5953, - 0x2bcd92, - 0x2c1510, - 0x2ca1cf, - 0x2d57d2, - 0x2d84d1, - 0x2d9513, - 0x2dbbd2, - 0x2dd20f, - 0x2e57ce, - 0x2f5092, - 0x2f6351, - 0x2f754f, - 0x2f834e, - 0x300011, - 0x355810, - 0x35f212, - 0x3702d1, - 0x2f9bc6, - 0x307487, - 0x373387, - 0x204b42, - 0x284e05, - 0x2febc7, - 0x217082, - 0x203142, - 0x2293c5, - 0x21ee43, - 0x35d986, - 0x2442cd, - 0x24460c, - 0x206602, - 0x3ab04b, - 0x24684a, - 0x30be4a, - 0x2bbf49, - 0x2ef68b, - 0x20d40d, - 0x2ff2cc, - 0x24890a, - 0x275b0c, - 0x27afcb, - 0x29a58c, - 0x2fa34b, - 0x2df243, - 0x35ee06, - 0x3a6502, - 0x2f8b82, - 0x2db2c3, - 0x202502, - 0x202503, - 0x245886, - 0x2665c7, - 0x365146, - 0x385cc8, - 0x2d0188, - 0x2d3186, - 0x2019c2, - 0x301c8d, - 0x301fcc, - 0x2da9c7, - 0x306d07, - 0x21fdc2, - 0x21ac02, - 0x23b302, - 0x254782, - 0x20d1c2, - 0x204ac3, - 0x200383, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x213184, - 0x204ac3, - 0x200383, - 0x213e83, - 0x204cc2, - 0x204e02, - 0x29a94005, - 0x29e02e85, - 0x2a3177c6, - 0x15f048, - 0x2a6b5145, - 0x20d1c2, - 0x2000c2, - 0x2ab9c685, - 0x2ae83305, - 0x2b283e07, - 0x2b68b309, - 0x2ba47ac4, - 0x208a42, - 0x200642, - 0x2bf72245, - 0x2c293149, - 0x2c71db88, - 0x2cab2085, - 0x2cf363c7, - 0x2d219b08, - 0x2d6e8605, - 0x2da5b4c6, - 0x2de346c9, - 0x2e2b8648, - 0x2e6c4b48, - 0x2ea9cf0a, - 0x2ee52104, - 0x2f2d6585, - 0x2f6becc8, - 0x2fb51245, - 0x2184c2, - 0x2fe63b83, - 0x302a7786, - 0x3064ea48, - 0x30a24f06, - 0x30ecec88, - 0x3132d1c6, - 0x316e4444, - 0x202082, - 0x31b630c7, - 0x31eaeb84, - 0x3227dc47, - 0x327a1087, - 0x200382, - 0x32aa0685, - 0x32e03bc4, - 0x332d1807, - 0x3362adc7, - 0x33a87406, - 0x33e36085, - 0x3429b807, - 0x346d2688, - 0x34a37f07, - 0x34eb0689, - 0x3538e6c5, - 0x35719c07, - 0x35a92e46, - 0x35e62d48, - 0x2460cd, - 0x24cf09, - 0x2f484b, - 0x25534b, - 0x27de4b, - 0x2aa88b, - 0x30f20b, - 0x30f4cb, - 0x30fd49, - 0x310f0b, - 0x3111cb, - 0x311ccb, - 0x31284a, - 0x312d8a, - 0x31338c, - 0x31608b, - 0x3166ca, - 0x327eca, - 0x3328ce, - 0x333a4e, - 0x333dca, - 0x335d8a, - 0x3369cb, - 0x336c8b, - 0x337a4b, - 0x34c7cb, - 0x34cdca, - 0x34da8b, - 0x34dd4a, - 0x34dfca, - 0x34e24a, - 0x373ecb, - 0x37a2cb, - 0x37c38e, - 0x37c70b, - 0x383ecb, - 0x38500b, - 0x38984a, - 0x389ac9, - 0x389d0a, - 0x38b38a, - 0x39e50b, - 0x39fe8b, - 0x3a09ca, - 0x3a28cb, - 0x3a588b, - 0x3b44cb, - 0x36285b88, - 0x3668c289, - 0x36aa3a49, - 0x36ee0bc8, - 0x33c685, - 0x202943, - 0x212944, - 0x206885, - 0x247806, - 0x25b245, - 0x28adc4, - 0x21a1c8, - 0x30af85, - 0x297a44, - 0x209907, - 0x2a280a, - 0x361d8a, - 0x3101c7, - 0x211f47, - 0x2fdec7, - 0x255b47, - 0x2fad45, - 0x343d06, - 0x22cb47, - 0x26fec4, - 0x2e6b46, - 0x2e6a46, - 0x208305, - 0x3492c4, - 0x38ec86, - 0x2a1647, - 0x22d046, - 0x351b47, - 0x26a783, - 0x2b4846, - 0x232045, - 0x283f07, - 0x270e0a, - 0x26dfc4, - 0x218ec8, - 0x2affc9, - 0x2cb147, - 0x334646, - 0x255908, - 0x200a49, - 0x3b23c4, - 0x2210c4, - 0x278285, - 0x22c848, - 0x2c7f47, - 0x2a7109, - 0x2f9cc8, - 0x347a86, - 0x24c646, - 0x29de88, - 0x354c46, - 0x202e85, - 0x2874c6, - 0x27e108, - 0x254b86, - 0x25d14b, - 0x29dac6, - 0x29f50d, - 0x3b1785, - 0x2aea46, - 0x20f505, - 0x349909, - 0x2abe87, - 0x3195c8, - 0x292986, - 0x29e709, - 0x364546, - 0x270d85, - 0x2a4dc6, - 0x2c99c6, - 0x2cdb89, - 0x200846, - 0x253087, - 0x277885, - 0x202383, - 0x25d2c5, - 0x29f7c7, - 0x358e06, - 0x3b1689, - 0x3177c6, - 0x287706, - 0x215ec9, - 0x286ec9, - 0x2a5607, - 0x2cf688, - 0x377f89, - 0x284a88, - 0x379386, - 0x2d9dc5, - 0x23cb4a, - 0x287786, - 0x3a8506, - 0x2cbbc5, - 0x272188, - 0x215587, - 0x22e68a, - 0x251746, - 0x24d345, - 0x329cc6, - 0x2d6347, - 0x334507, - 0x2c4145, - 0x270f45, - 0x2b2f86, - 0x351746, - 0x387046, - 0x2b8bc4, - 0x286209, - 0x28d146, - 0x30e50a, - 0x222848, - 0x309148, - 0x361d8a, - 0x2145c5, - 0x2a1585, - 0x37f588, - 0x2b6348, - 0x21b507, - 0x293846, - 0x320d48, - 0x3674c7, - 0x285188, - 0x2b9206, - 0x2885c8, - 0x29ad46, - 0x227c87, - 0x272b06, - 0x38ec86, - 0x25d9ca, - 0x384706, - 0x2d9dc9, - 0x2b5446, - 0x2e3d8a, - 0x2e4449, - 0x362586, - 0x2ba844, - 0x237c4d, - 0x28c507, - 0x3268c6, - 0x2c4a05, - 0x3645c5, - 0x375846, - 0x2d1649, - 0x2b4287, - 0x27f886, - 0x2c9546, - 0x28ae49, - 0x264a04, - 0x2d4a44, - 0x3ac808, - 0x245c46, - 0x277308, - 0x2e66c8, - 0x202fc7, - 0x3a80c9, - 0x387247, - 0x2b500a, - 0x2498cf, - 0x250b0a, - 0x233c45, - 0x27e345, - 0x218745, - 0x303b07, - 0x20e183, - 0x2cf888, - 0x3028c6, - 0x3029c9, - 0x2d4006, - 0x3aeb47, - 0x29e4c9, - 0x3194c8, - 0x2cbc87, - 0x30d803, - 0x33c705, - 0x20e105, - 0x2b8a0b, - 0x351304, - 0x257984, - 0x27cbc6, - 0x30e887, - 0x38b10a, - 0x2757c7, - 0x38c807, - 0x283305, - 0x200045, - 0x240909, - 0x38ec86, - 0x27564d, - 0x35af05, - 0x29f4c3, - 0x20ad83, - 0x34f785, - 0x347845, - 0x255908, - 0x280047, - 0x2d47c6, - 0x2a36c6, - 0x2296c5, - 0x231e47, - 0x202ac7, - 0x33f1c7, - 0x2d660a, - 0x2b4908, - 0x2b8bc4, - 0x254907, - 0x281607, - 0x3400c6, - 0x26f8c7, - 0x2eaa08, - 0x2e9e88, - 0x2abd86, - 0x2d1ec8, - 0x2008c4, - 0x22cb46, - 0x247d86, - 0x216646, - 0x3a8c46, - 0x22d9c4, - 0x255c06, - 0x2c31c6, - 0x29d406, - 0x235ec6, - 0x20ac46, - 0x2ea846, - 0x2d46c8, - 0x3af1c8, - 0x2d6e48, - 0x25b448, - 0x37f506, - 0x212485, - 0x2e2006, - 0x2b2105, - 0x388c87, - 0x216605, - 0x2136c3, - 0x203ec5, - 0x33fb44, - 0x20ad85, - 0x2266c3, - 0x338007, - 0x34bc88, - 0x351c06, - 0x32250d, - 0x27e306, - 0x29c985, - 0x2d9743, - 0x2be689, - 0x264b86, - 0x23c0c6, - 0x2a4ec4, - 0x250a87, - 0x233006, - 0x2b4545, - 0x234a83, - 0x207ac4, - 0x2817c6, - 0x2ded04, - 0x32b8c8, - 0x39ba49, - 0x24d849, - 0x2a4cca, - 0x387acd, - 0x208d07, - 0x224bc6, - 0x20a684, - 0x28b309, - 0x28a088, - 0x28c106, - 0x23dfc6, - 0x26f8c7, - 0x2b9a46, - 0x21f706, - 0x3ac246, - 0x3a110a, - 0x219b08, - 0x2464c5, - 0x26fd09, - 0x28568a, - 0x2fa988, - 0x2a0ec8, - 0x29bd48, - 0x2af08c, - 0x316305, - 0x2a3948, - 0x2e8e06, - 0x319746, - 0x3aea07, - 0x2756c5, - 0x287645, - 0x24d709, - 0x213487, - 0x302985, - 0x227487, - 0x20ad83, - 0x2c8485, - 0x20b8c8, - 0x25d647, - 0x2a0d89, - 0x2de405, - 0x307784, - 0x2a6508, - 0x363207, - 0x2cbe48, - 0x368c48, - 0x2dc805, - 0x304286, - 0x278686, - 0x2ac1c9, - 0x31c407, - 0x2b29c6, - 0x3b3907, - 0x221d03, - 0x247ac4, - 0x2a7885, - 0x231f84, - 0x383c84, - 0x286947, - 0x35bdc7, - 0x27fa44, - 0x2a0bd0, - 0x367c87, - 0x200045, - 0x2536cc, - 0x225344, - 0x2b1588, - 0x227b89, - 0x2b4e06, - 0x220d88, - 0x247344, - 0x247348, - 0x22ec86, - 0x235d48, - 0x2a1c06, - 0x2d328b, - 0x202385, - 0x2cb988, - 0x216ac4, - 0x39be8a, - 0x2a0d89, - 0x381346, - 0x218808, - 0x25ebc5, - 0x2b69c4, - 0x2b1486, - 0x33f088, - 0x285b88, - 0x340bc6, - 0x31d104, - 0x23cac6, - 0x3872c7, - 0x27db47, - 0x26f8cf, - 0x205547, - 0x362647, - 0x38eb45, - 0x352245, - 0x2a52c9, - 0x30e1c6, - 0x284045, - 0x2871c7, - 0x2c1108, - 0x29d505, - 0x272b06, - 0x222688, - 0x224f0a, - 0x2e13c8, - 0x28f187, - 0x249d06, - 0x26fcc6, - 0x20df43, - 0x218303, - 0x285849, - 0x377e09, - 0x2b0586, - 0x2de405, - 0x2163c8, - 0x218808, - 0x354dc8, - 0x3ac2cb, - 0x322747, - 0x30b249, - 0x26fb48, - 0x335844, - 0x349588, - 0x291409, - 0x2b2cc5, - 0x303a07, - 0x247b45, - 0x285a88, - 0x293e8b, - 0x29b550, - 0x2ae605, - 0x216a0c, - 0x2d4985, - 0x283383, - 0x29f386, - 0x2c0984, - 0x203cc6, - 0x2a1647, - 0x222704, - 0x24b388, - 0x2cf74d, - 0x35e245, - 0x208d44, - 0x233984, - 0x287bc9, - 0x2990c8, - 0x317647, - 0x22ed08, - 0x2862c8, - 0x27fb85, - 0x20f747, - 0x27fb07, - 0x238287, - 0x270f49, - 0x232e89, - 0x242d86, - 0x2bf606, - 0x26fb06, - 0x289845, - 0x39b744, - 0x3b0e86, - 0x3b5306, - 0x27fbc8, - 0x2d600b, - 0x26de87, - 0x20a684, - 0x364a46, - 0x367a47, - 0x34f0c5, - 0x263645, - 0x212dc4, - 0x232e06, - 0x3b0f08, - 0x28b309, - 0x252f86, - 0x289a48, - 0x2b4606, - 0x342708, - 0x34c34c, - 0x27fa46, - 0x29c64d, - 0x29cacb, - 0x253145, - 0x202c07, - 0x200946, - 0x3343c8, - 0x242e09, - 0x393c88, - 0x200045, - 0x2e2a87, - 0x284b88, - 0x358649, - 0x344106, - 0x252e8a, - 0x334148, - 0x393acb, - 0x3298cc, - 0x247448, - 0x280e46, - 0x303d08, - 0x3a8347, - 0x363489, - 0x29304d, - 0x29f986, - 0x21e608, - 0x3af089, - 0x2bfd08, - 0x2886c8, - 0x2c3a0c, - 0x2c5047, - 0x2c5507, - 0x270d85, - 0x31e5c7, - 0x2c0fc8, - 0x2b1506, - 0x2aaccc, - 0x2f55c8, - 0x2d0d88, - 0x2ba286, - 0x20de87, - 0x242f84, - 0x25b448, - 0x28f50c, - 0x353d0c, - 0x233cc5, - 0x2d2887, - 0x31d086, - 0x20de06, - 0x349ac8, - 0x2027c4, - 0x22d04b, - 0x27e8cb, - 0x249d06, - 0x2cf5c7, - 0x31a2c5, - 0x276545, - 0x22d186, - 0x25eb85, - 0x3512c5, - 0x2cd5c7, - 0x27d1c9, - 0x351904, - 0x34ee05, - 0x2e6fc5, - 0x2dea88, - 0x2287c5, - 0x2bca49, - 0x37aac7, - 0x37aacb, - 0x244806, - 0x2d4409, - 0x349208, - 0x27c385, - 0x238388, - 0x232ec8, - 0x23a6c7, - 0x2e2f87, - 0x2869c9, - 0x235c87, - 0x289149, - 0x2acf8c, - 0x2b0588, - 0x2b6189, - 0x321f87, - 0x286389, - 0x35bf07, - 0x3299c8, - 0x3a8285, - 0x22cac6, - 0x2c4a48, - 0x2f0fc8, - 0x285549, - 0x351307, - 0x276605, - 0x36b6c9, - 0x2b9ec6, - 0x2323c4, - 0x2323c6, - 0x24e8c8, - 0x252847, - 0x2d6208, - 0x2d1f89, - 0x3a1e07, - 0x2a29c6, - 0x202cc4, - 0x203f49, - 0x20f5c8, - 0x2ba147, - 0x343e06, - 0x20e1c6, - 0x3a8484, - 0x247f86, - 0x201b83, - 0x296789, - 0x202346, - 0x2d2205, - 0x2a36c6, - 0x24f305, - 0x285008, - 0x247187, - 0x244b46, - 0x39c6c6, - 0x309148, - 0x2a5447, - 0x29f9c5, - 0x2a09c8, - 0x3ada88, - 0x334148, - 0x2d4845, - 0x22cb46, - 0x24d609, - 0x2ac044, - 0x24f18b, - 0x21f40b, - 0x2463c9, - 0x20ad83, - 0x25bf05, - 0x213a86, - 0x313788, - 0x249844, - 0x351c06, - 0x2d6749, - 0x2bc545, - 0x2cd506, - 0x363206, - 0x2163c4, - 0x2aec0a, - 0x2d2148, - 0x2f0fc6, - 0x2c2585, - 0x3b1987, - 0x231147, - 0x304284, - 0x21f647, - 0x2165c4, - 0x2165c6, - 0x203c83, - 0x270f45, - 0x350e85, - 0x205788, - 0x254ac5, - 0x27f789, - 0x25b287, - 0x25b28b, - 0x2a758c, - 0x2a810a, - 0x3363c7, - 0x204083, - 0x212188, - 0x2d4a05, - 0x29d585, - 0x20ae44, - 0x3298c6, - 0x227b86, - 0x247fc7, - 0x2349cb, - 0x22d9c4, - 0x2e8f04, - 0x219e04, - 0x2cd786, - 0x222704, - 0x22c948, - 0x33c5c5, - 0x244d85, - 0x354d07, - 0x202d09, - 0x347845, - 0x37584a, - 0x277789, - 0x29810a, - 0x3a1249, - 0x335fc4, - 0x2c9605, - 0x2b9b48, - 0x2d18cb, - 0x278285, - 0x2f0086, - 0x2200c4, - 0x27fcc6, - 0x3a1c89, - 0x364b07, - 0x317988, - 0x387e46, - 0x387247, - 0x285b88, - 0x380946, - 0x37f0c4, - 0x363f87, - 0x366085, - 0x377547, - 0x25b4c4, - 0x2008c6, - 0x2f1e08, - 0x29cc88, - 0x2e88c7, - 0x27d548, - 0x29ae05, - 0x20abc4, - 0x361c88, - 0x27d644, - 0x2186c5, - 0x2fac44, - 0x3675c7, - 0x28d207, - 0x2864c8, - 0x2cbfc6, - 0x254a45, - 0x27f588, - 0x2e15c8, - 0x2a4c09, - 0x21f706, - 0x22e708, - 0x39bd0a, - 0x34f148, - 0x2e8605, - 0x2e2206, - 0x277648, - 0x2e2b4a, - 0x20b387, - 0x28a645, - 0x298888, - 0x2b3c44, - 0x272206, - 0x2c5888, - 0x20ac46, - 0x239a88, - 0x29bfc7, - 0x209806, - 0x2ba844, - 0x28ba07, - 0x2b6804, - 0x3a1c47, - 0x23bf0d, - 0x21b585, - 0x2d144b, - 0x2a1d06, - 0x255788, - 0x24b344, - 0x27bc86, - 0x2817c6, - 0x304047, - 0x29c30d, - 0x226dc7, - 0x2b6d48, - 0x271a05, - 0x27f048, - 0x2c7ec6, - 0x29ae88, - 0x223a06, - 0x26a9c7, - 0x336689, - 0x33d2c7, - 0x28c3c8, - 0x279685, - 0x21c848, - 0x20dd45, - 0x396005, - 0x3a14c5, - 0x221443, - 0x235984, - 0x26fd05, - 0x2346c9, - 0x285f86, - 0x2eab08, - 0x2e2d45, - 0x2b8847, - 0x2aee8a, - 0x2cd449, - 0x2c98ca, - 0x2d6ec8, - 0x2272cc, - 0x28724d, - 0x2ff683, - 0x239988, - 0x207a85, - 0x224cc6, - 0x319346, - 0x2e7f05, - 0x3b3a09, - 0x358f45, - 0x27f588, - 0x2841c6, - 0x348806, - 0x2a63c9, - 0x38f247, - 0x294146, - 0x2aee08, - 0x216548, - 0x2e0dc7, - 0x235ece, - 0x2c8105, - 0x358545, - 0x20ab48, - 0x27f3c7, - 0x20e202, - 0x2c3584, - 0x203bca, - 0x2ba208, - 0x367b46, - 0x29e608, - 0x278686, - 0x31a7c8, - 0x2b29c8, - 0x395fc4, - 0x2b8d85, - 0x68a8c4, - 0x68a8c4, - 0x68a8c4, - 0x202403, - 0x20e046, - 0x27fa46, - 0x2a220c, - 0x209843, - 0x285686, - 0x215344, - 0x264b08, - 0x2d6585, - 0x203cc6, - 0x2bedc8, - 0x2d8206, - 0x244ac6, - 0x381148, - 0x2a7907, - 0x235a49, - 0x2d4bca, - 0x208a84, - 0x216605, - 0x2a70c5, - 0x264886, - 0x208d46, - 0x2a2dc6, - 0x2f9ec6, - 0x235b84, - 0x235b8b, - 0x231144, - 0x2a23c5, - 0x2b19c5, - 0x203086, - 0x3b5548, - 0x287107, - 0x317744, - 0x2453c3, - 0x2b3745, - 0x30a847, - 0x28700b, - 0x205687, - 0x2becc8, - 0x2e8b47, - 0x231646, - 0x24d1c8, - 0x2e318b, - 0x2067c6, - 0x213bc9, - 0x2e3305, - 0x30d803, - 0x2cd506, - 0x29bec8, - 0x214cc3, - 0x200a03, - 0x285b86, - 0x278686, - 0x375dca, - 0x280e85, - 0x28160b, - 0x2a360b, - 0x245103, - 0x202043, - 0x2b4f84, - 0x278447, - 0x247444, - 0x202ec4, - 0x2e8c84, - 0x34f448, - 0x2c24c8, - 0x3b2049, - 0x38e748, - 0x200c07, - 0x235ec6, - 0x2ea74f, - 0x2c8246, - 0x2d6504, - 0x2c230a, - 0x30a747, - 0x208386, - 0x292e89, - 0x3b1fc5, - 0x2058c5, - 0x3b2106, - 0x21c983, - 0x2b3c89, - 0x219c86, - 0x212009, - 0x38b106, - 0x270f45, - 0x2340c5, - 0x205543, - 0x278588, - 0x211607, - 0x3028c4, - 0x264988, - 0x2313c4, - 0x338d86, - 0x29f386, - 0x2419c6, - 0x2cb849, - 0x29d505, - 0x38ec86, - 0x2a2fc9, - 0x2c7606, - 0x2ea846, - 0x386e86, - 0x200b45, - 0x2fac46, - 0x26a9c4, - 0x3a8285, - 0x2c4a44, - 0x2b7846, - 0x35aec4, - 0x20f843, - 0x28a145, - 0x232bc8, - 0x2e9687, - 0x2bd949, - 0x28a548, - 0x29dc51, - 0x36328a, - 0x249c47, - 0x2ea1c6, - 0x215344, - 0x2c4b48, - 0x282f48, - 0x29de0a, - 0x2bc80d, - 0x2a4dc6, - 0x381246, - 0x28bac6, - 0x2c3fc7, - 0x2b6e05, - 0x262c07, - 0x264a45, - 0x37ac04, - 0x2ad586, - 0x216287, - 0x2b398d, - 0x277587, - 0x21a0c8, - 0x27f889, - 0x2e2106, - 0x344085, - 0x226704, - 0x24e9c6, - 0x304186, - 0x2ba386, - 0x29ee88, - 0x2179c3, - 0x203043, - 0x3598c5, - 0x2300c6, - 0x2b2985, - 0x388048, - 0x2a180a, - 0x2cee04, - 0x264b08, - 0x29bd48, - 0x202ec7, - 0x2e2e09, - 0x2be9c8, - 0x28b387, - 0x2936c6, - 0x20ac4a, - 0x24ea48, - 0x396449, - 0x299188, - 0x21cec9, - 0x2ea087, - 0x2effc5, - 0x3ac4c6, - 0x2b1388, - 0x285d08, - 0x2a1048, - 0x249e08, - 0x2a23c5, - 0x20f444, - 0x211308, - 0x208484, - 0x3a1044, - 0x270f45, - 0x297a87, - 0x202ac9, - 0x303e47, - 0x215f45, - 0x27cdc6, - 0x34ebc6, - 0x203d44, - 0x2a6706, - 0x254884, - 0x27ef46, - 0x202886, - 0x214b06, - 0x200045, - 0x387f07, - 0x204083, - 0x206b49, - 0x308f48, - 0x264984, - 0x28b20d, - 0x29cd88, - 0x3053c8, - 0x3963c6, - 0x336789, - 0x2cd449, - 0x3a1985, - 0x2a190a, - 0x2adb4a, - 0x2af7cc, - 0x2af946, - 0x27d9c6, - 0x2c83c6, - 0x273209, - 0x224f06, - 0x262c46, - 0x359006, - 0x25b448, - 0x27d546, - 0x2d36cb, - 0x297c05, - 0x244d85, - 0x27dc45, - 0x366f46, - 0x20ac03, - 0x241946, - 0x277507, - 0x2c4a05, - 0x24c705, - 0x3645c5, - 0x327346, - 0x31da84, - 0x31da86, - 0x3add49, - 0x366dcc, - 0x37a948, - 0x33f004, - 0x2fa886, - 0x2a1e06, - 0x29bec8, - 0x218808, - 0x366cc9, - 0x3b1987, - 0x245989, - 0x254106, - 0x22c2c4, - 0x20bf04, - 0x286cc4, - 0x285b88, - 0x20290a, - 0x3477c6, - 0x352107, - 0x36f007, - 0x2d4505, - 0x2a7084, - 0x2913c6, - 0x2b6e46, - 0x202803, - 0x308d87, - 0x368b48, - 0x3a1aca, - 0x2ce348, - 0x2cec88, - 0x35af05, - 0x253245, - 0x26df85, - 0x2d48c6, - 0x33d4c6, - 0x35bd05, - 0x2969c9, - 0x2a6e8c, - 0x26e047, - 0x29de88, - 0x381a45, - 0x68a8c4, - 0x24df84, - 0x25d784, - 0x214486, - 0x2a450e, - 0x205947, - 0x2c41c5, - 0x2abfcc, - 0x231287, - 0x216207, - 0x218089, - 0x218f89, - 0x28a645, - 0x308f48, - 0x24d609, - 0x334005, - 0x2c4948, - 0x322906, - 0x361f06, - 0x2e4444, - 0x2ae848, - 0x251f43, - 0x303084, - 0x2b37c5, - 0x3ac0c7, - 0x210445, - 0x39bbc9, - 0x28aa8d, - 0x299886, - 0x245404, - 0x2937c8, - 0x27d00a, - 0x224107, - 0x23be45, - 0x203143, - 0x2a37ce, - 0x27868c, - 0x2faa87, - 0x2a46c7, - 0x203c03, - 0x224f45, - 0x25d785, - 0x29e9c8, - 0x29bb89, - 0x33ef06, - 0x247444, - 0x249b86, - 0x21e3cb, - 0x2cd1cc, - 0x221507, - 0x2d5c45, - 0x3ad988, - 0x2e0b85, - 0x2c2307, - 0x3630c7, - 0x251f45, - 0x20ac03, - 0x39a644, - 0x212905, - 0x351805, - 0x351806, - 0x34fd08, - 0x216287, - 0x319646, - 0x35c106, - 0x3a1406, - 0x2d5e89, - 0x20f847, - 0x26a5c6, - 0x2cd346, - 0x252006, - 0x2aeb45, - 0x219646, - 0x3768c5, - 0x228848, - 0x2973cb, - 0x291086, - 0x36f044, - 0x2e2909, - 0x25b284, - 0x322888, - 0x2324c7, - 0x2885c4, - 0x2be288, - 0x2c5304, - 0x2aeb84, - 0x28b145, - 0x35e286, - 0x34f387, - 0x239b43, - 0x2a2a85, - 0x322e84, - 0x358586, - 0x3a1a08, - 0x368885, - 0x297089, - 0x3363c5, - 0x2e1e88, - 0x215207, - 0x388dc8, - 0x2bd787, - 0x362709, - 0x255a86, - 0x32b3c6, - 0x359004, - 0x293605, - 0x30150c, - 0x27dc47, - 0x27e207, - 0x36eec8, - 0x299886, - 0x277444, - 0x32e344, - 0x286849, - 0x2c84c6, - 0x240987, - 0x3a8bc4, - 0x286086, - 0x343905, - 0x2cbb07, - 0x2d3646, - 0x252d49, - 0x2aab07, - 0x26f8c7, - 0x2a6246, - 0x3879c5, - 0x283988, - 0x219b08, - 0x2646c6, - 0x3688c5, - 0x261b06, - 0x209983, - 0x29e849, - 0x2a2b4e, - 0x2bd488, - 0x2314c8, - 0x2644cb, - 0x2972c6, - 0x2089c4, - 0x244ac4, - 0x2a2c4a, - 0x216907, - 0x26a685, - 0x213bc9, - 0x2c3285, - 0x3a1087, - 0x2b4c04, - 0x284487, - 0x2e65c8, - 0x2cb206, - 0x21e789, - 0x2beaca, - 0x216886, - 0x29c8c6, - 0x2b1945, - 0x37ccc5, - 0x31a107, - 0x24dd08, - 0x343848, - 0x395fc6, - 0x234145, - 0x208ace, - 0x2b8bc4, - 0x264645, - 0x27c749, - 0x30dfc8, - 0x28f0c6, - 0x2a04cc, - 0x2a1410, - 0x2a414f, - 0x2a51c8, - 0x3363c7, - 0x200045, - 0x26fd05, - 0x34f209, - 0x298a89, - 0x23cbc6, - 0x278307, - 0x2d2805, - 0x21b509, - 0x340146, - 0x224d4d, - 0x286b89, - 0x202ec4, - 0x2bd208, - 0x2113c9, - 0x347986, - 0x27cec5, - 0x32b3c6, - 0x317849, - 0x26ba08, - 0x212485, - 0x2ae844, - 0x2a068b, - 0x347845, - 0x2a07c6, - 0x287586, - 0x26ed86, - 0x287fcb, - 0x297189, - 0x35c045, - 0x388b87, - 0x363206, - 0x220f06, - 0x25d508, - 0x35e389, - 0x219e8c, - 0x30a648, - 0x360406, - 0x340bc3, - 0x303c06, - 0x287e05, - 0x281948, - 0x233b46, - 0x2cbd48, - 0x275845, - 0x29dfc5, - 0x215348, - 0x31a947, - 0x319287, - 0x247fc7, - 0x220d88, - 0x336508, - 0x31e4c6, - 0x2b7687, - 0x247987, - 0x287cca, - 0x254003, - 0x366f46, - 0x202a45, - 0x203bc4, - 0x27f889, - 0x362684, - 0x2a7e44, - 0x2a1c84, - 0x2a46cb, - 0x211547, - 0x208d05, - 0x29ab08, - 0x27cdc6, - 0x27cdc8, - 0x280dc6, - 0x2900c5, - 0x290385, - 0x291f46, - 0x292b08, - 0x292dc8, - 0x27fa46, - 0x29a94f, - 0x29e310, - 0x3b1785, - 0x204083, - 0x22c385, - 0x30b188, - 0x298989, - 0x334148, - 0x2d5d08, - 0x224788, - 0x211607, - 0x27ca89, - 0x2cbf48, - 0x25bd44, - 0x2a1b08, - 0x2deb49, - 0x2b81c7, - 0x29f904, - 0x303f08, - 0x387cca, - 0x2ebe06, - 0x2a4dc6, - 0x21f5c9, - 0x2a1647, - 0x2ce1c8, - 0x30cc88, - 0x3a8a48, - 0x356245, - 0x37dc45, - 0x244d85, - 0x25d745, - 0x37e287, - 0x20ac05, - 0x2c4a05, - 0x2b5546, - 0x334087, - 0x2d1807, - 0x387fc6, - 0x2d7405, - 0x2a07c6, - 0x212245, - 0x2b84c8, - 0x2f1d84, - 0x2c7686, - 0x343744, - 0x2b69c8, - 0x2c778a, - 0x28004c, - 0x234bc5, - 0x2c4086, - 0x21a046, - 0x368706, - 0x30b384, - 0x343bc5, - 0x280c07, - 0x2a16c9, - 0x2cdc87, - 0x68a8c4, - 0x68a8c4, - 0x3175c5, - 0x32dd04, - 0x29fe8a, - 0x27cc46, - 0x24d404, - 0x208305, - 0x37a545, - 0x2b6d44, - 0x2871c7, - 0x36b847, - 0x2cd788, - 0x368ec8, - 0x212489, - 0x340248, - 0x2a004b, - 0x250b44, - 0x221005, - 0x2840c5, - 0x247f49, - 0x35e389, - 0x2e2808, - 0x232248, - 0x203084, - 0x2a1e45, - 0x202943, - 0x264845, - 0x38ed06, - 0x29b9cc, - 0x20f4c6, - 0x247246, - 0x28f345, - 0x3273c8, - 0x2bd606, - 0x2ea346, - 0x2a4dc6, - 0x2297cc, - 0x2ba544, - 0x3a154a, - 0x28f288, - 0x29b807, - 0x322d86, - 0x33efc7, - 0x2f2185, - 0x343e06, - 0x34af86, - 0x356707, - 0x2be7c4, - 0x3676c5, - 0x27c744, - 0x37ac87, - 0x27c988, - 0x27d84a, - 0x284a07, - 0x2d22c7, - 0x336347, - 0x2e0cc9, - 0x29b9ca, - 0x219e43, - 0x2e9645, - 0x200c83, - 0x2e8cc9, - 0x26ac48, - 0x38eb47, - 0x334249, - 0x219c06, - 0x2d4108, - 0x337f85, - 0x2e16ca, - 0x2d8c49, - 0x2abc49, - 0x3aea07, - 0x283049, - 0x214a08, - 0x3568c6, - 0x2c4248, - 0x217b07, - 0x235c87, - 0x277787, - 0x2d2688, - 0x2fa706, - 0x387a85, - 0x280c07, - 0x29c3c8, - 0x3436c4, - 0x30e3c4, - 0x294047, - 0x2b2d47, - 0x24d48a, - 0x356846, - 0x330f0a, - 0x2c34c7, - 0x2b8987, - 0x257e44, - 0x289204, - 0x2d3546, - 0x3b3d44, - 0x3b3d4c, - 0x203505, - 0x218649, - 0x2dfc44, - 0x2b6e05, - 0x27cf88, - 0x292e85, - 0x375846, - 0x217f84, - 0x3ae3ca, - 0x32b7c6, - 0x2a68ca, - 0x237f07, - 0x2d3385, - 0x21c985, - 0x2d454a, - 0x2a6805, - 0x2a4cc6, - 0x208484, - 0x2b5106, - 0x31a1c5, - 0x233c06, - 0x2e88cc, - 0x2cd90a, - 0x2936c4, - 0x235ec6, - 0x2a1647, - 0x2d5204, - 0x25b448, - 0x38e5c6, - 0x208949, - 0x2bb109, - 0x2b0689, - 0x24f346, - 0x217c06, - 0x2c4387, - 0x296908, - 0x217a09, - 0x211547, - 0x29ac86, - 0x3872c7, - 0x28b985, - 0x2b8bc4, - 0x2c3f47, - 0x247b45, - 0x28b085, - 0x235247, - 0x251e08, - 0x3ad906, - 0x29d24d, - 0x29ebcf, - 0x2a360d, - 0x215f84, - 0x232cc6, - 0x2d91c8, - 0x358fc5, - 0x287e88, - 0x23a58a, - 0x202ec4, - 0x21e946, - 0x239607, - 0x22d9c7, - 0x2a79c9, - 0x2c4205, - 0x2b6d44, - 0x2b8cca, - 0x2be589, - 0x283147, - 0x272086, - 0x347986, - 0x2a1d86, - 0x364046, - 0x2d890f, - 0x2d9089, - 0x27d546, - 0x282e46, - 0x32fd89, - 0x2b7787, - 0x226743, - 0x229946, - 0x218303, - 0x2e7dc8, - 0x387107, - 0x2a53c9, - 0x29f208, - 0x3193c8, - 0x351446, - 0x20f409, - 0x23c1c5, - 0x2b7844, - 0x2a73c7, - 0x273285, - 0x215f84, - 0x208dc8, - 0x216bc4, - 0x2b74c7, - 0x34bc06, - 0x2b3045, - 0x299188, - 0x34784b, - 0x319c07, - 0x2d47c6, - 0x2c82c4, - 0x32d146, - 0x270f45, - 0x247b45, - 0x283709, - 0x286dc9, - 0x235cc4, - 0x235d05, - 0x235f05, - 0x2e1546, - 0x309048, - 0x2c2c46, - 0x36898b, - 0x2b4c8a, - 0x2b6905, - 0x290406, - 0x3025c5, - 0x2e0a45, - 0x2ab6c7, - 0x3ac808, - 0x245984, - 0x26c586, - 0x292e46, - 0x214bc7, - 0x30d7c4, - 0x2817c6, - 0x2b9f85, - 0x2b9f89, - 0x2135c4, - 0x2a7209, - 0x27fa46, - 0x2c5108, - 0x235f05, - 0x36f105, - 0x233c06, - 0x219d89, - 0x218f89, - 0x2472c6, - 0x30e0c8, - 0x28abc8, - 0x302584, - 0x2b9004, - 0x2b9008, - 0x3269c8, - 0x245a89, - 0x38ec86, - 0x2a4dc6, - 0x320c0d, - 0x351c06, - 0x34c209, - 0x23d1c5, - 0x3b2106, - 0x262d48, - 0x31d9c5, - 0x2479c4, - 0x270f45, - 0x2866c8, - 0x29fc49, - 0x27c804, - 0x2008c6, - 0x39660a, - 0x2fa988, - 0x24d609, - 0x244c4a, - 0x3341c6, - 0x29ed88, - 0x2c20c5, - 0x2c0e48, - 0x2bd885, - 0x219ac9, - 0x36bd09, - 0x203602, - 0x2e3305, - 0x276286, - 0x27f987, - 0x295705, - 0x2f0ec6, - 0x306288, - 0x299886, - 0x2b9a09, - 0x27e306, - 0x25d388, - 0x2afb85, - 0x25c586, - 0x26aac8, - 0x285b88, - 0x2e9f88, - 0x347b08, - 0x219644, - 0x209fc3, - 0x2b9c44, - 0x249b06, - 0x28b9c4, - 0x231407, - 0x2ea249, - 0x2c7a05, - 0x30cc86, - 0x229946, - 0x34fb4b, - 0x2b6846, - 0x20edc6, - 0x2cb6c8, - 0x24c646, - 0x2bcb03, - 0x2080c3, - 0x2b8bc4, - 0x22e605, - 0x2b4447, - 0x27c988, - 0x27c98f, - 0x280b0b, - 0x308e48, - 0x200946, - 0x30914e, - 0x233c03, - 0x2b43c4, - 0x2b67c5, - 0x2b6bc6, - 0x2914cb, - 0x297b46, - 0x222709, - 0x2b3045, - 0x38a208, - 0x211d88, - 0x218e4c, - 0x2a4706, - 0x264886, - 0x2de405, - 0x28c188, - 0x26aac5, - 0x335848, - 0x2a084a, - 0x2a3a49, - 0x68a8c4, - 0x3760d1c2, - 0x15f048, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x368883, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x2964c4, - 0x204ac3, - 0x200383, - 0x210e03, - 0x24ae04, - 0x2d0783, - 0x23a184, - 0x231b83, - 0x2da904, - 0x332ec3, - 0x2959c7, - 0x20fbc3, - 0x20abc3, - 0x2842c8, - 0x200383, - 0x2b400b, - 0x2f2a03, - 0x2716c6, - 0x205bc2, - 0x26b44b, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x200383, - 0x200e03, - 0x203383, - 0x204cc2, - 0x15f048, - 0x325b45, - 0x247bc8, - 0x2ec408, - 0x20d1c2, - 0x329dc5, - 0x39c307, - 0x2001c2, - 0x24b587, - 0x208a42, - 0x246f87, - 0x239ec9, - 0x2c1c88, - 0x3a88c9, - 0x338b02, - 0x270647, - 0x2abac4, - 0x39c3c7, - 0x2b4b87, - 0x24ca02, - 0x20fbc3, - 0x20b602, - 0x202082, - 0x200382, - 0x217902, - 0x200e02, - 0x20c4c2, - 0x2af685, - 0x24dec5, - 0xd1c2, - 0x31b83, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x117c3, - 0x701, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x2964c4, - 0x204303, - 0x204ac3, - 0x200383, - 0x21bd03, - 0x3a40d686, - 0x5e303, - 0x854c5, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x20d1c2, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x8082, - 0x15f048, - 0x4dcc4, - 0xe0f85, - 0x204cc2, - 0x2cfa44, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x236d03, - 0x2b0405, - 0x204303, - 0x205d83, - 0x204ac3, - 0x2104c3, - 0x200383, - 0x213e83, - 0x24ae83, - 0x24abc3, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x20d1c2, - 0x200383, - 0x15f048, - 0x332ec3, - 0x15f048, - 0x26ae03, - 0x2d0783, - 0x22ef04, - 0x231b83, - 0x332ec3, - 0x20a3c2, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x20a3c2, - 0x22d603, - 0x204ac3, - 0x200383, - 0x2ec383, - 0x213e83, - 0x204cc2, - 0x20d1c2, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x2716c5, - 0x1540c6, - 0x24ae04, - 0x205bc2, - 0x15f048, - 0x204cc2, - 0x1d508, - 0x20d1c2, - 0x97606, - 0x1681c4, - 0x16e1cb, - 0x3dc06, - 0xfcc7, - 0x231b83, - 0x332ec3, - 0x15ae05, - 0x19c804, - 0x221543, - 0x53fc7, - 0xdc304, - 0x204ac3, - 0x94fc4, - 0x200383, - 0x2f39c4, - 0xfe588, - 0x125886, - 0x114f85, - 0x20d1c2, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x20abc3, - 0x200383, - 0x2f2a03, - 0x205bc2, - 0x15f048, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204143, - 0x213184, - 0x204ac3, - 0x200383, - 0x2d0783, - 0x231b83, - 0x2da904, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x2716c6, - 0x231b83, - 0x332ec3, - 0x178ac3, - 0x200383, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0xfcc7, - 0x15f048, - 0x332ec3, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x40ed0783, - 0x231b83, - 0x204ac3, - 0x200383, - 0x15f048, - 0x204cc2, - 0x20d1c2, - 0x2d0783, - 0x332ec3, - 0x204ac3, - 0x200382, - 0x200383, - 0x316e47, - 0x23860b, - 0x2396c3, - 0x24be08, - 0x296687, - 0x225246, - 0x2c6145, - 0x373549, - 0x20f948, - 0x260d09, - 0x260d10, - 0x35d28b, - 0x385989, - 0x209303, - 0x2b5649, - 0x230806, - 0x23080c, - 0x260f08, - 0x3ae848, - 0x35d7c9, - 0x2a5d0e, - 0x20780b, - 0x2eb20c, - 0x205283, - 0x26cc4c, - 0x205289, - 0x257a87, - 0x231acc, - 0x36aa8a, - 0x24fe44, - 0x393f4d, - 0x26cb08, - 0x210e0d, - 0x272746, - 0x29258b, - 0x31a3c9, - 0x23d087, - 0x339606, - 0x349d89, - 0x38ce8a, - 0x37a0c8, - 0x2f24c4, - 0x34ecc7, - 0x3ac5c7, - 0x3a8dc4, - 0x32d984, - 0x237209, - 0x2ceac9, - 0x237908, - 0x210b85, - 0x392545, - 0x20aa06, - 0x393e09, - 0x23a80d, - 0x2eac88, - 0x20a907, - 0x2c61c8, - 0x382986, - 0x37ed04, - 0x359b85, - 0x202246, - 0x203204, - 0x205187, - 0x206d8a, - 0x211cc4, - 0x2167c6, - 0x2182c9, - 0x2182cf, - 0x2197cd, - 0x21a486, - 0x21d110, - 0x21d506, - 0x21dc47, - 0x21ebc7, - 0x21ebcf, - 0x21f889, - 0x2242c6, - 0x226487, - 0x226488, - 0x227649, - 0x2b3108, - 0x2e7907, - 0x20a203, - 0x378c86, - 0x3abf08, - 0x2a5fca, - 0x21fe49, - 0x20fa83, - 0x39c206, - 0x26c3ca, - 0x2fca47, - 0x2578ca, - 0x26a24e, - 0x21f9c6, - 0x2e3507, - 0x227086, - 0x201806, - 0x37da4b, - 0x30c58a, - 0x317ecd, - 0x217cc7, - 0x359188, - 0x359189, - 0x35918f, - 0x20e28c, - 0x281bc9, - 0x2e928e, - 0x295aca, - 0x3035c6, - 0x2fbbc6, - 0x3b06cc, - 0x3106cc, - 0x311448, - 0x33d1c7, - 0x25b7c5, - 0x2251c4, - 0x2438ce, - 0x38d104, - 0x257bc7, - 0x26d08a, - 0x36e914, - 0x373a4f, - 0x21ed88, - 0x378b48, - 0x357e8d, - 0x357e8e, - 0x3823c9, - 0x3a5b08, - 0x3a5b0f, - 0x2317cc, - 0x2317cf, - 0x232a07, - 0x23acca, - 0x21cc4b, - 0x23bcc8, - 0x23e5c7, - 0x264f4d, - 0x3151c6, - 0x394106, - 0x2417c9, - 0x259888, - 0x24c108, - 0x24c10e, - 0x238707, - 0x226985, - 0x24da85, - 0x205e04, - 0x225506, - 0x237808, - 0x260183, - 0x2efb8e, - 0x265308, - 0x2f198b, - 0x26afc7, - 0x395e05, - 0x26cdc6, - 0x2b0e07, - 0x307048, - 0x319f09, - 0x298fc5, - 0x28a188, - 0x217306, - 0x3a02ca, - 0x2437c9, - 0x231b89, - 0x231b8b, - 0x201148, - 0x3a8c89, - 0x210c46, - 0x22c54a, - 0x2b7f4a, - 0x23aecc, - 0x3acb87, - 0x2c1a8a, - 0x328ecb, - 0x328ed9, - 0x30fa48, - 0x271745, - 0x265106, - 0x258fc9, - 0x261cc6, - 0x21324a, - 0x20fb46, - 0x201e44, - 0x2c9ecd, - 0x201e47, - 0x20b549, - 0x383305, - 0x24e548, - 0x24ee89, - 0x24f0c4, - 0x24fd47, - 0x24fd48, - 0x250287, - 0x26ea08, - 0x2545c7, - 0x35c2c5, - 0x25c70c, - 0x25cf49, - 0x2c4dca, - 0x38f0c9, - 0x2b5749, - 0x2739cc, - 0x263e0b, - 0x2640c8, - 0x265688, - 0x268a44, - 0x288288, - 0x289389, - 0x36ab47, - 0x218506, - 0x317287, - 0x21e1c9, - 0x328b0b, - 0x32cfc7, - 0x200407, - 0x238047, - 0x210d84, - 0x210d85, - 0x2ac905, - 0x33c00b, - 0x399404, - 0x369d08, - 0x26f08a, - 0x2173c7, - 0x341dc7, - 0x290c12, - 0x27ee46, - 0x22e886, - 0x35898e, - 0x281346, - 0x298708, - 0x29938f, - 0x2111c8, - 0x38bb08, - 0x3af64a, - 0x3af651, - 0x2a6b4e, - 0x254e4a, - 0x254e4c, - 0x2014c7, - 0x3a5d10, - 0x3b5388, - 0x2a6d45, - 0x2b114a, - 0x20324c, - 0x29afcd, - 0x2fce06, - 0x2fce07, - 0x2fce0c, - 0x305c8c, - 0x32814c, - 0x28f98b, - 0x289b84, - 0x21f744, - 0x374149, - 0x2fe3c7, - 0x23e389, - 0x2b7d89, - 0x35a587, - 0x36a906, - 0x36a909, - 0x39d403, - 0x2129ca, - 0x32f807, - 0x238acb, - 0x317d4a, - 0x2abb44, - 0x39c546, - 0x284c89, - 0x3b3bc4, - 0x2035ca, - 0x2d4ac5, - 0x2c0005, - 0x2c000d, - 0x2c034e, - 0x378205, - 0x323506, - 0x2712c7, - 0x38684a, - 0x38d406, - 0x35ecc4, - 0x2f8987, - 0x2da18b, - 0x382a47, - 0x282ac4, - 0x24f706, - 0x24f70d, - 0x21de8c, - 0x204986, - 0x2eae8a, - 0x235806, - 0x2f3248, - 0x28bf47, - 0x33f88a, - 0x23d986, - 0x217bc3, - 0x262ec6, - 0x3abd88, - 0x2a024a, - 0x2766c7, - 0x2766c8, - 0x27dd84, - 0x2cc0c7, - 0x23ccc8, - 0x29e008, - 0x288b48, - 0x33110a, - 0x2e0405, - 0x2e0687, - 0x254c93, - 0x2d0806, - 0x26f288, - 0x222c09, - 0x24b448, - 0x3514cb, - 0x2cddc8, - 0x273704, - 0x215446, - 0x3b4f06, - 0x35e0c9, - 0x2c72c7, - 0x25c808, - 0x29e186, - 0x235144, - 0x2ce085, - 0x2c8a08, - 0x2c900a, - 0x2c9b48, - 0x2ce746, - 0x29ef8a, - 0x351988, - 0x2d5008, - 0x2d6a88, - 0x2d70c6, - 0x2d93c6, - 0x20168c, - 0x2d99d0, - 0x28de45, - 0x210fc8, - 0x306790, - 0x210fd0, - 0x260b8e, - 0x20130e, - 0x201314, - 0x31abcf, - 0x31af86, - 0x3319d1, - 0x339793, - 0x339c08, - 0x3aafc5, - 0x35b6c8, - 0x385785, - 0x22854c, - 0x229489, - 0x282449, - 0x245d47, - 0x377009, - 0x243d87, - 0x2fadc6, - 0x359987, - 0x261245, - 0x211803, - 0x260349, - 0x222ec9, - 0x378ac3, - 0x39a544, - 0x35c40d, - 0x3b1b0f, - 0x235185, - 0x35b5c6, - 0x211b07, - 0x325987, - 0x28cd86, - 0x28cd8b, - 0x2a82c5, - 0x25f106, - 0x2fba47, - 0x276ec9, - 0x2290c6, - 0x22e405, - 0x31190b, - 0x23bb46, - 0x3724c5, - 0x28b548, - 0x321d88, - 0x2d75cc, - 0x2d75d0, - 0x2e0149, - 0x2e7107, - 0x30860b, - 0x2e6186, - 0x2e77ca, - 0x2ea4cb, - 0x2eb74a, - 0x2eb9c6, - 0x2ec245, - 0x32f546, - 0x27e4c8, - 0x245e0a, - 0x357b1c, - 0x2f2acc, - 0x2f2dc8, - 0x2716c5, - 0x2f4f07, - 0x26a106, - 0x27d385, - 0x21c2c6, - 0x28cf48, - 0x2be807, - 0x2a5c08, - 0x2e360a, - 0x34a10c, - 0x34a389, - 0x37ee87, - 0x20d244, - 0x24db46, - 0x38b68a, - 0x2b7e85, - 0x20734c, - 0x20b088, - 0x377648, - 0x20d98c, - 0x21be8c, - 0x2206c9, - 0x220907, - 0x342c0c, - 0x3aa644, - 0x23c54a, - 0x2580cc, - 0x278acb, - 0x24140b, - 0x241f46, - 0x383847, - 0x2ddb07, - 0x3a5f4f, - 0x2fda11, - 0x2ddb12, - 0x30d0cd, - 0x30d0ce, - 0x30d40e, - 0x31ad88, - 0x31ad92, - 0x252288, - 0x2962c7, - 0x25260a, - 0x204748, - 0x281305, - 0x37e0ca, - 0x21da47, - 0x305304, - 0x21b083, - 0x2b0fc5, - 0x3af8c7, - 0x2fea07, - 0x29b1ce, - 0x30ff4d, - 0x313c49, - 0x220c45, - 0x33aa03, - 0x25fac6, - 0x36ffc5, - 0x2f1bc8, - 0x30c009, - 0x265145, - 0x26514f, - 0x2ec087, - 0x373485, - 0x21b2ca, - 0x299b86, - 0x2f33c9, - 0x384d0c, - 0x2f99c9, - 0x207b06, - 0x26ee8c, - 0x340cc6, - 0x2fc548, - 0x2fc746, - 0x30fbc6, - 0x349344, - 0x264443, - 0x2b270a, - 0x35b211, - 0x281d8a, - 0x255d05, - 0x277947, - 0x259307, - 0x23cdc4, - 0x23cdcb, - 0x3a8748, - 0x2bd306, - 0x36ef45, - 0x3a05c4, - 0x291949, - 0x330304, - 0x25cd87, - 0x332705, - 0x332707, - 0x358bc5, - 0x2af743, - 0x296188, - 0x34398a, - 0x239b43, - 0x325b8a, - 0x3b4086, - 0x264ecf, - 0x353689, - 0x2efb10, - 0x2dee88, - 0x2d0e89, - 0x29d087, - 0x24f68f, - 0x334604, - 0x2da984, - 0x21d386, - 0x2b3546, - 0x256dca, - 0x383586, - 0x32a787, - 0x3055c8, - 0x3057c7, - 0x306047, - 0x307a4a, - 0x309b4b, - 0x3a2445, - 0x2dd748, - 0x2166c3, - 0x3b120c, - 0x37140f, - 0x25b5cd, - 0x2c4607, - 0x313d89, - 0x217687, - 0x23e148, - 0x36eb0c, - 0x273608, - 0x258908, - 0x3188ce, - 0x32bad4, - 0x32bfe4, - 0x3424ca, - 0x35ea8b, - 0x243e44, - 0x243e49, - 0x21e9c8, - 0x24e105, - 0x25fc8a, - 0x239d87, - 0x2957c4, - 0x368883, - 0x2d0783, - 0x23a184, - 0x231b83, - 0x332ec3, - 0x2964c4, - 0x204303, - 0x20fbc3, - 0x201686, - 0x213184, - 0x204ac3, - 0x200383, - 0x21aa03, - 0x204cc2, - 0x368883, - 0x20d1c2, - 0x2d0783, - 0x23a184, - 0x231b83, - 0x332ec3, - 0x204303, - 0x201686, - 0x204ac3, - 0x200383, - 0x15f048, - 0x2d0783, - 0x231b83, - 0x2135c3, - 0x204ac3, - 0x200383, - 0x15f048, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x213184, - 0x204ac3, - 0x200383, - 0x204cc2, - 0x21fd43, - 0x20d1c2, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x20e542, - 0x20d882, - 0x20d1c2, - 0x2d0783, - 0x209c02, - 0x201d42, - 0x2964c4, - 0x222044, - 0x223342, - 0x213184, - 0x200382, - 0x200383, - 0x21aa03, - 0x241f46, - 0x217082, - 0x2016c2, - 0x201a82, - 0x436111c3, - 0x43a014c3, - 0x59a86, - 0x59a86, - 0x24ae04, - 0x143768a, - 0x2608c, - 0x21ecc, - 0x852cd, - 0x2ac47, - 0x1a608, - 0x218c8, - 0x19834a, - 0x446db445, - 0x12b089, - 0x103008, - 0x8ed4a, - 0x14a60e, - 0x144b24b, - 0x1681c4, - 0x1672c8, - 0x13edc7, - 0x16f07, - 0x11dd09, - 0x1b3c47, - 0x94b88, - 0x61f49, - 0x4bfc5, - 0x12494e, - 0xafbcd, - 0xfb48, - 0x44a37046, - 0x45437048, - 0x79c88, - 0x117050, - 0x69c87, - 0x6cf47, - 0x71187, - 0x75f87, - 0xa9c2, - 0x62507, - 0x10c74c, - 0x3b9c7, - 0xa9f46, - 0xaa689, - 0xad708, - 0x18d82, - 0x1d42, - 0x24a0b, - 0x2ccc9, - 0x4c809, - 0x17de88, - 0xb5e02, - 0x104389, - 0xd2fca, - 0xdb9c9, - 0xdd048, - 0xddfc7, - 0xe0389, - 0xe4685, - 0xe4a90, - 0x1a8e86, - 0x63c85, - 0x4a84d, - 0x1b3806, - 0xee547, - 0xf39d8, - 0x96b88, - 0xba9ca, - 0x53b4d, - 0x1702, - 0x177ac6, - 0x91788, - 0x1ae208, - 0x15ef09, - 0x56608, - 0x5dece, - 0xd68d, - 0xf8805, - 0x62288, - 0x59688, - 0x6902, - 0x125886, - 0x6c82, - 0x3c1, - 0x8b4c3, - 0x44ef4244, - 0x4529a283, - 0x141, - 0x15c06, - 0x141, - 0x1, - 0x15c06, - 0x8b4c3, - 0x14e4285, - 0x24fe44, - 0x2d0783, - 0x251304, - 0x2964c4, - 0x204ac3, - 0x222ac5, - 0x21bd03, - 0x2202c3, - 0x370145, - 0x24abc3, - 0x466d0783, - 0x231b83, - 0x332ec3, - 0x200041, - 0x20fbc3, - 0x222044, - 0x213184, - 0x204ac3, - 0x200383, - 0x213e83, - 0x15f048, - 0x204cc2, - 0x368883, - 0x20d1c2, - 0x2d0783, - 0x231b83, - 0x2135c3, - 0x201d42, - 0x2964c4, - 0x204303, - 0x20fbc3, - 0x204ac3, - 0x20abc3, - 0x200383, - 0x24abc3, - 0x15f048, - 0x371182, - 0xd1c2, - 0x1491b48, - 0x10598e, - 0x47608c42, - 0x32f9c8, - 0x233d86, - 0x210186, - 0x233707, - 0x47a00902, - 0x47f53508, - 0x20ebca, - 0x269708, - 0x201442, - 0x32f649, - 0x3a2487, - 0x218486, - 0x295ec9, - 0x247ec4, - 0x2e4186, - 0x2e1bc4, - 0x26bdc4, - 0x25bf49, - 0x326286, - 0x24df85, - 0x291285, - 0x390387, - 0x2c3747, - 0x2911c4, - 0x233946, - 0x2ffb45, - 0x367445, - 0x302505, - 0x392307, - 0x26ae05, - 0x315e49, - 0x32d305, - 0x307184, - 0x38d347, - 0x32ecce, - 0x330a09, - 0x358849, - 0x3ac9c6, - 0x2fe248, - 0x2b520b, - 0x2e3b0c, - 0x2898c6, - 0x2076c7, - 0x37b305, - 0x32d98a, - 0x237a09, - 0x3aa989, - 0x257646, - 0x2fb805, - 0x2aabc5, - 0x348f89, - 0x30268b, - 0x280f46, - 0x338346, - 0x20a904, - 0x2908c6, - 0x226a08, - 0x3abc06, - 0x20c5c6, - 0x206188, - 0x207f47, - 0x208649, - 0x209705, - 0x15f048, - 0x216e84, - 0x33d5c4, - 0x369f05, - 0x204f49, - 0x222347, - 0x22234b, - 0x223e4a, - 0x228485, - 0x4820a002, - 0x238987, - 0x48629248, - 0x27be07, - 0x2bf945, - 0x3aac0a, - 0xd1c2, - 0x38740b, - 0x25470a, - 0x222dc6, - 0x395e03, - 0x29538d, - 0x3582cc, - 0x37f24d, - 0x381085, - 0x227dc5, - 0x2601c7, - 0x209c09, - 0x20eac6, - 0x383405, - 0x2d8008, - 0x2907c3, - 0x2ec708, - 0x2907c8, - 0x2c6c47, - 0x3b2448, - 0x39b7c9, - 0x2c9747, - 0x238187, - 0x302b88, - 0x38ca44, - 0x38ca47, - 0x272648, - 0x2024c6, - 0x206fcf, - 0x2118c7, - 0x2e7a86, - 0x23e2c5, - 0x223783, - 0x365a47, - 0x36da03, - 0x250446, - 0x251c46, - 0x252a06, - 0x296e85, - 0x26ea03, - 0x388a48, - 0x370c89, - 0x37ffcb, - 0x252b88, - 0x254285, - 0x256405, - 0x48aabc02, - 0x359a49, - 0x296547, - 0x25f185, - 0x25be47, - 0x25dd86, - 0x363f05, - 0x36fe0b, - 0x2640c4, - 0x2692c5, - 0x269407, - 0x27b786, - 0x27bbc5, - 0x288487, - 0x288d47, - 0x2d1784, - 0x28e04a, - 0x28e508, - 0x2c2149, - 0x3648c5, - 0x2951c6, - 0x226bca, - 0x387646, - 0x26f5c7, - 0x2c1e0d, - 0x2a1f09, - 0x3597c5, - 0x339dc7, - 0x368388, - 0x26a888, - 0x314d07, - 0x20b246, - 0x217807, - 0x221143, - 0x33c004, - 0x3607c5, - 0x38dcc7, - 0x391d09, - 0x22a8c8, - 0x33fac5, - 0x242844, - 0x2f5bc5, - 0x38174d, - 0x203742, - 0x386ac6, - 0x377a06, - 0x2c8bca, - 0x37e686, - 0x38b5c5, - 0x368fc5, - 0x368fc7, - 0x3a010c, - 0x279b0a, - 0x290586, - 0x225085, - 0x290706, - 0x290a47, - 0x292846, - 0x296d8c, - 0x296009, - 0x48e16087, - 0x299745, - 0x299746, - 0x299d08, - 0x236785, - 0x2a8b45, - 0x2a9548, - 0x2a974a, - 0x49258142, - 0x4960c2c2, - 0x2e8f85, - 0x28b9c3, - 0x22b108, - 0x241d03, - 0x2a99c4, - 0x2f350b, - 0x34ef48, - 0x305148, - 0x49b67ec9, - 0x2af389, - 0x2afac6, - 0x2b0a88, - 0x2b0c89, - 0x2b1786, - 0x2b1905, - 0x372a86, - 0x2b1e49, - 0x319d87, - 0x25c446, - 0x233147, - 0x20e947, - 0x362e04, - 0x49f453c9, - 0x2cd008, - 0x353408, - 0x383d07, - 0x2c8686, - 0x235389, - 0x210147, - 0x34970a, - 0x330d48, - 0x349407, - 0x3b1546, - 0x2e834a, - 0x2733c8, - 0x30de45, - 0x36dac5, - 0x2f9807, - 0x371d49, - 0x3097cb, - 0x31e0c8, - 0x32d389, - 0x253487, - 0x2bad4c, - 0x2bb74c, - 0x2bba4a, - 0x2bbccc, - 0x2c5c08, - 0x2c5e08, - 0x2c6004, - 0x2c63c9, - 0x2c6609, - 0x2c684a, - 0x2c6ac9, - 0x2c6e07, - 0x3a448c, - 0x24b946, - 0x35d588, - 0x387706, - 0x330c06, - 0x3596c7, - 0x238ec8, - 0x2618cb, - 0x303207, - 0x359c49, - 0x251489, - 0x25bbc7, - 0x2e1e04, - 0x3643c7, - 0x2e1246, - 0x214046, - 0x2eb045, - 0x2c7408, - 0x2976c4, - 0x2976c6, - 0x2799cb, - 0x212cc9, - 0x209e06, - 0x20c709, - 0x392486, - 0x3aae08, - 0x214183, - 0x2fb985, - 0x215a09, - 0x224085, - 0x2f9644, - 0x27acc6, - 0x2ed005, - 0x2f7346, - 0x309ec7, - 0x328dc6, - 0x3a174b, - 0x22c447, - 0x234886, - 0x3742c6, - 0x390446, - 0x291189, - 0x240aca, - 0x2b8ec5, - 0x21898d, - 0x2a9846, - 0x2babc6, - 0x2ded86, - 0x2f31c5, - 0x2e4d87, - 0x29fa87, - 0x22bd4e, - 0x20fbc3, - 0x2c8649, - 0x263709, - 0x32dd87, - 0x2804c7, - 0x2a2ec5, - 0x343f05, - 0x4a23734f, - 0x2d10c7, - 0x2d1288, - 0x2d25c4, - 0x2d2e86, - 0x4a64db02, - 0x2d7346, - 0x201686, - 0x2638ce, - 0x2ec54a, - 0x28b6c6, - 0x22d88a, - 0x209a09, - 0x323d05, - 0x393948, - 0x3aef46, - 0x359508, - 0x2392c8, - 0x34434b, - 0x233805, - 0x26ae88, - 0x2062cc, - 0x2bf807, - 0x252546, - 0x281fc8, - 0x2253c8, - 0x4aa09282, - 0x25604b, - 0x37b489, - 0x2cf2c9, - 0x2f02c7, - 0x3b3648, - 0x4ae289c8, - 0x20e64b, - 0x37dd09, - 0x33f58d, - 0x27d648, - 0x290188, - 0x4b201882, - 0x3b2f44, - 0x4b60dc42, - 0x2f9486, - 0x4ba038c2, - 0x2448ca, - 0x210546, - 0x22d208, - 0x289e88, - 0x2e4086, - 0x2eb5c6, - 0x2f7106, - 0x2f1b45, - 0x23c804, - 0x4be1de04, - 0x20ae86, - 0x29a787, - 0x4c2f7d07, - 0x2dc60b, - 0x32f089, - 0x227e0a, - 0x263144, - 0x369108, - 0x25c20d, - 0x2f1509, - 0x2f1748, - 0x2f2009, - 0x2f39c4, - 0x20ce44, - 0x283cc5, - 0x317b0b, - 0x34eec6, - 0x33c645, - 0x21fb89, - 0x233a08, - 0x263844, - 0x32db09, - 0x208f45, - 0x2c3788, - 0x238847, - 0x358c48, - 0x284e86, - 0x22b987, - 0x2984c9, - 0x311a89, - 0x372545, - 0x295645, - 0x4c626a82, - 0x306f44, - 0x30ce05, - 0x2c1846, - 0x327285, - 0x2b4707, - 0x20af85, - 0x27b7c4, - 0x3aca86, - 0x383487, - 0x232106, - 0x21e105, - 0x202608, - 0x233f85, - 0x205d07, - 0x20bc49, - 0x212e0a, - 0x2494c7, - 0x2494cc, - 0x24df46, - 0x2e9ac9, - 0x230505, - 0x2366c8, - 0x210c03, - 0x210c05, - 0x2f7b45, - 0x26e707, - 0x4ca27202, - 0x227a07, - 0x2e5206, - 0x345306, - 0x2e62c6, - 0x225306, - 0x2091c8, - 0x35b805, - 0x2e7b47, - 0x2e7b4d, - 0x21b083, - 0x21f305, - 0x21b087, - 0x26b308, - 0x21ac45, - 0x2281c8, - 0x2ab9c6, - 0x32b247, - 0x2c7bc5, - 0x233886, - 0x2cfac5, - 0x22dfca, - 0x2efec6, - 0x25dbc7, - 0x2bc605, - 0x2f44c7, - 0x2f8904, - 0x2f95c6, - 0x3624c5, - 0x32608b, - 0x2e10c9, - 0x23d74a, - 0x3725c8, - 0x3007c8, - 0x300f0c, - 0x306b47, - 0x308c48, - 0x30aa88, - 0x30dac5, - 0x338b4a, - 0x33aa09, - 0x4ce00202, - 0x200206, - 0x20d684, - 0x2ef889, - 0x275d49, - 0x27b1c7, - 0x2fa547, - 0x2b7c09, - 0x331308, - 0x33130f, - 0x2dfa86, - 0x2db10b, - 0x361545, - 0x361547, - 0x374c89, - 0x2171c6, - 0x32da87, - 0x2dde85, - 0x22f544, - 0x26e186, - 0x211984, - 0x2e6c47, - 0x34c5c8, - 0x4d2fb708, - 0x2fbe85, - 0x2fbfc7, - 0x245709, - 0x208444, - 0x208448, - 0x4d7190c8, - 0x23cdc4, - 0x230c88, - 0x3396c4, - 0x220389, - 0x333105, - 0x4da05bc2, - 0x2dfac5, - 0x2e6845, - 0x271b88, - 0x232847, - 0x4de03382, - 0x30cbc5, - 0x2d4e86, - 0x27a786, - 0x306f08, - 0x318308, - 0x327246, - 0x32e246, - 0x249009, - 0x345246, - 0x21708b, - 0x2a12c5, - 0x204686, - 0x382588, - 0x3152c6, - 0x298e46, - 0x21b94a, - 0x22f9ca, - 0x2e8245, - 0x35b8c7, - 0x2f0cc6, - 0x4e206602, - 0x21b1c7, - 0x2a9085, - 0x226b44, - 0x226b45, - 0x263046, - 0x27a447, - 0x20d405, - 0x22fb44, - 0x365008, - 0x298f05, - 0x33c8c7, - 0x39fa85, - 0x22df05, - 0x256b44, - 0x28fbc9, - 0x2ff988, - 0x2ecec6, - 0x2de9c6, - 0x2b9d46, - 0x4e700448, - 0x300647, - 0x3009cd, - 0x30120c, - 0x301809, - 0x301a49, - 0x4eb546c2, - 0x3a5503, - 0x20b303, - 0x2e1305, - 0x38ddca, - 0x327106, - 0x307905, - 0x30a084, - 0x30a08b, - 0x31bdcc, - 0x31c5cc, - 0x31c8d5, - 0x31d74d, - 0x31f44f, - 0x31f812, - 0x31fc8f, - 0x320052, - 0x3204d3, - 0x32098d, - 0x320f4d, - 0x3212ce, - 0x322a8e, - 0x3232cc, - 0x32368c, - 0x323acb, - 0x323e4e, - 0x324f92, - 0x326ecc, - 0x327610, - 0x3335d2, - 0x3347cc, - 0x334e8d, - 0x3351cc, - 0x337611, - 0x3384cd, - 0x33ac4d, - 0x33b24a, - 0x33b4cc, - 0x33bdcc, - 0x33c34c, - 0x33cbcc, - 0x33fc53, - 0x340450, - 0x340850, - 0x340e4d, - 0x34144c, - 0x342209, - 0x342f0d, - 0x343253, - 0x344911, - 0x344d53, - 0x34560f, - 0x3459cc, - 0x345ccf, - 0x34608d, - 0x34668f, - 0x346a50, - 0x3474ce, - 0x34ac8e, - 0x34b590, - 0x34ca8d, - 0x34d40e, - 0x34d78c, - 0x34e753, - 0x351e0e, - 0x352390, - 0x352791, - 0x352bcf, - 0x352f93, - 0x35424d, - 0x35458f, - 0x35494e, - 0x354fd0, - 0x3553c9, - 0x356390, - 0x356acf, - 0x35714f, - 0x357512, - 0x359e8e, - 0x35a74d, - 0x35cc4d, - 0x35cf8d, - 0x35f68d, - 0x35f9cd, - 0x35fd10, - 0x36010b, - 0x36058c, - 0x36090c, - 0x360c0c, - 0x360f0e, - 0x372c10, - 0x374452, - 0x3748cb, - 0x374ece, - 0x37524e, - 0x375ace, - 0x37604b, - 0x4ef76396, - 0x37724d, - 0x378354, - 0x378e0d, - 0x37ae55, - 0x37c04d, - 0x37c9cf, - 0x37d20f, - 0x38028f, - 0x38064e, - 0x380acd, - 0x382f11, - 0x385ecc, - 0x3861cc, - 0x3864cb, - 0x386c4c, - 0x38824f, - 0x388612, - 0x388fcd, - 0x389f8c, - 0x38a40c, - 0x38a70d, - 0x38aa4f, - 0x38ae0e, - 0x38da8c, - 0x38e04d, - 0x38e38b, - 0x38ee8c, - 0x38f40d, - 0x38f74e, - 0x38fac9, - 0x390c53, - 0x39118d, - 0x3914cd, - 0x391acc, - 0x391f4e, - 0x39290f, - 0x392ccc, - 0x392fcd, - 0x39330f, - 0x3936cc, - 0x3943cc, - 0x39484c, - 0x394b4c, - 0x39520d, - 0x395552, - 0x396c0c, - 0x396f0c, - 0x397211, - 0x39764f, - 0x397a0f, - 0x397dd3, - 0x398a8e, - 0x398e0f, - 0x3991cc, - 0x4f39950e, - 0x39988f, - 0x399c56, - 0x39b312, - 0x39d64c, - 0x39e14f, - 0x39e7cd, - 0x39eb0f, - 0x39eecc, - 0x39f1cd, - 0x39f50d, - 0x3a0c4e, - 0x3a2b8c, - 0x3a2e8c, - 0x3a3190, - 0x3a4991, - 0x3a4dcb, - 0x3a510c, - 0x3a540e, - 0x3a7051, - 0x3a748e, - 0x3a780d, - 0x3aed0b, - 0x3afdcf, - 0x3b09d4, - 0x2630c2, - 0x2630c2, - 0x202583, - 0x2630c2, - 0x202583, - 0x2630c2, - 0x20ae82, - 0x372ac5, - 0x3a6d4c, - 0x2630c2, - 0x2630c2, - 0x20ae82, - 0x2630c2, - 0x29a385, - 0x212e05, - 0x2630c2, - 0x2630c2, - 0x211cc2, - 0x29a385, - 0x31e789, - 0x34460c, - 0x2630c2, - 0x2630c2, - 0x2630c2, - 0x2630c2, - 0x372ac5, - 0x2630c2, - 0x2630c2, - 0x2630c2, - 0x2630c2, - 0x211cc2, - 0x31e789, - 0x2630c2, - 0x2630c2, - 0x2630c2, - 0x212e05, - 0x2630c2, - 0x212e05, - 0x34460c, - 0x3a6d4c, - 0x368883, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x2964c4, - 0x204ac3, - 0x200383, - 0x1f08, - 0x15444, - 0xc1348, - 0x204cc2, - 0x5020d1c2, - 0x243403, - 0x24c944, - 0x202743, - 0x38e8c4, - 0x22e886, - 0x213843, - 0x31aa84, - 0x288845, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x25084a, - 0x241f46, - 0x3755cc, - 0x15f048, - 0x20d1c2, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x22d603, - 0x201686, - 0x204ac3, - 0x200383, - 0x21aa03, - 0xaa288, - 0x3942, - 0x513856c5, - 0x2ac47, - 0xd7a88, - 0xc0ce, - 0x8c792, - 0x16780b, - 0x516db445, - 0x51adb44c, - 0xf207, - 0x13ecc7, - 0x1698ca, - 0x3efd0, - 0x1acd05, - 0x16e1cb, - 0x1672c8, - 0x13edc7, - 0x2f64b, - 0x11dd09, - 0x150f47, - 0x1b3c47, - 0x81187, - 0x20586, - 0x94b88, - 0x52028b86, - 0xafbcd, - 0x169290, - 0x52401742, - 0xfb48, - 0x71f47, - 0x7f149, - 0x59b46, - 0x99f08, - 0x74842, - 0xa4f4a, - 0x2d587, - 0x3b9c7, - 0xaa689, - 0xad708, - 0x15ae05, - 0x194e8e, - 0x14d4e, - 0x26f4f, - 0x2ccc9, - 0x4c809, - 0x77e8b, - 0x878cf, - 0x8fdcc, - 0xadd8b, - 0xc4d08, - 0xdc507, - 0x162908, - 0xfe04b, - 0x12a54c, - 0x141acc, - 0x147f4c, - 0x14b0cd, - 0x17de88, - 0x42602, - 0x104389, - 0x18528b, - 0xc8886, - 0x116f8b, - 0xdd5ca, - 0xde185, - 0xe4a90, - 0x1294c6, - 0x63c85, - 0xe6448, - 0xee547, - 0xee807, - 0x5e987, - 0xf92ca, - 0xd790a, - 0x177ac6, - 0x97ccd, - 0x1ae208, - 0x56608, - 0x56a89, - 0xb9905, - 0x19de4c, - 0x14b2cb, - 0x171c84, - 0xff749, - 0x8146, - 0x16c2, - 0x125886, - 0x10d947, - 0x6c82, - 0xcb605, - 0x29b04, - 0x701, - 0x2bc43, - 0x51fadbc6, - 0x9a283, - 0x8a42, - 0x2d584, - 0x1442, - 0x4ae04, - 0x1342, - 0x2f82, - 0x3682, - 0x1124c2, - 0xe542, - 0xdb442, - 0x2ac2, - 0x1c402, - 0x26982, - 0x4d02, - 0x3b02, - 0x34682, - 0x31b83, - 0x7d02, - 0x1c2, - 0x41c2, - 0xda42, - 0x642, - 0xdc2, - 0x18d82, - 0x1a02, - 0x2282, - 0x1d42, - 0x4303, - 0xb02, - 0x2f02, - 0xb5e02, - 0x1b02, - 0x5d82, - 0x32c2, - 0x73c2, - 0x17c2, - 0x1f02, - 0x173102, - 0x73fc2, - 0x5e402, - 0x4ac3, - 0x2c2, - 0x9282, - 0x1002, - 0x14602, - 0x1724c5, - 0x6ec2, - 0x1202, - 0x41703, - 0x682, - 0xd42, - 0x1702, - 0xe5c2, - 0x1ac2, - 0x3382, - 0x6902, - 0x16c2, - 0x73c07, - 0x213dc3, - 0x204cc2, - 0x2d0783, - 0x231b83, - 0x2135c3, - 0x201d43, - 0x22d603, - 0x204ac3, - 0x20abc3, - 0x200383, - 0x29a2c3, - 0x1a5c3, - 0x15f048, - 0x2d0783, - 0x231b83, - 0x2135c3, - 0x20fbc3, - 0x204ac3, - 0x20abc3, - 0x200383, - 0x2d0783, - 0x231b83, - 0x200383, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x200041, - 0x20fbc3, - 0x204ac3, - 0x2104c3, - 0x200383, - 0x368883, - 0x2d0783, - 0x231b83, - 0x20fb43, - 0x2135c3, - 0x2300c3, - 0x287703, - 0x210503, - 0x234743, - 0x332ec3, - 0x2964c4, - 0x204ac3, - 0x200383, - 0x24abc3, - 0x200604, - 0x250c83, - 0x5283, - 0x3abd03, - 0x329b88, - 0x2e8384, - 0x2c264a, - 0x224906, - 0x10f9c4, - 0x38c2c7, - 0x21eeca, - 0x2df949, - 0x3a3b07, - 0x3a7dca, - 0x368883, - 0x2e900b, - 0x303349, - 0x2b9e45, - 0x2d7187, - 0xd1c2, - 0x2d0783, - 0x204d07, - 0x248d45, - 0x2e1cc9, - 0x231b83, - 0x233606, - 0x2c56c3, - 0xe1183, - 0x109686, - 0x60546, - 0x137c7, - 0x217546, - 0x222645, - 0x2cf187, - 0x2da587, - 0x54b32ec3, - 0x334a07, - 0x3642c3, - 0x3a2385, - 0x2964c4, - 0x32e3c8, - 0x2751cc, - 0x3a5745, - 0x2a2086, - 0x204bc7, - 0x37ef47, - 0x25b8c7, - 0x31f248, - 0x307ecf, - 0x2dfb85, - 0x243507, - 0x2394c7, - 0x2a9b0a, - 0x2d7e49, - 0x30bc85, - 0x32194a, - 0x1b06, - 0x2c5745, - 0x376284, - 0x289dc6, - 0x2f8cc7, - 0x242507, - 0x38cbc8, - 0x214185, - 0x248c46, - 0x20c545, - 0x387845, - 0x212c04, - 0x2e3f87, - 0x20900a, - 0x234d48, - 0x356946, - 0x2d603, - 0x2e0405, - 0x26c686, - 0x3a46c6, - 0x263b86, - 0x20fbc3, - 0x389247, - 0x239445, - 0x204ac3, - 0x2dd88d, - 0x20abc3, - 0x38ccc8, - 0x39a5c4, - 0x27ba85, - 0x2a9a06, - 0x2362c6, - 0x204587, - 0x2ae707, - 0x270b05, - 0x200383, - 0x27f2c7, - 0x329709, - 0x22b689, - 0x2f590a, - 0x24cd82, - 0x3a2344, - 0x2e76c4, - 0x261787, - 0x2278c8, - 0x2ef309, - 0x21f1c9, - 0x2f0487, - 0x303806, - 0xf22c6, - 0x2f39c4, - 0x2f3fca, - 0x2f6a08, - 0x2f6fc9, - 0x2bfe86, - 0x2b6ec5, - 0x234c08, - 0x2c9c4a, - 0x22c6c3, - 0x200786, - 0x2f0587, - 0x217f85, - 0x39a485, - 0x2717c3, - 0x258a04, - 0x36da85, - 0x288e47, - 0x2ffac5, - 0x2ed686, - 0xfff05, - 0x264a03, - 0x28b789, - 0x27b84c, - 0x2a7e0c, - 0x2d3bc8, - 0x3ade87, - 0x2fc8c8, - 0x2fcc0a, - 0x2fd84b, - 0x303488, - 0x33f408, - 0x2363c6, - 0x262685, - 0x200f4a, - 0x219545, - 0x205bc2, - 0x2c7a87, - 0x2a32c6, - 0x355ec5, - 0x38e989, - 0x26b785, - 0x285ec5, - 0x3a1f49, - 0x257cc6, - 0x3b1088, - 0x23e0c3, - 0x3b3306, - 0x27ac06, - 0x30ba85, - 0x30ba89, - 0x2bc289, - 0x24d0c7, - 0x10b904, - 0x30b907, - 0x21f0c9, - 0x23c905, - 0x4bbc8, - 0x3b3205, - 0x339505, - 0x376c89, - 0x205ac2, - 0x2e95c4, - 0x20d782, - 0x200b02, - 0x2ce985, - 0x30f748, - 0x2b9845, - 0x2c6fc3, - 0x2c6fc5, - 0x2d7543, - 0x210882, - 0x2e30c4, - 0x351903, - 0x204c82, - 0x35bb44, - 0x2e85c3, - 0x200e82, - 0x25e903, - 0x291704, - 0x2e7083, - 0x246f04, - 0x202602, - 0x21a903, - 0x215b43, - 0x206342, - 0x33c282, - 0x2bc0c9, - 0x202d82, - 0x28d304, - 0x201782, - 0x234a84, - 0x3037c4, - 0x2bcc44, - 0x2016c2, - 0x241a02, - 0x220883, - 0x225f83, - 0x387944, - 0x269e44, - 0x2bc484, - 0x2ce884, - 0x30b143, - 0x34f743, - 0x201a84, - 0x30d784, - 0x30e786, - 0x2e7782, - 0x20d1c2, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x204cc2, - 0x368883, - 0x2d0783, - 0x231b83, - 0x2001c3, - 0x332ec3, - 0x2964c4, - 0x2bc384, - 0x213184, - 0x204ac3, - 0x200383, - 0x21aa03, - 0x2f4684, - 0x32f983, - 0x2bf3c3, - 0x345184, - 0x3b3006, - 0x211503, - 0x13ecc7, - 0x234fc3, - 0x23a943, - 0x2b6703, - 0x265383, - 0x22d603, - 0x2db6c5, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x2ed143, - 0x2ab343, - 0x15f048, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204303, - 0x204ac3, - 0x23ee04, - 0x200383, - 0x26a104, - 0x2c2d45, - 0x13ecc7, - 0x20d1c2, - 0x2000c2, - 0x208a42, - 0x202082, - 0x200382, - 0x2d0783, - 0x23a184, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x15f048, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x213184, - 0x204ac3, - 0x200383, - 0x213e83, - 0x24ae04, - 0x15f048, - 0x2d0783, - 0x20abc3, - 0x1a5c3, - 0x24fe44, - 0x15f048, - 0x2d0783, - 0x251304, - 0x2964c4, - 0x20abc3, - 0x201882, - 0x200383, - 0x2202c3, - 0x58a04, - 0x370145, - 0x205bc2, - 0x30d8c3, - 0x204cc2, - 0x15f048, - 0x20d1c2, - 0x231b83, - 0x332ec3, - 0x201d42, - 0x200383, - 0x204cc2, - 0x15f048, - 0x231b83, - 0x332ec3, - 0x204303, - 0x20fbc3, - 0x30b544, - 0x204cc2, - 0x20d1c2, - 0x2d0783, - 0x231b83, - 0x2da904, - 0x332ec3, - 0x204303, - 0x20fbc3, - 0x204ac3, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x22d603, - 0x204ac3, - 0x200383, - 0x26a103, - 0x213e83, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x1a5c3, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x2964c4, - 0x22d603, - 0x204ac3, - 0x200383, - 0x217082, - 0x200141, - 0x204cc2, - 0x200001, - 0x31f542, - 0x15f048, - 0x21d105, - 0x200701, - 0xd0783, - 0x200101, - 0x2000c1, - 0x201e41, - 0x29da82, - 0x36da04, - 0x372a43, - 0x200181, - 0x200941, - 0x200041, - 0x200081, - 0x2ed7c7, - 0x2eeccf, - 0x2fc146, - 0x201481, - 0x289786, - 0x200c01, - 0x2002c1, - 0x33168e, - 0x200381, - 0x200383, - 0x200e81, - 0x279e45, - 0x210582, - 0x2716c5, - 0x2003c1, - 0x200201, - 0x200241, - 0x205bc2, - 0x200a01, - 0x201a81, - 0x2005c1, - 0x2007c1, - 0x200cc1, - 0x15f048, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x21bd03, - 0x2d0783, - 0x332ec3, - 0x91d48, - 0x20fbc3, - 0x204ac3, - 0x48803, - 0x200383, - 0x14ebc48, - 0x15f048, - 0x4dcc4, - 0x15f048, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x204ac3, - 0x200383, - 0x205283, - 0x15f048, - 0x2d0783, - 0x231b83, - 0x2da904, - 0x200383, - 0x293ac5, - 0x343984, - 0x2d0783, - 0x204ac3, - 0x200383, - 0x16b18a, - 0x20d1c2, - 0x2d0783, - 0x22f489, - 0x231b83, - 0x2d2389, - 0x332ec3, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x2f37c8, - 0x226647, - 0x370145, - 0x3a7f87, - 0x26b0cb, - 0x215cc8, - 0x32eac9, - 0x228087, - 0x200108, - 0x36f906, - 0x2344c7, - 0x29c108, - 0x2ab806, - 0x31d407, - 0x2aa449, - 0x2ba749, - 0x2c2ac6, - 0x2c38c5, - 0x2cce08, - 0x2b4783, - 0x2d7c88, - 0x231d87, - 0x206583, - 0x31d287, - 0x217905, - 0x2eeb08, - 0x359105, - 0x2cea43, - 0x23c289, - 0x2b0e87, - 0x35d504, - 0x2ff244, - 0x307ccb, - 0x308288, - 0x309587, - 0x2d0783, - 0x231b83, - 0x2135c3, - 0x200383, - 0x236ec3, - 0x332ec3, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x77fcb, - 0x204cc2, - 0x20d1c2, - 0x200383, - 0x15f048, - 0x204cc2, - 0x20d1c2, - 0x208a42, - 0x201d42, - 0x203cc2, - 0x204ac3, - 0x200382, - 0x204cc2, - 0x368883, - 0x20d1c2, - 0x2d0783, - 0x231b83, - 0x208a42, - 0x332ec3, - 0x204303, - 0x20fbc3, - 0x213184, - 0x204ac3, - 0x2183c3, - 0x200383, - 0x30b544, - 0x24abc3, - 0x332ec3, - 0x20d1c2, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x204ac3, - 0x20abc3, - 0x200383, - 0x39db07, - 0x2d0783, - 0x26e5c7, - 0x362a86, - 0x215ac3, - 0x2041c3, - 0x332ec3, - 0x209e43, - 0x2964c4, - 0x38b704, - 0x30dbc6, - 0x201303, - 0x204ac3, - 0x200383, - 0x293ac5, - 0x318244, - 0x369dc3, - 0x37ed83, - 0x2c7a87, - 0x2387c5, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x203782, - 0x3ae343, - 0x2c2d43, - 0x368883, - 0x5fed0783, - 0x209c02, - 0x231b83, - 0x202743, - 0x332ec3, - 0x2964c4, - 0x23a0c3, - 0x2dfb83, - 0x20fbc3, - 0x213184, - 0x6020c002, - 0x204ac3, - 0x200383, - 0x209103, - 0x229b03, - 0x217082, - 0x24abc3, - 0x15f048, - 0x332ec3, - 0x1a5c3, - 0x2957c4, - 0x368883, - 0x20d1c2, - 0x2d0783, - 0x23a184, - 0x231b83, - 0x332ec3, - 0x2964c4, - 0x204303, - 0x2cee84, - 0x222044, - 0x201686, - 0x213184, - 0x204ac3, - 0x200383, - 0x21aa03, - 0x2a32c6, - 0x3ddcb, - 0x28b86, - 0x4aa0a, - 0x10adca, - 0x15f048, - 0x20c504, - 0x2d0783, - 0x368844, - 0x231b83, - 0x256bc4, - 0x332ec3, - 0x262fc3, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x32e84b, - 0x39f84a, - 0x3b478c, - 0x204cc2, - 0x20d1c2, - 0x208a42, - 0x2b0405, - 0x2964c4, - 0x201f02, - 0x20fbc3, - 0x222044, - 0x202082, - 0x200382, - 0x20c4c2, - 0x217082, - 0x168883, - 0xd882, - 0x2b2409, - 0x259f88, - 0x332d49, - 0x234309, - 0x23b18a, - 0x24550a, - 0x20a182, - 0x21c402, - 0xd1c2, - 0x2d0783, - 0x220802, - 0x2436c6, - 0x356fc2, - 0x20a542, - 0x21ad8e, - 0x21a94e, - 0x281a47, - 0x204a47, - 0x221202, - 0x231b83, - 0x332ec3, - 0x20b502, - 0x201d42, - 0x4143, - 0x24058f, - 0x26b142, - 0x362cc7, - 0x2fa1c7, - 0x39d487, - 0x31e28c, - 0x364d0c, - 0x202444, - 0x283b0a, - 0x21a882, - 0x201b02, - 0x2bc744, - 0x22b1c2, - 0x2c5c02, - 0x364f44, - 0x2184c2, - 0x205d82, - 0x5d83, - 0x2ab887, - 0x33d885, - 0x2073c2, - 0x240504, - 0x373102, - 0x2df088, - 0x204ac3, - 0x203808, - 0x203ac2, - 0x232d85, - 0x203ac6, - 0x200383, - 0x206ec2, - 0x2ef547, - 0x10582, - 0x350845, - 0x31d185, - 0x207c82, - 0x236b82, - 0x3a860a, - 0x27098a, - 0x212bc2, - 0x353f84, - 0x2018c2, - 0x3a2208, - 0x219682, - 0x2a2588, - 0x304987, - 0x304c89, - 0x2037c2, - 0x309e45, - 0x247e85, - 0x21424b, - 0x2ca84c, - 0x22c208, - 0x3186c8, - 0x2e7782, - 0x204642, - 0x204cc2, - 0x15f048, - 0x20d1c2, - 0x2d0783, - 0x208a42, - 0x202082, - 0x200382, - 0x200383, - 0x20c4c2, - 0x204cc2, - 0x6260d1c2, - 0x62b32ec3, - 0x205d83, - 0x201f02, - 0x204ac3, - 0x3a8fc3, - 0x200383, - 0x2ec383, - 0x273d06, - 0x1613e83, - 0x15f048, - 0x63c85, - 0xae2cd, - 0xaafca, - 0x6ebc7, - 0x63201b82, - 0x63601442, - 0x63a00f82, - 0x63e02e02, - 0x642125c2, - 0x6460e542, - 0x13ecc7, - 0x64a0d1c2, - 0x64e0e482, - 0x6520fe42, - 0x65603b02, - 0x21a943, - 0x102c4, - 0x220a43, - 0x65a14002, - 0x65e023c2, - 0x51847, - 0x66214502, - 0x66600b82, - 0x66a00542, - 0x66e0a3c2, - 0x67202282, - 0x67601d42, - 0xbe445, - 0x221443, - 0x3b3bc4, - 0x67a2b1c2, - 0x67e42682, - 0x68202682, - 0x7e5cb, - 0x68600c02, - 0x68e513c2, - 0x69201f02, - 0x69603cc2, - 0x69a0bcc2, - 0x69e05f02, - 0x6a20b602, - 0x6a673fc2, - 0x6aa0c002, - 0x6ae04a02, - 0x6b202082, - 0x6b603702, - 0x6ba12982, - 0x6be31302, - 0x94fc4, - 0x358183, - 0x6c2126c2, - 0x6c61a582, - 0x6ca098c2, - 0x6ce00982, - 0x6d200382, - 0x6d604c82, - 0x78147, - 0x6da054c2, - 0x6de05502, - 0x6e20c4c2, - 0x6e609f42, - 0x19de4c, - 0x6ea22e82, - 0x6ee79242, - 0x6f200a02, - 0x6f606602, - 0x6fa019c2, - 0x6fe3b302, - 0x70206d02, - 0x70613882, - 0x70a7af82, - 0x70e43e02, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x75c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x68a3a0c3, - 0x2075c3, - 0x2db744, - 0x259e86, - 0x2f74c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x20d882, - 0x20d882, - 0x23a0c3, - 0x2075c3, - 0x716d0783, - 0x231b83, - 0x329e83, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x15f048, - 0x20d1c2, - 0x2d0783, - 0x204ac3, - 0x200383, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x24fe44, - 0x20d1c2, - 0x2d0783, - 0x3303c3, - 0x231b83, - 0x251304, - 0x2135c3, - 0x332ec3, - 0x2964c4, - 0x204303, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x2202c3, - 0x370145, - 0x2b2703, - 0x24abc3, - 0x20d1c2, - 0x2d0783, - 0x23a0c3, - 0x204ac3, - 0x200383, - 0x204cc2, - 0x368883, - 0x15f048, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x22e886, - 0x2964c4, - 0x204303, - 0x213184, - 0x204ac3, - 0x200383, - 0x21aa03, - 0x2d0783, - 0x231b83, - 0x204ac3, - 0x200383, - 0x2d0783, - 0x28b86, - 0x231b83, - 0x332ec3, - 0xe1946, - 0x204ac3, - 0x200383, - 0x315cc8, - 0x318509, - 0x327a09, - 0x332548, - 0x37d888, - 0x37d889, - 0x9da85, - 0x204cc2, - 0x238605, - 0x205d43, - 0x7420d1c2, - 0x231b83, - 0x332ec3, - 0x33e387, - 0x265383, - 0x20fbc3, - 0x204ac3, - 0x2104c3, - 0x212483, - 0x20abc3, - 0x200383, - 0x241f46, - 0x205bc2, - 0x24abc3, - 0x15f048, - 0x204cc2, - 0x368883, - 0x20d1c2, - 0x2d0783, - 0x231b83, - 0x332ec3, - 0x2964c4, - 0x20fbc3, - 0x204ac3, - 0x200383, - 0x213e83, - 0x153ca46, -} - -// children is the list of nodes' children, the parent's wildcard bit and the -// parent's node type. If a node has no children then their children index -// will be in the range [0, 6), depending on the wildcard bit and node type. -// -// The layout within the uint32, from MSB to LSB, is: -// [ 1 bits] unused -// [ 1 bits] wildcard bit -// [ 2 bits] node type -// [14 bits] high nodes index (exclusive) of children -// [14 bits] low nodes index (inclusive) of children -var children = [...]uint32{ - 0x0, - 0x10000000, - 0x20000000, - 0x40000000, - 0x50000000, - 0x60000000, - 0x1860612, - 0x1864618, - 0x1884619, - 0x19e0621, - 0x19f4678, - 0x1a0867d, - 0x1a18682, - 0x1a34686, - 0x1a3868d, - 0x1a5068e, - 0x1a74694, - 0x1a7869d, - 0x1a9069e, - 0x1a946a4, - 0x1a986a5, - 0x1ac06a6, - 0x1ac46b0, - 0x21acc6b1, - 0x1b146b3, - 0x1b186c5, - 0x1b386c6, - 0x1b4c6ce, - 0x1b506d3, - 0x1b806d4, - 0x1b9c6e0, - 0x1bc46e7, - 0x1bd06f1, - 0x1bd46f4, - 0x1c686f5, - 0x1c7c71a, - 0x1c9071f, - 0x1cc0724, - 0x1cd0730, - 0x1ce4734, - 0x1d08739, - 0x1e20742, - 0x1e24788, - 0x1e90789, - 0x1ea47a4, - 0x1eb87a9, - 0x1ec07ae, - 0x1ed07b0, - 0x1ed47b4, - 0x1eec7b5, - 0x1f347bb, - 0x1f4c7cd, - 0x1f507d3, - 0x1f547d4, - 0x1f5c7d5, - 0x1f987d7, - 0x61f9c7e6, - 0x1fb07e7, - 0x1fbc7ec, - 0x1fc07ef, - 0x1fd07f0, - 0x20807f4, - 0x2084820, - 0x22090821, - 0x22098824, - 0x20cc826, - 0x20d0833, - 0x2514834, - 0x225ac945, - 0x225b096b, - 0x225b496c, - 0x225c096d, - 0x225c4970, - 0x225d0971, - 0x225d4974, - 0x225d8975, - 0x225dc976, - 0x225e0977, - 0x225e4978, - 0x225f0979, - 0x225f497c, - 0x2260097d, - 0x22604980, - 0x22608981, - 0x2260c982, - 0x22610983, - 0x22614984, - 0x2618985, - 0x2261c986, - 0x22628987, - 0x2262c98a, - 0x263498b, - 0x2264498d, - 0x22648991, - 0x2654992, - 0x22658995, - 0x265c996, - 0x22660997, - 0x267c998, - 0x269499f, - 0x26989a5, - 0x26a89a6, - 0x26b09aa, - 0x26e49ac, - 0x26e89b9, - 0x26f89ba, - 0x27909be, - 0x227949e4, - 0x279c9e5, - 0x27a09e7, - 0x27b89e8, - 0x27cc9ee, - 0x27f49f3, - 0x28149fd, - 0x2844a05, - 0x286ca11, - 0x2870a1b, - 0x2894a1c, - 0x2898a25, - 0x28aca26, - 0x28b0a2b, - 0x28b4a2c, - 0x28d4a2d, - 0x28eca35, - 0x28f0a3b, - 0x228f4a3c, - 0x28f8a3d, - 0x2908a3e, - 0x290ca42, - 0x2984a43, - 0x29a0a61, - 0x29aca68, - 0x29c0a6b, - 0x29d8a70, - 0x29eca76, - 0x2a04a7b, - 0x2a1ca81, - 0x2a34a87, - 0x2a50a8d, - 0x2a68a94, - 0x2ac8a9a, - 0x2ae0ab2, - 0x2ae4ab8, - 0x2af8ab9, - 0x2b3cabe, - 0x2bbcacf, - 0x2be8aef, - 0x2becafa, - 0x2bf4afb, - 0x2c14afd, - 0x2c18b05, - 0x2c38b06, - 0x2c40b0e, - 0x2c78b10, - 0x2cb8b1e, - 0x2cbcb2e, - 0x2d0cb2f, - 0x2d10b43, - 0x22d14b44, - 0x2d2cb45, - 0x2d50b4b, - 0x2d70b54, - 0x3334b5c, - 0x3340ccd, - 0x3360cd0, - 0x351ccd8, - 0x35ecd47, - 0x365cd7b, - 0x36b4d97, - 0x379cdad, - 0x37f4de7, - 0x3830dfd, - 0x392ce0c, - 0x39f8e4b, - 0x3a90e7e, - 0x3b20ea4, - 0x3b84ec8, - 0x3dbcee1, - 0x3e74f6f, - 0x3f40f9d, - 0x3f8cfd0, - 0x4014fe3, - 0x4051005, - 0x40a1014, - 0x4119028, - 0x6411d046, - 0x64121047, - 0x64125048, - 0x41a1049, - 0x41fd068, - 0x427907f, - 0x42f109e, - 0x43710bc, - 0x43dd0dc, - 0x45090f7, - 0x4561142, - 0x64565158, - 0x45fd159, - 0x468517f, - 0x46d11a1, - 0x47391b4, - 0x47e11ce, - 0x48a91f8, - 0x491122a, - 0x4a25244, - 0x64a29289, - 0x64a2d28a, - 0x4a8928b, - 0x4ae52a2, - 0x4b752b9, - 0x4bf12dd, - 0x4c352fc, - 0x4d1930d, - 0x4d4d346, - 0x4dad353, - 0x4e2136b, - 0x4ea9388, - 0x4ee93aa, - 0x4f593ba, - 0x64f5d3d6, - 0x64f613d7, - 0x24f653d8, - 0x4f7d3d9, - 0x4f993df, - 0x4fdd3e6, - 0x4fed3f7, - 0x50053fb, - 0x507d401, - 0x508541f, - 0x5099421, - 0x50b1426, - 0x50d942c, - 0x50dd436, - 0x50e5437, - 0x50f9439, - 0x511543e, - 0x5119445, - 0x5121446, - 0x515d448, - 0x5171457, - 0x517945c, - 0x518145e, - 0x5185460, - 0x51a9461, - 0x51cd46a, - 0x51e5473, - 0x51e9479, - 0x51f147a, - 0x51f547c, - 0x524d47d, - 0x5271493, - 0x529149c, - 0x52ad4a4, - 0x52bd4ab, - 0x52d14af, - 0x52d54b4, - 0x52dd4b5, - 0x52f14b7, - 0x53014bc, - 0x53054c0, - 0x53214c1, - 0x5bb14c8, - 0x5be96ec, - 0x5c156fa, - 0x5c2d705, - 0x5c4d70b, - 0x5c6d713, - 0x5cb171b, - 0x5cb972c, - 0x25cbd72e, - 0x25cc172f, - 0x5cc5730, - 0x5e01731, - 0x25e05780, - 0x25e11781, - 0x25e19784, - 0x25e25786, - 0x5e29789, - 0x5e2d78a, - 0x5e5578b, - 0x5e7d795, - 0x5e8179f, - 0x5eb97a0, - 0x5ecd7ae, - 0x6a257b3, - 0x6a29a89, - 0x6a2da8a, - 0x26a31a8b, - 0x6a35a8c, - 0x26a39a8d, - 0x6a3da8e, - 0x26a49a8f, - 0x6a4da92, - 0x6a51a93, - 0x26a55a94, - 0x6a59a95, - 0x26a61a96, - 0x6a65a98, - 0x6a69a99, - 0x26a79a9a, - 0x6a7da9e, - 0x6a81a9f, - 0x6a85aa0, - 0x6a89aa1, - 0x26a8daa2, - 0x6a91aa3, - 0x6a95aa4, - 0x6a99aa5, - 0x6a9daa6, - 0x26aa5aa7, - 0x6aa9aa9, - 0x6aadaaa, - 0x6ab1aab, - 0x26ab5aac, - 0x6ab9aad, - 0x26ac1aae, - 0x26ac5ab0, - 0x6ae1ab1, - 0x6aedab8, - 0x6b2dabb, - 0x6b31acb, - 0x6b55acc, - 0x6b59ad5, - 0x6cc1ad6, - 0x26cc5b30, - 0x26ccdb31, - 0x26cd1b33, - 0x26cd5b34, - 0x6cddb35, - 0x6db9b37, - 0x6dbdb6e, - 0x6de9b6f, - 0x6dedb7a, - 0x6e0db7b, - 0x6e19b83, - 0x6e39b86, - 0x6e71b8e, - 0x7109b9c, - 0x71c5c42, - 0x71d9c71, - 0x720dc76, - 0x723dc83, - 0x7259c8f, - 0x727dc96, - 0x7299c9f, - 0x72b5ca6, - 0x72d9cad, - 0x72e9cb6, - 0x72edcba, - 0x7321cbb, - 0x733dcc8, - 0x7359ccf, - 0x737dcd6, - 0x739dcdf, - 0x73b1ce7, - 0x73c5cec, - 0x73c9cf1, - 0x73e9cf2, - 0x748dcfa, - 0x74a9d23, - 0x74c9d2a, - 0x74cdd32, - 0x74d1d33, - 0x74d5d34, - 0x74e9d35, - 0x7509d3a, - 0x7515d42, - 0x7519d45, - 0x7549d46, - 0x75c9d52, - 0x75ddd72, - 0x75e1d77, - 0x75f9d78, - 0x75fdd7e, - 0x7609d7f, - 0x760dd82, - 0x7629d83, - 0x7665d8a, - 0x7669d99, - 0x7689d9a, - 0x76d9da2, - 0x76f1db6, - 0x7745dbc, - 0x7749dd1, - 0x774ddd2, - 0x7751dd3, - 0x7795dd4, - 0x77a5de5, - 0x77ddde9, - 0x780ddf7, - 0x7955e03, - 0x7979e55, - 0x79a5e5e, - 0x79b1e69, - 0x79b9e6c, - 0x7ac9e6e, - 0x7ad5eb2, - 0x7ae1eb5, - 0x7aedeb8, - 0x7af9ebb, - 0x7b05ebe, - 0x7b11ec1, - 0x7b1dec4, - 0x7b29ec7, - 0x7b35eca, - 0x7b41ecd, - 0x7b4ded0, - 0x7b59ed3, - 0x7b65ed6, - 0x7b6ded9, - 0x7b79edb, - 0x7b85ede, - 0x7b91ee1, - 0x7b9dee4, - 0x7ba9ee7, - 0x7bb5eea, - 0x7bc1eed, - 0x7bcdef0, - 0x7bd9ef3, - 0x7be5ef6, - 0x7bf1ef9, - 0x7bfdefc, - 0x7c09eff, - 0x7c15f02, - 0x7c21f05, - 0x7c2df08, - 0x7c39f0b, - 0x7c41f0e, - 0x7c4df10, - 0x7c59f13, - 0x7c65f16, - 0x7c71f19, - 0x7c7df1c, - 0x7c89f1f, - 0x7c95f22, - 0x7ca1f25, - 0x7cadf28, - 0x7cb9f2b, - 0x7cc5f2e, - 0x7cd1f31, - 0x7cddf34, - 0x7ce5f37, - 0x7cf1f39, - 0x7cfdf3c, - 0x7d09f3f, - 0x7d15f42, - 0x7d21f45, - 0x7d2df48, - 0x7d39f4b, - 0x7d45f4e, - 0x7d49f51, - 0x7d55f52, - 0x7d6df55, - 0x7d71f5b, - 0x7d81f5c, - 0x7d99f60, - 0x7dddf66, - 0x7df1f77, - 0x7e25f7c, - 0x7e35f89, - 0x7e51f8d, - 0x7e69f94, - 0x7e6df9a, - 0x27eb1f9b, - 0x7eb5fac, - 0x7ee1fad, - 0x7ee5fb8, -} - -// max children 466 (capacity 511) -// max text offset 28023 (capacity 32767) -// max text length 36 (capacity 63) -// max hi 8121 (capacity 16383) -// max lo 8120 (capacity 16383) diff --git a/vendor/golang.org/x/net/publicsuffix/table_test.go b/vendor/golang.org/x/net/publicsuffix/table_test.go deleted file mode 100644 index f60c80e79..000000000 --- a/vendor/golang.org/x/net/publicsuffix/table_test.go +++ /dev/null @@ -1,16196 +0,0 @@ -// generated by go run gen.go; DO NOT EDIT - -package publicsuffix - -var rules = [...]string{ - "ac", - "com.ac", - "edu.ac", - "gov.ac", - "net.ac", - "mil.ac", - "org.ac", - "ad", - "nom.ad", - "ae", - "co.ae", - "net.ae", - "org.ae", - "sch.ae", - "ac.ae", - "gov.ae", - "mil.ae", - "aero", - "accident-investigation.aero", - "accident-prevention.aero", - "aerobatic.aero", - "aeroclub.aero", - "aerodrome.aero", - "agents.aero", - "aircraft.aero", - "airline.aero", - "airport.aero", - "air-surveillance.aero", - "airtraffic.aero", - "air-traffic-control.aero", - "ambulance.aero", - "amusement.aero", - "association.aero", - "author.aero", - "ballooning.aero", - "broker.aero", - "caa.aero", - "cargo.aero", - "catering.aero", - "certification.aero", - "championship.aero", - "charter.aero", - "civilaviation.aero", - "club.aero", - "conference.aero", - "consultant.aero", - "consulting.aero", - "control.aero", - "council.aero", - "crew.aero", - "design.aero", - "dgca.aero", - "educator.aero", - "emergency.aero", - "engine.aero", - "engineer.aero", - "entertainment.aero", - "equipment.aero", - "exchange.aero", - "express.aero", - "federation.aero", - "flight.aero", - "freight.aero", - "fuel.aero", - "gliding.aero", - "government.aero", - "groundhandling.aero", - "group.aero", - "hanggliding.aero", - "homebuilt.aero", - "insurance.aero", - "journal.aero", - "journalist.aero", - "leasing.aero", - "logistics.aero", - "magazine.aero", - "maintenance.aero", - "media.aero", - "microlight.aero", - "modelling.aero", - "navigation.aero", - "parachuting.aero", - "paragliding.aero", - "passenger-association.aero", - "pilot.aero", - "press.aero", - "production.aero", - "recreation.aero", - "repbody.aero", - "res.aero", - "research.aero", - "rotorcraft.aero", - "safety.aero", - "scientist.aero", - "services.aero", - "show.aero", - "skydiving.aero", - "software.aero", - "student.aero", - "trader.aero", - "trading.aero", - "trainer.aero", - "union.aero", - "workinggroup.aero", - "works.aero", - "af", - "gov.af", - "com.af", - "org.af", - "net.af", - "edu.af", - "ag", - "com.ag", - "org.ag", - "net.ag", - "co.ag", - "nom.ag", - "ai", - "off.ai", - "com.ai", - "net.ai", - "org.ai", - "al", - "com.al", - "edu.al", - "gov.al", - "mil.al", - "net.al", - "org.al", - "am", - "ao", - "ed.ao", - "gv.ao", - "og.ao", - "co.ao", - "pb.ao", - "it.ao", - "aq", - "ar", - "com.ar", - "edu.ar", - "gob.ar", - "gov.ar", - "int.ar", - "mil.ar", - "net.ar", - "org.ar", - "tur.ar", - "arpa", - "e164.arpa", - "in-addr.arpa", - "ip6.arpa", - "iris.arpa", - "uri.arpa", - "urn.arpa", - "as", - "gov.as", - "asia", - "at", - "ac.at", - "co.at", - "gv.at", - "or.at", - "au", - "com.au", - "net.au", - "org.au", - "edu.au", - "gov.au", - "asn.au", - "id.au", - "info.au", - "conf.au", - "oz.au", - "act.au", - "nsw.au", - "nt.au", - "qld.au", - "sa.au", - "tas.au", - "vic.au", - "wa.au", - "act.edu.au", - "nsw.edu.au", - "nt.edu.au", - "qld.edu.au", - "sa.edu.au", - "tas.edu.au", - "vic.edu.au", - "wa.edu.au", - "qld.gov.au", - "sa.gov.au", - "tas.gov.au", - "vic.gov.au", - "wa.gov.au", - "aw", - "com.aw", - "ax", - "az", - "com.az", - "net.az", - "int.az", - "gov.az", - "org.az", - "edu.az", - "info.az", - "pp.az", - "mil.az", - "name.az", - "pro.az", - "biz.az", - "ba", - "com.ba", - "edu.ba", - "gov.ba", - "mil.ba", - "net.ba", - "org.ba", - "bb", - "biz.bb", - "co.bb", - "com.bb", - "edu.bb", - "gov.bb", - "info.bb", - "net.bb", - "org.bb", - "store.bb", - "tv.bb", - "*.bd", - "be", - "ac.be", - "bf", - "gov.bf", - "bg", - "a.bg", - "b.bg", - "c.bg", - "d.bg", - "e.bg", - "f.bg", - "g.bg", - "h.bg", - "i.bg", - "j.bg", - "k.bg", - "l.bg", - "m.bg", - "n.bg", - "o.bg", - "p.bg", - "q.bg", - "r.bg", - "s.bg", - "t.bg", - "u.bg", - "v.bg", - "w.bg", - "x.bg", - "y.bg", - "z.bg", - "0.bg", - "1.bg", - "2.bg", - "3.bg", - "4.bg", - "5.bg", - "6.bg", - "7.bg", - "8.bg", - "9.bg", - "bh", - "com.bh", - "edu.bh", - "net.bh", - "org.bh", - "gov.bh", - "bi", - "co.bi", - "com.bi", - "edu.bi", - "or.bi", - "org.bi", - "biz", - "bj", - "asso.bj", - "barreau.bj", - "gouv.bj", - "bm", - "com.bm", - "edu.bm", - "gov.bm", - "net.bm", - "org.bm", - "*.bn", - "bo", - "com.bo", - "edu.bo", - "gov.bo", - "gob.bo", - "int.bo", - "org.bo", - "net.bo", - "mil.bo", - "tv.bo", - "br", - "adm.br", - "adv.br", - "agr.br", - "am.br", - "arq.br", - "art.br", - "ato.br", - "b.br", - "bio.br", - "blog.br", - "bmd.br", - "cim.br", - "cng.br", - "cnt.br", - "com.br", - "coop.br", - "ecn.br", - "eco.br", - "edu.br", - "emp.br", - "eng.br", - "esp.br", - "etc.br", - "eti.br", - "far.br", - "flog.br", - "fm.br", - "fnd.br", - "fot.br", - "fst.br", - "g12.br", - "ggf.br", - "gov.br", - "imb.br", - "ind.br", - "inf.br", - "jor.br", - "jus.br", - "leg.br", - "lel.br", - "mat.br", - "med.br", - "mil.br", - "mp.br", - "mus.br", - "net.br", - "*.nom.br", - "not.br", - "ntr.br", - "odo.br", - "org.br", - "ppg.br", - "pro.br", - "psc.br", - "psi.br", - "qsl.br", - "radio.br", - "rec.br", - "slg.br", - "srv.br", - "taxi.br", - "teo.br", - "tmp.br", - "trd.br", - "tur.br", - "tv.br", - "vet.br", - "vlog.br", - "wiki.br", - "zlg.br", - "bs", - "com.bs", - "net.bs", - "org.bs", - "edu.bs", - "gov.bs", - "bt", - "com.bt", - "edu.bt", - "gov.bt", - "net.bt", - "org.bt", - "bv", - "bw", - "co.bw", - "org.bw", - "by", - "gov.by", - "mil.by", - "com.by", - "of.by", - "bz", - "com.bz", - "net.bz", - "org.bz", - "edu.bz", - "gov.bz", - "ca", - "ab.ca", - "bc.ca", - "mb.ca", - "nb.ca", - "nf.ca", - "nl.ca", - "ns.ca", - "nt.ca", - "nu.ca", - "on.ca", - "pe.ca", - "qc.ca", - "sk.ca", - "yk.ca", - "gc.ca", - "cat", - "cc", - "cd", - "gov.cd", - "cf", - "cg", - "ch", - "ci", - "org.ci", - "or.ci", - "com.ci", - "co.ci", - "edu.ci", - "ed.ci", - "ac.ci", - "net.ci", - "go.ci", - "asso.ci", - "xn--aroport-bya.ci", - "int.ci", - "presse.ci", - "md.ci", - "gouv.ci", - "*.ck", - "!www.ck", - "cl", - "gov.cl", - "gob.cl", - "co.cl", - "mil.cl", - "cm", - "co.cm", - "com.cm", - "gov.cm", - "net.cm", - "cn", - "ac.cn", - "com.cn", - "edu.cn", - "gov.cn", - "net.cn", - "org.cn", - "mil.cn", - "xn--55qx5d.cn", - "xn--io0a7i.cn", - "xn--od0alg.cn", - "ah.cn", - "bj.cn", - "cq.cn", - "fj.cn", - "gd.cn", - "gs.cn", - "gz.cn", - "gx.cn", - "ha.cn", - "hb.cn", - "he.cn", - "hi.cn", - "hl.cn", - "hn.cn", - "jl.cn", - "js.cn", - "jx.cn", - "ln.cn", - "nm.cn", - "nx.cn", - "qh.cn", - "sc.cn", - "sd.cn", - "sh.cn", - "sn.cn", - "sx.cn", - "tj.cn", - "xj.cn", - "xz.cn", - "yn.cn", - "zj.cn", - "hk.cn", - "mo.cn", - "tw.cn", - "co", - "arts.co", - "com.co", - "edu.co", - "firm.co", - "gov.co", - "info.co", - "int.co", - "mil.co", - "net.co", - "nom.co", - "org.co", - "rec.co", - "web.co", - "com", - "coop", - "cr", - "ac.cr", - "co.cr", - "ed.cr", - "fi.cr", - "go.cr", - "or.cr", - "sa.cr", - "cu", - "com.cu", - "edu.cu", - "org.cu", - "net.cu", - "gov.cu", - "inf.cu", - "cv", - "cw", - "com.cw", - "edu.cw", - "net.cw", - "org.cw", - "cx", - "gov.cx", - "cy", - "ac.cy", - "biz.cy", - "com.cy", - "ekloges.cy", - "gov.cy", - "ltd.cy", - "name.cy", - "net.cy", - "org.cy", - "parliament.cy", - "press.cy", - "pro.cy", - "tm.cy", - "cz", - "de", - "dj", - "dk", - "dm", - "com.dm", - "net.dm", - "org.dm", - "edu.dm", - "gov.dm", - "do", - "art.do", - "com.do", - "edu.do", - "gob.do", - "gov.do", - "mil.do", - "net.do", - "org.do", - "sld.do", - "web.do", - "dz", - "com.dz", - "org.dz", - "net.dz", - "gov.dz", - "edu.dz", - "asso.dz", - "pol.dz", - "art.dz", - "ec", - "com.ec", - "info.ec", - "net.ec", - "fin.ec", - "k12.ec", - "med.ec", - "pro.ec", - "org.ec", - "edu.ec", - "gov.ec", - "gob.ec", - "mil.ec", - "edu", - "ee", - "edu.ee", - "gov.ee", - "riik.ee", - "lib.ee", - "med.ee", - "com.ee", - "pri.ee", - "aip.ee", - "org.ee", - "fie.ee", - "eg", - "com.eg", - "edu.eg", - "eun.eg", - "gov.eg", - "mil.eg", - "name.eg", - "net.eg", - "org.eg", - "sci.eg", - "*.er", - "es", - "com.es", - "nom.es", - "org.es", - "gob.es", - "edu.es", - "et", - "com.et", - "gov.et", - "org.et", - "edu.et", - "biz.et", - "name.et", - "info.et", - "net.et", - "eu", - "fi", - "aland.fi", - "*.fj", - "*.fk", - "fm", - "fo", - "fr", - "com.fr", - "asso.fr", - "nom.fr", - "prd.fr", - "presse.fr", - "tm.fr", - "aeroport.fr", - "assedic.fr", - "avocat.fr", - "avoues.fr", - "cci.fr", - "chambagri.fr", - "chirurgiens-dentistes.fr", - "experts-comptables.fr", - "geometre-expert.fr", - "gouv.fr", - "greta.fr", - "huissier-justice.fr", - "medecin.fr", - "notaires.fr", - "pharmacien.fr", - "port.fr", - "veterinaire.fr", - "ga", - "gb", - "gd", - "ge", - "com.ge", - "edu.ge", - "gov.ge", - "org.ge", - "mil.ge", - "net.ge", - "pvt.ge", - "gf", - "gg", - "co.gg", - "net.gg", - "org.gg", - "gh", - "com.gh", - "edu.gh", - "gov.gh", - "org.gh", - "mil.gh", - "gi", - "com.gi", - "ltd.gi", - "gov.gi", - "mod.gi", - "edu.gi", - "org.gi", - "gl", - "co.gl", - "com.gl", - "edu.gl", - "net.gl", - "org.gl", - "gm", - "gn", - "ac.gn", - "com.gn", - "edu.gn", - "gov.gn", - "org.gn", - "net.gn", - "gov", - "gp", - "com.gp", - "net.gp", - "mobi.gp", - "edu.gp", - "org.gp", - "asso.gp", - "gq", - "gr", - "com.gr", - "edu.gr", - "net.gr", - "org.gr", - "gov.gr", - "gs", - "gt", - "com.gt", - "edu.gt", - "gob.gt", - "ind.gt", - "mil.gt", - "net.gt", - "org.gt", - "*.gu", - "gw", - "gy", - "co.gy", - "com.gy", - "edu.gy", - "gov.gy", - "net.gy", - "org.gy", - "hk", - "com.hk", - "edu.hk", - "gov.hk", - "idv.hk", - "net.hk", - "org.hk", - "xn--55qx5d.hk", - "xn--wcvs22d.hk", - "xn--lcvr32d.hk", - "xn--mxtq1m.hk", - "xn--gmqw5a.hk", - "xn--ciqpn.hk", - "xn--gmq050i.hk", - "xn--zf0avx.hk", - "xn--io0a7i.hk", - "xn--mk0axi.hk", - "xn--od0alg.hk", - "xn--od0aq3b.hk", - "xn--tn0ag.hk", - "xn--uc0atv.hk", - "xn--uc0ay4a.hk", - "hm", - "hn", - "com.hn", - "edu.hn", - "org.hn", - "net.hn", - "mil.hn", - "gob.hn", - "hr", - "iz.hr", - "from.hr", - "name.hr", - "com.hr", - "ht", - "com.ht", - "shop.ht", - "firm.ht", - "info.ht", - "adult.ht", - "net.ht", - "pro.ht", - "org.ht", - "med.ht", - "art.ht", - "coop.ht", - "pol.ht", - "asso.ht", - "edu.ht", - "rel.ht", - "gouv.ht", - "perso.ht", - "hu", - "co.hu", - "info.hu", - "org.hu", - "priv.hu", - "sport.hu", - "tm.hu", - "2000.hu", - "agrar.hu", - "bolt.hu", - "casino.hu", - "city.hu", - "erotica.hu", - "erotika.hu", - "film.hu", - "forum.hu", - "games.hu", - "hotel.hu", - "ingatlan.hu", - "jogasz.hu", - "konyvelo.hu", - "lakas.hu", - "media.hu", - "news.hu", - "reklam.hu", - "sex.hu", - "shop.hu", - "suli.hu", - "szex.hu", - "tozsde.hu", - "utazas.hu", - "video.hu", - "id", - "ac.id", - "biz.id", - "co.id", - "desa.id", - "go.id", - "mil.id", - "my.id", - "net.id", - "or.id", - "sch.id", - "web.id", - "ie", - "gov.ie", - "il", - "ac.il", - "co.il", - "gov.il", - "idf.il", - "k12.il", - "muni.il", - "net.il", - "org.il", - "im", - "ac.im", - "co.im", - "com.im", - "ltd.co.im", - "net.im", - "org.im", - "plc.co.im", - "tt.im", - "tv.im", - "in", - "co.in", - "firm.in", - "net.in", - "org.in", - "gen.in", - "ind.in", - "nic.in", - "ac.in", - "edu.in", - "res.in", - "gov.in", - "mil.in", - "info", - "int", - "eu.int", - "io", - "com.io", - "iq", - "gov.iq", - "edu.iq", - "mil.iq", - "com.iq", - "org.iq", - "net.iq", - "ir", - "ac.ir", - "co.ir", - "gov.ir", - "id.ir", - "net.ir", - "org.ir", - "sch.ir", - "xn--mgba3a4f16a.ir", - "xn--mgba3a4fra.ir", - "is", - "net.is", - "com.is", - "edu.is", - "gov.is", - "org.is", - "int.is", - "it", - "gov.it", - "edu.it", - "abr.it", - "abruzzo.it", - "aosta-valley.it", - "aostavalley.it", - "bas.it", - "basilicata.it", - "cal.it", - "calabria.it", - "cam.it", - "campania.it", - "emilia-romagna.it", - "emiliaromagna.it", - "emr.it", - "friuli-v-giulia.it", - "friuli-ve-giulia.it", - "friuli-vegiulia.it", - "friuli-venezia-giulia.it", - "friuli-veneziagiulia.it", - "friuli-vgiulia.it", - "friuliv-giulia.it", - "friulive-giulia.it", - "friulivegiulia.it", - "friulivenezia-giulia.it", - "friuliveneziagiulia.it", - "friulivgiulia.it", - "fvg.it", - "laz.it", - "lazio.it", - "lig.it", - "liguria.it", - "lom.it", - "lombardia.it", - "lombardy.it", - "lucania.it", - "mar.it", - "marche.it", - "mol.it", - "molise.it", - "piedmont.it", - "piemonte.it", - "pmn.it", - "pug.it", - "puglia.it", - "sar.it", - "sardegna.it", - "sardinia.it", - "sic.it", - "sicilia.it", - "sicily.it", - "taa.it", - "tos.it", - "toscana.it", - "trentino-a-adige.it", - "trentino-aadige.it", - "trentino-alto-adige.it", - "trentino-altoadige.it", - "trentino-s-tirol.it", - "trentino-stirol.it", - "trentino-sud-tirol.it", - "trentino-sudtirol.it", - "trentino-sued-tirol.it", - "trentino-suedtirol.it", - "trentinoa-adige.it", - "trentinoaadige.it", - "trentinoalto-adige.it", - "trentinoaltoadige.it", - "trentinos-tirol.it", - "trentinostirol.it", - "trentinosud-tirol.it", - "trentinosudtirol.it", - "trentinosued-tirol.it", - "trentinosuedtirol.it", - "tuscany.it", - "umb.it", - "umbria.it", - "val-d-aosta.it", - "val-daosta.it", - "vald-aosta.it", - "valdaosta.it", - "valle-aosta.it", - "valle-d-aosta.it", - "valle-daosta.it", - "valleaosta.it", - "valled-aosta.it", - "valledaosta.it", - "vallee-aoste.it", - "valleeaoste.it", - "vao.it", - "vda.it", - "ven.it", - "veneto.it", - "ag.it", - "agrigento.it", - "al.it", - "alessandria.it", - "alto-adige.it", - "altoadige.it", - "an.it", - "ancona.it", - "andria-barletta-trani.it", - "andria-trani-barletta.it", - "andriabarlettatrani.it", - "andriatranibarletta.it", - "ao.it", - "aosta.it", - "aoste.it", - "ap.it", - "aq.it", - "aquila.it", - "ar.it", - "arezzo.it", - "ascoli-piceno.it", - "ascolipiceno.it", - "asti.it", - "at.it", - "av.it", - "avellino.it", - "ba.it", - "balsan.it", - "bari.it", - "barletta-trani-andria.it", - "barlettatraniandria.it", - "belluno.it", - "benevento.it", - "bergamo.it", - "bg.it", - "bi.it", - "biella.it", - "bl.it", - "bn.it", - "bo.it", - "bologna.it", - "bolzano.it", - "bozen.it", - "br.it", - "brescia.it", - "brindisi.it", - "bs.it", - "bt.it", - "bz.it", - "ca.it", - "cagliari.it", - "caltanissetta.it", - "campidano-medio.it", - "campidanomedio.it", - "campobasso.it", - "carbonia-iglesias.it", - "carboniaiglesias.it", - "carrara-massa.it", - "carraramassa.it", - "caserta.it", - "catania.it", - "catanzaro.it", - "cb.it", - "ce.it", - "cesena-forli.it", - "cesenaforli.it", - "ch.it", - "chieti.it", - "ci.it", - "cl.it", - "cn.it", - "co.it", - "como.it", - "cosenza.it", - "cr.it", - "cremona.it", - "crotone.it", - "cs.it", - "ct.it", - "cuneo.it", - "cz.it", - "dell-ogliastra.it", - "dellogliastra.it", - "en.it", - "enna.it", - "fc.it", - "fe.it", - "fermo.it", - "ferrara.it", - "fg.it", - "fi.it", - "firenze.it", - "florence.it", - "fm.it", - "foggia.it", - "forli-cesena.it", - "forlicesena.it", - "fr.it", - "frosinone.it", - "ge.it", - "genoa.it", - "genova.it", - "go.it", - "gorizia.it", - "gr.it", - "grosseto.it", - "iglesias-carbonia.it", - "iglesiascarbonia.it", - "im.it", - "imperia.it", - "is.it", - "isernia.it", - "kr.it", - "la-spezia.it", - "laquila.it", - "laspezia.it", - "latina.it", - "lc.it", - "le.it", - "lecce.it", - "lecco.it", - "li.it", - "livorno.it", - "lo.it", - "lodi.it", - "lt.it", - "lu.it", - "lucca.it", - "macerata.it", - "mantova.it", - "massa-carrara.it", - "massacarrara.it", - "matera.it", - "mb.it", - "mc.it", - "me.it", - "medio-campidano.it", - "mediocampidano.it", - "messina.it", - "mi.it", - "milan.it", - "milano.it", - "mn.it", - "mo.it", - "modena.it", - "monza-brianza.it", - "monza-e-della-brianza.it", - "monza.it", - "monzabrianza.it", - "monzaebrianza.it", - "monzaedellabrianza.it", - "ms.it", - "mt.it", - "na.it", - "naples.it", - "napoli.it", - "no.it", - "novara.it", - "nu.it", - "nuoro.it", - "og.it", - "ogliastra.it", - "olbia-tempio.it", - "olbiatempio.it", - "or.it", - "oristano.it", - "ot.it", - "pa.it", - "padova.it", - "padua.it", - "palermo.it", - "parma.it", - "pavia.it", - "pc.it", - "pd.it", - "pe.it", - "perugia.it", - "pesaro-urbino.it", - "pesarourbino.it", - "pescara.it", - "pg.it", - "pi.it", - "piacenza.it", - "pisa.it", - "pistoia.it", - "pn.it", - "po.it", - "pordenone.it", - "potenza.it", - "pr.it", - "prato.it", - "pt.it", - "pu.it", - "pv.it", - "pz.it", - "ra.it", - "ragusa.it", - "ravenna.it", - "rc.it", - "re.it", - "reggio-calabria.it", - "reggio-emilia.it", - "reggiocalabria.it", - "reggioemilia.it", - "rg.it", - "ri.it", - "rieti.it", - "rimini.it", - "rm.it", - "rn.it", - "ro.it", - "roma.it", - "rome.it", - "rovigo.it", - "sa.it", - "salerno.it", - "sassari.it", - "savona.it", - "si.it", - "siena.it", - "siracusa.it", - "so.it", - "sondrio.it", - "sp.it", - "sr.it", - "ss.it", - "suedtirol.it", - "sv.it", - "ta.it", - "taranto.it", - "te.it", - "tempio-olbia.it", - "tempioolbia.it", - "teramo.it", - "terni.it", - "tn.it", - "to.it", - "torino.it", - "tp.it", - "tr.it", - "trani-andria-barletta.it", - "trani-barletta-andria.it", - "traniandriabarletta.it", - "tranibarlettaandria.it", - "trapani.it", - "trentino.it", - "trento.it", - "treviso.it", - "trieste.it", - "ts.it", - "turin.it", - "tv.it", - "ud.it", - "udine.it", - "urbino-pesaro.it", - "urbinopesaro.it", - "va.it", - "varese.it", - "vb.it", - "vc.it", - "ve.it", - "venezia.it", - "venice.it", - "verbania.it", - "vercelli.it", - "verona.it", - "vi.it", - "vibo-valentia.it", - "vibovalentia.it", - "vicenza.it", - "viterbo.it", - "vr.it", - "vs.it", - "vt.it", - "vv.it", - "je", - "co.je", - "net.je", - "org.je", - "*.jm", - "jo", - "com.jo", - "org.jo", - "net.jo", - "edu.jo", - "sch.jo", - "gov.jo", - "mil.jo", - "name.jo", - "jobs", - "jp", - "ac.jp", - "ad.jp", - "co.jp", - "ed.jp", - "go.jp", - "gr.jp", - "lg.jp", - "ne.jp", - "or.jp", - "aichi.jp", - "akita.jp", - "aomori.jp", - "chiba.jp", - "ehime.jp", - "fukui.jp", - "fukuoka.jp", - "fukushima.jp", - "gifu.jp", - "gunma.jp", - "hiroshima.jp", - "hokkaido.jp", - "hyogo.jp", - "ibaraki.jp", - "ishikawa.jp", - "iwate.jp", - "kagawa.jp", - "kagoshima.jp", - "kanagawa.jp", - "kochi.jp", - "kumamoto.jp", - "kyoto.jp", - "mie.jp", - "miyagi.jp", - "miyazaki.jp", - "nagano.jp", - "nagasaki.jp", - "nara.jp", - "niigata.jp", - "oita.jp", - "okayama.jp", - "okinawa.jp", - "osaka.jp", - "saga.jp", - "saitama.jp", - "shiga.jp", - "shimane.jp", - "shizuoka.jp", - "tochigi.jp", - "tokushima.jp", - "tokyo.jp", - "tottori.jp", - "toyama.jp", - "wakayama.jp", - "yamagata.jp", - "yamaguchi.jp", - "yamanashi.jp", - "xn--4pvxs.jp", - "xn--vgu402c.jp", - "xn--c3s14m.jp", - "xn--f6qx53a.jp", - "xn--8pvr4u.jp", - "xn--uist22h.jp", - "xn--djrs72d6uy.jp", - "xn--mkru45i.jp", - "xn--0trq7p7nn.jp", - "xn--8ltr62k.jp", - "xn--2m4a15e.jp", - "xn--efvn9s.jp", - "xn--32vp30h.jp", - "xn--4it797k.jp", - "xn--1lqs71d.jp", - "xn--5rtp49c.jp", - "xn--5js045d.jp", - "xn--ehqz56n.jp", - "xn--1lqs03n.jp", - "xn--qqqt11m.jp", - "xn--kbrq7o.jp", - "xn--pssu33l.jp", - "xn--ntsq17g.jp", - "xn--uisz3g.jp", - "xn--6btw5a.jp", - "xn--1ctwo.jp", - "xn--6orx2r.jp", - "xn--rht61e.jp", - "xn--rht27z.jp", - "xn--djty4k.jp", - "xn--nit225k.jp", - "xn--rht3d.jp", - "xn--klty5x.jp", - "xn--kltx9a.jp", - "xn--kltp7d.jp", - "xn--uuwu58a.jp", - "xn--zbx025d.jp", - "xn--ntso0iqx3a.jp", - "xn--elqq16h.jp", - "xn--4it168d.jp", - "xn--klt787d.jp", - "xn--rny31h.jp", - "xn--7t0a264c.jp", - "xn--5rtq34k.jp", - "xn--k7yn95e.jp", - "xn--tor131o.jp", - "xn--d5qv7z876c.jp", - "*.kawasaki.jp", - "*.kitakyushu.jp", - "*.kobe.jp", - "*.nagoya.jp", - "*.sapporo.jp", - "*.sendai.jp", - "*.yokohama.jp", - "!city.kawasaki.jp", - "!city.kitakyushu.jp", - "!city.kobe.jp", - "!city.nagoya.jp", - "!city.sapporo.jp", - "!city.sendai.jp", - "!city.yokohama.jp", - "aisai.aichi.jp", - "ama.aichi.jp", - "anjo.aichi.jp", - "asuke.aichi.jp", - "chiryu.aichi.jp", - "chita.aichi.jp", - "fuso.aichi.jp", - "gamagori.aichi.jp", - "handa.aichi.jp", - "hazu.aichi.jp", - "hekinan.aichi.jp", - "higashiura.aichi.jp", - "ichinomiya.aichi.jp", - "inazawa.aichi.jp", - "inuyama.aichi.jp", - "isshiki.aichi.jp", - "iwakura.aichi.jp", - "kanie.aichi.jp", - "kariya.aichi.jp", - "kasugai.aichi.jp", - "kira.aichi.jp", - "kiyosu.aichi.jp", - "komaki.aichi.jp", - "konan.aichi.jp", - "kota.aichi.jp", - "mihama.aichi.jp", - "miyoshi.aichi.jp", - "nishio.aichi.jp", - "nisshin.aichi.jp", - "obu.aichi.jp", - "oguchi.aichi.jp", - "oharu.aichi.jp", - "okazaki.aichi.jp", - "owariasahi.aichi.jp", - "seto.aichi.jp", - "shikatsu.aichi.jp", - "shinshiro.aichi.jp", - "shitara.aichi.jp", - "tahara.aichi.jp", - "takahama.aichi.jp", - "tobishima.aichi.jp", - "toei.aichi.jp", - "togo.aichi.jp", - "tokai.aichi.jp", - "tokoname.aichi.jp", - "toyoake.aichi.jp", - "toyohashi.aichi.jp", - "toyokawa.aichi.jp", - "toyone.aichi.jp", - "toyota.aichi.jp", - "tsushima.aichi.jp", - "yatomi.aichi.jp", - "akita.akita.jp", - "daisen.akita.jp", - "fujisato.akita.jp", - "gojome.akita.jp", - "hachirogata.akita.jp", - "happou.akita.jp", - "higashinaruse.akita.jp", - "honjo.akita.jp", - "honjyo.akita.jp", - "ikawa.akita.jp", - "kamikoani.akita.jp", - "kamioka.akita.jp", - "katagami.akita.jp", - "kazuno.akita.jp", - "kitaakita.akita.jp", - "kosaka.akita.jp", - "kyowa.akita.jp", - "misato.akita.jp", - "mitane.akita.jp", - "moriyoshi.akita.jp", - "nikaho.akita.jp", - "noshiro.akita.jp", - "odate.akita.jp", - "oga.akita.jp", - "ogata.akita.jp", - "semboku.akita.jp", - "yokote.akita.jp", - "yurihonjo.akita.jp", - "aomori.aomori.jp", - "gonohe.aomori.jp", - "hachinohe.aomori.jp", - "hashikami.aomori.jp", - "hiranai.aomori.jp", - "hirosaki.aomori.jp", - "itayanagi.aomori.jp", - "kuroishi.aomori.jp", - "misawa.aomori.jp", - "mutsu.aomori.jp", - "nakadomari.aomori.jp", - "noheji.aomori.jp", - "oirase.aomori.jp", - "owani.aomori.jp", - "rokunohe.aomori.jp", - "sannohe.aomori.jp", - "shichinohe.aomori.jp", - "shingo.aomori.jp", - "takko.aomori.jp", - "towada.aomori.jp", - "tsugaru.aomori.jp", - "tsuruta.aomori.jp", - "abiko.chiba.jp", - "asahi.chiba.jp", - "chonan.chiba.jp", - "chosei.chiba.jp", - "choshi.chiba.jp", - "chuo.chiba.jp", - "funabashi.chiba.jp", - "futtsu.chiba.jp", - "hanamigawa.chiba.jp", - "ichihara.chiba.jp", - "ichikawa.chiba.jp", - "ichinomiya.chiba.jp", - "inzai.chiba.jp", - "isumi.chiba.jp", - "kamagaya.chiba.jp", - "kamogawa.chiba.jp", - "kashiwa.chiba.jp", - "katori.chiba.jp", - "katsuura.chiba.jp", - "kimitsu.chiba.jp", - "kisarazu.chiba.jp", - "kozaki.chiba.jp", - "kujukuri.chiba.jp", - "kyonan.chiba.jp", - "matsudo.chiba.jp", - "midori.chiba.jp", - "mihama.chiba.jp", - "minamiboso.chiba.jp", - "mobara.chiba.jp", - "mutsuzawa.chiba.jp", - "nagara.chiba.jp", - "nagareyama.chiba.jp", - "narashino.chiba.jp", - "narita.chiba.jp", - "noda.chiba.jp", - "oamishirasato.chiba.jp", - "omigawa.chiba.jp", - "onjuku.chiba.jp", - "otaki.chiba.jp", - "sakae.chiba.jp", - "sakura.chiba.jp", - "shimofusa.chiba.jp", - "shirako.chiba.jp", - "shiroi.chiba.jp", - "shisui.chiba.jp", - "sodegaura.chiba.jp", - "sosa.chiba.jp", - "tako.chiba.jp", - "tateyama.chiba.jp", - "togane.chiba.jp", - "tohnosho.chiba.jp", - "tomisato.chiba.jp", - "urayasu.chiba.jp", - "yachimata.chiba.jp", - "yachiyo.chiba.jp", - "yokaichiba.chiba.jp", - "yokoshibahikari.chiba.jp", - "yotsukaido.chiba.jp", - "ainan.ehime.jp", - "honai.ehime.jp", - "ikata.ehime.jp", - "imabari.ehime.jp", - "iyo.ehime.jp", - "kamijima.ehime.jp", - "kihoku.ehime.jp", - "kumakogen.ehime.jp", - "masaki.ehime.jp", - "matsuno.ehime.jp", - "matsuyama.ehime.jp", - "namikata.ehime.jp", - "niihama.ehime.jp", - "ozu.ehime.jp", - "saijo.ehime.jp", - "seiyo.ehime.jp", - "shikokuchuo.ehime.jp", - "tobe.ehime.jp", - "toon.ehime.jp", - "uchiko.ehime.jp", - "uwajima.ehime.jp", - "yawatahama.ehime.jp", - "echizen.fukui.jp", - "eiheiji.fukui.jp", - "fukui.fukui.jp", - "ikeda.fukui.jp", - "katsuyama.fukui.jp", - "mihama.fukui.jp", - "minamiechizen.fukui.jp", - "obama.fukui.jp", - "ohi.fukui.jp", - "ono.fukui.jp", - "sabae.fukui.jp", - "sakai.fukui.jp", - "takahama.fukui.jp", - "tsuruga.fukui.jp", - "wakasa.fukui.jp", - "ashiya.fukuoka.jp", - "buzen.fukuoka.jp", - "chikugo.fukuoka.jp", - "chikuho.fukuoka.jp", - "chikujo.fukuoka.jp", - "chikushino.fukuoka.jp", - "chikuzen.fukuoka.jp", - "chuo.fukuoka.jp", - "dazaifu.fukuoka.jp", - "fukuchi.fukuoka.jp", - "hakata.fukuoka.jp", - "higashi.fukuoka.jp", - "hirokawa.fukuoka.jp", - "hisayama.fukuoka.jp", - "iizuka.fukuoka.jp", - "inatsuki.fukuoka.jp", - "kaho.fukuoka.jp", - "kasuga.fukuoka.jp", - "kasuya.fukuoka.jp", - "kawara.fukuoka.jp", - "keisen.fukuoka.jp", - "koga.fukuoka.jp", - "kurate.fukuoka.jp", - "kurogi.fukuoka.jp", - "kurume.fukuoka.jp", - "minami.fukuoka.jp", - "miyako.fukuoka.jp", - "miyama.fukuoka.jp", - "miyawaka.fukuoka.jp", - "mizumaki.fukuoka.jp", - "munakata.fukuoka.jp", - "nakagawa.fukuoka.jp", - "nakama.fukuoka.jp", - "nishi.fukuoka.jp", - "nogata.fukuoka.jp", - "ogori.fukuoka.jp", - "okagaki.fukuoka.jp", - "okawa.fukuoka.jp", - "oki.fukuoka.jp", - "omuta.fukuoka.jp", - "onga.fukuoka.jp", - "onojo.fukuoka.jp", - "oto.fukuoka.jp", - "saigawa.fukuoka.jp", - "sasaguri.fukuoka.jp", - "shingu.fukuoka.jp", - "shinyoshitomi.fukuoka.jp", - "shonai.fukuoka.jp", - "soeda.fukuoka.jp", - "sue.fukuoka.jp", - "tachiarai.fukuoka.jp", - "tagawa.fukuoka.jp", - "takata.fukuoka.jp", - "toho.fukuoka.jp", - "toyotsu.fukuoka.jp", - "tsuiki.fukuoka.jp", - "ukiha.fukuoka.jp", - "umi.fukuoka.jp", - "usui.fukuoka.jp", - "yamada.fukuoka.jp", - "yame.fukuoka.jp", - "yanagawa.fukuoka.jp", - "yukuhashi.fukuoka.jp", - "aizubange.fukushima.jp", - "aizumisato.fukushima.jp", - "aizuwakamatsu.fukushima.jp", - "asakawa.fukushima.jp", - "bandai.fukushima.jp", - "date.fukushima.jp", - "fukushima.fukushima.jp", - "furudono.fukushima.jp", - "futaba.fukushima.jp", - "hanawa.fukushima.jp", - "higashi.fukushima.jp", - "hirata.fukushima.jp", - "hirono.fukushima.jp", - "iitate.fukushima.jp", - "inawashiro.fukushima.jp", - "ishikawa.fukushima.jp", - "iwaki.fukushima.jp", - "izumizaki.fukushima.jp", - "kagamiishi.fukushima.jp", - "kaneyama.fukushima.jp", - "kawamata.fukushima.jp", - "kitakata.fukushima.jp", - "kitashiobara.fukushima.jp", - "koori.fukushima.jp", - "koriyama.fukushima.jp", - "kunimi.fukushima.jp", - "miharu.fukushima.jp", - "mishima.fukushima.jp", - "namie.fukushima.jp", - "nango.fukushima.jp", - "nishiaizu.fukushima.jp", - "nishigo.fukushima.jp", - "okuma.fukushima.jp", - "omotego.fukushima.jp", - "ono.fukushima.jp", - "otama.fukushima.jp", - "samegawa.fukushima.jp", - "shimogo.fukushima.jp", - "shirakawa.fukushima.jp", - "showa.fukushima.jp", - "soma.fukushima.jp", - "sukagawa.fukushima.jp", - "taishin.fukushima.jp", - "tamakawa.fukushima.jp", - "tanagura.fukushima.jp", - "tenei.fukushima.jp", - "yabuki.fukushima.jp", - "yamato.fukushima.jp", - "yamatsuri.fukushima.jp", - "yanaizu.fukushima.jp", - "yugawa.fukushima.jp", - "anpachi.gifu.jp", - "ena.gifu.jp", - "gifu.gifu.jp", - "ginan.gifu.jp", - "godo.gifu.jp", - "gujo.gifu.jp", - "hashima.gifu.jp", - "hichiso.gifu.jp", - "hida.gifu.jp", - "higashishirakawa.gifu.jp", - "ibigawa.gifu.jp", - "ikeda.gifu.jp", - "kakamigahara.gifu.jp", - "kani.gifu.jp", - "kasahara.gifu.jp", - "kasamatsu.gifu.jp", - "kawaue.gifu.jp", - "kitagata.gifu.jp", - "mino.gifu.jp", - "minokamo.gifu.jp", - "mitake.gifu.jp", - "mizunami.gifu.jp", - "motosu.gifu.jp", - "nakatsugawa.gifu.jp", - "ogaki.gifu.jp", - "sakahogi.gifu.jp", - "seki.gifu.jp", - "sekigahara.gifu.jp", - "shirakawa.gifu.jp", - "tajimi.gifu.jp", - "takayama.gifu.jp", - "tarui.gifu.jp", - "toki.gifu.jp", - "tomika.gifu.jp", - "wanouchi.gifu.jp", - "yamagata.gifu.jp", - "yaotsu.gifu.jp", - "yoro.gifu.jp", - "annaka.gunma.jp", - "chiyoda.gunma.jp", - "fujioka.gunma.jp", - "higashiagatsuma.gunma.jp", - "isesaki.gunma.jp", - "itakura.gunma.jp", - "kanna.gunma.jp", - "kanra.gunma.jp", - "katashina.gunma.jp", - "kawaba.gunma.jp", - "kiryu.gunma.jp", - "kusatsu.gunma.jp", - "maebashi.gunma.jp", - "meiwa.gunma.jp", - "midori.gunma.jp", - "minakami.gunma.jp", - "naganohara.gunma.jp", - "nakanojo.gunma.jp", - "nanmoku.gunma.jp", - "numata.gunma.jp", - "oizumi.gunma.jp", - "ora.gunma.jp", - "ota.gunma.jp", - "shibukawa.gunma.jp", - "shimonita.gunma.jp", - "shinto.gunma.jp", - "showa.gunma.jp", - "takasaki.gunma.jp", - "takayama.gunma.jp", - "tamamura.gunma.jp", - "tatebayashi.gunma.jp", - "tomioka.gunma.jp", - "tsukiyono.gunma.jp", - "tsumagoi.gunma.jp", - "ueno.gunma.jp", - "yoshioka.gunma.jp", - "asaminami.hiroshima.jp", - "daiwa.hiroshima.jp", - "etajima.hiroshima.jp", - "fuchu.hiroshima.jp", - "fukuyama.hiroshima.jp", - "hatsukaichi.hiroshima.jp", - "higashihiroshima.hiroshima.jp", - "hongo.hiroshima.jp", - "jinsekikogen.hiroshima.jp", - "kaita.hiroshima.jp", - "kui.hiroshima.jp", - "kumano.hiroshima.jp", - "kure.hiroshima.jp", - "mihara.hiroshima.jp", - "miyoshi.hiroshima.jp", - "naka.hiroshima.jp", - "onomichi.hiroshima.jp", - "osakikamijima.hiroshima.jp", - "otake.hiroshima.jp", - "saka.hiroshima.jp", - "sera.hiroshima.jp", - "seranishi.hiroshima.jp", - "shinichi.hiroshima.jp", - "shobara.hiroshima.jp", - "takehara.hiroshima.jp", - "abashiri.hokkaido.jp", - "abira.hokkaido.jp", - "aibetsu.hokkaido.jp", - "akabira.hokkaido.jp", - "akkeshi.hokkaido.jp", - "asahikawa.hokkaido.jp", - "ashibetsu.hokkaido.jp", - "ashoro.hokkaido.jp", - "assabu.hokkaido.jp", - "atsuma.hokkaido.jp", - "bibai.hokkaido.jp", - "biei.hokkaido.jp", - "bifuka.hokkaido.jp", - "bihoro.hokkaido.jp", - "biratori.hokkaido.jp", - "chippubetsu.hokkaido.jp", - "chitose.hokkaido.jp", - "date.hokkaido.jp", - "ebetsu.hokkaido.jp", - "embetsu.hokkaido.jp", - "eniwa.hokkaido.jp", - "erimo.hokkaido.jp", - "esan.hokkaido.jp", - "esashi.hokkaido.jp", - "fukagawa.hokkaido.jp", - "fukushima.hokkaido.jp", - "furano.hokkaido.jp", - "furubira.hokkaido.jp", - "haboro.hokkaido.jp", - "hakodate.hokkaido.jp", - "hamatonbetsu.hokkaido.jp", - "hidaka.hokkaido.jp", - "higashikagura.hokkaido.jp", - "higashikawa.hokkaido.jp", - "hiroo.hokkaido.jp", - "hokuryu.hokkaido.jp", - "hokuto.hokkaido.jp", - "honbetsu.hokkaido.jp", - "horokanai.hokkaido.jp", - "horonobe.hokkaido.jp", - "ikeda.hokkaido.jp", - "imakane.hokkaido.jp", - "ishikari.hokkaido.jp", - "iwamizawa.hokkaido.jp", - "iwanai.hokkaido.jp", - "kamifurano.hokkaido.jp", - "kamikawa.hokkaido.jp", - "kamishihoro.hokkaido.jp", - "kamisunagawa.hokkaido.jp", - "kamoenai.hokkaido.jp", - "kayabe.hokkaido.jp", - "kembuchi.hokkaido.jp", - "kikonai.hokkaido.jp", - "kimobetsu.hokkaido.jp", - "kitahiroshima.hokkaido.jp", - "kitami.hokkaido.jp", - "kiyosato.hokkaido.jp", - "koshimizu.hokkaido.jp", - "kunneppu.hokkaido.jp", - "kuriyama.hokkaido.jp", - "kuromatsunai.hokkaido.jp", - "kushiro.hokkaido.jp", - "kutchan.hokkaido.jp", - "kyowa.hokkaido.jp", - "mashike.hokkaido.jp", - "matsumae.hokkaido.jp", - "mikasa.hokkaido.jp", - "minamifurano.hokkaido.jp", - "mombetsu.hokkaido.jp", - "moseushi.hokkaido.jp", - "mukawa.hokkaido.jp", - "muroran.hokkaido.jp", - "naie.hokkaido.jp", - "nakagawa.hokkaido.jp", - "nakasatsunai.hokkaido.jp", - "nakatombetsu.hokkaido.jp", - "nanae.hokkaido.jp", - "nanporo.hokkaido.jp", - "nayoro.hokkaido.jp", - "nemuro.hokkaido.jp", - "niikappu.hokkaido.jp", - "niki.hokkaido.jp", - "nishiokoppe.hokkaido.jp", - "noboribetsu.hokkaido.jp", - "numata.hokkaido.jp", - "obihiro.hokkaido.jp", - "obira.hokkaido.jp", - "oketo.hokkaido.jp", - "okoppe.hokkaido.jp", - "otaru.hokkaido.jp", - "otobe.hokkaido.jp", - "otofuke.hokkaido.jp", - "otoineppu.hokkaido.jp", - "oumu.hokkaido.jp", - "ozora.hokkaido.jp", - "pippu.hokkaido.jp", - "rankoshi.hokkaido.jp", - "rebun.hokkaido.jp", - "rikubetsu.hokkaido.jp", - "rishiri.hokkaido.jp", - "rishirifuji.hokkaido.jp", - "saroma.hokkaido.jp", - "sarufutsu.hokkaido.jp", - "shakotan.hokkaido.jp", - "shari.hokkaido.jp", - "shibecha.hokkaido.jp", - "shibetsu.hokkaido.jp", - "shikabe.hokkaido.jp", - "shikaoi.hokkaido.jp", - "shimamaki.hokkaido.jp", - "shimizu.hokkaido.jp", - "shimokawa.hokkaido.jp", - "shinshinotsu.hokkaido.jp", - "shintoku.hokkaido.jp", - "shiranuka.hokkaido.jp", - "shiraoi.hokkaido.jp", - "shiriuchi.hokkaido.jp", - "sobetsu.hokkaido.jp", - "sunagawa.hokkaido.jp", - "taiki.hokkaido.jp", - "takasu.hokkaido.jp", - "takikawa.hokkaido.jp", - "takinoue.hokkaido.jp", - "teshikaga.hokkaido.jp", - "tobetsu.hokkaido.jp", - "tohma.hokkaido.jp", - "tomakomai.hokkaido.jp", - "tomari.hokkaido.jp", - "toya.hokkaido.jp", - "toyako.hokkaido.jp", - "toyotomi.hokkaido.jp", - "toyoura.hokkaido.jp", - "tsubetsu.hokkaido.jp", - "tsukigata.hokkaido.jp", - "urakawa.hokkaido.jp", - "urausu.hokkaido.jp", - "uryu.hokkaido.jp", - "utashinai.hokkaido.jp", - "wakkanai.hokkaido.jp", - "wassamu.hokkaido.jp", - "yakumo.hokkaido.jp", - "yoichi.hokkaido.jp", - "aioi.hyogo.jp", - "akashi.hyogo.jp", - "ako.hyogo.jp", - "amagasaki.hyogo.jp", - "aogaki.hyogo.jp", - "asago.hyogo.jp", - "ashiya.hyogo.jp", - "awaji.hyogo.jp", - "fukusaki.hyogo.jp", - "goshiki.hyogo.jp", - "harima.hyogo.jp", - "himeji.hyogo.jp", - "ichikawa.hyogo.jp", - "inagawa.hyogo.jp", - "itami.hyogo.jp", - "kakogawa.hyogo.jp", - "kamigori.hyogo.jp", - "kamikawa.hyogo.jp", - "kasai.hyogo.jp", - "kasuga.hyogo.jp", - "kawanishi.hyogo.jp", - "miki.hyogo.jp", - "minamiawaji.hyogo.jp", - "nishinomiya.hyogo.jp", - "nishiwaki.hyogo.jp", - "ono.hyogo.jp", - "sanda.hyogo.jp", - "sannan.hyogo.jp", - "sasayama.hyogo.jp", - "sayo.hyogo.jp", - "shingu.hyogo.jp", - "shinonsen.hyogo.jp", - "shiso.hyogo.jp", - "sumoto.hyogo.jp", - "taishi.hyogo.jp", - "taka.hyogo.jp", - "takarazuka.hyogo.jp", - "takasago.hyogo.jp", - "takino.hyogo.jp", - "tamba.hyogo.jp", - "tatsuno.hyogo.jp", - "toyooka.hyogo.jp", - "yabu.hyogo.jp", - "yashiro.hyogo.jp", - "yoka.hyogo.jp", - "yokawa.hyogo.jp", - "ami.ibaraki.jp", - "asahi.ibaraki.jp", - "bando.ibaraki.jp", - "chikusei.ibaraki.jp", - "daigo.ibaraki.jp", - "fujishiro.ibaraki.jp", - "hitachi.ibaraki.jp", - "hitachinaka.ibaraki.jp", - "hitachiomiya.ibaraki.jp", - "hitachiota.ibaraki.jp", - "ibaraki.ibaraki.jp", - "ina.ibaraki.jp", - "inashiki.ibaraki.jp", - "itako.ibaraki.jp", - "iwama.ibaraki.jp", - "joso.ibaraki.jp", - "kamisu.ibaraki.jp", - "kasama.ibaraki.jp", - "kashima.ibaraki.jp", - "kasumigaura.ibaraki.jp", - "koga.ibaraki.jp", - "miho.ibaraki.jp", - "mito.ibaraki.jp", - "moriya.ibaraki.jp", - "naka.ibaraki.jp", - "namegata.ibaraki.jp", - "oarai.ibaraki.jp", - "ogawa.ibaraki.jp", - "omitama.ibaraki.jp", - "ryugasaki.ibaraki.jp", - "sakai.ibaraki.jp", - "sakuragawa.ibaraki.jp", - "shimodate.ibaraki.jp", - "shimotsuma.ibaraki.jp", - "shirosato.ibaraki.jp", - "sowa.ibaraki.jp", - "suifu.ibaraki.jp", - "takahagi.ibaraki.jp", - "tamatsukuri.ibaraki.jp", - "tokai.ibaraki.jp", - "tomobe.ibaraki.jp", - "tone.ibaraki.jp", - "toride.ibaraki.jp", - "tsuchiura.ibaraki.jp", - "tsukuba.ibaraki.jp", - "uchihara.ibaraki.jp", - "ushiku.ibaraki.jp", - "yachiyo.ibaraki.jp", - "yamagata.ibaraki.jp", - "yawara.ibaraki.jp", - "yuki.ibaraki.jp", - "anamizu.ishikawa.jp", - "hakui.ishikawa.jp", - "hakusan.ishikawa.jp", - "kaga.ishikawa.jp", - "kahoku.ishikawa.jp", - "kanazawa.ishikawa.jp", - "kawakita.ishikawa.jp", - "komatsu.ishikawa.jp", - "nakanoto.ishikawa.jp", - "nanao.ishikawa.jp", - "nomi.ishikawa.jp", - "nonoichi.ishikawa.jp", - "noto.ishikawa.jp", - "shika.ishikawa.jp", - "suzu.ishikawa.jp", - "tsubata.ishikawa.jp", - "tsurugi.ishikawa.jp", - "uchinada.ishikawa.jp", - "wajima.ishikawa.jp", - "fudai.iwate.jp", - "fujisawa.iwate.jp", - "hanamaki.iwate.jp", - "hiraizumi.iwate.jp", - "hirono.iwate.jp", - "ichinohe.iwate.jp", - "ichinoseki.iwate.jp", - "iwaizumi.iwate.jp", - "iwate.iwate.jp", - "joboji.iwate.jp", - "kamaishi.iwate.jp", - "kanegasaki.iwate.jp", - "karumai.iwate.jp", - "kawai.iwate.jp", - "kitakami.iwate.jp", - "kuji.iwate.jp", - "kunohe.iwate.jp", - "kuzumaki.iwate.jp", - "miyako.iwate.jp", - "mizusawa.iwate.jp", - "morioka.iwate.jp", - "ninohe.iwate.jp", - "noda.iwate.jp", - "ofunato.iwate.jp", - "oshu.iwate.jp", - "otsuchi.iwate.jp", - "rikuzentakata.iwate.jp", - "shiwa.iwate.jp", - "shizukuishi.iwate.jp", - "sumita.iwate.jp", - "tanohata.iwate.jp", - "tono.iwate.jp", - "yahaba.iwate.jp", - "yamada.iwate.jp", - "ayagawa.kagawa.jp", - "higashikagawa.kagawa.jp", - "kanonji.kagawa.jp", - "kotohira.kagawa.jp", - "manno.kagawa.jp", - "marugame.kagawa.jp", - "mitoyo.kagawa.jp", - "naoshima.kagawa.jp", - "sanuki.kagawa.jp", - "tadotsu.kagawa.jp", - "takamatsu.kagawa.jp", - "tonosho.kagawa.jp", - "uchinomi.kagawa.jp", - "utazu.kagawa.jp", - "zentsuji.kagawa.jp", - "akune.kagoshima.jp", - "amami.kagoshima.jp", - "hioki.kagoshima.jp", - "isa.kagoshima.jp", - "isen.kagoshima.jp", - "izumi.kagoshima.jp", - "kagoshima.kagoshima.jp", - "kanoya.kagoshima.jp", - "kawanabe.kagoshima.jp", - "kinko.kagoshima.jp", - "kouyama.kagoshima.jp", - "makurazaki.kagoshima.jp", - "matsumoto.kagoshima.jp", - "minamitane.kagoshima.jp", - "nakatane.kagoshima.jp", - "nishinoomote.kagoshima.jp", - "satsumasendai.kagoshima.jp", - "soo.kagoshima.jp", - "tarumizu.kagoshima.jp", - "yusui.kagoshima.jp", - "aikawa.kanagawa.jp", - "atsugi.kanagawa.jp", - "ayase.kanagawa.jp", - "chigasaki.kanagawa.jp", - "ebina.kanagawa.jp", - "fujisawa.kanagawa.jp", - "hadano.kanagawa.jp", - "hakone.kanagawa.jp", - "hiratsuka.kanagawa.jp", - "isehara.kanagawa.jp", - "kaisei.kanagawa.jp", - "kamakura.kanagawa.jp", - "kiyokawa.kanagawa.jp", - "matsuda.kanagawa.jp", - "minamiashigara.kanagawa.jp", - "miura.kanagawa.jp", - "nakai.kanagawa.jp", - "ninomiya.kanagawa.jp", - "odawara.kanagawa.jp", - "oi.kanagawa.jp", - "oiso.kanagawa.jp", - "sagamihara.kanagawa.jp", - "samukawa.kanagawa.jp", - "tsukui.kanagawa.jp", - "yamakita.kanagawa.jp", - "yamato.kanagawa.jp", - "yokosuka.kanagawa.jp", - "yugawara.kanagawa.jp", - "zama.kanagawa.jp", - "zushi.kanagawa.jp", - "aki.kochi.jp", - "geisei.kochi.jp", - "hidaka.kochi.jp", - "higashitsuno.kochi.jp", - "ino.kochi.jp", - "kagami.kochi.jp", - "kami.kochi.jp", - "kitagawa.kochi.jp", - "kochi.kochi.jp", - "mihara.kochi.jp", - "motoyama.kochi.jp", - "muroto.kochi.jp", - "nahari.kochi.jp", - "nakamura.kochi.jp", - "nankoku.kochi.jp", - "nishitosa.kochi.jp", - "niyodogawa.kochi.jp", - "ochi.kochi.jp", - "okawa.kochi.jp", - "otoyo.kochi.jp", - "otsuki.kochi.jp", - "sakawa.kochi.jp", - "sukumo.kochi.jp", - "susaki.kochi.jp", - "tosa.kochi.jp", - "tosashimizu.kochi.jp", - "toyo.kochi.jp", - "tsuno.kochi.jp", - "umaji.kochi.jp", - "yasuda.kochi.jp", - "yusuhara.kochi.jp", - "amakusa.kumamoto.jp", - "arao.kumamoto.jp", - "aso.kumamoto.jp", - "choyo.kumamoto.jp", - "gyokuto.kumamoto.jp", - "kamiamakusa.kumamoto.jp", - "kikuchi.kumamoto.jp", - "kumamoto.kumamoto.jp", - "mashiki.kumamoto.jp", - "mifune.kumamoto.jp", - "minamata.kumamoto.jp", - "minamioguni.kumamoto.jp", - "nagasu.kumamoto.jp", - "nishihara.kumamoto.jp", - "oguni.kumamoto.jp", - "ozu.kumamoto.jp", - "sumoto.kumamoto.jp", - "takamori.kumamoto.jp", - "uki.kumamoto.jp", - "uto.kumamoto.jp", - "yamaga.kumamoto.jp", - "yamato.kumamoto.jp", - "yatsushiro.kumamoto.jp", - "ayabe.kyoto.jp", - "fukuchiyama.kyoto.jp", - "higashiyama.kyoto.jp", - "ide.kyoto.jp", - "ine.kyoto.jp", - "joyo.kyoto.jp", - "kameoka.kyoto.jp", - "kamo.kyoto.jp", - "kita.kyoto.jp", - "kizu.kyoto.jp", - "kumiyama.kyoto.jp", - "kyotamba.kyoto.jp", - "kyotanabe.kyoto.jp", - "kyotango.kyoto.jp", - "maizuru.kyoto.jp", - "minami.kyoto.jp", - "minamiyamashiro.kyoto.jp", - "miyazu.kyoto.jp", - "muko.kyoto.jp", - "nagaokakyo.kyoto.jp", - "nakagyo.kyoto.jp", - "nantan.kyoto.jp", - "oyamazaki.kyoto.jp", - "sakyo.kyoto.jp", - "seika.kyoto.jp", - "tanabe.kyoto.jp", - "uji.kyoto.jp", - "ujitawara.kyoto.jp", - "wazuka.kyoto.jp", - "yamashina.kyoto.jp", - "yawata.kyoto.jp", - "asahi.mie.jp", - "inabe.mie.jp", - "ise.mie.jp", - "kameyama.mie.jp", - "kawagoe.mie.jp", - "kiho.mie.jp", - "kisosaki.mie.jp", - "kiwa.mie.jp", - "komono.mie.jp", - "kumano.mie.jp", - "kuwana.mie.jp", - "matsusaka.mie.jp", - "meiwa.mie.jp", - "mihama.mie.jp", - "minamiise.mie.jp", - "misugi.mie.jp", - "miyama.mie.jp", - "nabari.mie.jp", - "shima.mie.jp", - "suzuka.mie.jp", - "tado.mie.jp", - "taiki.mie.jp", - "taki.mie.jp", - "tamaki.mie.jp", - "toba.mie.jp", - "tsu.mie.jp", - "udono.mie.jp", - "ureshino.mie.jp", - "watarai.mie.jp", - "yokkaichi.mie.jp", - "furukawa.miyagi.jp", - "higashimatsushima.miyagi.jp", - "ishinomaki.miyagi.jp", - "iwanuma.miyagi.jp", - "kakuda.miyagi.jp", - "kami.miyagi.jp", - "kawasaki.miyagi.jp", - "marumori.miyagi.jp", - "matsushima.miyagi.jp", - "minamisanriku.miyagi.jp", - "misato.miyagi.jp", - "murata.miyagi.jp", - "natori.miyagi.jp", - "ogawara.miyagi.jp", - "ohira.miyagi.jp", - "onagawa.miyagi.jp", - "osaki.miyagi.jp", - "rifu.miyagi.jp", - "semine.miyagi.jp", - "shibata.miyagi.jp", - "shichikashuku.miyagi.jp", - "shikama.miyagi.jp", - "shiogama.miyagi.jp", - "shiroishi.miyagi.jp", - "tagajo.miyagi.jp", - "taiwa.miyagi.jp", - "tome.miyagi.jp", - "tomiya.miyagi.jp", - "wakuya.miyagi.jp", - "watari.miyagi.jp", - "yamamoto.miyagi.jp", - "zao.miyagi.jp", - "aya.miyazaki.jp", - "ebino.miyazaki.jp", - "gokase.miyazaki.jp", - "hyuga.miyazaki.jp", - "kadogawa.miyazaki.jp", - "kawaminami.miyazaki.jp", - "kijo.miyazaki.jp", - "kitagawa.miyazaki.jp", - "kitakata.miyazaki.jp", - "kitaura.miyazaki.jp", - "kobayashi.miyazaki.jp", - "kunitomi.miyazaki.jp", - "kushima.miyazaki.jp", - "mimata.miyazaki.jp", - "miyakonojo.miyazaki.jp", - "miyazaki.miyazaki.jp", - "morotsuka.miyazaki.jp", - "nichinan.miyazaki.jp", - "nishimera.miyazaki.jp", - "nobeoka.miyazaki.jp", - "saito.miyazaki.jp", - "shiiba.miyazaki.jp", - "shintomi.miyazaki.jp", - "takaharu.miyazaki.jp", - "takanabe.miyazaki.jp", - "takazaki.miyazaki.jp", - "tsuno.miyazaki.jp", - "achi.nagano.jp", - "agematsu.nagano.jp", - "anan.nagano.jp", - "aoki.nagano.jp", - "asahi.nagano.jp", - "azumino.nagano.jp", - "chikuhoku.nagano.jp", - "chikuma.nagano.jp", - "chino.nagano.jp", - "fujimi.nagano.jp", - "hakuba.nagano.jp", - "hara.nagano.jp", - "hiraya.nagano.jp", - "iida.nagano.jp", - "iijima.nagano.jp", - "iiyama.nagano.jp", - "iizuna.nagano.jp", - "ikeda.nagano.jp", - "ikusaka.nagano.jp", - "ina.nagano.jp", - "karuizawa.nagano.jp", - "kawakami.nagano.jp", - "kiso.nagano.jp", - "kisofukushima.nagano.jp", - "kitaaiki.nagano.jp", - "komagane.nagano.jp", - "komoro.nagano.jp", - "matsukawa.nagano.jp", - "matsumoto.nagano.jp", - "miasa.nagano.jp", - "minamiaiki.nagano.jp", - "minamimaki.nagano.jp", - "minamiminowa.nagano.jp", - "minowa.nagano.jp", - "miyada.nagano.jp", - "miyota.nagano.jp", - "mochizuki.nagano.jp", - "nagano.nagano.jp", - "nagawa.nagano.jp", - "nagiso.nagano.jp", - "nakagawa.nagano.jp", - "nakano.nagano.jp", - "nozawaonsen.nagano.jp", - "obuse.nagano.jp", - "ogawa.nagano.jp", - "okaya.nagano.jp", - "omachi.nagano.jp", - "omi.nagano.jp", - "ookuwa.nagano.jp", - "ooshika.nagano.jp", - "otaki.nagano.jp", - "otari.nagano.jp", - "sakae.nagano.jp", - "sakaki.nagano.jp", - "saku.nagano.jp", - "sakuho.nagano.jp", - "shimosuwa.nagano.jp", - "shinanomachi.nagano.jp", - "shiojiri.nagano.jp", - "suwa.nagano.jp", - "suzaka.nagano.jp", - "takagi.nagano.jp", - "takamori.nagano.jp", - "takayama.nagano.jp", - "tateshina.nagano.jp", - "tatsuno.nagano.jp", - "togakushi.nagano.jp", - "togura.nagano.jp", - "tomi.nagano.jp", - "ueda.nagano.jp", - "wada.nagano.jp", - "yamagata.nagano.jp", - "yamanouchi.nagano.jp", - "yasaka.nagano.jp", - "yasuoka.nagano.jp", - "chijiwa.nagasaki.jp", - "futsu.nagasaki.jp", - "goto.nagasaki.jp", - "hasami.nagasaki.jp", - "hirado.nagasaki.jp", - "iki.nagasaki.jp", - "isahaya.nagasaki.jp", - "kawatana.nagasaki.jp", - "kuchinotsu.nagasaki.jp", - "matsuura.nagasaki.jp", - "nagasaki.nagasaki.jp", - "obama.nagasaki.jp", - "omura.nagasaki.jp", - "oseto.nagasaki.jp", - "saikai.nagasaki.jp", - "sasebo.nagasaki.jp", - "seihi.nagasaki.jp", - "shimabara.nagasaki.jp", - "shinkamigoto.nagasaki.jp", - "togitsu.nagasaki.jp", - "tsushima.nagasaki.jp", - "unzen.nagasaki.jp", - "ando.nara.jp", - "gose.nara.jp", - "heguri.nara.jp", - "higashiyoshino.nara.jp", - "ikaruga.nara.jp", - "ikoma.nara.jp", - "kamikitayama.nara.jp", - "kanmaki.nara.jp", - "kashiba.nara.jp", - "kashihara.nara.jp", - "katsuragi.nara.jp", - "kawai.nara.jp", - "kawakami.nara.jp", - "kawanishi.nara.jp", - "koryo.nara.jp", - "kurotaki.nara.jp", - "mitsue.nara.jp", - "miyake.nara.jp", - "nara.nara.jp", - "nosegawa.nara.jp", - "oji.nara.jp", - "ouda.nara.jp", - "oyodo.nara.jp", - "sakurai.nara.jp", - "sango.nara.jp", - "shimoichi.nara.jp", - "shimokitayama.nara.jp", - "shinjo.nara.jp", - "soni.nara.jp", - "takatori.nara.jp", - "tawaramoto.nara.jp", - "tenkawa.nara.jp", - "tenri.nara.jp", - "uda.nara.jp", - "yamatokoriyama.nara.jp", - "yamatotakada.nara.jp", - "yamazoe.nara.jp", - "yoshino.nara.jp", - "aga.niigata.jp", - "agano.niigata.jp", - "gosen.niigata.jp", - "itoigawa.niigata.jp", - "izumozaki.niigata.jp", - "joetsu.niigata.jp", - "kamo.niigata.jp", - "kariwa.niigata.jp", - "kashiwazaki.niigata.jp", - "minamiuonuma.niigata.jp", - "mitsuke.niigata.jp", - "muika.niigata.jp", - "murakami.niigata.jp", - "myoko.niigata.jp", - "nagaoka.niigata.jp", - "niigata.niigata.jp", - "ojiya.niigata.jp", - "omi.niigata.jp", - "sado.niigata.jp", - "sanjo.niigata.jp", - "seiro.niigata.jp", - "seirou.niigata.jp", - "sekikawa.niigata.jp", - "shibata.niigata.jp", - "tagami.niigata.jp", - "tainai.niigata.jp", - "tochio.niigata.jp", - "tokamachi.niigata.jp", - "tsubame.niigata.jp", - "tsunan.niigata.jp", - "uonuma.niigata.jp", - "yahiko.niigata.jp", - "yoita.niigata.jp", - "yuzawa.niigata.jp", - "beppu.oita.jp", - "bungoono.oita.jp", - "bungotakada.oita.jp", - "hasama.oita.jp", - "hiji.oita.jp", - "himeshima.oita.jp", - "hita.oita.jp", - "kamitsue.oita.jp", - "kokonoe.oita.jp", - "kuju.oita.jp", - "kunisaki.oita.jp", - "kusu.oita.jp", - "oita.oita.jp", - "saiki.oita.jp", - "taketa.oita.jp", - "tsukumi.oita.jp", - "usa.oita.jp", - "usuki.oita.jp", - "yufu.oita.jp", - "akaiwa.okayama.jp", - "asakuchi.okayama.jp", - "bizen.okayama.jp", - "hayashima.okayama.jp", - "ibara.okayama.jp", - "kagamino.okayama.jp", - "kasaoka.okayama.jp", - "kibichuo.okayama.jp", - "kumenan.okayama.jp", - "kurashiki.okayama.jp", - "maniwa.okayama.jp", - "misaki.okayama.jp", - "nagi.okayama.jp", - "niimi.okayama.jp", - "nishiawakura.okayama.jp", - "okayama.okayama.jp", - "satosho.okayama.jp", - "setouchi.okayama.jp", - "shinjo.okayama.jp", - "shoo.okayama.jp", - "soja.okayama.jp", - "takahashi.okayama.jp", - "tamano.okayama.jp", - "tsuyama.okayama.jp", - "wake.okayama.jp", - "yakage.okayama.jp", - "aguni.okinawa.jp", - "ginowan.okinawa.jp", - "ginoza.okinawa.jp", - "gushikami.okinawa.jp", - "haebaru.okinawa.jp", - "higashi.okinawa.jp", - "hirara.okinawa.jp", - "iheya.okinawa.jp", - "ishigaki.okinawa.jp", - "ishikawa.okinawa.jp", - "itoman.okinawa.jp", - "izena.okinawa.jp", - "kadena.okinawa.jp", - "kin.okinawa.jp", - "kitadaito.okinawa.jp", - "kitanakagusuku.okinawa.jp", - "kumejima.okinawa.jp", - "kunigami.okinawa.jp", - "minamidaito.okinawa.jp", - "motobu.okinawa.jp", - "nago.okinawa.jp", - "naha.okinawa.jp", - "nakagusuku.okinawa.jp", - "nakijin.okinawa.jp", - "nanjo.okinawa.jp", - "nishihara.okinawa.jp", - "ogimi.okinawa.jp", - "okinawa.okinawa.jp", - "onna.okinawa.jp", - "shimoji.okinawa.jp", - "taketomi.okinawa.jp", - "tarama.okinawa.jp", - "tokashiki.okinawa.jp", - "tomigusuku.okinawa.jp", - "tonaki.okinawa.jp", - "urasoe.okinawa.jp", - "uruma.okinawa.jp", - "yaese.okinawa.jp", - "yomitan.okinawa.jp", - "yonabaru.okinawa.jp", - "yonaguni.okinawa.jp", - "zamami.okinawa.jp", - "abeno.osaka.jp", - "chihayaakasaka.osaka.jp", - "chuo.osaka.jp", - "daito.osaka.jp", - "fujiidera.osaka.jp", - "habikino.osaka.jp", - "hannan.osaka.jp", - "higashiosaka.osaka.jp", - "higashisumiyoshi.osaka.jp", - "higashiyodogawa.osaka.jp", - "hirakata.osaka.jp", - "ibaraki.osaka.jp", - "ikeda.osaka.jp", - "izumi.osaka.jp", - "izumiotsu.osaka.jp", - "izumisano.osaka.jp", - "kadoma.osaka.jp", - "kaizuka.osaka.jp", - "kanan.osaka.jp", - "kashiwara.osaka.jp", - "katano.osaka.jp", - "kawachinagano.osaka.jp", - "kishiwada.osaka.jp", - "kita.osaka.jp", - "kumatori.osaka.jp", - "matsubara.osaka.jp", - "minato.osaka.jp", - "minoh.osaka.jp", - "misaki.osaka.jp", - "moriguchi.osaka.jp", - "neyagawa.osaka.jp", - "nishi.osaka.jp", - "nose.osaka.jp", - "osakasayama.osaka.jp", - "sakai.osaka.jp", - "sayama.osaka.jp", - "sennan.osaka.jp", - "settsu.osaka.jp", - "shijonawate.osaka.jp", - "shimamoto.osaka.jp", - "suita.osaka.jp", - "tadaoka.osaka.jp", - "taishi.osaka.jp", - "tajiri.osaka.jp", - "takaishi.osaka.jp", - "takatsuki.osaka.jp", - "tondabayashi.osaka.jp", - "toyonaka.osaka.jp", - "toyono.osaka.jp", - "yao.osaka.jp", - "ariake.saga.jp", - "arita.saga.jp", - "fukudomi.saga.jp", - "genkai.saga.jp", - "hamatama.saga.jp", - "hizen.saga.jp", - "imari.saga.jp", - "kamimine.saga.jp", - "kanzaki.saga.jp", - "karatsu.saga.jp", - "kashima.saga.jp", - "kitagata.saga.jp", - "kitahata.saga.jp", - "kiyama.saga.jp", - "kouhoku.saga.jp", - "kyuragi.saga.jp", - "nishiarita.saga.jp", - "ogi.saga.jp", - "omachi.saga.jp", - "ouchi.saga.jp", - "saga.saga.jp", - "shiroishi.saga.jp", - "taku.saga.jp", - "tara.saga.jp", - "tosu.saga.jp", - "yoshinogari.saga.jp", - "arakawa.saitama.jp", - "asaka.saitama.jp", - "chichibu.saitama.jp", - "fujimi.saitama.jp", - "fujimino.saitama.jp", - "fukaya.saitama.jp", - "hanno.saitama.jp", - "hanyu.saitama.jp", - "hasuda.saitama.jp", - "hatogaya.saitama.jp", - "hatoyama.saitama.jp", - "hidaka.saitama.jp", - "higashichichibu.saitama.jp", - "higashimatsuyama.saitama.jp", - "honjo.saitama.jp", - "ina.saitama.jp", - "iruma.saitama.jp", - "iwatsuki.saitama.jp", - "kamiizumi.saitama.jp", - "kamikawa.saitama.jp", - "kamisato.saitama.jp", - "kasukabe.saitama.jp", - "kawagoe.saitama.jp", - "kawaguchi.saitama.jp", - "kawajima.saitama.jp", - "kazo.saitama.jp", - "kitamoto.saitama.jp", - "koshigaya.saitama.jp", - "kounosu.saitama.jp", - "kuki.saitama.jp", - "kumagaya.saitama.jp", - "matsubushi.saitama.jp", - "minano.saitama.jp", - "misato.saitama.jp", - "miyashiro.saitama.jp", - "miyoshi.saitama.jp", - "moroyama.saitama.jp", - "nagatoro.saitama.jp", - "namegawa.saitama.jp", - "niiza.saitama.jp", - "ogano.saitama.jp", - "ogawa.saitama.jp", - "ogose.saitama.jp", - "okegawa.saitama.jp", - "omiya.saitama.jp", - "otaki.saitama.jp", - "ranzan.saitama.jp", - "ryokami.saitama.jp", - "saitama.saitama.jp", - "sakado.saitama.jp", - "satte.saitama.jp", - "sayama.saitama.jp", - "shiki.saitama.jp", - "shiraoka.saitama.jp", - "soka.saitama.jp", - "sugito.saitama.jp", - "toda.saitama.jp", - "tokigawa.saitama.jp", - "tokorozawa.saitama.jp", - "tsurugashima.saitama.jp", - "urawa.saitama.jp", - "warabi.saitama.jp", - "yashio.saitama.jp", - "yokoze.saitama.jp", - "yono.saitama.jp", - "yorii.saitama.jp", - "yoshida.saitama.jp", - "yoshikawa.saitama.jp", - "yoshimi.saitama.jp", - "aisho.shiga.jp", - "gamo.shiga.jp", - "higashiomi.shiga.jp", - "hikone.shiga.jp", - "koka.shiga.jp", - "konan.shiga.jp", - "kosei.shiga.jp", - "koto.shiga.jp", - "kusatsu.shiga.jp", - "maibara.shiga.jp", - "moriyama.shiga.jp", - "nagahama.shiga.jp", - "nishiazai.shiga.jp", - "notogawa.shiga.jp", - "omihachiman.shiga.jp", - "otsu.shiga.jp", - "ritto.shiga.jp", - "ryuoh.shiga.jp", - "takashima.shiga.jp", - "takatsuki.shiga.jp", - "torahime.shiga.jp", - "toyosato.shiga.jp", - "yasu.shiga.jp", - "akagi.shimane.jp", - "ama.shimane.jp", - "gotsu.shimane.jp", - "hamada.shimane.jp", - "higashiizumo.shimane.jp", - "hikawa.shimane.jp", - "hikimi.shimane.jp", - "izumo.shimane.jp", - "kakinoki.shimane.jp", - "masuda.shimane.jp", - "matsue.shimane.jp", - "misato.shimane.jp", - "nishinoshima.shimane.jp", - "ohda.shimane.jp", - "okinoshima.shimane.jp", - "okuizumo.shimane.jp", - "shimane.shimane.jp", - "tamayu.shimane.jp", - "tsuwano.shimane.jp", - "unnan.shimane.jp", - "yakumo.shimane.jp", - "yasugi.shimane.jp", - "yatsuka.shimane.jp", - "arai.shizuoka.jp", - "atami.shizuoka.jp", - "fuji.shizuoka.jp", - "fujieda.shizuoka.jp", - "fujikawa.shizuoka.jp", - "fujinomiya.shizuoka.jp", - "fukuroi.shizuoka.jp", - "gotemba.shizuoka.jp", - "haibara.shizuoka.jp", - "hamamatsu.shizuoka.jp", - "higashiizu.shizuoka.jp", - "ito.shizuoka.jp", - "iwata.shizuoka.jp", - "izu.shizuoka.jp", - "izunokuni.shizuoka.jp", - "kakegawa.shizuoka.jp", - "kannami.shizuoka.jp", - "kawanehon.shizuoka.jp", - "kawazu.shizuoka.jp", - "kikugawa.shizuoka.jp", - "kosai.shizuoka.jp", - "makinohara.shizuoka.jp", - "matsuzaki.shizuoka.jp", - "minamiizu.shizuoka.jp", - "mishima.shizuoka.jp", - "morimachi.shizuoka.jp", - "nishiizu.shizuoka.jp", - "numazu.shizuoka.jp", - "omaezaki.shizuoka.jp", - "shimada.shizuoka.jp", - "shimizu.shizuoka.jp", - "shimoda.shizuoka.jp", - "shizuoka.shizuoka.jp", - "susono.shizuoka.jp", - "yaizu.shizuoka.jp", - "yoshida.shizuoka.jp", - "ashikaga.tochigi.jp", - "bato.tochigi.jp", - "haga.tochigi.jp", - "ichikai.tochigi.jp", - "iwafune.tochigi.jp", - "kaminokawa.tochigi.jp", - "kanuma.tochigi.jp", - "karasuyama.tochigi.jp", - "kuroiso.tochigi.jp", - "mashiko.tochigi.jp", - "mibu.tochigi.jp", - "moka.tochigi.jp", - "motegi.tochigi.jp", - "nasu.tochigi.jp", - "nasushiobara.tochigi.jp", - "nikko.tochigi.jp", - "nishikata.tochigi.jp", - "nogi.tochigi.jp", - "ohira.tochigi.jp", - "ohtawara.tochigi.jp", - "oyama.tochigi.jp", - "sakura.tochigi.jp", - "sano.tochigi.jp", - "shimotsuke.tochigi.jp", - "shioya.tochigi.jp", - "takanezawa.tochigi.jp", - "tochigi.tochigi.jp", - "tsuga.tochigi.jp", - "ujiie.tochigi.jp", - "utsunomiya.tochigi.jp", - "yaita.tochigi.jp", - "aizumi.tokushima.jp", - "anan.tokushima.jp", - "ichiba.tokushima.jp", - "itano.tokushima.jp", - "kainan.tokushima.jp", - "komatsushima.tokushima.jp", - "matsushige.tokushima.jp", - "mima.tokushima.jp", - "minami.tokushima.jp", - "miyoshi.tokushima.jp", - "mugi.tokushima.jp", - "nakagawa.tokushima.jp", - "naruto.tokushima.jp", - "sanagochi.tokushima.jp", - "shishikui.tokushima.jp", - "tokushima.tokushima.jp", - "wajiki.tokushima.jp", - "adachi.tokyo.jp", - "akiruno.tokyo.jp", - "akishima.tokyo.jp", - "aogashima.tokyo.jp", - "arakawa.tokyo.jp", - "bunkyo.tokyo.jp", - "chiyoda.tokyo.jp", - "chofu.tokyo.jp", - "chuo.tokyo.jp", - "edogawa.tokyo.jp", - "fuchu.tokyo.jp", - "fussa.tokyo.jp", - "hachijo.tokyo.jp", - "hachioji.tokyo.jp", - "hamura.tokyo.jp", - "higashikurume.tokyo.jp", - "higashimurayama.tokyo.jp", - "higashiyamato.tokyo.jp", - "hino.tokyo.jp", - "hinode.tokyo.jp", - "hinohara.tokyo.jp", - "inagi.tokyo.jp", - "itabashi.tokyo.jp", - "katsushika.tokyo.jp", - "kita.tokyo.jp", - "kiyose.tokyo.jp", - "kodaira.tokyo.jp", - "koganei.tokyo.jp", - "kokubunji.tokyo.jp", - "komae.tokyo.jp", - "koto.tokyo.jp", - "kouzushima.tokyo.jp", - "kunitachi.tokyo.jp", - "machida.tokyo.jp", - "meguro.tokyo.jp", - "minato.tokyo.jp", - "mitaka.tokyo.jp", - "mizuho.tokyo.jp", - "musashimurayama.tokyo.jp", - "musashino.tokyo.jp", - "nakano.tokyo.jp", - "nerima.tokyo.jp", - "ogasawara.tokyo.jp", - "okutama.tokyo.jp", - "ome.tokyo.jp", - "oshima.tokyo.jp", - "ota.tokyo.jp", - "setagaya.tokyo.jp", - "shibuya.tokyo.jp", - "shinagawa.tokyo.jp", - "shinjuku.tokyo.jp", - "suginami.tokyo.jp", - "sumida.tokyo.jp", - "tachikawa.tokyo.jp", - "taito.tokyo.jp", - "tama.tokyo.jp", - "toshima.tokyo.jp", - "chizu.tottori.jp", - "hino.tottori.jp", - "kawahara.tottori.jp", - "koge.tottori.jp", - "kotoura.tottori.jp", - "misasa.tottori.jp", - "nanbu.tottori.jp", - "nichinan.tottori.jp", - "sakaiminato.tottori.jp", - "tottori.tottori.jp", - "wakasa.tottori.jp", - "yazu.tottori.jp", - "yonago.tottori.jp", - "asahi.toyama.jp", - "fuchu.toyama.jp", - "fukumitsu.toyama.jp", - "funahashi.toyama.jp", - "himi.toyama.jp", - "imizu.toyama.jp", - "inami.toyama.jp", - "johana.toyama.jp", - "kamiichi.toyama.jp", - "kurobe.toyama.jp", - "nakaniikawa.toyama.jp", - "namerikawa.toyama.jp", - "nanto.toyama.jp", - "nyuzen.toyama.jp", - "oyabe.toyama.jp", - "taira.toyama.jp", - "takaoka.toyama.jp", - "tateyama.toyama.jp", - "toga.toyama.jp", - "tonami.toyama.jp", - "toyama.toyama.jp", - "unazuki.toyama.jp", - "uozu.toyama.jp", - "yamada.toyama.jp", - "arida.wakayama.jp", - "aridagawa.wakayama.jp", - "gobo.wakayama.jp", - "hashimoto.wakayama.jp", - "hidaka.wakayama.jp", - "hirogawa.wakayama.jp", - "inami.wakayama.jp", - "iwade.wakayama.jp", - "kainan.wakayama.jp", - "kamitonda.wakayama.jp", - "katsuragi.wakayama.jp", - "kimino.wakayama.jp", - "kinokawa.wakayama.jp", - "kitayama.wakayama.jp", - "koya.wakayama.jp", - "koza.wakayama.jp", - "kozagawa.wakayama.jp", - "kudoyama.wakayama.jp", - "kushimoto.wakayama.jp", - "mihama.wakayama.jp", - "misato.wakayama.jp", - "nachikatsuura.wakayama.jp", - "shingu.wakayama.jp", - "shirahama.wakayama.jp", - "taiji.wakayama.jp", - "tanabe.wakayama.jp", - "wakayama.wakayama.jp", - "yuasa.wakayama.jp", - "yura.wakayama.jp", - "asahi.yamagata.jp", - "funagata.yamagata.jp", - "higashine.yamagata.jp", - "iide.yamagata.jp", - "kahoku.yamagata.jp", - "kaminoyama.yamagata.jp", - "kaneyama.yamagata.jp", - "kawanishi.yamagata.jp", - "mamurogawa.yamagata.jp", - "mikawa.yamagata.jp", - "murayama.yamagata.jp", - "nagai.yamagata.jp", - "nakayama.yamagata.jp", - "nanyo.yamagata.jp", - "nishikawa.yamagata.jp", - "obanazawa.yamagata.jp", - "oe.yamagata.jp", - "oguni.yamagata.jp", - "ohkura.yamagata.jp", - "oishida.yamagata.jp", - "sagae.yamagata.jp", - "sakata.yamagata.jp", - "sakegawa.yamagata.jp", - "shinjo.yamagata.jp", - "shirataka.yamagata.jp", - "shonai.yamagata.jp", - "takahata.yamagata.jp", - "tendo.yamagata.jp", - "tozawa.yamagata.jp", - "tsuruoka.yamagata.jp", - "yamagata.yamagata.jp", - "yamanobe.yamagata.jp", - "yonezawa.yamagata.jp", - "yuza.yamagata.jp", - "abu.yamaguchi.jp", - "hagi.yamaguchi.jp", - "hikari.yamaguchi.jp", - "hofu.yamaguchi.jp", - "iwakuni.yamaguchi.jp", - "kudamatsu.yamaguchi.jp", - "mitou.yamaguchi.jp", - "nagato.yamaguchi.jp", - "oshima.yamaguchi.jp", - "shimonoseki.yamaguchi.jp", - "shunan.yamaguchi.jp", - "tabuse.yamaguchi.jp", - "tokuyama.yamaguchi.jp", - "toyota.yamaguchi.jp", - "ube.yamaguchi.jp", - "yuu.yamaguchi.jp", - "chuo.yamanashi.jp", - "doshi.yamanashi.jp", - "fuefuki.yamanashi.jp", - "fujikawa.yamanashi.jp", - "fujikawaguchiko.yamanashi.jp", - "fujiyoshida.yamanashi.jp", - "hayakawa.yamanashi.jp", - "hokuto.yamanashi.jp", - "ichikawamisato.yamanashi.jp", - "kai.yamanashi.jp", - "kofu.yamanashi.jp", - "koshu.yamanashi.jp", - "kosuge.yamanashi.jp", - "minami-alps.yamanashi.jp", - "minobu.yamanashi.jp", - "nakamichi.yamanashi.jp", - "nanbu.yamanashi.jp", - "narusawa.yamanashi.jp", - "nirasaki.yamanashi.jp", - "nishikatsura.yamanashi.jp", - "oshino.yamanashi.jp", - "otsuki.yamanashi.jp", - "showa.yamanashi.jp", - "tabayama.yamanashi.jp", - "tsuru.yamanashi.jp", - "uenohara.yamanashi.jp", - "yamanakako.yamanashi.jp", - "yamanashi.yamanashi.jp", - "*.ke", - "kg", - "org.kg", - "net.kg", - "com.kg", - "edu.kg", - "gov.kg", - "mil.kg", - "*.kh", - "ki", - "edu.ki", - "biz.ki", - "net.ki", - "org.ki", - "gov.ki", - "info.ki", - "com.ki", - "km", - "org.km", - "nom.km", - "gov.km", - "prd.km", - "tm.km", - "edu.km", - "mil.km", - "ass.km", - "com.km", - "coop.km", - "asso.km", - "presse.km", - "medecin.km", - "notaires.km", - "pharmaciens.km", - "veterinaire.km", - "gouv.km", - "kn", - "net.kn", - "org.kn", - "edu.kn", - "gov.kn", - "kp", - "com.kp", - "edu.kp", - "gov.kp", - "org.kp", - "rep.kp", - "tra.kp", - "kr", - "ac.kr", - "co.kr", - "es.kr", - "go.kr", - "hs.kr", - "kg.kr", - "mil.kr", - "ms.kr", - "ne.kr", - "or.kr", - "pe.kr", - "re.kr", - "sc.kr", - "busan.kr", - "chungbuk.kr", - "chungnam.kr", - "daegu.kr", - "daejeon.kr", - "gangwon.kr", - "gwangju.kr", - "gyeongbuk.kr", - "gyeonggi.kr", - "gyeongnam.kr", - "incheon.kr", - "jeju.kr", - "jeonbuk.kr", - "jeonnam.kr", - "seoul.kr", - "ulsan.kr", - "*.kw", - "ky", - "edu.ky", - "gov.ky", - "com.ky", - "org.ky", - "net.ky", - "kz", - "org.kz", - "edu.kz", - "net.kz", - "gov.kz", - "mil.kz", - "com.kz", - "la", - "int.la", - "net.la", - "info.la", - "edu.la", - "gov.la", - "per.la", - "com.la", - "org.la", - "lb", - "com.lb", - "edu.lb", - "gov.lb", - "net.lb", - "org.lb", - "lc", - "com.lc", - "net.lc", - "co.lc", - "org.lc", - "edu.lc", - "gov.lc", - "li", - "lk", - "gov.lk", - "sch.lk", - "net.lk", - "int.lk", - "com.lk", - "org.lk", - "edu.lk", - "ngo.lk", - "soc.lk", - "web.lk", - "ltd.lk", - "assn.lk", - "grp.lk", - "hotel.lk", - "ac.lk", - "lr", - "com.lr", - "edu.lr", - "gov.lr", - "org.lr", - "net.lr", - "ls", - "co.ls", - "org.ls", - "lt", - "gov.lt", - "lu", - "lv", - "com.lv", - "edu.lv", - "gov.lv", - "org.lv", - "mil.lv", - "id.lv", - "net.lv", - "asn.lv", - "conf.lv", - "ly", - "com.ly", - "net.ly", - "gov.ly", - "plc.ly", - "edu.ly", - "sch.ly", - "med.ly", - "org.ly", - "id.ly", - "ma", - "co.ma", - "net.ma", - "gov.ma", - "org.ma", - "ac.ma", - "press.ma", - "mc", - "tm.mc", - "asso.mc", - "md", - "me", - "co.me", - "net.me", - "org.me", - "edu.me", - "ac.me", - "gov.me", - "its.me", - "priv.me", - "mg", - "org.mg", - "nom.mg", - "gov.mg", - "prd.mg", - "tm.mg", - "edu.mg", - "mil.mg", - "com.mg", - "co.mg", - "mh", - "mil", - "mk", - "com.mk", - "org.mk", - "net.mk", - "edu.mk", - "gov.mk", - "inf.mk", - "name.mk", - "ml", - "com.ml", - "edu.ml", - "gouv.ml", - "gov.ml", - "net.ml", - "org.ml", - "presse.ml", - "*.mm", - "mn", - "gov.mn", - "edu.mn", - "org.mn", - "mo", - "com.mo", - "net.mo", - "org.mo", - "edu.mo", - "gov.mo", - "mobi", - "mp", - "mq", - "mr", - "gov.mr", - "ms", - "com.ms", - "edu.ms", - "gov.ms", - "net.ms", - "org.ms", - "mt", - "com.mt", - "edu.mt", - "net.mt", - "org.mt", - "mu", - "com.mu", - "net.mu", - "org.mu", - "gov.mu", - "ac.mu", - "co.mu", - "or.mu", - "museum", - "academy.museum", - "agriculture.museum", - "air.museum", - "airguard.museum", - "alabama.museum", - "alaska.museum", - "amber.museum", - "ambulance.museum", - "american.museum", - "americana.museum", - "americanantiques.museum", - "americanart.museum", - "amsterdam.museum", - "and.museum", - "annefrank.museum", - "anthro.museum", - "anthropology.museum", - "antiques.museum", - "aquarium.museum", - "arboretum.museum", - "archaeological.museum", - "archaeology.museum", - "architecture.museum", - "art.museum", - "artanddesign.museum", - "artcenter.museum", - "artdeco.museum", - "arteducation.museum", - "artgallery.museum", - "arts.museum", - "artsandcrafts.museum", - "asmatart.museum", - "assassination.museum", - "assisi.museum", - "association.museum", - "astronomy.museum", - "atlanta.museum", - "austin.museum", - "australia.museum", - "automotive.museum", - "aviation.museum", - "axis.museum", - "badajoz.museum", - "baghdad.museum", - "bahn.museum", - "bale.museum", - "baltimore.museum", - "barcelona.museum", - "baseball.museum", - "basel.museum", - "baths.museum", - "bauern.museum", - "beauxarts.museum", - "beeldengeluid.museum", - "bellevue.museum", - "bergbau.museum", - "berkeley.museum", - "berlin.museum", - "bern.museum", - "bible.museum", - "bilbao.museum", - "bill.museum", - "birdart.museum", - "birthplace.museum", - "bonn.museum", - "boston.museum", - "botanical.museum", - "botanicalgarden.museum", - "botanicgarden.museum", - "botany.museum", - "brandywinevalley.museum", - "brasil.museum", - "bristol.museum", - "british.museum", - "britishcolumbia.museum", - "broadcast.museum", - "brunel.museum", - "brussel.museum", - "brussels.museum", - "bruxelles.museum", - "building.museum", - "burghof.museum", - "bus.museum", - "bushey.museum", - "cadaques.museum", - "california.museum", - "cambridge.museum", - "can.museum", - "canada.museum", - "capebreton.museum", - "carrier.museum", - "cartoonart.museum", - "casadelamoneda.museum", - "castle.museum", - "castres.museum", - "celtic.museum", - "center.museum", - "chattanooga.museum", - "cheltenham.museum", - "chesapeakebay.museum", - "chicago.museum", - "children.museum", - "childrens.museum", - "childrensgarden.museum", - "chiropractic.museum", - "chocolate.museum", - "christiansburg.museum", - "cincinnati.museum", - "cinema.museum", - "circus.museum", - "civilisation.museum", - "civilization.museum", - "civilwar.museum", - "clinton.museum", - "clock.museum", - "coal.museum", - "coastaldefence.museum", - "cody.museum", - "coldwar.museum", - "collection.museum", - "colonialwilliamsburg.museum", - "coloradoplateau.museum", - "columbia.museum", - "columbus.museum", - "communication.museum", - "communications.museum", - "community.museum", - "computer.museum", - "computerhistory.museum", - "xn--comunicaes-v6a2o.museum", - "contemporary.museum", - "contemporaryart.museum", - "convent.museum", - "copenhagen.museum", - "corporation.museum", - "xn--correios-e-telecomunicaes-ghc29a.museum", - "corvette.museum", - "costume.museum", - "countryestate.museum", - "county.museum", - "crafts.museum", - "cranbrook.museum", - "creation.museum", - "cultural.museum", - "culturalcenter.museum", - "culture.museum", - "cyber.museum", - "cymru.museum", - "dali.museum", - "dallas.museum", - "database.museum", - "ddr.museum", - "decorativearts.museum", - "delaware.museum", - "delmenhorst.museum", - "denmark.museum", - "depot.museum", - "design.museum", - "detroit.museum", - "dinosaur.museum", - "discovery.museum", - "dolls.museum", - "donostia.museum", - "durham.museum", - "eastafrica.museum", - "eastcoast.museum", - "education.museum", - "educational.museum", - "egyptian.museum", - "eisenbahn.museum", - "elburg.museum", - "elvendrell.museum", - "embroidery.museum", - "encyclopedic.museum", - "england.museum", - "entomology.museum", - "environment.museum", - "environmentalconservation.museum", - "epilepsy.museum", - "essex.museum", - "estate.museum", - "ethnology.museum", - "exeter.museum", - "exhibition.museum", - "family.museum", - "farm.museum", - "farmequipment.museum", - "farmers.museum", - "farmstead.museum", - "field.museum", - "figueres.museum", - "filatelia.museum", - "film.museum", - "fineart.museum", - "finearts.museum", - "finland.museum", - "flanders.museum", - "florida.museum", - "force.museum", - "fortmissoula.museum", - "fortworth.museum", - "foundation.museum", - "francaise.museum", - "frankfurt.museum", - "franziskaner.museum", - "freemasonry.museum", - "freiburg.museum", - "fribourg.museum", - "frog.museum", - "fundacio.museum", - "furniture.museum", - "gallery.museum", - "garden.museum", - "gateway.museum", - "geelvinck.museum", - "gemological.museum", - "geology.museum", - "georgia.museum", - "giessen.museum", - "glas.museum", - "glass.museum", - "gorge.museum", - "grandrapids.museum", - "graz.museum", - "guernsey.museum", - "halloffame.museum", - "hamburg.museum", - "handson.museum", - "harvestcelebration.museum", - "hawaii.museum", - "health.museum", - "heimatunduhren.museum", - "hellas.museum", - "helsinki.museum", - "hembygdsforbund.museum", - "heritage.museum", - "histoire.museum", - "historical.museum", - "historicalsociety.museum", - "historichouses.museum", - "historisch.museum", - "historisches.museum", - "history.museum", - "historyofscience.museum", - "horology.museum", - "house.museum", - "humanities.museum", - "illustration.museum", - "imageandsound.museum", - "indian.museum", - "indiana.museum", - "indianapolis.museum", - "indianmarket.museum", - "intelligence.museum", - "interactive.museum", - "iraq.museum", - "iron.museum", - "isleofman.museum", - "jamison.museum", - "jefferson.museum", - "jerusalem.museum", - "jewelry.museum", - "jewish.museum", - "jewishart.museum", - "jfk.museum", - "journalism.museum", - "judaica.museum", - "judygarland.museum", - "juedisches.museum", - "juif.museum", - "karate.museum", - "karikatur.museum", - "kids.museum", - "koebenhavn.museum", - "koeln.museum", - "kunst.museum", - "kunstsammlung.museum", - "kunstunddesign.museum", - "labor.museum", - "labour.museum", - "lajolla.museum", - "lancashire.museum", - "landes.museum", - "lans.museum", - "xn--lns-qla.museum", - "larsson.museum", - "lewismiller.museum", - "lincoln.museum", - "linz.museum", - "living.museum", - "livinghistory.museum", - "localhistory.museum", - "london.museum", - "losangeles.museum", - "louvre.museum", - "loyalist.museum", - "lucerne.museum", - "luxembourg.museum", - "luzern.museum", - "mad.museum", - "madrid.museum", - "mallorca.museum", - "manchester.museum", - "mansion.museum", - "mansions.museum", - "manx.museum", - "marburg.museum", - "maritime.museum", - "maritimo.museum", - "maryland.museum", - "marylhurst.museum", - "media.museum", - "medical.museum", - "medizinhistorisches.museum", - "meeres.museum", - "memorial.museum", - "mesaverde.museum", - "michigan.museum", - "midatlantic.museum", - "military.museum", - "mill.museum", - "miners.museum", - "mining.museum", - "minnesota.museum", - "missile.museum", - "missoula.museum", - "modern.museum", - "moma.museum", - "money.museum", - "monmouth.museum", - "monticello.museum", - "montreal.museum", - "moscow.museum", - "motorcycle.museum", - "muenchen.museum", - "muenster.museum", - "mulhouse.museum", - "muncie.museum", - "museet.museum", - "museumcenter.museum", - "museumvereniging.museum", - "music.museum", - "national.museum", - "nationalfirearms.museum", - "nationalheritage.museum", - "nativeamerican.museum", - "naturalhistory.museum", - "naturalhistorymuseum.museum", - "naturalsciences.museum", - "nature.museum", - "naturhistorisches.museum", - "natuurwetenschappen.museum", - "naumburg.museum", - "naval.museum", - "nebraska.museum", - "neues.museum", - "newhampshire.museum", - "newjersey.museum", - "newmexico.museum", - "newport.museum", - "newspaper.museum", - "newyork.museum", - "niepce.museum", - "norfolk.museum", - "north.museum", - "nrw.museum", - "nuernberg.museum", - "nuremberg.museum", - "nyc.museum", - "nyny.museum", - "oceanographic.museum", - "oceanographique.museum", - "omaha.museum", - "online.museum", - "ontario.museum", - "openair.museum", - "oregon.museum", - "oregontrail.museum", - "otago.museum", - "oxford.museum", - "pacific.museum", - "paderborn.museum", - "palace.museum", - "paleo.museum", - "palmsprings.museum", - "panama.museum", - "paris.museum", - "pasadena.museum", - "pharmacy.museum", - "philadelphia.museum", - "philadelphiaarea.museum", - "philately.museum", - "phoenix.museum", - "photography.museum", - "pilots.museum", - "pittsburgh.museum", - "planetarium.museum", - "plantation.museum", - "plants.museum", - "plaza.museum", - "portal.museum", - "portland.museum", - "portlligat.museum", - "posts-and-telecommunications.museum", - "preservation.museum", - "presidio.museum", - "press.museum", - "project.museum", - "public.museum", - "pubol.museum", - "quebec.museum", - "railroad.museum", - "railway.museum", - "research.museum", - "resistance.museum", - "riodejaneiro.museum", - "rochester.museum", - "rockart.museum", - "roma.museum", - "russia.museum", - "saintlouis.museum", - "salem.museum", - "salvadordali.museum", - "salzburg.museum", - "sandiego.museum", - "sanfrancisco.museum", - "santabarbara.museum", - "santacruz.museum", - "santafe.museum", - "saskatchewan.museum", - "satx.museum", - "savannahga.museum", - "schlesisches.museum", - "schoenbrunn.museum", - "schokoladen.museum", - "school.museum", - "schweiz.museum", - "science.museum", - "scienceandhistory.museum", - "scienceandindustry.museum", - "sciencecenter.museum", - "sciencecenters.museum", - "science-fiction.museum", - "sciencehistory.museum", - "sciences.museum", - "sciencesnaturelles.museum", - "scotland.museum", - "seaport.museum", - "settlement.museum", - "settlers.museum", - "shell.museum", - "sherbrooke.museum", - "sibenik.museum", - "silk.museum", - "ski.museum", - "skole.museum", - "society.museum", - "sologne.museum", - "soundandvision.museum", - "southcarolina.museum", - "southwest.museum", - "space.museum", - "spy.museum", - "square.museum", - "stadt.museum", - "stalbans.museum", - "starnberg.museum", - "state.museum", - "stateofdelaware.museum", - "station.museum", - "steam.museum", - "steiermark.museum", - "stjohn.museum", - "stockholm.museum", - "stpetersburg.museum", - "stuttgart.museum", - "suisse.museum", - "surgeonshall.museum", - "surrey.museum", - "svizzera.museum", - "sweden.museum", - "sydney.museum", - "tank.museum", - "tcm.museum", - "technology.museum", - "telekommunikation.museum", - "television.museum", - "texas.museum", - "textile.museum", - "theater.museum", - "time.museum", - "timekeeping.museum", - "topology.museum", - "torino.museum", - "touch.museum", - "town.museum", - "transport.museum", - "tree.museum", - "trolley.museum", - "trust.museum", - "trustee.museum", - "uhren.museum", - "ulm.museum", - "undersea.museum", - "university.museum", - "usa.museum", - "usantiques.museum", - "usarts.museum", - "uscountryestate.museum", - "usculture.museum", - "usdecorativearts.museum", - "usgarden.museum", - "ushistory.museum", - "ushuaia.museum", - "uslivinghistory.museum", - "utah.museum", - "uvic.museum", - "valley.museum", - "vantaa.museum", - "versailles.museum", - "viking.museum", - "village.museum", - "virginia.museum", - "virtual.museum", - "virtuel.museum", - "vlaanderen.museum", - "volkenkunde.museum", - "wales.museum", - "wallonie.museum", - "war.museum", - "washingtondc.museum", - "watchandclock.museum", - "watch-and-clock.museum", - "western.museum", - "westfalen.museum", - "whaling.museum", - "wildlife.museum", - "williamsburg.museum", - "windmill.museum", - "workshop.museum", - "york.museum", - "yorkshire.museum", - "yosemite.museum", - "youth.museum", - "zoological.museum", - "zoology.museum", - "xn--9dbhblg6di.museum", - "xn--h1aegh.museum", - "mv", - "aero.mv", - "biz.mv", - "com.mv", - "coop.mv", - "edu.mv", - "gov.mv", - "info.mv", - "int.mv", - "mil.mv", - "museum.mv", - "name.mv", - "net.mv", - "org.mv", - "pro.mv", - "mw", - "ac.mw", - "biz.mw", - "co.mw", - "com.mw", - "coop.mw", - "edu.mw", - "gov.mw", - "int.mw", - "museum.mw", - "net.mw", - "org.mw", - "mx", - "com.mx", - "org.mx", - "gob.mx", - "edu.mx", - "net.mx", - "my", - "com.my", - "net.my", - "org.my", - "gov.my", - "edu.my", - "mil.my", - "name.my", - "mz", - "ac.mz", - "adv.mz", - "co.mz", - "edu.mz", - "gov.mz", - "mil.mz", - "net.mz", - "org.mz", - "na", - "info.na", - "pro.na", - "name.na", - "school.na", - "or.na", - "dr.na", - "us.na", - "mx.na", - "ca.na", - "in.na", - "cc.na", - "tv.na", - "ws.na", - "mobi.na", - "co.na", - "com.na", - "org.na", - "name", - "nc", - "asso.nc", - "ne", - "net", - "nf", - "com.nf", - "net.nf", - "per.nf", - "rec.nf", - "web.nf", - "arts.nf", - "firm.nf", - "info.nf", - "other.nf", - "store.nf", - "ng", - "com.ng", - "edu.ng", - "gov.ng", - "i.ng", - "mil.ng", - "mobi.ng", - "name.ng", - "net.ng", - "org.ng", - "sch.ng", - "ni", - "ac.ni", - "biz.ni", - "co.ni", - "com.ni", - "edu.ni", - "gob.ni", - "in.ni", - "info.ni", - "int.ni", - "mil.ni", - "net.ni", - "nom.ni", - "org.ni", - "web.ni", - "nl", - "bv.nl", - "no", - "fhs.no", - "vgs.no", - "fylkesbibl.no", - "folkebibl.no", - "museum.no", - "idrett.no", - "priv.no", - "mil.no", - "stat.no", - "dep.no", - "kommune.no", - "herad.no", - "aa.no", - "ah.no", - "bu.no", - "fm.no", - "hl.no", - "hm.no", - "jan-mayen.no", - "mr.no", - "nl.no", - "nt.no", - "of.no", - "ol.no", - "oslo.no", - "rl.no", - "sf.no", - "st.no", - "svalbard.no", - "tm.no", - "tr.no", - "va.no", - "vf.no", - "gs.aa.no", - "gs.ah.no", - "gs.bu.no", - "gs.fm.no", - "gs.hl.no", - "gs.hm.no", - "gs.jan-mayen.no", - "gs.mr.no", - "gs.nl.no", - "gs.nt.no", - "gs.of.no", - "gs.ol.no", - "gs.oslo.no", - "gs.rl.no", - "gs.sf.no", - "gs.st.no", - "gs.svalbard.no", - "gs.tm.no", - "gs.tr.no", - "gs.va.no", - "gs.vf.no", - "akrehamn.no", - "xn--krehamn-dxa.no", - "algard.no", - "xn--lgrd-poac.no", - "arna.no", - "brumunddal.no", - "bryne.no", - "bronnoysund.no", - "xn--brnnysund-m8ac.no", - "drobak.no", - "xn--drbak-wua.no", - "egersund.no", - "fetsund.no", - "floro.no", - "xn--flor-jra.no", - "fredrikstad.no", - "hokksund.no", - "honefoss.no", - "xn--hnefoss-q1a.no", - "jessheim.no", - "jorpeland.no", - "xn--jrpeland-54a.no", - "kirkenes.no", - "kopervik.no", - "krokstadelva.no", - "langevag.no", - "xn--langevg-jxa.no", - "leirvik.no", - "mjondalen.no", - "xn--mjndalen-64a.no", - "mo-i-rana.no", - "mosjoen.no", - "xn--mosjen-eya.no", - "nesoddtangen.no", - "orkanger.no", - "osoyro.no", - "xn--osyro-wua.no", - "raholt.no", - "xn--rholt-mra.no", - "sandnessjoen.no", - "xn--sandnessjen-ogb.no", - "skedsmokorset.no", - "slattum.no", - "spjelkavik.no", - "stathelle.no", - "stavern.no", - "stjordalshalsen.no", - "xn--stjrdalshalsen-sqb.no", - "tananger.no", - "tranby.no", - "vossevangen.no", - "afjord.no", - "xn--fjord-lra.no", - "agdenes.no", - "al.no", - "xn--l-1fa.no", - "alesund.no", - "xn--lesund-hua.no", - "alstahaug.no", - "alta.no", - "xn--lt-liac.no", - "alaheadju.no", - "xn--laheadju-7ya.no", - "alvdal.no", - "amli.no", - "xn--mli-tla.no", - "amot.no", - "xn--mot-tla.no", - "andebu.no", - "andoy.no", - "xn--andy-ira.no", - "andasuolo.no", - "ardal.no", - "xn--rdal-poa.no", - "aremark.no", - "arendal.no", - "xn--s-1fa.no", - "aseral.no", - "xn--seral-lra.no", - "asker.no", - "askim.no", - "askvoll.no", - "askoy.no", - "xn--asky-ira.no", - "asnes.no", - "xn--snes-poa.no", - "audnedaln.no", - "aukra.no", - "aure.no", - "aurland.no", - "aurskog-holand.no", - "xn--aurskog-hland-jnb.no", - "austevoll.no", - "austrheim.no", - "averoy.no", - "xn--avery-yua.no", - "balestrand.no", - "ballangen.no", - "balat.no", - "xn--blt-elab.no", - "balsfjord.no", - "bahccavuotna.no", - "xn--bhccavuotna-k7a.no", - "bamble.no", - "bardu.no", - "beardu.no", - "beiarn.no", - "bajddar.no", - "xn--bjddar-pta.no", - "baidar.no", - "xn--bidr-5nac.no", - "berg.no", - "bergen.no", - "berlevag.no", - "xn--berlevg-jxa.no", - "bearalvahki.no", - "xn--bearalvhki-y4a.no", - "bindal.no", - "birkenes.no", - "bjarkoy.no", - "xn--bjarky-fya.no", - "bjerkreim.no", - "bjugn.no", - "bodo.no", - "xn--bod-2na.no", - "badaddja.no", - "xn--bdddj-mrabd.no", - "budejju.no", - "bokn.no", - "bremanger.no", - "bronnoy.no", - "xn--brnny-wuac.no", - "bygland.no", - "bykle.no", - "barum.no", - "xn--brum-voa.no", - "bo.telemark.no", - "xn--b-5ga.telemark.no", - "bo.nordland.no", - "xn--b-5ga.nordland.no", - "bievat.no", - "xn--bievt-0qa.no", - "bomlo.no", - "xn--bmlo-gra.no", - "batsfjord.no", - "xn--btsfjord-9za.no", - "bahcavuotna.no", - "xn--bhcavuotna-s4a.no", - "dovre.no", - "drammen.no", - "drangedal.no", - "dyroy.no", - "xn--dyry-ira.no", - "donna.no", - "xn--dnna-gra.no", - "eid.no", - "eidfjord.no", - "eidsberg.no", - "eidskog.no", - "eidsvoll.no", - "eigersund.no", - "elverum.no", - "enebakk.no", - "engerdal.no", - "etne.no", - "etnedal.no", - "evenes.no", - "evenassi.no", - "xn--eveni-0qa01ga.no", - "evje-og-hornnes.no", - "farsund.no", - "fauske.no", - "fuossko.no", - "fuoisku.no", - "fedje.no", - "fet.no", - "finnoy.no", - "xn--finny-yua.no", - "fitjar.no", - "fjaler.no", - "fjell.no", - "flakstad.no", - "flatanger.no", - "flekkefjord.no", - "flesberg.no", - "flora.no", - "fla.no", - "xn--fl-zia.no", - "folldal.no", - "forsand.no", - "fosnes.no", - "frei.no", - "frogn.no", - "froland.no", - "frosta.no", - "frana.no", - "xn--frna-woa.no", - "froya.no", - "xn--frya-hra.no", - "fusa.no", - "fyresdal.no", - "forde.no", - "xn--frde-gra.no", - "gamvik.no", - "gangaviika.no", - "xn--ggaviika-8ya47h.no", - "gaular.no", - "gausdal.no", - "gildeskal.no", - "xn--gildeskl-g0a.no", - "giske.no", - "gjemnes.no", - "gjerdrum.no", - "gjerstad.no", - "gjesdal.no", - "gjovik.no", - "xn--gjvik-wua.no", - "gloppen.no", - "gol.no", - "gran.no", - "grane.no", - "granvin.no", - "gratangen.no", - "grimstad.no", - "grong.no", - "kraanghke.no", - "xn--kranghke-b0a.no", - "grue.no", - "gulen.no", - "hadsel.no", - "halden.no", - "halsa.no", - "hamar.no", - "hamaroy.no", - "habmer.no", - "xn--hbmer-xqa.no", - "hapmir.no", - "xn--hpmir-xqa.no", - "hammerfest.no", - "hammarfeasta.no", - "xn--hmmrfeasta-s4ac.no", - "haram.no", - "hareid.no", - "harstad.no", - "hasvik.no", - "aknoluokta.no", - "xn--koluokta-7ya57h.no", - "hattfjelldal.no", - "aarborte.no", - "haugesund.no", - "hemne.no", - "hemnes.no", - "hemsedal.no", - "heroy.more-og-romsdal.no", - "xn--hery-ira.xn--mre-og-romsdal-qqb.no", - "heroy.nordland.no", - "xn--hery-ira.nordland.no", - "hitra.no", - "hjartdal.no", - "hjelmeland.no", - "hobol.no", - "xn--hobl-ira.no", - "hof.no", - "hol.no", - "hole.no", - "holmestrand.no", - "holtalen.no", - "xn--holtlen-hxa.no", - "hornindal.no", - "horten.no", - "hurdal.no", - "hurum.no", - "hvaler.no", - "hyllestad.no", - "hagebostad.no", - "xn--hgebostad-g3a.no", - "hoyanger.no", - "xn--hyanger-q1a.no", - "hoylandet.no", - "xn--hylandet-54a.no", - "ha.no", - "xn--h-2fa.no", - "ibestad.no", - "inderoy.no", - "xn--indery-fya.no", - "iveland.no", - "jevnaker.no", - "jondal.no", - "jolster.no", - "xn--jlster-bya.no", - "karasjok.no", - "karasjohka.no", - "xn--krjohka-hwab49j.no", - "karlsoy.no", - "galsa.no", - "xn--gls-elac.no", - "karmoy.no", - "xn--karmy-yua.no", - "kautokeino.no", - "guovdageaidnu.no", - "klepp.no", - "klabu.no", - "xn--klbu-woa.no", - "kongsberg.no", - "kongsvinger.no", - "kragero.no", - "xn--krager-gya.no", - "kristiansand.no", - "kristiansund.no", - "krodsherad.no", - "xn--krdsherad-m8a.no", - "kvalsund.no", - "rahkkeravju.no", - "xn--rhkkervju-01af.no", - "kvam.no", - "kvinesdal.no", - "kvinnherad.no", - "kviteseid.no", - "kvitsoy.no", - "xn--kvitsy-fya.no", - "kvafjord.no", - "xn--kvfjord-nxa.no", - "giehtavuoatna.no", - "kvanangen.no", - "xn--kvnangen-k0a.no", - "navuotna.no", - "xn--nvuotna-hwa.no", - "kafjord.no", - "xn--kfjord-iua.no", - "gaivuotna.no", - "xn--givuotna-8ya.no", - "larvik.no", - "lavangen.no", - "lavagis.no", - "loabat.no", - "xn--loabt-0qa.no", - "lebesby.no", - "davvesiida.no", - "leikanger.no", - "leirfjord.no", - "leka.no", - "leksvik.no", - "lenvik.no", - "leangaviika.no", - "xn--leagaviika-52b.no", - "lesja.no", - "levanger.no", - "lier.no", - "lierne.no", - "lillehammer.no", - "lillesand.no", - "lindesnes.no", - "lindas.no", - "xn--linds-pra.no", - "lom.no", - "loppa.no", - "lahppi.no", - "xn--lhppi-xqa.no", - "lund.no", - "lunner.no", - "luroy.no", - "xn--lury-ira.no", - "luster.no", - "lyngdal.no", - "lyngen.no", - "ivgu.no", - "lardal.no", - "lerdal.no", - "xn--lrdal-sra.no", - "lodingen.no", - "xn--ldingen-q1a.no", - "lorenskog.no", - "xn--lrenskog-54a.no", - "loten.no", - "xn--lten-gra.no", - "malvik.no", - "masoy.no", - "xn--msy-ula0h.no", - "muosat.no", - "xn--muost-0qa.no", - "mandal.no", - "marker.no", - "marnardal.no", - "masfjorden.no", - "meland.no", - "meldal.no", - "melhus.no", - "meloy.no", - "xn--mely-ira.no", - "meraker.no", - "xn--merker-kua.no", - "moareke.no", - "xn--moreke-jua.no", - "midsund.no", - "midtre-gauldal.no", - "modalen.no", - "modum.no", - "molde.no", - "moskenes.no", - "moss.no", - "mosvik.no", - "malselv.no", - "xn--mlselv-iua.no", - "malatvuopmi.no", - "xn--mlatvuopmi-s4a.no", - "namdalseid.no", - "aejrie.no", - "namsos.no", - "namsskogan.no", - "naamesjevuemie.no", - "xn--nmesjevuemie-tcba.no", - "laakesvuemie.no", - "nannestad.no", - "narvik.no", - "narviika.no", - "naustdal.no", - "nedre-eiker.no", - "nes.akershus.no", - "nes.buskerud.no", - "nesna.no", - "nesodden.no", - "nesseby.no", - "unjarga.no", - "xn--unjrga-rta.no", - "nesset.no", - "nissedal.no", - "nittedal.no", - "nord-aurdal.no", - "nord-fron.no", - "nord-odal.no", - "norddal.no", - "nordkapp.no", - "davvenjarga.no", - "xn--davvenjrga-y4a.no", - "nordre-land.no", - "nordreisa.no", - "raisa.no", - "xn--risa-5na.no", - "nore-og-uvdal.no", - "notodden.no", - "naroy.no", - "xn--nry-yla5g.no", - "notteroy.no", - "xn--nttery-byae.no", - "odda.no", - "oksnes.no", - "xn--ksnes-uua.no", - "oppdal.no", - "oppegard.no", - "xn--oppegrd-ixa.no", - "orkdal.no", - "orland.no", - "xn--rland-uua.no", - "orskog.no", - "xn--rskog-uua.no", - "orsta.no", - "xn--rsta-fra.no", - "os.hedmark.no", - "os.hordaland.no", - "osen.no", - "osteroy.no", - "xn--ostery-fya.no", - "ostre-toten.no", - "xn--stre-toten-zcb.no", - "overhalla.no", - "ovre-eiker.no", - "xn--vre-eiker-k8a.no", - "oyer.no", - "xn--yer-zna.no", - "oygarden.no", - "xn--ygarden-p1a.no", - "oystre-slidre.no", - "xn--ystre-slidre-ujb.no", - "porsanger.no", - "porsangu.no", - "xn--porsgu-sta26f.no", - "porsgrunn.no", - "radoy.no", - "xn--rady-ira.no", - "rakkestad.no", - "rana.no", - "ruovat.no", - "randaberg.no", - "rauma.no", - "rendalen.no", - "rennebu.no", - "rennesoy.no", - "xn--rennesy-v1a.no", - "rindal.no", - "ringebu.no", - "ringerike.no", - "ringsaker.no", - "rissa.no", - "risor.no", - "xn--risr-ira.no", - "roan.no", - "rollag.no", - "rygge.no", - "ralingen.no", - "xn--rlingen-mxa.no", - "rodoy.no", - "xn--rdy-0nab.no", - "romskog.no", - "xn--rmskog-bya.no", - "roros.no", - "xn--rros-gra.no", - "rost.no", - "xn--rst-0na.no", - "royken.no", - "xn--ryken-vua.no", - "royrvik.no", - "xn--ryrvik-bya.no", - "rade.no", - "xn--rde-ula.no", - "salangen.no", - "siellak.no", - "saltdal.no", - "salat.no", - "xn--slt-elab.no", - "xn--slat-5na.no", - "samnanger.no", - "sande.more-og-romsdal.no", - "sande.xn--mre-og-romsdal-qqb.no", - "sande.vestfold.no", - "sandefjord.no", - "sandnes.no", - "sandoy.no", - "xn--sandy-yua.no", - "sarpsborg.no", - "sauda.no", - "sauherad.no", - "sel.no", - "selbu.no", - "selje.no", - "seljord.no", - "sigdal.no", - "siljan.no", - "sirdal.no", - "skaun.no", - "skedsmo.no", - "ski.no", - "skien.no", - "skiptvet.no", - "skjervoy.no", - "xn--skjervy-v1a.no", - "skierva.no", - "xn--skierv-uta.no", - "skjak.no", - "xn--skjk-soa.no", - "skodje.no", - "skanland.no", - "xn--sknland-fxa.no", - "skanit.no", - "xn--sknit-yqa.no", - "smola.no", - "xn--smla-hra.no", - "snillfjord.no", - "snasa.no", - "xn--snsa-roa.no", - "snoasa.no", - "snaase.no", - "xn--snase-nra.no", - "sogndal.no", - "sokndal.no", - "sola.no", - "solund.no", - "songdalen.no", - "sortland.no", - "spydeberg.no", - "stange.no", - "stavanger.no", - "steigen.no", - "steinkjer.no", - "stjordal.no", - "xn--stjrdal-s1a.no", - "stokke.no", - "stor-elvdal.no", - "stord.no", - "stordal.no", - "storfjord.no", - "omasvuotna.no", - "strand.no", - "stranda.no", - "stryn.no", - "sula.no", - "suldal.no", - "sund.no", - "sunndal.no", - "surnadal.no", - "sveio.no", - "svelvik.no", - "sykkylven.no", - "sogne.no", - "xn--sgne-gra.no", - "somna.no", - "xn--smna-gra.no", - "sondre-land.no", - "xn--sndre-land-0cb.no", - "sor-aurdal.no", - "xn--sr-aurdal-l8a.no", - "sor-fron.no", - "xn--sr-fron-q1a.no", - "sor-odal.no", - "xn--sr-odal-q1a.no", - "sor-varanger.no", - "xn--sr-varanger-ggb.no", - "matta-varjjat.no", - "xn--mtta-vrjjat-k7af.no", - "sorfold.no", - "xn--srfold-bya.no", - "sorreisa.no", - "xn--srreisa-q1a.no", - "sorum.no", - "xn--srum-gra.no", - "tana.no", - "deatnu.no", - "time.no", - "tingvoll.no", - "tinn.no", - "tjeldsund.no", - "dielddanuorri.no", - "tjome.no", - "xn--tjme-hra.no", - "tokke.no", - "tolga.no", - "torsken.no", - "tranoy.no", - "xn--trany-yua.no", - "tromso.no", - "xn--troms-zua.no", - "tromsa.no", - "romsa.no", - "trondheim.no", - "troandin.no", - "trysil.no", - "trana.no", - "xn--trna-woa.no", - "trogstad.no", - "xn--trgstad-r1a.no", - "tvedestrand.no", - "tydal.no", - "tynset.no", - "tysfjord.no", - "divtasvuodna.no", - "divttasvuotna.no", - "tysnes.no", - "tysvar.no", - "xn--tysvr-vra.no", - "tonsberg.no", - "xn--tnsberg-q1a.no", - "ullensaker.no", - "ullensvang.no", - "ulvik.no", - "utsira.no", - "vadso.no", - "xn--vads-jra.no", - "cahcesuolo.no", - "xn--hcesuolo-7ya35b.no", - "vaksdal.no", - "valle.no", - "vang.no", - "vanylven.no", - "vardo.no", - "xn--vard-jra.no", - "varggat.no", - "xn--vrggt-xqad.no", - "vefsn.no", - "vaapste.no", - "vega.no", - "vegarshei.no", - "xn--vegrshei-c0a.no", - "vennesla.no", - "verdal.no", - "verran.no", - "vestby.no", - "vestnes.no", - "vestre-slidre.no", - "vestre-toten.no", - "vestvagoy.no", - "xn--vestvgy-ixa6o.no", - "vevelstad.no", - "vik.no", - "vikna.no", - "vindafjord.no", - "volda.no", - "voss.no", - "varoy.no", - "xn--vry-yla5g.no", - "vagan.no", - "xn--vgan-qoa.no", - "voagat.no", - "vagsoy.no", - "xn--vgsy-qoa0j.no", - "vaga.no", - "xn--vg-yiab.no", - "valer.ostfold.no", - "xn--vler-qoa.xn--stfold-9xa.no", - "valer.hedmark.no", - "xn--vler-qoa.hedmark.no", - "*.np", - "nr", - "biz.nr", - "info.nr", - "gov.nr", - "edu.nr", - "org.nr", - "net.nr", - "com.nr", - "nu", - "nz", - "ac.nz", - "co.nz", - "cri.nz", - "geek.nz", - "gen.nz", - "govt.nz", - "health.nz", - "iwi.nz", - "kiwi.nz", - "maori.nz", - "mil.nz", - "xn--mori-qsa.nz", - "net.nz", - "org.nz", - "parliament.nz", - "school.nz", - "om", - "co.om", - "com.om", - "edu.om", - "gov.om", - "med.om", - "museum.om", - "net.om", - "org.om", - "pro.om", - "onion", - "org", - "pa", - "ac.pa", - "gob.pa", - "com.pa", - "org.pa", - "sld.pa", - "edu.pa", - "net.pa", - "ing.pa", - "abo.pa", - "med.pa", - "nom.pa", - "pe", - "edu.pe", - "gob.pe", - "nom.pe", - "mil.pe", - "org.pe", - "com.pe", - "net.pe", - "pf", - "com.pf", - "org.pf", - "edu.pf", - "*.pg", - "ph", - "com.ph", - "net.ph", - "org.ph", - "gov.ph", - "edu.ph", - "ngo.ph", - "mil.ph", - "i.ph", - "pk", - "com.pk", - "net.pk", - "edu.pk", - "org.pk", - "fam.pk", - "biz.pk", - "web.pk", - "gov.pk", - "gob.pk", - "gok.pk", - "gon.pk", - "gop.pk", - "gos.pk", - "info.pk", - "pl", - "com.pl", - "net.pl", - "org.pl", - "aid.pl", - "agro.pl", - "atm.pl", - "auto.pl", - "biz.pl", - "edu.pl", - "gmina.pl", - "gsm.pl", - "info.pl", - "mail.pl", - "miasta.pl", - "media.pl", - "mil.pl", - "nieruchomosci.pl", - "nom.pl", - "pc.pl", - "powiat.pl", - "priv.pl", - "realestate.pl", - "rel.pl", - "sex.pl", - "shop.pl", - "sklep.pl", - "sos.pl", - "szkola.pl", - "targi.pl", - "tm.pl", - "tourism.pl", - "travel.pl", - "turystyka.pl", - "gov.pl", - "ap.gov.pl", - "ic.gov.pl", - "is.gov.pl", - "us.gov.pl", - "kmpsp.gov.pl", - "kppsp.gov.pl", - "kwpsp.gov.pl", - "psp.gov.pl", - "wskr.gov.pl", - "kwp.gov.pl", - "mw.gov.pl", - "ug.gov.pl", - "um.gov.pl", - "umig.gov.pl", - "ugim.gov.pl", - "upow.gov.pl", - "uw.gov.pl", - "starostwo.gov.pl", - "pa.gov.pl", - "po.gov.pl", - "psse.gov.pl", - "pup.gov.pl", - "rzgw.gov.pl", - "sa.gov.pl", - "so.gov.pl", - "sr.gov.pl", - "wsa.gov.pl", - "sko.gov.pl", - "uzs.gov.pl", - "wiih.gov.pl", - "winb.gov.pl", - "pinb.gov.pl", - "wios.gov.pl", - "witd.gov.pl", - "wzmiuw.gov.pl", - "piw.gov.pl", - "wiw.gov.pl", - "griw.gov.pl", - "wif.gov.pl", - "oum.gov.pl", - "sdn.gov.pl", - "zp.gov.pl", - "uppo.gov.pl", - "mup.gov.pl", - "wuoz.gov.pl", - "konsulat.gov.pl", - "oirm.gov.pl", - "augustow.pl", - "babia-gora.pl", - "bedzin.pl", - "beskidy.pl", - "bialowieza.pl", - "bialystok.pl", - "bielawa.pl", - "bieszczady.pl", - "boleslawiec.pl", - "bydgoszcz.pl", - "bytom.pl", - "cieszyn.pl", - "czeladz.pl", - "czest.pl", - "dlugoleka.pl", - "elblag.pl", - "elk.pl", - "glogow.pl", - "gniezno.pl", - "gorlice.pl", - "grajewo.pl", - "ilawa.pl", - "jaworzno.pl", - "jelenia-gora.pl", - "jgora.pl", - "kalisz.pl", - "kazimierz-dolny.pl", - "karpacz.pl", - "kartuzy.pl", - "kaszuby.pl", - "katowice.pl", - "kepno.pl", - "ketrzyn.pl", - "klodzko.pl", - "kobierzyce.pl", - "kolobrzeg.pl", - "konin.pl", - "konskowola.pl", - "kutno.pl", - "lapy.pl", - "lebork.pl", - "legnica.pl", - "lezajsk.pl", - "limanowa.pl", - "lomza.pl", - "lowicz.pl", - "lubin.pl", - "lukow.pl", - "malbork.pl", - "malopolska.pl", - "mazowsze.pl", - "mazury.pl", - "mielec.pl", - "mielno.pl", - "mragowo.pl", - "naklo.pl", - "nowaruda.pl", - "nysa.pl", - "olawa.pl", - "olecko.pl", - "olkusz.pl", - "olsztyn.pl", - "opoczno.pl", - "opole.pl", - "ostroda.pl", - "ostroleka.pl", - "ostrowiec.pl", - "ostrowwlkp.pl", - "pila.pl", - "pisz.pl", - "podhale.pl", - "podlasie.pl", - "polkowice.pl", - "pomorze.pl", - "pomorskie.pl", - "prochowice.pl", - "pruszkow.pl", - "przeworsk.pl", - "pulawy.pl", - "radom.pl", - "rawa-maz.pl", - "rybnik.pl", - "rzeszow.pl", - "sanok.pl", - "sejny.pl", - "slask.pl", - "slupsk.pl", - "sosnowiec.pl", - "stalowa-wola.pl", - "skoczow.pl", - "starachowice.pl", - "stargard.pl", - "suwalki.pl", - "swidnica.pl", - "swiebodzin.pl", - "swinoujscie.pl", - "szczecin.pl", - "szczytno.pl", - "tarnobrzeg.pl", - "tgory.pl", - "turek.pl", - "tychy.pl", - "ustka.pl", - "walbrzych.pl", - "warmia.pl", - "warszawa.pl", - "waw.pl", - "wegrow.pl", - "wielun.pl", - "wlocl.pl", - "wloclawek.pl", - "wodzislaw.pl", - "wolomin.pl", - "wroclaw.pl", - "zachpomor.pl", - "zagan.pl", - "zarow.pl", - "zgora.pl", - "zgorzelec.pl", - "pm", - "pn", - "gov.pn", - "co.pn", - "org.pn", - "edu.pn", - "net.pn", - "post", - "pr", - "com.pr", - "net.pr", - "org.pr", - "gov.pr", - "edu.pr", - "isla.pr", - "pro.pr", - "biz.pr", - "info.pr", - "name.pr", - "est.pr", - "prof.pr", - "ac.pr", - "pro", - "aaa.pro", - "aca.pro", - "acct.pro", - "avocat.pro", - "bar.pro", - "cpa.pro", - "eng.pro", - "jur.pro", - "law.pro", - "med.pro", - "recht.pro", - "ps", - "edu.ps", - "gov.ps", - "sec.ps", - "plo.ps", - "com.ps", - "org.ps", - "net.ps", - "pt", - "net.pt", - "gov.pt", - "org.pt", - "edu.pt", - "int.pt", - "publ.pt", - "com.pt", - "nome.pt", - "pw", - "co.pw", - "ne.pw", - "or.pw", - "ed.pw", - "go.pw", - "belau.pw", - "py", - "com.py", - "coop.py", - "edu.py", - "gov.py", - "mil.py", - "net.py", - "org.py", - "qa", - "com.qa", - "edu.qa", - "gov.qa", - "mil.qa", - "name.qa", - "net.qa", - "org.qa", - "sch.qa", - "re", - "asso.re", - "com.re", - "nom.re", - "ro", - "arts.ro", - "com.ro", - "firm.ro", - "info.ro", - "nom.ro", - "nt.ro", - "org.ro", - "rec.ro", - "store.ro", - "tm.ro", - "www.ro", - "rs", - "ac.rs", - "co.rs", - "edu.rs", - "gov.rs", - "in.rs", - "org.rs", - "ru", - "ac.ru", - "edu.ru", - "gov.ru", - "int.ru", - "mil.ru", - "test.ru", - "rw", - "gov.rw", - "net.rw", - "edu.rw", - "ac.rw", - "com.rw", - "co.rw", - "int.rw", - "mil.rw", - "gouv.rw", - "sa", - "com.sa", - "net.sa", - "org.sa", - "gov.sa", - "med.sa", - "pub.sa", - "edu.sa", - "sch.sa", - "sb", - "com.sb", - "edu.sb", - "gov.sb", - "net.sb", - "org.sb", - "sc", - "com.sc", - "gov.sc", - "net.sc", - "org.sc", - "edu.sc", - "sd", - "com.sd", - "net.sd", - "org.sd", - "edu.sd", - "med.sd", - "tv.sd", - "gov.sd", - "info.sd", - "se", - "a.se", - "ac.se", - "b.se", - "bd.se", - "brand.se", - "c.se", - "d.se", - "e.se", - "f.se", - "fh.se", - "fhsk.se", - "fhv.se", - "g.se", - "h.se", - "i.se", - "k.se", - "komforb.se", - "kommunalforbund.se", - "komvux.se", - "l.se", - "lanbib.se", - "m.se", - "n.se", - "naturbruksgymn.se", - "o.se", - "org.se", - "p.se", - "parti.se", - "pp.se", - "press.se", - "r.se", - "s.se", - "t.se", - "tm.se", - "u.se", - "w.se", - "x.se", - "y.se", - "z.se", - "sg", - "com.sg", - "net.sg", - "org.sg", - "gov.sg", - "edu.sg", - "per.sg", - "sh", - "com.sh", - "net.sh", - "gov.sh", - "org.sh", - "mil.sh", - "si", - "sj", - "sk", - "sl", - "com.sl", - "net.sl", - "edu.sl", - "gov.sl", - "org.sl", - "sm", - "sn", - "art.sn", - "com.sn", - "edu.sn", - "gouv.sn", - "org.sn", - "perso.sn", - "univ.sn", - "so", - "com.so", - "net.so", - "org.so", - "sr", - "st", - "co.st", - "com.st", - "consulado.st", - "edu.st", - "embaixada.st", - "gov.st", - "mil.st", - "net.st", - "org.st", - "principe.st", - "saotome.st", - "store.st", - "su", - "adygeya.su", - "arkhangelsk.su", - "balashov.su", - "bashkiria.su", - "bryansk.su", - "dagestan.su", - "grozny.su", - "ivanovo.su", - "kalmykia.su", - "kaluga.su", - "karelia.su", - "khakassia.su", - "krasnodar.su", - "kurgan.su", - "lenug.su", - "mordovia.su", - "msk.su", - "murmansk.su", - "nalchik.su", - "nov.su", - "obninsk.su", - "penza.su", - "pokrovsk.su", - "sochi.su", - "spb.su", - "togliatti.su", - "troitsk.su", - "tula.su", - "tuva.su", - "vladikavkaz.su", - "vladimir.su", - "vologda.su", - "sv", - "com.sv", - "edu.sv", - "gob.sv", - "org.sv", - "red.sv", - "sx", - "gov.sx", - "sy", - "edu.sy", - "gov.sy", - "net.sy", - "mil.sy", - "com.sy", - "org.sy", - "sz", - "co.sz", - "ac.sz", - "org.sz", - "tc", - "td", - "tel", - "tf", - "tg", - "th", - "ac.th", - "co.th", - "go.th", - "in.th", - "mi.th", - "net.th", - "or.th", - "tj", - "ac.tj", - "biz.tj", - "co.tj", - "com.tj", - "edu.tj", - "go.tj", - "gov.tj", - "int.tj", - "mil.tj", - "name.tj", - "net.tj", - "nic.tj", - "org.tj", - "test.tj", - "web.tj", - "tk", - "tl", - "gov.tl", - "tm", - "com.tm", - "co.tm", - "org.tm", - "net.tm", - "nom.tm", - "gov.tm", - "mil.tm", - "edu.tm", - "tn", - "com.tn", - "ens.tn", - "fin.tn", - "gov.tn", - "ind.tn", - "intl.tn", - "nat.tn", - "net.tn", - "org.tn", - "info.tn", - "perso.tn", - "tourism.tn", - "edunet.tn", - "rnrt.tn", - "rns.tn", - "rnu.tn", - "mincom.tn", - "agrinet.tn", - "defense.tn", - "turen.tn", - "to", - "com.to", - "gov.to", - "net.to", - "org.to", - "edu.to", - "mil.to", - "tr", - "com.tr", - "info.tr", - "biz.tr", - "net.tr", - "org.tr", - "web.tr", - "gen.tr", - "tv.tr", - "av.tr", - "dr.tr", - "bbs.tr", - "name.tr", - "tel.tr", - "gov.tr", - "bel.tr", - "pol.tr", - "mil.tr", - "k12.tr", - "edu.tr", - "kep.tr", - "nc.tr", - "gov.nc.tr", - "travel", - "tt", - "co.tt", - "com.tt", - "org.tt", - "net.tt", - "biz.tt", - "info.tt", - "pro.tt", - "int.tt", - "coop.tt", - "jobs.tt", - "mobi.tt", - "travel.tt", - "museum.tt", - "aero.tt", - "name.tt", - "gov.tt", - "edu.tt", - "tv", - "tw", - "edu.tw", - "gov.tw", - "mil.tw", - "com.tw", - "net.tw", - "org.tw", - "idv.tw", - "game.tw", - "ebiz.tw", - "club.tw", - "xn--zf0ao64a.tw", - "xn--uc0atv.tw", - "xn--czrw28b.tw", - "tz", - "ac.tz", - "co.tz", - "go.tz", - "hotel.tz", - "info.tz", - "me.tz", - "mil.tz", - "mobi.tz", - "ne.tz", - "or.tz", - "sc.tz", - "tv.tz", - "ua", - "com.ua", - "edu.ua", - "gov.ua", - "in.ua", - "net.ua", - "org.ua", - "cherkassy.ua", - "cherkasy.ua", - "chernigov.ua", - "chernihiv.ua", - "chernivtsi.ua", - "chernovtsy.ua", - "ck.ua", - "cn.ua", - "cr.ua", - "crimea.ua", - "cv.ua", - "dn.ua", - "dnepropetrovsk.ua", - "dnipropetrovsk.ua", - "dominic.ua", - "donetsk.ua", - "dp.ua", - "if.ua", - "ivano-frankivsk.ua", - "kh.ua", - "kharkiv.ua", - "kharkov.ua", - "kherson.ua", - "khmelnitskiy.ua", - "khmelnytskyi.ua", - "kiev.ua", - "kirovograd.ua", - "km.ua", - "kr.ua", - "krym.ua", - "ks.ua", - "kv.ua", - "kyiv.ua", - "lg.ua", - "lt.ua", - "lugansk.ua", - "lutsk.ua", - "lv.ua", - "lviv.ua", - "mk.ua", - "mykolaiv.ua", - "nikolaev.ua", - "od.ua", - "odesa.ua", - "odessa.ua", - "pl.ua", - "poltava.ua", - "rivne.ua", - "rovno.ua", - "rv.ua", - "sb.ua", - "sebastopol.ua", - "sevastopol.ua", - "sm.ua", - "sumy.ua", - "te.ua", - "ternopil.ua", - "uz.ua", - "uzhgorod.ua", - "vinnica.ua", - "vinnytsia.ua", - "vn.ua", - "volyn.ua", - "yalta.ua", - "zaporizhzhe.ua", - "zaporizhzhia.ua", - "zhitomir.ua", - "zhytomyr.ua", - "zp.ua", - "zt.ua", - "ug", - "co.ug", - "or.ug", - "ac.ug", - "sc.ug", - "go.ug", - "ne.ug", - "com.ug", - "org.ug", - "uk", - "ac.uk", - "co.uk", - "gov.uk", - "ltd.uk", - "me.uk", - "net.uk", - "nhs.uk", - "org.uk", - "plc.uk", - "police.uk", - "*.sch.uk", - "us", - "dni.us", - "fed.us", - "isa.us", - "kids.us", - "nsn.us", - "ak.us", - "al.us", - "ar.us", - "as.us", - "az.us", - "ca.us", - "co.us", - "ct.us", - "dc.us", - "de.us", - "fl.us", - "ga.us", - "gu.us", - "hi.us", - "ia.us", - "id.us", - "il.us", - "in.us", - "ks.us", - "ky.us", - "la.us", - "ma.us", - "md.us", - "me.us", - "mi.us", - "mn.us", - "mo.us", - "ms.us", - "mt.us", - "nc.us", - "nd.us", - "ne.us", - "nh.us", - "nj.us", - "nm.us", - "nv.us", - "ny.us", - "oh.us", - "ok.us", - "or.us", - "pa.us", - "pr.us", - "ri.us", - "sc.us", - "sd.us", - "tn.us", - "tx.us", - "ut.us", - "vi.us", - "vt.us", - "va.us", - "wa.us", - "wi.us", - "wv.us", - "wy.us", - "k12.ak.us", - "k12.al.us", - "k12.ar.us", - "k12.as.us", - "k12.az.us", - "k12.ca.us", - "k12.co.us", - "k12.ct.us", - "k12.dc.us", - "k12.de.us", - "k12.fl.us", - "k12.ga.us", - "k12.gu.us", - "k12.ia.us", - "k12.id.us", - "k12.il.us", - "k12.in.us", - "k12.ks.us", - "k12.ky.us", - "k12.la.us", - "k12.ma.us", - "k12.md.us", - "k12.me.us", - "k12.mi.us", - "k12.mn.us", - "k12.mo.us", - "k12.ms.us", - "k12.mt.us", - "k12.nc.us", - "k12.ne.us", - "k12.nh.us", - "k12.nj.us", - "k12.nm.us", - "k12.nv.us", - "k12.ny.us", - "k12.oh.us", - "k12.ok.us", - "k12.or.us", - "k12.pa.us", - "k12.pr.us", - "k12.ri.us", - "k12.sc.us", - "k12.tn.us", - "k12.tx.us", - "k12.ut.us", - "k12.vi.us", - "k12.vt.us", - "k12.va.us", - "k12.wa.us", - "k12.wi.us", - "k12.wy.us", - "cc.ak.us", - "cc.al.us", - "cc.ar.us", - "cc.as.us", - "cc.az.us", - "cc.ca.us", - "cc.co.us", - "cc.ct.us", - "cc.dc.us", - "cc.de.us", - "cc.fl.us", - "cc.ga.us", - "cc.gu.us", - "cc.hi.us", - "cc.ia.us", - "cc.id.us", - "cc.il.us", - "cc.in.us", - "cc.ks.us", - "cc.ky.us", - "cc.la.us", - "cc.ma.us", - "cc.md.us", - "cc.me.us", - "cc.mi.us", - "cc.mn.us", - "cc.mo.us", - "cc.ms.us", - "cc.mt.us", - "cc.nc.us", - "cc.nd.us", - "cc.ne.us", - "cc.nh.us", - "cc.nj.us", - "cc.nm.us", - "cc.nv.us", - "cc.ny.us", - "cc.oh.us", - "cc.ok.us", - "cc.or.us", - "cc.pa.us", - "cc.pr.us", - "cc.ri.us", - "cc.sc.us", - "cc.sd.us", - "cc.tn.us", - "cc.tx.us", - "cc.ut.us", - "cc.vi.us", - "cc.vt.us", - "cc.va.us", - "cc.wa.us", - "cc.wi.us", - "cc.wv.us", - "cc.wy.us", - "lib.ak.us", - "lib.al.us", - "lib.ar.us", - "lib.as.us", - "lib.az.us", - "lib.ca.us", - "lib.co.us", - "lib.ct.us", - "lib.dc.us", - "lib.fl.us", - "lib.ga.us", - "lib.gu.us", - "lib.hi.us", - "lib.ia.us", - "lib.id.us", - "lib.il.us", - "lib.in.us", - "lib.ks.us", - "lib.ky.us", - "lib.la.us", - "lib.ma.us", - "lib.md.us", - "lib.me.us", - "lib.mi.us", - "lib.mn.us", - "lib.mo.us", - "lib.ms.us", - "lib.mt.us", - "lib.nc.us", - "lib.nd.us", - "lib.ne.us", - "lib.nh.us", - "lib.nj.us", - "lib.nm.us", - "lib.nv.us", - "lib.ny.us", - "lib.oh.us", - "lib.ok.us", - "lib.or.us", - "lib.pa.us", - "lib.pr.us", - "lib.ri.us", - "lib.sc.us", - "lib.sd.us", - "lib.tn.us", - "lib.tx.us", - "lib.ut.us", - "lib.vi.us", - "lib.vt.us", - "lib.va.us", - "lib.wa.us", - "lib.wi.us", - "lib.wy.us", - "pvt.k12.ma.us", - "chtr.k12.ma.us", - "paroch.k12.ma.us", - "uy", - "com.uy", - "edu.uy", - "gub.uy", - "mil.uy", - "net.uy", - "org.uy", - "uz", - "co.uz", - "com.uz", - "net.uz", - "org.uz", - "va", - "vc", - "com.vc", - "net.vc", - "org.vc", - "gov.vc", - "mil.vc", - "edu.vc", - "ve", - "arts.ve", - "co.ve", - "com.ve", - "e12.ve", - "edu.ve", - "firm.ve", - "gob.ve", - "gov.ve", - "info.ve", - "int.ve", - "mil.ve", - "net.ve", - "org.ve", - "rec.ve", - "store.ve", - "tec.ve", - "web.ve", - "vg", - "vi", - "co.vi", - "com.vi", - "k12.vi", - "net.vi", - "org.vi", - "vn", - "com.vn", - "net.vn", - "org.vn", - "edu.vn", - "gov.vn", - "int.vn", - "ac.vn", - "biz.vn", - "info.vn", - "name.vn", - "pro.vn", - "health.vn", - "vu", - "com.vu", - "edu.vu", - "net.vu", - "org.vu", - "wf", - "ws", - "com.ws", - "net.ws", - "org.ws", - "gov.ws", - "edu.ws", - "yt", - "xn--mgbaam7a8h", - "xn--y9a3aq", - "xn--54b7fta0cc", - "xn--90ais", - "xn--fiqs8s", - "xn--fiqz9s", - "xn--lgbbat1ad8j", - "xn--wgbh1c", - "xn--e1a4c", - "xn--node", - "xn--qxam", - "xn--j6w193g", - "xn--h2brj9c", - "xn--mgbbh1a71e", - "xn--fpcrj9c3d", - "xn--gecrj9c", - "xn--s9brj9c", - "xn--45brj9c", - "xn--xkc2dl3a5ee0h", - "xn--mgba3a4f16a", - "xn--mgba3a4fra", - "xn--mgbtx2b", - "xn--mgbayh7gpa", - "xn--3e0b707e", - "xn--80ao21a", - "xn--fzc2c9e2c", - "xn--xkc2al3hye2a", - "xn--mgbc0a9azcg", - "xn--d1alf", - "xn--l1acc", - "xn--mix891f", - "xn--mix082f", - "xn--mgbx4cd0ab", - "xn--mgb9awbf", - "xn--mgbai9azgqp6j", - "xn--mgbai9a5eva00b", - "xn--ygbi2ammx", - "xn--90a3ac", - "xn--o1ac.xn--90a3ac", - "xn--c1avg.xn--90a3ac", - "xn--90azh.xn--90a3ac", - "xn--d1at.xn--90a3ac", - "xn--o1ach.xn--90a3ac", - "xn--80au.xn--90a3ac", - "xn--p1ai", - "xn--wgbl6a", - "xn--mgberp4a5d4ar", - "xn--mgberp4a5d4a87g", - "xn--mgbqly7c0a67fbc", - "xn--mgbqly7cvafr", - "xn--mgbpl2fh", - "xn--yfro4i67o", - "xn--clchc0ea0b2g2a9gcd", - "xn--ogbpf8fl", - "xn--mgbtf8fl", - "xn--o3cw4h", - "xn--pgbs0dh", - "xn--kpry57d", - "xn--kprw13d", - "xn--nnx388a", - "xn--j1amh", - "xn--mgb2ddes", - "xxx", - "*.ye", - "ac.za", - "agric.za", - "alt.za", - "co.za", - "edu.za", - "gov.za", - "grondar.za", - "law.za", - "mil.za", - "net.za", - "ngo.za", - "nis.za", - "nom.za", - "org.za", - "school.za", - "tm.za", - "web.za", - "zm", - "ac.zm", - "biz.zm", - "co.zm", - "com.zm", - "edu.zm", - "gov.zm", - "info.zm", - "mil.zm", - "net.zm", - "org.zm", - "sch.zm", - "*.zw", - "aaa", - "aarp", - "abarth", - "abb", - "abbott", - "abbvie", - "abc", - "able", - "abogado", - "abudhabi", - "academy", - "accenture", - "accountant", - "accountants", - "aco", - "active", - "actor", - "adac", - "ads", - "adult", - "aeg", - "aetna", - "afamilycompany", - "afl", - "africa", - "agakhan", - "agency", - "aig", - "aigo", - "airbus", - "airforce", - "airtel", - "akdn", - "alfaromeo", - "alibaba", - "alipay", - "allfinanz", - "allstate", - "ally", - "alsace", - "alstom", - "americanexpress", - "americanfamily", - "amex", - "amfam", - "amica", - "amsterdam", - "analytics", - "android", - "anquan", - "anz", - "aol", - "apartments", - "app", - "apple", - "aquarelle", - "arab", - "aramco", - "archi", - "army", - "art", - "arte", - "asda", - "associates", - "athleta", - "attorney", - "auction", - "audi", - "audible", - "audio", - "auspost", - "author", - "auto", - "autos", - "avianca", - "aws", - "axa", - "azure", - "baby", - "baidu", - "banamex", - "bananarepublic", - "band", - "bank", - "bar", - "barcelona", - "barclaycard", - "barclays", - "barefoot", - "bargains", - "baseball", - "basketball", - "bauhaus", - "bayern", - "bbc", - "bbt", - "bbva", - "bcg", - "bcn", - "beats", - "beauty", - "beer", - "bentley", - "berlin", - "best", - "bestbuy", - "bet", - "bharti", - "bible", - "bid", - "bike", - "bing", - "bingo", - "bio", - "black", - "blackfriday", - "blanco", - "blockbuster", - "blog", - "bloomberg", - "blue", - "bms", - "bmw", - "bnl", - "bnpparibas", - "boats", - "boehringer", - "bofa", - "bom", - "bond", - "boo", - "book", - "booking", - "boots", - "bosch", - "bostik", - "boston", - "bot", - "boutique", - "box", - "bradesco", - "bridgestone", - "broadway", - "broker", - "brother", - "brussels", - "budapest", - "bugatti", - "build", - "builders", - "business", - "buy", - "buzz", - "bzh", - "cab", - "cafe", - "cal", - "call", - "calvinklein", - "cam", - "camera", - "camp", - "cancerresearch", - "canon", - "capetown", - "capital", - "capitalone", - "car", - "caravan", - "cards", - "care", - "career", - "careers", - "cars", - "cartier", - "casa", - "case", - "caseih", - "cash", - "casino", - "catering", - "catholic", - "cba", - "cbn", - "cbre", - "cbs", - "ceb", - "center", - "ceo", - "cern", - "cfa", - "cfd", - "chanel", - "channel", - "chase", - "chat", - "cheap", - "chintai", - "chloe", - "christmas", - "chrome", - "chrysler", - "church", - "cipriani", - "circle", - "cisco", - "citadel", - "citi", - "citic", - "city", - "cityeats", - "claims", - "cleaning", - "click", - "clinic", - "clinique", - "clothing", - "cloud", - "club", - "clubmed", - "coach", - "codes", - "coffee", - "college", - "cologne", - "comcast", - "commbank", - "community", - "company", - "compare", - "computer", - "comsec", - "condos", - "construction", - "consulting", - "contact", - "contractors", - "cooking", - "cookingchannel", - "cool", - "corsica", - "country", - "coupon", - "coupons", - "courses", - "credit", - "creditcard", - "creditunion", - "cricket", - "crown", - "crs", - "cruise", - "cruises", - "csc", - "cuisinella", - "cymru", - "cyou", - "dabur", - "dad", - "dance", - "data", - "date", - "dating", - "datsun", - "day", - "dclk", - "dds", - "deal", - "dealer", - "deals", - "degree", - "delivery", - "dell", - "deloitte", - "delta", - "democrat", - "dental", - "dentist", - "desi", - "design", - "dev", - "dhl", - "diamonds", - "diet", - "digital", - "direct", - "directory", - "discount", - "discover", - "dish", - "diy", - "dnp", - "docs", - "doctor", - "dodge", - "dog", - "doha", - "domains", - "dot", - "download", - "drive", - "dtv", - "dubai", - "duck", - "dunlop", - "duns", - "dupont", - "durban", - "dvag", - "dvr", - "dwg", - "earth", - "eat", - "eco", - "edeka", - "education", - "email", - "emerck", - "energy", - "engineer", - "engineering", - "enterprises", - "epost", - "epson", - "equipment", - "ericsson", - "erni", - "esq", - "estate", - "esurance", - "etisalat", - "eurovision", - "eus", - "events", - "everbank", - "exchange", - "expert", - "exposed", - "express", - "extraspace", - "fage", - "fail", - "fairwinds", - "faith", - "family", - "fan", - "fans", - "farm", - "farmers", - "fashion", - "fast", - "fedex", - "feedback", - "ferrari", - "ferrero", - "fiat", - "fidelity", - "fido", - "film", - "final", - "finance", - "financial", - "fire", - "firestone", - "firmdale", - "fish", - "fishing", - "fit", - "fitness", - "flickr", - "flights", - "flir", - "florist", - "flowers", - "fly", - "foo", - "food", - "foodnetwork", - "football", - "ford", - "forex", - "forsale", - "forum", - "foundation", - "fox", - "free", - "fresenius", - "frl", - "frogans", - "frontdoor", - "frontier", - "ftr", - "fujitsu", - "fujixerox", - "fun", - "fund", - "furniture", - "futbol", - "fyi", - "gal", - "gallery", - "gallo", - "gallup", - "game", - "games", - "gap", - "garden", - "gbiz", - "gdn", - "gea", - "gent", - "genting", - "george", - "ggee", - "gift", - "gifts", - "gives", - "giving", - "glade", - "glass", - "gle", - "global", - "globo", - "gmail", - "gmbh", - "gmo", - "gmx", - "godaddy", - "gold", - "goldpoint", - "golf", - "goo", - "goodhands", - "goodyear", - "goog", - "google", - "gop", - "got", - "grainger", - "graphics", - "gratis", - "green", - "gripe", - "grocery", - "group", - "guardian", - "gucci", - "guge", - "guide", - "guitars", - "guru", - "hair", - "hamburg", - "hangout", - "haus", - "hbo", - "hdfc", - "hdfcbank", - "health", - "healthcare", - "help", - "helsinki", - "here", - "hermes", - "hgtv", - "hiphop", - "hisamitsu", - "hitachi", - "hiv", - "hkt", - "hockey", - "holdings", - "holiday", - "homedepot", - "homegoods", - "homes", - "homesense", - "honda", - "honeywell", - "horse", - "hospital", - "host", - "hosting", - "hot", - "hoteles", - "hotels", - "hotmail", - "house", - "how", - "hsbc", - "htc", - "hughes", - "hyatt", - "hyundai", - "ibm", - "icbc", - "ice", - "icu", - "ieee", - "ifm", - "iinet", - "ikano", - "imamat", - "imdb", - "immo", - "immobilien", - "industries", - "infiniti", - "ing", - "ink", - "institute", - "insurance", - "insure", - "intel", - "international", - "intuit", - "investments", - "ipiranga", - "irish", - "iselect", - "ismaili", - "ist", - "istanbul", - "itau", - "itv", - "iveco", - "iwc", - "jaguar", - "java", - "jcb", - "jcp", - "jeep", - "jetzt", - "jewelry", - "jio", - "jlc", - "jll", - "jmp", - "jnj", - "joburg", - "jot", - "joy", - "jpmorgan", - "jprs", - "juegos", - "juniper", - "kaufen", - "kddi", - "kerryhotels", - "kerrylogistics", - "kerryproperties", - "kfh", - "kia", - "kim", - "kinder", - "kindle", - "kitchen", - "kiwi", - "koeln", - "komatsu", - "kosher", - "kpmg", - "kpn", - "krd", - "kred", - "kuokgroup", - "kyoto", - "lacaixa", - "ladbrokes", - "lamborghini", - "lamer", - "lancaster", - "lancia", - "lancome", - "land", - "landrover", - "lanxess", - "lasalle", - "lat", - "latino", - "latrobe", - "law", - "lawyer", - "lds", - "lease", - "leclerc", - "lefrak", - "legal", - "lego", - "lexus", - "lgbt", - "liaison", - "lidl", - "life", - "lifeinsurance", - "lifestyle", - "lighting", - "like", - "lilly", - "limited", - "limo", - "lincoln", - "linde", - "link", - "lipsy", - "live", - "living", - "lixil", - "loan", - "loans", - "locker", - "locus", - "loft", - "lol", - "london", - "lotte", - "lotto", - "love", - "lpl", - "lplfinancial", - "ltd", - "ltda", - "lundbeck", - "lupin", - "luxe", - "luxury", - "macys", - "madrid", - "maif", - "maison", - "makeup", - "man", - "management", - "mango", - "map", - "market", - "marketing", - "markets", - "marriott", - "marshalls", - "maserati", - "mattel", - "mba", - "mcd", - "mcdonalds", - "mckinsey", - "med", - "media", - "meet", - "melbourne", - "meme", - "memorial", - "men", - "menu", - "meo", - "merckmsd", - "metlife", - "miami", - "microsoft", - "mini", - "mint", - "mit", - "mitsubishi", - "mlb", - "mls", - "mma", - "mobile", - "mobily", - "moda", - "moe", - "moi", - "mom", - "monash", - "money", - "monster", - "montblanc", - "mopar", - "mormon", - "mortgage", - "moscow", - "moto", - "motorcycles", - "mov", - "movie", - "movistar", - "msd", - "mtn", - "mtpc", - "mtr", - "mutual", - "mutuelle", - "nab", - "nadex", - "nagoya", - "nationwide", - "natura", - "navy", - "nba", - "nec", - "netbank", - "netflix", - "network", - "neustar", - "new", - "newholland", - "news", - "next", - "nextdirect", - "nexus", - "nfl", - "ngo", - "nhk", - "nico", - "nike", - "nikon", - "ninja", - "nissan", - "nissay", - "nokia", - "northwesternmutual", - "norton", - "now", - "nowruz", - "nowtv", - "nra", - "nrw", - "ntt", - "nyc", - "obi", - "observer", - "off", - "office", - "okinawa", - "olayan", - "olayangroup", - "oldnavy", - "ollo", - "omega", - "one", - "ong", - "onl", - "online", - "onyourside", - "ooo", - "open", - "oracle", - "orange", - "organic", - "orientexpress", - "origins", - "osaka", - "otsuka", - "ott", - "ovh", - "page", - "pamperedchef", - "panasonic", - "panerai", - "paris", - "pars", - "partners", - "parts", - "party", - "passagens", - "pay", - "pccw", - "pet", - "pfizer", - "pharmacy", - "phd", - "philips", - "phone", - "photo", - "photography", - "photos", - "physio", - "piaget", - "pics", - "pictet", - "pictures", - "pid", - "pin", - "ping", - "pink", - "pioneer", - "pizza", - "place", - "play", - "playstation", - "plumbing", - "plus", - "pnc", - "pohl", - "poker", - "politie", - "porn", - "pramerica", - "praxi", - "press", - "prime", - "prod", - "productions", - "prof", - "progressive", - "promo", - "properties", - "property", - "protection", - "pru", - "prudential", - "pub", - "pwc", - "qpon", - "quebec", - "quest", - "qvc", - "racing", - "radio", - "raid", - "read", - "realestate", - "realtor", - "realty", - "recipes", - "red", - "redstone", - "redumbrella", - "rehab", - "reise", - "reisen", - "reit", - "reliance", - "ren", - "rent", - "rentals", - "repair", - "report", - "republican", - "rest", - "restaurant", - "review", - "reviews", - "rexroth", - "rich", - "richardli", - "ricoh", - "rightathome", - "ril", - "rio", - "rip", - "rmit", - "rocher", - "rocks", - "rodeo", - "rogers", - "room", - "rsvp", - "ruhr", - "run", - "rwe", - "ryukyu", - "saarland", - "safe", - "safety", - "sakura", - "sale", - "salon", - "samsclub", - "samsung", - "sandvik", - "sandvikcoromant", - "sanofi", - "sap", - "sapo", - "sarl", - "sas", - "save", - "saxo", - "sbi", - "sbs", - "sca", - "scb", - "schaeffler", - "schmidt", - "scholarships", - "school", - "schule", - "schwarz", - "science", - "scjohnson", - "scor", - "scot", - "search", - "seat", - "secure", - "security", - "seek", - "select", - "sener", - "services", - "ses", - "seven", - "sew", - "sex", - "sexy", - "sfr", - "shangrila", - "sharp", - "shaw", - "shell", - "shia", - "shiksha", - "shoes", - "shop", - "shopping", - "shouji", - "show", - "showtime", - "shriram", - "silk", - "sina", - "singles", - "site", - "ski", - "skin", - "sky", - "skype", - "sling", - "smart", - "smile", - "sncf", - "soccer", - "social", - "softbank", - "software", - "sohu", - "solar", - "solutions", - "song", - "sony", - "soy", - "space", - "spiegel", - "spot", - "spreadbetting", - "srl", - "srt", - "stada", - "staples", - "star", - "starhub", - "statebank", - "statefarm", - "statoil", - "stc", - "stcgroup", - "stockholm", - "storage", - "store", - "stream", - "studio", - "study", - "style", - "sucks", - "supplies", - "supply", - "support", - "surf", - "surgery", - "suzuki", - "swatch", - "swiftcover", - "swiss", - "sydney", - "symantec", - "systems", - "tab", - "taipei", - "talk", - "taobao", - "target", - "tatamotors", - "tatar", - "tattoo", - "tax", - "taxi", - "tci", - "tdk", - "team", - "tech", - "technology", - "telecity", - "telefonica", - "temasek", - "tennis", - "teva", - "thd", - "theater", - "theatre", - "theguardian", - "tiaa", - "tickets", - "tienda", - "tiffany", - "tips", - "tires", - "tirol", - "tjmaxx", - "tjx", - "tkmaxx", - "tmall", - "today", - "tokyo", - "tools", - "top", - "toray", - "toshiba", - "total", - "tours", - "town", - "toyota", - "toys", - "trade", - "trading", - "training", - "travelchannel", - "travelers", - "travelersinsurance", - "trust", - "trv", - "tube", - "tui", - "tunes", - "tushu", - "tvs", - "ubank", - "ubs", - "uconnect", - "unicom", - "university", - "uno", - "uol", - "ups", - "vacations", - "vana", - "vanguard", - "vegas", - "ventures", - "verisign", - "versicherung", - "vet", - "viajes", - "video", - "vig", - "viking", - "villas", - "vin", - "vip", - "virgin", - "visa", - "vision", - "vista", - "vistaprint", - "viva", - "vivo", - "vlaanderen", - "vodka", - "volkswagen", - "volvo", - "vote", - "voting", - "voto", - "voyage", - "vuelos", - "wales", - "walmart", - "walter", - "wang", - "wanggou", - "warman", - "watch", - "watches", - "weather", - "weatherchannel", - "webcam", - "weber", - "website", - "wed", - "wedding", - "weibo", - "weir", - "whoswho", - "wien", - "wiki", - "williamhill", - "win", - "windows", - "wine", - "winners", - "wme", - "wolterskluwer", - "woodside", - "work", - "works", - "world", - "wow", - "wtc", - "wtf", - "xbox", - "xerox", - "xfinity", - "xihuan", - "xin", - "xn--11b4c3d", - "xn--1ck2e1b", - "xn--1qqw23a", - "xn--30rr7y", - "xn--3bst00m", - "xn--3ds443g", - "xn--3oq18vl8pn36a", - "xn--3pxu8k", - "xn--42c2d9a", - "xn--45q11c", - "xn--4gbrim", - "xn--4gq48lf9j", - "xn--55qw42g", - "xn--55qx5d", - "xn--5su34j936bgsg", - "xn--5tzm5g", - "xn--6frz82g", - "xn--6qq986b3xl", - "xn--80adxhks", - "xn--80aqecdr1a", - "xn--80asehdb", - "xn--80aswg", - "xn--8y0a063a", - "xn--9dbq2a", - "xn--9et52u", - "xn--9krt00a", - "xn--b4w605ferd", - "xn--bck1b9a5dre4c", - "xn--c1avg", - "xn--c2br7g", - "xn--cck2b3b", - "xn--cg4bki", - "xn--czr694b", - "xn--czrs0t", - "xn--czru2d", - "xn--d1acj3b", - "xn--eckvdtc9d", - "xn--efvy88h", - "xn--estv75g", - "xn--fct429k", - "xn--fhbei", - "xn--fiq228c5hs", - "xn--fiq64b", - "xn--fjq720a", - "xn--flw351e", - "xn--fzys8d69uvgm", - "xn--g2xx48c", - "xn--gckr3f0f", - "xn--gk3at1e", - "xn--hxt814e", - "xn--i1b6b1a6a2e", - "xn--imr513n", - "xn--io0a7i", - "xn--j1aef", - "xn--jlq61u9w7b", - "xn--jvr189m", - "xn--kcrx77d1x4a", - "xn--kpu716f", - "xn--kput3i", - "xn--mgba3a3ejt", - "xn--mgba7c0bbn0a", - "xn--mgbaakc7dvf", - "xn--mgbab2bd", - "xn--mgbb9fbpob", - "xn--mgbca7dzdo", - "xn--mgbi4ecexp", - "xn--mgbt3dhd", - "xn--mk1bu44c", - "xn--mxtq1m", - "xn--ngbc5azd", - "xn--ngbe9e0a", - "xn--ngbrx", - "xn--nqv7f", - "xn--nqv7fs00ema", - "xn--nyqy26a", - "xn--p1acf", - "xn--pbt977c", - "xn--pssy2u", - "xn--q9jyb4c", - "xn--qcka1pmc", - "xn--rhqv96g", - "xn--rovu88b", - "xn--ses554g", - "xn--t60b56a", - "xn--tckwe", - "xn--tiq49xqyj", - "xn--unup4y", - "xn--vermgensberater-ctb", - "xn--vermgensberatung-pwb", - "xn--vhquv", - "xn--vuq861b", - "xn--w4r85el8fhu5dnra", - "xn--w4rs40l", - "xn--xhq521b", - "xn--zfr164b", - "xperia", - "xyz", - "yachts", - "yahoo", - "yamaxun", - "yandex", - "yodobashi", - "yoga", - "yokohama", - "you", - "youtube", - "yun", - "zappos", - "zara", - "zero", - "zip", - "zippo", - "zone", - "zuerich", - "beep.pl", - "*.compute.estate", - "*.alces.network", - "*.alwaysdata.net", - "cloudfront.net", - "*.compute.amazonaws.com", - "*.compute-1.amazonaws.com", - "*.compute.amazonaws.com.cn", - "us-east-1.amazonaws.com", - "elasticbeanstalk.cn-north-1.amazonaws.com.cn", - "*.elasticbeanstalk.com", - "*.elb.amazonaws.com", - "*.elb.amazonaws.com.cn", - "*.s3.amazonaws.com", - "s3-ap-northeast-1.amazonaws.com", - "s3-ap-northeast-2.amazonaws.com", - "s3-ap-south-1.amazonaws.com", - "s3-ap-southeast-1.amazonaws.com", - "s3-ap-southeast-2.amazonaws.com", - "s3-ca-central-1.amazonaws.com", - "s3-eu-central-1.amazonaws.com", - "s3-eu-west-1.amazonaws.com", - "s3-external-1.amazonaws.com", - "s3-fips-us-gov-west-1.amazonaws.com", - "s3-sa-east-1.amazonaws.com", - "s3-us-gov-west-1.amazonaws.com", - "s3-us-east-2.amazonaws.com", - "s3-us-west-1.amazonaws.com", - "s3-us-west-2.amazonaws.com", - "s3.ap-northeast-2.amazonaws.com", - "s3.ap-south-1.amazonaws.com", - "s3.cn-north-1.amazonaws.com.cn", - "s3.ca-central-1.amazonaws.com", - "s3.eu-central-1.amazonaws.com", - "s3.us-east-2.amazonaws.com", - "s3.dualstack.ap-northeast-1.amazonaws.com", - "s3.dualstack.ap-northeast-2.amazonaws.com", - "s3.dualstack.ap-south-1.amazonaws.com", - "s3.dualstack.ap-southeast-1.amazonaws.com", - "s3.dualstack.ap-southeast-2.amazonaws.com", - "s3.dualstack.ca-central-1.amazonaws.com", - "s3.dualstack.eu-central-1.amazonaws.com", - "s3.dualstack.eu-west-1.amazonaws.com", - "s3.dualstack.sa-east-1.amazonaws.com", - "s3.dualstack.us-east-1.amazonaws.com", - "s3.dualstack.us-east-2.amazonaws.com", - "s3-website-us-east-1.amazonaws.com", - "s3-website-us-west-1.amazonaws.com", - "s3-website-us-west-2.amazonaws.com", - "s3-website-ap-northeast-1.amazonaws.com", - "s3-website-ap-southeast-1.amazonaws.com", - "s3-website-ap-southeast-2.amazonaws.com", - "s3-website-eu-west-1.amazonaws.com", - "s3-website-sa-east-1.amazonaws.com", - "s3-website.ap-northeast-2.amazonaws.com", - "s3-website.ap-south-1.amazonaws.com", - "s3-website.ca-central-1.amazonaws.com", - "s3-website.eu-central-1.amazonaws.com", - "s3-website.us-east-2.amazonaws.com", - "t3l3p0rt.net", - "tele.amune.org", - "on-aptible.com", - "user.party.eus", - "pimienta.org", - "poivron.org", - "potager.org", - "sweetpepper.org", - "myasustor.com", - "myfritz.net", - "backplaneapp.io", - "betainabox.com", - "bnr.la", - "boxfuse.io", - "browsersafetymark.io", - "mycd.eu", - "ae.org", - "ar.com", - "br.com", - "cn.com", - "com.de", - "com.se", - "de.com", - "eu.com", - "gb.com", - "gb.net", - "hu.com", - "hu.net", - "jp.net", - "jpn.com", - "kr.com", - "mex.com", - "no.com", - "qc.com", - "ru.com", - "sa.com", - "se.com", - "se.net", - "uk.com", - "uk.net", - "us.com", - "uy.com", - "za.bz", - "za.com", - "africa.com", - "gr.com", - "in.net", - "us.org", - "co.com", - "c.la", - "certmgr.org", - "xenapponazure.com", - "virtueeldomein.nl", - "cloudcontrolled.com", - "cloudcontrolapp.com", - "co.ca", - "co.cz", - "c.cdn77.org", - "cdn77-ssl.net", - "r.cdn77.net", - "rsc.cdn77.org", - "ssl.origin.cdn77-secure.org", - "cloudns.asia", - "cloudns.biz", - "cloudns.club", - "cloudns.cc", - "cloudns.eu", - "cloudns.in", - "cloudns.info", - "cloudns.org", - "cloudns.pro", - "cloudns.pw", - "cloudns.us", - "co.nl", - "co.no", - "*.platform.sh", - "dyn.cosidns.de", - "dynamisches-dns.de", - "dnsupdater.de", - "internet-dns.de", - "l-o-g-i-n.de", - "dynamic-dns.info", - "feste-ip.net", - "knx-server.net", - "static-access.net", - "realm.cz", - "*.cryptonomic.net", - "cupcake.is", - "cyon.link", - "cyon.site", - "daplie.me", - "biz.dk", - "co.dk", - "firm.dk", - "reg.dk", - "store.dk", - "dedyn.io", - "dnshome.de", - "dreamhosters.com", - "mydrobo.com", - "drud.io", - "drud.us", - "duckdns.org", - "dy.fi", - "tunk.org", - "dyndns-at-home.com", - "dyndns-at-work.com", - "dyndns-blog.com", - "dyndns-free.com", - "dyndns-home.com", - "dyndns-ip.com", - "dyndns-mail.com", - "dyndns-office.com", - "dyndns-pics.com", - "dyndns-remote.com", - "dyndns-server.com", - "dyndns-web.com", - "dyndns-wiki.com", - "dyndns-work.com", - "dyndns.biz", - "dyndns.info", - "dyndns.org", - "dyndns.tv", - "at-band-camp.net", - "ath.cx", - "barrel-of-knowledge.info", - "barrell-of-knowledge.info", - "better-than.tv", - "blogdns.com", - "blogdns.net", - "blogdns.org", - "blogsite.org", - "boldlygoingnowhere.org", - "broke-it.net", - "buyshouses.net", - "cechire.com", - "dnsalias.com", - "dnsalias.net", - "dnsalias.org", - "dnsdojo.com", - "dnsdojo.net", - "dnsdojo.org", - "does-it.net", - "doesntexist.com", - "doesntexist.org", - "dontexist.com", - "dontexist.net", - "dontexist.org", - "doomdns.com", - "doomdns.org", - "dvrdns.org", - "dyn-o-saur.com", - "dynalias.com", - "dynalias.net", - "dynalias.org", - "dynathome.net", - "dyndns.ws", - "endofinternet.net", - "endofinternet.org", - "endoftheinternet.org", - "est-a-la-maison.com", - "est-a-la-masion.com", - "est-le-patron.com", - "est-mon-blogueur.com", - "for-better.biz", - "for-more.biz", - "for-our.info", - "for-some.biz", - "for-the.biz", - "forgot.her.name", - "forgot.his.name", - "from-ak.com", - "from-al.com", - "from-ar.com", - "from-az.net", - "from-ca.com", - "from-co.net", - "from-ct.com", - "from-dc.com", - "from-de.com", - "from-fl.com", - "from-ga.com", - "from-hi.com", - "from-ia.com", - "from-id.com", - "from-il.com", - "from-in.com", - "from-ks.com", - "from-ky.com", - "from-la.net", - "from-ma.com", - "from-md.com", - "from-me.org", - "from-mi.com", - "from-mn.com", - "from-mo.com", - "from-ms.com", - "from-mt.com", - "from-nc.com", - "from-nd.com", - "from-ne.com", - "from-nh.com", - "from-nj.com", - "from-nm.com", - "from-nv.com", - "from-ny.net", - "from-oh.com", - "from-ok.com", - "from-or.com", - "from-pa.com", - "from-pr.com", - "from-ri.com", - "from-sc.com", - "from-sd.com", - "from-tn.com", - "from-tx.com", - "from-ut.com", - "from-va.com", - "from-vt.com", - "from-wa.com", - "from-wi.com", - "from-wv.com", - "from-wy.com", - "ftpaccess.cc", - "fuettertdasnetz.de", - "game-host.org", - "game-server.cc", - "getmyip.com", - "gets-it.net", - "go.dyndns.org", - "gotdns.com", - "gotdns.org", - "groks-the.info", - "groks-this.info", - "ham-radio-op.net", - "here-for-more.info", - "hobby-site.com", - "hobby-site.org", - "home.dyndns.org", - "homedns.org", - "homeftp.net", - "homeftp.org", - "homeip.net", - "homelinux.com", - "homelinux.net", - "homelinux.org", - "homeunix.com", - "homeunix.net", - "homeunix.org", - "iamallama.com", - "in-the-band.net", - "is-a-anarchist.com", - "is-a-blogger.com", - "is-a-bookkeeper.com", - "is-a-bruinsfan.org", - "is-a-bulls-fan.com", - "is-a-candidate.org", - "is-a-caterer.com", - "is-a-celticsfan.org", - "is-a-chef.com", - "is-a-chef.net", - "is-a-chef.org", - "is-a-conservative.com", - "is-a-cpa.com", - "is-a-cubicle-slave.com", - "is-a-democrat.com", - "is-a-designer.com", - "is-a-doctor.com", - "is-a-financialadvisor.com", - "is-a-geek.com", - "is-a-geek.net", - "is-a-geek.org", - "is-a-green.com", - "is-a-guru.com", - "is-a-hard-worker.com", - "is-a-hunter.com", - "is-a-knight.org", - "is-a-landscaper.com", - "is-a-lawyer.com", - "is-a-liberal.com", - "is-a-libertarian.com", - "is-a-linux-user.org", - "is-a-llama.com", - "is-a-musician.com", - "is-a-nascarfan.com", - "is-a-nurse.com", - "is-a-painter.com", - "is-a-patsfan.org", - "is-a-personaltrainer.com", - "is-a-photographer.com", - "is-a-player.com", - "is-a-republican.com", - "is-a-rockstar.com", - "is-a-socialist.com", - "is-a-soxfan.org", - "is-a-student.com", - "is-a-teacher.com", - "is-a-techie.com", - "is-a-therapist.com", - "is-an-accountant.com", - "is-an-actor.com", - "is-an-actress.com", - "is-an-anarchist.com", - "is-an-artist.com", - "is-an-engineer.com", - "is-an-entertainer.com", - "is-by.us", - "is-certified.com", - "is-found.org", - "is-gone.com", - "is-into-anime.com", - "is-into-cars.com", - "is-into-cartoons.com", - "is-into-games.com", - "is-leet.com", - "is-lost.org", - "is-not-certified.com", - "is-saved.org", - "is-slick.com", - "is-uberleet.com", - "is-very-bad.org", - "is-very-evil.org", - "is-very-good.org", - "is-very-nice.org", - "is-very-sweet.org", - "is-with-theband.com", - "isa-geek.com", - "isa-geek.net", - "isa-geek.org", - "isa-hockeynut.com", - "issmarterthanyou.com", - "isteingeek.de", - "istmein.de", - "kicks-ass.net", - "kicks-ass.org", - "knowsitall.info", - "land-4-sale.us", - "lebtimnetz.de", - "leitungsen.de", - "likes-pie.com", - "likescandy.com", - "merseine.nu", - "mine.nu", - "misconfused.org", - "mypets.ws", - "myphotos.cc", - "neat-url.com", - "office-on-the.net", - "on-the-web.tv", - "podzone.net", - "podzone.org", - "readmyblog.org", - "saves-the-whales.com", - "scrapper-site.net", - "scrapping.cc", - "selfip.biz", - "selfip.com", - "selfip.info", - "selfip.net", - "selfip.org", - "sells-for-less.com", - "sells-for-u.com", - "sells-it.net", - "sellsyourhome.org", - "servebbs.com", - "servebbs.net", - "servebbs.org", - "serveftp.net", - "serveftp.org", - "servegame.org", - "shacknet.nu", - "simple-url.com", - "space-to-rent.com", - "stuff-4-sale.org", - "stuff-4-sale.us", - "teaches-yoga.com", - "thruhere.net", - "traeumtgerade.de", - "webhop.biz", - "webhop.info", - "webhop.net", - "webhop.org", - "worse-than.tv", - "writesthisblog.com", - "ddnss.de", - "dyn.ddnss.de", - "dyndns.ddnss.de", - "dyndns1.de", - "dyn-ip24.de", - "home-webserver.de", - "dyn.home-webserver.de", - "myhome-server.de", - "ddnss.org", - "dynv6.net", - "e4.cz", - "enonic.io", - "customer.enonic.io", - "eu.org", - "al.eu.org", - "asso.eu.org", - "at.eu.org", - "au.eu.org", - "be.eu.org", - "bg.eu.org", - "ca.eu.org", - "cd.eu.org", - "ch.eu.org", - "cn.eu.org", - "cy.eu.org", - "cz.eu.org", - "de.eu.org", - "dk.eu.org", - "edu.eu.org", - "ee.eu.org", - "es.eu.org", - "fi.eu.org", - "fr.eu.org", - "gr.eu.org", - "hr.eu.org", - "hu.eu.org", - "ie.eu.org", - "il.eu.org", - "in.eu.org", - "int.eu.org", - "is.eu.org", - "it.eu.org", - "jp.eu.org", - "kr.eu.org", - "lt.eu.org", - "lu.eu.org", - "lv.eu.org", - "mc.eu.org", - "me.eu.org", - "mk.eu.org", - "mt.eu.org", - "my.eu.org", - "net.eu.org", - "ng.eu.org", - "nl.eu.org", - "no.eu.org", - "nz.eu.org", - "paris.eu.org", - "pl.eu.org", - "pt.eu.org", - "q-a.eu.org", - "ro.eu.org", - "ru.eu.org", - "se.eu.org", - "si.eu.org", - "sk.eu.org", - "tr.eu.org", - "uk.eu.org", - "us.eu.org", - "eu-1.evennode.com", - "eu-2.evennode.com", - "us-1.evennode.com", - "us-2.evennode.com", - "apps.fbsbx.com", - "map.fastly.net", - "a.prod.fastly.net", - "global.prod.fastly.net", - "a.ssl.fastly.net", - "b.ssl.fastly.net", - "global.ssl.fastly.net", - "fastlylb.net", - "map.fastlylb.net", - "fhapp.xyz", - "firebaseapp.com", - "flynnhub.com", - "freebox-os.com", - "freeboxos.com", - "fbx-os.fr", - "fbxos.fr", - "freebox-os.fr", - "freeboxos.fr", - "myfusion.cloud", - "futurehosting.at", - "futuremailing.at", - "*.ex.ortsinfo.at", - "*.kunden.ortsinfo.at", - "*.statics.cloud", - "service.gov.uk", - "github.io", - "githubusercontent.com", - "githubcloud.com", - "*.api.githubcloud.com", - "*.ext.githubcloud.com", - "gist.githubcloud.com", - "*.githubcloudusercontent.com", - "gitlab.io", - "homeoffice.gov.uk", - "ro.im", - "shop.ro", - "goip.de", - "*.0emm.com", - "appspot.com", - "blogspot.ae", - "blogspot.al", - "blogspot.am", - "blogspot.ba", - "blogspot.be", - "blogspot.bg", - "blogspot.bj", - "blogspot.ca", - "blogspot.cf", - "blogspot.ch", - "blogspot.cl", - "blogspot.co.at", - "blogspot.co.id", - "blogspot.co.il", - "blogspot.co.ke", - "blogspot.co.nz", - "blogspot.co.uk", - "blogspot.co.za", - "blogspot.com", - "blogspot.com.ar", - "blogspot.com.au", - "blogspot.com.br", - "blogspot.com.by", - "blogspot.com.co", - "blogspot.com.cy", - "blogspot.com.ee", - "blogspot.com.eg", - "blogspot.com.es", - "blogspot.com.mt", - "blogspot.com.ng", - "blogspot.com.tr", - "blogspot.com.uy", - "blogspot.cv", - "blogspot.cz", - "blogspot.de", - "blogspot.dk", - "blogspot.fi", - "blogspot.fr", - "blogspot.gr", - "blogspot.hk", - "blogspot.hr", - "blogspot.hu", - "blogspot.ie", - "blogspot.in", - "blogspot.is", - "blogspot.it", - "blogspot.jp", - "blogspot.kr", - "blogspot.li", - "blogspot.lt", - "blogspot.lu", - "blogspot.md", - "blogspot.mk", - "blogspot.mr", - "blogspot.mx", - "blogspot.my", - "blogspot.nl", - "blogspot.no", - "blogspot.pe", - "blogspot.pt", - "blogspot.qa", - "blogspot.re", - "blogspot.ro", - "blogspot.rs", - "blogspot.ru", - "blogspot.se", - "blogspot.sg", - "blogspot.si", - "blogspot.sk", - "blogspot.sn", - "blogspot.td", - "blogspot.tw", - "blogspot.ug", - "blogspot.vn", - "cloudfunctions.net", - "codespot.com", - "googleapis.com", - "googlecode.com", - "pagespeedmobilizer.com", - "publishproxy.com", - "withgoogle.com", - "withyoutube.com", - "hashbang.sh", - "hasura-app.io", - "hepforge.org", - "herokuapp.com", - "herokussl.com", - "iki.fi", - "biz.at", - "info.at", - "ac.leg.br", - "al.leg.br", - "am.leg.br", - "ap.leg.br", - "ba.leg.br", - "ce.leg.br", - "df.leg.br", - "es.leg.br", - "go.leg.br", - "ma.leg.br", - "mg.leg.br", - "ms.leg.br", - "mt.leg.br", - "pa.leg.br", - "pb.leg.br", - "pe.leg.br", - "pi.leg.br", - "pr.leg.br", - "rj.leg.br", - "rn.leg.br", - "ro.leg.br", - "rr.leg.br", - "rs.leg.br", - "sc.leg.br", - "se.leg.br", - "sp.leg.br", - "to.leg.br", - "*.triton.zone", - "*.cns.joyent.com", - "js.org", - "keymachine.de", - "knightpoint.systems", - "co.krd", - "edu.krd", - "*.magentosite.cloud", - "meteorapp.com", - "eu.meteorapp.com", - "co.pl", - "azurewebsites.net", - "azure-mobile.net", - "cloudapp.net", - "bmoattachments.org", - "4u.com", - "ngrok.io", - "nfshost.com", - "nsupdate.info", - "nerdpol.ovh", - "blogsyte.com", - "brasilia.me", - "cable-modem.org", - "ciscofreak.com", - "collegefan.org", - "couchpotatofries.org", - "damnserver.com", - "ddns.me", - "ditchyourip.com", - "dnsfor.me", - "dnsiskinky.com", - "dvrcam.info", - "dynns.com", - "eating-organic.net", - "fantasyleague.cc", - "geekgalaxy.com", - "golffan.us", - "health-carereform.com", - "homesecuritymac.com", - "homesecuritypc.com", - "hopto.me", - "ilovecollege.info", - "loginto.me", - "mlbfan.org", - "mmafan.biz", - "myactivedirectory.com", - "mydissent.net", - "myeffect.net", - "mymediapc.net", - "mypsx.net", - "mysecuritycamera.com", - "mysecuritycamera.net", - "mysecuritycamera.org", - "net-freaks.com", - "nflfan.org", - "nhlfan.net", - "no-ip.ca", - "no-ip.co.uk", - "no-ip.net", - "noip.us", - "onthewifi.com", - "pgafan.net", - "point2this.com", - "pointto.us", - "privatizehealthinsurance.net", - "quicksytes.com", - "read-books.org", - "securitytactics.com", - "serveexchange.com", - "servehumour.com", - "servep2p.com", - "servesarcasm.com", - "stufftoread.com", - "ufcfan.org", - "unusualperson.com", - "workisboring.com", - "3utilities.com", - "bounceme.net", - "ddns.net", - "ddnsking.com", - "gotdns.ch", - "hopto.org", - "myftp.biz", - "myftp.org", - "myvnc.com", - "no-ip.biz", - "no-ip.info", - "no-ip.org", - "noip.me", - "redirectme.net", - "servebeer.com", - "serveblog.net", - "servecounterstrike.com", - "serveftp.com", - "servegame.com", - "servehalflife.com", - "servehttp.com", - "serveirc.com", - "serveminecraft.net", - "servemp3.com", - "servepics.com", - "servequake.com", - "sytes.net", - "webhop.me", - "zapto.org", - "nyc.mn", - "nid.io", - "opencraft.hosting", - "operaunite.com", - "outsystemscloud.com", - "ownprovider.com", - "oy.lc", - "pgfog.com", - "pagefrontapp.com", - "art.pl", - "gliwice.pl", - "krakow.pl", - "poznan.pl", - "wroc.pl", - "zakopane.pl", - "pantheonsite.io", - "gotpantheon.com", - "mypep.link", - "on-web.fr", - "xen.prgmr.com", - "priv.at", - "protonet.io", - "chirurgiens-dentistes-en-france.fr", - "qa2.com", - "dev-myqnapcloud.com", - "alpha-myqnapcloud.com", - "myqnapcloud.com", - "rackmaze.com", - "rackmaze.net", - "rhcloud.com", - "hzc.io", - "wellbeingzone.eu", - "ptplus.fit", - "wellbeingzone.co.uk", - "sandcats.io", - "logoip.de", - "logoip.com", - "firewall-gateway.com", - "firewall-gateway.de", - "my-gateway.de", - "my-router.de", - "spdns.de", - "spdns.eu", - "firewall-gateway.net", - "my-firewall.org", - "myfirewall.org", - "spdns.org", - "biz.ua", - "co.ua", - "pp.ua", - "shiftedit.io", - "myshopblocks.com", - "1kapp.com", - "appchizi.com", - "applinzi.com", - "sinaapp.com", - "vipsinaapp.com", - "bounty-full.com", - "alpha.bounty-full.com", - "beta.bounty-full.com", - "static.land", - "dev.static.land", - "sites.static.land", - "apps.lair.io", - "*.stolos.io", - "spacekit.io", - "stackspace.space", - "diskstation.me", - "dscloud.biz", - "dscloud.me", - "dscloud.mobi", - "dsmynas.com", - "dsmynas.net", - "dsmynas.org", - "familyds.com", - "familyds.net", - "familyds.org", - "i234.me", - "myds.me", - "synology.me", - "taifun-dns.de", - "gda.pl", - "gdansk.pl", - "gdynia.pl", - "med.pl", - "sopot.pl", - "bloxcms.com", - "townnews-staging.com", - "*.transurl.be", - "*.transurl.eu", - "*.transurl.nl", - "tuxfamily.org", - "dd-dns.de", - "diskstation.eu", - "diskstation.org", - "dray-dns.de", - "draydns.de", - "dyn-vpn.de", - "dynvpn.de", - "mein-vigor.de", - "my-vigor.de", - "my-wan.de", - "syno-ds.de", - "synology-diskstation.de", - "synology-ds.de", - "hk.com", - "hk.org", - "ltd.hk", - "inc.hk", - "lib.de.us", - "router.management", - "remotewd.com", - "wmflabs.org", - "yolasite.com", - "ybo.faith", - "yombo.me", - "homelink.one", - "ybo.party", - "ybo.review", - "ybo.science", - "ybo.trade", - "za.net", - "za.org", - "now.sh", - "cc.ua", - "inf.ua", - "ltd.ua", -} - -var nodeLabels = [...]string{ - "aaa", - "aarp", - "abarth", - "abb", - "abbott", - "abbvie", - "abc", - "able", - "abogado", - "abudhabi", - "ac", - "academy", - "accenture", - "accountant", - "accountants", - "aco", - "active", - "actor", - "ad", - "adac", - "ads", - "adult", - "ae", - "aeg", - "aero", - "aetna", - "af", - "afamilycompany", - "afl", - "africa", - "ag", - "agakhan", - "agency", - "ai", - "aig", - "aigo", - "airbus", - "airforce", - "airtel", - "akdn", - "al", - "alfaromeo", - "alibaba", - "alipay", - "allfinanz", - "allstate", - "ally", - "alsace", - "alstom", - "am", - "americanexpress", - "americanfamily", - "amex", - "amfam", - "amica", - "amsterdam", - "analytics", - "android", - "anquan", - "anz", - "ao", - "aol", - "apartments", - "app", - "apple", - "aq", - "aquarelle", - "ar", - "arab", - "aramco", - "archi", - "army", - "arpa", - "art", - "arte", - "as", - "asda", - "asia", - "associates", - "at", - "athleta", - "attorney", - "au", - "auction", - "audi", - "audible", - "audio", - "auspost", - "author", - "auto", - "autos", - "avianca", - "aw", - "aws", - "ax", - "axa", - "az", - "azure", - "ba", - "baby", - "baidu", - "banamex", - "bananarepublic", - "band", - "bank", - "bar", - "barcelona", - "barclaycard", - "barclays", - "barefoot", - "bargains", - "baseball", - "basketball", - "bauhaus", - "bayern", - "bb", - "bbc", - "bbt", - "bbva", - "bcg", - "bcn", - "bd", - "be", - "beats", - "beauty", - "beer", - "bentley", - "berlin", - "best", - "bestbuy", - "bet", - "bf", - "bg", - "bh", - "bharti", - "bi", - "bible", - "bid", - "bike", - "bing", - "bingo", - "bio", - "biz", - "bj", - "black", - "blackfriday", - "blanco", - "blockbuster", - "blog", - "bloomberg", - "blue", - "bm", - "bms", - "bmw", - "bn", - "bnl", - "bnpparibas", - "bo", - "boats", - "boehringer", - "bofa", - "bom", - "bond", - "boo", - "book", - "booking", - "boots", - "bosch", - "bostik", - "boston", - "bot", - "boutique", - "box", - "br", - "bradesco", - "bridgestone", - "broadway", - "broker", - "brother", - "brussels", - "bs", - "bt", - "budapest", - "bugatti", - "build", - "builders", - "business", - "buy", - "buzz", - "bv", - "bw", - "by", - "bz", - "bzh", - "ca", - "cab", - "cafe", - "cal", - "call", - "calvinklein", - "cam", - "camera", - "camp", - "cancerresearch", - "canon", - "capetown", - "capital", - "capitalone", - "car", - "caravan", - "cards", - "care", - "career", - "careers", - "cars", - "cartier", - "casa", - "case", - "caseih", - "cash", - "casino", - "cat", - "catering", - "catholic", - "cba", - "cbn", - "cbre", - "cbs", - "cc", - "cd", - "ceb", - "center", - "ceo", - "cern", - "cf", - "cfa", - "cfd", - "cg", - "ch", - "chanel", - "channel", - "chase", - "chat", - "cheap", - "chintai", - "chloe", - "christmas", - "chrome", - "chrysler", - "church", - "ci", - "cipriani", - "circle", - "cisco", - "citadel", - "citi", - "citic", - "city", - "cityeats", - "ck", - "cl", - "claims", - "cleaning", - "click", - "clinic", - "clinique", - "clothing", - "cloud", - "club", - "clubmed", - "cm", - "cn", - "co", - "coach", - "codes", - "coffee", - "college", - "cologne", - "com", - "comcast", - "commbank", - "community", - "company", - "compare", - "computer", - "comsec", - "condos", - "construction", - "consulting", - "contact", - "contractors", - "cooking", - "cookingchannel", - "cool", - "coop", - "corsica", - "country", - "coupon", - "coupons", - "courses", - "cr", - "credit", - "creditcard", - "creditunion", - "cricket", - "crown", - "crs", - "cruise", - "cruises", - "csc", - "cu", - "cuisinella", - "cv", - "cw", - "cx", - "cy", - "cymru", - "cyou", - "cz", - "dabur", - "dad", - "dance", - "data", - "date", - "dating", - "datsun", - "day", - "dclk", - "dds", - "de", - "deal", - "dealer", - "deals", - "degree", - "delivery", - "dell", - "deloitte", - "delta", - "democrat", - "dental", - "dentist", - "desi", - "design", - "dev", - "dhl", - "diamonds", - "diet", - "digital", - "direct", - "directory", - "discount", - "discover", - "dish", - "diy", - "dj", - "dk", - "dm", - "dnp", - "do", - "docs", - "doctor", - "dodge", - "dog", - "doha", - "domains", - "dot", - "download", - "drive", - "dtv", - "dubai", - "duck", - "dunlop", - "duns", - "dupont", - "durban", - "dvag", - "dvr", - "dwg", - "dz", - "earth", - "eat", - "ec", - "eco", - "edeka", - "edu", - "education", - "ee", - "eg", - "email", - "emerck", - "energy", - "engineer", - "engineering", - "enterprises", - "epost", - "epson", - "equipment", - "er", - "ericsson", - "erni", - "es", - "esq", - "estate", - "esurance", - "et", - "etisalat", - "eu", - "eurovision", - "eus", - "events", - "everbank", - "exchange", - "expert", - "exposed", - "express", - "extraspace", - "fage", - "fail", - "fairwinds", - "faith", - "family", - "fan", - "fans", - "farm", - "farmers", - "fashion", - "fast", - "fedex", - "feedback", - "ferrari", - "ferrero", - "fi", - "fiat", - "fidelity", - "fido", - "film", - "final", - "finance", - "financial", - "fire", - "firestone", - "firmdale", - "fish", - "fishing", - "fit", - "fitness", - "fj", - "fk", - "flickr", - "flights", - "flir", - "florist", - "flowers", - "fly", - "fm", - "fo", - "foo", - "food", - "foodnetwork", - "football", - "ford", - "forex", - "forsale", - "forum", - "foundation", - "fox", - "fr", - "free", - "fresenius", - "frl", - "frogans", - "frontdoor", - "frontier", - "ftr", - "fujitsu", - "fujixerox", - "fun", - "fund", - "furniture", - "futbol", - "fyi", - "ga", - "gal", - "gallery", - "gallo", - "gallup", - "game", - "games", - "gap", - "garden", - "gb", - "gbiz", - "gd", - "gdn", - "ge", - "gea", - "gent", - "genting", - "george", - "gf", - "gg", - "ggee", - "gh", - "gi", - "gift", - "gifts", - "gives", - "giving", - "gl", - "glade", - "glass", - "gle", - "global", - "globo", - "gm", - "gmail", - "gmbh", - "gmo", - "gmx", - "gn", - "godaddy", - "gold", - "goldpoint", - "golf", - "goo", - "goodhands", - "goodyear", - "goog", - "google", - "gop", - "got", - "gov", - "gp", - "gq", - "gr", - "grainger", - "graphics", - "gratis", - "green", - "gripe", - "grocery", - "group", - "gs", - "gt", - "gu", - "guardian", - "gucci", - "guge", - "guide", - "guitars", - "guru", - "gw", - "gy", - "hair", - "hamburg", - "hangout", - "haus", - "hbo", - "hdfc", - "hdfcbank", - "health", - "healthcare", - "help", - "helsinki", - "here", - "hermes", - "hgtv", - "hiphop", - "hisamitsu", - "hitachi", - "hiv", - "hk", - "hkt", - "hm", - "hn", - "hockey", - "holdings", - "holiday", - "homedepot", - "homegoods", - "homes", - "homesense", - "honda", - "honeywell", - "horse", - "hospital", - "host", - "hosting", - "hot", - "hoteles", - "hotels", - "hotmail", - "house", - "how", - "hr", - "hsbc", - "ht", - "htc", - "hu", - "hughes", - "hyatt", - "hyundai", - "ibm", - "icbc", - "ice", - "icu", - "id", - "ie", - "ieee", - "ifm", - "iinet", - "ikano", - "il", - "im", - "imamat", - "imdb", - "immo", - "immobilien", - "in", - "industries", - "infiniti", - "info", - "ing", - "ink", - "institute", - "insurance", - "insure", - "int", - "intel", - "international", - "intuit", - "investments", - "io", - "ipiranga", - "iq", - "ir", - "irish", - "is", - "iselect", - "ismaili", - "ist", - "istanbul", - "it", - "itau", - "itv", - "iveco", - "iwc", - "jaguar", - "java", - "jcb", - "jcp", - "je", - "jeep", - "jetzt", - "jewelry", - "jio", - "jlc", - "jll", - "jm", - "jmp", - "jnj", - "jo", - "jobs", - "joburg", - "jot", - "joy", - "jp", - "jpmorgan", - "jprs", - "juegos", - "juniper", - "kaufen", - "kddi", - "ke", - "kerryhotels", - "kerrylogistics", - "kerryproperties", - "kfh", - "kg", - "kh", - "ki", - "kia", - "kim", - "kinder", - "kindle", - "kitchen", - "kiwi", - "km", - "kn", - "koeln", - "komatsu", - "kosher", - "kp", - "kpmg", - "kpn", - "kr", - "krd", - "kred", - "kuokgroup", - "kw", - "ky", - "kyoto", - "kz", - "la", - "lacaixa", - "ladbrokes", - "lamborghini", - "lamer", - "lancaster", - "lancia", - "lancome", - "land", - "landrover", - "lanxess", - "lasalle", - "lat", - "latino", - "latrobe", - "law", - "lawyer", - "lb", - "lc", - "lds", - "lease", - "leclerc", - "lefrak", - "legal", - "lego", - "lexus", - "lgbt", - "li", - "liaison", - "lidl", - "life", - "lifeinsurance", - "lifestyle", - "lighting", - "like", - "lilly", - "limited", - "limo", - "lincoln", - "linde", - "link", - "lipsy", - "live", - "living", - "lixil", - "lk", - "loan", - "loans", - "locker", - "locus", - "loft", - "lol", - "london", - "lotte", - "lotto", - "love", - "lpl", - "lplfinancial", - "lr", - "ls", - "lt", - "ltd", - "ltda", - "lu", - "lundbeck", - "lupin", - "luxe", - "luxury", - "lv", - "ly", - "ma", - "macys", - "madrid", - "maif", - "maison", - "makeup", - "man", - "management", - "mango", - "map", - "market", - "marketing", - "markets", - "marriott", - "marshalls", - "maserati", - "mattel", - "mba", - "mc", - "mcd", - "mcdonalds", - "mckinsey", - "md", - "me", - "med", - "media", - "meet", - "melbourne", - "meme", - "memorial", - "men", - "menu", - "meo", - "merckmsd", - "metlife", - "mg", - "mh", - "miami", - "microsoft", - "mil", - "mini", - "mint", - "mit", - "mitsubishi", - "mk", - "ml", - "mlb", - "mls", - "mm", - "mma", - "mn", - "mo", - "mobi", - "mobile", - "mobily", - "moda", - "moe", - "moi", - "mom", - "monash", - "money", - "monster", - "montblanc", - "mopar", - "mormon", - "mortgage", - "moscow", - "moto", - "motorcycles", - "mov", - "movie", - "movistar", - "mp", - "mq", - "mr", - "ms", - "msd", - "mt", - "mtn", - "mtpc", - "mtr", - "mu", - "museum", - "mutual", - "mutuelle", - "mv", - "mw", - "mx", - "my", - "mz", - "na", - "nab", - "nadex", - "nagoya", - "name", - "nationwide", - "natura", - "navy", - "nba", - "nc", - "ne", - "nec", - "net", - "netbank", - "netflix", - "network", - "neustar", - "new", - "newholland", - "news", - "next", - "nextdirect", - "nexus", - "nf", - "nfl", - "ng", - "ngo", - "nhk", - "ni", - "nico", - "nike", - "nikon", - "ninja", - "nissan", - "nissay", - "nl", - "no", - "nokia", - "northwesternmutual", - "norton", - "now", - "nowruz", - "nowtv", - "np", - "nr", - "nra", - "nrw", - "ntt", - "nu", - "nyc", - "nz", - "obi", - "observer", - "off", - "office", - "okinawa", - "olayan", - "olayangroup", - "oldnavy", - "ollo", - "om", - "omega", - "one", - "ong", - "onion", - "onl", - "online", - "onyourside", - "ooo", - "open", - "oracle", - "orange", - "org", - "organic", - "orientexpress", - "origins", - "osaka", - "otsuka", - "ott", - "ovh", - "pa", - "page", - "pamperedchef", - "panasonic", - "panerai", - "paris", - "pars", - "partners", - "parts", - "party", - "passagens", - "pay", - "pccw", - "pe", - "pet", - "pf", - "pfizer", - "pg", - "ph", - "pharmacy", - "phd", - "philips", - "phone", - "photo", - "photography", - "photos", - "physio", - "piaget", - "pics", - "pictet", - "pictures", - "pid", - "pin", - "ping", - "pink", - "pioneer", - "pizza", - "pk", - "pl", - "place", - "play", - "playstation", - "plumbing", - "plus", - "pm", - "pn", - "pnc", - "pohl", - "poker", - "politie", - "porn", - "post", - "pr", - "pramerica", - "praxi", - "press", - "prime", - "pro", - "prod", - "productions", - "prof", - "progressive", - "promo", - "properties", - "property", - "protection", - "pru", - "prudential", - "ps", - "pt", - "pub", - "pw", - "pwc", - "py", - "qa", - "qpon", - "quebec", - "quest", - "qvc", - "racing", - "radio", - "raid", - "re", - "read", - "realestate", - "realtor", - "realty", - "recipes", - "red", - "redstone", - "redumbrella", - "rehab", - "reise", - "reisen", - "reit", - "reliance", - "ren", - "rent", - "rentals", - "repair", - "report", - "republican", - "rest", - "restaurant", - "review", - "reviews", - "rexroth", - "rich", - "richardli", - "ricoh", - "rightathome", - "ril", - "rio", - "rip", - "rmit", - "ro", - "rocher", - "rocks", - "rodeo", - "rogers", - "room", - "rs", - "rsvp", - "ru", - "ruhr", - "run", - "rw", - "rwe", - "ryukyu", - "sa", - "saarland", - "safe", - "safety", - "sakura", - "sale", - "salon", - "samsclub", - "samsung", - "sandvik", - "sandvikcoromant", - "sanofi", - "sap", - "sapo", - "sarl", - "sas", - "save", - "saxo", - "sb", - "sbi", - "sbs", - "sc", - "sca", - "scb", - "schaeffler", - "schmidt", - "scholarships", - "school", - "schule", - "schwarz", - "science", - "scjohnson", - "scor", - "scot", - "sd", - "se", - "search", - "seat", - "secure", - "security", - "seek", - "select", - "sener", - "services", - "ses", - "seven", - "sew", - "sex", - "sexy", - "sfr", - "sg", - "sh", - "shangrila", - "sharp", - "shaw", - "shell", - "shia", - "shiksha", - "shoes", - "shop", - "shopping", - "shouji", - "show", - "showtime", - "shriram", - "si", - "silk", - "sina", - "singles", - "site", - "sj", - "sk", - "ski", - "skin", - "sky", - "skype", - "sl", - "sling", - "sm", - "smart", - "smile", - "sn", - "sncf", - "so", - "soccer", - "social", - "softbank", - "software", - "sohu", - "solar", - "solutions", - "song", - "sony", - "soy", - "space", - "spiegel", - "spot", - "spreadbetting", - "sr", - "srl", - "srt", - "st", - "stada", - "staples", - "star", - "starhub", - "statebank", - "statefarm", - "statoil", - "stc", - "stcgroup", - "stockholm", - "storage", - "store", - "stream", - "studio", - "study", - "style", - "su", - "sucks", - "supplies", - "supply", - "support", - "surf", - "surgery", - "suzuki", - "sv", - "swatch", - "swiftcover", - "swiss", - "sx", - "sy", - "sydney", - "symantec", - "systems", - "sz", - "tab", - "taipei", - "talk", - "taobao", - "target", - "tatamotors", - "tatar", - "tattoo", - "tax", - "taxi", - "tc", - "tci", - "td", - "tdk", - "team", - "tech", - "technology", - "tel", - "telecity", - "telefonica", - "temasek", - "tennis", - "teva", - "tf", - "tg", - "th", - "thd", - "theater", - "theatre", - "theguardian", - "tiaa", - "tickets", - "tienda", - "tiffany", - "tips", - "tires", - "tirol", - "tj", - "tjmaxx", - "tjx", - "tk", - "tkmaxx", - "tl", - "tm", - "tmall", - "tn", - "to", - "today", - "tokyo", - "tools", - "top", - "toray", - "toshiba", - "total", - "tours", - "town", - "toyota", - "toys", - "tr", - "trade", - "trading", - "training", - "travel", - "travelchannel", - "travelers", - "travelersinsurance", - "trust", - "trv", - "tt", - "tube", - "tui", - "tunes", - "tushu", - "tv", - "tvs", - "tw", - "tz", - "ua", - "ubank", - "ubs", - "uconnect", - "ug", - "uk", - "unicom", - "university", - "uno", - "uol", - "ups", - "us", - "uy", - "uz", - "va", - "vacations", - "vana", - "vanguard", - "vc", - "ve", - "vegas", - "ventures", - "verisign", - "versicherung", - "vet", - "vg", - "vi", - "viajes", - "video", - "vig", - "viking", - "villas", - "vin", - "vip", - "virgin", - "visa", - "vision", - "vista", - "vistaprint", - "viva", - "vivo", - "vlaanderen", - "vn", - "vodka", - "volkswagen", - "volvo", - "vote", - "voting", - "voto", - "voyage", - "vu", - "vuelos", - "wales", - "walmart", - "walter", - "wang", - "wanggou", - "warman", - "watch", - "watches", - "weather", - "weatherchannel", - "webcam", - "weber", - "website", - "wed", - "wedding", - "weibo", - "weir", - "wf", - "whoswho", - "wien", - "wiki", - "williamhill", - "win", - "windows", - "wine", - "winners", - "wme", - "wolterskluwer", - "woodside", - "work", - "works", - "world", - "wow", - "ws", - "wtc", - "wtf", - "xbox", - "xerox", - "xfinity", - "xihuan", - "xin", - "xn--11b4c3d", - "xn--1ck2e1b", - "xn--1qqw23a", - "xn--30rr7y", - "xn--3bst00m", - "xn--3ds443g", - "xn--3e0b707e", - "xn--3oq18vl8pn36a", - "xn--3pxu8k", - "xn--42c2d9a", - "xn--45brj9c", - "xn--45q11c", - "xn--4gbrim", - "xn--4gq48lf9j", - "xn--54b7fta0cc", - "xn--55qw42g", - "xn--55qx5d", - "xn--5su34j936bgsg", - "xn--5tzm5g", - "xn--6frz82g", - "xn--6qq986b3xl", - "xn--80adxhks", - "xn--80ao21a", - "xn--80aqecdr1a", - "xn--80asehdb", - "xn--80aswg", - "xn--8y0a063a", - "xn--90a3ac", - "xn--90ais", - "xn--9dbq2a", - "xn--9et52u", - "xn--9krt00a", - "xn--b4w605ferd", - "xn--bck1b9a5dre4c", - "xn--c1avg", - "xn--c2br7g", - "xn--cck2b3b", - "xn--cg4bki", - "xn--clchc0ea0b2g2a9gcd", - "xn--czr694b", - "xn--czrs0t", - "xn--czru2d", - "xn--d1acj3b", - "xn--d1alf", - "xn--e1a4c", - "xn--eckvdtc9d", - "xn--efvy88h", - "xn--estv75g", - "xn--fct429k", - "xn--fhbei", - "xn--fiq228c5hs", - "xn--fiq64b", - "xn--fiqs8s", - "xn--fiqz9s", - "xn--fjq720a", - "xn--flw351e", - "xn--fpcrj9c3d", - "xn--fzc2c9e2c", - "xn--fzys8d69uvgm", - "xn--g2xx48c", - "xn--gckr3f0f", - "xn--gecrj9c", - "xn--gk3at1e", - "xn--h2brj9c", - "xn--hxt814e", - "xn--i1b6b1a6a2e", - "xn--imr513n", - "xn--io0a7i", - "xn--j1aef", - "xn--j1amh", - "xn--j6w193g", - "xn--jlq61u9w7b", - "xn--jvr189m", - "xn--kcrx77d1x4a", - "xn--kprw13d", - "xn--kpry57d", - "xn--kpu716f", - "xn--kput3i", - "xn--l1acc", - "xn--lgbbat1ad8j", - "xn--mgb2ddes", - "xn--mgb9awbf", - "xn--mgba3a3ejt", - "xn--mgba3a4f16a", - "xn--mgba3a4fra", - "xn--mgba7c0bbn0a", - "xn--mgbaakc7dvf", - "xn--mgbaam7a8h", - "xn--mgbab2bd", - "xn--mgbai9a5eva00b", - "xn--mgbai9azgqp6j", - "xn--mgbayh7gpa", - "xn--mgbb9fbpob", - "xn--mgbbh1a71e", - "xn--mgbc0a9azcg", - "xn--mgbca7dzdo", - "xn--mgberp4a5d4a87g", - "xn--mgberp4a5d4ar", - "xn--mgbi4ecexp", - "xn--mgbpl2fh", - "xn--mgbqly7c0a67fbc", - "xn--mgbqly7cvafr", - "xn--mgbt3dhd", - "xn--mgbtf8fl", - "xn--mgbtx2b", - "xn--mgbx4cd0ab", - "xn--mix082f", - "xn--mix891f", - "xn--mk1bu44c", - "xn--mxtq1m", - "xn--ngbc5azd", - "xn--ngbe9e0a", - "xn--ngbrx", - "xn--nnx388a", - "xn--node", - "xn--nqv7f", - "xn--nqv7fs00ema", - "xn--nyqy26a", - "xn--o3cw4h", - "xn--ogbpf8fl", - "xn--p1acf", - "xn--p1ai", - "xn--pbt977c", - "xn--pgbs0dh", - "xn--pssy2u", - "xn--q9jyb4c", - "xn--qcka1pmc", - "xn--qxam", - "xn--rhqv96g", - "xn--rovu88b", - "xn--s9brj9c", - "xn--ses554g", - "xn--t60b56a", - "xn--tckwe", - "xn--tiq49xqyj", - "xn--unup4y", - "xn--vermgensberater-ctb", - "xn--vermgensberatung-pwb", - "xn--vhquv", - "xn--vuq861b", - "xn--w4r85el8fhu5dnra", - "xn--w4rs40l", - "xn--wgbh1c", - "xn--wgbl6a", - "xn--xhq521b", - "xn--xkc2al3hye2a", - "xn--xkc2dl3a5ee0h", - "xn--y9a3aq", - "xn--yfro4i67o", - "xn--ygbi2ammx", - "xn--zfr164b", - "xperia", - "xxx", - "xyz", - "yachts", - "yahoo", - "yamaxun", - "yandex", - "ye", - "yodobashi", - "yoga", - "yokohama", - "you", - "youtube", - "yt", - "yun", - "za", - "zappos", - "zara", - "zero", - "zip", - "zippo", - "zm", - "zone", - "zuerich", - "zw", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "nom", - "ac", - "blogspot", - "co", - "gov", - "mil", - "net", - "org", - "sch", - "accident-investigation", - "accident-prevention", - "aerobatic", - "aeroclub", - "aerodrome", - "agents", - "air-surveillance", - "air-traffic-control", - "aircraft", - "airline", - "airport", - "airtraffic", - "ambulance", - "amusement", - "association", - "author", - "ballooning", - "broker", - "caa", - "cargo", - "catering", - "certification", - "championship", - "charter", - "civilaviation", - "club", - "conference", - "consultant", - "consulting", - "control", - "council", - "crew", - "design", - "dgca", - "educator", - "emergency", - "engine", - "engineer", - "entertainment", - "equipment", - "exchange", - "express", - "federation", - "flight", - "freight", - "fuel", - "gliding", - "government", - "groundhandling", - "group", - "hanggliding", - "homebuilt", - "insurance", - "journal", - "journalist", - "leasing", - "logistics", - "magazine", - "maintenance", - "media", - "microlight", - "modelling", - "navigation", - "parachuting", - "paragliding", - "passenger-association", - "pilot", - "press", - "production", - "recreation", - "repbody", - "res", - "research", - "rotorcraft", - "safety", - "scientist", - "services", - "show", - "skydiving", - "software", - "student", - "trader", - "trading", - "trainer", - "union", - "workinggroup", - "works", - "com", - "edu", - "gov", - "net", - "org", - "co", - "com", - "net", - "nom", - "org", - "com", - "net", - "off", - "org", - "blogspot", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "blogspot", - "co", - "ed", - "gv", - "it", - "og", - "pb", - "com", - "edu", - "gob", - "gov", - "int", - "mil", - "net", - "org", - "tur", - "blogspot", - "e164", - "in-addr", - "ip6", - "iris", - "uri", - "urn", - "gov", - "cloudns", - "ac", - "biz", - "co", - "futurehosting", - "futuremailing", - "gv", - "info", - "or", - "ortsinfo", - "priv", - "blogspot", - "ex", - "kunden", - "act", - "asn", - "com", - "conf", - "edu", - "gov", - "id", - "info", - "net", - "nsw", - "nt", - "org", - "oz", - "qld", - "sa", - "tas", - "vic", - "wa", - "blogspot", - "act", - "nsw", - "nt", - "qld", - "sa", - "tas", - "vic", - "wa", - "qld", - "sa", - "tas", - "vic", - "wa", - "com", - "biz", - "com", - "edu", - "gov", - "info", - "int", - "mil", - "name", - "net", - "org", - "pp", - "pro", - "blogspot", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "biz", - "co", - "com", - "edu", - "gov", - "info", - "net", - "org", - "store", - "tv", - "ac", - "blogspot", - "transurl", - "gov", - "0", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "a", - "b", - "blogspot", - "c", - "d", - "e", - "f", - "g", - "h", - "i", - "j", - "k", - "l", - "m", - "n", - "o", - "p", - "q", - "r", - "s", - "t", - "u", - "v", - "w", - "x", - "y", - "z", - "com", - "edu", - "gov", - "net", - "org", - "co", - "com", - "edu", - "or", - "org", - "cloudns", - "dscloud", - "dyndns", - "for-better", - "for-more", - "for-some", - "for-the", - "mmafan", - "myftp", - "no-ip", - "selfip", - "webhop", - "asso", - "barreau", - "blogspot", - "gouv", - "com", - "edu", - "gov", - "net", - "org", - "com", - "edu", - "gob", - "gov", - "int", - "mil", - "net", - "org", - "tv", - "adm", - "adv", - "agr", - "am", - "arq", - "art", - "ato", - "b", - "bio", - "blog", - "bmd", - "cim", - "cng", - "cnt", - "com", - "coop", - "ecn", - "eco", - "edu", - "emp", - "eng", - "esp", - "etc", - "eti", - "far", - "flog", - "fm", - "fnd", - "fot", - "fst", - "g12", - "ggf", - "gov", - "imb", - "ind", - "inf", - "jor", - "jus", - "leg", - "lel", - "mat", - "med", - "mil", - "mp", - "mus", - "net", - "nom", - "not", - "ntr", - "odo", - "org", - "ppg", - "pro", - "psc", - "psi", - "qsl", - "radio", - "rec", - "slg", - "srv", - "taxi", - "teo", - "tmp", - "trd", - "tur", - "tv", - "vet", - "vlog", - "wiki", - "zlg", - "blogspot", - "ac", - "al", - "am", - "ap", - "ba", - "ce", - "df", - "es", - "go", - "ma", - "mg", - "ms", - "mt", - "pa", - "pb", - "pe", - "pi", - "pr", - "rj", - "rn", - "ro", - "rr", - "rs", - "sc", - "se", - "sp", - "to", - "com", - "edu", - "gov", - "net", - "org", - "com", - "edu", - "gov", - "net", - "org", - "co", - "org", - "com", - "gov", - "mil", - "of", - "blogspot", - "com", - "edu", - "gov", - "net", - "org", - "za", - "ab", - "bc", - "blogspot", - "co", - "gc", - "mb", - "nb", - "nf", - "nl", - "no-ip", - "ns", - "nt", - "nu", - "on", - "pe", - "qc", - "sk", - "yk", - "cloudns", - "fantasyleague", - "ftpaccess", - "game-server", - "myphotos", - "scrapping", - "gov", - "blogspot", - "blogspot", - "gotdns", - "ac", - "asso", - "co", - "com", - "ed", - "edu", - "go", - "gouv", - "int", - "md", - "net", - "or", - "org", - "presse", - "xn--aroport-bya", - "www", - "blogspot", - "co", - "gob", - "gov", - "mil", - "magentosite", - "myfusion", - "statics", - "cloudns", - "co", - "com", - "gov", - "net", - "ac", - "ah", - "bj", - "com", - "cq", - "edu", - "fj", - "gd", - "gov", - "gs", - "gx", - "gz", - "ha", - "hb", - "he", - "hi", - "hk", - "hl", - "hn", - "jl", - "js", - "jx", - "ln", - "mil", - "mo", - "net", - "nm", - "nx", - "org", - "qh", - "sc", - "sd", - "sh", - "sn", - "sx", - "tj", - "tw", - "xj", - "xn--55qx5d", - "xn--io0a7i", - "xn--od0alg", - "xz", - "yn", - "zj", - "amazonaws", - "cn-north-1", - "compute", - "elb", - "elasticbeanstalk", - "s3", - "arts", - "com", - "edu", - "firm", - "gov", - "info", - "int", - "mil", - "net", - "nom", - "org", - "rec", - "web", - "blogspot", - "0emm", - "1kapp", - "3utilities", - "4u", - "africa", - "alpha-myqnapcloud", - "amazonaws", - "appchizi", - "applinzi", - "appspot", - "ar", - "betainabox", - "blogdns", - "blogspot", - "blogsyte", - "bloxcms", - "bounty-full", - "br", - "cechire", - "ciscofreak", - "cloudcontrolapp", - "cloudcontrolled", - "cn", - "co", - "codespot", - "damnserver", - "ddnsking", - "de", - "dev-myqnapcloud", - "ditchyourip", - "dnsalias", - "dnsdojo", - "dnsiskinky", - "doesntexist", - "dontexist", - "doomdns", - "dreamhosters", - "dsmynas", - "dyn-o-saur", - "dynalias", - "dyndns-at-home", - "dyndns-at-work", - "dyndns-blog", - "dyndns-free", - "dyndns-home", - "dyndns-ip", - "dyndns-mail", - "dyndns-office", - "dyndns-pics", - "dyndns-remote", - "dyndns-server", - "dyndns-web", - "dyndns-wiki", - "dyndns-work", - "dynns", - "elasticbeanstalk", - "est-a-la-maison", - "est-a-la-masion", - "est-le-patron", - "est-mon-blogueur", - "eu", - "evennode", - "familyds", - "fbsbx", - "firebaseapp", - "firewall-gateway", - "flynnhub", - "freebox-os", - "freeboxos", - "from-ak", - "from-al", - "from-ar", - "from-ca", - "from-ct", - "from-dc", - "from-de", - "from-fl", - "from-ga", - "from-hi", - "from-ia", - "from-id", - "from-il", - "from-in", - "from-ks", - "from-ky", - "from-ma", - "from-md", - "from-mi", - "from-mn", - "from-mo", - "from-ms", - "from-mt", - "from-nc", - "from-nd", - "from-ne", - "from-nh", - "from-nj", - "from-nm", - "from-nv", - "from-oh", - "from-ok", - "from-or", - "from-pa", - "from-pr", - "from-ri", - "from-sc", - "from-sd", - "from-tn", - "from-tx", - "from-ut", - "from-va", - "from-vt", - "from-wa", - "from-wi", - "from-wv", - "from-wy", - "gb", - "geekgalaxy", - "getmyip", - "githubcloud", - "githubcloudusercontent", - "githubusercontent", - "googleapis", - "googlecode", - "gotdns", - "gotpantheon", - "gr", - "health-carereform", - "herokuapp", - "herokussl", - "hk", - "hobby-site", - "homelinux", - "homesecuritymac", - "homesecuritypc", - "homeunix", - "hu", - "iamallama", - "is-a-anarchist", - "is-a-blogger", - "is-a-bookkeeper", - "is-a-bulls-fan", - "is-a-caterer", - "is-a-chef", - "is-a-conservative", - "is-a-cpa", - "is-a-cubicle-slave", - "is-a-democrat", - "is-a-designer", - "is-a-doctor", - "is-a-financialadvisor", - "is-a-geek", - "is-a-green", - "is-a-guru", - "is-a-hard-worker", - "is-a-hunter", - "is-a-landscaper", - "is-a-lawyer", - "is-a-liberal", - "is-a-libertarian", - "is-a-llama", - "is-a-musician", - "is-a-nascarfan", - "is-a-nurse", - "is-a-painter", - "is-a-personaltrainer", - "is-a-photographer", - "is-a-player", - "is-a-republican", - "is-a-rockstar", - "is-a-socialist", - "is-a-student", - "is-a-teacher", - "is-a-techie", - "is-a-therapist", - "is-an-accountant", - "is-an-actor", - "is-an-actress", - "is-an-anarchist", - "is-an-artist", - "is-an-engineer", - "is-an-entertainer", - "is-certified", - "is-gone", - "is-into-anime", - "is-into-cars", - "is-into-cartoons", - "is-into-games", - "is-leet", - "is-not-certified", - "is-slick", - "is-uberleet", - "is-with-theband", - "isa-geek", - "isa-hockeynut", - "issmarterthanyou", - "joyent", - "jpn", - "kr", - "likes-pie", - "likescandy", - "logoip", - "meteorapp", - "mex", - "myactivedirectory", - "myasustor", - "mydrobo", - "myqnapcloud", - "mysecuritycamera", - "myshopblocks", - "myvnc", - "neat-url", - "net-freaks", - "nfshost", - "no", - "on-aptible", - "onthewifi", - "operaunite", - "outsystemscloud", - "ownprovider", - "pagefrontapp", - "pagespeedmobilizer", - "pgfog", - "point2this", - "prgmr", - "publishproxy", - "qa2", - "qc", - "quicksytes", - "rackmaze", - "remotewd", - "rhcloud", - "ru", - "sa", - "saves-the-whales", - "se", - "securitytactics", - "selfip", - "sells-for-less", - "sells-for-u", - "servebbs", - "servebeer", - "servecounterstrike", - "serveexchange", - "serveftp", - "servegame", - "servehalflife", - "servehttp", - "servehumour", - "serveirc", - "servemp3", - "servep2p", - "servepics", - "servequake", - "servesarcasm", - "simple-url", - "sinaapp", - "space-to-rent", - "stufftoread", - "teaches-yoga", - "townnews-staging", - "uk", - "unusualperson", - "us", - "uy", - "vipsinaapp", - "withgoogle", - "withyoutube", - "workisboring", - "writesthisblog", - "xenapponazure", - "yolasite", - "za", - "ap-northeast-1", - "ap-northeast-2", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "compute", - "compute-1", - "elb", - "eu-central-1", - "eu-west-1", - "s3", - "s3-ap-northeast-1", - "s3-ap-northeast-2", - "s3-ap-south-1", - "s3-ap-southeast-1", - "s3-ap-southeast-2", - "s3-ca-central-1", - "s3-eu-central-1", - "s3-eu-west-1", - "s3-external-1", - "s3-fips-us-gov-west-1", - "s3-sa-east-1", - "s3-us-east-2", - "s3-us-gov-west-1", - "s3-us-west-1", - "s3-us-west-2", - "s3-website-ap-northeast-1", - "s3-website-ap-southeast-1", - "s3-website-ap-southeast-2", - "s3-website-eu-west-1", - "s3-website-sa-east-1", - "s3-website-us-east-1", - "s3-website-us-west-1", - "s3-website-us-west-2", - "sa-east-1", - "us-east-1", - "us-east-2", - "dualstack", - "s3", - "dualstack", - "s3", - "s3-website", - "s3", - "dualstack", - "s3", - "s3-website", - "s3", - "dualstack", - "s3", - "dualstack", - "s3", - "dualstack", - "s3", - "s3-website", - "s3", - "dualstack", - "s3", - "s3-website", - "s3", - "dualstack", - "s3", - "dualstack", - "s3", - "dualstack", - "s3", - "dualstack", - "s3", - "s3-website", - "s3", - "alpha", - "beta", - "eu-1", - "eu-2", - "us-1", - "us-2", - "apps", - "api", - "ext", - "gist", - "cns", - "eu", - "xen", - "ac", - "co", - "ed", - "fi", - "go", - "or", - "sa", - "com", - "edu", - "gov", - "inf", - "net", - "org", - "blogspot", - "com", - "edu", - "net", - "org", - "ath", - "gov", - "ac", - "biz", - "com", - "ekloges", - "gov", - "ltd", - "name", - "net", - "org", - "parliament", - "press", - "pro", - "tm", - "blogspot", - "blogspot", - "co", - "e4", - "realm", - "blogspot", - "com", - "cosidns", - "dd-dns", - "ddnss", - "dnshome", - "dnsupdater", - "dray-dns", - "draydns", - "dyn-ip24", - "dyn-vpn", - "dynamisches-dns", - "dyndns1", - "dynvpn", - "firewall-gateway", - "fuettertdasnetz", - "goip", - "home-webserver", - "internet-dns", - "isteingeek", - "istmein", - "keymachine", - "l-o-g-i-n", - "lebtimnetz", - "leitungsen", - "logoip", - "mein-vigor", - "my-gateway", - "my-router", - "my-vigor", - "my-wan", - "myhome-server", - "spdns", - "syno-ds", - "synology-diskstation", - "synology-ds", - "taifun-dns", - "traeumtgerade", - "dyn", - "dyn", - "dyndns", - "dyn", - "biz", - "blogspot", - "co", - "firm", - "reg", - "store", - "com", - "edu", - "gov", - "net", - "org", - "art", - "com", - "edu", - "gob", - "gov", - "mil", - "net", - "org", - "sld", - "web", - "art", - "asso", - "com", - "edu", - "gov", - "net", - "org", - "pol", - "com", - "edu", - "fin", - "gob", - "gov", - "info", - "k12", - "med", - "mil", - "net", - "org", - "pro", - "aip", - "com", - "edu", - "fie", - "gov", - "lib", - "med", - "org", - "pri", - "riik", - "blogspot", - "com", - "edu", - "eun", - "gov", - "mil", - "name", - "net", - "org", - "sci", - "blogspot", - "com", - "edu", - "gob", - "nom", - "org", - "blogspot", - "compute", - "biz", - "com", - "edu", - "gov", - "info", - "name", - "net", - "org", - "cloudns", - "diskstation", - "mycd", - "spdns", - "transurl", - "wellbeingzone", - "party", - "user", - "ybo", - "aland", - "blogspot", - "dy", - "iki", - "ptplus", - "aeroport", - "assedic", - "asso", - "avocat", - "avoues", - "blogspot", - "cci", - "chambagri", - "chirurgiens-dentistes", - "chirurgiens-dentistes-en-france", - "com", - "experts-comptables", - "fbx-os", - "fbxos", - "freebox-os", - "freeboxos", - "geometre-expert", - "gouv", - "greta", - "huissier-justice", - "medecin", - "nom", - "notaires", - "on-web", - "pharmacien", - "port", - "prd", - "presse", - "tm", - "veterinaire", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "pvt", - "co", - "net", - "org", - "com", - "edu", - "gov", - "mil", - "org", - "com", - "edu", - "gov", - "ltd", - "mod", - "org", - "co", - "com", - "edu", - "net", - "org", - "ac", - "com", - "edu", - "gov", - "net", - "org", - "asso", - "com", - "edu", - "mobi", - "net", - "org", - "blogspot", - "com", - "edu", - "gov", - "net", - "org", - "com", - "edu", - "gob", - "ind", - "mil", - "net", - "org", - "co", - "com", - "edu", - "gov", - "net", - "org", - "blogspot", - "com", - "edu", - "gov", - "idv", - "inc", - "ltd", - "net", - "org", - "xn--55qx5d", - "xn--ciqpn", - "xn--gmq050i", - "xn--gmqw5a", - "xn--io0a7i", - "xn--lcvr32d", - "xn--mk0axi", - "xn--mxtq1m", - "xn--od0alg", - "xn--od0aq3b", - "xn--tn0ag", - "xn--uc0atv", - "xn--uc0ay4a", - "xn--wcvs22d", - "xn--zf0avx", - "com", - "edu", - "gob", - "mil", - "net", - "org", - "opencraft", - "blogspot", - "com", - "from", - "iz", - "name", - "adult", - "art", - "asso", - "com", - "coop", - "edu", - "firm", - "gouv", - "info", - "med", - "net", - "org", - "perso", - "pol", - "pro", - "rel", - "shop", - "2000", - "agrar", - "blogspot", - "bolt", - "casino", - "city", - "co", - "erotica", - "erotika", - "film", - "forum", - "games", - "hotel", - "info", - "ingatlan", - "jogasz", - "konyvelo", - "lakas", - "media", - "news", - "org", - "priv", - "reklam", - "sex", - "shop", - "sport", - "suli", - "szex", - "tm", - "tozsde", - "utazas", - "video", - "ac", - "biz", - "co", - "desa", - "go", - "mil", - "my", - "net", - "or", - "sch", - "web", - "blogspot", - "blogspot", - "gov", - "ac", - "co", - "gov", - "idf", - "k12", - "muni", - "net", - "org", - "blogspot", - "ac", - "co", - "com", - "net", - "org", - "ro", - "tt", - "tv", - "ltd", - "plc", - "ac", - "blogspot", - "cloudns", - "co", - "edu", - "firm", - "gen", - "gov", - "ind", - "mil", - "net", - "nic", - "org", - "res", - "barrel-of-knowledge", - "barrell-of-knowledge", - "cloudns", - "dvrcam", - "dynamic-dns", - "dyndns", - "for-our", - "groks-the", - "groks-this", - "here-for-more", - "ilovecollege", - "knowsitall", - "no-ip", - "nsupdate", - "selfip", - "webhop", - "eu", - "backplaneapp", - "boxfuse", - "browsersafetymark", - "com", - "dedyn", - "drud", - "enonic", - "github", - "gitlab", - "hasura-app", - "hzc", - "lair", - "ngrok", - "nid", - "pantheonsite", - "protonet", - "sandcats", - "shiftedit", - "spacekit", - "stolos", - "customer", - "apps", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "ac", - "co", - "gov", - "id", - "net", - "org", - "sch", - "xn--mgba3a4f16a", - "xn--mgba3a4fra", - "blogspot", - "com", - "cupcake", - "edu", - "gov", - "int", - "net", - "org", - "abr", - "abruzzo", - "ag", - "agrigento", - "al", - "alessandria", - "alto-adige", - "altoadige", - "an", - "ancona", - "andria-barletta-trani", - "andria-trani-barletta", - "andriabarlettatrani", - "andriatranibarletta", - "ao", - "aosta", - "aosta-valley", - "aostavalley", - "aoste", - "ap", - "aq", - "aquila", - "ar", - "arezzo", - "ascoli-piceno", - "ascolipiceno", - "asti", - "at", - "av", - "avellino", - "ba", - "balsan", - "bari", - "barletta-trani-andria", - "barlettatraniandria", - "bas", - "basilicata", - "belluno", - "benevento", - "bergamo", - "bg", - "bi", - "biella", - "bl", - "blogspot", - "bn", - "bo", - "bologna", - "bolzano", - "bozen", - "br", - "brescia", - "brindisi", - "bs", - "bt", - "bz", - "ca", - "cagliari", - "cal", - "calabria", - "caltanissetta", - "cam", - "campania", - "campidano-medio", - "campidanomedio", - "campobasso", - "carbonia-iglesias", - "carboniaiglesias", - "carrara-massa", - "carraramassa", - "caserta", - "catania", - "catanzaro", - "cb", - "ce", - "cesena-forli", - "cesenaforli", - "ch", - "chieti", - "ci", - "cl", - "cn", - "co", - "como", - "cosenza", - "cr", - "cremona", - "crotone", - "cs", - "ct", - "cuneo", - "cz", - "dell-ogliastra", - "dellogliastra", - "edu", - "emilia-romagna", - "emiliaromagna", - "emr", - "en", - "enna", - "fc", - "fe", - "fermo", - "ferrara", - "fg", - "fi", - "firenze", - "florence", - "fm", - "foggia", - "forli-cesena", - "forlicesena", - "fr", - "friuli-v-giulia", - "friuli-ve-giulia", - "friuli-vegiulia", - "friuli-venezia-giulia", - "friuli-veneziagiulia", - "friuli-vgiulia", - "friuliv-giulia", - "friulive-giulia", - "friulivegiulia", - "friulivenezia-giulia", - "friuliveneziagiulia", - "friulivgiulia", - "frosinone", - "fvg", - "ge", - "genoa", - "genova", - "go", - "gorizia", - "gov", - "gr", - "grosseto", - "iglesias-carbonia", - "iglesiascarbonia", - "im", - "imperia", - "is", - "isernia", - "kr", - "la-spezia", - "laquila", - "laspezia", - "latina", - "laz", - "lazio", - "lc", - "le", - "lecce", - "lecco", - "li", - "lig", - "liguria", - "livorno", - "lo", - "lodi", - "lom", - "lombardia", - "lombardy", - "lt", - "lu", - "lucania", - "lucca", - "macerata", - "mantova", - "mar", - "marche", - "massa-carrara", - "massacarrara", - "matera", - "mb", - "mc", - "me", - "medio-campidano", - "mediocampidano", - "messina", - "mi", - "milan", - "milano", - "mn", - "mo", - "modena", - "mol", - "molise", - "monza", - "monza-brianza", - "monza-e-della-brianza", - "monzabrianza", - "monzaebrianza", - "monzaedellabrianza", - "ms", - "mt", - "na", - "naples", - "napoli", - "no", - "novara", - "nu", - "nuoro", - "og", - "ogliastra", - "olbia-tempio", - "olbiatempio", - "or", - "oristano", - "ot", - "pa", - "padova", - "padua", - "palermo", - "parma", - "pavia", - "pc", - "pd", - "pe", - "perugia", - "pesaro-urbino", - "pesarourbino", - "pescara", - "pg", - "pi", - "piacenza", - "piedmont", - "piemonte", - "pisa", - "pistoia", - "pmn", - "pn", - "po", - "pordenone", - "potenza", - "pr", - "prato", - "pt", - "pu", - "pug", - "puglia", - "pv", - "pz", - "ra", - "ragusa", - "ravenna", - "rc", - "re", - "reggio-calabria", - "reggio-emilia", - "reggiocalabria", - "reggioemilia", - "rg", - "ri", - "rieti", - "rimini", - "rm", - "rn", - "ro", - "roma", - "rome", - "rovigo", - "sa", - "salerno", - "sar", - "sardegna", - "sardinia", - "sassari", - "savona", - "si", - "sic", - "sicilia", - "sicily", - "siena", - "siracusa", - "so", - "sondrio", - "sp", - "sr", - "ss", - "suedtirol", - "sv", - "ta", - "taa", - "taranto", - "te", - "tempio-olbia", - "tempioolbia", - "teramo", - "terni", - "tn", - "to", - "torino", - "tos", - "toscana", - "tp", - "tr", - "trani-andria-barletta", - "trani-barletta-andria", - "traniandriabarletta", - "tranibarlettaandria", - "trapani", - "trentino", - "trentino-a-adige", - "trentino-aadige", - "trentino-alto-adige", - "trentino-altoadige", - "trentino-s-tirol", - "trentino-stirol", - "trentino-sud-tirol", - "trentino-sudtirol", - "trentino-sued-tirol", - "trentino-suedtirol", - "trentinoa-adige", - "trentinoaadige", - "trentinoalto-adige", - "trentinoaltoadige", - "trentinos-tirol", - "trentinostirol", - "trentinosud-tirol", - "trentinosudtirol", - "trentinosued-tirol", - "trentinosuedtirol", - "trento", - "treviso", - "trieste", - "ts", - "turin", - "tuscany", - "tv", - "ud", - "udine", - "umb", - "umbria", - "urbino-pesaro", - "urbinopesaro", - "va", - "val-d-aosta", - "val-daosta", - "vald-aosta", - "valdaosta", - "valle-aosta", - "valle-d-aosta", - "valle-daosta", - "valleaosta", - "valled-aosta", - "valledaosta", - "vallee-aoste", - "valleeaoste", - "vao", - "varese", - "vb", - "vc", - "vda", - "ve", - "ven", - "veneto", - "venezia", - "venice", - "verbania", - "vercelli", - "verona", - "vi", - "vibo-valentia", - "vibovalentia", - "vicenza", - "viterbo", - "vr", - "vs", - "vt", - "vv", - "co", - "net", - "org", - "com", - "edu", - "gov", - "mil", - "name", - "net", - "org", - "sch", - "ac", - "ad", - "aichi", - "akita", - "aomori", - "blogspot", - "chiba", - "co", - "ed", - "ehime", - "fukui", - "fukuoka", - "fukushima", - "gifu", - "go", - "gr", - "gunma", - "hiroshima", - "hokkaido", - "hyogo", - "ibaraki", - "ishikawa", - "iwate", - "kagawa", - "kagoshima", - "kanagawa", - "kawasaki", - "kitakyushu", - "kobe", - "kochi", - "kumamoto", - "kyoto", - "lg", - "mie", - "miyagi", - "miyazaki", - "nagano", - "nagasaki", - "nagoya", - "nara", - "ne", - "niigata", - "oita", - "okayama", - "okinawa", - "or", - "osaka", - "saga", - "saitama", - "sapporo", - "sendai", - "shiga", - "shimane", - "shizuoka", - "tochigi", - "tokushima", - "tokyo", - "tottori", - "toyama", - "wakayama", - "xn--0trq7p7nn", - "xn--1ctwo", - "xn--1lqs03n", - "xn--1lqs71d", - "xn--2m4a15e", - "xn--32vp30h", - "xn--4it168d", - "xn--4it797k", - "xn--4pvxs", - "xn--5js045d", - "xn--5rtp49c", - "xn--5rtq34k", - "xn--6btw5a", - "xn--6orx2r", - "xn--7t0a264c", - "xn--8ltr62k", - "xn--8pvr4u", - "xn--c3s14m", - "xn--d5qv7z876c", - "xn--djrs72d6uy", - "xn--djty4k", - "xn--efvn9s", - "xn--ehqz56n", - "xn--elqq16h", - "xn--f6qx53a", - "xn--k7yn95e", - "xn--kbrq7o", - "xn--klt787d", - "xn--kltp7d", - "xn--kltx9a", - "xn--klty5x", - "xn--mkru45i", - "xn--nit225k", - "xn--ntso0iqx3a", - "xn--ntsq17g", - "xn--pssu33l", - "xn--qqqt11m", - "xn--rht27z", - "xn--rht3d", - "xn--rht61e", - "xn--rny31h", - "xn--tor131o", - "xn--uist22h", - "xn--uisz3g", - "xn--uuwu58a", - "xn--vgu402c", - "xn--zbx025d", - "yamagata", - "yamaguchi", - "yamanashi", - "yokohama", - "aisai", - "ama", - "anjo", - "asuke", - "chiryu", - "chita", - "fuso", - "gamagori", - "handa", - "hazu", - "hekinan", - "higashiura", - "ichinomiya", - "inazawa", - "inuyama", - "isshiki", - "iwakura", - "kanie", - "kariya", - "kasugai", - "kira", - "kiyosu", - "komaki", - "konan", - "kota", - "mihama", - "miyoshi", - "nishio", - "nisshin", - "obu", - "oguchi", - "oharu", - "okazaki", - "owariasahi", - "seto", - "shikatsu", - "shinshiro", - "shitara", - "tahara", - "takahama", - "tobishima", - "toei", - "togo", - "tokai", - "tokoname", - "toyoake", - "toyohashi", - "toyokawa", - "toyone", - "toyota", - "tsushima", - "yatomi", - "akita", - "daisen", - "fujisato", - "gojome", - "hachirogata", - "happou", - "higashinaruse", - "honjo", - "honjyo", - "ikawa", - "kamikoani", - "kamioka", - "katagami", - "kazuno", - "kitaakita", - "kosaka", - "kyowa", - "misato", - "mitane", - "moriyoshi", - "nikaho", - "noshiro", - "odate", - "oga", - "ogata", - "semboku", - "yokote", - "yurihonjo", - "aomori", - "gonohe", - "hachinohe", - "hashikami", - "hiranai", - "hirosaki", - "itayanagi", - "kuroishi", - "misawa", - "mutsu", - "nakadomari", - "noheji", - "oirase", - "owani", - "rokunohe", - "sannohe", - "shichinohe", - "shingo", - "takko", - "towada", - "tsugaru", - "tsuruta", - "abiko", - "asahi", - "chonan", - "chosei", - "choshi", - "chuo", - "funabashi", - "futtsu", - "hanamigawa", - "ichihara", - "ichikawa", - "ichinomiya", - "inzai", - "isumi", - "kamagaya", - "kamogawa", - "kashiwa", - "katori", - "katsuura", - "kimitsu", - "kisarazu", - "kozaki", - "kujukuri", - "kyonan", - "matsudo", - "midori", - "mihama", - "minamiboso", - "mobara", - "mutsuzawa", - "nagara", - "nagareyama", - "narashino", - "narita", - "noda", - "oamishirasato", - "omigawa", - "onjuku", - "otaki", - "sakae", - "sakura", - "shimofusa", - "shirako", - "shiroi", - "shisui", - "sodegaura", - "sosa", - "tako", - "tateyama", - "togane", - "tohnosho", - "tomisato", - "urayasu", - "yachimata", - "yachiyo", - "yokaichiba", - "yokoshibahikari", - "yotsukaido", - "ainan", - "honai", - "ikata", - "imabari", - "iyo", - "kamijima", - "kihoku", - "kumakogen", - "masaki", - "matsuno", - "matsuyama", - "namikata", - "niihama", - "ozu", - "saijo", - "seiyo", - "shikokuchuo", - "tobe", - "toon", - "uchiko", - "uwajima", - "yawatahama", - "echizen", - "eiheiji", - "fukui", - "ikeda", - "katsuyama", - "mihama", - "minamiechizen", - "obama", - "ohi", - "ono", - "sabae", - "sakai", - "takahama", - "tsuruga", - "wakasa", - "ashiya", - "buzen", - "chikugo", - "chikuho", - "chikujo", - "chikushino", - "chikuzen", - "chuo", - "dazaifu", - "fukuchi", - "hakata", - "higashi", - "hirokawa", - "hisayama", - "iizuka", - "inatsuki", - "kaho", - "kasuga", - "kasuya", - "kawara", - "keisen", - "koga", - "kurate", - "kurogi", - "kurume", - "minami", - "miyako", - "miyama", - "miyawaka", - "mizumaki", - "munakata", - "nakagawa", - "nakama", - "nishi", - "nogata", - "ogori", - "okagaki", - "okawa", - "oki", - "omuta", - "onga", - "onojo", - "oto", - "saigawa", - "sasaguri", - "shingu", - "shinyoshitomi", - "shonai", - "soeda", - "sue", - "tachiarai", - "tagawa", - "takata", - "toho", - "toyotsu", - "tsuiki", - "ukiha", - "umi", - "usui", - "yamada", - "yame", - "yanagawa", - "yukuhashi", - "aizubange", - "aizumisato", - "aizuwakamatsu", - "asakawa", - "bandai", - "date", - "fukushima", - "furudono", - "futaba", - "hanawa", - "higashi", - "hirata", - "hirono", - "iitate", - "inawashiro", - "ishikawa", - "iwaki", - "izumizaki", - "kagamiishi", - "kaneyama", - "kawamata", - "kitakata", - "kitashiobara", - "koori", - "koriyama", - "kunimi", - "miharu", - "mishima", - "namie", - "nango", - "nishiaizu", - "nishigo", - "okuma", - "omotego", - "ono", - "otama", - "samegawa", - "shimogo", - "shirakawa", - "showa", - "soma", - "sukagawa", - "taishin", - "tamakawa", - "tanagura", - "tenei", - "yabuki", - "yamato", - "yamatsuri", - "yanaizu", - "yugawa", - "anpachi", - "ena", - "gifu", - "ginan", - "godo", - "gujo", - "hashima", - "hichiso", - "hida", - "higashishirakawa", - "ibigawa", - "ikeda", - "kakamigahara", - "kani", - "kasahara", - "kasamatsu", - "kawaue", - "kitagata", - "mino", - "minokamo", - "mitake", - "mizunami", - "motosu", - "nakatsugawa", - "ogaki", - "sakahogi", - "seki", - "sekigahara", - "shirakawa", - "tajimi", - "takayama", - "tarui", - "toki", - "tomika", - "wanouchi", - "yamagata", - "yaotsu", - "yoro", - "annaka", - "chiyoda", - "fujioka", - "higashiagatsuma", - "isesaki", - "itakura", - "kanna", - "kanra", - "katashina", - "kawaba", - "kiryu", - "kusatsu", - "maebashi", - "meiwa", - "midori", - "minakami", - "naganohara", - "nakanojo", - "nanmoku", - "numata", - "oizumi", - "ora", - "ota", - "shibukawa", - "shimonita", - "shinto", - "showa", - "takasaki", - "takayama", - "tamamura", - "tatebayashi", - "tomioka", - "tsukiyono", - "tsumagoi", - "ueno", - "yoshioka", - "asaminami", - "daiwa", - "etajima", - "fuchu", - "fukuyama", - "hatsukaichi", - "higashihiroshima", - "hongo", - "jinsekikogen", - "kaita", - "kui", - "kumano", - "kure", - "mihara", - "miyoshi", - "naka", - "onomichi", - "osakikamijima", - "otake", - "saka", - "sera", - "seranishi", - "shinichi", - "shobara", - "takehara", - "abashiri", - "abira", - "aibetsu", - "akabira", - "akkeshi", - "asahikawa", - "ashibetsu", - "ashoro", - "assabu", - "atsuma", - "bibai", - "biei", - "bifuka", - "bihoro", - "biratori", - "chippubetsu", - "chitose", - "date", - "ebetsu", - "embetsu", - "eniwa", - "erimo", - "esan", - "esashi", - "fukagawa", - "fukushima", - "furano", - "furubira", - "haboro", - "hakodate", - "hamatonbetsu", - "hidaka", - "higashikagura", - "higashikawa", - "hiroo", - "hokuryu", - "hokuto", - "honbetsu", - "horokanai", - "horonobe", - "ikeda", - "imakane", - "ishikari", - "iwamizawa", - "iwanai", - "kamifurano", - "kamikawa", - "kamishihoro", - "kamisunagawa", - "kamoenai", - "kayabe", - "kembuchi", - "kikonai", - "kimobetsu", - "kitahiroshima", - "kitami", - "kiyosato", - "koshimizu", - "kunneppu", - "kuriyama", - "kuromatsunai", - "kushiro", - "kutchan", - "kyowa", - "mashike", - "matsumae", - "mikasa", - "minamifurano", - "mombetsu", - "moseushi", - "mukawa", - "muroran", - "naie", - "nakagawa", - "nakasatsunai", - "nakatombetsu", - "nanae", - "nanporo", - "nayoro", - "nemuro", - "niikappu", - "niki", - "nishiokoppe", - "noboribetsu", - "numata", - "obihiro", - "obira", - "oketo", - "okoppe", - "otaru", - "otobe", - "otofuke", - "otoineppu", - "oumu", - "ozora", - "pippu", - "rankoshi", - "rebun", - "rikubetsu", - "rishiri", - "rishirifuji", - "saroma", - "sarufutsu", - "shakotan", - "shari", - "shibecha", - "shibetsu", - "shikabe", - "shikaoi", - "shimamaki", - "shimizu", - "shimokawa", - "shinshinotsu", - "shintoku", - "shiranuka", - "shiraoi", - "shiriuchi", - "sobetsu", - "sunagawa", - "taiki", - "takasu", - "takikawa", - "takinoue", - "teshikaga", - "tobetsu", - "tohma", - "tomakomai", - "tomari", - "toya", - "toyako", - "toyotomi", - "toyoura", - "tsubetsu", - "tsukigata", - "urakawa", - "urausu", - "uryu", - "utashinai", - "wakkanai", - "wassamu", - "yakumo", - "yoichi", - "aioi", - "akashi", - "ako", - "amagasaki", - "aogaki", - "asago", - "ashiya", - "awaji", - "fukusaki", - "goshiki", - "harima", - "himeji", - "ichikawa", - "inagawa", - "itami", - "kakogawa", - "kamigori", - "kamikawa", - "kasai", - "kasuga", - "kawanishi", - "miki", - "minamiawaji", - "nishinomiya", - "nishiwaki", - "ono", - "sanda", - "sannan", - "sasayama", - "sayo", - "shingu", - "shinonsen", - "shiso", - "sumoto", - "taishi", - "taka", - "takarazuka", - "takasago", - "takino", - "tamba", - "tatsuno", - "toyooka", - "yabu", - "yashiro", - "yoka", - "yokawa", - "ami", - "asahi", - "bando", - "chikusei", - "daigo", - "fujishiro", - "hitachi", - "hitachinaka", - "hitachiomiya", - "hitachiota", - "ibaraki", - "ina", - "inashiki", - "itako", - "iwama", - "joso", - "kamisu", - "kasama", - "kashima", - "kasumigaura", - "koga", - "miho", - "mito", - "moriya", - "naka", - "namegata", - "oarai", - "ogawa", - "omitama", - "ryugasaki", - "sakai", - "sakuragawa", - "shimodate", - "shimotsuma", - "shirosato", - "sowa", - "suifu", - "takahagi", - "tamatsukuri", - "tokai", - "tomobe", - "tone", - "toride", - "tsuchiura", - "tsukuba", - "uchihara", - "ushiku", - "yachiyo", - "yamagata", - "yawara", - "yuki", - "anamizu", - "hakui", - "hakusan", - "kaga", - "kahoku", - "kanazawa", - "kawakita", - "komatsu", - "nakanoto", - "nanao", - "nomi", - "nonoichi", - "noto", - "shika", - "suzu", - "tsubata", - "tsurugi", - "uchinada", - "wajima", - "fudai", - "fujisawa", - "hanamaki", - "hiraizumi", - "hirono", - "ichinohe", - "ichinoseki", - "iwaizumi", - "iwate", - "joboji", - "kamaishi", - "kanegasaki", - "karumai", - "kawai", - "kitakami", - "kuji", - "kunohe", - "kuzumaki", - "miyako", - "mizusawa", - "morioka", - "ninohe", - "noda", - "ofunato", - "oshu", - "otsuchi", - "rikuzentakata", - "shiwa", - "shizukuishi", - "sumita", - "tanohata", - "tono", - "yahaba", - "yamada", - "ayagawa", - "higashikagawa", - "kanonji", - "kotohira", - "manno", - "marugame", - "mitoyo", - "naoshima", - "sanuki", - "tadotsu", - "takamatsu", - "tonosho", - "uchinomi", - "utazu", - "zentsuji", - "akune", - "amami", - "hioki", - "isa", - "isen", - "izumi", - "kagoshima", - "kanoya", - "kawanabe", - "kinko", - "kouyama", - "makurazaki", - "matsumoto", - "minamitane", - "nakatane", - "nishinoomote", - "satsumasendai", - "soo", - "tarumizu", - "yusui", - "aikawa", - "atsugi", - "ayase", - "chigasaki", - "ebina", - "fujisawa", - "hadano", - "hakone", - "hiratsuka", - "isehara", - "kaisei", - "kamakura", - "kiyokawa", - "matsuda", - "minamiashigara", - "miura", - "nakai", - "ninomiya", - "odawara", - "oi", - "oiso", - "sagamihara", - "samukawa", - "tsukui", - "yamakita", - "yamato", - "yokosuka", - "yugawara", - "zama", - "zushi", - "city", - "city", - "city", - "aki", - "geisei", - "hidaka", - "higashitsuno", - "ino", - "kagami", - "kami", - "kitagawa", - "kochi", - "mihara", - "motoyama", - "muroto", - "nahari", - "nakamura", - "nankoku", - "nishitosa", - "niyodogawa", - "ochi", - "okawa", - "otoyo", - "otsuki", - "sakawa", - "sukumo", - "susaki", - "tosa", - "tosashimizu", - "toyo", - "tsuno", - "umaji", - "yasuda", - "yusuhara", - "amakusa", - "arao", - "aso", - "choyo", - "gyokuto", - "kamiamakusa", - "kikuchi", - "kumamoto", - "mashiki", - "mifune", - "minamata", - "minamioguni", - "nagasu", - "nishihara", - "oguni", - "ozu", - "sumoto", - "takamori", - "uki", - "uto", - "yamaga", - "yamato", - "yatsushiro", - "ayabe", - "fukuchiyama", - "higashiyama", - "ide", - "ine", - "joyo", - "kameoka", - "kamo", - "kita", - "kizu", - "kumiyama", - "kyotamba", - "kyotanabe", - "kyotango", - "maizuru", - "minami", - "minamiyamashiro", - "miyazu", - "muko", - "nagaokakyo", - "nakagyo", - "nantan", - "oyamazaki", - "sakyo", - "seika", - "tanabe", - "uji", - "ujitawara", - "wazuka", - "yamashina", - "yawata", - "asahi", - "inabe", - "ise", - "kameyama", - "kawagoe", - "kiho", - "kisosaki", - "kiwa", - "komono", - "kumano", - "kuwana", - "matsusaka", - "meiwa", - "mihama", - "minamiise", - "misugi", - "miyama", - "nabari", - "shima", - "suzuka", - "tado", - "taiki", - "taki", - "tamaki", - "toba", - "tsu", - "udono", - "ureshino", - "watarai", - "yokkaichi", - "furukawa", - "higashimatsushima", - "ishinomaki", - "iwanuma", - "kakuda", - "kami", - "kawasaki", - "marumori", - "matsushima", - "minamisanriku", - "misato", - "murata", - "natori", - "ogawara", - "ohira", - "onagawa", - "osaki", - "rifu", - "semine", - "shibata", - "shichikashuku", - "shikama", - "shiogama", - "shiroishi", - "tagajo", - "taiwa", - "tome", - "tomiya", - "wakuya", - "watari", - "yamamoto", - "zao", - "aya", - "ebino", - "gokase", - "hyuga", - "kadogawa", - "kawaminami", - "kijo", - "kitagawa", - "kitakata", - "kitaura", - "kobayashi", - "kunitomi", - "kushima", - "mimata", - "miyakonojo", - "miyazaki", - "morotsuka", - "nichinan", - "nishimera", - "nobeoka", - "saito", - "shiiba", - "shintomi", - "takaharu", - "takanabe", - "takazaki", - "tsuno", - "achi", - "agematsu", - "anan", - "aoki", - "asahi", - "azumino", - "chikuhoku", - "chikuma", - "chino", - "fujimi", - "hakuba", - "hara", - "hiraya", - "iida", - "iijima", - "iiyama", - "iizuna", - "ikeda", - "ikusaka", - "ina", - "karuizawa", - "kawakami", - "kiso", - "kisofukushima", - "kitaaiki", - "komagane", - "komoro", - "matsukawa", - "matsumoto", - "miasa", - "minamiaiki", - "minamimaki", - "minamiminowa", - "minowa", - "miyada", - "miyota", - "mochizuki", - "nagano", - "nagawa", - "nagiso", - "nakagawa", - "nakano", - "nozawaonsen", - "obuse", - "ogawa", - "okaya", - "omachi", - "omi", - "ookuwa", - "ooshika", - "otaki", - "otari", - "sakae", - "sakaki", - "saku", - "sakuho", - "shimosuwa", - "shinanomachi", - "shiojiri", - "suwa", - "suzaka", - "takagi", - "takamori", - "takayama", - "tateshina", - "tatsuno", - "togakushi", - "togura", - "tomi", - "ueda", - "wada", - "yamagata", - "yamanouchi", - "yasaka", - "yasuoka", - "chijiwa", - "futsu", - "goto", - "hasami", - "hirado", - "iki", - "isahaya", - "kawatana", - "kuchinotsu", - "matsuura", - "nagasaki", - "obama", - "omura", - "oseto", - "saikai", - "sasebo", - "seihi", - "shimabara", - "shinkamigoto", - "togitsu", - "tsushima", - "unzen", - "city", - "ando", - "gose", - "heguri", - "higashiyoshino", - "ikaruga", - "ikoma", - "kamikitayama", - "kanmaki", - "kashiba", - "kashihara", - "katsuragi", - "kawai", - "kawakami", - "kawanishi", - "koryo", - "kurotaki", - "mitsue", - "miyake", - "nara", - "nosegawa", - "oji", - "ouda", - "oyodo", - "sakurai", - "sango", - "shimoichi", - "shimokitayama", - "shinjo", - "soni", - "takatori", - "tawaramoto", - "tenkawa", - "tenri", - "uda", - "yamatokoriyama", - "yamatotakada", - "yamazoe", - "yoshino", - "aga", - "agano", - "gosen", - "itoigawa", - "izumozaki", - "joetsu", - "kamo", - "kariwa", - "kashiwazaki", - "minamiuonuma", - "mitsuke", - "muika", - "murakami", - "myoko", - "nagaoka", - "niigata", - "ojiya", - "omi", - "sado", - "sanjo", - "seiro", - "seirou", - "sekikawa", - "shibata", - "tagami", - "tainai", - "tochio", - "tokamachi", - "tsubame", - "tsunan", - "uonuma", - "yahiko", - "yoita", - "yuzawa", - "beppu", - "bungoono", - "bungotakada", - "hasama", - "hiji", - "himeshima", - "hita", - "kamitsue", - "kokonoe", - "kuju", - "kunisaki", - "kusu", - "oita", - "saiki", - "taketa", - "tsukumi", - "usa", - "usuki", - "yufu", - "akaiwa", - "asakuchi", - "bizen", - "hayashima", - "ibara", - "kagamino", - "kasaoka", - "kibichuo", - "kumenan", - "kurashiki", - "maniwa", - "misaki", - "nagi", - "niimi", - "nishiawakura", - "okayama", - "satosho", - "setouchi", - "shinjo", - "shoo", - "soja", - "takahashi", - "tamano", - "tsuyama", - "wake", - "yakage", - "aguni", - "ginowan", - "ginoza", - "gushikami", - "haebaru", - "higashi", - "hirara", - "iheya", - "ishigaki", - "ishikawa", - "itoman", - "izena", - "kadena", - "kin", - "kitadaito", - "kitanakagusuku", - "kumejima", - "kunigami", - "minamidaito", - "motobu", - "nago", - "naha", - "nakagusuku", - "nakijin", - "nanjo", - "nishihara", - "ogimi", - "okinawa", - "onna", - "shimoji", - "taketomi", - "tarama", - "tokashiki", - "tomigusuku", - "tonaki", - "urasoe", - "uruma", - "yaese", - "yomitan", - "yonabaru", - "yonaguni", - "zamami", - "abeno", - "chihayaakasaka", - "chuo", - "daito", - "fujiidera", - "habikino", - "hannan", - "higashiosaka", - "higashisumiyoshi", - "higashiyodogawa", - "hirakata", - "ibaraki", - "ikeda", - "izumi", - "izumiotsu", - "izumisano", - "kadoma", - "kaizuka", - "kanan", - "kashiwara", - "katano", - "kawachinagano", - "kishiwada", - "kita", - "kumatori", - "matsubara", - "minato", - "minoh", - "misaki", - "moriguchi", - "neyagawa", - "nishi", - "nose", - "osakasayama", - "sakai", - "sayama", - "sennan", - "settsu", - "shijonawate", - "shimamoto", - "suita", - "tadaoka", - "taishi", - "tajiri", - "takaishi", - "takatsuki", - "tondabayashi", - "toyonaka", - "toyono", - "yao", - "ariake", - "arita", - "fukudomi", - "genkai", - "hamatama", - "hizen", - "imari", - "kamimine", - "kanzaki", - "karatsu", - "kashima", - "kitagata", - "kitahata", - "kiyama", - "kouhoku", - "kyuragi", - "nishiarita", - "ogi", - "omachi", - "ouchi", - "saga", - "shiroishi", - "taku", - "tara", - "tosu", - "yoshinogari", - "arakawa", - "asaka", - "chichibu", - "fujimi", - "fujimino", - "fukaya", - "hanno", - "hanyu", - "hasuda", - "hatogaya", - "hatoyama", - "hidaka", - "higashichichibu", - "higashimatsuyama", - "honjo", - "ina", - "iruma", - "iwatsuki", - "kamiizumi", - "kamikawa", - "kamisato", - "kasukabe", - "kawagoe", - "kawaguchi", - "kawajima", - "kazo", - "kitamoto", - "koshigaya", - "kounosu", - "kuki", - "kumagaya", - "matsubushi", - "minano", - "misato", - "miyashiro", - "miyoshi", - "moroyama", - "nagatoro", - "namegawa", - "niiza", - "ogano", - "ogawa", - "ogose", - "okegawa", - "omiya", - "otaki", - "ranzan", - "ryokami", - "saitama", - "sakado", - "satte", - "sayama", - "shiki", - "shiraoka", - "soka", - "sugito", - "toda", - "tokigawa", - "tokorozawa", - "tsurugashima", - "urawa", - "warabi", - "yashio", - "yokoze", - "yono", - "yorii", - "yoshida", - "yoshikawa", - "yoshimi", - "city", - "city", - "aisho", - "gamo", - "higashiomi", - "hikone", - "koka", - "konan", - "kosei", - "koto", - "kusatsu", - "maibara", - "moriyama", - "nagahama", - "nishiazai", - "notogawa", - "omihachiman", - "otsu", - "ritto", - "ryuoh", - "takashima", - "takatsuki", - "torahime", - "toyosato", - "yasu", - "akagi", - "ama", - "gotsu", - "hamada", - "higashiizumo", - "hikawa", - "hikimi", - "izumo", - "kakinoki", - "masuda", - "matsue", - "misato", - "nishinoshima", - "ohda", - "okinoshima", - "okuizumo", - "shimane", - "tamayu", - "tsuwano", - "unnan", - "yakumo", - "yasugi", - "yatsuka", - "arai", - "atami", - "fuji", - "fujieda", - "fujikawa", - "fujinomiya", - "fukuroi", - "gotemba", - "haibara", - "hamamatsu", - "higashiizu", - "ito", - "iwata", - "izu", - "izunokuni", - "kakegawa", - "kannami", - "kawanehon", - "kawazu", - "kikugawa", - "kosai", - "makinohara", - "matsuzaki", - "minamiizu", - "mishima", - "morimachi", - "nishiizu", - "numazu", - "omaezaki", - "shimada", - "shimizu", - "shimoda", - "shizuoka", - "susono", - "yaizu", - "yoshida", - "ashikaga", - "bato", - "haga", - "ichikai", - "iwafune", - "kaminokawa", - "kanuma", - "karasuyama", - "kuroiso", - "mashiko", - "mibu", - "moka", - "motegi", - "nasu", - "nasushiobara", - "nikko", - "nishikata", - "nogi", - "ohira", - "ohtawara", - "oyama", - "sakura", - "sano", - "shimotsuke", - "shioya", - "takanezawa", - "tochigi", - "tsuga", - "ujiie", - "utsunomiya", - "yaita", - "aizumi", - "anan", - "ichiba", - "itano", - "kainan", - "komatsushima", - "matsushige", - "mima", - "minami", - "miyoshi", - "mugi", - "nakagawa", - "naruto", - "sanagochi", - "shishikui", - "tokushima", - "wajiki", - "adachi", - "akiruno", - "akishima", - "aogashima", - "arakawa", - "bunkyo", - "chiyoda", - "chofu", - "chuo", - "edogawa", - "fuchu", - "fussa", - "hachijo", - "hachioji", - "hamura", - "higashikurume", - "higashimurayama", - "higashiyamato", - "hino", - "hinode", - "hinohara", - "inagi", - "itabashi", - "katsushika", - "kita", - "kiyose", - "kodaira", - "koganei", - "kokubunji", - "komae", - "koto", - "kouzushima", - "kunitachi", - "machida", - "meguro", - "minato", - "mitaka", - "mizuho", - "musashimurayama", - "musashino", - "nakano", - "nerima", - "ogasawara", - "okutama", - "ome", - "oshima", - "ota", - "setagaya", - "shibuya", - "shinagawa", - "shinjuku", - "suginami", - "sumida", - "tachikawa", - "taito", - "tama", - "toshima", - "chizu", - "hino", - "kawahara", - "koge", - "kotoura", - "misasa", - "nanbu", - "nichinan", - "sakaiminato", - "tottori", - "wakasa", - "yazu", - "yonago", - "asahi", - "fuchu", - "fukumitsu", - "funahashi", - "himi", - "imizu", - "inami", - "johana", - "kamiichi", - "kurobe", - "nakaniikawa", - "namerikawa", - "nanto", - "nyuzen", - "oyabe", - "taira", - "takaoka", - "tateyama", - "toga", - "tonami", - "toyama", - "unazuki", - "uozu", - "yamada", - "arida", - "aridagawa", - "gobo", - "hashimoto", - "hidaka", - "hirogawa", - "inami", - "iwade", - "kainan", - "kamitonda", - "katsuragi", - "kimino", - "kinokawa", - "kitayama", - "koya", - "koza", - "kozagawa", - "kudoyama", - "kushimoto", - "mihama", - "misato", - "nachikatsuura", - "shingu", - "shirahama", - "taiji", - "tanabe", - "wakayama", - "yuasa", - "yura", - "asahi", - "funagata", - "higashine", - "iide", - "kahoku", - "kaminoyama", - "kaneyama", - "kawanishi", - "mamurogawa", - "mikawa", - "murayama", - "nagai", - "nakayama", - "nanyo", - "nishikawa", - "obanazawa", - "oe", - "oguni", - "ohkura", - "oishida", - "sagae", - "sakata", - "sakegawa", - "shinjo", - "shirataka", - "shonai", - "takahata", - "tendo", - "tozawa", - "tsuruoka", - "yamagata", - "yamanobe", - "yonezawa", - "yuza", - "abu", - "hagi", - "hikari", - "hofu", - "iwakuni", - "kudamatsu", - "mitou", - "nagato", - "oshima", - "shimonoseki", - "shunan", - "tabuse", - "tokuyama", - "toyota", - "ube", - "yuu", - "chuo", - "doshi", - "fuefuki", - "fujikawa", - "fujikawaguchiko", - "fujiyoshida", - "hayakawa", - "hokuto", - "ichikawamisato", - "kai", - "kofu", - "koshu", - "kosuge", - "minami-alps", - "minobu", - "nakamichi", - "nanbu", - "narusawa", - "nirasaki", - "nishikatsura", - "oshino", - "otsuki", - "showa", - "tabayama", - "tsuru", - "uenohara", - "yamanakako", - "yamanashi", - "city", - "co", - "blogspot", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "biz", - "com", - "edu", - "gov", - "info", - "net", - "org", - "ass", - "asso", - "com", - "coop", - "edu", - "gouv", - "gov", - "medecin", - "mil", - "nom", - "notaires", - "org", - "pharmaciens", - "prd", - "presse", - "tm", - "veterinaire", - "edu", - "gov", - "net", - "org", - "com", - "edu", - "gov", - "org", - "rep", - "tra", - "ac", - "blogspot", - "busan", - "chungbuk", - "chungnam", - "co", - "daegu", - "daejeon", - "es", - "gangwon", - "go", - "gwangju", - "gyeongbuk", - "gyeonggi", - "gyeongnam", - "hs", - "incheon", - "jeju", - "jeonbuk", - "jeonnam", - "kg", - "mil", - "ms", - "ne", - "or", - "pe", - "re", - "sc", - "seoul", - "ulsan", - "co", - "edu", - "com", - "edu", - "gov", - "net", - "org", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "bnr", - "c", - "com", - "edu", - "gov", - "info", - "int", - "net", - "org", - "per", - "static", - "dev", - "sites", - "com", - "edu", - "gov", - "net", - "org", - "co", - "com", - "edu", - "gov", - "net", - "org", - "oy", - "blogspot", - "cyon", - "mypep", - "ac", - "assn", - "com", - "edu", - "gov", - "grp", - "hotel", - "int", - "ltd", - "net", - "ngo", - "org", - "sch", - "soc", - "web", - "com", - "edu", - "gov", - "net", - "org", - "co", - "org", - "blogspot", - "gov", - "blogspot", - "asn", - "com", - "conf", - "edu", - "gov", - "id", - "mil", - "net", - "org", - "com", - "edu", - "gov", - "id", - "med", - "net", - "org", - "plc", - "sch", - "ac", - "co", - "gov", - "net", - "org", - "press", - "router", - "asso", - "tm", - "blogspot", - "ac", - "brasilia", - "co", - "daplie", - "ddns", - "diskstation", - "dnsfor", - "dscloud", - "edu", - "gov", - "hopto", - "i234", - "its", - "loginto", - "myds", - "net", - "noip", - "org", - "priv", - "synology", - "webhop", - "yombo", - "co", - "com", - "edu", - "gov", - "mil", - "nom", - "org", - "prd", - "tm", - "blogspot", - "com", - "edu", - "gov", - "inf", - "name", - "net", - "org", - "com", - "edu", - "gouv", - "gov", - "net", - "org", - "presse", - "edu", - "gov", - "nyc", - "org", - "com", - "edu", - "gov", - "net", - "org", - "dscloud", - "blogspot", - "gov", - "com", - "edu", - "gov", - "net", - "org", - "com", - "edu", - "net", - "org", - "blogspot", - "ac", - "co", - "com", - "gov", - "net", - "or", - "org", - "academy", - "agriculture", - "air", - "airguard", - "alabama", - "alaska", - "amber", - "ambulance", - "american", - "americana", - "americanantiques", - "americanart", - "amsterdam", - "and", - "annefrank", - "anthro", - "anthropology", - "antiques", - "aquarium", - "arboretum", - "archaeological", - "archaeology", - "architecture", - "art", - "artanddesign", - "artcenter", - "artdeco", - "arteducation", - "artgallery", - "arts", - "artsandcrafts", - "asmatart", - "assassination", - "assisi", - "association", - "astronomy", - "atlanta", - "austin", - "australia", - "automotive", - "aviation", - "axis", - "badajoz", - "baghdad", - "bahn", - "bale", - "baltimore", - "barcelona", - "baseball", - "basel", - "baths", - "bauern", - "beauxarts", - "beeldengeluid", - "bellevue", - "bergbau", - "berkeley", - "berlin", - "bern", - "bible", - "bilbao", - "bill", - "birdart", - "birthplace", - "bonn", - "boston", - "botanical", - "botanicalgarden", - "botanicgarden", - "botany", - "brandywinevalley", - "brasil", - "bristol", - "british", - "britishcolumbia", - "broadcast", - "brunel", - "brussel", - "brussels", - "bruxelles", - "building", - "burghof", - "bus", - "bushey", - "cadaques", - "california", - "cambridge", - "can", - "canada", - "capebreton", - "carrier", - "cartoonart", - "casadelamoneda", - "castle", - "castres", - "celtic", - "center", - "chattanooga", - "cheltenham", - "chesapeakebay", - "chicago", - "children", - "childrens", - "childrensgarden", - "chiropractic", - "chocolate", - "christiansburg", - "cincinnati", - "cinema", - "circus", - "civilisation", - "civilization", - "civilwar", - "clinton", - "clock", - "coal", - "coastaldefence", - "cody", - "coldwar", - "collection", - "colonialwilliamsburg", - "coloradoplateau", - "columbia", - "columbus", - "communication", - "communications", - "community", - "computer", - "computerhistory", - "contemporary", - "contemporaryart", - "convent", - "copenhagen", - "corporation", - "corvette", - "costume", - "countryestate", - "county", - "crafts", - "cranbrook", - "creation", - "cultural", - "culturalcenter", - "culture", - "cyber", - "cymru", - "dali", - "dallas", - "database", - "ddr", - "decorativearts", - "delaware", - "delmenhorst", - "denmark", - "depot", - "design", - "detroit", - "dinosaur", - "discovery", - "dolls", - "donostia", - "durham", - "eastafrica", - "eastcoast", - "education", - "educational", - "egyptian", - "eisenbahn", - "elburg", - "elvendrell", - "embroidery", - "encyclopedic", - "england", - "entomology", - "environment", - "environmentalconservation", - "epilepsy", - "essex", - "estate", - "ethnology", - "exeter", - "exhibition", - "family", - "farm", - "farmequipment", - "farmers", - "farmstead", - "field", - "figueres", - "filatelia", - "film", - "fineart", - "finearts", - "finland", - "flanders", - "florida", - "force", - "fortmissoula", - "fortworth", - "foundation", - "francaise", - "frankfurt", - "franziskaner", - "freemasonry", - "freiburg", - "fribourg", - "frog", - "fundacio", - "furniture", - "gallery", - "garden", - "gateway", - "geelvinck", - "gemological", - "geology", - "georgia", - "giessen", - "glas", - "glass", - "gorge", - "grandrapids", - "graz", - "guernsey", - "halloffame", - "hamburg", - "handson", - "harvestcelebration", - "hawaii", - "health", - "heimatunduhren", - "hellas", - "helsinki", - "hembygdsforbund", - "heritage", - "histoire", - "historical", - "historicalsociety", - "historichouses", - "historisch", - "historisches", - "history", - "historyofscience", - "horology", - "house", - "humanities", - "illustration", - "imageandsound", - "indian", - "indiana", - "indianapolis", - "indianmarket", - "intelligence", - "interactive", - "iraq", - "iron", - "isleofman", - "jamison", - "jefferson", - "jerusalem", - "jewelry", - "jewish", - "jewishart", - "jfk", - "journalism", - "judaica", - "judygarland", - "juedisches", - "juif", - "karate", - "karikatur", - "kids", - "koebenhavn", - "koeln", - "kunst", - "kunstsammlung", - "kunstunddesign", - "labor", - "labour", - "lajolla", - "lancashire", - "landes", - "lans", - "larsson", - "lewismiller", - "lincoln", - "linz", - "living", - "livinghistory", - "localhistory", - "london", - "losangeles", - "louvre", - "loyalist", - "lucerne", - "luxembourg", - "luzern", - "mad", - "madrid", - "mallorca", - "manchester", - "mansion", - "mansions", - "manx", - "marburg", - "maritime", - "maritimo", - "maryland", - "marylhurst", - "media", - "medical", - "medizinhistorisches", - "meeres", - "memorial", - "mesaverde", - "michigan", - "midatlantic", - "military", - "mill", - "miners", - "mining", - "minnesota", - "missile", - "missoula", - "modern", - "moma", - "money", - "monmouth", - "monticello", - "montreal", - "moscow", - "motorcycle", - "muenchen", - "muenster", - "mulhouse", - "muncie", - "museet", - "museumcenter", - "museumvereniging", - "music", - "national", - "nationalfirearms", - "nationalheritage", - "nativeamerican", - "naturalhistory", - "naturalhistorymuseum", - "naturalsciences", - "nature", - "naturhistorisches", - "natuurwetenschappen", - "naumburg", - "naval", - "nebraska", - "neues", - "newhampshire", - "newjersey", - "newmexico", - "newport", - "newspaper", - "newyork", - "niepce", - "norfolk", - "north", - "nrw", - "nuernberg", - "nuremberg", - "nyc", - "nyny", - "oceanographic", - "oceanographique", - "omaha", - "online", - "ontario", - "openair", - "oregon", - "oregontrail", - "otago", - "oxford", - "pacific", - "paderborn", - "palace", - "paleo", - "palmsprings", - "panama", - "paris", - "pasadena", - "pharmacy", - "philadelphia", - "philadelphiaarea", - "philately", - "phoenix", - "photography", - "pilots", - "pittsburgh", - "planetarium", - "plantation", - "plants", - "plaza", - "portal", - "portland", - "portlligat", - "posts-and-telecommunications", - "preservation", - "presidio", - "press", - "project", - "public", - "pubol", - "quebec", - "railroad", - "railway", - "research", - "resistance", - "riodejaneiro", - "rochester", - "rockart", - "roma", - "russia", - "saintlouis", - "salem", - "salvadordali", - "salzburg", - "sandiego", - "sanfrancisco", - "santabarbara", - "santacruz", - "santafe", - "saskatchewan", - "satx", - "savannahga", - "schlesisches", - "schoenbrunn", - "schokoladen", - "school", - "schweiz", - "science", - "science-fiction", - "scienceandhistory", - "scienceandindustry", - "sciencecenter", - "sciencecenters", - "sciencehistory", - "sciences", - "sciencesnaturelles", - "scotland", - "seaport", - "settlement", - "settlers", - "shell", - "sherbrooke", - "sibenik", - "silk", - "ski", - "skole", - "society", - "sologne", - "soundandvision", - "southcarolina", - "southwest", - "space", - "spy", - "square", - "stadt", - "stalbans", - "starnberg", - "state", - "stateofdelaware", - "station", - "steam", - "steiermark", - "stjohn", - "stockholm", - "stpetersburg", - "stuttgart", - "suisse", - "surgeonshall", - "surrey", - "svizzera", - "sweden", - "sydney", - "tank", - "tcm", - "technology", - "telekommunikation", - "television", - "texas", - "textile", - "theater", - "time", - "timekeeping", - "topology", - "torino", - "touch", - "town", - "transport", - "tree", - "trolley", - "trust", - "trustee", - "uhren", - "ulm", - "undersea", - "university", - "usa", - "usantiques", - "usarts", - "uscountryestate", - "usculture", - "usdecorativearts", - "usgarden", - "ushistory", - "ushuaia", - "uslivinghistory", - "utah", - "uvic", - "valley", - "vantaa", - "versailles", - "viking", - "village", - "virginia", - "virtual", - "virtuel", - "vlaanderen", - "volkenkunde", - "wales", - "wallonie", - "war", - "washingtondc", - "watch-and-clock", - "watchandclock", - "western", - "westfalen", - "whaling", - "wildlife", - "williamsburg", - "windmill", - "workshop", - "xn--9dbhblg6di", - "xn--comunicaes-v6a2o", - "xn--correios-e-telecomunicaes-ghc29a", - "xn--h1aegh", - "xn--lns-qla", - "york", - "yorkshire", - "yosemite", - "youth", - "zoological", - "zoology", - "aero", - "biz", - "com", - "coop", - "edu", - "gov", - "info", - "int", - "mil", - "museum", - "name", - "net", - "org", - "pro", - "ac", - "biz", - "co", - "com", - "coop", - "edu", - "gov", - "int", - "museum", - "net", - "org", - "blogspot", - "com", - "edu", - "gob", - "net", - "org", - "blogspot", - "com", - "edu", - "gov", - "mil", - "name", - "net", - "org", - "ac", - "adv", - "co", - "edu", - "gov", - "mil", - "net", - "org", - "ca", - "cc", - "co", - "com", - "dr", - "in", - "info", - "mobi", - "mx", - "name", - "or", - "org", - "pro", - "school", - "tv", - "us", - "ws", - "her", - "his", - "forgot", - "forgot", - "asso", - "alwaysdata", - "at-band-camp", - "azure-mobile", - "azurewebsites", - "blogdns", - "bounceme", - "broke-it", - "buyshouses", - "cdn77", - "cdn77-ssl", - "cloudapp", - "cloudfront", - "cloudfunctions", - "cryptonomic", - "ddns", - "dnsalias", - "dnsdojo", - "does-it", - "dontexist", - "dsmynas", - "dynalias", - "dynathome", - "dynv6", - "eating-organic", - "endofinternet", - "familyds", - "fastly", - "fastlylb", - "feste-ip", - "firewall-gateway", - "from-az", - "from-co", - "from-la", - "from-ny", - "gb", - "gets-it", - "ham-radio-op", - "homeftp", - "homeip", - "homelinux", - "homeunix", - "hu", - "in", - "in-the-band", - "is-a-chef", - "is-a-geek", - "isa-geek", - "jp", - "kicks-ass", - "knx-server", - "mydissent", - "myeffect", - "myfritz", - "mymediapc", - "mypsx", - "mysecuritycamera", - "nhlfan", - "no-ip", - "office-on-the", - "pgafan", - "podzone", - "privatizehealthinsurance", - "rackmaze", - "redirectme", - "scrapper-site", - "se", - "selfip", - "sells-it", - "servebbs", - "serveblog", - "serveftp", - "serveminecraft", - "static-access", - "sytes", - "t3l3p0rt", - "thruhere", - "uk", - "webhop", - "za", - "r", - "map", - "prod", - "ssl", - "a", - "global", - "a", - "b", - "global", - "map", - "alces", - "arts", - "com", - "firm", - "info", - "net", - "other", - "per", - "rec", - "store", - "web", - "com", - "edu", - "gov", - "i", - "mil", - "mobi", - "name", - "net", - "org", - "sch", - "blogspot", - "ac", - "biz", - "co", - "com", - "edu", - "gob", - "in", - "info", - "int", - "mil", - "net", - "nom", - "org", - "web", - "blogspot", - "bv", - "co", - "transurl", - "virtueeldomein", - "aa", - "aarborte", - "aejrie", - "afjord", - "agdenes", - "ah", - "akershus", - "aknoluokta", - "akrehamn", - "al", - "alaheadju", - "alesund", - "algard", - "alstahaug", - "alta", - "alvdal", - "amli", - "amot", - "andasuolo", - "andebu", - "andoy", - "ardal", - "aremark", - "arendal", - "arna", - "aseral", - "asker", - "askim", - "askoy", - "askvoll", - "asnes", - "audnedaln", - "aukra", - "aure", - "aurland", - "aurskog-holand", - "austevoll", - "austrheim", - "averoy", - "badaddja", - "bahcavuotna", - "bahccavuotna", - "baidar", - "bajddar", - "balat", - "balestrand", - "ballangen", - "balsfjord", - "bamble", - "bardu", - "barum", - "batsfjord", - "bearalvahki", - "beardu", - "beiarn", - "berg", - "bergen", - "berlevag", - "bievat", - "bindal", - "birkenes", - "bjarkoy", - "bjerkreim", - "bjugn", - "blogspot", - "bodo", - "bokn", - "bomlo", - "bremanger", - "bronnoy", - "bronnoysund", - "brumunddal", - "bryne", - "bu", - "budejju", - "buskerud", - "bygland", - "bykle", - "cahcesuolo", - "co", - "davvenjarga", - "davvesiida", - "deatnu", - "dep", - "dielddanuorri", - "divtasvuodna", - "divttasvuotna", - "donna", - "dovre", - "drammen", - "drangedal", - "drobak", - "dyroy", - "egersund", - "eid", - "eidfjord", - "eidsberg", - "eidskog", - "eidsvoll", - "eigersund", - "elverum", - "enebakk", - "engerdal", - "etne", - "etnedal", - "evenassi", - "evenes", - "evje-og-hornnes", - "farsund", - "fauske", - "fedje", - "fet", - "fetsund", - "fhs", - "finnoy", - "fitjar", - "fjaler", - "fjell", - "fla", - "flakstad", - "flatanger", - "flekkefjord", - "flesberg", - "flora", - "floro", - "fm", - "folkebibl", - "folldal", - "forde", - "forsand", - "fosnes", - "frana", - "fredrikstad", - "frei", - "frogn", - "froland", - "frosta", - "froya", - "fuoisku", - "fuossko", - "fusa", - "fylkesbibl", - "fyresdal", - "gaivuotna", - "galsa", - "gamvik", - "gangaviika", - "gaular", - "gausdal", - "giehtavuoatna", - "gildeskal", - "giske", - "gjemnes", - "gjerdrum", - "gjerstad", - "gjesdal", - "gjovik", - "gloppen", - "gol", - "gran", - "grane", - "granvin", - "gratangen", - "grimstad", - "grong", - "grue", - "gulen", - "guovdageaidnu", - "ha", - "habmer", - "hadsel", - "hagebostad", - "halden", - "halsa", - "hamar", - "hamaroy", - "hammarfeasta", - "hammerfest", - "hapmir", - "haram", - "hareid", - "harstad", - "hasvik", - "hattfjelldal", - "haugesund", - "hedmark", - "hemne", - "hemnes", - "hemsedal", - "herad", - "hitra", - "hjartdal", - "hjelmeland", - "hl", - "hm", - "hobol", - "hof", - "hokksund", - "hol", - "hole", - "holmestrand", - "holtalen", - "honefoss", - "hordaland", - "hornindal", - "horten", - "hoyanger", - "hoylandet", - "hurdal", - "hurum", - "hvaler", - "hyllestad", - "ibestad", - "idrett", - "inderoy", - "iveland", - "ivgu", - "jan-mayen", - "jessheim", - "jevnaker", - "jolster", - "jondal", - "jorpeland", - "kafjord", - "karasjohka", - "karasjok", - "karlsoy", - "karmoy", - "kautokeino", - "kirkenes", - "klabu", - "klepp", - "kommune", - "kongsberg", - "kongsvinger", - "kopervik", - "kraanghke", - "kragero", - "kristiansand", - "kristiansund", - "krodsherad", - "krokstadelva", - "kvafjord", - "kvalsund", - "kvam", - "kvanangen", - "kvinesdal", - "kvinnherad", - "kviteseid", - "kvitsoy", - "laakesvuemie", - "lahppi", - "langevag", - "lardal", - "larvik", - "lavagis", - "lavangen", - "leangaviika", - "lebesby", - "leikanger", - "leirfjord", - "leirvik", - "leka", - "leksvik", - "lenvik", - "lerdal", - "lesja", - "levanger", - "lier", - "lierne", - "lillehammer", - "lillesand", - "lindas", - "lindesnes", - "loabat", - "lodingen", - "lom", - "loppa", - "lorenskog", - "loten", - "lund", - "lunner", - "luroy", - "luster", - "lyngdal", - "lyngen", - "malatvuopmi", - "malselv", - "malvik", - "mandal", - "marker", - "marnardal", - "masfjorden", - "masoy", - "matta-varjjat", - "meland", - "meldal", - "melhus", - "meloy", - "meraker", - "midsund", - "midtre-gauldal", - "mil", - "mjondalen", - "mo-i-rana", - "moareke", - "modalen", - "modum", - "molde", - "more-og-romsdal", - "mosjoen", - "moskenes", - "moss", - "mosvik", - "mr", - "muosat", - "museum", - "naamesjevuemie", - "namdalseid", - "namsos", - "namsskogan", - "nannestad", - "naroy", - "narviika", - "narvik", - "naustdal", - "navuotna", - "nedre-eiker", - "nesna", - "nesodden", - "nesoddtangen", - "nesseby", - "nesset", - "nissedal", - "nittedal", - "nl", - "nord-aurdal", - "nord-fron", - "nord-odal", - "norddal", - "nordkapp", - "nordland", - "nordre-land", - "nordreisa", - "nore-og-uvdal", - "notodden", - "notteroy", - "nt", - "odda", - "of", - "oksnes", - "ol", - "omasvuotna", - "oppdal", - "oppegard", - "orkanger", - "orkdal", - "orland", - "orskog", - "orsta", - "osen", - "oslo", - "osoyro", - "osteroy", - "ostfold", - "ostre-toten", - "overhalla", - "ovre-eiker", - "oyer", - "oygarden", - "oystre-slidre", - "porsanger", - "porsangu", - "porsgrunn", - "priv", - "rade", - "radoy", - "rahkkeravju", - "raholt", - "raisa", - "rakkestad", - "ralingen", - "rana", - "randaberg", - "rauma", - "rendalen", - "rennebu", - "rennesoy", - "rindal", - "ringebu", - "ringerike", - "ringsaker", - "risor", - "rissa", - "rl", - "roan", - "rodoy", - "rollag", - "romsa", - "romskog", - "roros", - "rost", - "royken", - "royrvik", - "ruovat", - "rygge", - "salangen", - "salat", - "saltdal", - "samnanger", - "sandefjord", - "sandnes", - "sandnessjoen", - "sandoy", - "sarpsborg", - "sauda", - "sauherad", - "sel", - "selbu", - "selje", - "seljord", - "sf", - "siellak", - "sigdal", - "siljan", - "sirdal", - "skanit", - "skanland", - "skaun", - "skedsmo", - "skedsmokorset", - "ski", - "skien", - "skierva", - "skiptvet", - "skjak", - "skjervoy", - "skodje", - "slattum", - "smola", - "snaase", - "snasa", - "snillfjord", - "snoasa", - "sogndal", - "sogne", - "sokndal", - "sola", - "solund", - "somna", - "sondre-land", - "songdalen", - "sor-aurdal", - "sor-fron", - "sor-odal", - "sor-varanger", - "sorfold", - "sorreisa", - "sortland", - "sorum", - "spjelkavik", - "spydeberg", - "st", - "stange", - "stat", - "stathelle", - "stavanger", - "stavern", - "steigen", - "steinkjer", - "stjordal", - "stjordalshalsen", - "stokke", - "stor-elvdal", - "stord", - "stordal", - "storfjord", - "strand", - "stranda", - "stryn", - "sula", - "suldal", - "sund", - "sunndal", - "surnadal", - "svalbard", - "sveio", - "svelvik", - "sykkylven", - "tana", - "tananger", - "telemark", - "time", - "tingvoll", - "tinn", - "tjeldsund", - "tjome", - "tm", - "tokke", - "tolga", - "tonsberg", - "torsken", - "tr", - "trana", - "tranby", - "tranoy", - "troandin", - "trogstad", - "tromsa", - "tromso", - "trondheim", - "trysil", - "tvedestrand", - "tydal", - "tynset", - "tysfjord", - "tysnes", - "tysvar", - "ullensaker", - "ullensvang", - "ulvik", - "unjarga", - "utsira", - "va", - "vaapste", - "vadso", - "vaga", - "vagan", - "vagsoy", - "vaksdal", - "valle", - "vang", - "vanylven", - "vardo", - "varggat", - "varoy", - "vefsn", - "vega", - "vegarshei", - "vennesla", - "verdal", - "verran", - "vestby", - "vestfold", - "vestnes", - "vestre-slidre", - "vestre-toten", - "vestvagoy", - "vevelstad", - "vf", - "vgs", - "vik", - "vikna", - "vindafjord", - "voagat", - "volda", - "voss", - "vossevangen", - "xn--andy-ira", - "xn--asky-ira", - "xn--aurskog-hland-jnb", - "xn--avery-yua", - "xn--bdddj-mrabd", - "xn--bearalvhki-y4a", - "xn--berlevg-jxa", - "xn--bhcavuotna-s4a", - "xn--bhccavuotna-k7a", - "xn--bidr-5nac", - "xn--bievt-0qa", - "xn--bjarky-fya", - "xn--bjddar-pta", - "xn--blt-elab", - "xn--bmlo-gra", - "xn--bod-2na", - "xn--brnny-wuac", - "xn--brnnysund-m8ac", - "xn--brum-voa", - "xn--btsfjord-9za", - "xn--davvenjrga-y4a", - "xn--dnna-gra", - "xn--drbak-wua", - "xn--dyry-ira", - "xn--eveni-0qa01ga", - "xn--finny-yua", - "xn--fjord-lra", - "xn--fl-zia", - "xn--flor-jra", - "xn--frde-gra", - "xn--frna-woa", - "xn--frya-hra", - "xn--ggaviika-8ya47h", - "xn--gildeskl-g0a", - "xn--givuotna-8ya", - "xn--gjvik-wua", - "xn--gls-elac", - "xn--h-2fa", - "xn--hbmer-xqa", - "xn--hcesuolo-7ya35b", - "xn--hgebostad-g3a", - "xn--hmmrfeasta-s4ac", - "xn--hnefoss-q1a", - "xn--hobl-ira", - "xn--holtlen-hxa", - "xn--hpmir-xqa", - "xn--hyanger-q1a", - "xn--hylandet-54a", - "xn--indery-fya", - "xn--jlster-bya", - "xn--jrpeland-54a", - "xn--karmy-yua", - "xn--kfjord-iua", - "xn--klbu-woa", - "xn--koluokta-7ya57h", - "xn--krager-gya", - "xn--kranghke-b0a", - "xn--krdsherad-m8a", - "xn--krehamn-dxa", - "xn--krjohka-hwab49j", - "xn--ksnes-uua", - "xn--kvfjord-nxa", - "xn--kvitsy-fya", - "xn--kvnangen-k0a", - "xn--l-1fa", - "xn--laheadju-7ya", - "xn--langevg-jxa", - "xn--ldingen-q1a", - "xn--leagaviika-52b", - "xn--lesund-hua", - "xn--lgrd-poac", - "xn--lhppi-xqa", - "xn--linds-pra", - "xn--loabt-0qa", - "xn--lrdal-sra", - "xn--lrenskog-54a", - "xn--lt-liac", - "xn--lten-gra", - "xn--lury-ira", - "xn--mely-ira", - "xn--merker-kua", - "xn--mjndalen-64a", - "xn--mlatvuopmi-s4a", - "xn--mli-tla", - "xn--mlselv-iua", - "xn--moreke-jua", - "xn--mosjen-eya", - "xn--mot-tla", - "xn--mre-og-romsdal-qqb", - "xn--msy-ula0h", - "xn--mtta-vrjjat-k7af", - "xn--muost-0qa", - "xn--nmesjevuemie-tcba", - "xn--nry-yla5g", - "xn--nttery-byae", - "xn--nvuotna-hwa", - "xn--oppegrd-ixa", - "xn--ostery-fya", - "xn--osyro-wua", - "xn--porsgu-sta26f", - "xn--rady-ira", - "xn--rdal-poa", - "xn--rde-ula", - "xn--rdy-0nab", - "xn--rennesy-v1a", - "xn--rhkkervju-01af", - "xn--rholt-mra", - "xn--risa-5na", - "xn--risr-ira", - "xn--rland-uua", - "xn--rlingen-mxa", - "xn--rmskog-bya", - "xn--rros-gra", - "xn--rskog-uua", - "xn--rst-0na", - "xn--rsta-fra", - "xn--ryken-vua", - "xn--ryrvik-bya", - "xn--s-1fa", - "xn--sandnessjen-ogb", - "xn--sandy-yua", - "xn--seral-lra", - "xn--sgne-gra", - "xn--skierv-uta", - "xn--skjervy-v1a", - "xn--skjk-soa", - "xn--sknit-yqa", - "xn--sknland-fxa", - "xn--slat-5na", - "xn--slt-elab", - "xn--smla-hra", - "xn--smna-gra", - "xn--snase-nra", - "xn--sndre-land-0cb", - "xn--snes-poa", - "xn--snsa-roa", - "xn--sr-aurdal-l8a", - "xn--sr-fron-q1a", - "xn--sr-odal-q1a", - "xn--sr-varanger-ggb", - "xn--srfold-bya", - "xn--srreisa-q1a", - "xn--srum-gra", - "xn--stfold-9xa", - "xn--stjrdal-s1a", - "xn--stjrdalshalsen-sqb", - "xn--stre-toten-zcb", - "xn--tjme-hra", - "xn--tnsberg-q1a", - "xn--trany-yua", - "xn--trgstad-r1a", - "xn--trna-woa", - "xn--troms-zua", - "xn--tysvr-vra", - "xn--unjrga-rta", - "xn--vads-jra", - "xn--vard-jra", - "xn--vegrshei-c0a", - "xn--vestvgy-ixa6o", - "xn--vg-yiab", - "xn--vgan-qoa", - "xn--vgsy-qoa0j", - "xn--vre-eiker-k8a", - "xn--vrggt-xqad", - "xn--vry-yla5g", - "xn--yer-zna", - "xn--ygarden-p1a", - "xn--ystre-slidre-ujb", - "gs", - "gs", - "nes", - "gs", - "nes", - "gs", - "os", - "valer", - "xn--vler-qoa", - "gs", - "gs", - "os", - "gs", - "heroy", - "sande", - "gs", - "gs", - "bo", - "heroy", - "xn--b-5ga", - "xn--hery-ira", - "gs", - "gs", - "gs", - "gs", - "valer", - "gs", - "gs", - "gs", - "gs", - "bo", - "xn--b-5ga", - "gs", - "gs", - "gs", - "sande", - "gs", - "sande", - "xn--hery-ira", - "xn--vler-qoa", - "biz", - "com", - "edu", - "gov", - "info", - "net", - "org", - "merseine", - "mine", - "shacknet", - "ac", - "co", - "cri", - "geek", - "gen", - "govt", - "health", - "iwi", - "kiwi", - "maori", - "mil", - "net", - "org", - "parliament", - "school", - "xn--mori-qsa", - "blogspot", - "co", - "com", - "edu", - "gov", - "med", - "museum", - "net", - "org", - "pro", - "homelink", - "ae", - "amune", - "blogdns", - "blogsite", - "bmoattachments", - "boldlygoingnowhere", - "cable-modem", - "cdn77", - "cdn77-secure", - "certmgr", - "cloudns", - "collegefan", - "couchpotatofries", - "ddnss", - "diskstation", - "dnsalias", - "dnsdojo", - "doesntexist", - "dontexist", - "doomdns", - "dsmynas", - "duckdns", - "dvrdns", - "dynalias", - "dyndns", - "endofinternet", - "endoftheinternet", - "eu", - "familyds", - "from-me", - "game-host", - "gotdns", - "hepforge", - "hk", - "hobby-site", - "homedns", - "homeftp", - "homelinux", - "homeunix", - "hopto", - "is-a-bruinsfan", - "is-a-candidate", - "is-a-celticsfan", - "is-a-chef", - "is-a-geek", - "is-a-knight", - "is-a-linux-user", - "is-a-patsfan", - "is-a-soxfan", - "is-found", - "is-lost", - "is-saved", - "is-very-bad", - "is-very-evil", - "is-very-good", - "is-very-nice", - "is-very-sweet", - "isa-geek", - "js", - "kicks-ass", - "misconfused", - "mlbfan", - "my-firewall", - "myfirewall", - "myftp", - "mysecuritycamera", - "nflfan", - "no-ip", - "pimienta", - "podzone", - "poivron", - "potager", - "read-books", - "readmyblog", - "selfip", - "sellsyourhome", - "servebbs", - "serveftp", - "servegame", - "spdns", - "stuff-4-sale", - "sweetpepper", - "tunk", - "tuxfamily", - "ufcfan", - "us", - "webhop", - "wmflabs", - "za", - "zapto", - "tele", - "c", - "rsc", - "origin", - "ssl", - "go", - "home", - "al", - "asso", - "at", - "au", - "be", - "bg", - "ca", - "cd", - "ch", - "cn", - "cy", - "cz", - "de", - "dk", - "edu", - "ee", - "es", - "fi", - "fr", - "gr", - "hr", - "hu", - "ie", - "il", - "in", - "int", - "is", - "it", - "jp", - "kr", - "lt", - "lu", - "lv", - "mc", - "me", - "mk", - "mt", - "my", - "net", - "ng", - "nl", - "no", - "nz", - "paris", - "pl", - "pt", - "q-a", - "ro", - "ru", - "se", - "si", - "sk", - "tr", - "uk", - "us", - "nerdpol", - "abo", - "ac", - "com", - "edu", - "gob", - "ing", - "med", - "net", - "nom", - "org", - "sld", - "ybo", - "blogspot", - "com", - "edu", - "gob", - "mil", - "net", - "nom", - "org", - "com", - "edu", - "org", - "com", - "edu", - "gov", - "i", - "mil", - "net", - "ngo", - "org", - "biz", - "com", - "edu", - "fam", - "gob", - "gok", - "gon", - "gop", - "gos", - "gov", - "info", - "net", - "org", - "web", - "agro", - "aid", - "art", - "atm", - "augustow", - "auto", - "babia-gora", - "bedzin", - "beep", - "beskidy", - "bialowieza", - "bialystok", - "bielawa", - "bieszczady", - "biz", - "boleslawiec", - "bydgoszcz", - "bytom", - "cieszyn", - "co", - "com", - "czeladz", - "czest", - "dlugoleka", - "edu", - "elblag", - "elk", - "gda", - "gdansk", - "gdynia", - "gliwice", - "glogow", - "gmina", - "gniezno", - "gorlice", - "gov", - "grajewo", - "gsm", - "ilawa", - "info", - "jaworzno", - "jelenia-gora", - "jgora", - "kalisz", - "karpacz", - "kartuzy", - "kaszuby", - "katowice", - "kazimierz-dolny", - "kepno", - "ketrzyn", - "klodzko", - "kobierzyce", - "kolobrzeg", - "konin", - "konskowola", - "krakow", - "kutno", - "lapy", - "lebork", - "legnica", - "lezajsk", - "limanowa", - "lomza", - "lowicz", - "lubin", - "lukow", - "mail", - "malbork", - "malopolska", - "mazowsze", - "mazury", - "med", - "media", - "miasta", - "mielec", - "mielno", - "mil", - "mragowo", - "naklo", - "net", - "nieruchomosci", - "nom", - "nowaruda", - "nysa", - "olawa", - "olecko", - "olkusz", - "olsztyn", - "opoczno", - "opole", - "org", - "ostroda", - "ostroleka", - "ostrowiec", - "ostrowwlkp", - "pc", - "pila", - "pisz", - "podhale", - "podlasie", - "polkowice", - "pomorskie", - "pomorze", - "powiat", - "poznan", - "priv", - "prochowice", - "pruszkow", - "przeworsk", - "pulawy", - "radom", - "rawa-maz", - "realestate", - "rel", - "rybnik", - "rzeszow", - "sanok", - "sejny", - "sex", - "shop", - "sklep", - "skoczow", - "slask", - "slupsk", - "sopot", - "sos", - "sosnowiec", - "stalowa-wola", - "starachowice", - "stargard", - "suwalki", - "swidnica", - "swiebodzin", - "swinoujscie", - "szczecin", - "szczytno", - "szkola", - "targi", - "tarnobrzeg", - "tgory", - "tm", - "tourism", - "travel", - "turek", - "turystyka", - "tychy", - "ustka", - "walbrzych", - "warmia", - "warszawa", - "waw", - "wegrow", - "wielun", - "wlocl", - "wloclawek", - "wodzislaw", - "wolomin", - "wroc", - "wroclaw", - "zachpomor", - "zagan", - "zakopane", - "zarow", - "zgora", - "zgorzelec", - "ap", - "griw", - "ic", - "is", - "kmpsp", - "konsulat", - "kppsp", - "kwp", - "kwpsp", - "mup", - "mw", - "oirm", - "oum", - "pa", - "pinb", - "piw", - "po", - "psp", - "psse", - "pup", - "rzgw", - "sa", - "sdn", - "sko", - "so", - "sr", - "starostwo", - "ug", - "ugim", - "um", - "umig", - "upow", - "uppo", - "us", - "uw", - "uzs", - "wif", - "wiih", - "winb", - "wios", - "witd", - "wiw", - "wsa", - "wskr", - "wuoz", - "wzmiuw", - "zp", - "co", - "edu", - "gov", - "net", - "org", - "ac", - "biz", - "com", - "edu", - "est", - "gov", - "info", - "isla", - "name", - "net", - "org", - "pro", - "prof", - "aaa", - "aca", - "acct", - "avocat", - "bar", - "cloudns", - "cpa", - "eng", - "jur", - "law", - "med", - "recht", - "com", - "edu", - "gov", - "net", - "org", - "plo", - "sec", - "blogspot", - "com", - "edu", - "gov", - "int", - "net", - "nome", - "org", - "publ", - "belau", - "cloudns", - "co", - "ed", - "go", - "ne", - "or", - "com", - "coop", - "edu", - "gov", - "mil", - "net", - "org", - "blogspot", - "com", - "edu", - "gov", - "mil", - "name", - "net", - "org", - "sch", - "asso", - "blogspot", - "com", - "nom", - "ybo", - "arts", - "blogspot", - "com", - "firm", - "info", - "nom", - "nt", - "org", - "rec", - "shop", - "store", - "tm", - "www", - "ac", - "blogspot", - "co", - "edu", - "gov", - "in", - "org", - "ac", - "blogspot", - "edu", - "gov", - "int", - "mil", - "test", - "ac", - "co", - "com", - "edu", - "gouv", - "gov", - "int", - "mil", - "net", - "com", - "edu", - "gov", - "med", - "net", - "org", - "pub", - "sch", - "com", - "edu", - "gov", - "net", - "org", - "com", - "edu", - "gov", - "net", - "org", - "ybo", - "com", - "edu", - "gov", - "info", - "med", - "net", - "org", - "tv", - "a", - "ac", - "b", - "bd", - "blogspot", - "brand", - "c", - "com", - "d", - "e", - "f", - "fh", - "fhsk", - "fhv", - "g", - "h", - "i", - "k", - "komforb", - "kommunalforbund", - "komvux", - "l", - "lanbib", - "m", - "n", - "naturbruksgymn", - "o", - "org", - "p", - "parti", - "pp", - "press", - "r", - "s", - "t", - "tm", - "u", - "w", - "x", - "y", - "z", - "blogspot", - "com", - "edu", - "gov", - "net", - "org", - "per", - "com", - "gov", - "hashbang", - "mil", - "net", - "now", - "org", - "platform", - "blogspot", - "cyon", - "blogspot", - "com", - "edu", - "gov", - "net", - "org", - "art", - "blogspot", - "com", - "edu", - "gouv", - "org", - "perso", - "univ", - "com", - "net", - "org", - "stackspace", - "co", - "com", - "consulado", - "edu", - "embaixada", - "gov", - "mil", - "net", - "org", - "principe", - "saotome", - "store", - "adygeya", - "arkhangelsk", - "balashov", - "bashkiria", - "bryansk", - "dagestan", - "grozny", - "ivanovo", - "kalmykia", - "kaluga", - "karelia", - "khakassia", - "krasnodar", - "kurgan", - "lenug", - "mordovia", - "msk", - "murmansk", - "nalchik", - "nov", - "obninsk", - "penza", - "pokrovsk", - "sochi", - "spb", - "togliatti", - "troitsk", - "tula", - "tuva", - "vladikavkaz", - "vladimir", - "vologda", - "com", - "edu", - "gob", - "org", - "red", - "gov", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "knightpoint", - "ac", - "co", - "org", - "blogspot", - "ac", - "co", - "go", - "in", - "mi", - "net", - "or", - "ac", - "biz", - "co", - "com", - "edu", - "go", - "gov", - "int", - "mil", - "name", - "net", - "nic", - "org", - "test", - "web", - "gov", - "co", - "com", - "edu", - "gov", - "mil", - "net", - "nom", - "org", - "agrinet", - "com", - "defense", - "edunet", - "ens", - "fin", - "gov", - "ind", - "info", - "intl", - "mincom", - "nat", - "net", - "org", - "perso", - "rnrt", - "rns", - "rnu", - "tourism", - "turen", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "av", - "bbs", - "bel", - "biz", - "com", - "dr", - "edu", - "gen", - "gov", - "info", - "k12", - "kep", - "mil", - "name", - "nc", - "net", - "org", - "pol", - "tel", - "tv", - "web", - "blogspot", - "gov", - "ybo", - "aero", - "biz", - "co", - "com", - "coop", - "edu", - "gov", - "info", - "int", - "jobs", - "mobi", - "museum", - "name", - "net", - "org", - "pro", - "travel", - "better-than", - "dyndns", - "on-the-web", - "worse-than", - "blogspot", - "club", - "com", - "ebiz", - "edu", - "game", - "gov", - "idv", - "mil", - "net", - "org", - "xn--czrw28b", - "xn--uc0atv", - "xn--zf0ao64a", - "ac", - "co", - "go", - "hotel", - "info", - "me", - "mil", - "mobi", - "ne", - "or", - "sc", - "tv", - "biz", - "cc", - "cherkassy", - "cherkasy", - "chernigov", - "chernihiv", - "chernivtsi", - "chernovtsy", - "ck", - "cn", - "co", - "com", - "cr", - "crimea", - "cv", - "dn", - "dnepropetrovsk", - "dnipropetrovsk", - "dominic", - "donetsk", - "dp", - "edu", - "gov", - "if", - "in", - "inf", - "ivano-frankivsk", - "kh", - "kharkiv", - "kharkov", - "kherson", - "khmelnitskiy", - "khmelnytskyi", - "kiev", - "kirovograd", - "km", - "kr", - "krym", - "ks", - "kv", - "kyiv", - "lg", - "lt", - "ltd", - "lugansk", - "lutsk", - "lv", - "lviv", - "mk", - "mykolaiv", - "net", - "nikolaev", - "od", - "odesa", - "odessa", - "org", - "pl", - "poltava", - "pp", - "rivne", - "rovno", - "rv", - "sb", - "sebastopol", - "sevastopol", - "sm", - "sumy", - "te", - "ternopil", - "uz", - "uzhgorod", - "vinnica", - "vinnytsia", - "vn", - "volyn", - "yalta", - "zaporizhzhe", - "zaporizhzhia", - "zhitomir", - "zhytomyr", - "zp", - "zt", - "ac", - "blogspot", - "co", - "com", - "go", - "ne", - "or", - "org", - "sc", - "ac", - "co", - "gov", - "ltd", - "me", - "net", - "nhs", - "org", - "plc", - "police", - "sch", - "blogspot", - "no-ip", - "wellbeingzone", - "homeoffice", - "service", - "ak", - "al", - "ar", - "as", - "az", - "ca", - "cloudns", - "co", - "ct", - "dc", - "de", - "dni", - "drud", - "fed", - "fl", - "ga", - "golffan", - "gu", - "hi", - "ia", - "id", - "il", - "in", - "is-by", - "isa", - "kids", - "ks", - "ky", - "la", - "land-4-sale", - "ma", - "md", - "me", - "mi", - "mn", - "mo", - "ms", - "mt", - "nc", - "nd", - "ne", - "nh", - "nj", - "nm", - "noip", - "nsn", - "nv", - "ny", - "oh", - "ok", - "or", - "pa", - "pointto", - "pr", - "ri", - "sc", - "sd", - "stuff-4-sale", - "tn", - "tx", - "ut", - "va", - "vi", - "vt", - "wa", - "wi", - "wv", - "wy", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "chtr", - "paroch", - "pvt", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "cc", - "k12", - "lib", - "com", - "edu", - "gub", - "mil", - "net", - "org", - "blogspot", - "co", - "com", - "net", - "org", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "arts", - "co", - "com", - "e12", - "edu", - "firm", - "gob", - "gov", - "info", - "int", - "mil", - "net", - "org", - "rec", - "store", - "tec", - "web", - "co", - "com", - "k12", - "net", - "org", - "ac", - "biz", - "blogspot", - "com", - "edu", - "gov", - "health", - "info", - "int", - "name", - "net", - "org", - "pro", - "com", - "edu", - "net", - "org", - "com", - "dyndns", - "edu", - "gov", - "mypets", - "net", - "org", - "xn--80au", - "xn--90azh", - "xn--c1avg", - "xn--d1at", - "xn--o1ac", - "xn--o1ach", - "fhapp", - "ac", - "agric", - "alt", - "co", - "edu", - "gov", - "grondar", - "law", - "mil", - "net", - "ngo", - "nis", - "nom", - "org", - "school", - "tm", - "web", - "blogspot", - "ac", - "biz", - "co", - "com", - "edu", - "gov", - "info", - "mil", - "net", - "org", - "sch", - "triton", -} diff --git a/vendor/golang.org/x/net/route/address.go b/vendor/golang.org/x/net/route/address.go deleted file mode 100644 index e6bfa39e9..000000000 --- a/vendor/golang.org/x/net/route/address.go +++ /dev/null @@ -1,425 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package route - -import "runtime" - -// An Addr represents an address associated with packet routing. -type Addr interface { - // Family returns an address family. - Family() int -} - -// A LinkAddr represents a link-layer address. -type LinkAddr struct { - Index int // interface index when attached - Name string // interface name when attached - Addr []byte // link-layer address when attached -} - -// Family implements the Family method of Addr interface. -func (a *LinkAddr) Family() int { return sysAF_LINK } - -func (a *LinkAddr) lenAndSpace() (int, int) { - l := 8 + len(a.Name) + len(a.Addr) - return l, roundup(l) -} - -func (a *LinkAddr) marshal(b []byte) (int, error) { - l, ll := a.lenAndSpace() - if len(b) < ll { - return 0, errShortBuffer - } - nlen, alen := len(a.Name), len(a.Addr) - if nlen > 255 || alen > 255 { - return 0, errInvalidAddr - } - b[0] = byte(l) - b[1] = sysAF_LINK - if a.Index > 0 { - nativeEndian.PutUint16(b[2:4], uint16(a.Index)) - } - data := b[8:] - if nlen > 0 { - b[5] = byte(nlen) - copy(data[:nlen], a.Addr) - data = data[nlen:] - } - if alen > 0 { - b[6] = byte(alen) - copy(data[:alen], a.Name) - data = data[alen:] - } - return ll, nil -} - -func parseLinkAddr(b []byte) (Addr, error) { - if len(b) < 8 { - return nil, errInvalidAddr - } - _, a, err := parseKernelLinkAddr(sysAF_LINK, b[4:]) - if err != nil { - return nil, err - } - a.(*LinkAddr).Index = int(nativeEndian.Uint16(b[2:4])) - return a, nil -} - -// parseKernelLinkAddr parses b as a link-layer address in -// conventional BSD kernel form. -func parseKernelLinkAddr(_ int, b []byte) (int, Addr, error) { - // The encoding looks like the following: - // +----------------------------+ - // | Type (1 octet) | - // +----------------------------+ - // | Name length (1 octet) | - // +----------------------------+ - // | Address length (1 octet) | - // +----------------------------+ - // | Selector length (1 octet) | - // +----------------------------+ - // | Data (variable) | - // +----------------------------+ - // - // On some platforms, all-bit-one of length field means "don't - // care". - nlen, alen, slen := int(b[1]), int(b[2]), int(b[3]) - if nlen == 0xff { - nlen = 0 - } - if alen == 0xff { - alen = 0 - } - if slen == 0xff { - slen = 0 - } - l := 4 + nlen + alen + slen - if len(b) < l { - return 0, nil, errInvalidAddr - } - data := b[4:] - var name string - var addr []byte - if nlen > 0 { - name = string(data[:nlen]) - data = data[nlen:] - } - if alen > 0 { - addr = data[:alen] - data = data[alen:] - } - return l, &LinkAddr{Name: name, Addr: addr}, nil -} - -// An Inet4Addr represents an internet address for IPv4. -type Inet4Addr struct { - IP [4]byte // IP address -} - -// Family implements the Family method of Addr interface. -func (a *Inet4Addr) Family() int { return sysAF_INET } - -func (a *Inet4Addr) lenAndSpace() (int, int) { - return sizeofSockaddrInet, roundup(sizeofSockaddrInet) -} - -func (a *Inet4Addr) marshal(b []byte) (int, error) { - l, ll := a.lenAndSpace() - if len(b) < ll { - return 0, errShortBuffer - } - b[0] = byte(l) - b[1] = sysAF_INET - copy(b[4:8], a.IP[:]) - return ll, nil -} - -// An Inet6Addr represents an internet address for IPv6. -type Inet6Addr struct { - IP [16]byte // IP address - ZoneID int // zone identifier -} - -// Family implements the Family method of Addr interface. -func (a *Inet6Addr) Family() int { return sysAF_INET6 } - -func (a *Inet6Addr) lenAndSpace() (int, int) { - return sizeofSockaddrInet6, roundup(sizeofSockaddrInet6) -} - -func (a *Inet6Addr) marshal(b []byte) (int, error) { - l, ll := a.lenAndSpace() - if len(b) < ll { - return 0, errShortBuffer - } - b[0] = byte(l) - b[1] = sysAF_INET6 - copy(b[8:24], a.IP[:]) - if a.ZoneID > 0 { - nativeEndian.PutUint32(b[24:28], uint32(a.ZoneID)) - } - return ll, nil -} - -// parseInetAddr parses b as an internet address for IPv4 or IPv6. -func parseInetAddr(af int, b []byte) (Addr, error) { - switch af { - case sysAF_INET: - if len(b) < sizeofSockaddrInet { - return nil, errInvalidAddr - } - a := &Inet4Addr{} - copy(a.IP[:], b[4:8]) - return a, nil - case sysAF_INET6: - if len(b) < sizeofSockaddrInet6 { - return nil, errInvalidAddr - } - a := &Inet6Addr{ZoneID: int(nativeEndian.Uint32(b[24:28]))} - copy(a.IP[:], b[8:24]) - if a.IP[0] == 0xfe && a.IP[1]&0xc0 == 0x80 || a.IP[0] == 0xff && (a.IP[1]&0x0f == 0x01 || a.IP[1]&0x0f == 0x02) { - // KAME based IPv6 protocol stack usually - // embeds the interface index in the - // interface-local or link-local address as - // the kernel-internal form. - id := int(bigEndian.Uint16(a.IP[2:4])) - if id != 0 { - a.ZoneID = id - a.IP[2], a.IP[3] = 0, 0 - } - } - return a, nil - default: - return nil, errInvalidAddr - } -} - -// parseKernelInetAddr parses b as an internet address in conventional -// BSD kernel form. -func parseKernelInetAddr(af int, b []byte) (int, Addr, error) { - // The encoding looks similar to the NLRI encoding. - // +----------------------------+ - // | Length (1 octet) | - // +----------------------------+ - // | Address prefix (variable) | - // +----------------------------+ - // - // The differences between the kernel form and the NLRI - // encoding are: - // - // - The length field of the kernel form indicates the prefix - // length in bytes, not in bits - // - // - In the kernel form, zero value of the length field - // doesn't mean 0.0.0.0/0 or ::/0 - // - // - The kernel form appends leading bytes to the prefix field - // to make the tuple to be conformed with - // the routing message boundary - l := int(b[0]) - if runtime.GOOS == "darwin" { - // On Darwn, an address in the kernel form is also - // used as a message filler. - if l == 0 || len(b) > roundup(l) { - l = roundup(l) - } - } else { - l = roundup(l) - } - if len(b) < l { - return 0, nil, errInvalidAddr - } - // Don't reorder case expressions. - // The case expressions for IPv6 must come first. - const ( - off4 = 4 // offset of in_addr - off6 = 8 // offset of in6_addr - ) - switch { - case b[0] == sizeofSockaddrInet6: - a := &Inet6Addr{} - copy(a.IP[:], b[off6:off6+16]) - return int(b[0]), a, nil - case af == sysAF_INET6: - a := &Inet6Addr{} - if l-1 < off6 { - copy(a.IP[:], b[1:l]) - } else { - copy(a.IP[:], b[l-off6:l]) - } - return int(b[0]), a, nil - case b[0] == sizeofSockaddrInet: - a := &Inet4Addr{} - copy(a.IP[:], b[off4:off4+4]) - return int(b[0]), a, nil - default: // an old fashion, AF_UNSPEC or unknown means AF_INET - a := &Inet4Addr{} - if l-1 < off4 { - copy(a.IP[:], b[1:l]) - } else { - copy(a.IP[:], b[l-off4:l]) - } - return int(b[0]), a, nil - } -} - -// A DefaultAddr represents an address of various operating -// system-specific features. -type DefaultAddr struct { - af int - Raw []byte // raw format of address -} - -// Family implements the Family method of Addr interface. -func (a *DefaultAddr) Family() int { return a.af } - -func (a *DefaultAddr) lenAndSpace() (int, int) { - l := len(a.Raw) - return l, roundup(l) -} - -func (a *DefaultAddr) marshal(b []byte) (int, error) { - l, ll := a.lenAndSpace() - if len(b) < ll { - return 0, errShortBuffer - } - if l > 255 { - return 0, errInvalidAddr - } - b[1] = byte(l) - copy(b[:l], a.Raw) - return ll, nil -} - -func parseDefaultAddr(b []byte) (Addr, error) { - if len(b) < 2 || len(b) < int(b[0]) { - return nil, errInvalidAddr - } - a := &DefaultAddr{af: int(b[1]), Raw: b[:b[0]]} - return a, nil -} - -func addrsSpace(as []Addr) int { - var l int - for _, a := range as { - switch a := a.(type) { - case *LinkAddr: - _, ll := a.lenAndSpace() - l += ll - case *Inet4Addr: - _, ll := a.lenAndSpace() - l += ll - case *Inet6Addr: - _, ll := a.lenAndSpace() - l += ll - case *DefaultAddr: - _, ll := a.lenAndSpace() - l += ll - } - } - return l -} - -// marshalAddrs marshals as and returns a bitmap indicating which -// address is stored in b. -func marshalAddrs(b []byte, as []Addr) (uint, error) { - var attrs uint - for i, a := range as { - switch a := a.(type) { - case *LinkAddr: - l, err := a.marshal(b) - if err != nil { - return 0, err - } - b = b[l:] - attrs |= 1 << uint(i) - case *Inet4Addr: - l, err := a.marshal(b) - if err != nil { - return 0, err - } - b = b[l:] - attrs |= 1 << uint(i) - case *Inet6Addr: - l, err := a.marshal(b) - if err != nil { - return 0, err - } - b = b[l:] - attrs |= 1 << uint(i) - case *DefaultAddr: - l, err := a.marshal(b) - if err != nil { - return 0, err - } - b = b[l:] - attrs |= 1 << uint(i) - } - } - return attrs, nil -} - -func parseAddrs(attrs uint, fn func(int, []byte) (int, Addr, error), b []byte) ([]Addr, error) { - var as [sysRTAX_MAX]Addr - af := int(sysAF_UNSPEC) - for i := uint(0); i < sysRTAX_MAX && len(b) >= roundup(0); i++ { - if attrs&(1<> 8) -} - -func (binaryLittleEndian) Uint32(b []byte) uint32 { - _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 - return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 -} - -func (binaryLittleEndian) PutUint32(b []byte, v uint32) { - _ = b[3] // early bounds check to guarantee safety of writes below - b[0] = byte(v) - b[1] = byte(v >> 8) - b[2] = byte(v >> 16) - b[3] = byte(v >> 24) -} - -func (binaryLittleEndian) Uint64(b []byte) uint64 { - _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 - return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | - uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 -} - -type binaryBigEndian struct{} - -func (binaryBigEndian) Uint16(b []byte) uint16 { - _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808 - return uint16(b[1]) | uint16(b[0])<<8 -} - -func (binaryBigEndian) PutUint16(b []byte, v uint16) { - _ = b[1] // early bounds check to guarantee safety of writes below - b[0] = byte(v >> 8) - b[1] = byte(v) -} - -func (binaryBigEndian) Uint32(b []byte) uint32 { - _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 - return uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24 -} - -func (binaryBigEndian) PutUint32(b []byte, v uint32) { - _ = b[3] // early bounds check to guarantee safety of writes below - b[0] = byte(v >> 24) - b[1] = byte(v >> 16) - b[2] = byte(v >> 8) - b[3] = byte(v) -} - -func (binaryBigEndian) Uint64(b []byte) uint64 { - _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 - return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 | - uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56 -} diff --git a/vendor/golang.org/x/net/route/defs_darwin.go b/vendor/golang.org/x/net/route/defs_darwin.go deleted file mode 100644 index e7716442d..000000000 --- a/vendor/golang.org/x/net/route/defs_darwin.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package route - -/* -#include -#include - -#include -#include -#include - -#include -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_ROUTE = C.AF_ROUTE - sysAF_LINK = C.AF_LINK - sysAF_INET6 = C.AF_INET6 - - sysSOCK_RAW = C.SOCK_RAW - - sysNET_RT_DUMP = C.NET_RT_DUMP - sysNET_RT_FLAGS = C.NET_RT_FLAGS - sysNET_RT_IFLIST = C.NET_RT_IFLIST - sysNET_RT_STAT = C.NET_RT_STAT - sysNET_RT_TRASH = C.NET_RT_TRASH - sysNET_RT_IFLIST2 = C.NET_RT_IFLIST2 - sysNET_RT_DUMP2 = C.NET_RT_DUMP2 - sysNET_RT_MAXID = C.NET_RT_MAXID -) - -const ( - sysCTL_MAXNAME = C.CTL_MAXNAME - - sysCTL_UNSPEC = C.CTL_UNSPEC - sysCTL_KERN = C.CTL_KERN - sysCTL_VM = C.CTL_VM - sysCTL_VFS = C.CTL_VFS - sysCTL_NET = C.CTL_NET - sysCTL_DEBUG = C.CTL_DEBUG - sysCTL_HW = C.CTL_HW - sysCTL_MACHDEP = C.CTL_MACHDEP - sysCTL_USER = C.CTL_USER - sysCTL_MAXID = C.CTL_MAXID -) - -const ( - sysRTM_VERSION = C.RTM_VERSION - - sysRTM_ADD = C.RTM_ADD - sysRTM_DELETE = C.RTM_DELETE - sysRTM_CHANGE = C.RTM_CHANGE - sysRTM_GET = C.RTM_GET - sysRTM_LOSING = C.RTM_LOSING - sysRTM_REDIRECT = C.RTM_REDIRECT - sysRTM_MISS = C.RTM_MISS - sysRTM_LOCK = C.RTM_LOCK - sysRTM_OLDADD = C.RTM_OLDADD - sysRTM_OLDDEL = C.RTM_OLDDEL - sysRTM_RESOLVE = C.RTM_RESOLVE - sysRTM_NEWADDR = C.RTM_NEWADDR - sysRTM_DELADDR = C.RTM_DELADDR - sysRTM_IFINFO = C.RTM_IFINFO - sysRTM_NEWMADDR = C.RTM_NEWMADDR - sysRTM_DELMADDR = C.RTM_DELMADDR - sysRTM_IFINFO2 = C.RTM_IFINFO2 - sysRTM_NEWMADDR2 = C.RTM_NEWMADDR2 - sysRTM_GET2 = C.RTM_GET2 - - sysRTA_DST = C.RTA_DST - sysRTA_GATEWAY = C.RTA_GATEWAY - sysRTA_NETMASK = C.RTA_NETMASK - sysRTA_GENMASK = C.RTA_GENMASK - sysRTA_IFP = C.RTA_IFP - sysRTA_IFA = C.RTA_IFA - sysRTA_AUTHOR = C.RTA_AUTHOR - sysRTA_BRD = C.RTA_BRD - - sysRTAX_DST = C.RTAX_DST - sysRTAX_GATEWAY = C.RTAX_GATEWAY - sysRTAX_NETMASK = C.RTAX_NETMASK - sysRTAX_GENMASK = C.RTAX_GENMASK - sysRTAX_IFP = C.RTAX_IFP - sysRTAX_IFA = C.RTAX_IFA - sysRTAX_AUTHOR = C.RTAX_AUTHOR - sysRTAX_BRD = C.RTAX_BRD - sysRTAX_MAX = C.RTAX_MAX -) - -const ( - sizeofIfMsghdrDarwin15 = C.sizeof_struct_if_msghdr - sizeofIfaMsghdrDarwin15 = C.sizeof_struct_ifa_msghdr - sizeofIfmaMsghdrDarwin15 = C.sizeof_struct_ifma_msghdr - sizeofIfMsghdr2Darwin15 = C.sizeof_struct_if_msghdr2 - sizeofIfmaMsghdr2Darwin15 = C.sizeof_struct_ifma_msghdr2 - sizeofIfDataDarwin15 = C.sizeof_struct_if_data - sizeofIfData64Darwin15 = C.sizeof_struct_if_data64 - - sizeofRtMsghdrDarwin15 = C.sizeof_struct_rt_msghdr - sizeofRtMsghdr2Darwin15 = C.sizeof_struct_rt_msghdr2 - sizeofRtMetricsDarwin15 = C.sizeof_struct_rt_metrics - - sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 -) diff --git a/vendor/golang.org/x/net/route/defs_dragonfly.go b/vendor/golang.org/x/net/route/defs_dragonfly.go deleted file mode 100644 index dd31de269..000000000 --- a/vendor/golang.org/x/net/route/defs_dragonfly.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package route - -/* -#include -#include - -#include -#include -#include - -#include -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_ROUTE = C.AF_ROUTE - sysAF_LINK = C.AF_LINK - sysAF_INET6 = C.AF_INET6 - - sysSOCK_RAW = C.SOCK_RAW - - sysNET_RT_DUMP = C.NET_RT_DUMP - sysNET_RT_FLAGS = C.NET_RT_FLAGS - sysNET_RT_IFLIST = C.NET_RT_IFLIST - sysNET_RT_MAXID = C.NET_RT_MAXID -) - -const ( - sysCTL_MAXNAME = C.CTL_MAXNAME - - sysCTL_UNSPEC = C.CTL_UNSPEC - sysCTL_KERN = C.CTL_KERN - sysCTL_VM = C.CTL_VM - sysCTL_VFS = C.CTL_VFS - sysCTL_NET = C.CTL_NET - sysCTL_DEBUG = C.CTL_DEBUG - sysCTL_HW = C.CTL_HW - sysCTL_MACHDEP = C.CTL_MACHDEP - sysCTL_USER = C.CTL_USER - sysCTL_P1003_1B = C.CTL_P1003_1B - sysCTL_LWKT = C.CTL_LWKT - sysCTL_MAXID = C.CTL_MAXID -) - -const ( - sysRTM_VERSION = C.RTM_VERSION - - sysRTM_ADD = C.RTM_ADD - sysRTM_DELETE = C.RTM_DELETE - sysRTM_CHANGE = C.RTM_CHANGE - sysRTM_GET = C.RTM_GET - sysRTM_LOSING = C.RTM_LOSING - sysRTM_REDIRECT = C.RTM_REDIRECT - sysRTM_MISS = C.RTM_MISS - sysRTM_LOCK = C.RTM_LOCK - sysRTM_OLDADD = C.RTM_OLDADD - sysRTM_OLDDEL = C.RTM_OLDDEL - sysRTM_RESOLVE = C.RTM_RESOLVE - sysRTM_NEWADDR = C.RTM_NEWADDR - sysRTM_DELADDR = C.RTM_DELADDR - sysRTM_IFINFO = C.RTM_IFINFO - sysRTM_NEWMADDR = C.RTM_NEWMADDR - sysRTM_DELMADDR = C.RTM_DELMADDR - sysRTM_IFANNOUNCE = C.RTM_IFANNOUNCE - sysRTM_IEEE80211 = C.RTM_IEEE80211 - - sysRTA_DST = C.RTA_DST - sysRTA_GATEWAY = C.RTA_GATEWAY - sysRTA_NETMASK = C.RTA_NETMASK - sysRTA_GENMASK = C.RTA_GENMASK - sysRTA_IFP = C.RTA_IFP - sysRTA_IFA = C.RTA_IFA - sysRTA_AUTHOR = C.RTA_AUTHOR - sysRTA_BRD = C.RTA_BRD - sysRTA_MPLS1 = C.RTA_MPLS1 - sysRTA_MPLS2 = C.RTA_MPLS2 - sysRTA_MPLS3 = C.RTA_MPLS3 - - sysRTAX_DST = C.RTAX_DST - sysRTAX_GATEWAY = C.RTAX_GATEWAY - sysRTAX_NETMASK = C.RTAX_NETMASK - sysRTAX_GENMASK = C.RTAX_GENMASK - sysRTAX_IFP = C.RTAX_IFP - sysRTAX_IFA = C.RTAX_IFA - sysRTAX_AUTHOR = C.RTAX_AUTHOR - sysRTAX_BRD = C.RTAX_BRD - sysRTAX_MPLS1 = C.RTAX_MPLS1 - sysRTAX_MPLS2 = C.RTAX_MPLS2 - sysRTAX_MPLS3 = C.RTAX_MPLS3 - sysRTAX_MAX = C.RTAX_MAX -) - -const ( - sizeofIfMsghdrDragonFlyBSD4 = C.sizeof_struct_if_msghdr - sizeofIfaMsghdrDragonFlyBSD4 = C.sizeof_struct_ifa_msghdr - sizeofIfmaMsghdrDragonFlyBSD4 = C.sizeof_struct_ifma_msghdr - sizeofIfAnnouncemsghdrDragonFlyBSD4 = C.sizeof_struct_if_announcemsghdr - - sizeofRtMsghdrDragonFlyBSD4 = C.sizeof_struct_rt_msghdr - sizeofRtMetricsDragonFlyBSD4 = C.sizeof_struct_rt_metrics - - sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 -) diff --git a/vendor/golang.org/x/net/route/defs_freebsd.go b/vendor/golang.org/x/net/route/defs_freebsd.go deleted file mode 100644 index d95594d8e..000000000 --- a/vendor/golang.org/x/net/route/defs_freebsd.go +++ /dev/null @@ -1,337 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package route - -/* -#include -#include - -#include -#include -#include - -#include - -struct if_data_freebsd7 { - u_char ifi_type; - u_char ifi_physical; - u_char ifi_addrlen; - u_char ifi_hdrlen; - u_char ifi_link_state; - u_char ifi_spare_char1; - u_char ifi_spare_char2; - u_char ifi_datalen; - u_long ifi_mtu; - u_long ifi_metric; - u_long ifi_baudrate; - u_long ifi_ipackets; - u_long ifi_ierrors; - u_long ifi_opackets; - u_long ifi_oerrors; - u_long ifi_collisions; - u_long ifi_ibytes; - u_long ifi_obytes; - u_long ifi_imcasts; - u_long ifi_omcasts; - u_long ifi_iqdrops; - u_long ifi_noproto; - u_long ifi_hwassist; - time_t __ifi_epoch; - struct timeval __ifi_lastchange; -}; - -struct if_data_freebsd8 { - u_char ifi_type; - u_char ifi_physical; - u_char ifi_addrlen; - u_char ifi_hdrlen; - u_char ifi_link_state; - u_char ifi_spare_char1; - u_char ifi_spare_char2; - u_char ifi_datalen; - u_long ifi_mtu; - u_long ifi_metric; - u_long ifi_baudrate; - u_long ifi_ipackets; - u_long ifi_ierrors; - u_long ifi_opackets; - u_long ifi_oerrors; - u_long ifi_collisions; - u_long ifi_ibytes; - u_long ifi_obytes; - u_long ifi_imcasts; - u_long ifi_omcasts; - u_long ifi_iqdrops; - u_long ifi_noproto; - u_long ifi_hwassist; - time_t __ifi_epoch; - struct timeval __ifi_lastchange; -}; - -struct if_data_freebsd9 { - u_char ifi_type; - u_char ifi_physical; - u_char ifi_addrlen; - u_char ifi_hdrlen; - u_char ifi_link_state; - u_char ifi_spare_char1; - u_char ifi_spare_char2; - u_char ifi_datalen; - u_long ifi_mtu; - u_long ifi_metric; - u_long ifi_baudrate; - u_long ifi_ipackets; - u_long ifi_ierrors; - u_long ifi_opackets; - u_long ifi_oerrors; - u_long ifi_collisions; - u_long ifi_ibytes; - u_long ifi_obytes; - u_long ifi_imcasts; - u_long ifi_omcasts; - u_long ifi_iqdrops; - u_long ifi_noproto; - u_long ifi_hwassist; - time_t __ifi_epoch; - struct timeval __ifi_lastchange; -}; - -struct if_data_freebsd10 { - u_char ifi_type; - u_char ifi_physical; - u_char ifi_addrlen; - u_char ifi_hdrlen; - u_char ifi_link_state; - u_char ifi_vhid; - u_char ifi_baudrate_pf; - u_char ifi_datalen; - u_long ifi_mtu; - u_long ifi_metric; - u_long ifi_baudrate; - u_long ifi_ipackets; - u_long ifi_ierrors; - u_long ifi_opackets; - u_long ifi_oerrors; - u_long ifi_collisions; - u_long ifi_ibytes; - u_long ifi_obytes; - u_long ifi_imcasts; - u_long ifi_omcasts; - u_long ifi_iqdrops; - u_long ifi_noproto; - uint64_t ifi_hwassist; - time_t __ifi_epoch; - struct timeval __ifi_lastchange; -}; - -struct if_data_freebsd11 { - uint8_t ifi_type; - uint8_t ifi_physical; - uint8_t ifi_addrlen; - uint8_t ifi_hdrlen; - uint8_t ifi_link_state; - uint8_t ifi_vhid; - uint16_t ifi_datalen; - uint32_t ifi_mtu; - uint32_t ifi_metric; - uint64_t ifi_baudrate; - uint64_t ifi_ipackets; - uint64_t ifi_ierrors; - uint64_t ifi_opackets; - uint64_t ifi_oerrors; - uint64_t ifi_collisions; - uint64_t ifi_ibytes; - uint64_t ifi_obytes; - uint64_t ifi_imcasts; - uint64_t ifi_omcasts; - uint64_t ifi_iqdrops; - uint64_t ifi_oqdrops; - uint64_t ifi_noproto; - uint64_t ifi_hwassist; - union { - time_t tt; - uint64_t ph; - } __ifi_epoch; - union { - struct timeval tv; - struct { - uint64_t ph1; - uint64_t ph2; - } ph; - } __ifi_lastchange; -}; - -struct if_msghdr_freebsd7 { - u_short ifm_msglen; - u_char ifm_version; - u_char ifm_type; - int ifm_addrs; - int ifm_flags; - u_short ifm_index; - struct if_data_freebsd7 ifm_data; -}; - -struct if_msghdr_freebsd8 { - u_short ifm_msglen; - u_char ifm_version; - u_char ifm_type; - int ifm_addrs; - int ifm_flags; - u_short ifm_index; - struct if_data_freebsd8 ifm_data; -}; - -struct if_msghdr_freebsd9 { - u_short ifm_msglen; - u_char ifm_version; - u_char ifm_type; - int ifm_addrs; - int ifm_flags; - u_short ifm_index; - struct if_data_freebsd9 ifm_data; -}; - -struct if_msghdr_freebsd10 { - u_short ifm_msglen; - u_char ifm_version; - u_char ifm_type; - int ifm_addrs; - int ifm_flags; - u_short ifm_index; - struct if_data_freebsd10 ifm_data; -}; - -struct if_msghdr_freebsd11 { - u_short ifm_msglen; - u_char ifm_version; - u_char ifm_type; - int ifm_addrs; - int ifm_flags; - u_short ifm_index; - struct if_data_freebsd11 ifm_data; -}; -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_ROUTE = C.AF_ROUTE - sysAF_LINK = C.AF_LINK - sysAF_INET6 = C.AF_INET6 - - sysSOCK_RAW = C.SOCK_RAW - - sysNET_RT_DUMP = C.NET_RT_DUMP - sysNET_RT_FLAGS = C.NET_RT_FLAGS - sysNET_RT_IFLIST = C.NET_RT_IFLIST - sysNET_RT_IFMALIST = C.NET_RT_IFMALIST - sysNET_RT_IFLISTL = C.NET_RT_IFLISTL -) - -const ( - sysCTL_MAXNAME = C.CTL_MAXNAME - - sysCTL_UNSPEC = C.CTL_UNSPEC - sysCTL_KERN = C.CTL_KERN - sysCTL_VM = C.CTL_VM - sysCTL_VFS = C.CTL_VFS - sysCTL_NET = C.CTL_NET - sysCTL_DEBUG = C.CTL_DEBUG - sysCTL_HW = C.CTL_HW - sysCTL_MACHDEP = C.CTL_MACHDEP - sysCTL_USER = C.CTL_USER - sysCTL_P1003_1B = C.CTL_P1003_1B -) - -const ( - sysRTM_VERSION = C.RTM_VERSION - - sysRTM_ADD = C.RTM_ADD - sysRTM_DELETE = C.RTM_DELETE - sysRTM_CHANGE = C.RTM_CHANGE - sysRTM_GET = C.RTM_GET - sysRTM_LOSING = C.RTM_LOSING - sysRTM_REDIRECT = C.RTM_REDIRECT - sysRTM_MISS = C.RTM_MISS - sysRTM_LOCK = C.RTM_LOCK - sysRTM_RESOLVE = C.RTM_RESOLVE - sysRTM_NEWADDR = C.RTM_NEWADDR - sysRTM_DELADDR = C.RTM_DELADDR - sysRTM_IFINFO = C.RTM_IFINFO - sysRTM_NEWMADDR = C.RTM_NEWMADDR - sysRTM_DELMADDR = C.RTM_DELMADDR - sysRTM_IFANNOUNCE = C.RTM_IFANNOUNCE - sysRTM_IEEE80211 = C.RTM_IEEE80211 - - sysRTA_DST = C.RTA_DST - sysRTA_GATEWAY = C.RTA_GATEWAY - sysRTA_NETMASK = C.RTA_NETMASK - sysRTA_GENMASK = C.RTA_GENMASK - sysRTA_IFP = C.RTA_IFP - sysRTA_IFA = C.RTA_IFA - sysRTA_AUTHOR = C.RTA_AUTHOR - sysRTA_BRD = C.RTA_BRD - - sysRTAX_DST = C.RTAX_DST - sysRTAX_GATEWAY = C.RTAX_GATEWAY - sysRTAX_NETMASK = C.RTAX_NETMASK - sysRTAX_GENMASK = C.RTAX_GENMASK - sysRTAX_IFP = C.RTAX_IFP - sysRTAX_IFA = C.RTAX_IFA - sysRTAX_AUTHOR = C.RTAX_AUTHOR - sysRTAX_BRD = C.RTAX_BRD - sysRTAX_MAX = C.RTAX_MAX -) - -const ( - sizeofIfMsghdrlFreeBSD10 = C.sizeof_struct_if_msghdrl - sizeofIfaMsghdrFreeBSD10 = C.sizeof_struct_ifa_msghdr - sizeofIfaMsghdrlFreeBSD10 = C.sizeof_struct_ifa_msghdrl - sizeofIfmaMsghdrFreeBSD10 = C.sizeof_struct_ifma_msghdr - sizeofIfAnnouncemsghdrFreeBSD10 = C.sizeof_struct_if_announcemsghdr - - sizeofRtMsghdrFreeBSD10 = C.sizeof_struct_rt_msghdr - sizeofRtMetricsFreeBSD10 = C.sizeof_struct_rt_metrics - - sizeofIfMsghdrFreeBSD7 = C.sizeof_struct_if_msghdr_freebsd7 - sizeofIfMsghdrFreeBSD8 = C.sizeof_struct_if_msghdr_freebsd8 - sizeofIfMsghdrFreeBSD9 = C.sizeof_struct_if_msghdr_freebsd9 - sizeofIfMsghdrFreeBSD10 = C.sizeof_struct_if_msghdr_freebsd10 - sizeofIfMsghdrFreeBSD11 = C.sizeof_struct_if_msghdr_freebsd11 - - sizeofIfDataFreeBSD7 = C.sizeof_struct_if_data_freebsd7 - sizeofIfDataFreeBSD8 = C.sizeof_struct_if_data_freebsd8 - sizeofIfDataFreeBSD9 = C.sizeof_struct_if_data_freebsd9 - sizeofIfDataFreeBSD10 = C.sizeof_struct_if_data_freebsd10 - sizeofIfDataFreeBSD11 = C.sizeof_struct_if_data_freebsd11 - - sizeofIfMsghdrlFreeBSD10Emu = C.sizeof_struct_if_msghdrl - sizeofIfaMsghdrFreeBSD10Emu = C.sizeof_struct_ifa_msghdr - sizeofIfaMsghdrlFreeBSD10Emu = C.sizeof_struct_ifa_msghdrl - sizeofIfmaMsghdrFreeBSD10Emu = C.sizeof_struct_ifma_msghdr - sizeofIfAnnouncemsghdrFreeBSD10Emu = C.sizeof_struct_if_announcemsghdr - - sizeofRtMsghdrFreeBSD10Emu = C.sizeof_struct_rt_msghdr - sizeofRtMetricsFreeBSD10Emu = C.sizeof_struct_rt_metrics - - sizeofIfMsghdrFreeBSD7Emu = C.sizeof_struct_if_msghdr_freebsd7 - sizeofIfMsghdrFreeBSD8Emu = C.sizeof_struct_if_msghdr_freebsd8 - sizeofIfMsghdrFreeBSD9Emu = C.sizeof_struct_if_msghdr_freebsd9 - sizeofIfMsghdrFreeBSD10Emu = C.sizeof_struct_if_msghdr_freebsd10 - sizeofIfMsghdrFreeBSD11Emu = C.sizeof_struct_if_msghdr_freebsd11 - - sizeofIfDataFreeBSD7Emu = C.sizeof_struct_if_data_freebsd7 - sizeofIfDataFreeBSD8Emu = C.sizeof_struct_if_data_freebsd8 - sizeofIfDataFreeBSD9Emu = C.sizeof_struct_if_data_freebsd9 - sizeofIfDataFreeBSD10Emu = C.sizeof_struct_if_data_freebsd10 - sizeofIfDataFreeBSD11Emu = C.sizeof_struct_if_data_freebsd11 - - sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 -) diff --git a/vendor/golang.org/x/net/route/defs_netbsd.go b/vendor/golang.org/x/net/route/defs_netbsd.go deleted file mode 100644 index b0abd549a..000000000 --- a/vendor/golang.org/x/net/route/defs_netbsd.go +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package route - -/* -#include -#include - -#include -#include -#include - -#include -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_ROUTE = C.AF_ROUTE - sysAF_LINK = C.AF_LINK - sysAF_INET6 = C.AF_INET6 - - sysSOCK_RAW = C.SOCK_RAW - - sysNET_RT_DUMP = C.NET_RT_DUMP - sysNET_RT_FLAGS = C.NET_RT_FLAGS - sysNET_RT_IFLIST = C.NET_RT_IFLIST - sysNET_RT_MAXID = C.NET_RT_MAXID -) - -const ( - sysCTL_MAXNAME = C.CTL_MAXNAME - - sysCTL_UNSPEC = C.CTL_UNSPEC - sysCTL_KERN = C.CTL_KERN - sysCTL_VM = C.CTL_VM - sysCTL_VFS = C.CTL_VFS - sysCTL_NET = C.CTL_NET - sysCTL_DEBUG = C.CTL_DEBUG - sysCTL_HW = C.CTL_HW - sysCTL_MACHDEP = C.CTL_MACHDEP - sysCTL_USER = C.CTL_USER - sysCTL_DDB = C.CTL_DDB - sysCTL_PROC = C.CTL_PROC - sysCTL_VENDOR = C.CTL_VENDOR - sysCTL_EMUL = C.CTL_EMUL - sysCTL_SECURITY = C.CTL_SECURITY - sysCTL_MAXID = C.CTL_MAXID -) - -const ( - sysRTM_VERSION = C.RTM_VERSION - - sysRTM_ADD = C.RTM_ADD - sysRTM_DELETE = C.RTM_DELETE - sysRTM_CHANGE = C.RTM_CHANGE - sysRTM_GET = C.RTM_GET - sysRTM_LOSING = C.RTM_LOSING - sysRTM_REDIRECT = C.RTM_REDIRECT - sysRTM_MISS = C.RTM_MISS - sysRTM_LOCK = C.RTM_LOCK - sysRTM_OLDADD = C.RTM_OLDADD - sysRTM_OLDDEL = C.RTM_OLDDEL - sysRTM_RESOLVE = C.RTM_RESOLVE - sysRTM_NEWADDR = C.RTM_NEWADDR - sysRTM_DELADDR = C.RTM_DELADDR - sysRTM_IFANNOUNCE = C.RTM_IFANNOUNCE - sysRTM_IEEE80211 = C.RTM_IEEE80211 - sysRTM_SETGATE = C.RTM_SETGATE - sysRTM_LLINFO_UPD = C.RTM_LLINFO_UPD - sysRTM_IFINFO = C.RTM_IFINFO - sysRTM_CHGADDR = C.RTM_CHGADDR - - sysRTA_DST = C.RTA_DST - sysRTA_GATEWAY = C.RTA_GATEWAY - sysRTA_NETMASK = C.RTA_NETMASK - sysRTA_GENMASK = C.RTA_GENMASK - sysRTA_IFP = C.RTA_IFP - sysRTA_IFA = C.RTA_IFA - sysRTA_AUTHOR = C.RTA_AUTHOR - sysRTA_BRD = C.RTA_BRD - sysRTA_TAG = C.RTA_TAG - - sysRTAX_DST = C.RTAX_DST - sysRTAX_GATEWAY = C.RTAX_GATEWAY - sysRTAX_NETMASK = C.RTAX_NETMASK - sysRTAX_GENMASK = C.RTAX_GENMASK - sysRTAX_IFP = C.RTAX_IFP - sysRTAX_IFA = C.RTAX_IFA - sysRTAX_AUTHOR = C.RTAX_AUTHOR - sysRTAX_BRD = C.RTAX_BRD - sysRTAX_TAG = C.RTAX_TAG - sysRTAX_MAX = C.RTAX_MAX -) - -const ( - sizeofIfMsghdrNetBSD7 = C.sizeof_struct_if_msghdr - sizeofIfaMsghdrNetBSD7 = C.sizeof_struct_ifa_msghdr - sizeofIfAnnouncemsghdrNetBSD7 = C.sizeof_struct_if_announcemsghdr - - sizeofRtMsghdrNetBSD7 = C.sizeof_struct_rt_msghdr - sizeofRtMetricsNetBSD7 = C.sizeof_struct_rt_metrics - - sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 -) diff --git a/vendor/golang.org/x/net/route/defs_openbsd.go b/vendor/golang.org/x/net/route/defs_openbsd.go deleted file mode 100644 index 0f66d3619..000000000 --- a/vendor/golang.org/x/net/route/defs_openbsd.go +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package route - -/* -#include -#include - -#include -#include -#include - -#include -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_ROUTE = C.AF_ROUTE - sysAF_LINK = C.AF_LINK - sysAF_INET6 = C.AF_INET6 - - sysSOCK_RAW = C.SOCK_RAW - - sysNET_RT_DUMP = C.NET_RT_DUMP - sysNET_RT_FLAGS = C.NET_RT_FLAGS - sysNET_RT_IFLIST = C.NET_RT_IFLIST - sysNET_RT_STATS = C.NET_RT_STATS - sysNET_RT_TABLE = C.NET_RT_TABLE - sysNET_RT_IFNAMES = C.NET_RT_IFNAMES - sysNET_RT_MAXID = C.NET_RT_MAXID -) - -const ( - sysCTL_MAXNAME = C.CTL_MAXNAME - - sysCTL_UNSPEC = C.CTL_UNSPEC - sysCTL_KERN = C.CTL_KERN - sysCTL_VM = C.CTL_VM - sysCTL_FS = C.CTL_FS - sysCTL_NET = C.CTL_NET - sysCTL_DEBUG = C.CTL_DEBUG - sysCTL_HW = C.CTL_HW - sysCTL_MACHDEP = C.CTL_MACHDEP - sysCTL_DDB = C.CTL_DDB - sysCTL_VFS = C.CTL_VFS - sysCTL_MAXID = C.CTL_MAXID -) - -const ( - sysRTM_VERSION = C.RTM_VERSION - - sysRTM_ADD = C.RTM_ADD - sysRTM_DELETE = C.RTM_DELETE - sysRTM_CHANGE = C.RTM_CHANGE - sysRTM_GET = C.RTM_GET - sysRTM_LOSING = C.RTM_LOSING - sysRTM_REDIRECT = C.RTM_REDIRECT - sysRTM_MISS = C.RTM_MISS - sysRTM_LOCK = C.RTM_LOCK - sysRTM_RESOLVE = C.RTM_RESOLVE - sysRTM_NEWADDR = C.RTM_NEWADDR - sysRTM_DELADDR = C.RTM_DELADDR - sysRTM_IFINFO = C.RTM_IFINFO - sysRTM_IFANNOUNCE = C.RTM_IFANNOUNCE - sysRTM_DESYNC = C.RTM_DESYNC - - sysRTA_DST = C.RTA_DST - sysRTA_GATEWAY = C.RTA_GATEWAY - sysRTA_NETMASK = C.RTA_NETMASK - sysRTA_GENMASK = C.RTA_GENMASK - sysRTA_IFP = C.RTA_IFP - sysRTA_IFA = C.RTA_IFA - sysRTA_AUTHOR = C.RTA_AUTHOR - sysRTA_BRD = C.RTA_BRD - sysRTA_SRC = C.RTA_SRC - sysRTA_SRCMASK = C.RTA_SRCMASK - sysRTA_LABEL = C.RTA_LABEL - - sysRTAX_DST = C.RTAX_DST - sysRTAX_GATEWAY = C.RTAX_GATEWAY - sysRTAX_NETMASK = C.RTAX_NETMASK - sysRTAX_GENMASK = C.RTAX_GENMASK - sysRTAX_IFP = C.RTAX_IFP - sysRTAX_IFA = C.RTAX_IFA - sysRTAX_AUTHOR = C.RTAX_AUTHOR - sysRTAX_BRD = C.RTAX_BRD - sysRTAX_SRC = C.RTAX_SRC - sysRTAX_SRCMASK = C.RTAX_SRCMASK - sysRTAX_LABEL = C.RTAX_LABEL - sysRTAX_MAX = C.RTAX_MAX -) - -const ( - sizeofRtMsghdr = C.sizeof_struct_rt_msghdr - - sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 -) diff --git a/vendor/golang.org/x/net/route/interface.go b/vendor/golang.org/x/net/route/interface.go deleted file mode 100644 index 854906d9c..000000000 --- a/vendor/golang.org/x/net/route/interface.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package route - -// An InterfaceMessage represents an interface message. -type InterfaceMessage struct { - Version int // message version - Type int // message type - Flags int // interface flags - Index int // interface index - Name string // interface name - Addrs []Addr // addresses - - extOff int // offset of header extension - raw []byte // raw message -} - -// An InterfaceAddrMessage represents an interface address message. -type InterfaceAddrMessage struct { - Version int // message version - Type int // message type - Flags int // interface flags - Index int // interface index - Addrs []Addr // addresses - - raw []byte // raw message -} - -// Sys implements the Sys method of Message interface. -func (m *InterfaceAddrMessage) Sys() []Sys { return nil } - -// An InterfaceMulticastAddrMessage represents an interface multicast -// address message. -type InterfaceMulticastAddrMessage struct { - Version int // message version - Type int // messsage type - Flags int // interface flags - Index int // interface index - Addrs []Addr // addresses - - raw []byte // raw message -} - -// Sys implements the Sys method of Message interface. -func (m *InterfaceMulticastAddrMessage) Sys() []Sys { return nil } - -// An InterfaceAnnounceMessage represents an interface announcement -// message. -type InterfaceAnnounceMessage struct { - Version int // message version - Type int // message type - Index int // interface index - Name string // interface name - What int // what type of announcement - - raw []byte // raw message -} - -// Sys implements the Sys method of Message interface. -func (m *InterfaceAnnounceMessage) Sys() []Sys { return nil } diff --git a/vendor/golang.org/x/net/route/interface_announce.go b/vendor/golang.org/x/net/route/interface_announce.go deleted file mode 100644 index 520d657b5..000000000 --- a/vendor/golang.org/x/net/route/interface_announce.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build dragonfly freebsd netbsd - -package route - -func (w *wireFormat) parseInterfaceAnnounceMessage(_ RIBType, b []byte) (Message, error) { - if len(b) < w.bodyOff { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - m := &InterfaceAnnounceMessage{ - Version: int(b[2]), - Type: int(b[3]), - Index: int(nativeEndian.Uint16(b[4:6])), - What: int(nativeEndian.Uint16(b[22:24])), - raw: b[:l], - } - for i := 0; i < 16; i++ { - if b[6+i] != 0 { - continue - } - m.Name = string(b[6 : 6+i]) - break - } - return m, nil -} diff --git a/vendor/golang.org/x/net/route/interface_classic.go b/vendor/golang.org/x/net/route/interface_classic.go deleted file mode 100644 index ac4e7a680..000000000 --- a/vendor/golang.org/x/net/route/interface_classic.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly netbsd - -package route - -import "runtime" - -func (w *wireFormat) parseInterfaceMessage(_ RIBType, b []byte) (Message, error) { - if len(b) < w.bodyOff { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - attrs := uint(nativeEndian.Uint32(b[4:8])) - if attrs&sysRTA_IFP == 0 { - return nil, nil - } - m := &InterfaceMessage{ - Version: int(b[2]), - Type: int(b[3]), - Addrs: make([]Addr, sysRTAX_MAX), - Flags: int(nativeEndian.Uint32(b[8:12])), - Index: int(nativeEndian.Uint16(b[12:14])), - extOff: w.extOff, - raw: b[:l], - } - a, err := parseLinkAddr(b[w.bodyOff:]) - if err != nil { - return nil, err - } - m.Addrs[sysRTAX_IFP] = a - m.Name = a.(*LinkAddr).Name - return m, nil -} - -func (w *wireFormat) parseInterfaceAddrMessage(_ RIBType, b []byte) (Message, error) { - if len(b) < w.bodyOff { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - m := &InterfaceAddrMessage{ - Version: int(b[2]), - Type: int(b[3]), - Flags: int(nativeEndian.Uint32(b[8:12])), - raw: b[:l], - } - if runtime.GOOS == "netbsd" { - m.Index = int(nativeEndian.Uint16(b[16:18])) - } else { - m.Index = int(nativeEndian.Uint16(b[12:14])) - } - var err error - m.Addrs, err = parseAddrs(uint(nativeEndian.Uint32(b[4:8])), parseKernelInetAddr, b[w.bodyOff:]) - if err != nil { - return nil, err - } - return m, nil -} diff --git a/vendor/golang.org/x/net/route/interface_freebsd.go b/vendor/golang.org/x/net/route/interface_freebsd.go deleted file mode 100644 index 9f6f50c00..000000000 --- a/vendor/golang.org/x/net/route/interface_freebsd.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -func (w *wireFormat) parseInterfaceMessage(typ RIBType, b []byte) (Message, error) { - var extOff, bodyOff int - if typ == sysNET_RT_IFLISTL { - if len(b) < 20 { - return nil, errMessageTooShort - } - extOff = int(nativeEndian.Uint16(b[18:20])) - bodyOff = int(nativeEndian.Uint16(b[16:18])) - } else { - extOff = w.extOff - bodyOff = w.bodyOff - } - if len(b) < extOff || len(b) < bodyOff { - return nil, errInvalidMessage - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - attrs := uint(nativeEndian.Uint32(b[4:8])) - if attrs&sysRTA_IFP == 0 { - return nil, nil - } - m := &InterfaceMessage{ - Version: int(b[2]), - Type: int(b[3]), - Flags: int(nativeEndian.Uint32(b[8:12])), - Index: int(nativeEndian.Uint16(b[12:14])), - Addrs: make([]Addr, sysRTAX_MAX), - extOff: extOff, - raw: b[:l], - } - a, err := parseLinkAddr(b[bodyOff:]) - if err != nil { - return nil, err - } - m.Addrs[sysRTAX_IFP] = a - m.Name = a.(*LinkAddr).Name - return m, nil -} - -func (w *wireFormat) parseInterfaceAddrMessage(typ RIBType, b []byte) (Message, error) { - var bodyOff int - if typ == sysNET_RT_IFLISTL { - if len(b) < 24 { - return nil, errMessageTooShort - } - bodyOff = int(nativeEndian.Uint16(b[16:18])) - } else { - bodyOff = w.bodyOff - } - if len(b) < bodyOff { - return nil, errInvalidMessage - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - m := &InterfaceAddrMessage{ - Version: int(b[2]), - Type: int(b[3]), - Flags: int(nativeEndian.Uint32(b[8:12])), - Index: int(nativeEndian.Uint16(b[12:14])), - raw: b[:l], - } - var err error - m.Addrs, err = parseAddrs(uint(nativeEndian.Uint32(b[4:8])), parseKernelInetAddr, b[bodyOff:]) - if err != nil { - return nil, err - } - return m, nil -} diff --git a/vendor/golang.org/x/net/route/interface_multicast.go b/vendor/golang.org/x/net/route/interface_multicast.go deleted file mode 100644 index 1e99a9cc6..000000000 --- a/vendor/golang.org/x/net/route/interface_multicast.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd - -package route - -func (w *wireFormat) parseInterfaceMulticastAddrMessage(_ RIBType, b []byte) (Message, error) { - if len(b) < w.bodyOff { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - m := &InterfaceMulticastAddrMessage{ - Version: int(b[2]), - Type: int(b[3]), - Flags: int(nativeEndian.Uint32(b[8:12])), - Index: int(nativeEndian.Uint16(b[12:14])), - raw: b[:l], - } - var err error - m.Addrs, err = parseAddrs(uint(nativeEndian.Uint32(b[4:8])), parseKernelInetAddr, b[w.bodyOff:]) - if err != nil { - return nil, err - } - return m, nil -} diff --git a/vendor/golang.org/x/net/route/interface_openbsd.go b/vendor/golang.org/x/net/route/interface_openbsd.go deleted file mode 100644 index e4a143c1c..000000000 --- a/vendor/golang.org/x/net/route/interface_openbsd.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -func (*wireFormat) parseInterfaceMessage(_ RIBType, b []byte) (Message, error) { - if len(b) < 32 { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - attrs := uint(nativeEndian.Uint32(b[12:16])) - if attrs&sysRTA_IFP == 0 { - return nil, nil - } - m := &InterfaceMessage{ - Version: int(b[2]), - Type: int(b[3]), - Flags: int(nativeEndian.Uint32(b[16:20])), - Index: int(nativeEndian.Uint16(b[6:8])), - Addrs: make([]Addr, sysRTAX_MAX), - raw: b[:l], - } - ll := int(nativeEndian.Uint16(b[4:6])) - if len(b) < ll { - return nil, errInvalidMessage - } - a, err := parseLinkAddr(b[ll:]) - if err != nil { - return nil, err - } - m.Addrs[sysRTAX_IFP] = a - m.Name = a.(*LinkAddr).Name - return m, nil -} - -func (*wireFormat) parseInterfaceAddrMessage(_ RIBType, b []byte) (Message, error) { - if len(b) < 24 { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - bodyOff := int(nativeEndian.Uint16(b[4:6])) - if len(b) < bodyOff { - return nil, errInvalidMessage - } - m := &InterfaceAddrMessage{ - Version: int(b[2]), - Type: int(b[3]), - Flags: int(nativeEndian.Uint32(b[12:16])), - Index: int(nativeEndian.Uint16(b[6:8])), - raw: b[:l], - } - var err error - m.Addrs, err = parseAddrs(uint(nativeEndian.Uint32(b[12:16])), parseKernelInetAddr, b[bodyOff:]) - if err != nil { - return nil, err - } - return m, nil -} - -func (*wireFormat) parseInterfaceAnnounceMessage(_ RIBType, b []byte) (Message, error) { - if len(b) < 26 { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - m := &InterfaceAnnounceMessage{ - Version: int(b[2]), - Type: int(b[3]), - Index: int(nativeEndian.Uint16(b[6:8])), - What: int(nativeEndian.Uint16(b[8:10])), - raw: b[:l], - } - for i := 0; i < 16; i++ { - if b[10+i] != 0 { - continue - } - m.Name = string(b[10 : 10+i]) - break - } - return m, nil -} diff --git a/vendor/golang.org/x/net/route/message.go b/vendor/golang.org/x/net/route/message.go deleted file mode 100644 index 0fa7e09f4..000000000 --- a/vendor/golang.org/x/net/route/message.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package route - -// A Message represents a routing message. -type Message interface { - // Sys returns operating system-specific information. - Sys() []Sys -} - -// A Sys reprensents operating system-specific information. -type Sys interface { - // SysType returns a type of operating system-specific - // information. - SysType() SysType -} - -// A SysType represents a type of operating system-specific -// information. -type SysType int - -const ( - SysMetrics SysType = iota - SysStats -) - -// ParseRIB parses b as a routing information base and returns a list -// of routing messages. -func ParseRIB(typ RIBType, b []byte) ([]Message, error) { - if !typ.parseable() { - return nil, errUnsupportedMessage - } - var msgs []Message - nmsgs, nskips := 0, 0 - for len(b) > 4 { - nmsgs++ - l := int(nativeEndian.Uint16(b[:2])) - if l == 0 { - return nil, errInvalidMessage - } - if len(b) < l { - return nil, errMessageTooShort - } - if b[2] != sysRTM_VERSION { - b = b[l:] - continue - } - if w, ok := wireFormats[int(b[3])]; !ok { - nskips++ - } else { - m, err := w.parse(typ, b) - if err != nil { - return nil, err - } - if m == nil { - nskips++ - } else { - msgs = append(msgs, m) - } - } - b = b[l:] - } - // We failed to parse any of the messages - version mismatch? - if nmsgs != len(msgs)+nskips { - return nil, errMessageMismatch - } - return msgs, nil -} diff --git a/vendor/golang.org/x/net/route/message_darwin_test.go b/vendor/golang.org/x/net/route/message_darwin_test.go deleted file mode 100644 index 316aa7507..000000000 --- a/vendor/golang.org/x/net/route/message_darwin_test.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -import "testing" - -func TestFetchAndParseRIBOnDarwin(t *testing.T) { - for _, typ := range []RIBType{sysNET_RT_FLAGS, sysNET_RT_DUMP2, sysNET_RT_IFLIST2} { - var lastErr error - var ms []Message - for _, af := range []int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} { - rs, err := fetchAndParseRIB(af, typ) - if err != nil { - lastErr = err - continue - } - ms = append(ms, rs...) - } - if len(ms) == 0 && lastErr != nil { - t.Error(typ, lastErr) - continue - } - ss, err := msgs(ms).validate() - if err != nil { - t.Error(typ, err) - continue - } - for _, s := range ss { - t.Log(s) - } - } -} diff --git a/vendor/golang.org/x/net/route/message_freebsd_test.go b/vendor/golang.org/x/net/route/message_freebsd_test.go deleted file mode 100644 index db4b56752..000000000 --- a/vendor/golang.org/x/net/route/message_freebsd_test.go +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -import ( - "testing" - "unsafe" -) - -func TestFetchAndParseRIBOnFreeBSD(t *testing.T) { - for _, typ := range []RIBType{sysNET_RT_IFMALIST} { - var lastErr error - var ms []Message - for _, af := range []int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} { - rs, err := fetchAndParseRIB(af, typ) - if err != nil { - lastErr = err - continue - } - ms = append(ms, rs...) - } - if len(ms) == 0 && lastErr != nil { - t.Error(typ, lastErr) - continue - } - ss, err := msgs(ms).validate() - if err != nil { - t.Error(typ, err) - continue - } - for _, s := range ss { - t.Log(s) - } - } -} - -func TestFetchAndParseRIBOnFreeBSD10AndAbove(t *testing.T) { - if _, err := FetchRIB(sysAF_UNSPEC, sysNET_RT_IFLISTL, 0); err != nil { - t.Skip("NET_RT_IFLISTL not supported") - } - var p uintptr - if kernelAlign != int(unsafe.Sizeof(p)) { - t.Skip("NET_RT_IFLIST vs. NET_RT_IFLISTL doesn't work for 386 emulation on amd64") - } - - var tests = [2]struct { - typ RIBType - b []byte - msgs []Message - ss []string - }{ - {typ: sysNET_RT_IFLIST}, - {typ: sysNET_RT_IFLISTL}, - } - for i := range tests { - var lastErr error - for _, af := range []int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} { - rs, err := fetchAndParseRIB(af, tests[i].typ) - if err != nil { - lastErr = err - continue - } - tests[i].msgs = append(tests[i].msgs, rs...) - } - if len(tests[i].msgs) == 0 && lastErr != nil { - t.Error(tests[i].typ, lastErr) - continue - } - tests[i].ss, lastErr = msgs(tests[i].msgs).validate() - if lastErr != nil { - t.Error(tests[i].typ, lastErr) - continue - } - for _, s := range tests[i].ss { - t.Log(s) - } - } - for i := len(tests) - 1; i > 0; i-- { - if len(tests[i].ss) != len(tests[i-1].ss) { - t.Errorf("got %v; want %v", tests[i].ss, tests[i-1].ss) - continue - } - for j, s1 := range tests[i].ss { - s0 := tests[i-1].ss[j] - if s1 != s0 { - t.Errorf("got %s; want %s", s1, s0) - } - } - } -} diff --git a/vendor/golang.org/x/net/route/message_test.go b/vendor/golang.org/x/net/route/message_test.go deleted file mode 100644 index e848dabf4..000000000 --- a/vendor/golang.org/x/net/route/message_test.go +++ /dev/null @@ -1,239 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package route - -import ( - "os" - "syscall" - "testing" - "time" -) - -func TestFetchAndParseRIB(t *testing.T) { - for _, typ := range []RIBType{sysNET_RT_DUMP, sysNET_RT_IFLIST} { - var lastErr error - var ms []Message - for _, af := range []int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} { - rs, err := fetchAndParseRIB(af, typ) - if err != nil { - lastErr = err - continue - } - ms = append(ms, rs...) - } - if len(ms) == 0 && lastErr != nil { - t.Error(typ, lastErr) - continue - } - ss, err := msgs(ms).validate() - if err != nil { - t.Error(typ, err) - continue - } - for _, s := range ss { - t.Log(typ, s) - } - } -} - -var ( - rtmonSock int - rtmonErr error -) - -func init() { - // We need to keep rtmonSock alive to avoid treading on - // recycled socket descriptors. - rtmonSock, rtmonErr = syscall.Socket(sysAF_ROUTE, sysSOCK_RAW, sysAF_UNSPEC) -} - -// TestMonitorAndParseRIB leaks a worker goroutine and a socket -// descriptor but that's intentional. -func TestMonitorAndParseRIB(t *testing.T) { - if testing.Short() || os.Getuid() != 0 { - t.Skip("must be root") - } - - if rtmonErr != nil { - t.Fatal(rtmonErr) - } - - // We suppose that using an IPv4 link-local address and the - // dot1Q ID for Token Ring and FDDI doesn't harm anyone. - pv := &propVirtual{addr: "169.254.0.1", mask: "255.255.255.0"} - if err := pv.configure(1002); err != nil { - t.Skip(err) - } - if err := pv.setup(); err != nil { - t.Skip(err) - } - pv.teardown() - - go func() { - b := make([]byte, os.Getpagesize()) - for { - // There's no easy way to unblock this read - // call because the routing message exchange - // over routing socket is a connectionless - // message-oriented protocol, no control plane - // for signaling connectivity, and we cannot - // use the net package of standard library due - // to the lack of support for routing socket - // and circular dependency. - n, err := syscall.Read(rtmonSock, b) - if err != nil { - return - } - ms, err := ParseRIB(0, b[:n]) - if err != nil { - t.Error(err) - return - } - ss, err := msgs(ms).validate() - if err != nil { - t.Error(err) - return - } - for _, s := range ss { - t.Log(s) - } - } - }() - - for _, vid := range []int{1002, 1003, 1004, 1005} { - pv := &propVirtual{addr: "169.254.0.1", mask: "255.255.255.0"} - if err := pv.configure(vid); err != nil { - t.Fatal(err) - } - if err := pv.setup(); err != nil { - t.Fatal(err) - } - time.Sleep(200 * time.Millisecond) - if err := pv.teardown(); err != nil { - t.Fatal(err) - } - time.Sleep(200 * time.Millisecond) - } -} - -func TestParseRIBWithFuzz(t *testing.T) { - for _, fuzz := range []string{ - "0\x00\x05\x050000000000000000" + - "00000000000000000000" + - "00000000000000000000" + - "00000000000000000000" + - "0000000000000\x02000000" + - "00000000", - "\x02\x00\x05\f0000000000000000" + - "0\x0200000000000000", - "\x02\x00\x05\x100000000000000\x1200" + - "0\x00\xff\x00", - "\x02\x00\x05\f0000000000000000" + - "0\x12000\x00\x02\x0000", - "\x00\x00\x00\x01\x00", - "00000", - } { - for typ := RIBType(0); typ < 256; typ++ { - ParseRIB(typ, []byte(fuzz)) - } - } -} - -func TestRouteMessage(t *testing.T) { - s, err := syscall.Socket(sysAF_ROUTE, sysSOCK_RAW, sysAF_UNSPEC) - if err != nil { - t.Fatal(err) - } - defer syscall.Close(s) - - var ms []RouteMessage - for _, af := range []int{sysAF_INET, sysAF_INET6} { - if _, err := fetchAndParseRIB(af, sysNET_RT_DUMP); err != nil { - t.Log(err) - continue - } - switch af { - case sysAF_INET: - ms = append(ms, []RouteMessage{ - { - Type: sysRTM_GET, - Addrs: []Addr{ - &Inet4Addr{IP: [4]byte{127, 0, 0, 1}}, - nil, - nil, - nil, - &LinkAddr{}, - &Inet4Addr{}, - nil, - &Inet4Addr{}, - }, - }, - { - Type: sysRTM_GET, - Addrs: []Addr{ - &Inet4Addr{IP: [4]byte{127, 0, 0, 1}}, - }, - }, - }...) - case sysAF_INET6: - ms = append(ms, []RouteMessage{ - { - Type: sysRTM_GET, - Addrs: []Addr{ - &Inet6Addr{IP: [16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}}, - nil, - nil, - nil, - &LinkAddr{}, - &Inet6Addr{}, - nil, - &Inet6Addr{}, - }, - }, - { - Type: sysRTM_GET, - Addrs: []Addr{ - &Inet6Addr{IP: [16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}}, - }, - }, - }...) - } - } - for i, m := range ms { - m.ID = uintptr(os.Getpid()) - m.Seq = i + 1 - wb, err := m.Marshal() - if err != nil { - t.Fatalf("%v: %v", m, err) - } - if _, err := syscall.Write(s, wb); err != nil { - t.Fatalf("%v: %v", m, err) - } - rb := make([]byte, os.Getpagesize()) - n, err := syscall.Read(s, rb) - if err != nil { - t.Fatalf("%v: %v", m, err) - } - rms, err := ParseRIB(0, rb[:n]) - if err != nil { - t.Fatalf("%v: %v", m, err) - } - for _, rm := range rms { - err := rm.(*RouteMessage).Err - if err != nil { - t.Errorf("%v: %v", m, err) - } - } - ss, err := msgs(rms).validate() - if err != nil { - t.Fatalf("%v: %v", m, err) - } - for _, s := range ss { - t.Log(s) - } - } -} diff --git a/vendor/golang.org/x/net/route/route.go b/vendor/golang.org/x/net/route/route.go deleted file mode 100644 index 081da0d5c..000000000 --- a/vendor/golang.org/x/net/route/route.go +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -// Package route provides basic functions for the manipulation of -// packet routing facilities on BSD variants. -// -// The package supports any version of Darwin, any version of -// DragonFly BSD, FreeBSD 7 through 11, NetBSD 6 and above, and -// OpenBSD 5.6 and above. -package route - -import ( - "errors" - "os" - "syscall" -) - -var ( - errUnsupportedMessage = errors.New("unsupported message") - errMessageMismatch = errors.New("message mismatch") - errMessageTooShort = errors.New("message too short") - errInvalidMessage = errors.New("invalid message") - errInvalidAddr = errors.New("invalid address") - errShortBuffer = errors.New("short buffer") -) - -// A RouteMessage represents a message conveying an address prefix, a -// nexthop address and an output interface. -// -// Unlike other messages, this message can be used to query adjacency -// information for the given address prefix, to add a new route, and -// to delete or modify the existing route from the routing information -// base inside the kernel by writing and reading route messages on a -// routing socket. -// -// For the manipulation of routing information, the route message must -// contain appropriate fields that include: -// -// Version = -// Type = -// Flags = -// Index = -// ID = -// Seq = -// Addrs = -// -// The Type field specifies a type of manipulation, the Flags field -// specifies a class of target information and the Addrs field -// specifies target information like the following: -// -// route.RouteMessage{ -// Version: RTM_VERSION, -// Type: RTM_GET, -// Flags: RTF_UP | RTF_HOST, -// ID: uintptr(os.Getpid()), -// Seq: 1, -// Addrs: []route.Addrs{ -// RTAX_DST: &route.Inet4Addr{ ... }, -// RTAX_IFP: &route.LinkAddr{ ... }, -// RTAX_BRD: &route.Inet4Addr{ ... }, -// }, -// } -// -// The values for the above fields depend on the implementation of -// each operating system. -// -// The Err field on a response message contains an error value on the -// requested operation. If non-nil, the requested operation is failed. -type RouteMessage struct { - Version int // message version - Type int // message type - Flags int // route flags - Index int // interface index when atatched - ID uintptr // sender's identifier; usually process ID - Seq int // sequence number - Err error // error on requested operation - Addrs []Addr // addresses - - extOff int // offset of header extension - raw []byte // raw message -} - -// Marshal returns the binary encoding of m. -func (m *RouteMessage) Marshal() ([]byte, error) { - return m.marshal() -} - -// A RIBType reprensents a type of routing information base. -type RIBType int - -const ( - RIBTypeRoute RIBType = syscall.NET_RT_DUMP - RIBTypeInterface RIBType = syscall.NET_RT_IFLIST -) - -// FetchRIB fetches a routing information base from the operating -// system. -// -// The provided af must be an address family. -// -// The provided arg must be a RIBType-specific argument. -// When RIBType is related to routes, arg might be a set of route -// flags. When RIBType is related to network interfaces, arg might be -// an interface index or a set of interface flags. In most cases, zero -// means a wildcard. -func FetchRIB(af int, typ RIBType, arg int) ([]byte, error) { - mib := [6]int32{sysCTL_NET, sysAF_ROUTE, 0, int32(af), int32(typ), int32(arg)} - n := uintptr(0) - if err := sysctl(mib[:], nil, &n, nil, 0); err != nil { - return nil, os.NewSyscallError("sysctl", err) - } - if n == 0 { - return nil, nil - } - b := make([]byte, n) - if err := sysctl(mib[:], &b[0], &n, nil, 0); err != nil { - return nil, os.NewSyscallError("sysctl", err) - } - return b[:n], nil -} diff --git a/vendor/golang.org/x/net/route/route_classic.go b/vendor/golang.org/x/net/route/route_classic.go deleted file mode 100644 index 61b2bb4ad..000000000 --- a/vendor/golang.org/x/net/route/route_classic.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd - -package route - -import "syscall" - -func (m *RouteMessage) marshal() ([]byte, error) { - w, ok := wireFormats[m.Type] - if !ok { - return nil, errUnsupportedMessage - } - l := w.bodyOff + addrsSpace(m.Addrs) - b := make([]byte, l) - nativeEndian.PutUint16(b[:2], uint16(l)) - if m.Version == 0 { - b[2] = sysRTM_VERSION - } else { - b[2] = byte(m.Version) - } - b[3] = byte(m.Type) - nativeEndian.PutUint32(b[8:12], uint32(m.Flags)) - nativeEndian.PutUint16(b[4:6], uint16(m.Index)) - nativeEndian.PutUint32(b[16:20], uint32(m.ID)) - nativeEndian.PutUint32(b[20:24], uint32(m.Seq)) - attrs, err := marshalAddrs(b[w.bodyOff:], m.Addrs) - if err != nil { - return nil, err - } - if attrs > 0 { - nativeEndian.PutUint32(b[12:16], uint32(attrs)) - } - return b, nil -} - -func (w *wireFormat) parseRouteMessage(typ RIBType, b []byte) (Message, error) { - if len(b) < w.bodyOff { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - m := &RouteMessage{ - Version: int(b[2]), - Type: int(b[3]), - Flags: int(nativeEndian.Uint32(b[8:12])), - Index: int(nativeEndian.Uint16(b[4:6])), - ID: uintptr(nativeEndian.Uint32(b[16:20])), - Seq: int(nativeEndian.Uint32(b[20:24])), - extOff: w.extOff, - raw: b[:l], - } - errno := syscall.Errno(nativeEndian.Uint32(b[28:32])) - if errno != 0 { - m.Err = errno - } - var err error - m.Addrs, err = parseAddrs(uint(nativeEndian.Uint32(b[12:16])), parseKernelInetAddr, b[w.bodyOff:]) - if err != nil { - return nil, err - } - return m, nil -} diff --git a/vendor/golang.org/x/net/route/route_openbsd.go b/vendor/golang.org/x/net/route/route_openbsd.go deleted file mode 100644 index daf2e90c4..000000000 --- a/vendor/golang.org/x/net/route/route_openbsd.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -import "syscall" - -func (m *RouteMessage) marshal() ([]byte, error) { - l := sizeofRtMsghdr + addrsSpace(m.Addrs) - b := make([]byte, l) - nativeEndian.PutUint16(b[:2], uint16(l)) - if m.Version == 0 { - b[2] = sysRTM_VERSION - } else { - b[2] = byte(m.Version) - } - b[3] = byte(m.Type) - nativeEndian.PutUint16(b[4:6], uint16(sizeofRtMsghdr)) - nativeEndian.PutUint32(b[16:20], uint32(m.Flags)) - nativeEndian.PutUint16(b[6:8], uint16(m.Index)) - nativeEndian.PutUint32(b[24:28], uint32(m.ID)) - nativeEndian.PutUint32(b[28:32], uint32(m.Seq)) - attrs, err := marshalAddrs(b[sizeofRtMsghdr:], m.Addrs) - if err != nil { - return nil, err - } - if attrs > 0 { - nativeEndian.PutUint32(b[12:16], uint32(attrs)) - } - return b, nil -} - -func (*wireFormat) parseRouteMessage(_ RIBType, b []byte) (Message, error) { - if len(b) < sizeofRtMsghdr { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - m := &RouteMessage{ - Version: int(b[2]), - Type: int(b[3]), - Flags: int(nativeEndian.Uint32(b[16:20])), - Index: int(nativeEndian.Uint16(b[6:8])), - ID: uintptr(nativeEndian.Uint32(b[24:28])), - Seq: int(nativeEndian.Uint32(b[28:32])), - raw: b[:l], - } - ll := int(nativeEndian.Uint16(b[4:6])) - if len(b) < ll { - return nil, errInvalidMessage - } - errno := syscall.Errno(nativeEndian.Uint32(b[32:36])) - if errno != 0 { - m.Err = errno - } - as, err := parseAddrs(uint(nativeEndian.Uint32(b[12:16])), parseKernelInetAddr, b[ll:]) - if err != nil { - return nil, err - } - m.Addrs = as - return m, nil -} diff --git a/vendor/golang.org/x/net/route/route_test.go b/vendor/golang.org/x/net/route/route_test.go deleted file mode 100644 index 63fd8c561..000000000 --- a/vendor/golang.org/x/net/route/route_test.go +++ /dev/null @@ -1,386 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package route - -import ( - "fmt" - "os/exec" - "runtime" - "time" -) - -func (m *RouteMessage) String() string { - return fmt.Sprintf("%s", addrAttrs(nativeEndian.Uint32(m.raw[12:16]))) -} - -func (m *InterfaceMessage) String() string { - var attrs addrAttrs - if runtime.GOOS == "openbsd" { - attrs = addrAttrs(nativeEndian.Uint32(m.raw[12:16])) - } else { - attrs = addrAttrs(nativeEndian.Uint32(m.raw[4:8])) - } - return fmt.Sprintf("%s", attrs) -} - -func (m *InterfaceAddrMessage) String() string { - var attrs addrAttrs - if runtime.GOOS == "openbsd" { - attrs = addrAttrs(nativeEndian.Uint32(m.raw[12:16])) - } else { - attrs = addrAttrs(nativeEndian.Uint32(m.raw[4:8])) - } - return fmt.Sprintf("%s", attrs) -} - -func (m *InterfaceMulticastAddrMessage) String() string { - return fmt.Sprintf("%s", addrAttrs(nativeEndian.Uint32(m.raw[4:8]))) -} - -func (m *InterfaceAnnounceMessage) String() string { - what := "" - switch m.What { - case 0: - what = "arrival" - case 1: - what = "departure" - } - return fmt.Sprintf("(%d %s %s)", m.Index, m.Name, what) -} - -func (m *InterfaceMetrics) String() string { - return fmt.Sprintf("(type=%d mtu=%d)", m.Type, m.MTU) -} - -func (m *RouteMetrics) String() string { - return fmt.Sprintf("(pmtu=%d)", m.PathMTU) -} - -type addrAttrs uint - -var addrAttrNames = [...]string{ - "dst", - "gateway", - "netmask", - "genmask", - "ifp", - "ifa", - "author", - "brd", - "df:mpls1-n:tag-o:src", // mpls1 for dragonfly, tag for netbsd, src for openbsd - "df:mpls2-o:srcmask", // mpls2 for dragonfly, srcmask for openbsd - "df:mpls3-o:label", // mpls3 for dragonfly, label for openbsd -} - -func (attrs addrAttrs) String() string { - var s string - for i, name := range addrAttrNames { - if attrs&(1<" - } - return s -} - -type msgs []Message - -func (ms msgs) validate() ([]string, error) { - var ss []string - for _, m := range ms { - switch m := m.(type) { - case *RouteMessage: - if err := addrs(m.Addrs).match(addrAttrs(nativeEndian.Uint32(m.raw[12:16]))); err != nil { - return nil, err - } - sys := m.Sys() - if sys == nil { - return nil, fmt.Errorf("no sys for %s", m.String()) - } - ss = append(ss, m.String()+" "+syss(sys).String()+" "+addrs(m.Addrs).String()) - case *InterfaceMessage: - var attrs addrAttrs - if runtime.GOOS == "openbsd" { - attrs = addrAttrs(nativeEndian.Uint32(m.raw[12:16])) - } else { - attrs = addrAttrs(nativeEndian.Uint32(m.raw[4:8])) - } - if err := addrs(m.Addrs).match(attrs); err != nil { - return nil, err - } - sys := m.Sys() - if sys == nil { - return nil, fmt.Errorf("no sys for %s", m.String()) - } - ss = append(ss, m.String()+" "+syss(sys).String()+" "+addrs(m.Addrs).String()) - case *InterfaceAddrMessage: - var attrs addrAttrs - if runtime.GOOS == "openbsd" { - attrs = addrAttrs(nativeEndian.Uint32(m.raw[12:16])) - } else { - attrs = addrAttrs(nativeEndian.Uint32(m.raw[4:8])) - } - if err := addrs(m.Addrs).match(attrs); err != nil { - return nil, err - } - ss = append(ss, m.String()+" "+addrs(m.Addrs).String()) - case *InterfaceMulticastAddrMessage: - if err := addrs(m.Addrs).match(addrAttrs(nativeEndian.Uint32(m.raw[4:8]))); err != nil { - return nil, err - } - ss = append(ss, m.String()+" "+addrs(m.Addrs).String()) - case *InterfaceAnnounceMessage: - ss = append(ss, m.String()) - default: - ss = append(ss, fmt.Sprintf("%+v", m)) - } - } - return ss, nil -} - -type syss []Sys - -func (sys syss) String() string { - var s string - for _, sy := range sys { - switch sy := sy.(type) { - case *InterfaceMetrics: - if len(s) > 0 { - s += " " - } - s += sy.String() - case *RouteMetrics: - if len(s) > 0 { - s += " " - } - s += sy.String() - } - } - return s -} - -type addrFamily int - -func (af addrFamily) String() string { - switch af { - case sysAF_UNSPEC: - return "unspec" - case sysAF_LINK: - return "link" - case sysAF_INET: - return "inet4" - case sysAF_INET6: - return "inet6" - default: - return fmt.Sprintf("%d", af) - } -} - -const hexDigit = "0123456789abcdef" - -type llAddr []byte - -func (a llAddr) String() string { - if len(a) == 0 { - return "" - } - buf := make([]byte, 0, len(a)*3-1) - for i, b := range a { - if i > 0 { - buf = append(buf, ':') - } - buf = append(buf, hexDigit[b>>4]) - buf = append(buf, hexDigit[b&0xF]) - } - return string(buf) -} - -type ipAddr []byte - -func (a ipAddr) String() string { - if len(a) == 0 { - return "" - } - if len(a) == 4 { - return fmt.Sprintf("%d.%d.%d.%d", a[0], a[1], a[2], a[3]) - } - if len(a) == 16 { - return fmt.Sprintf("%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]) - } - s := make([]byte, len(a)*2) - for i, tn := range a { - s[i*2], s[i*2+1] = hexDigit[tn>>4], hexDigit[tn&0xf] - } - return string(s) -} - -func (a *LinkAddr) String() string { - name := a.Name - if name == "" { - name = "" - } - lla := llAddr(a.Addr).String() - if lla == "" { - lla = "" - } - return fmt.Sprintf("(%v %d %s %s)", addrFamily(a.Family()), a.Index, name, lla) -} - -func (a *Inet4Addr) String() string { - return fmt.Sprintf("(%v %v)", addrFamily(a.Family()), ipAddr(a.IP[:])) -} - -func (a *Inet6Addr) String() string { - return fmt.Sprintf("(%v %v %d)", addrFamily(a.Family()), ipAddr(a.IP[:]), a.ZoneID) -} - -func (a *DefaultAddr) String() string { - return fmt.Sprintf("(%v %s)", addrFamily(a.Family()), ipAddr(a.Raw[2:]).String()) -} - -type addrs []Addr - -func (as addrs) String() string { - var s string - for _, a := range as { - if a == nil { - continue - } - if len(s) > 0 { - s += " " - } - switch a := a.(type) { - case *LinkAddr: - s += a.String() - case *Inet4Addr: - s += a.String() - case *Inet6Addr: - s += a.String() - case *DefaultAddr: - s += a.String() - } - } - if s == "" { - return "" - } - return s -} - -func (as addrs) match(attrs addrAttrs) error { - var ts addrAttrs - af := sysAF_UNSPEC - for i := range as { - if as[i] != nil { - ts |= 1 << uint(i) - } - switch as[i].(type) { - case *Inet4Addr: - if af == sysAF_UNSPEC { - af = sysAF_INET - } - if af != sysAF_INET { - return fmt.Errorf("got %v; want %v", addrs(as), addrFamily(af)) - } - case *Inet6Addr: - if af == sysAF_UNSPEC { - af = sysAF_INET6 - } - if af != sysAF_INET6 { - return fmt.Errorf("got %v; want %v", addrs(as), addrFamily(af)) - } - } - } - if ts != attrs && ts > attrs { - return fmt.Errorf("%v not included in %v", ts, attrs) - } - return nil -} - -func fetchAndParseRIB(af int, typ RIBType) ([]Message, error) { - var err error - var b []byte - for i := 0; i < 3; i++ { - if b, err = FetchRIB(af, typ, 0); err != nil { - time.Sleep(10 * time.Millisecond) - continue - } - break - } - if err != nil { - return nil, fmt.Errorf("%v %d %v", addrFamily(af), typ, err) - } - ms, err := ParseRIB(typ, b) - if err != nil { - return nil, fmt.Errorf("%v %d %v", addrFamily(af), typ, err) - } - return ms, nil -} - -// propVirtual is a proprietary virtual network interface. -type propVirtual struct { - name string - addr, mask string - setupCmds []*exec.Cmd - teardownCmds []*exec.Cmd -} - -func (pv *propVirtual) setup() error { - for _, cmd := range pv.setupCmds { - if err := cmd.Run(); err != nil { - pv.teardown() - return err - } - } - return nil -} - -func (pv *propVirtual) teardown() error { - for _, cmd := range pv.teardownCmds { - if err := cmd.Run(); err != nil { - return err - } - } - return nil -} - -func (pv *propVirtual) configure(suffix int) error { - if runtime.GOOS == "openbsd" { - pv.name = fmt.Sprintf("vether%d", suffix) - } else { - pv.name = fmt.Sprintf("vlan%d", suffix) - } - xname, err := exec.LookPath("ifconfig") - if err != nil { - return err - } - pv.setupCmds = append(pv.setupCmds, &exec.Cmd{ - Path: xname, - Args: []string{"ifconfig", pv.name, "create"}, - }) - if runtime.GOOS == "netbsd" { - // NetBSD requires an underlying dot1Q-capable network - // interface. - pv.setupCmds = append(pv.setupCmds, &exec.Cmd{ - Path: xname, - Args: []string{"ifconfig", pv.name, "vlan", fmt.Sprintf("%d", suffix&0xfff), "vlanif", "wm0"}, - }) - } - pv.setupCmds = append(pv.setupCmds, &exec.Cmd{ - Path: xname, - Args: []string{"ifconfig", pv.name, "inet", pv.addr, "netmask", pv.mask}, - }) - pv.teardownCmds = append(pv.teardownCmds, &exec.Cmd{ - Path: xname, - Args: []string{"ifconfig", pv.name, "destroy"}, - }) - return nil -} diff --git a/vendor/golang.org/x/net/route/sys.go b/vendor/golang.org/x/net/route/sys.go deleted file mode 100644 index 3d0ee9b14..000000000 --- a/vendor/golang.org/x/net/route/sys.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package route - -import "unsafe" - -var ( - nativeEndian binaryByteOrder - kernelAlign int - wireFormats map[int]*wireFormat -) - -func init() { - i := uint32(1) - b := (*[4]byte)(unsafe.Pointer(&i)) - if b[0] == 1 { - nativeEndian = littleEndian - } else { - nativeEndian = bigEndian - } - kernelAlign, wireFormats = probeRoutingStack() -} - -func roundup(l int) int { - if l == 0 { - return kernelAlign - } - return (l + kernelAlign - 1) & ^(kernelAlign - 1) -} - -type wireFormat struct { - extOff int // offset of header extension - bodyOff int // offset of message body - parse func(RIBType, []byte) (Message, error) -} diff --git a/vendor/golang.org/x/net/route/sys_darwin.go b/vendor/golang.org/x/net/route/sys_darwin.go deleted file mode 100644 index e742c919d..000000000 --- a/vendor/golang.org/x/net/route/sys_darwin.go +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -func (typ RIBType) parseable() bool { - switch typ { - case sysNET_RT_STAT, sysNET_RT_TRASH: - return false - default: - return true - } -} - -// A RouteMetrics represents route metrics. -type RouteMetrics struct { - PathMTU int // path maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (rmx *RouteMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *RouteMessage) Sys() []Sys { - return []Sys{ - &RouteMetrics{ - PathMTU: int(nativeEndian.Uint32(m.raw[m.extOff+4 : m.extOff+8])), - }, - } -} - -// A InterfaceMetrics represents interface metrics. -type InterfaceMetrics struct { - Type int // interface type - MTU int // maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *InterfaceMessage) Sys() []Sys { - return []Sys{ - &InterfaceMetrics{ - Type: int(m.raw[m.extOff]), - MTU: int(nativeEndian.Uint32(m.raw[m.extOff+8 : m.extOff+12])), - }, - } -} - -func probeRoutingStack() (int, map[int]*wireFormat) { - rtm := &wireFormat{extOff: 36, bodyOff: sizeofRtMsghdrDarwin15} - rtm.parse = rtm.parseRouteMessage - rtm2 := &wireFormat{extOff: 36, bodyOff: sizeofRtMsghdr2Darwin15} - rtm2.parse = rtm2.parseRouteMessage - ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrDarwin15} - ifm.parse = ifm.parseInterfaceMessage - ifm2 := &wireFormat{extOff: 32, bodyOff: sizeofIfMsghdr2Darwin15} - ifm2.parse = ifm2.parseInterfaceMessage - ifam := &wireFormat{extOff: sizeofIfaMsghdrDarwin15, bodyOff: sizeofIfaMsghdrDarwin15} - ifam.parse = ifam.parseInterfaceAddrMessage - ifmam := &wireFormat{extOff: sizeofIfmaMsghdrDarwin15, bodyOff: sizeofIfmaMsghdrDarwin15} - ifmam.parse = ifmam.parseInterfaceMulticastAddrMessage - ifmam2 := &wireFormat{extOff: sizeofIfmaMsghdr2Darwin15, bodyOff: sizeofIfmaMsghdr2Darwin15} - ifmam2.parse = ifmam2.parseInterfaceMulticastAddrMessage - // Darwin kernels require 32-bit aligned access to routing facilities. - return 4, map[int]*wireFormat{ - sysRTM_ADD: rtm, - sysRTM_DELETE: rtm, - sysRTM_CHANGE: rtm, - sysRTM_GET: rtm, - sysRTM_LOSING: rtm, - sysRTM_REDIRECT: rtm, - sysRTM_MISS: rtm, - sysRTM_LOCK: rtm, - sysRTM_RESOLVE: rtm, - sysRTM_NEWADDR: ifam, - sysRTM_DELADDR: ifam, - sysRTM_IFINFO: ifm, - sysRTM_NEWMADDR: ifmam, - sysRTM_DELMADDR: ifmam, - sysRTM_IFINFO2: ifm2, - sysRTM_NEWMADDR2: ifmam2, - sysRTM_GET2: rtm2, - } -} diff --git a/vendor/golang.org/x/net/route/sys_dragonfly.go b/vendor/golang.org/x/net/route/sys_dragonfly.go deleted file mode 100644 index b175cb18c..000000000 --- a/vendor/golang.org/x/net/route/sys_dragonfly.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -import "unsafe" - -func (typ RIBType) parseable() bool { return true } - -// A RouteMetrics represents route metrics. -type RouteMetrics struct { - PathMTU int // path maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (rmx *RouteMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *RouteMessage) Sys() []Sys { - return []Sys{ - &RouteMetrics{ - PathMTU: int(nativeEndian.Uint64(m.raw[m.extOff+8 : m.extOff+16])), - }, - } -} - -// A InterfaceMetrics represents interface metrics. -type InterfaceMetrics struct { - Type int // interface type - MTU int // maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *InterfaceMessage) Sys() []Sys { - return []Sys{ - &InterfaceMetrics{ - Type: int(m.raw[m.extOff]), - MTU: int(nativeEndian.Uint32(m.raw[m.extOff+8 : m.extOff+12])), - }, - } -} - -func probeRoutingStack() (int, map[int]*wireFormat) { - var p uintptr - rtm := &wireFormat{extOff: 40, bodyOff: sizeofRtMsghdrDragonFlyBSD4} - rtm.parse = rtm.parseRouteMessage - ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrDragonFlyBSD4} - ifm.parse = ifm.parseInterfaceMessage - ifam := &wireFormat{extOff: sizeofIfaMsghdrDragonFlyBSD4, bodyOff: sizeofIfaMsghdrDragonFlyBSD4} - ifam.parse = ifam.parseInterfaceAddrMessage - ifmam := &wireFormat{extOff: sizeofIfmaMsghdrDragonFlyBSD4, bodyOff: sizeofIfmaMsghdrDragonFlyBSD4} - ifmam.parse = ifmam.parseInterfaceMulticastAddrMessage - ifanm := &wireFormat{extOff: sizeofIfAnnouncemsghdrDragonFlyBSD4, bodyOff: sizeofIfAnnouncemsghdrDragonFlyBSD4} - ifanm.parse = ifanm.parseInterfaceAnnounceMessage - return int(unsafe.Sizeof(p)), map[int]*wireFormat{ - sysRTM_ADD: rtm, - sysRTM_DELETE: rtm, - sysRTM_CHANGE: rtm, - sysRTM_GET: rtm, - sysRTM_LOSING: rtm, - sysRTM_REDIRECT: rtm, - sysRTM_MISS: rtm, - sysRTM_LOCK: rtm, - sysRTM_RESOLVE: rtm, - sysRTM_NEWADDR: ifam, - sysRTM_DELADDR: ifam, - sysRTM_IFINFO: ifm, - sysRTM_NEWMADDR: ifmam, - sysRTM_DELMADDR: ifmam, - sysRTM_IFANNOUNCE: ifanm, - } -} diff --git a/vendor/golang.org/x/net/route/sys_freebsd.go b/vendor/golang.org/x/net/route/sys_freebsd.go deleted file mode 100644 index 010d4ae78..000000000 --- a/vendor/golang.org/x/net/route/sys_freebsd.go +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -import ( - "syscall" - "unsafe" -) - -func (typ RIBType) parseable() bool { return true } - -// A RouteMetrics represents route metrics. -type RouteMetrics struct { - PathMTU int // path maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (rmx *RouteMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *RouteMessage) Sys() []Sys { - if kernelAlign == 8 { - return []Sys{ - &RouteMetrics{ - PathMTU: int(nativeEndian.Uint64(m.raw[m.extOff+8 : m.extOff+16])), - }, - } - } - return []Sys{ - &RouteMetrics{ - PathMTU: int(nativeEndian.Uint32(m.raw[m.extOff+4 : m.extOff+8])), - }, - } -} - -// A InterfaceMetrics represents interface metrics. -type InterfaceMetrics struct { - Type int // interface type - MTU int // maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *InterfaceMessage) Sys() []Sys { - return []Sys{ - &InterfaceMetrics{ - Type: int(m.raw[m.extOff]), - MTU: int(nativeEndian.Uint32(m.raw[m.extOff+8 : m.extOff+12])), - }, - } -} - -func probeRoutingStack() (int, map[int]*wireFormat) { - var p uintptr - wordSize := int(unsafe.Sizeof(p)) - align := int(unsafe.Sizeof(p)) - // In the case of kern.supported_archs="amd64 i386", we need - // to know the underlying kernel's architecture because the - // alignment for routing facilities are set at the build time - // of the kernel. - conf, _ := syscall.Sysctl("kern.conftxt") - for i, j := 0, 0; j < len(conf); j++ { - if conf[j] != '\n' { - continue - } - s := conf[i:j] - i = j + 1 - if len(s) > len("machine") && s[:len("machine")] == "machine" { - s = s[len("machine"):] - for k := 0; k < len(s); k++ { - if s[k] == ' ' || s[k] == '\t' { - s = s[1:] - } - break - } - if s == "amd64" { - align = 8 - } - break - } - } - var rtm, ifm, ifam, ifmam, ifanm *wireFormat - if align != wordSize { // 386 emulation on amd64 - rtm = &wireFormat{extOff: sizeofRtMsghdrFreeBSD10Emu - sizeofRtMetricsFreeBSD10Emu, bodyOff: sizeofRtMsghdrFreeBSD10Emu} - ifm = &wireFormat{extOff: 16} - ifam = &wireFormat{extOff: sizeofIfaMsghdrFreeBSD10Emu, bodyOff: sizeofIfaMsghdrFreeBSD10Emu} - ifmam = &wireFormat{extOff: sizeofIfmaMsghdrFreeBSD10Emu, bodyOff: sizeofIfmaMsghdrFreeBSD10Emu} - ifanm = &wireFormat{extOff: sizeofIfAnnouncemsghdrFreeBSD10Emu, bodyOff: sizeofIfAnnouncemsghdrFreeBSD10Emu} - } else { - rtm = &wireFormat{extOff: sizeofRtMsghdrFreeBSD10 - sizeofRtMetricsFreeBSD10, bodyOff: sizeofRtMsghdrFreeBSD10} - ifm = &wireFormat{extOff: 16} - ifam = &wireFormat{extOff: sizeofIfaMsghdrFreeBSD10, bodyOff: sizeofIfaMsghdrFreeBSD10} - ifmam = &wireFormat{extOff: sizeofIfmaMsghdrFreeBSD10, bodyOff: sizeofIfmaMsghdrFreeBSD10} - ifanm = &wireFormat{extOff: sizeofIfAnnouncemsghdrFreeBSD10, bodyOff: sizeofIfAnnouncemsghdrFreeBSD10} - } - rel, _ := syscall.SysctlUint32("kern.osreldate") - switch { - case rel < 800000: - if align != wordSize { // 386 emulation on amd64 - ifm.bodyOff = sizeofIfMsghdrFreeBSD7Emu - } else { - ifm.bodyOff = sizeofIfMsghdrFreeBSD7 - } - case 800000 <= rel && rel < 900000: - if align != wordSize { // 386 emulation on amd64 - ifm.bodyOff = sizeofIfMsghdrFreeBSD8Emu - } else { - ifm.bodyOff = sizeofIfMsghdrFreeBSD8 - } - case 900000 <= rel && rel < 1000000: - if align != wordSize { // 386 emulation on amd64 - ifm.bodyOff = sizeofIfMsghdrFreeBSD9Emu - } else { - ifm.bodyOff = sizeofIfMsghdrFreeBSD9 - } - case 1000000 <= rel && rel < 1100000: - if align != wordSize { // 386 emulation on amd64 - ifm.bodyOff = sizeofIfMsghdrFreeBSD10Emu - } else { - ifm.bodyOff = sizeofIfMsghdrFreeBSD10 - } - default: - if align != wordSize { // 386 emulation on amd64 - ifm.bodyOff = sizeofIfMsghdrFreeBSD11Emu - } else { - ifm.bodyOff = sizeofIfMsghdrFreeBSD11 - } - } - rtm.parse = rtm.parseRouteMessage - ifm.parse = ifm.parseInterfaceMessage - ifam.parse = ifam.parseInterfaceAddrMessage - ifmam.parse = ifmam.parseInterfaceMulticastAddrMessage - ifanm.parse = ifanm.parseInterfaceAnnounceMessage - return align, map[int]*wireFormat{ - sysRTM_ADD: rtm, - sysRTM_DELETE: rtm, - sysRTM_CHANGE: rtm, - sysRTM_GET: rtm, - sysRTM_LOSING: rtm, - sysRTM_REDIRECT: rtm, - sysRTM_MISS: rtm, - sysRTM_LOCK: rtm, - sysRTM_RESOLVE: rtm, - sysRTM_NEWADDR: ifam, - sysRTM_DELADDR: ifam, - sysRTM_IFINFO: ifm, - sysRTM_NEWMADDR: ifmam, - sysRTM_DELMADDR: ifmam, - sysRTM_IFANNOUNCE: ifanm, - } -} diff --git a/vendor/golang.org/x/net/route/sys_netbsd.go b/vendor/golang.org/x/net/route/sys_netbsd.go deleted file mode 100644 index b4e330140..000000000 --- a/vendor/golang.org/x/net/route/sys_netbsd.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -func (typ RIBType) parseable() bool { return true } - -// A RouteMetrics represents route metrics. -type RouteMetrics struct { - PathMTU int // path maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (rmx *RouteMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *RouteMessage) Sys() []Sys { - return []Sys{ - &RouteMetrics{ - PathMTU: int(nativeEndian.Uint64(m.raw[m.extOff+8 : m.extOff+16])), - }, - } -} - -// A InterfaceMetrics represents interface metrics. -type InterfaceMetrics struct { - Type int // interface type - MTU int // maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *InterfaceMessage) Sys() []Sys { - return []Sys{ - &InterfaceMetrics{ - Type: int(m.raw[m.extOff]), - MTU: int(nativeEndian.Uint32(m.raw[m.extOff+8 : m.extOff+12])), - }, - } -} - -func probeRoutingStack() (int, map[int]*wireFormat) { - rtm := &wireFormat{extOff: 40, bodyOff: sizeofRtMsghdrNetBSD7} - rtm.parse = rtm.parseRouteMessage - ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrNetBSD7} - ifm.parse = ifm.parseInterfaceMessage - ifam := &wireFormat{extOff: sizeofIfaMsghdrNetBSD7, bodyOff: sizeofIfaMsghdrNetBSD7} - ifam.parse = ifam.parseInterfaceAddrMessage - ifanm := &wireFormat{extOff: sizeofIfAnnouncemsghdrNetBSD7, bodyOff: sizeofIfAnnouncemsghdrNetBSD7} - ifanm.parse = ifanm.parseInterfaceAnnounceMessage - // NetBSD 6 and above kernels require 64-bit aligned access to - // routing facilities. - return 8, map[int]*wireFormat{ - sysRTM_ADD: rtm, - sysRTM_DELETE: rtm, - sysRTM_CHANGE: rtm, - sysRTM_GET: rtm, - sysRTM_LOSING: rtm, - sysRTM_REDIRECT: rtm, - sysRTM_MISS: rtm, - sysRTM_LOCK: rtm, - sysRTM_RESOLVE: rtm, - sysRTM_NEWADDR: ifam, - sysRTM_DELADDR: ifam, - sysRTM_IFANNOUNCE: ifanm, - sysRTM_IFINFO: ifm, - } -} diff --git a/vendor/golang.org/x/net/route/sys_openbsd.go b/vendor/golang.org/x/net/route/sys_openbsd.go deleted file mode 100644 index 8798dc4ca..000000000 --- a/vendor/golang.org/x/net/route/sys_openbsd.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -import "unsafe" - -func (typ RIBType) parseable() bool { - switch typ { - case sysNET_RT_STATS, sysNET_RT_TABLE: - return false - default: - return true - } -} - -// A RouteMetrics represents route metrics. -type RouteMetrics struct { - PathMTU int // path maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (rmx *RouteMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *RouteMessage) Sys() []Sys { - return []Sys{ - &RouteMetrics{ - PathMTU: int(nativeEndian.Uint32(m.raw[60:64])), - }, - } -} - -// A InterfaceMetrics represents interface metrics. -type InterfaceMetrics struct { - Type int // interface type - MTU int // maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *InterfaceMessage) Sys() []Sys { - return []Sys{ - &InterfaceMetrics{ - Type: int(m.raw[24]), - MTU: int(nativeEndian.Uint32(m.raw[28:32])), - }, - } -} - -func probeRoutingStack() (int, map[int]*wireFormat) { - var p uintptr - rtm := &wireFormat{extOff: -1, bodyOff: -1} - rtm.parse = rtm.parseRouteMessage - ifm := &wireFormat{extOff: -1, bodyOff: -1} - ifm.parse = ifm.parseInterfaceMessage - ifam := &wireFormat{extOff: -1, bodyOff: -1} - ifam.parse = ifam.parseInterfaceAddrMessage - ifanm := &wireFormat{extOff: -1, bodyOff: -1} - ifanm.parse = ifanm.parseInterfaceAnnounceMessage - return int(unsafe.Sizeof(p)), map[int]*wireFormat{ - sysRTM_ADD: rtm, - sysRTM_DELETE: rtm, - sysRTM_CHANGE: rtm, - sysRTM_GET: rtm, - sysRTM_LOSING: rtm, - sysRTM_REDIRECT: rtm, - sysRTM_MISS: rtm, - sysRTM_LOCK: rtm, - sysRTM_RESOLVE: rtm, - sysRTM_NEWADDR: ifam, - sysRTM_DELADDR: ifam, - sysRTM_IFINFO: ifm, - sysRTM_IFANNOUNCE: ifanm, - } -} diff --git a/vendor/golang.org/x/net/route/syscall.go b/vendor/golang.org/x/net/route/syscall.go deleted file mode 100644 index c211188b1..000000000 --- a/vendor/golang.org/x/net/route/syscall.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package route - -import ( - "syscall" - "unsafe" -) - -var zero uintptr - -func sysctl(mib []int32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error { - var p unsafe.Pointer - if len(mib) > 0 { - p = unsafe.Pointer(&mib[0]) - } else { - p = unsafe.Pointer(&zero) - } - _, _, errno := syscall.Syscall6(syscall.SYS___SYSCTL, uintptr(p), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) - if errno != 0 { - return error(errno) - } - return nil -} diff --git a/vendor/golang.org/x/net/route/zsys_darwin.go b/vendor/golang.org/x/net/route/zsys_darwin.go deleted file mode 100644 index 4e2e1ab09..000000000 --- a/vendor/golang.org/x/net/route/zsys_darwin.go +++ /dev/null @@ -1,99 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_darwin.go - -package route - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_ROUTE = 0x11 - sysAF_LINK = 0x12 - sysAF_INET6 = 0x1e - - sysSOCK_RAW = 0x3 - - sysNET_RT_DUMP = 0x1 - sysNET_RT_FLAGS = 0x2 - sysNET_RT_IFLIST = 0x3 - sysNET_RT_STAT = 0x4 - sysNET_RT_TRASH = 0x5 - sysNET_RT_IFLIST2 = 0x6 - sysNET_RT_DUMP2 = 0x7 - sysNET_RT_MAXID = 0xa -) - -const ( - sysCTL_MAXNAME = 0xc - - sysCTL_UNSPEC = 0x0 - sysCTL_KERN = 0x1 - sysCTL_VM = 0x2 - sysCTL_VFS = 0x3 - sysCTL_NET = 0x4 - sysCTL_DEBUG = 0x5 - sysCTL_HW = 0x6 - sysCTL_MACHDEP = 0x7 - sysCTL_USER = 0x8 - sysCTL_MAXID = 0x9 -) - -const ( - sysRTM_VERSION = 0x5 - - sysRTM_ADD = 0x1 - sysRTM_DELETE = 0x2 - sysRTM_CHANGE = 0x3 - sysRTM_GET = 0x4 - sysRTM_LOSING = 0x5 - sysRTM_REDIRECT = 0x6 - sysRTM_MISS = 0x7 - sysRTM_LOCK = 0x8 - sysRTM_OLDADD = 0x9 - sysRTM_OLDDEL = 0xa - sysRTM_RESOLVE = 0xb - sysRTM_NEWADDR = 0xc - sysRTM_DELADDR = 0xd - sysRTM_IFINFO = 0xe - sysRTM_NEWMADDR = 0xf - sysRTM_DELMADDR = 0x10 - sysRTM_IFINFO2 = 0x12 - sysRTM_NEWMADDR2 = 0x13 - sysRTM_GET2 = 0x14 - - sysRTA_DST = 0x1 - sysRTA_GATEWAY = 0x2 - sysRTA_NETMASK = 0x4 - sysRTA_GENMASK = 0x8 - sysRTA_IFP = 0x10 - sysRTA_IFA = 0x20 - sysRTA_AUTHOR = 0x40 - sysRTA_BRD = 0x80 - - sysRTAX_DST = 0x0 - sysRTAX_GATEWAY = 0x1 - sysRTAX_NETMASK = 0x2 - sysRTAX_GENMASK = 0x3 - sysRTAX_IFP = 0x4 - sysRTAX_IFA = 0x5 - sysRTAX_AUTHOR = 0x6 - sysRTAX_BRD = 0x7 - sysRTAX_MAX = 0x8 -) - -const ( - sizeofIfMsghdrDarwin15 = 0x70 - sizeofIfaMsghdrDarwin15 = 0x14 - sizeofIfmaMsghdrDarwin15 = 0x10 - sizeofIfMsghdr2Darwin15 = 0xa0 - sizeofIfmaMsghdr2Darwin15 = 0x14 - sizeofIfDataDarwin15 = 0x60 - sizeofIfData64Darwin15 = 0x80 - - sizeofRtMsghdrDarwin15 = 0x5c - sizeofRtMsghdr2Darwin15 = 0x5c - sizeofRtMetricsDarwin15 = 0x38 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/route/zsys_dragonfly.go b/vendor/golang.org/x/net/route/zsys_dragonfly.go deleted file mode 100644 index 719c88d11..000000000 --- a/vendor/golang.org/x/net/route/zsys_dragonfly.go +++ /dev/null @@ -1,98 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_dragonfly.go - -package route - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_ROUTE = 0x11 - sysAF_LINK = 0x12 - sysAF_INET6 = 0x1c - - sysSOCK_RAW = 0x3 - - sysNET_RT_DUMP = 0x1 - sysNET_RT_FLAGS = 0x2 - sysNET_RT_IFLIST = 0x3 - sysNET_RT_MAXID = 0x4 -) - -const ( - sysCTL_MAXNAME = 0xc - - sysCTL_UNSPEC = 0x0 - sysCTL_KERN = 0x1 - sysCTL_VM = 0x2 - sysCTL_VFS = 0x3 - sysCTL_NET = 0x4 - sysCTL_DEBUG = 0x5 - sysCTL_HW = 0x6 - sysCTL_MACHDEP = 0x7 - sysCTL_USER = 0x8 - sysCTL_P1003_1B = 0x9 - sysCTL_LWKT = 0xa - sysCTL_MAXID = 0xb -) - -const ( - sysRTM_VERSION = 0x6 - - sysRTM_ADD = 0x1 - sysRTM_DELETE = 0x2 - sysRTM_CHANGE = 0x3 - sysRTM_GET = 0x4 - sysRTM_LOSING = 0x5 - sysRTM_REDIRECT = 0x6 - sysRTM_MISS = 0x7 - sysRTM_LOCK = 0x8 - sysRTM_OLDADD = 0x9 - sysRTM_OLDDEL = 0xa - sysRTM_RESOLVE = 0xb - sysRTM_NEWADDR = 0xc - sysRTM_DELADDR = 0xd - sysRTM_IFINFO = 0xe - sysRTM_NEWMADDR = 0xf - sysRTM_DELMADDR = 0x10 - sysRTM_IFANNOUNCE = 0x11 - sysRTM_IEEE80211 = 0x12 - - sysRTA_DST = 0x1 - sysRTA_GATEWAY = 0x2 - sysRTA_NETMASK = 0x4 - sysRTA_GENMASK = 0x8 - sysRTA_IFP = 0x10 - sysRTA_IFA = 0x20 - sysRTA_AUTHOR = 0x40 - sysRTA_BRD = 0x80 - sysRTA_MPLS1 = 0x100 - sysRTA_MPLS2 = 0x200 - sysRTA_MPLS3 = 0x400 - - sysRTAX_DST = 0x0 - sysRTAX_GATEWAY = 0x1 - sysRTAX_NETMASK = 0x2 - sysRTAX_GENMASK = 0x3 - sysRTAX_IFP = 0x4 - sysRTAX_IFA = 0x5 - sysRTAX_AUTHOR = 0x6 - sysRTAX_BRD = 0x7 - sysRTAX_MPLS1 = 0x8 - sysRTAX_MPLS2 = 0x9 - sysRTAX_MPLS3 = 0xa - sysRTAX_MAX = 0xb -) - -const ( - sizeofIfMsghdrDragonFlyBSD4 = 0xb0 - sizeofIfaMsghdrDragonFlyBSD4 = 0x14 - sizeofIfmaMsghdrDragonFlyBSD4 = 0x10 - sizeofIfAnnouncemsghdrDragonFlyBSD4 = 0x18 - - sizeofRtMsghdrDragonFlyBSD4 = 0x98 - sizeofRtMetricsDragonFlyBSD4 = 0x70 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/route/zsys_freebsd_386.go b/vendor/golang.org/x/net/route/zsys_freebsd_386.go deleted file mode 100644 index b03bc01f6..000000000 --- a/vendor/golang.org/x/net/route/zsys_freebsd_386.go +++ /dev/null @@ -1,126 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package route - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_ROUTE = 0x11 - sysAF_LINK = 0x12 - sysAF_INET6 = 0x1c - - sysSOCK_RAW = 0x3 - - sysNET_RT_DUMP = 0x1 - sysNET_RT_FLAGS = 0x2 - sysNET_RT_IFLIST = 0x3 - sysNET_RT_IFMALIST = 0x4 - sysNET_RT_IFLISTL = 0x5 -) - -const ( - sysCTL_MAXNAME = 0x18 - - sysCTL_UNSPEC = 0x0 - sysCTL_KERN = 0x1 - sysCTL_VM = 0x2 - sysCTL_VFS = 0x3 - sysCTL_NET = 0x4 - sysCTL_DEBUG = 0x5 - sysCTL_HW = 0x6 - sysCTL_MACHDEP = 0x7 - sysCTL_USER = 0x8 - sysCTL_P1003_1B = 0x9 -) - -const ( - sysRTM_VERSION = 0x5 - - sysRTM_ADD = 0x1 - sysRTM_DELETE = 0x2 - sysRTM_CHANGE = 0x3 - sysRTM_GET = 0x4 - sysRTM_LOSING = 0x5 - sysRTM_REDIRECT = 0x6 - sysRTM_MISS = 0x7 - sysRTM_LOCK = 0x8 - sysRTM_RESOLVE = 0xb - sysRTM_NEWADDR = 0xc - sysRTM_DELADDR = 0xd - sysRTM_IFINFO = 0xe - sysRTM_NEWMADDR = 0xf - sysRTM_DELMADDR = 0x10 - sysRTM_IFANNOUNCE = 0x11 - sysRTM_IEEE80211 = 0x12 - - sysRTA_DST = 0x1 - sysRTA_GATEWAY = 0x2 - sysRTA_NETMASK = 0x4 - sysRTA_GENMASK = 0x8 - sysRTA_IFP = 0x10 - sysRTA_IFA = 0x20 - sysRTA_AUTHOR = 0x40 - sysRTA_BRD = 0x80 - - sysRTAX_DST = 0x0 - sysRTAX_GATEWAY = 0x1 - sysRTAX_NETMASK = 0x2 - sysRTAX_GENMASK = 0x3 - sysRTAX_IFP = 0x4 - sysRTAX_IFA = 0x5 - sysRTAX_AUTHOR = 0x6 - sysRTAX_BRD = 0x7 - sysRTAX_MAX = 0x8 -) - -const ( - sizeofIfMsghdrlFreeBSD10 = 0x68 - sizeofIfaMsghdrFreeBSD10 = 0x14 - sizeofIfaMsghdrlFreeBSD10 = 0x6c - sizeofIfmaMsghdrFreeBSD10 = 0x10 - sizeofIfAnnouncemsghdrFreeBSD10 = 0x18 - - sizeofRtMsghdrFreeBSD10 = 0x5c - sizeofRtMetricsFreeBSD10 = 0x38 - - sizeofIfMsghdrFreeBSD7 = 0x60 - sizeofIfMsghdrFreeBSD8 = 0x60 - sizeofIfMsghdrFreeBSD9 = 0x60 - sizeofIfMsghdrFreeBSD10 = 0x64 - sizeofIfMsghdrFreeBSD11 = 0xa8 - - sizeofIfDataFreeBSD7 = 0x50 - sizeofIfDataFreeBSD8 = 0x50 - sizeofIfDataFreeBSD9 = 0x50 - sizeofIfDataFreeBSD10 = 0x54 - sizeofIfDataFreeBSD11 = 0x98 - - // MODIFIED BY HAND FOR 386 EMULATION ON AMD64 - // 386 EMULATION USES THE UNDERLYING RAW DATA LAYOUT - - sizeofIfMsghdrlFreeBSD10Emu = 0xb0 - sizeofIfaMsghdrFreeBSD10Emu = 0x14 - sizeofIfaMsghdrlFreeBSD10Emu = 0xb0 - sizeofIfmaMsghdrFreeBSD10Emu = 0x10 - sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18 - - sizeofRtMsghdrFreeBSD10Emu = 0x98 - sizeofRtMetricsFreeBSD10Emu = 0x70 - - sizeofIfMsghdrFreeBSD7Emu = 0xa8 - sizeofIfMsghdrFreeBSD8Emu = 0xa8 - sizeofIfMsghdrFreeBSD9Emu = 0xa8 - sizeofIfMsghdrFreeBSD10Emu = 0xa8 - sizeofIfMsghdrFreeBSD11Emu = 0xa8 - - sizeofIfDataFreeBSD7Emu = 0x98 - sizeofIfDataFreeBSD8Emu = 0x98 - sizeofIfDataFreeBSD9Emu = 0x98 - sizeofIfDataFreeBSD10Emu = 0x98 - sizeofIfDataFreeBSD11Emu = 0x98 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/route/zsys_freebsd_amd64.go b/vendor/golang.org/x/net/route/zsys_freebsd_amd64.go deleted file mode 100644 index 0b675b3d3..000000000 --- a/vendor/golang.org/x/net/route/zsys_freebsd_amd64.go +++ /dev/null @@ -1,123 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package route - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_ROUTE = 0x11 - sysAF_LINK = 0x12 - sysAF_INET6 = 0x1c - - sysSOCK_RAW = 0x3 - - sysNET_RT_DUMP = 0x1 - sysNET_RT_FLAGS = 0x2 - sysNET_RT_IFLIST = 0x3 - sysNET_RT_IFMALIST = 0x4 - sysNET_RT_IFLISTL = 0x5 -) - -const ( - sysCTL_MAXNAME = 0x18 - - sysCTL_UNSPEC = 0x0 - sysCTL_KERN = 0x1 - sysCTL_VM = 0x2 - sysCTL_VFS = 0x3 - sysCTL_NET = 0x4 - sysCTL_DEBUG = 0x5 - sysCTL_HW = 0x6 - sysCTL_MACHDEP = 0x7 - sysCTL_USER = 0x8 - sysCTL_P1003_1B = 0x9 -) - -const ( - sysRTM_VERSION = 0x5 - - sysRTM_ADD = 0x1 - sysRTM_DELETE = 0x2 - sysRTM_CHANGE = 0x3 - sysRTM_GET = 0x4 - sysRTM_LOSING = 0x5 - sysRTM_REDIRECT = 0x6 - sysRTM_MISS = 0x7 - sysRTM_LOCK = 0x8 - sysRTM_RESOLVE = 0xb - sysRTM_NEWADDR = 0xc - sysRTM_DELADDR = 0xd - sysRTM_IFINFO = 0xe - sysRTM_NEWMADDR = 0xf - sysRTM_DELMADDR = 0x10 - sysRTM_IFANNOUNCE = 0x11 - sysRTM_IEEE80211 = 0x12 - - sysRTA_DST = 0x1 - sysRTA_GATEWAY = 0x2 - sysRTA_NETMASK = 0x4 - sysRTA_GENMASK = 0x8 - sysRTA_IFP = 0x10 - sysRTA_IFA = 0x20 - sysRTA_AUTHOR = 0x40 - sysRTA_BRD = 0x80 - - sysRTAX_DST = 0x0 - sysRTAX_GATEWAY = 0x1 - sysRTAX_NETMASK = 0x2 - sysRTAX_GENMASK = 0x3 - sysRTAX_IFP = 0x4 - sysRTAX_IFA = 0x5 - sysRTAX_AUTHOR = 0x6 - sysRTAX_BRD = 0x7 - sysRTAX_MAX = 0x8 -) - -const ( - sizeofIfMsghdrlFreeBSD10 = 0xb0 - sizeofIfaMsghdrFreeBSD10 = 0x14 - sizeofIfaMsghdrlFreeBSD10 = 0xb0 - sizeofIfmaMsghdrFreeBSD10 = 0x10 - sizeofIfAnnouncemsghdrFreeBSD10 = 0x18 - - sizeofRtMsghdrFreeBSD10 = 0x98 - sizeofRtMetricsFreeBSD10 = 0x70 - - sizeofIfMsghdrFreeBSD7 = 0xa8 - sizeofIfMsghdrFreeBSD8 = 0xa8 - sizeofIfMsghdrFreeBSD9 = 0xa8 - sizeofIfMsghdrFreeBSD10 = 0xa8 - sizeofIfMsghdrFreeBSD11 = 0xa8 - - sizeofIfDataFreeBSD7 = 0x98 - sizeofIfDataFreeBSD8 = 0x98 - sizeofIfDataFreeBSD9 = 0x98 - sizeofIfDataFreeBSD10 = 0x98 - sizeofIfDataFreeBSD11 = 0x98 - - sizeofIfMsghdrlFreeBSD10Emu = 0xb0 - sizeofIfaMsghdrFreeBSD10Emu = 0x14 - sizeofIfaMsghdrlFreeBSD10Emu = 0xb0 - sizeofIfmaMsghdrFreeBSD10Emu = 0x10 - sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18 - - sizeofRtMsghdrFreeBSD10Emu = 0x98 - sizeofRtMetricsFreeBSD10Emu = 0x70 - - sizeofIfMsghdrFreeBSD7Emu = 0xa8 - sizeofIfMsghdrFreeBSD8Emu = 0xa8 - sizeofIfMsghdrFreeBSD9Emu = 0xa8 - sizeofIfMsghdrFreeBSD10Emu = 0xa8 - sizeofIfMsghdrFreeBSD11Emu = 0xa8 - - sizeofIfDataFreeBSD7Emu = 0x98 - sizeofIfDataFreeBSD8Emu = 0x98 - sizeofIfDataFreeBSD9Emu = 0x98 - sizeofIfDataFreeBSD10Emu = 0x98 - sizeofIfDataFreeBSD11Emu = 0x98 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/route/zsys_freebsd_arm.go b/vendor/golang.org/x/net/route/zsys_freebsd_arm.go deleted file mode 100644 index 58f8ea16f..000000000 --- a/vendor/golang.org/x/net/route/zsys_freebsd_arm.go +++ /dev/null @@ -1,123 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package route - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_ROUTE = 0x11 - sysAF_LINK = 0x12 - sysAF_INET6 = 0x1c - - sysSOCK_RAW = 0x3 - - sysNET_RT_DUMP = 0x1 - sysNET_RT_FLAGS = 0x2 - sysNET_RT_IFLIST = 0x3 - sysNET_RT_IFMALIST = 0x4 - sysNET_RT_IFLISTL = 0x5 -) - -const ( - sysCTL_MAXNAME = 0x18 - - sysCTL_UNSPEC = 0x0 - sysCTL_KERN = 0x1 - sysCTL_VM = 0x2 - sysCTL_VFS = 0x3 - sysCTL_NET = 0x4 - sysCTL_DEBUG = 0x5 - sysCTL_HW = 0x6 - sysCTL_MACHDEP = 0x7 - sysCTL_USER = 0x8 - sysCTL_P1003_1B = 0x9 -) - -const ( - sysRTM_VERSION = 0x5 - - sysRTM_ADD = 0x1 - sysRTM_DELETE = 0x2 - sysRTM_CHANGE = 0x3 - sysRTM_GET = 0x4 - sysRTM_LOSING = 0x5 - sysRTM_REDIRECT = 0x6 - sysRTM_MISS = 0x7 - sysRTM_LOCK = 0x8 - sysRTM_RESOLVE = 0xb - sysRTM_NEWADDR = 0xc - sysRTM_DELADDR = 0xd - sysRTM_IFINFO = 0xe - sysRTM_NEWMADDR = 0xf - sysRTM_DELMADDR = 0x10 - sysRTM_IFANNOUNCE = 0x11 - sysRTM_IEEE80211 = 0x12 - - sysRTA_DST = 0x1 - sysRTA_GATEWAY = 0x2 - sysRTA_NETMASK = 0x4 - sysRTA_GENMASK = 0x8 - sysRTA_IFP = 0x10 - sysRTA_IFA = 0x20 - sysRTA_AUTHOR = 0x40 - sysRTA_BRD = 0x80 - - sysRTAX_DST = 0x0 - sysRTAX_GATEWAY = 0x1 - sysRTAX_NETMASK = 0x2 - sysRTAX_GENMASK = 0x3 - sysRTAX_IFP = 0x4 - sysRTAX_IFA = 0x5 - sysRTAX_AUTHOR = 0x6 - sysRTAX_BRD = 0x7 - sysRTAX_MAX = 0x8 -) - -const ( - sizeofIfMsghdrlFreeBSD10 = 0x68 - sizeofIfaMsghdrFreeBSD10 = 0x14 - sizeofIfaMsghdrlFreeBSD10 = 0x6c - sizeofIfmaMsghdrFreeBSD10 = 0x10 - sizeofIfAnnouncemsghdrFreeBSD10 = 0x18 - - sizeofRtMsghdrFreeBSD10 = 0x5c - sizeofRtMetricsFreeBSD10 = 0x38 - - sizeofIfMsghdrFreeBSD7 = 0x70 - sizeofIfMsghdrFreeBSD8 = 0x70 - sizeofIfMsghdrFreeBSD9 = 0x70 - sizeofIfMsghdrFreeBSD10 = 0x70 - sizeofIfMsghdrFreeBSD11 = 0xa8 - - sizeofIfDataFreeBSD7 = 0x60 - sizeofIfDataFreeBSD8 = 0x60 - sizeofIfDataFreeBSD9 = 0x60 - sizeofIfDataFreeBSD10 = 0x60 - sizeofIfDataFreeBSD11 = 0x98 - - sizeofIfMsghdrlFreeBSD10Emu = 0x68 - sizeofIfaMsghdrFreeBSD10Emu = 0x14 - sizeofIfaMsghdrlFreeBSD10Emu = 0x6c - sizeofIfmaMsghdrFreeBSD10Emu = 0x10 - sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18 - - sizeofRtMsghdrFreeBSD10Emu = 0x5c - sizeofRtMetricsFreeBSD10Emu = 0x38 - - sizeofIfMsghdrFreeBSD7Emu = 0x70 - sizeofIfMsghdrFreeBSD8Emu = 0x70 - sizeofIfMsghdrFreeBSD9Emu = 0x70 - sizeofIfMsghdrFreeBSD10Emu = 0x70 - sizeofIfMsghdrFreeBSD11Emu = 0xa8 - - sizeofIfDataFreeBSD7Emu = 0x60 - sizeofIfDataFreeBSD8Emu = 0x60 - sizeofIfDataFreeBSD9Emu = 0x60 - sizeofIfDataFreeBSD10Emu = 0x60 - sizeofIfDataFreeBSD11Emu = 0x98 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/route/zsys_netbsd.go b/vendor/golang.org/x/net/route/zsys_netbsd.go deleted file mode 100644 index e0df45e8b..000000000 --- a/vendor/golang.org/x/net/route/zsys_netbsd.go +++ /dev/null @@ -1,97 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_netbsd.go - -package route - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_ROUTE = 0x22 - sysAF_LINK = 0x12 - sysAF_INET6 = 0x18 - - sysSOCK_RAW = 0x3 - - sysNET_RT_DUMP = 0x1 - sysNET_RT_FLAGS = 0x2 - sysNET_RT_IFLIST = 0x5 - sysNET_RT_MAXID = 0x6 -) - -const ( - sysCTL_MAXNAME = 0xc - - sysCTL_UNSPEC = 0x0 - sysCTL_KERN = 0x1 - sysCTL_VM = 0x2 - sysCTL_VFS = 0x3 - sysCTL_NET = 0x4 - sysCTL_DEBUG = 0x5 - sysCTL_HW = 0x6 - sysCTL_MACHDEP = 0x7 - sysCTL_USER = 0x8 - sysCTL_DDB = 0x9 - sysCTL_PROC = 0xa - sysCTL_VENDOR = 0xb - sysCTL_EMUL = 0xc - sysCTL_SECURITY = 0xd - sysCTL_MAXID = 0xe -) - -const ( - sysRTM_VERSION = 0x4 - - sysRTM_ADD = 0x1 - sysRTM_DELETE = 0x2 - sysRTM_CHANGE = 0x3 - sysRTM_GET = 0x4 - sysRTM_LOSING = 0x5 - sysRTM_REDIRECT = 0x6 - sysRTM_MISS = 0x7 - sysRTM_LOCK = 0x8 - sysRTM_OLDADD = 0x9 - sysRTM_OLDDEL = 0xa - sysRTM_RESOLVE = 0xb - sysRTM_NEWADDR = 0xc - sysRTM_DELADDR = 0xd - sysRTM_IFANNOUNCE = 0x10 - sysRTM_IEEE80211 = 0x11 - sysRTM_SETGATE = 0x12 - sysRTM_LLINFO_UPD = 0x13 - sysRTM_IFINFO = 0x14 - sysRTM_CHGADDR = 0x15 - - sysRTA_DST = 0x1 - sysRTA_GATEWAY = 0x2 - sysRTA_NETMASK = 0x4 - sysRTA_GENMASK = 0x8 - sysRTA_IFP = 0x10 - sysRTA_IFA = 0x20 - sysRTA_AUTHOR = 0x40 - sysRTA_BRD = 0x80 - sysRTA_TAG = 0x100 - - sysRTAX_DST = 0x0 - sysRTAX_GATEWAY = 0x1 - sysRTAX_NETMASK = 0x2 - sysRTAX_GENMASK = 0x3 - sysRTAX_IFP = 0x4 - sysRTAX_IFA = 0x5 - sysRTAX_AUTHOR = 0x6 - sysRTAX_BRD = 0x7 - sysRTAX_TAG = 0x8 - sysRTAX_MAX = 0x9 -) - -const ( - sizeofIfMsghdrNetBSD7 = 0x98 - sizeofIfaMsghdrNetBSD7 = 0x18 - sizeofIfAnnouncemsghdrNetBSD7 = 0x18 - - sizeofRtMsghdrNetBSD7 = 0x78 - sizeofRtMetricsNetBSD7 = 0x50 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/route/zsys_openbsd.go b/vendor/golang.org/x/net/route/zsys_openbsd.go deleted file mode 100644 index f5a1ff967..000000000 --- a/vendor/golang.org/x/net/route/zsys_openbsd.go +++ /dev/null @@ -1,90 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_openbsd.go - -package route - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_ROUTE = 0x11 - sysAF_LINK = 0x12 - sysAF_INET6 = 0x18 - - sysSOCK_RAW = 0x3 - - sysNET_RT_DUMP = 0x1 - sysNET_RT_FLAGS = 0x2 - sysNET_RT_IFLIST = 0x3 - sysNET_RT_STATS = 0x4 - sysNET_RT_TABLE = 0x5 - sysNET_RT_IFNAMES = 0x6 - sysNET_RT_MAXID = 0x7 -) - -const ( - sysCTL_MAXNAME = 0xc - - sysCTL_UNSPEC = 0x0 - sysCTL_KERN = 0x1 - sysCTL_VM = 0x2 - sysCTL_FS = 0x3 - sysCTL_NET = 0x4 - sysCTL_DEBUG = 0x5 - sysCTL_HW = 0x6 - sysCTL_MACHDEP = 0x7 - sysCTL_DDB = 0x9 - sysCTL_VFS = 0xa - sysCTL_MAXID = 0xb -) - -const ( - sysRTM_VERSION = 0x5 - - sysRTM_ADD = 0x1 - sysRTM_DELETE = 0x2 - sysRTM_CHANGE = 0x3 - sysRTM_GET = 0x4 - sysRTM_LOSING = 0x5 - sysRTM_REDIRECT = 0x6 - sysRTM_MISS = 0x7 - sysRTM_LOCK = 0x8 - sysRTM_RESOLVE = 0xb - sysRTM_NEWADDR = 0xc - sysRTM_DELADDR = 0xd - sysRTM_IFINFO = 0xe - sysRTM_IFANNOUNCE = 0xf - sysRTM_DESYNC = 0x10 - - sysRTA_DST = 0x1 - sysRTA_GATEWAY = 0x2 - sysRTA_NETMASK = 0x4 - sysRTA_GENMASK = 0x8 - sysRTA_IFP = 0x10 - sysRTA_IFA = 0x20 - sysRTA_AUTHOR = 0x40 - sysRTA_BRD = 0x80 - sysRTA_SRC = 0x100 - sysRTA_SRCMASK = 0x200 - sysRTA_LABEL = 0x400 - - sysRTAX_DST = 0x0 - sysRTAX_GATEWAY = 0x1 - sysRTAX_NETMASK = 0x2 - sysRTAX_GENMASK = 0x3 - sysRTAX_IFP = 0x4 - sysRTAX_IFA = 0x5 - sysRTAX_AUTHOR = 0x6 - sysRTAX_BRD = 0x7 - sysRTAX_SRC = 0x8 - sysRTAX_SRCMASK = 0x9 - sysRTAX_LABEL = 0xa - sysRTAX_MAX = 0xb -) - -const ( - sizeofRtMsghdr = 0x60 - - sizeofSockaddrStorage = 0x100 - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/trace/events.go b/vendor/golang.org/x/net/trace/events.go deleted file mode 100644 index d8daec1a7..000000000 --- a/vendor/golang.org/x/net/trace/events.go +++ /dev/null @@ -1,532 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package trace - -import ( - "bytes" - "fmt" - "html/template" - "io" - "log" - "net/http" - "runtime" - "sort" - "strconv" - "strings" - "sync" - "sync/atomic" - "text/tabwriter" - "time" -) - -const maxEventsPerLog = 100 - -type bucket struct { - MaxErrAge time.Duration - String string -} - -var buckets = []bucket{ - {0, "total"}, - {10 * time.Second, "errs<10s"}, - {1 * time.Minute, "errs<1m"}, - {10 * time.Minute, "errs<10m"}, - {1 * time.Hour, "errs<1h"}, - {10 * time.Hour, "errs<10h"}, - {24000 * time.Hour, "errors"}, -} - -// RenderEvents renders the HTML page typically served at /debug/events. -// It does not do any auth checking; see AuthRequest for the default auth check -// used by the handler registered on http.DefaultServeMux. -// req may be nil. -func RenderEvents(w http.ResponseWriter, req *http.Request, sensitive bool) { - now := time.Now() - data := &struct { - Families []string // family names - Buckets []bucket - Counts [][]int // eventLog count per family/bucket - - // Set when a bucket has been selected. - Family string - Bucket int - EventLogs eventLogs - Expanded bool - }{ - Buckets: buckets, - } - - data.Families = make([]string, 0, len(families)) - famMu.RLock() - for name := range families { - data.Families = append(data.Families, name) - } - famMu.RUnlock() - sort.Strings(data.Families) - - // Count the number of eventLogs in each family for each error age. - data.Counts = make([][]int, len(data.Families)) - for i, name := range data.Families { - // TODO(sameer): move this loop under the family lock. - f := getEventFamily(name) - data.Counts[i] = make([]int, len(data.Buckets)) - for j, b := range data.Buckets { - data.Counts[i][j] = f.Count(now, b.MaxErrAge) - } - } - - if req != nil { - var ok bool - data.Family, data.Bucket, ok = parseEventsArgs(req) - if !ok { - // No-op - } else { - data.EventLogs = getEventFamily(data.Family).Copy(now, buckets[data.Bucket].MaxErrAge) - } - if data.EventLogs != nil { - defer data.EventLogs.Free() - sort.Sort(data.EventLogs) - } - if exp, err := strconv.ParseBool(req.FormValue("exp")); err == nil { - data.Expanded = exp - } - } - - famMu.RLock() - defer famMu.RUnlock() - if err := eventsTmpl().Execute(w, data); err != nil { - log.Printf("net/trace: Failed executing template: %v", err) - } -} - -func parseEventsArgs(req *http.Request) (fam string, b int, ok bool) { - fam, bStr := req.FormValue("fam"), req.FormValue("b") - if fam == "" || bStr == "" { - return "", 0, false - } - b, err := strconv.Atoi(bStr) - if err != nil || b < 0 || b >= len(buckets) { - return "", 0, false - } - return fam, b, true -} - -// An EventLog provides a log of events associated with a specific object. -type EventLog interface { - // Printf formats its arguments with fmt.Sprintf and adds the - // result to the event log. - Printf(format string, a ...interface{}) - - // Errorf is like Printf, but it marks this event as an error. - Errorf(format string, a ...interface{}) - - // Finish declares that this event log is complete. - // The event log should not be used after calling this method. - Finish() -} - -// NewEventLog returns a new EventLog with the specified family name -// and title. -func NewEventLog(family, title string) EventLog { - el := newEventLog() - el.ref() - el.Family, el.Title = family, title - el.Start = time.Now() - el.events = make([]logEntry, 0, maxEventsPerLog) - el.stack = make([]uintptr, 32) - n := runtime.Callers(2, el.stack) - el.stack = el.stack[:n] - - getEventFamily(family).add(el) - return el -} - -func (el *eventLog) Finish() { - getEventFamily(el.Family).remove(el) - el.unref() // matches ref in New -} - -var ( - famMu sync.RWMutex - families = make(map[string]*eventFamily) // family name => family -) - -func getEventFamily(fam string) *eventFamily { - famMu.Lock() - defer famMu.Unlock() - f := families[fam] - if f == nil { - f = &eventFamily{} - families[fam] = f - } - return f -} - -type eventFamily struct { - mu sync.RWMutex - eventLogs eventLogs -} - -func (f *eventFamily) add(el *eventLog) { - f.mu.Lock() - f.eventLogs = append(f.eventLogs, el) - f.mu.Unlock() -} - -func (f *eventFamily) remove(el *eventLog) { - f.mu.Lock() - defer f.mu.Unlock() - for i, el0 := range f.eventLogs { - if el == el0 { - copy(f.eventLogs[i:], f.eventLogs[i+1:]) - f.eventLogs = f.eventLogs[:len(f.eventLogs)-1] - return - } - } -} - -func (f *eventFamily) Count(now time.Time, maxErrAge time.Duration) (n int) { - f.mu.RLock() - defer f.mu.RUnlock() - for _, el := range f.eventLogs { - if el.hasRecentError(now, maxErrAge) { - n++ - } - } - return -} - -func (f *eventFamily) Copy(now time.Time, maxErrAge time.Duration) (els eventLogs) { - f.mu.RLock() - defer f.mu.RUnlock() - els = make(eventLogs, 0, len(f.eventLogs)) - for _, el := range f.eventLogs { - if el.hasRecentError(now, maxErrAge) { - el.ref() - els = append(els, el) - } - } - return -} - -type eventLogs []*eventLog - -// Free calls unref on each element of the list. -func (els eventLogs) Free() { - for _, el := range els { - el.unref() - } -} - -// eventLogs may be sorted in reverse chronological order. -func (els eventLogs) Len() int { return len(els) } -func (els eventLogs) Less(i, j int) bool { return els[i].Start.After(els[j].Start) } -func (els eventLogs) Swap(i, j int) { els[i], els[j] = els[j], els[i] } - -// A logEntry is a timestamped log entry in an event log. -type logEntry struct { - When time.Time - Elapsed time.Duration // since previous event in log - NewDay bool // whether this event is on a different day to the previous event - What string - IsErr bool -} - -// WhenString returns a string representation of the elapsed time of the event. -// It will include the date if midnight was crossed. -func (e logEntry) WhenString() string { - if e.NewDay { - return e.When.Format("2006/01/02 15:04:05.000000") - } - return e.When.Format("15:04:05.000000") -} - -// An eventLog represents an active event log. -type eventLog struct { - // Family is the top-level grouping of event logs to which this belongs. - Family string - - // Title is the title of this event log. - Title string - - // Timing information. - Start time.Time - - // Call stack where this event log was created. - stack []uintptr - - // Append-only sequence of events. - // - // TODO(sameer): change this to a ring buffer to avoid the array copy - // when we hit maxEventsPerLog. - mu sync.RWMutex - events []logEntry - LastErrorTime time.Time - discarded int - - refs int32 // how many buckets this is in -} - -func (el *eventLog) reset() { - // Clear all but the mutex. Mutexes may not be copied, even when unlocked. - el.Family = "" - el.Title = "" - el.Start = time.Time{} - el.stack = nil - el.events = nil - el.LastErrorTime = time.Time{} - el.discarded = 0 - el.refs = 0 -} - -func (el *eventLog) hasRecentError(now time.Time, maxErrAge time.Duration) bool { - if maxErrAge == 0 { - return true - } - el.mu.RLock() - defer el.mu.RUnlock() - return now.Sub(el.LastErrorTime) < maxErrAge -} - -// delta returns the elapsed time since the last event or the log start, -// and whether it spans midnight. -// L >= el.mu -func (el *eventLog) delta(t time.Time) (time.Duration, bool) { - if len(el.events) == 0 { - return t.Sub(el.Start), false - } - prev := el.events[len(el.events)-1].When - return t.Sub(prev), prev.Day() != t.Day() - -} - -func (el *eventLog) Printf(format string, a ...interface{}) { - el.printf(false, format, a...) -} - -func (el *eventLog) Errorf(format string, a ...interface{}) { - el.printf(true, format, a...) -} - -func (el *eventLog) printf(isErr bool, format string, a ...interface{}) { - e := logEntry{When: time.Now(), IsErr: isErr, What: fmt.Sprintf(format, a...)} - el.mu.Lock() - e.Elapsed, e.NewDay = el.delta(e.When) - if len(el.events) < maxEventsPerLog { - el.events = append(el.events, e) - } else { - // Discard the oldest event. - if el.discarded == 0 { - // el.discarded starts at two to count for the event it - // is replacing, plus the next one that we are about to - // drop. - el.discarded = 2 - } else { - el.discarded++ - } - // TODO(sameer): if this causes allocations on a critical path, - // change eventLog.What to be a fmt.Stringer, as in trace.go. - el.events[0].What = fmt.Sprintf("(%d events discarded)", el.discarded) - // The timestamp of the discarded meta-event should be - // the time of the last event it is representing. - el.events[0].When = el.events[1].When - copy(el.events[1:], el.events[2:]) - el.events[maxEventsPerLog-1] = e - } - if e.IsErr { - el.LastErrorTime = e.When - } - el.mu.Unlock() -} - -func (el *eventLog) ref() { - atomic.AddInt32(&el.refs, 1) -} - -func (el *eventLog) unref() { - if atomic.AddInt32(&el.refs, -1) == 0 { - freeEventLog(el) - } -} - -func (el *eventLog) When() string { - return el.Start.Format("2006/01/02 15:04:05.000000") -} - -func (el *eventLog) ElapsedTime() string { - elapsed := time.Since(el.Start) - return fmt.Sprintf("%.6f", elapsed.Seconds()) -} - -func (el *eventLog) Stack() string { - buf := new(bytes.Buffer) - tw := tabwriter.NewWriter(buf, 1, 8, 1, '\t', 0) - printStackRecord(tw, el.stack) - tw.Flush() - return buf.String() -} - -// printStackRecord prints the function + source line information -// for a single stack trace. -// Adapted from runtime/pprof/pprof.go. -func printStackRecord(w io.Writer, stk []uintptr) { - for _, pc := range stk { - f := runtime.FuncForPC(pc) - if f == nil { - continue - } - file, line := f.FileLine(pc) - name := f.Name() - // Hide runtime.goexit and any runtime functions at the beginning. - if strings.HasPrefix(name, "runtime.") { - continue - } - fmt.Fprintf(w, "# %s\t%s:%d\n", name, file, line) - } -} - -func (el *eventLog) Events() []logEntry { - el.mu.RLock() - defer el.mu.RUnlock() - return el.events -} - -// freeEventLogs is a freelist of *eventLog -var freeEventLogs = make(chan *eventLog, 1000) - -// newEventLog returns a event log ready to use. -func newEventLog() *eventLog { - select { - case el := <-freeEventLogs: - return el - default: - return new(eventLog) - } -} - -// freeEventLog adds el to freeEventLogs if there's room. -// This is non-blocking. -func freeEventLog(el *eventLog) { - el.reset() - select { - case freeEventLogs <- el: - default: - } -} - -var eventsTmplCache *template.Template -var eventsTmplOnce sync.Once - -func eventsTmpl() *template.Template { - eventsTmplOnce.Do(func() { - eventsTmplCache = template.Must(template.New("events").Funcs(template.FuncMap{ - "elapsed": elapsed, - "trimSpace": strings.TrimSpace, - }).Parse(eventsHTML)) - }) - return eventsTmplCache -} - -const eventsHTML = ` - - - events - - - - -

    /debug/events

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


    -

    Family: {{$.Family}}

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

    /debug/requests

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

    Family: {{$.Family}}

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

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

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

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

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

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

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

    Foo

    \n\n

    Bar\n" - d := NewDecoder(strings.NewReader(testInput)) - var err error - for _, err = d.Token(); err == nil; _, err = d.Token() { - } - synerr, ok := err.(*SyntaxError) - if !ok { - t.Error("Expected SyntaxError.") - } - if synerr.Line != 3 { - t.Error("SyntaxError didn't have correct line number.") - } -} - -func TestTrailingRawToken(t *testing.T) { - input := ` ` - d := NewDecoder(strings.NewReader(input)) - var err error - for _, err = d.RawToken(); err == nil; _, err = d.RawToken() { - } - if err != io.EOF { - t.Fatalf("d.RawToken() = _, %v, want _, io.EOF", err) - } -} - -func TestTrailingToken(t *testing.T) { - input := ` ` - d := NewDecoder(strings.NewReader(input)) - var err error - for _, err = d.Token(); err == nil; _, err = d.Token() { - } - if err != io.EOF { - t.Fatalf("d.Token() = _, %v, want _, io.EOF", err) - } -} - -func TestEntityInsideCDATA(t *testing.T) { - input := `` - d := NewDecoder(strings.NewReader(input)) - var err error - for _, err = d.Token(); err == nil; _, err = d.Token() { - } - if err != io.EOF { - t.Fatalf("d.Token() = _, %v, want _, io.EOF", err) - } -} - -var characterTests = []struct { - in string - err string -}{ - {"\x12", "illegal character code U+0012"}, - {"\x0b", "illegal character code U+000B"}, - {"\xef\xbf\xbe", "illegal character code U+FFFE"}, - {"\r\n\x07", "illegal character code U+0007"}, - {"what's up", "expected attribute name in element"}, - {"&abc\x01;", "invalid character entity &abc (no semicolon)"}, - {"&\x01;", "invalid character entity & (no semicolon)"}, - {"&\xef\xbf\xbe;", "invalid character entity &\uFFFE;"}, - {"&hello;", "invalid character entity &hello;"}, -} - -func TestDisallowedCharacters(t *testing.T) { - - for i, tt := range characterTests { - d := NewDecoder(strings.NewReader(tt.in)) - var err error - - for err == nil { - _, err = d.Token() - } - synerr, ok := err.(*SyntaxError) - if !ok { - t.Fatalf("input %d d.Token() = _, %v, want _, *SyntaxError", i, err) - } - if synerr.Msg != tt.err { - t.Fatalf("input %d synerr.Msg wrong: want %q, got %q", i, tt.err, synerr.Msg) - } - } -} - -type procInstEncodingTest struct { - expect, got string -} - -var procInstTests = []struct { - input string - expect [2]string -}{ - {`version="1.0" encoding="utf-8"`, [2]string{"1.0", "utf-8"}}, - {`version="1.0" encoding='utf-8'`, [2]string{"1.0", "utf-8"}}, - {`version="1.0" encoding='utf-8' `, [2]string{"1.0", "utf-8"}}, - {`version="1.0" encoding=utf-8`, [2]string{"1.0", ""}}, - {`encoding="FOO" `, [2]string{"", "FOO"}}, -} - -func TestProcInstEncoding(t *testing.T) { - for _, test := range procInstTests { - if got := procInst("version", test.input); got != test.expect[0] { - t.Errorf("procInst(version, %q) = %q; want %q", test.input, got, test.expect[0]) - } - if got := procInst("encoding", test.input); got != test.expect[1] { - t.Errorf("procInst(encoding, %q) = %q; want %q", test.input, got, test.expect[1]) - } - } -} - -// Ensure that directives with comments include the complete -// text of any nested directives. - -var directivesWithCommentsInput = ` -]> -]> - --> --> []> -` - -var directivesWithCommentsTokens = []Token{ - CharData("\n"), - Directive(`DOCTYPE []`), - CharData("\n"), - Directive(`DOCTYPE []`), - CharData("\n"), - Directive(`DOCTYPE []`), - CharData("\n"), -} - -func TestDirectivesWithComments(t *testing.T) { - d := NewDecoder(strings.NewReader(directivesWithCommentsInput)) - - for i, want := range directivesWithCommentsTokens { - have, err := d.Token() - if err != nil { - t.Fatalf("token %d: unexpected error: %s", i, err) - } - if !reflect.DeepEqual(have, want) { - t.Errorf("token %d = %#v want %#v", i, have, want) - } - } -} - -// Writer whose Write method always returns an error. -type errWriter struct{} - -func (errWriter) Write(p []byte) (n int, err error) { return 0, fmt.Errorf("unwritable") } - -func TestEscapeTextIOErrors(t *testing.T) { - expectErr := "unwritable" - err := EscapeText(errWriter{}, []byte{'A'}) - - if err == nil || err.Error() != expectErr { - t.Errorf("have %v, want %v", err, expectErr) - } -} - -func TestEscapeTextInvalidChar(t *testing.T) { - input := []byte("A \x00 terminated string.") - expected := "A \uFFFD terminated string." - - buff := new(bytes.Buffer) - if err := EscapeText(buff, input); err != nil { - t.Fatalf("have %v, want nil", err) - } - text := buff.String() - - if text != expected { - t.Errorf("have %v, want %v", text, expected) - } -} - -func TestIssue5880(t *testing.T) { - type T []byte - data, err := Marshal(T{192, 168, 0, 1}) - if err != nil { - t.Errorf("Marshal error: %v", err) - } - if !utf8.Valid(data) { - t.Errorf("Marshal generated invalid UTF-8: %x", data) - } -} diff --git a/vendor/golang.org/x/net/webdav/litmus_test_server.go b/vendor/golang.org/x/net/webdav/litmus_test_server.go deleted file mode 100644 index 514db5dd1..000000000 --- a/vendor/golang.org/x/net/webdav/litmus_test_server.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -/* -This program is a server for the WebDAV 'litmus' compliance test at -http://www.webdav.org/neon/litmus/ -To run the test: - -go run litmus_test_server.go - -and separately, from the downloaded litmus-xxx directory: - -make URL=http://localhost:9999/ check -*/ -package main - -import ( - "flag" - "fmt" - "log" - "net/http" - "net/url" - - "golang.org/x/net/webdav" -) - -var port = flag.Int("port", 9999, "server port") - -func main() { - flag.Parse() - log.SetFlags(0) - h := &webdav.Handler{ - FileSystem: webdav.NewMemFS(), - LockSystem: webdav.NewMemLS(), - Logger: func(r *http.Request, err error) { - litmus := r.Header.Get("X-Litmus") - if len(litmus) > 19 { - litmus = litmus[:16] + "..." - } - - switch r.Method { - case "COPY", "MOVE": - dst := "" - if u, err := url.Parse(r.Header.Get("Destination")); err == nil { - dst = u.Path - } - o := r.Header.Get("Overwrite") - log.Printf("%-20s%-10s%-30s%-30so=%-2s%v", litmus, r.Method, r.URL.Path, dst, o, err) - default: - log.Printf("%-20s%-10s%-30s%v", litmus, r.Method, r.URL.Path, err) - } - }, - } - - // The next line would normally be: - // http.Handle("/", h) - // but we wrap that HTTP handler h to cater for a special case. - // - // The propfind_invalid2 litmus test case expects an empty namespace prefix - // declaration to be an error. The FAQ in the webdav litmus test says: - // - // "What does the "propfind_invalid2" test check for?... - // - // If a request was sent with an XML body which included an empty namespace - // prefix declaration (xmlns:ns1=""), then the server must reject that with - // a "400 Bad Request" response, as it is invalid according to the XML - // Namespace specification." - // - // On the other hand, the Go standard library's encoding/xml package - // accepts an empty xmlns namespace, as per the discussion at - // https://github.com/golang/go/issues/8068 - // - // Empty namespaces seem disallowed in the second (2006) edition of the XML - // standard, but allowed in a later edition. The grammar differs between - // http://www.w3.org/TR/2006/REC-xml-names-20060816/#ns-decl and - // http://www.w3.org/TR/REC-xml-names/#dt-prefix - // - // Thus, we assume that the propfind_invalid2 test is obsolete, and - // hard-code the 400 Bad Request response that the test expects. - http.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.Header.Get("X-Litmus") == "props: 3 (propfind_invalid2)" { - http.Error(w, "400 Bad Request", http.StatusBadRequest) - return - } - h.ServeHTTP(w, r) - })) - - addr := fmt.Sprintf(":%d", *port) - log.Printf("Serving %v", addr) - log.Fatal(http.ListenAndServe(addr, nil)) -} diff --git a/vendor/golang.org/x/net/webdav/lock.go b/vendor/golang.org/x/net/webdav/lock.go deleted file mode 100644 index 344ac5cea..000000000 --- a/vendor/golang.org/x/net/webdav/lock.go +++ /dev/null @@ -1,445 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webdav - -import ( - "container/heap" - "errors" - "strconv" - "strings" - "sync" - "time" -) - -var ( - // ErrConfirmationFailed is returned by a LockSystem's Confirm method. - ErrConfirmationFailed = errors.New("webdav: confirmation failed") - // ErrForbidden is returned by a LockSystem's Unlock method. - ErrForbidden = errors.New("webdav: forbidden") - // ErrLocked is returned by a LockSystem's Create, Refresh and Unlock methods. - ErrLocked = errors.New("webdav: locked") - // ErrNoSuchLock is returned by a LockSystem's Refresh and Unlock methods. - ErrNoSuchLock = errors.New("webdav: no such lock") -) - -// Condition can match a WebDAV resource, based on a token or ETag. -// Exactly one of Token and ETag should be non-empty. -type Condition struct { - Not bool - Token string - ETag string -} - -// LockSystem manages access to a collection of named resources. The elements -// in a lock name are separated by slash ('/', U+002F) characters, regardless -// of host operating system convention. -type LockSystem interface { - // Confirm confirms that the caller can claim all of the locks specified by - // the given conditions, and that holding the union of all of those locks - // gives exclusive access to all of the named resources. Up to two resources - // can be named. Empty names are ignored. - // - // Exactly one of release and err will be non-nil. If release is non-nil, - // all of the requested locks are held until release is called. Calling - // release does not unlock the lock, in the WebDAV UNLOCK sense, but once - // Confirm has confirmed that a lock claim is valid, that lock cannot be - // Confirmed again until it has been released. - // - // If Confirm returns ErrConfirmationFailed then the Handler will continue - // to try any other set of locks presented (a WebDAV HTTP request can - // present more than one set of locks). If it returns any other non-nil - // error, the Handler will write a "500 Internal Server Error" HTTP status. - Confirm(now time.Time, name0, name1 string, conditions ...Condition) (release func(), err error) - - // Create creates a lock with the given depth, duration, owner and root - // (name). The depth will either be negative (meaning infinite) or zero. - // - // If Create returns ErrLocked then the Handler will write a "423 Locked" - // HTTP status. If it returns any other non-nil error, the Handler will - // write a "500 Internal Server Error" HTTP status. - // - // See http://www.webdav.org/specs/rfc4918.html#rfc.section.9.10.6 for - // when to use each error. - // - // The token returned identifies the created lock. It should be an absolute - // URI as defined by RFC 3986, Section 4.3. In particular, it should not - // contain whitespace. - Create(now time.Time, details LockDetails) (token string, err error) - - // Refresh refreshes the lock with the given token. - // - // If Refresh returns ErrLocked then the Handler will write a "423 Locked" - // HTTP Status. If Refresh returns ErrNoSuchLock then the Handler will write - // a "412 Precondition Failed" HTTP Status. If it returns any other non-nil - // error, the Handler will write a "500 Internal Server Error" HTTP status. - // - // See http://www.webdav.org/specs/rfc4918.html#rfc.section.9.10.6 for - // when to use each error. - Refresh(now time.Time, token string, duration time.Duration) (LockDetails, error) - - // Unlock unlocks the lock with the given token. - // - // If Unlock returns ErrForbidden then the Handler will write a "403 - // Forbidden" HTTP Status. If Unlock returns ErrLocked then the Handler - // will write a "423 Locked" HTTP status. If Unlock returns ErrNoSuchLock - // then the Handler will write a "409 Conflict" HTTP Status. If it returns - // any other non-nil error, the Handler will write a "500 Internal Server - // Error" HTTP status. - // - // See http://www.webdav.org/specs/rfc4918.html#rfc.section.9.11.1 for - // when to use each error. - Unlock(now time.Time, token string) error -} - -// LockDetails are a lock's metadata. -type LockDetails struct { - // Root is the root resource name being locked. For a zero-depth lock, the - // root is the only resource being locked. - Root string - // Duration is the lock timeout. A negative duration means infinite. - Duration time.Duration - // OwnerXML is the verbatim XML given in a LOCK HTTP request. - // - // TODO: does the "verbatim" nature play well with XML namespaces? - // Does the OwnerXML field need to have more structure? See - // https://codereview.appspot.com/175140043/#msg2 - OwnerXML string - // ZeroDepth is whether the lock has zero depth. If it does not have zero - // depth, it has infinite depth. - ZeroDepth bool -} - -// NewMemLS returns a new in-memory LockSystem. -func NewMemLS() LockSystem { - return &memLS{ - byName: make(map[string]*memLSNode), - byToken: make(map[string]*memLSNode), - gen: uint64(time.Now().Unix()), - } -} - -type memLS struct { - mu sync.Mutex - byName map[string]*memLSNode - byToken map[string]*memLSNode - gen uint64 - // byExpiry only contains those nodes whose LockDetails have a finite - // Duration and are yet to expire. - byExpiry byExpiry -} - -func (m *memLS) nextToken() string { - m.gen++ - return strconv.FormatUint(m.gen, 10) -} - -func (m *memLS) collectExpiredNodes(now time.Time) { - for len(m.byExpiry) > 0 { - if now.Before(m.byExpiry[0].expiry) { - break - } - m.remove(m.byExpiry[0]) - } -} - -func (m *memLS) Confirm(now time.Time, name0, name1 string, conditions ...Condition) (func(), error) { - m.mu.Lock() - defer m.mu.Unlock() - m.collectExpiredNodes(now) - - var n0, n1 *memLSNode - if name0 != "" { - if n0 = m.lookup(slashClean(name0), conditions...); n0 == nil { - return nil, ErrConfirmationFailed - } - } - if name1 != "" { - if n1 = m.lookup(slashClean(name1), conditions...); n1 == nil { - return nil, ErrConfirmationFailed - } - } - - // Don't hold the same node twice. - if n1 == n0 { - n1 = nil - } - - if n0 != nil { - m.hold(n0) - } - if n1 != nil { - m.hold(n1) - } - return func() { - m.mu.Lock() - defer m.mu.Unlock() - if n1 != nil { - m.unhold(n1) - } - if n0 != nil { - m.unhold(n0) - } - }, nil -} - -// lookup returns the node n that locks the named resource, provided that n -// matches at least one of the given conditions and that lock isn't held by -// another party. Otherwise, it returns nil. -// -// n may be a parent of the named resource, if n is an infinite depth lock. -func (m *memLS) lookup(name string, conditions ...Condition) (n *memLSNode) { - // TODO: support Condition.Not and Condition.ETag. - for _, c := range conditions { - n = m.byToken[c.Token] - if n == nil || n.held { - continue - } - if name == n.details.Root { - return n - } - if n.details.ZeroDepth { - continue - } - if n.details.Root == "/" || strings.HasPrefix(name, n.details.Root+"/") { - return n - } - } - return nil -} - -func (m *memLS) hold(n *memLSNode) { - if n.held { - panic("webdav: memLS inconsistent held state") - } - n.held = true - if n.details.Duration >= 0 && n.byExpiryIndex >= 0 { - heap.Remove(&m.byExpiry, n.byExpiryIndex) - } -} - -func (m *memLS) unhold(n *memLSNode) { - if !n.held { - panic("webdav: memLS inconsistent held state") - } - n.held = false - if n.details.Duration >= 0 { - heap.Push(&m.byExpiry, n) - } -} - -func (m *memLS) Create(now time.Time, details LockDetails) (string, error) { - m.mu.Lock() - defer m.mu.Unlock() - m.collectExpiredNodes(now) - details.Root = slashClean(details.Root) - - if !m.canCreate(details.Root, details.ZeroDepth) { - return "", ErrLocked - } - n := m.create(details.Root) - n.token = m.nextToken() - m.byToken[n.token] = n - n.details = details - if n.details.Duration >= 0 { - n.expiry = now.Add(n.details.Duration) - heap.Push(&m.byExpiry, n) - } - return n.token, nil -} - -func (m *memLS) Refresh(now time.Time, token string, duration time.Duration) (LockDetails, error) { - m.mu.Lock() - defer m.mu.Unlock() - m.collectExpiredNodes(now) - - n := m.byToken[token] - if n == nil { - return LockDetails{}, ErrNoSuchLock - } - if n.held { - return LockDetails{}, ErrLocked - } - if n.byExpiryIndex >= 0 { - heap.Remove(&m.byExpiry, n.byExpiryIndex) - } - n.details.Duration = duration - if n.details.Duration >= 0 { - n.expiry = now.Add(n.details.Duration) - heap.Push(&m.byExpiry, n) - } - return n.details, nil -} - -func (m *memLS) Unlock(now time.Time, token string) error { - m.mu.Lock() - defer m.mu.Unlock() - m.collectExpiredNodes(now) - - n := m.byToken[token] - if n == nil { - return ErrNoSuchLock - } - if n.held { - return ErrLocked - } - m.remove(n) - return nil -} - -func (m *memLS) canCreate(name string, zeroDepth bool) bool { - return walkToRoot(name, func(name0 string, first bool) bool { - n := m.byName[name0] - if n == nil { - return true - } - if first { - if n.token != "" { - // The target node is already locked. - return false - } - if !zeroDepth { - // The requested lock depth is infinite, and the fact that n exists - // (n != nil) means that a descendent of the target node is locked. - return false - } - } else if n.token != "" && !n.details.ZeroDepth { - // An ancestor of the target node is locked with infinite depth. - return false - } - return true - }) -} - -func (m *memLS) create(name string) (ret *memLSNode) { - walkToRoot(name, func(name0 string, first bool) bool { - n := m.byName[name0] - if n == nil { - n = &memLSNode{ - details: LockDetails{ - Root: name0, - }, - byExpiryIndex: -1, - } - m.byName[name0] = n - } - n.refCount++ - if first { - ret = n - } - return true - }) - return ret -} - -func (m *memLS) remove(n *memLSNode) { - delete(m.byToken, n.token) - n.token = "" - walkToRoot(n.details.Root, func(name0 string, first bool) bool { - x := m.byName[name0] - x.refCount-- - if x.refCount == 0 { - delete(m.byName, name0) - } - return true - }) - if n.byExpiryIndex >= 0 { - heap.Remove(&m.byExpiry, n.byExpiryIndex) - } -} - -func walkToRoot(name string, f func(name0 string, first bool) bool) bool { - for first := true; ; first = false { - if !f(name, first) { - return false - } - if name == "/" { - break - } - name = name[:strings.LastIndex(name, "/")] - if name == "" { - name = "/" - } - } - return true -} - -type memLSNode struct { - // details are the lock metadata. Even if this node's name is not explicitly locked, - // details.Root will still equal the node's name. - details LockDetails - // token is the unique identifier for this node's lock. An empty token means that - // this node is not explicitly locked. - token string - // refCount is the number of self-or-descendent nodes that are explicitly locked. - refCount int - // expiry is when this node's lock expires. - expiry time.Time - // byExpiryIndex is the index of this node in memLS.byExpiry. It is -1 - // if this node does not expire, or has expired. - byExpiryIndex int - // held is whether this node's lock is actively held by a Confirm call. - held bool -} - -type byExpiry []*memLSNode - -func (b *byExpiry) Len() int { - return len(*b) -} - -func (b *byExpiry) Less(i, j int) bool { - return (*b)[i].expiry.Before((*b)[j].expiry) -} - -func (b *byExpiry) Swap(i, j int) { - (*b)[i], (*b)[j] = (*b)[j], (*b)[i] - (*b)[i].byExpiryIndex = i - (*b)[j].byExpiryIndex = j -} - -func (b *byExpiry) Push(x interface{}) { - n := x.(*memLSNode) - n.byExpiryIndex = len(*b) - *b = append(*b, n) -} - -func (b *byExpiry) Pop() interface{} { - i := len(*b) - 1 - n := (*b)[i] - (*b)[i] = nil - n.byExpiryIndex = -1 - *b = (*b)[:i] - return n -} - -const infiniteTimeout = -1 - -// parseTimeout parses the Timeout HTTP header, as per section 10.7. If s is -// empty, an infiniteTimeout is returned. -func parseTimeout(s string) (time.Duration, error) { - if s == "" { - return infiniteTimeout, nil - } - if i := strings.IndexByte(s, ','); i >= 0 { - s = s[:i] - } - s = strings.TrimSpace(s) - if s == "Infinite" { - return infiniteTimeout, nil - } - const pre = "Second-" - if !strings.HasPrefix(s, pre) { - return 0, errInvalidTimeout - } - s = s[len(pre):] - if s == "" || s[0] < '0' || '9' < s[0] { - return 0, errInvalidTimeout - } - n, err := strconv.ParseInt(s, 10, 64) - if err != nil || 1<<32-1 < n { - return 0, errInvalidTimeout - } - return time.Duration(n) * time.Second, nil -} diff --git a/vendor/golang.org/x/net/webdav/lock_test.go b/vendor/golang.org/x/net/webdav/lock_test.go deleted file mode 100644 index 116d6c0d7..000000000 --- a/vendor/golang.org/x/net/webdav/lock_test.go +++ /dev/null @@ -1,731 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webdav - -import ( - "fmt" - "math/rand" - "path" - "reflect" - "sort" - "strconv" - "strings" - "testing" - "time" -) - -func TestWalkToRoot(t *testing.T) { - testCases := []struct { - name string - want []string - }{{ - "/a/b/c/d", - []string{ - "/a/b/c/d", - "/a/b/c", - "/a/b", - "/a", - "/", - }, - }, { - "/a", - []string{ - "/a", - "/", - }, - }, { - "/", - []string{ - "/", - }, - }} - - for _, tc := range testCases { - var got []string - if !walkToRoot(tc.name, func(name0 string, first bool) bool { - if first != (len(got) == 0) { - t.Errorf("name=%q: first=%t but len(got)==%d", tc.name, first, len(got)) - return false - } - got = append(got, name0) - return true - }) { - continue - } - if !reflect.DeepEqual(got, tc.want) { - t.Errorf("name=%q:\ngot %q\nwant %q", tc.name, got, tc.want) - } - } -} - -var lockTestDurations = []time.Duration{ - infiniteTimeout, // infiniteTimeout means to never expire. - 0, // A zero duration means to expire immediately. - 100 * time.Hour, // A very large duration will not expire in these tests. -} - -// lockTestNames are the names of a set of mutually compatible locks. For each -// name fragment: -// - _ means no explicit lock. -// - i means a infinite-depth lock, -// - z means a zero-depth lock, -var lockTestNames = []string{ - "/_/_/_/_/z", - "/_/_/i", - "/_/z", - "/_/z/i", - "/_/z/z", - "/_/z/_/i", - "/_/z/_/z", - "/i", - "/z", - "/z/_/i", - "/z/_/z", -} - -func lockTestZeroDepth(name string) bool { - switch name[len(name)-1] { - case 'i': - return false - case 'z': - return true - } - panic(fmt.Sprintf("lock name %q did not end with 'i' or 'z'", name)) -} - -func TestMemLSCanCreate(t *testing.T) { - now := time.Unix(0, 0) - m := NewMemLS().(*memLS) - - for _, name := range lockTestNames { - _, err := m.Create(now, LockDetails{ - Root: name, - Duration: infiniteTimeout, - ZeroDepth: lockTestZeroDepth(name), - }) - if err != nil { - t.Fatalf("creating lock for %q: %v", name, err) - } - } - - wantCanCreate := func(name string, zeroDepth bool) bool { - for _, n := range lockTestNames { - switch { - case n == name: - // An existing lock has the same name as the proposed lock. - return false - case strings.HasPrefix(n, name): - // An existing lock would be a child of the proposed lock, - // which conflicts if the proposed lock has infinite depth. - if !zeroDepth { - return false - } - case strings.HasPrefix(name, n): - // An existing lock would be an ancestor of the proposed lock, - // which conflicts if the ancestor has infinite depth. - if n[len(n)-1] == 'i' { - return false - } - } - } - return true - } - - var check func(int, string) - check = func(recursion int, name string) { - for _, zeroDepth := range []bool{false, true} { - got := m.canCreate(name, zeroDepth) - want := wantCanCreate(name, zeroDepth) - if got != want { - t.Errorf("canCreate name=%q zeroDepth=%t: got %t, want %t", name, zeroDepth, got, want) - } - } - if recursion == 6 { - return - } - if name != "/" { - name += "/" - } - for _, c := range "_iz" { - check(recursion+1, name+string(c)) - } - } - check(0, "/") -} - -func TestMemLSLookup(t *testing.T) { - now := time.Unix(0, 0) - m := NewMemLS().(*memLS) - - badToken := m.nextToken() - t.Logf("badToken=%q", badToken) - - for _, name := range lockTestNames { - token, err := m.Create(now, LockDetails{ - Root: name, - Duration: infiniteTimeout, - ZeroDepth: lockTestZeroDepth(name), - }) - if err != nil { - t.Fatalf("creating lock for %q: %v", name, err) - } - t.Logf("%-15q -> node=%p token=%q", name, m.byName[name], token) - } - - baseNames := append([]string{"/a", "/b/c"}, lockTestNames...) - for _, baseName := range baseNames { - for _, suffix := range []string{"", "/0", "/1/2/3"} { - name := baseName + suffix - - goodToken := "" - base := m.byName[baseName] - if base != nil && (suffix == "" || !lockTestZeroDepth(baseName)) { - goodToken = base.token - } - - for _, token := range []string{badToken, goodToken} { - if token == "" { - continue - } - - got := m.lookup(name, Condition{Token: token}) - want := base - if token == badToken { - want = nil - } - if got != want { - t.Errorf("name=%-20qtoken=%q (bad=%t): got %p, want %p", - name, token, token == badToken, got, want) - } - } - } - } -} - -func TestMemLSConfirm(t *testing.T) { - now := time.Unix(0, 0) - m := NewMemLS().(*memLS) - alice, err := m.Create(now, LockDetails{ - Root: "/alice", - Duration: infiniteTimeout, - ZeroDepth: false, - }) - tweedle, err := m.Create(now, LockDetails{ - Root: "/tweedle", - Duration: infiniteTimeout, - ZeroDepth: false, - }) - if err != nil { - t.Fatalf("Create: %v", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Create: inconsistent state: %v", err) - } - - // Test a mismatch between name and condition. - _, err = m.Confirm(now, "/tweedle/dee", "", Condition{Token: alice}) - if err != ErrConfirmationFailed { - t.Fatalf("Confirm (mismatch): got %v, want ErrConfirmationFailed", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Confirm (mismatch): inconsistent state: %v", err) - } - - // Test two names (that fall under the same lock) in the one Confirm call. - release, err := m.Confirm(now, "/tweedle/dee", "/tweedle/dum", Condition{Token: tweedle}) - if err != nil { - t.Fatalf("Confirm (twins): %v", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Confirm (twins): inconsistent state: %v", err) - } - release() - if err := m.consistent(); err != nil { - t.Fatalf("release (twins): inconsistent state: %v", err) - } - - // Test the same two names in overlapping Confirm / release calls. - releaseDee, err := m.Confirm(now, "/tweedle/dee", "", Condition{Token: tweedle}) - if err != nil { - t.Fatalf("Confirm (sequence #0): %v", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Confirm (sequence #0): inconsistent state: %v", err) - } - - _, err = m.Confirm(now, "/tweedle/dum", "", Condition{Token: tweedle}) - if err != ErrConfirmationFailed { - t.Fatalf("Confirm (sequence #1): got %v, want ErrConfirmationFailed", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Confirm (sequence #1): inconsistent state: %v", err) - } - - releaseDee() - if err := m.consistent(); err != nil { - t.Fatalf("release (sequence #2): inconsistent state: %v", err) - } - - releaseDum, err := m.Confirm(now, "/tweedle/dum", "", Condition{Token: tweedle}) - if err != nil { - t.Fatalf("Confirm (sequence #3): %v", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Confirm (sequence #3): inconsistent state: %v", err) - } - - // Test that you can't unlock a held lock. - err = m.Unlock(now, tweedle) - if err != ErrLocked { - t.Fatalf("Unlock (sequence #4): got %v, want ErrLocked", err) - } - - releaseDum() - if err := m.consistent(); err != nil { - t.Fatalf("release (sequence #5): inconsistent state: %v", err) - } - - err = m.Unlock(now, tweedle) - if err != nil { - t.Fatalf("Unlock (sequence #6): %v", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Unlock (sequence #6): inconsistent state: %v", err) - } -} - -func TestMemLSNonCanonicalRoot(t *testing.T) { - now := time.Unix(0, 0) - m := NewMemLS().(*memLS) - token, err := m.Create(now, LockDetails{ - Root: "/foo/./bar//", - Duration: 1 * time.Second, - }) - if err != nil { - t.Fatalf("Create: %v", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Create: inconsistent state: %v", err) - } - if err := m.Unlock(now, token); err != nil { - t.Fatalf("Unlock: %v", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Unlock: inconsistent state: %v", err) - } -} - -func TestMemLSExpiry(t *testing.T) { - m := NewMemLS().(*memLS) - testCases := []string{ - "setNow 0", - "create /a.5", - "want /a.5", - "create /c.6", - "want /a.5 /c.6", - "create /a/b.7", - "want /a.5 /a/b.7 /c.6", - "setNow 4", - "want /a.5 /a/b.7 /c.6", - "setNow 5", - "want /a/b.7 /c.6", - "setNow 6", - "want /a/b.7", - "setNow 7", - "want ", - "setNow 8", - "want ", - "create /a.12", - "create /b.13", - "create /c.15", - "create /a/d.16", - "want /a.12 /a/d.16 /b.13 /c.15", - "refresh /a.14", - "want /a.14 /a/d.16 /b.13 /c.15", - "setNow 12", - "want /a.14 /a/d.16 /b.13 /c.15", - "setNow 13", - "want /a.14 /a/d.16 /c.15", - "setNow 14", - "want /a/d.16 /c.15", - "refresh /a/d.20", - "refresh /c.20", - "want /a/d.20 /c.20", - "setNow 20", - "want ", - } - - tokens := map[string]string{} - zTime := time.Unix(0, 0) - now := zTime - for i, tc := range testCases { - j := strings.IndexByte(tc, ' ') - if j < 0 { - t.Fatalf("test case #%d %q: invalid command", i, tc) - } - op, arg := tc[:j], tc[j+1:] - switch op { - default: - t.Fatalf("test case #%d %q: invalid operation %q", i, tc, op) - - case "create", "refresh": - parts := strings.Split(arg, ".") - if len(parts) != 2 { - t.Fatalf("test case #%d %q: invalid create", i, tc) - } - root := parts[0] - d, err := strconv.Atoi(parts[1]) - if err != nil { - t.Fatalf("test case #%d %q: invalid duration", i, tc) - } - dur := time.Unix(0, 0).Add(time.Duration(d) * time.Second).Sub(now) - - switch op { - case "create": - token, err := m.Create(now, LockDetails{ - Root: root, - Duration: dur, - ZeroDepth: true, - }) - if err != nil { - t.Fatalf("test case #%d %q: Create: %v", i, tc, err) - } - tokens[root] = token - - case "refresh": - token := tokens[root] - if token == "" { - t.Fatalf("test case #%d %q: no token for %q", i, tc, root) - } - got, err := m.Refresh(now, token, dur) - if err != nil { - t.Fatalf("test case #%d %q: Refresh: %v", i, tc, err) - } - want := LockDetails{ - Root: root, - Duration: dur, - ZeroDepth: true, - } - if got != want { - t.Fatalf("test case #%d %q:\ngot %v\nwant %v", i, tc, got, want) - } - } - - case "setNow": - d, err := strconv.Atoi(arg) - if err != nil { - t.Fatalf("test case #%d %q: invalid duration", i, tc) - } - now = time.Unix(0, 0).Add(time.Duration(d) * time.Second) - - case "want": - m.mu.Lock() - m.collectExpiredNodes(now) - got := make([]string, 0, len(m.byToken)) - for _, n := range m.byToken { - got = append(got, fmt.Sprintf("%s.%d", - n.details.Root, n.expiry.Sub(zTime)/time.Second)) - } - m.mu.Unlock() - sort.Strings(got) - want := []string{} - if arg != "" { - want = strings.Split(arg, " ") - } - if !reflect.DeepEqual(got, want) { - t.Fatalf("test case #%d %q:\ngot %q\nwant %q", i, tc, got, want) - } - } - - if err := m.consistent(); err != nil { - t.Fatalf("test case #%d %q: inconsistent state: %v", i, tc, err) - } - } -} - -func TestMemLS(t *testing.T) { - now := time.Unix(0, 0) - m := NewMemLS().(*memLS) - rng := rand.New(rand.NewSource(0)) - tokens := map[string]string{} - nConfirm, nCreate, nRefresh, nUnlock := 0, 0, 0, 0 - const N = 2000 - - for i := 0; i < N; i++ { - name := lockTestNames[rng.Intn(len(lockTestNames))] - duration := lockTestDurations[rng.Intn(len(lockTestDurations))] - confirmed, unlocked := false, false - - // If the name was already locked, we randomly confirm/release, refresh - // or unlock it. Otherwise, we create a lock. - token := tokens[name] - if token != "" { - switch rng.Intn(3) { - case 0: - confirmed = true - nConfirm++ - release, err := m.Confirm(now, name, "", Condition{Token: token}) - if err != nil { - t.Fatalf("iteration #%d: Confirm %q: %v", i, name, err) - } - if err := m.consistent(); err != nil { - t.Fatalf("iteration #%d: inconsistent state: %v", i, err) - } - release() - - case 1: - nRefresh++ - if _, err := m.Refresh(now, token, duration); err != nil { - t.Fatalf("iteration #%d: Refresh %q: %v", i, name, err) - } - - case 2: - unlocked = true - nUnlock++ - if err := m.Unlock(now, token); err != nil { - t.Fatalf("iteration #%d: Unlock %q: %v", i, name, err) - } - } - - } else { - nCreate++ - var err error - token, err = m.Create(now, LockDetails{ - Root: name, - Duration: duration, - ZeroDepth: lockTestZeroDepth(name), - }) - if err != nil { - t.Fatalf("iteration #%d: Create %q: %v", i, name, err) - } - } - - if !confirmed { - if duration == 0 || unlocked { - // A zero-duration lock should expire immediately and is - // effectively equivalent to being unlocked. - tokens[name] = "" - } else { - tokens[name] = token - } - } - - if err := m.consistent(); err != nil { - t.Fatalf("iteration #%d: inconsistent state: %v", i, err) - } - } - - if nConfirm < N/10 { - t.Fatalf("too few Confirm calls: got %d, want >= %d", nConfirm, N/10) - } - if nCreate < N/10 { - t.Fatalf("too few Create calls: got %d, want >= %d", nCreate, N/10) - } - if nRefresh < N/10 { - t.Fatalf("too few Refresh calls: got %d, want >= %d", nRefresh, N/10) - } - if nUnlock < N/10 { - t.Fatalf("too few Unlock calls: got %d, want >= %d", nUnlock, N/10) - } -} - -func (m *memLS) consistent() error { - m.mu.Lock() - defer m.mu.Unlock() - - // If m.byName is non-empty, then it must contain an entry for the root "/", - // and its refCount should equal the number of locked nodes. - if len(m.byName) > 0 { - n := m.byName["/"] - if n == nil { - return fmt.Errorf(`non-empty m.byName does not contain the root "/"`) - } - if n.refCount != len(m.byToken) { - return fmt.Errorf("root node refCount=%d, differs from len(m.byToken)=%d", n.refCount, len(m.byToken)) - } - } - - for name, n := range m.byName { - // The map keys should be consistent with the node's copy of the key. - if n.details.Root != name { - return fmt.Errorf("node name %q != byName map key %q", n.details.Root, name) - } - - // A name must be clean, and start with a "/". - if len(name) == 0 || name[0] != '/' { - return fmt.Errorf(`node name %q does not start with "/"`, name) - } - if name != path.Clean(name) { - return fmt.Errorf(`node name %q is not clean`, name) - } - - // A node's refCount should be positive. - if n.refCount <= 0 { - return fmt.Errorf("non-positive refCount for node at name %q", name) - } - - // A node's refCount should be the number of self-or-descendents that - // are locked (i.e. have a non-empty token). - var list []string - for name0, n0 := range m.byName { - // All of lockTestNames' name fragments are one byte long: '_', 'i' or 'z', - // so strings.HasPrefix is equivalent to self-or-descendent name match. - // We don't have to worry about "/foo/bar" being a false positive match - // for "/foo/b". - if strings.HasPrefix(name0, name) && n0.token != "" { - list = append(list, name0) - } - } - if n.refCount != len(list) { - sort.Strings(list) - return fmt.Errorf("node at name %q has refCount %d but locked self-or-descendents are %q (len=%d)", - name, n.refCount, list, len(list)) - } - - // A node n is in m.byToken if it has a non-empty token. - if n.token != "" { - if _, ok := m.byToken[n.token]; !ok { - return fmt.Errorf("node at name %q has token %q but not in m.byToken", name, n.token) - } - } - - // A node n is in m.byExpiry if it has a non-negative byExpiryIndex. - if n.byExpiryIndex >= 0 { - if n.byExpiryIndex >= len(m.byExpiry) { - return fmt.Errorf("node at name %q has byExpiryIndex %d but m.byExpiry has length %d", name, n.byExpiryIndex, len(m.byExpiry)) - } - if n != m.byExpiry[n.byExpiryIndex] { - return fmt.Errorf("node at name %q has byExpiryIndex %d but that indexes a different node", name, n.byExpiryIndex) - } - } - } - - for token, n := range m.byToken { - // The map keys should be consistent with the node's copy of the key. - if n.token != token { - return fmt.Errorf("node token %q != byToken map key %q", n.token, token) - } - - // Every node in m.byToken is in m.byName. - if _, ok := m.byName[n.details.Root]; !ok { - return fmt.Errorf("node at name %q in m.byToken but not in m.byName", n.details.Root) - } - } - - for i, n := range m.byExpiry { - // The slice indices should be consistent with the node's copy of the index. - if n.byExpiryIndex != i { - return fmt.Errorf("node byExpiryIndex %d != byExpiry slice index %d", n.byExpiryIndex, i) - } - - // Every node in m.byExpiry is in m.byName. - if _, ok := m.byName[n.details.Root]; !ok { - return fmt.Errorf("node at name %q in m.byExpiry but not in m.byName", n.details.Root) - } - - // No node in m.byExpiry should be held. - if n.held { - return fmt.Errorf("node at name %q in m.byExpiry is held", n.details.Root) - } - } - return nil -} - -func TestParseTimeout(t *testing.T) { - testCases := []struct { - s string - want time.Duration - wantErr error - }{{ - "", - infiniteTimeout, - nil, - }, { - "Infinite", - infiniteTimeout, - nil, - }, { - "Infinitesimal", - 0, - errInvalidTimeout, - }, { - "infinite", - 0, - errInvalidTimeout, - }, { - "Second-0", - 0 * time.Second, - nil, - }, { - "Second-123", - 123 * time.Second, - nil, - }, { - " Second-456 ", - 456 * time.Second, - nil, - }, { - "Second-4100000000", - 4100000000 * time.Second, - nil, - }, { - "junk", - 0, - errInvalidTimeout, - }, { - "Second-", - 0, - errInvalidTimeout, - }, { - "Second--1", - 0, - errInvalidTimeout, - }, { - "Second--123", - 0, - errInvalidTimeout, - }, { - "Second-+123", - 0, - errInvalidTimeout, - }, { - "Second-0x123", - 0, - errInvalidTimeout, - }, { - "second-123", - 0, - errInvalidTimeout, - }, { - "Second-4294967295", - 4294967295 * time.Second, - nil, - }, { - // Section 10.7 says that "The timeout value for TimeType "Second" - // must not be greater than 2^32-1." - "Second-4294967296", - 0, - errInvalidTimeout, - }, { - // This test case comes from section 9.10.9 of the spec. It says, - // - // "In this request, the client has specified that it desires an - // infinite-length lock, if available, otherwise a timeout of 4.1 - // billion seconds, if available." - // - // The Go WebDAV package always supports infinite length locks, - // and ignores the fallback after the comma. - "Infinite, Second-4100000000", - infiniteTimeout, - nil, - }} - - for _, tc := range testCases { - got, gotErr := parseTimeout(tc.s) - if got != tc.want || gotErr != tc.wantErr { - t.Errorf("parsing %q:\ngot %v, %v\nwant %v, %v", tc.s, got, gotErr, tc.want, tc.wantErr) - } - } -} diff --git a/vendor/golang.org/x/net/webdav/prop.go b/vendor/golang.org/x/net/webdav/prop.go deleted file mode 100644 index e36a3b31d..000000000 --- a/vendor/golang.org/x/net/webdav/prop.go +++ /dev/null @@ -1,418 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webdav - -import ( - "bytes" - "encoding/xml" - "fmt" - "io" - "mime" - "net/http" - "os" - "path/filepath" - "strconv" - - "golang.org/x/net/context" -) - -// Proppatch describes a property update instruction as defined in RFC 4918. -// See http://www.webdav.org/specs/rfc4918.html#METHOD_PROPPATCH -type Proppatch struct { - // Remove specifies whether this patch removes properties. If it does not - // remove them, it sets them. - Remove bool - // Props contains the properties to be set or removed. - Props []Property -} - -// Propstat describes a XML propstat element as defined in RFC 4918. -// See http://www.webdav.org/specs/rfc4918.html#ELEMENT_propstat -type Propstat struct { - // Props contains the properties for which Status applies. - Props []Property - - // Status defines the HTTP status code of the properties in Prop. - // Allowed values include, but are not limited to the WebDAV status - // code extensions for HTTP/1.1. - // http://www.webdav.org/specs/rfc4918.html#status.code.extensions.to.http11 - Status int - - // XMLError contains the XML representation of the optional error element. - // XML content within this field must not rely on any predefined - // namespace declarations or prefixes. If empty, the XML error element - // is omitted. - XMLError string - - // ResponseDescription contains the contents of the optional - // responsedescription field. If empty, the XML element is omitted. - ResponseDescription string -} - -// makePropstats returns a slice containing those of x and y whose Props slice -// is non-empty. If both are empty, it returns a slice containing an otherwise -// zero Propstat whose HTTP status code is 200 OK. -func makePropstats(x, y Propstat) []Propstat { - pstats := make([]Propstat, 0, 2) - if len(x.Props) != 0 { - pstats = append(pstats, x) - } - if len(y.Props) != 0 { - pstats = append(pstats, y) - } - if len(pstats) == 0 { - pstats = append(pstats, Propstat{ - Status: http.StatusOK, - }) - } - return pstats -} - -// DeadPropsHolder holds the dead properties of a resource. -// -// Dead properties are those properties that are explicitly defined. In -// comparison, live properties, such as DAV:getcontentlength, are implicitly -// defined by the underlying resource, and cannot be explicitly overridden or -// removed. See the Terminology section of -// http://www.webdav.org/specs/rfc4918.html#rfc.section.3 -// -// There is a whitelist of the names of live properties. This package handles -// all live properties, and will only pass non-whitelisted names to the Patch -// method of DeadPropsHolder implementations. -type DeadPropsHolder interface { - // DeadProps returns a copy of the dead properties held. - DeadProps() (map[xml.Name]Property, error) - - // Patch patches the dead properties held. - // - // Patching is atomic; either all or no patches succeed. It returns (nil, - // non-nil) if an internal server error occurred, otherwise the Propstats - // collectively contain one Property for each proposed patch Property. If - // all patches succeed, Patch returns a slice of length one and a Propstat - // element with a 200 OK HTTP status code. If none succeed, for reasons - // other than an internal server error, no Propstat has status 200 OK. - // - // For more details on when various HTTP status codes apply, see - // http://www.webdav.org/specs/rfc4918.html#PROPPATCH-status - Patch([]Proppatch) ([]Propstat, error) -} - -// liveProps contains all supported, protected DAV: properties. -var liveProps = map[xml.Name]struct { - // findFn implements the propfind function of this property. If nil, - // it indicates a hidden property. - findFn func(context.Context, FileSystem, LockSystem, string, os.FileInfo) (string, error) - // dir is true if the property applies to directories. - dir bool -}{ - {Space: "DAV:", Local: "resourcetype"}: { - findFn: findResourceType, - dir: true, - }, - {Space: "DAV:", Local: "displayname"}: { - findFn: findDisplayName, - dir: true, - }, - {Space: "DAV:", Local: "getcontentlength"}: { - findFn: findContentLength, - dir: false, - }, - {Space: "DAV:", Local: "getlastmodified"}: { - findFn: findLastModified, - // http://webdav.org/specs/rfc4918.html#PROPERTY_getlastmodified - // suggests that getlastmodified should only apply to GETable - // resources, and this package does not support GET on directories. - // - // Nonetheless, some WebDAV clients expect child directories to be - // sortable by getlastmodified date, so this value is true, not false. - // See golang.org/issue/15334. - dir: true, - }, - {Space: "DAV:", Local: "creationdate"}: { - findFn: nil, - dir: false, - }, - {Space: "DAV:", Local: "getcontentlanguage"}: { - findFn: nil, - dir: false, - }, - {Space: "DAV:", Local: "getcontenttype"}: { - findFn: findContentType, - dir: false, - }, - {Space: "DAV:", Local: "getetag"}: { - findFn: findETag, - // findETag implements ETag as the concatenated hex values of a file's - // modification time and size. This is not a reliable synchronization - // mechanism for directories, so we do not advertise getetag for DAV - // collections. - dir: false, - }, - - // TODO: The lockdiscovery property requires LockSystem to list the - // active locks on a resource. - {Space: "DAV:", Local: "lockdiscovery"}: {}, - {Space: "DAV:", Local: "supportedlock"}: { - findFn: findSupportedLock, - dir: true, - }, -} - -// TODO(nigeltao) merge props and allprop? - -// Props returns the status of the properties named pnames for resource name. -// -// Each Propstat has a unique status and each property name will only be part -// of one Propstat element. -func props(ctx context.Context, fs FileSystem, ls LockSystem, name string, pnames []xml.Name) ([]Propstat, error) { - f, err := fs.OpenFile(ctx, name, os.O_RDONLY, 0) - if err != nil { - return nil, err - } - defer f.Close() - fi, err := f.Stat() - if err != nil { - return nil, err - } - isDir := fi.IsDir() - - var deadProps map[xml.Name]Property - if dph, ok := f.(DeadPropsHolder); ok { - deadProps, err = dph.DeadProps() - if err != nil { - return nil, err - } - } - - pstatOK := Propstat{Status: http.StatusOK} - pstatNotFound := Propstat{Status: http.StatusNotFound} - for _, pn := range pnames { - // If this file has dead properties, check if they contain pn. - if dp, ok := deadProps[pn]; ok { - pstatOK.Props = append(pstatOK.Props, dp) - continue - } - // Otherwise, it must either be a live property or we don't know it. - if prop := liveProps[pn]; prop.findFn != nil && (prop.dir || !isDir) { - innerXML, err := prop.findFn(ctx, fs, ls, name, fi) - if err != nil { - return nil, err - } - pstatOK.Props = append(pstatOK.Props, Property{ - XMLName: pn, - InnerXML: []byte(innerXML), - }) - } else { - pstatNotFound.Props = append(pstatNotFound.Props, Property{ - XMLName: pn, - }) - } - } - return makePropstats(pstatOK, pstatNotFound), nil -} - -// Propnames returns the property names defined for resource name. -func propnames(ctx context.Context, fs FileSystem, ls LockSystem, name string) ([]xml.Name, error) { - f, err := fs.OpenFile(ctx, name, os.O_RDONLY, 0) - if err != nil { - return nil, err - } - defer f.Close() - fi, err := f.Stat() - if err != nil { - return nil, err - } - isDir := fi.IsDir() - - var deadProps map[xml.Name]Property - if dph, ok := f.(DeadPropsHolder); ok { - deadProps, err = dph.DeadProps() - if err != nil { - return nil, err - } - } - - pnames := make([]xml.Name, 0, len(liveProps)+len(deadProps)) - for pn, prop := range liveProps { - if prop.findFn != nil && (prop.dir || !isDir) { - pnames = append(pnames, pn) - } - } - for pn := range deadProps { - pnames = append(pnames, pn) - } - return pnames, nil -} - -// Allprop returns the properties defined for resource name and the properties -// named in include. -// -// Note that RFC 4918 defines 'allprop' to return the DAV: properties defined -// within the RFC plus dead properties. Other live properties should only be -// returned if they are named in 'include'. -// -// See http://www.webdav.org/specs/rfc4918.html#METHOD_PROPFIND -func allprop(ctx context.Context, fs FileSystem, ls LockSystem, name string, include []xml.Name) ([]Propstat, error) { - pnames, err := propnames(ctx, fs, ls, name) - if err != nil { - return nil, err - } - // Add names from include if they are not already covered in pnames. - nameset := make(map[xml.Name]bool) - for _, pn := range pnames { - nameset[pn] = true - } - for _, pn := range include { - if !nameset[pn] { - pnames = append(pnames, pn) - } - } - return props(ctx, fs, ls, name, pnames) -} - -// Patch patches the properties of resource name. The return values are -// constrained in the same manner as DeadPropsHolder.Patch. -func patch(ctx context.Context, fs FileSystem, ls LockSystem, name string, patches []Proppatch) ([]Propstat, error) { - conflict := false -loop: - for _, patch := range patches { - for _, p := range patch.Props { - if _, ok := liveProps[p.XMLName]; ok { - conflict = true - break loop - } - } - } - if conflict { - pstatForbidden := Propstat{ - Status: http.StatusForbidden, - XMLError: ``, - } - pstatFailedDep := Propstat{ - Status: StatusFailedDependency, - } - for _, patch := range patches { - for _, p := range patch.Props { - if _, ok := liveProps[p.XMLName]; ok { - pstatForbidden.Props = append(pstatForbidden.Props, Property{XMLName: p.XMLName}) - } else { - pstatFailedDep.Props = append(pstatFailedDep.Props, Property{XMLName: p.XMLName}) - } - } - } - return makePropstats(pstatForbidden, pstatFailedDep), nil - } - - f, err := fs.OpenFile(ctx, name, os.O_RDWR, 0) - if err != nil { - return nil, err - } - defer f.Close() - if dph, ok := f.(DeadPropsHolder); ok { - ret, err := dph.Patch(patches) - if err != nil { - return nil, err - } - // http://www.webdav.org/specs/rfc4918.html#ELEMENT_propstat says that - // "The contents of the prop XML element must only list the names of - // properties to which the result in the status element applies." - for _, pstat := range ret { - for i, p := range pstat.Props { - pstat.Props[i] = Property{XMLName: p.XMLName} - } - } - return ret, nil - } - // The file doesn't implement the optional DeadPropsHolder interface, so - // all patches are forbidden. - pstat := Propstat{Status: http.StatusForbidden} - for _, patch := range patches { - for _, p := range patch.Props { - pstat.Props = append(pstat.Props, Property{XMLName: p.XMLName}) - } - } - return []Propstat{pstat}, nil -} - -func escapeXML(s string) string { - for i := 0; i < len(s); i++ { - // As an optimization, if s contains only ASCII letters, digits or a - // few special characters, the escaped value is s itself and we don't - // need to allocate a buffer and convert between string and []byte. - switch c := s[i]; { - case c == ' ' || c == '_' || - ('+' <= c && c <= '9') || // Digits as well as + , - . and / - ('A' <= c && c <= 'Z') || - ('a' <= c && c <= 'z'): - continue - } - // Otherwise, go through the full escaping process. - var buf bytes.Buffer - xml.EscapeText(&buf, []byte(s)) - return buf.String() - } - return s -} - -func findResourceType(ctx context.Context, fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) { - if fi.IsDir() { - return ``, nil - } - return "", nil -} - -func findDisplayName(ctx context.Context, fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) { - if slashClean(name) == "/" { - // Hide the real name of a possibly prefixed root directory. - return "", nil - } - return escapeXML(fi.Name()), nil -} - -func findContentLength(ctx context.Context, fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) { - return strconv.FormatInt(fi.Size(), 10), nil -} - -func findLastModified(ctx context.Context, fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) { - return fi.ModTime().Format(http.TimeFormat), nil -} - -func findContentType(ctx context.Context, fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) { - f, err := fs.OpenFile(ctx, name, os.O_RDONLY, 0) - if err != nil { - return "", err - } - defer f.Close() - // This implementation is based on serveContent's code in the standard net/http package. - ctype := mime.TypeByExtension(filepath.Ext(name)) - if ctype != "" { - return ctype, nil - } - // Read a chunk to decide between utf-8 text and binary. - var buf [512]byte - n, err := io.ReadFull(f, buf[:]) - if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF { - return "", err - } - ctype = http.DetectContentType(buf[:n]) - // Rewind file. - _, err = f.Seek(0, os.SEEK_SET) - return ctype, err -} - -func findETag(ctx context.Context, fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) { - // The Apache http 2.4 web server by default concatenates the - // modification time and size of a file. We replicate the heuristic - // with nanosecond granularity. - return fmt.Sprintf(`"%x%x"`, fi.ModTime().UnixNano(), fi.Size()), nil -} - -func findSupportedLock(ctx context.Context, fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) { - return `` + - `` + - `` + - `` + - ``, nil -} diff --git a/vendor/golang.org/x/net/webdav/prop_test.go b/vendor/golang.org/x/net/webdav/prop_test.go deleted file mode 100644 index 57d0e826f..000000000 --- a/vendor/golang.org/x/net/webdav/prop_test.go +++ /dev/null @@ -1,613 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webdav - -import ( - "encoding/xml" - "fmt" - "net/http" - "os" - "reflect" - "sort" - "testing" - - "golang.org/x/net/context" -) - -func TestMemPS(t *testing.T) { - ctx := context.Background() - // calcProps calculates the getlastmodified and getetag DAV: property - // values in pstats for resource name in file-system fs. - calcProps := func(name string, fs FileSystem, ls LockSystem, pstats []Propstat) error { - fi, err := fs.Stat(ctx, name) - if err != nil { - return err - } - for _, pst := range pstats { - for i, p := range pst.Props { - switch p.XMLName { - case xml.Name{Space: "DAV:", Local: "getlastmodified"}: - p.InnerXML = []byte(fi.ModTime().Format(http.TimeFormat)) - pst.Props[i] = p - case xml.Name{Space: "DAV:", Local: "getetag"}: - if fi.IsDir() { - continue - } - etag, err := findETag(ctx, fs, ls, name, fi) - if err != nil { - return err - } - p.InnerXML = []byte(etag) - pst.Props[i] = p - } - } - } - return nil - } - - const ( - lockEntry = `` + - `` + - `` + - `` + - `` - statForbiddenError = `` - ) - - type propOp struct { - op string - name string - pnames []xml.Name - patches []Proppatch - wantPnames []xml.Name - wantPropstats []Propstat - } - - testCases := []struct { - desc string - noDeadProps bool - buildfs []string - propOp []propOp - }{{ - desc: "propname", - buildfs: []string{"mkdir /dir", "touch /file"}, - propOp: []propOp{{ - op: "propname", - name: "/dir", - wantPnames: []xml.Name{ - {Space: "DAV:", Local: "resourcetype"}, - {Space: "DAV:", Local: "displayname"}, - {Space: "DAV:", Local: "supportedlock"}, - {Space: "DAV:", Local: "getlastmodified"}, - }, - }, { - op: "propname", - name: "/file", - wantPnames: []xml.Name{ - {Space: "DAV:", Local: "resourcetype"}, - {Space: "DAV:", Local: "displayname"}, - {Space: "DAV:", Local: "getcontentlength"}, - {Space: "DAV:", Local: "getlastmodified"}, - {Space: "DAV:", Local: "getcontenttype"}, - {Space: "DAV:", Local: "getetag"}, - {Space: "DAV:", Local: "supportedlock"}, - }, - }}, - }, { - desc: "allprop dir and file", - buildfs: []string{"mkdir /dir", "write /file foobarbaz"}, - propOp: []propOp{{ - op: "allprop", - name: "/dir", - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "resourcetype"}, - InnerXML: []byte(``), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "displayname"}, - InnerXML: []byte("dir"), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getlastmodified"}, - InnerXML: nil, // Calculated during test. - }, { - XMLName: xml.Name{Space: "DAV:", Local: "supportedlock"}, - InnerXML: []byte(lockEntry), - }}, - }}, - }, { - op: "allprop", - name: "/file", - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "resourcetype"}, - InnerXML: []byte(""), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "displayname"}, - InnerXML: []byte("file"), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getcontentlength"}, - InnerXML: []byte("9"), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getlastmodified"}, - InnerXML: nil, // Calculated during test. - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getcontenttype"}, - InnerXML: []byte("text/plain; charset=utf-8"), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getetag"}, - InnerXML: nil, // Calculated during test. - }, { - XMLName: xml.Name{Space: "DAV:", Local: "supportedlock"}, - InnerXML: []byte(lockEntry), - }}, - }}, - }, { - op: "allprop", - name: "/file", - pnames: []xml.Name{ - {"DAV:", "resourcetype"}, - {"foo", "bar"}, - }, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "resourcetype"}, - InnerXML: []byte(""), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "displayname"}, - InnerXML: []byte("file"), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getcontentlength"}, - InnerXML: []byte("9"), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getlastmodified"}, - InnerXML: nil, // Calculated during test. - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getcontenttype"}, - InnerXML: []byte("text/plain; charset=utf-8"), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getetag"}, - InnerXML: nil, // Calculated during test. - }, { - XMLName: xml.Name{Space: "DAV:", Local: "supportedlock"}, - InnerXML: []byte(lockEntry), - }}}, { - Status: http.StatusNotFound, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}}, - }, - }}, - }, { - desc: "propfind DAV:resourcetype", - buildfs: []string{"mkdir /dir", "touch /file"}, - propOp: []propOp{{ - op: "propfind", - name: "/dir", - pnames: []xml.Name{{"DAV:", "resourcetype"}}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "resourcetype"}, - InnerXML: []byte(``), - }}, - }}, - }, { - op: "propfind", - name: "/file", - pnames: []xml.Name{{"DAV:", "resourcetype"}}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "resourcetype"}, - InnerXML: []byte(""), - }}, - }}, - }}, - }, { - desc: "propfind unsupported DAV properties", - buildfs: []string{"mkdir /dir"}, - propOp: []propOp{{ - op: "propfind", - name: "/dir", - pnames: []xml.Name{{"DAV:", "getcontentlanguage"}}, - wantPropstats: []Propstat{{ - Status: http.StatusNotFound, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "getcontentlanguage"}, - }}, - }}, - }, { - op: "propfind", - name: "/dir", - pnames: []xml.Name{{"DAV:", "creationdate"}}, - wantPropstats: []Propstat{{ - Status: http.StatusNotFound, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "creationdate"}, - }}, - }}, - }}, - }, { - desc: "propfind getetag for files but not for directories", - buildfs: []string{"mkdir /dir", "touch /file"}, - propOp: []propOp{{ - op: "propfind", - name: "/dir", - pnames: []xml.Name{{"DAV:", "getetag"}}, - wantPropstats: []Propstat{{ - Status: http.StatusNotFound, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "getetag"}, - }}, - }}, - }, { - op: "propfind", - name: "/file", - pnames: []xml.Name{{"DAV:", "getetag"}}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "getetag"}, - InnerXML: nil, // Calculated during test. - }}, - }}, - }}, - }, { - desc: "proppatch property on no-dead-properties file system", - buildfs: []string{"mkdir /dir"}, - noDeadProps: true, - propOp: []propOp{{ - op: "proppatch", - name: "/dir", - patches: []Proppatch{{ - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - wantPropstats: []Propstat{{ - Status: http.StatusForbidden, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - }, { - op: "proppatch", - name: "/dir", - patches: []Proppatch{{ - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "getetag"}, - }}, - }}, - wantPropstats: []Propstat{{ - Status: http.StatusForbidden, - XMLError: statForbiddenError, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "getetag"}, - }}, - }}, - }}, - }, { - desc: "proppatch dead property", - buildfs: []string{"mkdir /dir"}, - propOp: []propOp{{ - op: "proppatch", - name: "/dir", - patches: []Proppatch{{ - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - InnerXML: []byte("baz"), - }}, - }}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - }, { - op: "propfind", - name: "/dir", - pnames: []xml.Name{{Space: "foo", Local: "bar"}}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - InnerXML: []byte("baz"), - }}, - }}, - }}, - }, { - desc: "proppatch dead property with failed dependency", - buildfs: []string{"mkdir /dir"}, - propOp: []propOp{{ - op: "proppatch", - name: "/dir", - patches: []Proppatch{{ - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - InnerXML: []byte("baz"), - }}, - }, { - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "displayname"}, - InnerXML: []byte("xxx"), - }}, - }}, - wantPropstats: []Propstat{{ - Status: http.StatusForbidden, - XMLError: statForbiddenError, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "displayname"}, - }}, - }, { - Status: StatusFailedDependency, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - }, { - op: "propfind", - name: "/dir", - pnames: []xml.Name{{Space: "foo", Local: "bar"}}, - wantPropstats: []Propstat{{ - Status: http.StatusNotFound, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - }}, - }, { - desc: "proppatch remove dead property", - buildfs: []string{"mkdir /dir"}, - propOp: []propOp{{ - op: "proppatch", - name: "/dir", - patches: []Proppatch{{ - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - InnerXML: []byte("baz"), - }, { - XMLName: xml.Name{Space: "spam", Local: "ham"}, - InnerXML: []byte("eggs"), - }}, - }}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }, { - XMLName: xml.Name{Space: "spam", Local: "ham"}, - }}, - }}, - }, { - op: "propfind", - name: "/dir", - pnames: []xml.Name{ - {Space: "foo", Local: "bar"}, - {Space: "spam", Local: "ham"}, - }, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - InnerXML: []byte("baz"), - }, { - XMLName: xml.Name{Space: "spam", Local: "ham"}, - InnerXML: []byte("eggs"), - }}, - }}, - }, { - op: "proppatch", - name: "/dir", - patches: []Proppatch{{ - Remove: true, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - }, { - op: "propfind", - name: "/dir", - pnames: []xml.Name{ - {Space: "foo", Local: "bar"}, - {Space: "spam", Local: "ham"}, - }, - wantPropstats: []Propstat{{ - Status: http.StatusNotFound, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }, { - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "spam", Local: "ham"}, - InnerXML: []byte("eggs"), - }}, - }}, - }}, - }, { - desc: "propname with dead property", - buildfs: []string{"touch /file"}, - propOp: []propOp{{ - op: "proppatch", - name: "/file", - patches: []Proppatch{{ - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - InnerXML: []byte("baz"), - }}, - }}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - }, { - op: "propname", - name: "/file", - wantPnames: []xml.Name{ - {Space: "DAV:", Local: "resourcetype"}, - {Space: "DAV:", Local: "displayname"}, - {Space: "DAV:", Local: "getcontentlength"}, - {Space: "DAV:", Local: "getlastmodified"}, - {Space: "DAV:", Local: "getcontenttype"}, - {Space: "DAV:", Local: "getetag"}, - {Space: "DAV:", Local: "supportedlock"}, - {Space: "foo", Local: "bar"}, - }, - }}, - }, { - desc: "proppatch remove unknown dead property", - buildfs: []string{"mkdir /dir"}, - propOp: []propOp{{ - op: "proppatch", - name: "/dir", - patches: []Proppatch{{ - Remove: true, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - }}, - }, { - desc: "bad: propfind unknown property", - buildfs: []string{"mkdir /dir"}, - propOp: []propOp{{ - op: "propfind", - name: "/dir", - pnames: []xml.Name{{"foo:", "bar"}}, - wantPropstats: []Propstat{{ - Status: http.StatusNotFound, - Props: []Property{{ - XMLName: xml.Name{Space: "foo:", Local: "bar"}, - }}, - }}, - }}, - }} - - for _, tc := range testCases { - fs, err := buildTestFS(tc.buildfs) - if err != nil { - t.Fatalf("%s: cannot create test filesystem: %v", tc.desc, err) - } - if tc.noDeadProps { - fs = noDeadPropsFS{fs} - } - ls := NewMemLS() - for _, op := range tc.propOp { - desc := fmt.Sprintf("%s: %s %s", tc.desc, op.op, op.name) - if err = calcProps(op.name, fs, ls, op.wantPropstats); err != nil { - t.Fatalf("%s: calcProps: %v", desc, err) - } - - // Call property system. - var propstats []Propstat - switch op.op { - case "propname": - pnames, err := propnames(ctx, fs, ls, op.name) - if err != nil { - t.Errorf("%s: got error %v, want nil", desc, err) - continue - } - sort.Sort(byXMLName(pnames)) - sort.Sort(byXMLName(op.wantPnames)) - if !reflect.DeepEqual(pnames, op.wantPnames) { - t.Errorf("%s: pnames\ngot %q\nwant %q", desc, pnames, op.wantPnames) - } - continue - case "allprop": - propstats, err = allprop(ctx, fs, ls, op.name, op.pnames) - case "propfind": - propstats, err = props(ctx, fs, ls, op.name, op.pnames) - case "proppatch": - propstats, err = patch(ctx, fs, ls, op.name, op.patches) - default: - t.Fatalf("%s: %s not implemented", desc, op.op) - } - if err != nil { - t.Errorf("%s: got error %v, want nil", desc, err) - continue - } - // Compare return values from allprop, propfind or proppatch. - for _, pst := range propstats { - sort.Sort(byPropname(pst.Props)) - } - for _, pst := range op.wantPropstats { - sort.Sort(byPropname(pst.Props)) - } - sort.Sort(byStatus(propstats)) - sort.Sort(byStatus(op.wantPropstats)) - if !reflect.DeepEqual(propstats, op.wantPropstats) { - t.Errorf("%s: propstat\ngot %q\nwant %q", desc, propstats, op.wantPropstats) - } - } - } -} - -func cmpXMLName(a, b xml.Name) bool { - if a.Space != b.Space { - return a.Space < b.Space - } - return a.Local < b.Local -} - -type byXMLName []xml.Name - -func (b byXMLName) Len() int { return len(b) } -func (b byXMLName) Swap(i, j int) { b[i], b[j] = b[j], b[i] } -func (b byXMLName) Less(i, j int) bool { return cmpXMLName(b[i], b[j]) } - -type byPropname []Property - -func (b byPropname) Len() int { return len(b) } -func (b byPropname) Swap(i, j int) { b[i], b[j] = b[j], b[i] } -func (b byPropname) Less(i, j int) bool { return cmpXMLName(b[i].XMLName, b[j].XMLName) } - -type byStatus []Propstat - -func (b byStatus) Len() int { return len(b) } -func (b byStatus) Swap(i, j int) { b[i], b[j] = b[j], b[i] } -func (b byStatus) Less(i, j int) bool { return b[i].Status < b[j].Status } - -type noDeadPropsFS struct { - FileSystem -} - -func (fs noDeadPropsFS) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (File, error) { - f, err := fs.FileSystem.OpenFile(ctx, name, flag, perm) - if err != nil { - return nil, err - } - return noDeadPropsFile{f}, nil -} - -// noDeadPropsFile wraps a File but strips any optional DeadPropsHolder methods -// provided by the underlying File implementation. -type noDeadPropsFile struct { - f File -} - -func (f noDeadPropsFile) Close() error { return f.f.Close() } -func (f noDeadPropsFile) Read(p []byte) (int, error) { return f.f.Read(p) } -func (f noDeadPropsFile) Readdir(count int) ([]os.FileInfo, error) { return f.f.Readdir(count) } -func (f noDeadPropsFile) Seek(off int64, whence int) (int64, error) { return f.f.Seek(off, whence) } -func (f noDeadPropsFile) Stat() (os.FileInfo, error) { return f.f.Stat() } -func (f noDeadPropsFile) Write(p []byte) (int, error) { return f.f.Write(p) } diff --git a/vendor/golang.org/x/net/webdav/webdav.go b/vendor/golang.org/x/net/webdav/webdav.go deleted file mode 100644 index 7b56687fc..000000000 --- a/vendor/golang.org/x/net/webdav/webdav.go +++ /dev/null @@ -1,702 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package webdav provides a WebDAV server implementation. -package webdav // import "golang.org/x/net/webdav" - -import ( - "errors" - "fmt" - "io" - "net/http" - "net/url" - "os" - "path" - "strings" - "time" -) - -type Handler struct { - // Prefix is the URL path prefix to strip from WebDAV resource paths. - Prefix string - // FileSystem is the virtual file system. - FileSystem FileSystem - // LockSystem is the lock management system. - LockSystem LockSystem - // Logger is an optional error logger. If non-nil, it will be called - // for all HTTP requests. - Logger func(*http.Request, error) -} - -func (h *Handler) stripPrefix(p string) (string, int, error) { - if h.Prefix == "" { - return p, http.StatusOK, nil - } - if r := strings.TrimPrefix(p, h.Prefix); len(r) < len(p) { - return r, http.StatusOK, nil - } - return p, http.StatusNotFound, errPrefixMismatch -} - -func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - status, err := http.StatusBadRequest, errUnsupportedMethod - if h.FileSystem == nil { - status, err = http.StatusInternalServerError, errNoFileSystem - } else if h.LockSystem == nil { - status, err = http.StatusInternalServerError, errNoLockSystem - } else { - switch r.Method { - case "OPTIONS": - status, err = h.handleOptions(w, r) - case "GET", "HEAD", "POST": - status, err = h.handleGetHeadPost(w, r) - case "DELETE": - status, err = h.handleDelete(w, r) - case "PUT": - status, err = h.handlePut(w, r) - case "MKCOL": - status, err = h.handleMkcol(w, r) - case "COPY", "MOVE": - status, err = h.handleCopyMove(w, r) - case "LOCK": - status, err = h.handleLock(w, r) - case "UNLOCK": - status, err = h.handleUnlock(w, r) - case "PROPFIND": - status, err = h.handlePropfind(w, r) - case "PROPPATCH": - status, err = h.handleProppatch(w, r) - } - } - - if status != 0 { - w.WriteHeader(status) - if status != http.StatusNoContent { - w.Write([]byte(StatusText(status))) - } - } - if h.Logger != nil { - h.Logger(r, err) - } -} - -func (h *Handler) lock(now time.Time, root string) (token string, status int, err error) { - token, err = h.LockSystem.Create(now, LockDetails{ - Root: root, - Duration: infiniteTimeout, - ZeroDepth: true, - }) - if err != nil { - if err == ErrLocked { - return "", StatusLocked, err - } - return "", http.StatusInternalServerError, err - } - return token, 0, nil -} - -func (h *Handler) confirmLocks(r *http.Request, src, dst string) (release func(), status int, err error) { - hdr := r.Header.Get("If") - if hdr == "" { - // An empty If header means that the client hasn't previously created locks. - // Even if this client doesn't care about locks, we still need to check that - // the resources aren't locked by another client, so we create temporary - // locks that would conflict with another client's locks. These temporary - // locks are unlocked at the end of the HTTP request. - now, srcToken, dstToken := time.Now(), "", "" - if src != "" { - srcToken, status, err = h.lock(now, src) - if err != nil { - return nil, status, err - } - } - if dst != "" { - dstToken, status, err = h.lock(now, dst) - if err != nil { - if srcToken != "" { - h.LockSystem.Unlock(now, srcToken) - } - return nil, status, err - } - } - - return func() { - if dstToken != "" { - h.LockSystem.Unlock(now, dstToken) - } - if srcToken != "" { - h.LockSystem.Unlock(now, srcToken) - } - }, 0, nil - } - - ih, ok := parseIfHeader(hdr) - if !ok { - return nil, http.StatusBadRequest, errInvalidIfHeader - } - // ih is a disjunction (OR) of ifLists, so any ifList will do. - for _, l := range ih.lists { - lsrc := l.resourceTag - if lsrc == "" { - lsrc = src - } else { - u, err := url.Parse(lsrc) - if err != nil { - continue - } - if u.Host != r.Host { - continue - } - lsrc, status, err = h.stripPrefix(u.Path) - if err != nil { - return nil, status, err - } - } - release, err = h.LockSystem.Confirm(time.Now(), lsrc, dst, l.conditions...) - if err == ErrConfirmationFailed { - continue - } - if err != nil { - return nil, http.StatusInternalServerError, err - } - return release, 0, nil - } - // Section 10.4.1 says that "If this header is evaluated and all state lists - // fail, then the request must fail with a 412 (Precondition Failed) status." - // We follow the spec even though the cond_put_corrupt_token test case from - // the litmus test warns on seeing a 412 instead of a 423 (Locked). - return nil, http.StatusPreconditionFailed, ErrLocked -} - -func (h *Handler) handleOptions(w http.ResponseWriter, r *http.Request) (status int, err error) { - reqPath, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - ctx := getContext(r) - allow := "OPTIONS, LOCK, PUT, MKCOL" - if fi, err := h.FileSystem.Stat(ctx, reqPath); err == nil { - if fi.IsDir() { - allow = "OPTIONS, LOCK, DELETE, PROPPATCH, COPY, MOVE, UNLOCK, PROPFIND" - } else { - allow = "OPTIONS, LOCK, GET, HEAD, POST, DELETE, PROPPATCH, COPY, MOVE, UNLOCK, PROPFIND, PUT" - } - } - w.Header().Set("Allow", allow) - // http://www.webdav.org/specs/rfc4918.html#dav.compliance.classes - w.Header().Set("DAV", "1, 2") - // http://msdn.microsoft.com/en-au/library/cc250217.aspx - w.Header().Set("MS-Author-Via", "DAV") - return 0, nil -} - -func (h *Handler) handleGetHeadPost(w http.ResponseWriter, r *http.Request) (status int, err error) { - reqPath, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - // TODO: check locks for read-only access?? - ctx := getContext(r) - f, err := h.FileSystem.OpenFile(ctx, reqPath, os.O_RDONLY, 0) - if err != nil { - return http.StatusNotFound, err - } - defer f.Close() - fi, err := f.Stat() - if err != nil { - return http.StatusNotFound, err - } - if fi.IsDir() { - return http.StatusMethodNotAllowed, nil - } - etag, err := findETag(ctx, h.FileSystem, h.LockSystem, reqPath, fi) - if err != nil { - return http.StatusInternalServerError, err - } - w.Header().Set("ETag", etag) - // Let ServeContent determine the Content-Type header. - http.ServeContent(w, r, reqPath, fi.ModTime(), f) - return 0, nil -} - -func (h *Handler) handleDelete(w http.ResponseWriter, r *http.Request) (status int, err error) { - reqPath, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - release, status, err := h.confirmLocks(r, reqPath, "") - if err != nil { - return status, err - } - defer release() - - ctx := getContext(r) - - // TODO: return MultiStatus where appropriate. - - // "godoc os RemoveAll" says that "If the path does not exist, RemoveAll - // returns nil (no error)." WebDAV semantics are that it should return a - // "404 Not Found". We therefore have to Stat before we RemoveAll. - if _, err := h.FileSystem.Stat(ctx, reqPath); err != nil { - if os.IsNotExist(err) { - return http.StatusNotFound, err - } - return http.StatusMethodNotAllowed, err - } - if err := h.FileSystem.RemoveAll(ctx, reqPath); err != nil { - return http.StatusMethodNotAllowed, err - } - return http.StatusNoContent, nil -} - -func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request) (status int, err error) { - reqPath, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - release, status, err := h.confirmLocks(r, reqPath, "") - if err != nil { - return status, err - } - defer release() - // TODO(rost): Support the If-Match, If-None-Match headers? See bradfitz' - // comments in http.checkEtag. - ctx := getContext(r) - - f, err := h.FileSystem.OpenFile(ctx, reqPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) - if err != nil { - return http.StatusNotFound, err - } - _, copyErr := io.Copy(f, r.Body) - fi, statErr := f.Stat() - closeErr := f.Close() - // TODO(rost): Returning 405 Method Not Allowed might not be appropriate. - if copyErr != nil { - return http.StatusMethodNotAllowed, copyErr - } - if statErr != nil { - return http.StatusMethodNotAllowed, statErr - } - if closeErr != nil { - return http.StatusMethodNotAllowed, closeErr - } - etag, err := findETag(ctx, h.FileSystem, h.LockSystem, reqPath, fi) - if err != nil { - return http.StatusInternalServerError, err - } - w.Header().Set("ETag", etag) - return http.StatusCreated, nil -} - -func (h *Handler) handleMkcol(w http.ResponseWriter, r *http.Request) (status int, err error) { - reqPath, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - release, status, err := h.confirmLocks(r, reqPath, "") - if err != nil { - return status, err - } - defer release() - - ctx := getContext(r) - - if r.ContentLength > 0 { - return http.StatusUnsupportedMediaType, nil - } - if err := h.FileSystem.Mkdir(ctx, reqPath, 0777); err != nil { - if os.IsNotExist(err) { - return http.StatusConflict, err - } - return http.StatusMethodNotAllowed, err - } - return http.StatusCreated, nil -} - -func (h *Handler) handleCopyMove(w http.ResponseWriter, r *http.Request) (status int, err error) { - hdr := r.Header.Get("Destination") - if hdr == "" { - return http.StatusBadRequest, errInvalidDestination - } - u, err := url.Parse(hdr) - if err != nil { - return http.StatusBadRequest, errInvalidDestination - } - if u.Host != r.Host { - return http.StatusBadGateway, errInvalidDestination - } - - src, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - - dst, status, err := h.stripPrefix(u.Path) - if err != nil { - return status, err - } - - if dst == "" { - return http.StatusBadGateway, errInvalidDestination - } - if dst == src { - return http.StatusForbidden, errDestinationEqualsSource - } - - ctx := getContext(r) - - if r.Method == "COPY" { - // Section 7.5.1 says that a COPY only needs to lock the destination, - // not both destination and source. Strictly speaking, this is racy, - // even though a COPY doesn't modify the source, if a concurrent - // operation modifies the source. However, the litmus test explicitly - // checks that COPYing a locked-by-another source is OK. - release, status, err := h.confirmLocks(r, "", dst) - if err != nil { - return status, err - } - defer release() - - // Section 9.8.3 says that "The COPY method on a collection without a Depth - // header must act as if a Depth header with value "infinity" was included". - depth := infiniteDepth - if hdr := r.Header.Get("Depth"); hdr != "" { - depth = parseDepth(hdr) - if depth != 0 && depth != infiniteDepth { - // Section 9.8.3 says that "A client may submit a Depth header on a - // COPY on a collection with a value of "0" or "infinity"." - return http.StatusBadRequest, errInvalidDepth - } - } - return copyFiles(ctx, h.FileSystem, src, dst, r.Header.Get("Overwrite") != "F", depth, 0) - } - - release, status, err := h.confirmLocks(r, src, dst) - if err != nil { - return status, err - } - defer release() - - // Section 9.9.2 says that "The MOVE method on a collection must act as if - // a "Depth: infinity" header was used on it. A client must not submit a - // Depth header on a MOVE on a collection with any value but "infinity"." - if hdr := r.Header.Get("Depth"); hdr != "" { - if parseDepth(hdr) != infiniteDepth { - return http.StatusBadRequest, errInvalidDepth - } - } - return moveFiles(ctx, h.FileSystem, src, dst, r.Header.Get("Overwrite") == "T") -} - -func (h *Handler) handleLock(w http.ResponseWriter, r *http.Request) (retStatus int, retErr error) { - duration, err := parseTimeout(r.Header.Get("Timeout")) - if err != nil { - return http.StatusBadRequest, err - } - li, status, err := readLockInfo(r.Body) - if err != nil { - return status, err - } - - ctx := getContext(r) - token, ld, now, created := "", LockDetails{}, time.Now(), false - if li == (lockInfo{}) { - // An empty lockInfo means to refresh the lock. - ih, ok := parseIfHeader(r.Header.Get("If")) - if !ok { - return http.StatusBadRequest, errInvalidIfHeader - } - if len(ih.lists) == 1 && len(ih.lists[0].conditions) == 1 { - token = ih.lists[0].conditions[0].Token - } - if token == "" { - return http.StatusBadRequest, errInvalidLockToken - } - ld, err = h.LockSystem.Refresh(now, token, duration) - if err != nil { - if err == ErrNoSuchLock { - return http.StatusPreconditionFailed, err - } - return http.StatusInternalServerError, err - } - - } else { - // Section 9.10.3 says that "If no Depth header is submitted on a LOCK request, - // then the request MUST act as if a "Depth:infinity" had been submitted." - depth := infiniteDepth - if hdr := r.Header.Get("Depth"); hdr != "" { - depth = parseDepth(hdr) - if depth != 0 && depth != infiniteDepth { - // Section 9.10.3 says that "Values other than 0 or infinity must not be - // used with the Depth header on a LOCK method". - return http.StatusBadRequest, errInvalidDepth - } - } - reqPath, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - ld = LockDetails{ - Root: reqPath, - Duration: duration, - OwnerXML: li.Owner.InnerXML, - ZeroDepth: depth == 0, - } - token, err = h.LockSystem.Create(now, ld) - if err != nil { - if err == ErrLocked { - return StatusLocked, err - } - return http.StatusInternalServerError, err - } - defer func() { - if retErr != nil { - h.LockSystem.Unlock(now, token) - } - }() - - // Create the resource if it didn't previously exist. - if _, err := h.FileSystem.Stat(ctx, reqPath); err != nil { - f, err := h.FileSystem.OpenFile(ctx, reqPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) - if err != nil { - // TODO: detect missing intermediate dirs and return http.StatusConflict? - return http.StatusInternalServerError, err - } - f.Close() - created = true - } - - // http://www.webdav.org/specs/rfc4918.html#HEADER_Lock-Token says that the - // Lock-Token value is a Coded-URL. We add angle brackets. - w.Header().Set("Lock-Token", "<"+token+">") - } - - w.Header().Set("Content-Type", "application/xml; charset=utf-8") - if created { - // This is "w.WriteHeader(http.StatusCreated)" and not "return - // http.StatusCreated, nil" because we write our own (XML) response to w - // and Handler.ServeHTTP would otherwise write "Created". - w.WriteHeader(http.StatusCreated) - } - writeLockInfo(w, token, ld) - return 0, nil -} - -func (h *Handler) handleUnlock(w http.ResponseWriter, r *http.Request) (status int, err error) { - // http://www.webdav.org/specs/rfc4918.html#HEADER_Lock-Token says that the - // Lock-Token value is a Coded-URL. We strip its angle brackets. - t := r.Header.Get("Lock-Token") - if len(t) < 2 || t[0] != '<' || t[len(t)-1] != '>' { - return http.StatusBadRequest, errInvalidLockToken - } - t = t[1 : len(t)-1] - - switch err = h.LockSystem.Unlock(time.Now(), t); err { - case nil: - return http.StatusNoContent, err - case ErrForbidden: - return http.StatusForbidden, err - case ErrLocked: - return StatusLocked, err - case ErrNoSuchLock: - return http.StatusConflict, err - default: - return http.StatusInternalServerError, err - } -} - -func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) (status int, err error) { - reqPath, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - ctx := getContext(r) - fi, err := h.FileSystem.Stat(ctx, reqPath) - if err != nil { - if os.IsNotExist(err) { - return http.StatusNotFound, err - } - return http.StatusMethodNotAllowed, err - } - depth := infiniteDepth - if hdr := r.Header.Get("Depth"); hdr != "" { - depth = parseDepth(hdr) - if depth == invalidDepth { - return http.StatusBadRequest, errInvalidDepth - } - } - pf, status, err := readPropfind(r.Body) - if err != nil { - return status, err - } - - mw := multistatusWriter{w: w} - - walkFn := func(reqPath string, info os.FileInfo, err error) error { - if err != nil { - return err - } - var pstats []Propstat - if pf.Propname != nil { - pnames, err := propnames(ctx, h.FileSystem, h.LockSystem, reqPath) - if err != nil { - return err - } - pstat := Propstat{Status: http.StatusOK} - for _, xmlname := range pnames { - pstat.Props = append(pstat.Props, Property{XMLName: xmlname}) - } - pstats = append(pstats, pstat) - } else if pf.Allprop != nil { - pstats, err = allprop(ctx, h.FileSystem, h.LockSystem, reqPath, pf.Prop) - } else { - pstats, err = props(ctx, h.FileSystem, h.LockSystem, reqPath, pf.Prop) - } - if err != nil { - return err - } - return mw.write(makePropstatResponse(path.Join(h.Prefix, reqPath), pstats)) - } - - walkErr := walkFS(ctx, h.FileSystem, depth, reqPath, fi, walkFn) - closeErr := mw.close() - if walkErr != nil { - return http.StatusInternalServerError, walkErr - } - if closeErr != nil { - return http.StatusInternalServerError, closeErr - } - return 0, nil -} - -func (h *Handler) handleProppatch(w http.ResponseWriter, r *http.Request) (status int, err error) { - reqPath, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - release, status, err := h.confirmLocks(r, reqPath, "") - if err != nil { - return status, err - } - defer release() - - ctx := getContext(r) - - if _, err := h.FileSystem.Stat(ctx, reqPath); err != nil { - if os.IsNotExist(err) { - return http.StatusNotFound, err - } - return http.StatusMethodNotAllowed, err - } - patches, status, err := readProppatch(r.Body) - if err != nil { - return status, err - } - pstats, err := patch(ctx, h.FileSystem, h.LockSystem, reqPath, patches) - if err != nil { - return http.StatusInternalServerError, err - } - mw := multistatusWriter{w: w} - writeErr := mw.write(makePropstatResponse(r.URL.Path, pstats)) - closeErr := mw.close() - if writeErr != nil { - return http.StatusInternalServerError, writeErr - } - if closeErr != nil { - return http.StatusInternalServerError, closeErr - } - return 0, nil -} - -func makePropstatResponse(href string, pstats []Propstat) *response { - resp := response{ - Href: []string{(&url.URL{Path: href}).EscapedPath()}, - Propstat: make([]propstat, 0, len(pstats)), - } - for _, p := range pstats { - var xmlErr *xmlError - if p.XMLError != "" { - xmlErr = &xmlError{InnerXML: []byte(p.XMLError)} - } - resp.Propstat = append(resp.Propstat, propstat{ - Status: fmt.Sprintf("HTTP/1.1 %d %s", p.Status, StatusText(p.Status)), - Prop: p.Props, - ResponseDescription: p.ResponseDescription, - Error: xmlErr, - }) - } - return &resp -} - -const ( - infiniteDepth = -1 - invalidDepth = -2 -) - -// parseDepth maps the strings "0", "1" and "infinity" to 0, 1 and -// infiniteDepth. Parsing any other string returns invalidDepth. -// -// Different WebDAV methods have further constraints on valid depths: -// - PROPFIND has no further restrictions, as per section 9.1. -// - COPY accepts only "0" or "infinity", as per section 9.8.3. -// - MOVE accepts only "infinity", as per section 9.9.2. -// - LOCK accepts only "0" or "infinity", as per section 9.10.3. -// These constraints are enforced by the handleXxx methods. -func parseDepth(s string) int { - switch s { - case "0": - return 0 - case "1": - return 1 - case "infinity": - return infiniteDepth - } - return invalidDepth -} - -// http://www.webdav.org/specs/rfc4918.html#status.code.extensions.to.http11 -const ( - StatusMulti = 207 - StatusUnprocessableEntity = 422 - StatusLocked = 423 - StatusFailedDependency = 424 - StatusInsufficientStorage = 507 -) - -func StatusText(code int) string { - switch code { - case StatusMulti: - return "Multi-Status" - case StatusUnprocessableEntity: - return "Unprocessable Entity" - case StatusLocked: - return "Locked" - case StatusFailedDependency: - return "Failed Dependency" - case StatusInsufficientStorage: - return "Insufficient Storage" - } - return http.StatusText(code) -} - -var ( - errDestinationEqualsSource = errors.New("webdav: destination equals source") - errDirectoryNotEmpty = errors.New("webdav: directory not empty") - errInvalidDepth = errors.New("webdav: invalid depth") - errInvalidDestination = errors.New("webdav: invalid destination") - errInvalidIfHeader = errors.New("webdav: invalid If header") - errInvalidLockInfo = errors.New("webdav: invalid lock info") - errInvalidLockToken = errors.New("webdav: invalid lock token") - errInvalidPropfind = errors.New("webdav: invalid propfind") - errInvalidProppatch = errors.New("webdav: invalid proppatch") - errInvalidResponse = errors.New("webdav: invalid response") - errInvalidTimeout = errors.New("webdav: invalid timeout") - errNoFileSystem = errors.New("webdav: no file system") - errNoLockSystem = errors.New("webdav: no lock system") - errNotADirectory = errors.New("webdav: not a directory") - errPrefixMismatch = errors.New("webdav: prefix mismatch") - errRecursionTooDeep = errors.New("webdav: recursion too deep") - errUnsupportedLockInfo = errors.New("webdav: unsupported lock info") - errUnsupportedMethod = errors.New("webdav: unsupported method") -) diff --git a/vendor/golang.org/x/net/webdav/webdav_test.go b/vendor/golang.org/x/net/webdav/webdav_test.go deleted file mode 100644 index 25e0d5421..000000000 --- a/vendor/golang.org/x/net/webdav/webdav_test.go +++ /dev/null @@ -1,344 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webdav - -import ( - "errors" - "fmt" - "io" - "io/ioutil" - "net/http" - "net/http/httptest" - "net/url" - "os" - "reflect" - "regexp" - "sort" - "strings" - "testing" - - "golang.org/x/net/context" -) - -// TODO: add tests to check XML responses with the expected prefix path -func TestPrefix(t *testing.T) { - const dst, blah = "Destination", "blah blah blah" - - // createLockBody comes from the example in Section 9.10.7. - const createLockBody = ` - - - - - http://example.org/~ejw/contact.html - - - ` - - do := func(method, urlStr string, body string, wantStatusCode int, headers ...string) (http.Header, error) { - var bodyReader io.Reader - if body != "" { - bodyReader = strings.NewReader(body) - } - req, err := http.NewRequest(method, urlStr, bodyReader) - if err != nil { - return nil, err - } - for len(headers) >= 2 { - req.Header.Add(headers[0], headers[1]) - headers = headers[2:] - } - res, err := http.DefaultTransport.RoundTrip(req) - if err != nil { - return nil, err - } - defer res.Body.Close() - if res.StatusCode != wantStatusCode { - return nil, fmt.Errorf("got status code %d, want %d", res.StatusCode, wantStatusCode) - } - return res.Header, nil - } - - prefixes := []string{ - "/", - "/a/", - "/a/b/", - "/a/b/c/", - } - ctx := context.Background() - for _, prefix := range prefixes { - fs := NewMemFS() - h := &Handler{ - FileSystem: fs, - LockSystem: NewMemLS(), - } - mux := http.NewServeMux() - if prefix != "/" { - h.Prefix = prefix - } - mux.Handle(prefix, h) - srv := httptest.NewServer(mux) - defer srv.Close() - - // The script is: - // MKCOL /a - // MKCOL /a/b - // PUT /a/b/c - // COPY /a/b/c /a/b/d - // MKCOL /a/b/e - // MOVE /a/b/d /a/b/e/f - // LOCK /a/b/e/g - // PUT /a/b/e/g - // which should yield the (possibly stripped) filenames /a/b/c, - // /a/b/e/f and /a/b/e/g, plus their parent directories. - - wantA := map[string]int{ - "/": http.StatusCreated, - "/a/": http.StatusMovedPermanently, - "/a/b/": http.StatusNotFound, - "/a/b/c/": http.StatusNotFound, - }[prefix] - if _, err := do("MKCOL", srv.URL+"/a", "", wantA); err != nil { - t.Errorf("prefix=%-9q MKCOL /a: %v", prefix, err) - continue - } - - wantB := map[string]int{ - "/": http.StatusCreated, - "/a/": http.StatusCreated, - "/a/b/": http.StatusMovedPermanently, - "/a/b/c/": http.StatusNotFound, - }[prefix] - if _, err := do("MKCOL", srv.URL+"/a/b", "", wantB); err != nil { - t.Errorf("prefix=%-9q MKCOL /a/b: %v", prefix, err) - continue - } - - wantC := map[string]int{ - "/": http.StatusCreated, - "/a/": http.StatusCreated, - "/a/b/": http.StatusCreated, - "/a/b/c/": http.StatusMovedPermanently, - }[prefix] - if _, err := do("PUT", srv.URL+"/a/b/c", blah, wantC); err != nil { - t.Errorf("prefix=%-9q PUT /a/b/c: %v", prefix, err) - continue - } - - wantD := map[string]int{ - "/": http.StatusCreated, - "/a/": http.StatusCreated, - "/a/b/": http.StatusCreated, - "/a/b/c/": http.StatusMovedPermanently, - }[prefix] - if _, err := do("COPY", srv.URL+"/a/b/c", "", wantD, dst, srv.URL+"/a/b/d"); err != nil { - t.Errorf("prefix=%-9q COPY /a/b/c /a/b/d: %v", prefix, err) - continue - } - - wantE := map[string]int{ - "/": http.StatusCreated, - "/a/": http.StatusCreated, - "/a/b/": http.StatusCreated, - "/a/b/c/": http.StatusNotFound, - }[prefix] - if _, err := do("MKCOL", srv.URL+"/a/b/e", "", wantE); err != nil { - t.Errorf("prefix=%-9q MKCOL /a/b/e: %v", prefix, err) - continue - } - - wantF := map[string]int{ - "/": http.StatusCreated, - "/a/": http.StatusCreated, - "/a/b/": http.StatusCreated, - "/a/b/c/": http.StatusNotFound, - }[prefix] - if _, err := do("MOVE", srv.URL+"/a/b/d", "", wantF, dst, srv.URL+"/a/b/e/f"); err != nil { - t.Errorf("prefix=%-9q MOVE /a/b/d /a/b/e/f: %v", prefix, err) - continue - } - - var lockToken string - wantG := map[string]int{ - "/": http.StatusCreated, - "/a/": http.StatusCreated, - "/a/b/": http.StatusCreated, - "/a/b/c/": http.StatusNotFound, - }[prefix] - if h, err := do("LOCK", srv.URL+"/a/b/e/g", createLockBody, wantG); err != nil { - t.Errorf("prefix=%-9q LOCK /a/b/e/g: %v", prefix, err) - continue - } else { - lockToken = h.Get("Lock-Token") - } - - ifHeader := fmt.Sprintf("<%s/a/b/e/g> (%s)", srv.URL, lockToken) - wantH := map[string]int{ - "/": http.StatusCreated, - "/a/": http.StatusCreated, - "/a/b/": http.StatusCreated, - "/a/b/c/": http.StatusNotFound, - }[prefix] - if _, err := do("PUT", srv.URL+"/a/b/e/g", blah, wantH, "If", ifHeader); err != nil { - t.Errorf("prefix=%-9q PUT /a/b/e/g: %v", prefix, err) - continue - } - - got, err := find(ctx, nil, fs, "/") - if err != nil { - t.Errorf("prefix=%-9q find: %v", prefix, err) - continue - } - sort.Strings(got) - want := map[string][]string{ - "/": {"/", "/a", "/a/b", "/a/b/c", "/a/b/e", "/a/b/e/f", "/a/b/e/g"}, - "/a/": {"/", "/b", "/b/c", "/b/e", "/b/e/f", "/b/e/g"}, - "/a/b/": {"/", "/c", "/e", "/e/f", "/e/g"}, - "/a/b/c/": {"/"}, - }[prefix] - if !reflect.DeepEqual(got, want) { - t.Errorf("prefix=%-9q find:\ngot %v\nwant %v", prefix, got, want) - continue - } - } -} - -func TestEscapeXML(t *testing.T) { - // These test cases aren't exhaustive, and there is more than one way to - // escape e.g. a quot (as """ or """) or an apos. We presume that - // the encoding/xml package tests xml.EscapeText more thoroughly. This test - // here is just a sanity check for this package's escapeXML function, and - // its attempt to provide a fast path (and avoid a bytes.Buffer allocation) - // when escaping filenames is obviously a no-op. - testCases := map[string]string{ - "": "", - " ": " ", - "&": "&", - "*": "*", - "+": "+", - ",": ",", - "-": "-", - ".": ".", - "/": "/", - "0": "0", - "9": "9", - ":": ":", - "<": "<", - ">": ">", - "A": "A", - "_": "_", - "a": "a", - "~": "~", - "\u0201": "\u0201", - "&": "&amp;", - "foo&baz": "foo&<b/ar>baz", - } - - for in, want := range testCases { - if got := escapeXML(in); got != want { - t.Errorf("in=%q: got %q, want %q", in, got, want) - } - } -} - -func TestFilenameEscape(t *testing.T) { - hrefRe := regexp.MustCompile(`([^<]*)`) - displayNameRe := regexp.MustCompile(`([^<]*)`) - do := func(method, urlStr string) (string, string, error) { - req, err := http.NewRequest(method, urlStr, nil) - if err != nil { - return "", "", err - } - res, err := http.DefaultClient.Do(req) - if err != nil { - return "", "", err - } - defer res.Body.Close() - - b, err := ioutil.ReadAll(res.Body) - if err != nil { - return "", "", err - } - hrefMatch := hrefRe.FindStringSubmatch(string(b)) - if len(hrefMatch) != 2 { - return "", "", errors.New("D:href not found") - } - displayNameMatch := displayNameRe.FindStringSubmatch(string(b)) - if len(displayNameMatch) != 2 { - return "", "", errors.New("D:displayname not found") - } - - return hrefMatch[1], displayNameMatch[1], nil - } - - testCases := []struct { - name, wantHref, wantDisplayName string - }{{ - name: `/foo%bar`, - wantHref: `/foo%25bar`, - wantDisplayName: `foo%bar`, - }, { - name: `/ã“ã‚“ã«ã¡ã‚世界`, - wantHref: `/%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%82%8F%E4%B8%96%E7%95%8C`, - wantDisplayName: `ã“ã‚“ã«ã¡ã‚世界`, - }, { - name: `/Program Files/`, - wantHref: `/Program%20Files`, - wantDisplayName: `Program Files`, - }, { - name: `/go+lang`, - wantHref: `/go+lang`, - wantDisplayName: `go+lang`, - }, { - name: `/go&lang`, - wantHref: `/go&lang`, - wantDisplayName: `go&lang`, - }, { - name: `/goexclusive"` - Shared *struct{} `xml:"lockscope>shared"` - Write *struct{} `xml:"locktype>write"` - Owner owner `xml:"owner"` -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_owner -type owner struct { - InnerXML string `xml:",innerxml"` -} - -func readLockInfo(r io.Reader) (li lockInfo, status int, err error) { - c := &countingReader{r: r} - if err = ixml.NewDecoder(c).Decode(&li); err != nil { - if err == io.EOF { - if c.n == 0 { - // An empty body means to refresh the lock. - // http://www.webdav.org/specs/rfc4918.html#refreshing-locks - return lockInfo{}, 0, nil - } - err = errInvalidLockInfo - } - return lockInfo{}, http.StatusBadRequest, err - } - // We only support exclusive (non-shared) write locks. In practice, these are - // the only types of locks that seem to matter. - if li.Exclusive == nil || li.Shared != nil || li.Write == nil { - return lockInfo{}, http.StatusNotImplemented, errUnsupportedLockInfo - } - return li, 0, nil -} - -type countingReader struct { - n int - r io.Reader -} - -func (c *countingReader) Read(p []byte) (int, error) { - n, err := c.r.Read(p) - c.n += n - return n, err -} - -func writeLockInfo(w io.Writer, token string, ld LockDetails) (int, error) { - depth := "infinity" - if ld.ZeroDepth { - depth = "0" - } - timeout := ld.Duration / time.Second - return fmt.Fprintf(w, "\n"+ - "\n"+ - " \n"+ - " \n"+ - " %s\n"+ - " %s\n"+ - " Second-%d\n"+ - " %s\n"+ - " %s\n"+ - "", - depth, ld.OwnerXML, timeout, escape(token), escape(ld.Root), - ) -} - -func escape(s string) string { - for i := 0; i < len(s); i++ { - switch s[i] { - case '"', '&', '\'', '<', '>': - b := bytes.NewBuffer(nil) - ixml.EscapeText(b, []byte(s)) - return b.String() - } - } - return s -} - -// Next returns the next token, if any, in the XML stream of d. -// RFC 4918 requires to ignore comments, processing instructions -// and directives. -// http://www.webdav.org/specs/rfc4918.html#property_values -// http://www.webdav.org/specs/rfc4918.html#xml-extensibility -func next(d *ixml.Decoder) (ixml.Token, error) { - for { - t, err := d.Token() - if err != nil { - return t, err - } - switch t.(type) { - case ixml.Comment, ixml.Directive, ixml.ProcInst: - continue - default: - return t, nil - } - } -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_prop (for propfind) -type propfindProps []xml.Name - -// UnmarshalXML appends the property names enclosed within start to pn. -// -// It returns an error if start does not contain any properties or if -// properties contain values. Character data between properties is ignored. -func (pn *propfindProps) UnmarshalXML(d *ixml.Decoder, start ixml.StartElement) error { - for { - t, err := next(d) - if err != nil { - return err - } - switch t.(type) { - case ixml.EndElement: - if len(*pn) == 0 { - return fmt.Errorf("%s must not be empty", start.Name.Local) - } - return nil - case ixml.StartElement: - name := t.(ixml.StartElement).Name - t, err = next(d) - if err != nil { - return err - } - if _, ok := t.(ixml.EndElement); !ok { - return fmt.Errorf("unexpected token %T", t) - } - *pn = append(*pn, xml.Name(name)) - } - } -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_propfind -type propfind struct { - XMLName ixml.Name `xml:"DAV: propfind"` - Allprop *struct{} `xml:"DAV: allprop"` - Propname *struct{} `xml:"DAV: propname"` - Prop propfindProps `xml:"DAV: prop"` - Include propfindProps `xml:"DAV: include"` -} - -func readPropfind(r io.Reader) (pf propfind, status int, err error) { - c := countingReader{r: r} - if err = ixml.NewDecoder(&c).Decode(&pf); err != nil { - if err == io.EOF { - if c.n == 0 { - // An empty body means to propfind allprop. - // http://www.webdav.org/specs/rfc4918.html#METHOD_PROPFIND - return propfind{Allprop: new(struct{})}, 0, nil - } - err = errInvalidPropfind - } - return propfind{}, http.StatusBadRequest, err - } - - if pf.Allprop == nil && pf.Include != nil { - return propfind{}, http.StatusBadRequest, errInvalidPropfind - } - if pf.Allprop != nil && (pf.Prop != nil || pf.Propname != nil) { - return propfind{}, http.StatusBadRequest, errInvalidPropfind - } - if pf.Prop != nil && pf.Propname != nil { - return propfind{}, http.StatusBadRequest, errInvalidPropfind - } - if pf.Propname == nil && pf.Allprop == nil && pf.Prop == nil { - return propfind{}, http.StatusBadRequest, errInvalidPropfind - } - return pf, 0, nil -} - -// Property represents a single DAV resource property as defined in RFC 4918. -// See http://www.webdav.org/specs/rfc4918.html#data.model.for.resource.properties -type Property struct { - // XMLName is the fully qualified name that identifies this property. - XMLName xml.Name - - // Lang is an optional xml:lang attribute. - Lang string `xml:"xml:lang,attr,omitempty"` - - // InnerXML contains the XML representation of the property value. - // See http://www.webdav.org/specs/rfc4918.html#property_values - // - // Property values of complex type or mixed-content must have fully - // expanded XML namespaces or be self-contained with according - // XML namespace declarations. They must not rely on any XML - // namespace declarations within the scope of the XML document, - // even including the DAV: namespace. - InnerXML []byte `xml:",innerxml"` -} - -// ixmlProperty is the same as the Property type except it holds an ixml.Name -// instead of an xml.Name. -type ixmlProperty struct { - XMLName ixml.Name - Lang string `xml:"xml:lang,attr,omitempty"` - InnerXML []byte `xml:",innerxml"` -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_error -// See multistatusWriter for the "D:" namespace prefix. -type xmlError struct { - XMLName ixml.Name `xml:"D:error"` - InnerXML []byte `xml:",innerxml"` -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_propstat -// See multistatusWriter for the "D:" namespace prefix. -type propstat struct { - Prop []Property `xml:"D:prop>_ignored_"` - Status string `xml:"D:status"` - Error *xmlError `xml:"D:error"` - ResponseDescription string `xml:"D:responsedescription,omitempty"` -} - -// ixmlPropstat is the same as the propstat type except it holds an ixml.Name -// instead of an xml.Name. -type ixmlPropstat struct { - Prop []ixmlProperty `xml:"D:prop>_ignored_"` - Status string `xml:"D:status"` - Error *xmlError `xml:"D:error"` - ResponseDescription string `xml:"D:responsedescription,omitempty"` -} - -// MarshalXML prepends the "D:" namespace prefix on properties in the DAV: namespace -// before encoding. See multistatusWriter. -func (ps propstat) MarshalXML(e *ixml.Encoder, start ixml.StartElement) error { - // Convert from a propstat to an ixmlPropstat. - ixmlPs := ixmlPropstat{ - Prop: make([]ixmlProperty, len(ps.Prop)), - Status: ps.Status, - Error: ps.Error, - ResponseDescription: ps.ResponseDescription, - } - for k, prop := range ps.Prop { - ixmlPs.Prop[k] = ixmlProperty{ - XMLName: ixml.Name(prop.XMLName), - Lang: prop.Lang, - InnerXML: prop.InnerXML, - } - } - - for k, prop := range ixmlPs.Prop { - if prop.XMLName.Space == "DAV:" { - prop.XMLName = ixml.Name{Space: "", Local: "D:" + prop.XMLName.Local} - ixmlPs.Prop[k] = prop - } - } - // Distinct type to avoid infinite recursion of MarshalXML. - type newpropstat ixmlPropstat - return e.EncodeElement(newpropstat(ixmlPs), start) -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_response -// See multistatusWriter for the "D:" namespace prefix. -type response struct { - XMLName ixml.Name `xml:"D:response"` - Href []string `xml:"D:href"` - Propstat []propstat `xml:"D:propstat"` - Status string `xml:"D:status,omitempty"` - Error *xmlError `xml:"D:error"` - ResponseDescription string `xml:"D:responsedescription,omitempty"` -} - -// MultistatusWriter marshals one or more Responses into a XML -// multistatus response. -// See http://www.webdav.org/specs/rfc4918.html#ELEMENT_multistatus -// TODO(rsto, mpl): As a workaround, the "D:" namespace prefix, defined as -// "DAV:" on this element, is prepended on the nested response, as well as on all -// its nested elements. All property names in the DAV: namespace are prefixed as -// well. This is because some versions of Mini-Redirector (on windows 7) ignore -// elements with a default namespace (no prefixed namespace). A less intrusive fix -// should be possible after golang.org/cl/11074. See https://golang.org/issue/11177 -type multistatusWriter struct { - // ResponseDescription contains the optional responsedescription - // of the multistatus XML element. Only the latest content before - // close will be emitted. Empty response descriptions are not - // written. - responseDescription string - - w http.ResponseWriter - enc *ixml.Encoder -} - -// Write validates and emits a DAV response as part of a multistatus response -// element. -// -// It sets the HTTP status code of its underlying http.ResponseWriter to 207 -// (Multi-Status) and populates the Content-Type header. If r is the -// first, valid response to be written, Write prepends the XML representation -// of r with a multistatus tag. Callers must call close after the last response -// has been written. -func (w *multistatusWriter) write(r *response) error { - switch len(r.Href) { - case 0: - return errInvalidResponse - case 1: - if len(r.Propstat) > 0 != (r.Status == "") { - return errInvalidResponse - } - default: - if len(r.Propstat) > 0 || r.Status == "" { - return errInvalidResponse - } - } - err := w.writeHeader() - if err != nil { - return err - } - return w.enc.Encode(r) -} - -// writeHeader writes a XML multistatus start element on w's underlying -// http.ResponseWriter and returns the result of the write operation. -// After the first write attempt, writeHeader becomes a no-op. -func (w *multistatusWriter) writeHeader() error { - if w.enc != nil { - return nil - } - w.w.Header().Add("Content-Type", "text/xml; charset=utf-8") - w.w.WriteHeader(StatusMulti) - _, err := fmt.Fprintf(w.w, ``) - if err != nil { - return err - } - w.enc = ixml.NewEncoder(w.w) - return w.enc.EncodeToken(ixml.StartElement{ - Name: ixml.Name{ - Space: "DAV:", - Local: "multistatus", - }, - Attr: []ixml.Attr{{ - Name: ixml.Name{Space: "xmlns", Local: "D"}, - Value: "DAV:", - }}, - }) -} - -// Close completes the marshalling of the multistatus response. It returns -// an error if the multistatus response could not be completed. If both the -// return value and field enc of w are nil, then no multistatus response has -// been written. -func (w *multistatusWriter) close() error { - if w.enc == nil { - return nil - } - var end []ixml.Token - if w.responseDescription != "" { - name := ixml.Name{Space: "DAV:", Local: "responsedescription"} - end = append(end, - ixml.StartElement{Name: name}, - ixml.CharData(w.responseDescription), - ixml.EndElement{Name: name}, - ) - } - end = append(end, ixml.EndElement{ - Name: ixml.Name{Space: "DAV:", Local: "multistatus"}, - }) - for _, t := range end { - err := w.enc.EncodeToken(t) - if err != nil { - return err - } - } - return w.enc.Flush() -} - -var xmlLangName = ixml.Name{Space: "http://www.w3.org/XML/1998/namespace", Local: "lang"} - -func xmlLang(s ixml.StartElement, d string) string { - for _, attr := range s.Attr { - if attr.Name == xmlLangName { - return attr.Value - } - } - return d -} - -type xmlValue []byte - -func (v *xmlValue) UnmarshalXML(d *ixml.Decoder, start ixml.StartElement) error { - // The XML value of a property can be arbitrary, mixed-content XML. - // To make sure that the unmarshalled value contains all required - // namespaces, we encode all the property value XML tokens into a - // buffer. This forces the encoder to redeclare any used namespaces. - var b bytes.Buffer - e := ixml.NewEncoder(&b) - for { - t, err := next(d) - if err != nil { - return err - } - if e, ok := t.(ixml.EndElement); ok && e.Name == start.Name { - break - } - if err = e.EncodeToken(t); err != nil { - return err - } - } - err := e.Flush() - if err != nil { - return err - } - *v = b.Bytes() - return nil -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_prop (for proppatch) -type proppatchProps []Property - -// UnmarshalXML appends the property names and values enclosed within start -// to ps. -// -// An xml:lang attribute that is defined either on the DAV:prop or property -// name XML element is propagated to the property's Lang field. -// -// UnmarshalXML returns an error if start does not contain any properties or if -// property values contain syntactically incorrect XML. -func (ps *proppatchProps) UnmarshalXML(d *ixml.Decoder, start ixml.StartElement) error { - lang := xmlLang(start, "") - for { - t, err := next(d) - if err != nil { - return err - } - switch elem := t.(type) { - case ixml.EndElement: - if len(*ps) == 0 { - return fmt.Errorf("%s must not be empty", start.Name.Local) - } - return nil - case ixml.StartElement: - p := Property{ - XMLName: xml.Name(t.(ixml.StartElement).Name), - Lang: xmlLang(t.(ixml.StartElement), lang), - } - err = d.DecodeElement(((*xmlValue)(&p.InnerXML)), &elem) - if err != nil { - return err - } - *ps = append(*ps, p) - } - } -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_set -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_remove -type setRemove struct { - XMLName ixml.Name - Lang string `xml:"xml:lang,attr,omitempty"` - Prop proppatchProps `xml:"DAV: prop"` -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_propertyupdate -type propertyupdate struct { - XMLName ixml.Name `xml:"DAV: propertyupdate"` - Lang string `xml:"xml:lang,attr,omitempty"` - SetRemove []setRemove `xml:",any"` -} - -func readProppatch(r io.Reader) (patches []Proppatch, status int, err error) { - var pu propertyupdate - if err = ixml.NewDecoder(r).Decode(&pu); err != nil { - return nil, http.StatusBadRequest, err - } - for _, op := range pu.SetRemove { - remove := false - switch op.XMLName { - case ixml.Name{Space: "DAV:", Local: "set"}: - // No-op. - case ixml.Name{Space: "DAV:", Local: "remove"}: - for _, p := range op.Prop { - if len(p.InnerXML) > 0 { - return nil, http.StatusBadRequest, errInvalidProppatch - } - } - remove = true - default: - return nil, http.StatusBadRequest, errInvalidProppatch - } - patches = append(patches, Proppatch{Remove: remove, Props: op.Prop}) - } - return patches, 0, nil -} diff --git a/vendor/golang.org/x/net/webdav/xml_test.go b/vendor/golang.org/x/net/webdav/xml_test.go deleted file mode 100644 index a3d9e1ed8..000000000 --- a/vendor/golang.org/x/net/webdav/xml_test.go +++ /dev/null @@ -1,906 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webdav - -import ( - "bytes" - "encoding/xml" - "fmt" - "io" - "net/http" - "net/http/httptest" - "reflect" - "sort" - "strings" - "testing" - - ixml "golang.org/x/net/webdav/internal/xml" -) - -func TestReadLockInfo(t *testing.T) { - // The "section x.y.z" test cases come from section x.y.z of the spec at - // http://www.webdav.org/specs/rfc4918.html - testCases := []struct { - desc string - input string - wantLI lockInfo - wantStatus int - }{{ - "bad: junk", - "xxx", - lockInfo{}, - http.StatusBadRequest, - }, { - "bad: invalid owner XML", - "" + - "\n" + - " \n" + - " \n" + - " \n" + - " no end tag \n" + - " \n" + - "", - lockInfo{}, - http.StatusBadRequest, - }, { - "bad: invalid UTF-8", - "" + - "\n" + - " \n" + - " \n" + - " \n" + - " \xff \n" + - " \n" + - "", - lockInfo{}, - http.StatusBadRequest, - }, { - "bad: unfinished XML #1", - "" + - "\n" + - " \n" + - " \n", - lockInfo{}, - http.StatusBadRequest, - }, { - "bad: unfinished XML #2", - "" + - "\n" + - " \n" + - " \n" + - " \n", - lockInfo{}, - http.StatusBadRequest, - }, { - "good: empty", - "", - lockInfo{}, - 0, - }, { - "good: plain-text owner", - "" + - "\n" + - " \n" + - " \n" + - " gopher\n" + - "", - lockInfo{ - XMLName: ixml.Name{Space: "DAV:", Local: "lockinfo"}, - Exclusive: new(struct{}), - Write: new(struct{}), - Owner: owner{ - InnerXML: "gopher", - }, - }, - 0, - }, { - "section 9.10.7", - "" + - "\n" + - " \n" + - " \n" + - " \n" + - " http://example.org/~ejw/contact.html\n" + - " \n" + - "", - lockInfo{ - XMLName: ixml.Name{Space: "DAV:", Local: "lockinfo"}, - Exclusive: new(struct{}), - Write: new(struct{}), - Owner: owner{ - InnerXML: "\n http://example.org/~ejw/contact.html\n ", - }, - }, - 0, - }} - - for _, tc := range testCases { - li, status, err := readLockInfo(strings.NewReader(tc.input)) - if tc.wantStatus != 0 { - if err == nil { - t.Errorf("%s: got nil error, want non-nil", tc.desc) - continue - } - } else if err != nil { - t.Errorf("%s: %v", tc.desc, err) - continue - } - if !reflect.DeepEqual(li, tc.wantLI) || status != tc.wantStatus { - t.Errorf("%s:\ngot lockInfo=%v, status=%v\nwant lockInfo=%v, status=%v", - tc.desc, li, status, tc.wantLI, tc.wantStatus) - continue - } - } -} - -func TestReadPropfind(t *testing.T) { - testCases := []struct { - desc string - input string - wantPF propfind - wantStatus int - }{{ - desc: "propfind: propname", - input: "" + - "\n" + - " \n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Propname: new(struct{}), - }, - }, { - desc: "propfind: empty body means allprop", - input: "", - wantPF: propfind{ - Allprop: new(struct{}), - }, - }, { - desc: "propfind: allprop", - input: "" + - "\n" + - " \n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Allprop: new(struct{}), - }, - }, { - desc: "propfind: allprop followed by include", - input: "" + - "\n" + - " \n" + - " \n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Allprop: new(struct{}), - Include: propfindProps{xml.Name{Space: "DAV:", Local: "displayname"}}, - }, - }, { - desc: "propfind: include followed by allprop", - input: "" + - "\n" + - " \n" + - " \n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Allprop: new(struct{}), - Include: propfindProps{xml.Name{Space: "DAV:", Local: "displayname"}}, - }, - }, { - desc: "propfind: propfind", - input: "" + - "\n" + - " \n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Prop: propfindProps{xml.Name{Space: "DAV:", Local: "displayname"}}, - }, - }, { - desc: "propfind: prop with ignored comments", - input: "" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Prop: propfindProps{xml.Name{Space: "DAV:", Local: "displayname"}}, - }, - }, { - desc: "propfind: propfind with ignored whitespace", - input: "" + - "\n" + - " \n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Prop: propfindProps{xml.Name{Space: "DAV:", Local: "displayname"}}, - }, - }, { - desc: "propfind: propfind with ignored mixed-content", - input: "" + - "\n" + - " foobar\n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Prop: propfindProps{xml.Name{Space: "DAV:", Local: "displayname"}}, - }, - }, { - desc: "propfind: propname with ignored element (section A.4)", - input: "" + - "\n" + - " \n" + - " *boss*\n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Propname: new(struct{}), - }, - }, { - desc: "propfind: bad: junk", - input: "xxx", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: propname and allprop (section A.3)", - input: "" + - "\n" + - " " + - " " + - "", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: propname and prop", - input: "" + - "\n" + - " \n" + - " \n" + - "", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: allprop and prop", - input: "" + - "\n" + - " \n" + - " \n" + - "", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: empty propfind with ignored element (section A.4)", - input: "" + - "\n" + - " \n" + - "", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: empty prop", - input: "" + - "\n" + - " \n" + - "", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: prop with just chardata", - input: "" + - "\n" + - " foo\n" + - "", - wantStatus: http.StatusBadRequest, - }, { - desc: "bad: interrupted prop", - input: "" + - "\n" + - " \n", - wantStatus: http.StatusBadRequest, - }, { - desc: "bad: malformed end element prop", - input: "" + - "\n" + - " \n", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: property with chardata value", - input: "" + - "\n" + - " bar\n" + - "", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: property with whitespace value", - input: "" + - "\n" + - " \n" + - "", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: include without allprop", - input: "" + - "\n" + - " \n" + - "", - wantStatus: http.StatusBadRequest, - }} - - for _, tc := range testCases { - pf, status, err := readPropfind(strings.NewReader(tc.input)) - if tc.wantStatus != 0 { - if err == nil { - t.Errorf("%s: got nil error, want non-nil", tc.desc) - continue - } - } else if err != nil { - t.Errorf("%s: %v", tc.desc, err) - continue - } - if !reflect.DeepEqual(pf, tc.wantPF) || status != tc.wantStatus { - t.Errorf("%s:\ngot propfind=%v, status=%v\nwant propfind=%v, status=%v", - tc.desc, pf, status, tc.wantPF, tc.wantStatus) - continue - } - } -} - -func TestMultistatusWriter(t *testing.T) { - ///The "section x.y.z" test cases come from section x.y.z of the spec at - // http://www.webdav.org/specs/rfc4918.html - testCases := []struct { - desc string - responses []response - respdesc string - writeHeader bool - wantXML string - wantCode int - wantErr error - }{{ - desc: "section 9.2.2 (failed dependency)", - responses: []response{{ - Href: []string{"http://example.com/foo"}, - Propstat: []propstat{{ - Prop: []Property{{ - XMLName: xml.Name{ - Space: "http://ns.example.com/", - Local: "Authors", - }, - }}, - Status: "HTTP/1.1 424 Failed Dependency", - }, { - Prop: []Property{{ - XMLName: xml.Name{ - Space: "http://ns.example.com/", - Local: "Copyright-Owner", - }, - }}, - Status: "HTTP/1.1 409 Conflict", - }}, - ResponseDescription: "Copyright Owner cannot be deleted or altered.", - }}, - wantXML: `` + - `` + - `` + - ` ` + - ` http://example.com/foo` + - ` ` + - ` ` + - ` ` + - ` ` + - ` HTTP/1.1 424 Failed Dependency` + - ` ` + - ` ` + - ` ` + - ` ` + - ` ` + - ` HTTP/1.1 409 Conflict` + - ` ` + - ` Copyright Owner cannot be deleted or altered.` + - `` + - ``, - wantCode: StatusMulti, - }, { - desc: "section 9.6.2 (lock-token-submitted)", - responses: []response{{ - Href: []string{"http://example.com/foo"}, - Status: "HTTP/1.1 423 Locked", - Error: &xmlError{ - InnerXML: []byte(``), - }, - }}, - wantXML: `` + - `` + - `` + - ` ` + - ` http://example.com/foo` + - ` HTTP/1.1 423 Locked` + - ` ` + - ` ` + - ``, - wantCode: StatusMulti, - }, { - desc: "section 9.1.3", - responses: []response{{ - Href: []string{"http://example.com/foo"}, - Propstat: []propstat{{ - Prop: []Property{{ - XMLName: xml.Name{Space: "http://ns.example.com/boxschema/", Local: "bigbox"}, - InnerXML: []byte(`` + - `` + - `Box type A` + - ``), - }, { - XMLName: xml.Name{Space: "http://ns.example.com/boxschema/", Local: "author"}, - InnerXML: []byte(`` + - `` + - `J.J. Johnson` + - ``), - }}, - Status: "HTTP/1.1 200 OK", - }, { - Prop: []Property{{ - XMLName: xml.Name{Space: "http://ns.example.com/boxschema/", Local: "DingALing"}, - }, { - XMLName: xml.Name{Space: "http://ns.example.com/boxschema/", Local: "Random"}, - }}, - Status: "HTTP/1.1 403 Forbidden", - ResponseDescription: "The user does not have access to the DingALing property.", - }}, - }}, - respdesc: "There has been an access violation error.", - wantXML: `` + - `` + - `` + - ` ` + - ` http://example.com/foo` + - ` ` + - ` ` + - ` Box type A` + - ` J.J. Johnson` + - ` ` + - ` HTTP/1.1 200 OK` + - ` ` + - ` ` + - ` ` + - ` ` + - ` ` + - ` ` + - ` HTTP/1.1 403 Forbidden` + - ` The user does not have access to the DingALing property.` + - ` ` + - ` ` + - ` There has been an access violation error.` + - ``, - wantCode: StatusMulti, - }, { - desc: "no response written", - // default of http.responseWriter - wantCode: http.StatusOK, - }, { - desc: "no response written (with description)", - respdesc: "too bad", - // default of http.responseWriter - wantCode: http.StatusOK, - }, { - desc: "empty multistatus with header", - writeHeader: true, - wantXML: ``, - wantCode: StatusMulti, - }, { - desc: "bad: no href", - responses: []response{{ - Propstat: []propstat{{ - Prop: []Property{{ - XMLName: xml.Name{ - Space: "http://example.com/", - Local: "foo", - }, - }}, - Status: "HTTP/1.1 200 OK", - }}, - }}, - wantErr: errInvalidResponse, - // default of http.responseWriter - wantCode: http.StatusOK, - }, { - desc: "bad: multiple hrefs and no status", - responses: []response{{ - Href: []string{"http://example.com/foo", "http://example.com/bar"}, - }}, - wantErr: errInvalidResponse, - // default of http.responseWriter - wantCode: http.StatusOK, - }, { - desc: "bad: one href and no propstat", - responses: []response{{ - Href: []string{"http://example.com/foo"}, - }}, - wantErr: errInvalidResponse, - // default of http.responseWriter - wantCode: http.StatusOK, - }, { - desc: "bad: status with one href and propstat", - responses: []response{{ - Href: []string{"http://example.com/foo"}, - Propstat: []propstat{{ - Prop: []Property{{ - XMLName: xml.Name{ - Space: "http://example.com/", - Local: "foo", - }, - }}, - Status: "HTTP/1.1 200 OK", - }}, - Status: "HTTP/1.1 200 OK", - }}, - wantErr: errInvalidResponse, - // default of http.responseWriter - wantCode: http.StatusOK, - }, { - desc: "bad: multiple hrefs and propstat", - responses: []response{{ - Href: []string{ - "http://example.com/foo", - "http://example.com/bar", - }, - Propstat: []propstat{{ - Prop: []Property{{ - XMLName: xml.Name{ - Space: "http://example.com/", - Local: "foo", - }, - }}, - Status: "HTTP/1.1 200 OK", - }}, - }}, - wantErr: errInvalidResponse, - // default of http.responseWriter - wantCode: http.StatusOK, - }} - - n := xmlNormalizer{omitWhitespace: true} -loop: - for _, tc := range testCases { - rec := httptest.NewRecorder() - w := multistatusWriter{w: rec, responseDescription: tc.respdesc} - if tc.writeHeader { - if err := w.writeHeader(); err != nil { - t.Errorf("%s: got writeHeader error %v, want nil", tc.desc, err) - continue - } - } - for _, r := range tc.responses { - if err := w.write(&r); err != nil { - if err != tc.wantErr { - t.Errorf("%s: got write error %v, want %v", - tc.desc, err, tc.wantErr) - } - continue loop - } - } - if err := w.close(); err != tc.wantErr { - t.Errorf("%s: got close error %v, want %v", - tc.desc, err, tc.wantErr) - continue - } - if rec.Code != tc.wantCode { - t.Errorf("%s: got HTTP status code %d, want %d\n", - tc.desc, rec.Code, tc.wantCode) - continue - } - gotXML := rec.Body.String() - eq, err := n.equalXML(strings.NewReader(gotXML), strings.NewReader(tc.wantXML)) - if err != nil { - t.Errorf("%s: equalXML: %v", tc.desc, err) - continue - } - if !eq { - t.Errorf("%s: XML body\ngot %s\nwant %s", tc.desc, gotXML, tc.wantXML) - } - } -} - -func TestReadProppatch(t *testing.T) { - ppStr := func(pps []Proppatch) string { - var outer []string - for _, pp := range pps { - var inner []string - for _, p := range pp.Props { - inner = append(inner, fmt.Sprintf("{XMLName: %q, Lang: %q, InnerXML: %q}", - p.XMLName, p.Lang, p.InnerXML)) - } - outer = append(outer, fmt.Sprintf("{Remove: %t, Props: [%s]}", - pp.Remove, strings.Join(inner, ", "))) - } - return "[" + strings.Join(outer, ", ") + "]" - } - - testCases := []struct { - desc string - input string - wantPP []Proppatch - wantStatus int - }{{ - desc: "proppatch: section 9.2 (with simple property value)", - input: `` + - `` + - `` + - ` ` + - ` somevalue` + - ` ` + - ` ` + - ` ` + - ` ` + - ``, - wantPP: []Proppatch{{ - Props: []Property{{ - xml.Name{Space: "http://ns.example.com/z/", Local: "Authors"}, - "", - []byte(`somevalue`), - }}, - }, { - Remove: true, - Props: []Property{{ - xml.Name{Space: "http://ns.example.com/z/", Local: "Copyright-Owner"}, - "", - nil, - }}, - }}, - }, { - desc: "proppatch: lang attribute on prop", - input: `` + - `` + - `` + - ` ` + - ` ` + - ` ` + - ` ` + - ` ` + - ``, - wantPP: []Proppatch{{ - Props: []Property{{ - xml.Name{Space: "http://example.com/ns", Local: "foo"}, - "en", - nil, - }}, - }}, - }, { - desc: "bad: remove with value", - input: `` + - `` + - `` + - ` ` + - ` ` + - ` ` + - ` Jim Whitehead` + - ` ` + - ` ` + - ` ` + - ``, - wantStatus: http.StatusBadRequest, - }, { - desc: "bad: empty propertyupdate", - input: `` + - `` + - ``, - wantStatus: http.StatusBadRequest, - }, { - desc: "bad: empty prop", - input: `` + - `` + - `` + - ` ` + - ` ` + - ` ` + - ``, - wantStatus: http.StatusBadRequest, - }} - - for _, tc := range testCases { - pp, status, err := readProppatch(strings.NewReader(tc.input)) - if tc.wantStatus != 0 { - if err == nil { - t.Errorf("%s: got nil error, want non-nil", tc.desc) - continue - } - } else if err != nil { - t.Errorf("%s: %v", tc.desc, err) - continue - } - if status != tc.wantStatus { - t.Errorf("%s: got status %d, want %d", tc.desc, status, tc.wantStatus) - continue - } - if !reflect.DeepEqual(pp, tc.wantPP) || status != tc.wantStatus { - t.Errorf("%s: proppatch\ngot %v\nwant %v", tc.desc, ppStr(pp), ppStr(tc.wantPP)) - } - } -} - -func TestUnmarshalXMLValue(t *testing.T) { - testCases := []struct { - desc string - input string - wantVal string - }{{ - desc: "simple char data", - input: "foo", - wantVal: "foo", - }, { - desc: "empty element", - input: "", - wantVal: "", - }, { - desc: "preserve namespace", - input: ``, - wantVal: ``, - }, { - desc: "preserve root element namespace", - input: ``, - wantVal: ``, - }, { - desc: "preserve whitespace", - input: " \t ", - wantVal: " \t ", - }, { - desc: "preserve mixed content", - input: ` a `, - wantVal: ` a `, - }, { - desc: "section 9.2", - input: `` + - `` + - ` Jim Whitehead` + - ` Roy Fielding` + - ``, - wantVal: `` + - ` Jim Whitehead` + - ` Roy Fielding`, - }, { - desc: "section 4.3.1 (mixed content)", - input: `` + - `` + - ` Jane Doe` + - ` ` + - ` mailto:jane.doe@example.com` + - ` http://www.example.com` + - ` ` + - ` Jane has been working way too long on the` + - ` long-awaited revision of ]]>.` + - ` ` + - ``, - wantVal: `` + - ` Jane Doe` + - ` ` + - ` mailto:jane.doe@example.com` + - ` http://www.example.com` + - ` ` + - ` Jane has been working way too long on the` + - ` long-awaited revision of <RFC2518>.` + - ` `, - }} - - var n xmlNormalizer - for _, tc := range testCases { - d := ixml.NewDecoder(strings.NewReader(tc.input)) - var v xmlValue - if err := d.Decode(&v); err != nil { - t.Errorf("%s: got error %v, want nil", tc.desc, err) - continue - } - eq, err := n.equalXML(bytes.NewReader(v), strings.NewReader(tc.wantVal)) - if err != nil { - t.Errorf("%s: equalXML: %v", tc.desc, err) - continue - } - if !eq { - t.Errorf("%s:\ngot %s\nwant %s", tc.desc, string(v), tc.wantVal) - } - } -} - -// xmlNormalizer normalizes XML. -type xmlNormalizer struct { - // omitWhitespace instructs to ignore whitespace between element tags. - omitWhitespace bool - // omitComments instructs to ignore XML comments. - omitComments bool -} - -// normalize writes the normalized XML content of r to w. It applies the -// following rules -// -// * Rename namespace prefixes according to an internal heuristic. -// * Remove unnecessary namespace declarations. -// * Sort attributes in XML start elements in lexical order of their -// fully qualified name. -// * Remove XML directives and processing instructions. -// * Remove CDATA between XML tags that only contains whitespace, if -// instructed to do so. -// * Remove comments, if instructed to do so. -// -func (n *xmlNormalizer) normalize(w io.Writer, r io.Reader) error { - d := ixml.NewDecoder(r) - e := ixml.NewEncoder(w) - for { - t, err := d.Token() - if err != nil { - if t == nil && err == io.EOF { - break - } - return err - } - switch val := t.(type) { - case ixml.Directive, ixml.ProcInst: - continue - case ixml.Comment: - if n.omitComments { - continue - } - case ixml.CharData: - if n.omitWhitespace && len(bytes.TrimSpace(val)) == 0 { - continue - } - case ixml.StartElement: - start, _ := ixml.CopyToken(val).(ixml.StartElement) - attr := start.Attr[:0] - for _, a := range start.Attr { - if a.Name.Space == "xmlns" || a.Name.Local == "xmlns" { - continue - } - attr = append(attr, a) - } - sort.Sort(byName(attr)) - start.Attr = attr - t = start - } - err = e.EncodeToken(t) - if err != nil { - return err - } - } - return e.Flush() -} - -// equalXML tests for equality of the normalized XML contents of a and b. -func (n *xmlNormalizer) equalXML(a, b io.Reader) (bool, error) { - var buf bytes.Buffer - if err := n.normalize(&buf, a); err != nil { - return false, err - } - normA := buf.String() - buf.Reset() - if err := n.normalize(&buf, b); err != nil { - return false, err - } - normB := buf.String() - return normA == normB, nil -} - -type byName []ixml.Attr - -func (a byName) Len() int { return len(a) } -func (a byName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -func (a byName) Less(i, j int) bool { - if a[i].Name.Space != a[j].Name.Space { - return a[i].Name.Space < a[j].Name.Space - } - return a[i].Name.Local < a[j].Name.Local -} diff --git a/vendor/golang.org/x/net/websocket/client.go b/vendor/golang.org/x/net/websocket/client.go deleted file mode 100644 index 69a4ac7ee..000000000 --- a/vendor/golang.org/x/net/websocket/client.go +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package websocket - -import ( - "bufio" - "io" - "net" - "net/http" - "net/url" -) - -// DialError is an error that occurs while dialling a websocket server. -type DialError struct { - *Config - Err error -} - -func (e *DialError) Error() string { - return "websocket.Dial " + e.Config.Location.String() + ": " + e.Err.Error() -} - -// NewConfig creates a new WebSocket config for client connection. -func NewConfig(server, origin string) (config *Config, err error) { - config = new(Config) - config.Version = ProtocolVersionHybi13 - config.Location, err = url.ParseRequestURI(server) - if err != nil { - return - } - config.Origin, err = url.ParseRequestURI(origin) - if err != nil { - return - } - config.Header = http.Header(make(map[string][]string)) - return -} - -// NewClient creates a new WebSocket client connection over rwc. -func NewClient(config *Config, rwc io.ReadWriteCloser) (ws *Conn, err error) { - br := bufio.NewReader(rwc) - bw := bufio.NewWriter(rwc) - err = hybiClientHandshake(config, br, bw) - if err != nil { - return - } - buf := bufio.NewReadWriter(br, bw) - ws = newHybiClientConn(config, buf, rwc) - return -} - -// Dial opens a new client connection to a WebSocket. -func Dial(url_, protocol, origin string) (ws *Conn, err error) { - config, err := NewConfig(url_, origin) - if err != nil { - return nil, err - } - if protocol != "" { - config.Protocol = []string{protocol} - } - return DialConfig(config) -} - -var portMap = map[string]string{ - "ws": "80", - "wss": "443", -} - -func parseAuthority(location *url.URL) string { - if _, ok := portMap[location.Scheme]; ok { - if _, _, err := net.SplitHostPort(location.Host); err != nil { - return net.JoinHostPort(location.Host, portMap[location.Scheme]) - } - } - return location.Host -} - -// DialConfig opens a new client connection to a WebSocket with a config. -func DialConfig(config *Config) (ws *Conn, err error) { - var client net.Conn - if config.Location == nil { - return nil, &DialError{config, ErrBadWebSocketLocation} - } - if config.Origin == nil { - return nil, &DialError{config, ErrBadWebSocketOrigin} - } - dialer := config.Dialer - if dialer == nil { - dialer = &net.Dialer{} - } - client, err = dialWithDialer(dialer, config) - if err != nil { - goto Error - } - ws, err = NewClient(config, client) - if err != nil { - client.Close() - goto Error - } - return - -Error: - return nil, &DialError{config, err} -} diff --git a/vendor/golang.org/x/net/websocket/dial.go b/vendor/golang.org/x/net/websocket/dial.go deleted file mode 100644 index 2dab943a4..000000000 --- a/vendor/golang.org/x/net/websocket/dial.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package websocket - -import ( - "crypto/tls" - "net" -) - -func dialWithDialer(dialer *net.Dialer, config *Config) (conn net.Conn, err error) { - switch config.Location.Scheme { - case "ws": - conn, err = dialer.Dial("tcp", parseAuthority(config.Location)) - - case "wss": - conn, err = tls.DialWithDialer(dialer, "tcp", parseAuthority(config.Location), config.TlsConfig) - - default: - err = ErrBadScheme - } - return -} diff --git a/vendor/golang.org/x/net/websocket/dial_test.go b/vendor/golang.org/x/net/websocket/dial_test.go deleted file mode 100644 index aa03e30dd..000000000 --- a/vendor/golang.org/x/net/websocket/dial_test.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package websocket - -import ( - "crypto/tls" - "fmt" - "log" - "net" - "net/http/httptest" - "testing" - "time" -) - -// This test depend on Go 1.3+ because in earlier versions the Dialer won't be -// used in TLS connections and a timeout won't be triggered. -func TestDialConfigTLSWithDialer(t *testing.T) { - tlsServer := httptest.NewTLSServer(nil) - tlsServerAddr := tlsServer.Listener.Addr().String() - log.Print("Test TLS WebSocket server listening on ", tlsServerAddr) - defer tlsServer.Close() - config, _ := NewConfig(fmt.Sprintf("wss://%s/echo", tlsServerAddr), "http://localhost") - config.Dialer = &net.Dialer{ - Deadline: time.Now().Add(-time.Minute), - } - config.TlsConfig = &tls.Config{ - InsecureSkipVerify: true, - } - _, err := DialConfig(config) - dialerr, ok := err.(*DialError) - if !ok { - t.Fatalf("DialError expected, got %#v", err) - } - neterr, ok := dialerr.Err.(*net.OpError) - if !ok { - t.Fatalf("net.OpError error expected, got %#v", dialerr.Err) - } - if !neterr.Timeout() { - t.Fatalf("expected timeout error, got %#v", neterr) - } -} diff --git a/vendor/golang.org/x/net/websocket/exampledial_test.go b/vendor/golang.org/x/net/websocket/exampledial_test.go deleted file mode 100644 index 72bb9d48e..000000000 --- a/vendor/golang.org/x/net/websocket/exampledial_test.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package websocket_test - -import ( - "fmt" - "log" - - "golang.org/x/net/websocket" -) - -// This example demonstrates a trivial client. -func ExampleDial() { - origin := "http://localhost/" - url := "ws://localhost:12345/ws" - ws, err := websocket.Dial(url, "", origin) - if err != nil { - log.Fatal(err) - } - if _, err := ws.Write([]byte("hello, world!\n")); err != nil { - log.Fatal(err) - } - var msg = make([]byte, 512) - var n int - if n, err = ws.Read(msg); err != nil { - log.Fatal(err) - } - fmt.Printf("Received: %s.\n", msg[:n]) -} diff --git a/vendor/golang.org/x/net/websocket/examplehandler_test.go b/vendor/golang.org/x/net/websocket/examplehandler_test.go deleted file mode 100644 index f22a98fcd..000000000 --- a/vendor/golang.org/x/net/websocket/examplehandler_test.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package websocket_test - -import ( - "io" - "net/http" - - "golang.org/x/net/websocket" -) - -// Echo the data received on the WebSocket. -func EchoServer(ws *websocket.Conn) { - io.Copy(ws, ws) -} - -// This example demonstrates a trivial echo server. -func ExampleHandler() { - http.Handle("/echo", websocket.Handler(EchoServer)) - err := http.ListenAndServe(":12345", nil) - if err != nil { - panic("ListenAndServe: " + err.Error()) - } -} diff --git a/vendor/golang.org/x/net/websocket/hybi.go b/vendor/golang.org/x/net/websocket/hybi.go deleted file mode 100644 index 8cffdd16c..000000000 --- a/vendor/golang.org/x/net/websocket/hybi.go +++ /dev/null @@ -1,583 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package websocket - -// This file implements a protocol of hybi draft. -// http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17 - -import ( - "bufio" - "bytes" - "crypto/rand" - "crypto/sha1" - "encoding/base64" - "encoding/binary" - "fmt" - "io" - "io/ioutil" - "net/http" - "net/url" - "strings" -) - -const ( - websocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" - - closeStatusNormal = 1000 - closeStatusGoingAway = 1001 - closeStatusProtocolError = 1002 - closeStatusUnsupportedData = 1003 - closeStatusFrameTooLarge = 1004 - closeStatusNoStatusRcvd = 1005 - closeStatusAbnormalClosure = 1006 - closeStatusBadMessageData = 1007 - closeStatusPolicyViolation = 1008 - closeStatusTooBigData = 1009 - closeStatusExtensionMismatch = 1010 - - maxControlFramePayloadLength = 125 -) - -var ( - ErrBadMaskingKey = &ProtocolError{"bad masking key"} - ErrBadPongMessage = &ProtocolError{"bad pong message"} - ErrBadClosingStatus = &ProtocolError{"bad closing status"} - ErrUnsupportedExtensions = &ProtocolError{"unsupported extensions"} - ErrNotImplemented = &ProtocolError{"not implemented"} - - handshakeHeader = map[string]bool{ - "Host": true, - "Upgrade": true, - "Connection": true, - "Sec-Websocket-Key": true, - "Sec-Websocket-Origin": true, - "Sec-Websocket-Version": true, - "Sec-Websocket-Protocol": true, - "Sec-Websocket-Accept": true, - } -) - -// A hybiFrameHeader is a frame header as defined in hybi draft. -type hybiFrameHeader struct { - Fin bool - Rsv [3]bool - OpCode byte - Length int64 - MaskingKey []byte - - data *bytes.Buffer -} - -// A hybiFrameReader is a reader for hybi frame. -type hybiFrameReader struct { - reader io.Reader - - header hybiFrameHeader - pos int64 - length int -} - -func (frame *hybiFrameReader) Read(msg []byte) (n int, err error) { - n, err = frame.reader.Read(msg) - if frame.header.MaskingKey != nil { - for i := 0; i < n; i++ { - msg[i] = msg[i] ^ frame.header.MaskingKey[frame.pos%4] - frame.pos++ - } - } - return n, err -} - -func (frame *hybiFrameReader) PayloadType() byte { return frame.header.OpCode } - -func (frame *hybiFrameReader) HeaderReader() io.Reader { - if frame.header.data == nil { - return nil - } - if frame.header.data.Len() == 0 { - return nil - } - return frame.header.data -} - -func (frame *hybiFrameReader) TrailerReader() io.Reader { return nil } - -func (frame *hybiFrameReader) Len() (n int) { return frame.length } - -// A hybiFrameReaderFactory creates new frame reader based on its frame type. -type hybiFrameReaderFactory struct { - *bufio.Reader -} - -// NewFrameReader reads a frame header from the connection, and creates new reader for the frame. -// See Section 5.2 Base Framing protocol for detail. -// http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17#section-5.2 -func (buf hybiFrameReaderFactory) NewFrameReader() (frame frameReader, err error) { - hybiFrame := new(hybiFrameReader) - frame = hybiFrame - var header []byte - var b byte - // First byte. FIN/RSV1/RSV2/RSV3/OpCode(4bits) - b, err = buf.ReadByte() - if err != nil { - return - } - header = append(header, b) - hybiFrame.header.Fin = ((header[0] >> 7) & 1) != 0 - for i := 0; i < 3; i++ { - j := uint(6 - i) - hybiFrame.header.Rsv[i] = ((header[0] >> j) & 1) != 0 - } - hybiFrame.header.OpCode = header[0] & 0x0f - - // Second byte. Mask/Payload len(7bits) - b, err = buf.ReadByte() - if err != nil { - return - } - header = append(header, b) - mask := (b & 0x80) != 0 - b &= 0x7f - lengthFields := 0 - switch { - case b <= 125: // Payload length 7bits. - hybiFrame.header.Length = int64(b) - case b == 126: // Payload length 7+16bits - lengthFields = 2 - case b == 127: // Payload length 7+64bits - lengthFields = 8 - } - for i := 0; i < lengthFields; i++ { - b, err = buf.ReadByte() - if err != nil { - return - } - if lengthFields == 8 && i == 0 { // MSB must be zero when 7+64 bits - b &= 0x7f - } - header = append(header, b) - hybiFrame.header.Length = hybiFrame.header.Length*256 + int64(b) - } - if mask { - // Masking key. 4 bytes. - for i := 0; i < 4; i++ { - b, err = buf.ReadByte() - if err != nil { - return - } - header = append(header, b) - hybiFrame.header.MaskingKey = append(hybiFrame.header.MaskingKey, b) - } - } - hybiFrame.reader = io.LimitReader(buf.Reader, hybiFrame.header.Length) - hybiFrame.header.data = bytes.NewBuffer(header) - hybiFrame.length = len(header) + int(hybiFrame.header.Length) - return -} - -// A HybiFrameWriter is a writer for hybi frame. -type hybiFrameWriter struct { - writer *bufio.Writer - - header *hybiFrameHeader -} - -func (frame *hybiFrameWriter) Write(msg []byte) (n int, err error) { - var header []byte - var b byte - if frame.header.Fin { - b |= 0x80 - } - for i := 0; i < 3; i++ { - if frame.header.Rsv[i] { - j := uint(6 - i) - b |= 1 << j - } - } - b |= frame.header.OpCode - header = append(header, b) - if frame.header.MaskingKey != nil { - b = 0x80 - } else { - b = 0 - } - lengthFields := 0 - length := len(msg) - switch { - case length <= 125: - b |= byte(length) - case length < 65536: - b |= 126 - lengthFields = 2 - default: - b |= 127 - lengthFields = 8 - } - header = append(header, b) - for i := 0; i < lengthFields; i++ { - j := uint((lengthFields - i - 1) * 8) - b = byte((length >> j) & 0xff) - header = append(header, b) - } - if frame.header.MaskingKey != nil { - if len(frame.header.MaskingKey) != 4 { - return 0, ErrBadMaskingKey - } - header = append(header, frame.header.MaskingKey...) - frame.writer.Write(header) - data := make([]byte, length) - for i := range data { - data[i] = msg[i] ^ frame.header.MaskingKey[i%4] - } - frame.writer.Write(data) - err = frame.writer.Flush() - return length, err - } - frame.writer.Write(header) - frame.writer.Write(msg) - err = frame.writer.Flush() - return length, err -} - -func (frame *hybiFrameWriter) Close() error { return nil } - -type hybiFrameWriterFactory struct { - *bufio.Writer - needMaskingKey bool -} - -func (buf hybiFrameWriterFactory) NewFrameWriter(payloadType byte) (frame frameWriter, err error) { - frameHeader := &hybiFrameHeader{Fin: true, OpCode: payloadType} - if buf.needMaskingKey { - frameHeader.MaskingKey, err = generateMaskingKey() - if err != nil { - return nil, err - } - } - return &hybiFrameWriter{writer: buf.Writer, header: frameHeader}, nil -} - -type hybiFrameHandler struct { - conn *Conn - payloadType byte -} - -func (handler *hybiFrameHandler) HandleFrame(frame frameReader) (frameReader, error) { - if handler.conn.IsServerConn() { - // The client MUST mask all frames sent to the server. - if frame.(*hybiFrameReader).header.MaskingKey == nil { - handler.WriteClose(closeStatusProtocolError) - return nil, io.EOF - } - } else { - // The server MUST NOT mask all frames. - if frame.(*hybiFrameReader).header.MaskingKey != nil { - handler.WriteClose(closeStatusProtocolError) - return nil, io.EOF - } - } - if header := frame.HeaderReader(); header != nil { - io.Copy(ioutil.Discard, header) - } - switch frame.PayloadType() { - case ContinuationFrame: - frame.(*hybiFrameReader).header.OpCode = handler.payloadType - case TextFrame, BinaryFrame: - handler.payloadType = frame.PayloadType() - case CloseFrame: - return nil, io.EOF - case PingFrame, PongFrame: - b := make([]byte, maxControlFramePayloadLength) - n, err := io.ReadFull(frame, b) - if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF { - return nil, err - } - io.Copy(ioutil.Discard, frame) - if frame.PayloadType() == PingFrame { - if _, err := handler.WritePong(b[:n]); err != nil { - return nil, err - } - } - return nil, nil - } - return frame, nil -} - -func (handler *hybiFrameHandler) WriteClose(status int) (err error) { - handler.conn.wio.Lock() - defer handler.conn.wio.Unlock() - w, err := handler.conn.frameWriterFactory.NewFrameWriter(CloseFrame) - if err != nil { - return err - } - msg := make([]byte, 2) - binary.BigEndian.PutUint16(msg, uint16(status)) - _, err = w.Write(msg) - w.Close() - return err -} - -func (handler *hybiFrameHandler) WritePong(msg []byte) (n int, err error) { - handler.conn.wio.Lock() - defer handler.conn.wio.Unlock() - w, err := handler.conn.frameWriterFactory.NewFrameWriter(PongFrame) - if err != nil { - return 0, err - } - n, err = w.Write(msg) - w.Close() - return n, err -} - -// newHybiConn creates a new WebSocket connection speaking hybi draft protocol. -func newHybiConn(config *Config, buf *bufio.ReadWriter, rwc io.ReadWriteCloser, request *http.Request) *Conn { - if buf == nil { - br := bufio.NewReader(rwc) - bw := bufio.NewWriter(rwc) - buf = bufio.NewReadWriter(br, bw) - } - ws := &Conn{config: config, request: request, buf: buf, rwc: rwc, - frameReaderFactory: hybiFrameReaderFactory{buf.Reader}, - frameWriterFactory: hybiFrameWriterFactory{ - buf.Writer, request == nil}, - PayloadType: TextFrame, - defaultCloseStatus: closeStatusNormal} - ws.frameHandler = &hybiFrameHandler{conn: ws} - return ws -} - -// generateMaskingKey generates a masking key for a frame. -func generateMaskingKey() (maskingKey []byte, err error) { - maskingKey = make([]byte, 4) - if _, err = io.ReadFull(rand.Reader, maskingKey); err != nil { - return - } - return -} - -// generateNonce generates a nonce consisting of a randomly selected 16-byte -// value that has been base64-encoded. -func generateNonce() (nonce []byte) { - key := make([]byte, 16) - if _, err := io.ReadFull(rand.Reader, key); err != nil { - panic(err) - } - nonce = make([]byte, 24) - base64.StdEncoding.Encode(nonce, key) - return -} - -// removeZone removes IPv6 zone identifer from host. -// E.g., "[fe80::1%en0]:8080" to "[fe80::1]:8080" -func removeZone(host string) string { - if !strings.HasPrefix(host, "[") { - return host - } - i := strings.LastIndex(host, "]") - if i < 0 { - return host - } - j := strings.LastIndex(host[:i], "%") - if j < 0 { - return host - } - return host[:j] + host[i:] -} - -// getNonceAccept computes the base64-encoded SHA-1 of the concatenation of -// the nonce ("Sec-WebSocket-Key" value) with the websocket GUID string. -func getNonceAccept(nonce []byte) (expected []byte, err error) { - h := sha1.New() - if _, err = h.Write(nonce); err != nil { - return - } - if _, err = h.Write([]byte(websocketGUID)); err != nil { - return - } - expected = make([]byte, 28) - base64.StdEncoding.Encode(expected, h.Sum(nil)) - return -} - -// Client handshake described in draft-ietf-hybi-thewebsocket-protocol-17 -func hybiClientHandshake(config *Config, br *bufio.Reader, bw *bufio.Writer) (err error) { - bw.WriteString("GET " + config.Location.RequestURI() + " HTTP/1.1\r\n") - - // According to RFC 6874, an HTTP client, proxy, or other - // intermediary must remove any IPv6 zone identifier attached - // to an outgoing URI. - bw.WriteString("Host: " + removeZone(config.Location.Host) + "\r\n") - bw.WriteString("Upgrade: websocket\r\n") - bw.WriteString("Connection: Upgrade\r\n") - nonce := generateNonce() - if config.handshakeData != nil { - nonce = []byte(config.handshakeData["key"]) - } - bw.WriteString("Sec-WebSocket-Key: " + string(nonce) + "\r\n") - bw.WriteString("Origin: " + strings.ToLower(config.Origin.String()) + "\r\n") - - if config.Version != ProtocolVersionHybi13 { - return ErrBadProtocolVersion - } - - bw.WriteString("Sec-WebSocket-Version: " + fmt.Sprintf("%d", config.Version) + "\r\n") - if len(config.Protocol) > 0 { - bw.WriteString("Sec-WebSocket-Protocol: " + strings.Join(config.Protocol, ", ") + "\r\n") - } - // TODO(ukai): send Sec-WebSocket-Extensions. - err = config.Header.WriteSubset(bw, handshakeHeader) - if err != nil { - return err - } - - bw.WriteString("\r\n") - if err = bw.Flush(); err != nil { - return err - } - - resp, err := http.ReadResponse(br, &http.Request{Method: "GET"}) - if err != nil { - return err - } - if resp.StatusCode != 101 { - return ErrBadStatus - } - if strings.ToLower(resp.Header.Get("Upgrade")) != "websocket" || - strings.ToLower(resp.Header.Get("Connection")) != "upgrade" { - return ErrBadUpgrade - } - expectedAccept, err := getNonceAccept(nonce) - if err != nil { - return err - } - if resp.Header.Get("Sec-WebSocket-Accept") != string(expectedAccept) { - return ErrChallengeResponse - } - if resp.Header.Get("Sec-WebSocket-Extensions") != "" { - return ErrUnsupportedExtensions - } - offeredProtocol := resp.Header.Get("Sec-WebSocket-Protocol") - if offeredProtocol != "" { - protocolMatched := false - for i := 0; i < len(config.Protocol); i++ { - if config.Protocol[i] == offeredProtocol { - protocolMatched = true - break - } - } - if !protocolMatched { - return ErrBadWebSocketProtocol - } - config.Protocol = []string{offeredProtocol} - } - - return nil -} - -// newHybiClientConn creates a client WebSocket connection after handshake. -func newHybiClientConn(config *Config, buf *bufio.ReadWriter, rwc io.ReadWriteCloser) *Conn { - return newHybiConn(config, buf, rwc, nil) -} - -// A HybiServerHandshaker performs a server handshake using hybi draft protocol. -type hybiServerHandshaker struct { - *Config - accept []byte -} - -func (c *hybiServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Request) (code int, err error) { - c.Version = ProtocolVersionHybi13 - if req.Method != "GET" { - return http.StatusMethodNotAllowed, ErrBadRequestMethod - } - // HTTP version can be safely ignored. - - if strings.ToLower(req.Header.Get("Upgrade")) != "websocket" || - !strings.Contains(strings.ToLower(req.Header.Get("Connection")), "upgrade") { - return http.StatusBadRequest, ErrNotWebSocket - } - - key := req.Header.Get("Sec-Websocket-Key") - if key == "" { - return http.StatusBadRequest, ErrChallengeResponse - } - version := req.Header.Get("Sec-Websocket-Version") - switch version { - case "13": - c.Version = ProtocolVersionHybi13 - default: - return http.StatusBadRequest, ErrBadWebSocketVersion - } - var scheme string - if req.TLS != nil { - scheme = "wss" - } else { - scheme = "ws" - } - c.Location, err = url.ParseRequestURI(scheme + "://" + req.Host + req.URL.RequestURI()) - if err != nil { - return http.StatusBadRequest, err - } - protocol := strings.TrimSpace(req.Header.Get("Sec-Websocket-Protocol")) - if protocol != "" { - protocols := strings.Split(protocol, ",") - for i := 0; i < len(protocols); i++ { - c.Protocol = append(c.Protocol, strings.TrimSpace(protocols[i])) - } - } - c.accept, err = getNonceAccept([]byte(key)) - if err != nil { - return http.StatusInternalServerError, err - } - return http.StatusSwitchingProtocols, nil -} - -// Origin parses the Origin header in req. -// If the Origin header is not set, it returns nil and nil. -func Origin(config *Config, req *http.Request) (*url.URL, error) { - var origin string - switch config.Version { - case ProtocolVersionHybi13: - origin = req.Header.Get("Origin") - } - if origin == "" { - return nil, nil - } - return url.ParseRequestURI(origin) -} - -func (c *hybiServerHandshaker) AcceptHandshake(buf *bufio.Writer) (err error) { - if len(c.Protocol) > 0 { - if len(c.Protocol) != 1 { - // You need choose a Protocol in Handshake func in Server. - return ErrBadWebSocketProtocol - } - } - buf.WriteString("HTTP/1.1 101 Switching Protocols\r\n") - buf.WriteString("Upgrade: websocket\r\n") - buf.WriteString("Connection: Upgrade\r\n") - buf.WriteString("Sec-WebSocket-Accept: " + string(c.accept) + "\r\n") - if len(c.Protocol) > 0 { - buf.WriteString("Sec-WebSocket-Protocol: " + c.Protocol[0] + "\r\n") - } - // TODO(ukai): send Sec-WebSocket-Extensions. - if c.Header != nil { - err := c.Header.WriteSubset(buf, handshakeHeader) - if err != nil { - return err - } - } - buf.WriteString("\r\n") - return buf.Flush() -} - -func (c *hybiServerHandshaker) NewServerConn(buf *bufio.ReadWriter, rwc io.ReadWriteCloser, request *http.Request) *Conn { - return newHybiServerConn(c.Config, buf, rwc, request) -} - -// newHybiServerConn returns a new WebSocket connection speaking hybi draft protocol. -func newHybiServerConn(config *Config, buf *bufio.ReadWriter, rwc io.ReadWriteCloser, request *http.Request) *Conn { - return newHybiConn(config, buf, rwc, request) -} diff --git a/vendor/golang.org/x/net/websocket/hybi_test.go b/vendor/golang.org/x/net/websocket/hybi_test.go deleted file mode 100644 index 9504aa2d3..000000000 --- a/vendor/golang.org/x/net/websocket/hybi_test.go +++ /dev/null @@ -1,608 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package websocket - -import ( - "bufio" - "bytes" - "fmt" - "io" - "net/http" - "net/url" - "strings" - "testing" -) - -// Test the getNonceAccept function with values in -// http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17 -func TestSecWebSocketAccept(t *testing.T) { - nonce := []byte("dGhlIHNhbXBsZSBub25jZQ==") - expected := []byte("s3pPLMBiTxaQ9kYGzzhZRbK+xOo=") - accept, err := getNonceAccept(nonce) - if err != nil { - t.Errorf("getNonceAccept: returned error %v", err) - return - } - if !bytes.Equal(expected, accept) { - t.Errorf("getNonceAccept: expected %q got %q", expected, accept) - } -} - -func TestHybiClientHandshake(t *testing.T) { - type test struct { - url, host string - } - tests := []test{ - {"ws://server.example.com/chat", "server.example.com"}, - {"ws://127.0.0.1/chat", "127.0.0.1"}, - } - if _, err := url.ParseRequestURI("http://[fe80::1%25lo0]"); err == nil { - tests = append(tests, test{"ws://[fe80::1%25lo0]/chat", "[fe80::1]"}) - } - - for _, tt := range tests { - var b bytes.Buffer - bw := bufio.NewWriter(&b) - br := bufio.NewReader(strings.NewReader(`HTTP/1.1 101 Switching Protocols -Upgrade: websocket -Connection: Upgrade -Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= -Sec-WebSocket-Protocol: chat - -`)) - var err error - var config Config - config.Location, err = url.ParseRequestURI(tt.url) - if err != nil { - t.Fatal("location url", err) - } - config.Origin, err = url.ParseRequestURI("http://example.com") - if err != nil { - t.Fatal("origin url", err) - } - config.Protocol = append(config.Protocol, "chat") - config.Protocol = append(config.Protocol, "superchat") - config.Version = ProtocolVersionHybi13 - config.handshakeData = map[string]string{ - "key": "dGhlIHNhbXBsZSBub25jZQ==", - } - if err := hybiClientHandshake(&config, br, bw); err != nil { - t.Fatal("handshake", err) - } - req, err := http.ReadRequest(bufio.NewReader(&b)) - if err != nil { - t.Fatal("read request", err) - } - if req.Method != "GET" { - t.Errorf("request method expected GET, but got %s", req.Method) - } - if req.URL.Path != "/chat" { - t.Errorf("request path expected /chat, but got %s", req.URL.Path) - } - if req.Proto != "HTTP/1.1" { - t.Errorf("request proto expected HTTP/1.1, but got %s", req.Proto) - } - if req.Host != tt.host { - t.Errorf("request host expected %s, but got %s", tt.host, req.Host) - } - var expectedHeader = map[string]string{ - "Connection": "Upgrade", - "Upgrade": "websocket", - "Sec-Websocket-Key": config.handshakeData["key"], - "Origin": config.Origin.String(), - "Sec-Websocket-Protocol": "chat, superchat", - "Sec-Websocket-Version": fmt.Sprintf("%d", ProtocolVersionHybi13), - } - for k, v := range expectedHeader { - if req.Header.Get(k) != v { - t.Errorf("%s expected %s, but got %v", k, v, req.Header.Get(k)) - } - } - } -} - -func TestHybiClientHandshakeWithHeader(t *testing.T) { - b := bytes.NewBuffer([]byte{}) - bw := bufio.NewWriter(b) - br := bufio.NewReader(strings.NewReader(`HTTP/1.1 101 Switching Protocols -Upgrade: websocket -Connection: Upgrade -Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= -Sec-WebSocket-Protocol: chat - -`)) - var err error - config := new(Config) - config.Location, err = url.ParseRequestURI("ws://server.example.com/chat") - if err != nil { - t.Fatal("location url", err) - } - config.Origin, err = url.ParseRequestURI("http://example.com") - if err != nil { - t.Fatal("origin url", err) - } - config.Protocol = append(config.Protocol, "chat") - config.Protocol = append(config.Protocol, "superchat") - config.Version = ProtocolVersionHybi13 - config.Header = http.Header(make(map[string][]string)) - config.Header.Add("User-Agent", "test") - - config.handshakeData = map[string]string{ - "key": "dGhlIHNhbXBsZSBub25jZQ==", - } - err = hybiClientHandshake(config, br, bw) - if err != nil { - t.Errorf("handshake failed: %v", err) - } - req, err := http.ReadRequest(bufio.NewReader(b)) - if err != nil { - t.Fatalf("read request: %v", err) - } - if req.Method != "GET" { - t.Errorf("request method expected GET, but got %q", req.Method) - } - if req.URL.Path != "/chat" { - t.Errorf("request path expected /chat, but got %q", req.URL.Path) - } - if req.Proto != "HTTP/1.1" { - t.Errorf("request proto expected HTTP/1.1, but got %q", req.Proto) - } - if req.Host != "server.example.com" { - t.Errorf("request Host expected server.example.com, but got %v", req.Host) - } - var expectedHeader = map[string]string{ - "Connection": "Upgrade", - "Upgrade": "websocket", - "Sec-Websocket-Key": config.handshakeData["key"], - "Origin": config.Origin.String(), - "Sec-Websocket-Protocol": "chat, superchat", - "Sec-Websocket-Version": fmt.Sprintf("%d", ProtocolVersionHybi13), - "User-Agent": "test", - } - for k, v := range expectedHeader { - if req.Header.Get(k) != v { - t.Errorf(fmt.Sprintf("%s expected %q but got %q", k, v, req.Header.Get(k))) - } - } -} - -func TestHybiServerHandshake(t *testing.T) { - config := new(Config) - handshaker := &hybiServerHandshaker{Config: config} - br := bufio.NewReader(strings.NewReader(`GET /chat HTTP/1.1 -Host: server.example.com -Upgrade: websocket -Connection: Upgrade -Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== -Origin: http://example.com -Sec-WebSocket-Protocol: chat, superchat -Sec-WebSocket-Version: 13 - -`)) - req, err := http.ReadRequest(br) - if err != nil { - t.Fatal("request", err) - } - code, err := handshaker.ReadHandshake(br, req) - if err != nil { - t.Errorf("handshake failed: %v", err) - } - if code != http.StatusSwitchingProtocols { - t.Errorf("status expected %q but got %q", http.StatusSwitchingProtocols, code) - } - expectedProtocols := []string{"chat", "superchat"} - if fmt.Sprintf("%v", config.Protocol) != fmt.Sprintf("%v", expectedProtocols) { - t.Errorf("protocol expected %q but got %q", expectedProtocols, config.Protocol) - } - b := bytes.NewBuffer([]byte{}) - bw := bufio.NewWriter(b) - - config.Protocol = config.Protocol[:1] - - err = handshaker.AcceptHandshake(bw) - if err != nil { - t.Errorf("handshake response failed: %v", err) - } - expectedResponse := strings.Join([]string{ - "HTTP/1.1 101 Switching Protocols", - "Upgrade: websocket", - "Connection: Upgrade", - "Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", - "Sec-WebSocket-Protocol: chat", - "", ""}, "\r\n") - - if b.String() != expectedResponse { - t.Errorf("handshake expected %q but got %q", expectedResponse, b.String()) - } -} - -func TestHybiServerHandshakeNoSubProtocol(t *testing.T) { - config := new(Config) - handshaker := &hybiServerHandshaker{Config: config} - br := bufio.NewReader(strings.NewReader(`GET /chat HTTP/1.1 -Host: server.example.com -Upgrade: websocket -Connection: Upgrade -Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== -Origin: http://example.com -Sec-WebSocket-Version: 13 - -`)) - req, err := http.ReadRequest(br) - if err != nil { - t.Fatal("request", err) - } - code, err := handshaker.ReadHandshake(br, req) - if err != nil { - t.Errorf("handshake failed: %v", err) - } - if code != http.StatusSwitchingProtocols { - t.Errorf("status expected %q but got %q", http.StatusSwitchingProtocols, code) - } - if len(config.Protocol) != 0 { - t.Errorf("len(config.Protocol) expected 0, but got %q", len(config.Protocol)) - } - b := bytes.NewBuffer([]byte{}) - bw := bufio.NewWriter(b) - - err = handshaker.AcceptHandshake(bw) - if err != nil { - t.Errorf("handshake response failed: %v", err) - } - expectedResponse := strings.Join([]string{ - "HTTP/1.1 101 Switching Protocols", - "Upgrade: websocket", - "Connection: Upgrade", - "Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", - "", ""}, "\r\n") - - if b.String() != expectedResponse { - t.Errorf("handshake expected %q but got %q", expectedResponse, b.String()) - } -} - -func TestHybiServerHandshakeHybiBadVersion(t *testing.T) { - config := new(Config) - handshaker := &hybiServerHandshaker{Config: config} - br := bufio.NewReader(strings.NewReader(`GET /chat HTTP/1.1 -Host: server.example.com -Upgrade: websocket -Connection: Upgrade -Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== -Sec-WebSocket-Origin: http://example.com -Sec-WebSocket-Protocol: chat, superchat -Sec-WebSocket-Version: 9 - -`)) - req, err := http.ReadRequest(br) - if err != nil { - t.Fatal("request", err) - } - code, err := handshaker.ReadHandshake(br, req) - if err != ErrBadWebSocketVersion { - t.Errorf("handshake expected err %q but got %q", ErrBadWebSocketVersion, err) - } - if code != http.StatusBadRequest { - t.Errorf("status expected %q but got %q", http.StatusBadRequest, code) - } -} - -func testHybiFrame(t *testing.T, testHeader, testPayload, testMaskedPayload []byte, frameHeader *hybiFrameHeader) { - b := bytes.NewBuffer([]byte{}) - frameWriterFactory := &hybiFrameWriterFactory{bufio.NewWriter(b), false} - w, _ := frameWriterFactory.NewFrameWriter(TextFrame) - w.(*hybiFrameWriter).header = frameHeader - _, err := w.Write(testPayload) - w.Close() - if err != nil { - t.Errorf("Write error %q", err) - } - var expectedFrame []byte - expectedFrame = append(expectedFrame, testHeader...) - expectedFrame = append(expectedFrame, testMaskedPayload...) - if !bytes.Equal(expectedFrame, b.Bytes()) { - t.Errorf("frame expected %q got %q", expectedFrame, b.Bytes()) - } - frameReaderFactory := &hybiFrameReaderFactory{bufio.NewReader(b)} - r, err := frameReaderFactory.NewFrameReader() - if err != nil { - t.Errorf("Read error %q", err) - } - if header := r.HeaderReader(); header == nil { - t.Errorf("no header") - } else { - actualHeader := make([]byte, r.Len()) - n, err := header.Read(actualHeader) - if err != nil { - t.Errorf("Read header error %q", err) - } else { - if n < len(testHeader) { - t.Errorf("header too short %q got %q", testHeader, actualHeader[:n]) - } - if !bytes.Equal(testHeader, actualHeader[:n]) { - t.Errorf("header expected %q got %q", testHeader, actualHeader[:n]) - } - } - } - if trailer := r.TrailerReader(); trailer != nil { - t.Errorf("unexpected trailer %q", trailer) - } - frame := r.(*hybiFrameReader) - if frameHeader.Fin != frame.header.Fin || - frameHeader.OpCode != frame.header.OpCode || - len(testPayload) != int(frame.header.Length) { - t.Errorf("mismatch %v (%d) vs %v", frameHeader, len(testPayload), frame) - } - payload := make([]byte, len(testPayload)) - _, err = r.Read(payload) - if err != nil && err != io.EOF { - t.Errorf("read %v", err) - } - if !bytes.Equal(testPayload, payload) { - t.Errorf("payload %q vs %q", testPayload, payload) - } -} - -func TestHybiShortTextFrame(t *testing.T) { - frameHeader := &hybiFrameHeader{Fin: true, OpCode: TextFrame} - payload := []byte("hello") - testHybiFrame(t, []byte{0x81, 0x05}, payload, payload, frameHeader) - - payload = make([]byte, 125) - testHybiFrame(t, []byte{0x81, 125}, payload, payload, frameHeader) -} - -func TestHybiShortMaskedTextFrame(t *testing.T) { - frameHeader := &hybiFrameHeader{Fin: true, OpCode: TextFrame, - MaskingKey: []byte{0xcc, 0x55, 0x80, 0x20}} - payload := []byte("hello") - maskedPayload := []byte{0xa4, 0x30, 0xec, 0x4c, 0xa3} - header := []byte{0x81, 0x85} - header = append(header, frameHeader.MaskingKey...) - testHybiFrame(t, header, payload, maskedPayload, frameHeader) -} - -func TestHybiShortBinaryFrame(t *testing.T) { - frameHeader := &hybiFrameHeader{Fin: true, OpCode: BinaryFrame} - payload := []byte("hello") - testHybiFrame(t, []byte{0x82, 0x05}, payload, payload, frameHeader) - - payload = make([]byte, 125) - testHybiFrame(t, []byte{0x82, 125}, payload, payload, frameHeader) -} - -func TestHybiControlFrame(t *testing.T) { - payload := []byte("hello") - - frameHeader := &hybiFrameHeader{Fin: true, OpCode: PingFrame} - testHybiFrame(t, []byte{0x89, 0x05}, payload, payload, frameHeader) - - frameHeader = &hybiFrameHeader{Fin: true, OpCode: PingFrame} - testHybiFrame(t, []byte{0x89, 0x00}, nil, nil, frameHeader) - - frameHeader = &hybiFrameHeader{Fin: true, OpCode: PongFrame} - testHybiFrame(t, []byte{0x8A, 0x05}, payload, payload, frameHeader) - - frameHeader = &hybiFrameHeader{Fin: true, OpCode: PongFrame} - testHybiFrame(t, []byte{0x8A, 0x00}, nil, nil, frameHeader) - - frameHeader = &hybiFrameHeader{Fin: true, OpCode: CloseFrame} - payload = []byte{0x03, 0xe8} // 1000 - testHybiFrame(t, []byte{0x88, 0x02}, payload, payload, frameHeader) -} - -func TestHybiLongFrame(t *testing.T) { - frameHeader := &hybiFrameHeader{Fin: true, OpCode: TextFrame} - payload := make([]byte, 126) - testHybiFrame(t, []byte{0x81, 126, 0x00, 126}, payload, payload, frameHeader) - - payload = make([]byte, 65535) - testHybiFrame(t, []byte{0x81, 126, 0xff, 0xff}, payload, payload, frameHeader) - - payload = make([]byte, 65536) - testHybiFrame(t, []byte{0x81, 127, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00}, payload, payload, frameHeader) -} - -func TestHybiClientRead(t *testing.T) { - wireData := []byte{0x81, 0x05, 'h', 'e', 'l', 'l', 'o', - 0x89, 0x05, 'h', 'e', 'l', 'l', 'o', // ping - 0x81, 0x05, 'w', 'o', 'r', 'l', 'd'} - br := bufio.NewReader(bytes.NewBuffer(wireData)) - bw := bufio.NewWriter(bytes.NewBuffer([]byte{})) - conn := newHybiConn(newConfig(t, "/"), bufio.NewReadWriter(br, bw), nil, nil) - - msg := make([]byte, 512) - n, err := conn.Read(msg) - if err != nil { - t.Errorf("read 1st frame, error %q", err) - } - if n != 5 { - t.Errorf("read 1st frame, expect 5, got %d", n) - } - if !bytes.Equal(wireData[2:7], msg[:n]) { - t.Errorf("read 1st frame %v, got %v", wireData[2:7], msg[:n]) - } - n, err = conn.Read(msg) - if err != nil { - t.Errorf("read 2nd frame, error %q", err) - } - if n != 5 { - t.Errorf("read 2nd frame, expect 5, got %d", n) - } - if !bytes.Equal(wireData[16:21], msg[:n]) { - t.Errorf("read 2nd frame %v, got %v", wireData[16:21], msg[:n]) - } - n, err = conn.Read(msg) - if err == nil { - t.Errorf("read not EOF") - } - if n != 0 { - t.Errorf("expect read 0, got %d", n) - } -} - -func TestHybiShortRead(t *testing.T) { - wireData := []byte{0x81, 0x05, 'h', 'e', 'l', 'l', 'o', - 0x89, 0x05, 'h', 'e', 'l', 'l', 'o', // ping - 0x81, 0x05, 'w', 'o', 'r', 'l', 'd'} - br := bufio.NewReader(bytes.NewBuffer(wireData)) - bw := bufio.NewWriter(bytes.NewBuffer([]byte{})) - conn := newHybiConn(newConfig(t, "/"), bufio.NewReadWriter(br, bw), nil, nil) - - step := 0 - pos := 0 - expectedPos := []int{2, 5, 16, 19} - expectedLen := []int{3, 2, 3, 2} - for { - msg := make([]byte, 3) - n, err := conn.Read(msg) - if step >= len(expectedPos) { - if err == nil { - t.Errorf("read not EOF") - } - if n != 0 { - t.Errorf("expect read 0, got %d", n) - } - return - } - pos = expectedPos[step] - endPos := pos + expectedLen[step] - if err != nil { - t.Errorf("read from %d, got error %q", pos, err) - return - } - if n != endPos-pos { - t.Errorf("read from %d, expect %d, got %d", pos, endPos-pos, n) - } - if !bytes.Equal(wireData[pos:endPos], msg[:n]) { - t.Errorf("read from %d, frame %v, got %v", pos, wireData[pos:endPos], msg[:n]) - } - step++ - } -} - -func TestHybiServerRead(t *testing.T) { - wireData := []byte{0x81, 0x85, 0xcc, 0x55, 0x80, 0x20, - 0xa4, 0x30, 0xec, 0x4c, 0xa3, // hello - 0x89, 0x85, 0xcc, 0x55, 0x80, 0x20, - 0xa4, 0x30, 0xec, 0x4c, 0xa3, // ping: hello - 0x81, 0x85, 0xed, 0x83, 0xb4, 0x24, - 0x9a, 0xec, 0xc6, 0x48, 0x89, // world - } - br := bufio.NewReader(bytes.NewBuffer(wireData)) - bw := bufio.NewWriter(bytes.NewBuffer([]byte{})) - conn := newHybiConn(newConfig(t, "/"), bufio.NewReadWriter(br, bw), nil, new(http.Request)) - - expected := [][]byte{[]byte("hello"), []byte("world")} - - msg := make([]byte, 512) - n, err := conn.Read(msg) - if err != nil { - t.Errorf("read 1st frame, error %q", err) - } - if n != 5 { - t.Errorf("read 1st frame, expect 5, got %d", n) - } - if !bytes.Equal(expected[0], msg[:n]) { - t.Errorf("read 1st frame %q, got %q", expected[0], msg[:n]) - } - - n, err = conn.Read(msg) - if err != nil { - t.Errorf("read 2nd frame, error %q", err) - } - if n != 5 { - t.Errorf("read 2nd frame, expect 5, got %d", n) - } - if !bytes.Equal(expected[1], msg[:n]) { - t.Errorf("read 2nd frame %q, got %q", expected[1], msg[:n]) - } - - n, err = conn.Read(msg) - if err == nil { - t.Errorf("read not EOF") - } - if n != 0 { - t.Errorf("expect read 0, got %d", n) - } -} - -func TestHybiServerReadWithoutMasking(t *testing.T) { - wireData := []byte{0x81, 0x05, 'h', 'e', 'l', 'l', 'o'} - br := bufio.NewReader(bytes.NewBuffer(wireData)) - bw := bufio.NewWriter(bytes.NewBuffer([]byte{})) - conn := newHybiConn(newConfig(t, "/"), bufio.NewReadWriter(br, bw), nil, new(http.Request)) - // server MUST close the connection upon receiving a non-masked frame. - msg := make([]byte, 512) - _, err := conn.Read(msg) - if err != io.EOF { - t.Errorf("read 1st frame, expect %q, but got %q", io.EOF, err) - } -} - -func TestHybiClientReadWithMasking(t *testing.T) { - wireData := []byte{0x81, 0x85, 0xcc, 0x55, 0x80, 0x20, - 0xa4, 0x30, 0xec, 0x4c, 0xa3, // hello - } - br := bufio.NewReader(bytes.NewBuffer(wireData)) - bw := bufio.NewWriter(bytes.NewBuffer([]byte{})) - conn := newHybiConn(newConfig(t, "/"), bufio.NewReadWriter(br, bw), nil, nil) - - // client MUST close the connection upon receiving a masked frame. - msg := make([]byte, 512) - _, err := conn.Read(msg) - if err != io.EOF { - t.Errorf("read 1st frame, expect %q, but got %q", io.EOF, err) - } -} - -// Test the hybiServerHandshaker supports firefox implementation and -// checks Connection request header include (but it's not necessary -// equal to) "upgrade" -func TestHybiServerFirefoxHandshake(t *testing.T) { - config := new(Config) - handshaker := &hybiServerHandshaker{Config: config} - br := bufio.NewReader(strings.NewReader(`GET /chat HTTP/1.1 -Host: server.example.com -Upgrade: websocket -Connection: keep-alive, upgrade -Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== -Origin: http://example.com -Sec-WebSocket-Protocol: chat, superchat -Sec-WebSocket-Version: 13 - -`)) - req, err := http.ReadRequest(br) - if err != nil { - t.Fatal("request", err) - } - code, err := handshaker.ReadHandshake(br, req) - if err != nil { - t.Errorf("handshake failed: %v", err) - } - if code != http.StatusSwitchingProtocols { - t.Errorf("status expected %q but got %q", http.StatusSwitchingProtocols, code) - } - b := bytes.NewBuffer([]byte{}) - bw := bufio.NewWriter(b) - - config.Protocol = []string{"chat"} - - err = handshaker.AcceptHandshake(bw) - if err != nil { - t.Errorf("handshake response failed: %v", err) - } - expectedResponse := strings.Join([]string{ - "HTTP/1.1 101 Switching Protocols", - "Upgrade: websocket", - "Connection: Upgrade", - "Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", - "Sec-WebSocket-Protocol: chat", - "", ""}, "\r\n") - - if b.String() != expectedResponse { - t.Errorf("handshake expected %q but got %q", expectedResponse, b.String()) - } -} diff --git a/vendor/golang.org/x/net/websocket/server.go b/vendor/golang.org/x/net/websocket/server.go deleted file mode 100644 index 0895dea19..000000000 --- a/vendor/golang.org/x/net/websocket/server.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package websocket - -import ( - "bufio" - "fmt" - "io" - "net/http" -) - -func newServerConn(rwc io.ReadWriteCloser, buf *bufio.ReadWriter, req *http.Request, config *Config, handshake func(*Config, *http.Request) error) (conn *Conn, err error) { - var hs serverHandshaker = &hybiServerHandshaker{Config: config} - code, err := hs.ReadHandshake(buf.Reader, req) - if err == ErrBadWebSocketVersion { - fmt.Fprintf(buf, "HTTP/1.1 %03d %s\r\n", code, http.StatusText(code)) - fmt.Fprintf(buf, "Sec-WebSocket-Version: %s\r\n", SupportedProtocolVersion) - buf.WriteString("\r\n") - buf.WriteString(err.Error()) - buf.Flush() - return - } - if err != nil { - fmt.Fprintf(buf, "HTTP/1.1 %03d %s\r\n", code, http.StatusText(code)) - buf.WriteString("\r\n") - buf.WriteString(err.Error()) - buf.Flush() - return - } - if handshake != nil { - err = handshake(config, req) - if err != nil { - code = http.StatusForbidden - fmt.Fprintf(buf, "HTTP/1.1 %03d %s\r\n", code, http.StatusText(code)) - buf.WriteString("\r\n") - buf.Flush() - return - } - } - err = hs.AcceptHandshake(buf.Writer) - if err != nil { - code = http.StatusBadRequest - fmt.Fprintf(buf, "HTTP/1.1 %03d %s\r\n", code, http.StatusText(code)) - buf.WriteString("\r\n") - buf.Flush() - return - } - conn = hs.NewServerConn(buf, rwc, req) - return -} - -// Server represents a server of a WebSocket. -type Server struct { - // Config is a WebSocket configuration for new WebSocket connection. - Config - - // Handshake is an optional function in WebSocket handshake. - // For example, you can check, or don't check Origin header. - // Another example, you can select config.Protocol. - Handshake func(*Config, *http.Request) error - - // Handler handles a WebSocket connection. - Handler -} - -// ServeHTTP implements the http.Handler interface for a WebSocket -func (s Server) ServeHTTP(w http.ResponseWriter, req *http.Request) { - s.serveWebSocket(w, req) -} - -func (s Server) serveWebSocket(w http.ResponseWriter, req *http.Request) { - rwc, buf, err := w.(http.Hijacker).Hijack() - if err != nil { - panic("Hijack failed: " + err.Error()) - } - // The server should abort the WebSocket connection if it finds - // the client did not send a handshake that matches with protocol - // specification. - defer rwc.Close() - conn, err := newServerConn(rwc, buf, req, &s.Config, s.Handshake) - if err != nil { - return - } - if conn == nil { - panic("unexpected nil conn") - } - s.Handler(conn) -} - -// Handler is a simple interface to a WebSocket browser client. -// It checks if Origin header is valid URL by default. -// You might want to verify websocket.Conn.Config().Origin in the func. -// If you use Server instead of Handler, you could call websocket.Origin and -// check the origin in your Handshake func. So, if you want to accept -// non-browser clients, which do not send an Origin header, set a -// Server.Handshake that does not check the origin. -type Handler func(*Conn) - -func checkOrigin(config *Config, req *http.Request) (err error) { - config.Origin, err = Origin(config, req) - if err == nil && config.Origin == nil { - return fmt.Errorf("null origin") - } - return err -} - -// ServeHTTP implements the http.Handler interface for a WebSocket -func (h Handler) ServeHTTP(w http.ResponseWriter, req *http.Request) { - s := Server{Handler: h, Handshake: checkOrigin} - s.serveWebSocket(w, req) -} diff --git a/vendor/golang.org/x/net/websocket/websocket.go b/vendor/golang.org/x/net/websocket/websocket.go deleted file mode 100644 index e242c89a7..000000000 --- a/vendor/golang.org/x/net/websocket/websocket.go +++ /dev/null @@ -1,448 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package websocket implements a client and server for the WebSocket protocol -// as specified in RFC 6455. -// -// This package currently lacks some features found in an alternative -// and more actively maintained WebSocket package: -// -// https://godoc.org/github.com/gorilla/websocket -// -package websocket // import "golang.org/x/net/websocket" - -import ( - "bufio" - "crypto/tls" - "encoding/json" - "errors" - "io" - "io/ioutil" - "net" - "net/http" - "net/url" - "sync" - "time" -) - -const ( - ProtocolVersionHybi13 = 13 - ProtocolVersionHybi = ProtocolVersionHybi13 - SupportedProtocolVersion = "13" - - ContinuationFrame = 0 - TextFrame = 1 - BinaryFrame = 2 - CloseFrame = 8 - PingFrame = 9 - PongFrame = 10 - UnknownFrame = 255 - - DefaultMaxPayloadBytes = 32 << 20 // 32MB -) - -// ProtocolError represents WebSocket protocol errors. -type ProtocolError struct { - ErrorString string -} - -func (err *ProtocolError) Error() string { return err.ErrorString } - -var ( - ErrBadProtocolVersion = &ProtocolError{"bad protocol version"} - ErrBadScheme = &ProtocolError{"bad scheme"} - ErrBadStatus = &ProtocolError{"bad status"} - ErrBadUpgrade = &ProtocolError{"missing or bad upgrade"} - ErrBadWebSocketOrigin = &ProtocolError{"missing or bad WebSocket-Origin"} - ErrBadWebSocketLocation = &ProtocolError{"missing or bad WebSocket-Location"} - ErrBadWebSocketProtocol = &ProtocolError{"missing or bad WebSocket-Protocol"} - ErrBadWebSocketVersion = &ProtocolError{"missing or bad WebSocket Version"} - ErrChallengeResponse = &ProtocolError{"mismatch challenge/response"} - ErrBadFrame = &ProtocolError{"bad frame"} - ErrBadFrameBoundary = &ProtocolError{"not on frame boundary"} - ErrNotWebSocket = &ProtocolError{"not websocket protocol"} - ErrBadRequestMethod = &ProtocolError{"bad method"} - ErrNotSupported = &ProtocolError{"not supported"} -) - -// ErrFrameTooLarge is returned by Codec's Receive method if payload size -// exceeds limit set by Conn.MaxPayloadBytes -var ErrFrameTooLarge = errors.New("websocket: frame payload size exceeds limit") - -// Addr is an implementation of net.Addr for WebSocket. -type Addr struct { - *url.URL -} - -// Network returns the network type for a WebSocket, "websocket". -func (addr *Addr) Network() string { return "websocket" } - -// Config is a WebSocket configuration -type Config struct { - // A WebSocket server address. - Location *url.URL - - // A Websocket client origin. - Origin *url.URL - - // WebSocket subprotocols. - Protocol []string - - // WebSocket protocol version. - Version int - - // TLS config for secure WebSocket (wss). - TlsConfig *tls.Config - - // Additional header fields to be sent in WebSocket opening handshake. - Header http.Header - - // Dialer used when opening websocket connections. - Dialer *net.Dialer - - handshakeData map[string]string -} - -// serverHandshaker is an interface to handle WebSocket server side handshake. -type serverHandshaker interface { - // ReadHandshake reads handshake request message from client. - // Returns http response code and error if any. - ReadHandshake(buf *bufio.Reader, req *http.Request) (code int, err error) - - // AcceptHandshake accepts the client handshake request and sends - // handshake response back to client. - AcceptHandshake(buf *bufio.Writer) (err error) - - // NewServerConn creates a new WebSocket connection. - NewServerConn(buf *bufio.ReadWriter, rwc io.ReadWriteCloser, request *http.Request) (conn *Conn) -} - -// frameReader is an interface to read a WebSocket frame. -type frameReader interface { - // Reader is to read payload of the frame. - io.Reader - - // PayloadType returns payload type. - PayloadType() byte - - // HeaderReader returns a reader to read header of the frame. - HeaderReader() io.Reader - - // TrailerReader returns a reader to read trailer of the frame. - // If it returns nil, there is no trailer in the frame. - TrailerReader() io.Reader - - // Len returns total length of the frame, including header and trailer. - Len() int -} - -// frameReaderFactory is an interface to creates new frame reader. -type frameReaderFactory interface { - NewFrameReader() (r frameReader, err error) -} - -// frameWriter is an interface to write a WebSocket frame. -type frameWriter interface { - // Writer is to write payload of the frame. - io.WriteCloser -} - -// frameWriterFactory is an interface to create new frame writer. -type frameWriterFactory interface { - NewFrameWriter(payloadType byte) (w frameWriter, err error) -} - -type frameHandler interface { - HandleFrame(frame frameReader) (r frameReader, err error) - WriteClose(status int) (err error) -} - -// Conn represents a WebSocket connection. -// -// Multiple goroutines may invoke methods on a Conn simultaneously. -type Conn struct { - config *Config - request *http.Request - - buf *bufio.ReadWriter - rwc io.ReadWriteCloser - - rio sync.Mutex - frameReaderFactory - frameReader - - wio sync.Mutex - frameWriterFactory - - frameHandler - PayloadType byte - defaultCloseStatus int - - // MaxPayloadBytes limits the size of frame payload received over Conn - // by Codec's Receive method. If zero, DefaultMaxPayloadBytes is used. - MaxPayloadBytes int -} - -// Read implements the io.Reader interface: -// it reads data of a frame from the WebSocket connection. -// if msg is not large enough for the frame data, it fills the msg and next Read -// will read the rest of the frame data. -// it reads Text frame or Binary frame. -func (ws *Conn) Read(msg []byte) (n int, err error) { - ws.rio.Lock() - defer ws.rio.Unlock() -again: - if ws.frameReader == nil { - frame, err := ws.frameReaderFactory.NewFrameReader() - if err != nil { - return 0, err - } - ws.frameReader, err = ws.frameHandler.HandleFrame(frame) - if err != nil { - return 0, err - } - if ws.frameReader == nil { - goto again - } - } - n, err = ws.frameReader.Read(msg) - if err == io.EOF { - if trailer := ws.frameReader.TrailerReader(); trailer != nil { - io.Copy(ioutil.Discard, trailer) - } - ws.frameReader = nil - goto again - } - return n, err -} - -// Write implements the io.Writer interface: -// it writes data as a frame to the WebSocket connection. -func (ws *Conn) Write(msg []byte) (n int, err error) { - ws.wio.Lock() - defer ws.wio.Unlock() - w, err := ws.frameWriterFactory.NewFrameWriter(ws.PayloadType) - if err != nil { - return 0, err - } - n, err = w.Write(msg) - w.Close() - return n, err -} - -// Close implements the io.Closer interface. -func (ws *Conn) Close() error { - err := ws.frameHandler.WriteClose(ws.defaultCloseStatus) - err1 := ws.rwc.Close() - if err != nil { - return err - } - return err1 -} - -func (ws *Conn) IsClientConn() bool { return ws.request == nil } -func (ws *Conn) IsServerConn() bool { return ws.request != nil } - -// LocalAddr returns the WebSocket Origin for the connection for client, or -// the WebSocket location for server. -func (ws *Conn) LocalAddr() net.Addr { - if ws.IsClientConn() { - return &Addr{ws.config.Origin} - } - return &Addr{ws.config.Location} -} - -// RemoteAddr returns the WebSocket location for the connection for client, or -// the Websocket Origin for server. -func (ws *Conn) RemoteAddr() net.Addr { - if ws.IsClientConn() { - return &Addr{ws.config.Location} - } - return &Addr{ws.config.Origin} -} - -var errSetDeadline = errors.New("websocket: cannot set deadline: not using a net.Conn") - -// SetDeadline sets the connection's network read & write deadlines. -func (ws *Conn) SetDeadline(t time.Time) error { - if conn, ok := ws.rwc.(net.Conn); ok { - return conn.SetDeadline(t) - } - return errSetDeadline -} - -// SetReadDeadline sets the connection's network read deadline. -func (ws *Conn) SetReadDeadline(t time.Time) error { - if conn, ok := ws.rwc.(net.Conn); ok { - return conn.SetReadDeadline(t) - } - return errSetDeadline -} - -// SetWriteDeadline sets the connection's network write deadline. -func (ws *Conn) SetWriteDeadline(t time.Time) error { - if conn, ok := ws.rwc.(net.Conn); ok { - return conn.SetWriteDeadline(t) - } - return errSetDeadline -} - -// Config returns the WebSocket config. -func (ws *Conn) Config() *Config { return ws.config } - -// Request returns the http request upgraded to the WebSocket. -// It is nil for client side. -func (ws *Conn) Request() *http.Request { return ws.request } - -// Codec represents a symmetric pair of functions that implement a codec. -type Codec struct { - Marshal func(v interface{}) (data []byte, payloadType byte, err error) - Unmarshal func(data []byte, payloadType byte, v interface{}) (err error) -} - -// Send sends v marshaled by cd.Marshal as single frame to ws. -func (cd Codec) Send(ws *Conn, v interface{}) (err error) { - data, payloadType, err := cd.Marshal(v) - if err != nil { - return err - } - ws.wio.Lock() - defer ws.wio.Unlock() - w, err := ws.frameWriterFactory.NewFrameWriter(payloadType) - if err != nil { - return err - } - _, err = w.Write(data) - w.Close() - return err -} - -// Receive receives single frame from ws, unmarshaled by cd.Unmarshal and stores -// in v. The whole frame payload is read to an in-memory buffer; max size of -// payload is defined by ws.MaxPayloadBytes. If frame payload size exceeds -// limit, ErrFrameTooLarge is returned; in this case frame is not read off wire -// completely. The next call to Receive would read and discard leftover data of -// previous oversized frame before processing next frame. -func (cd Codec) Receive(ws *Conn, v interface{}) (err error) { - ws.rio.Lock() - defer ws.rio.Unlock() - if ws.frameReader != nil { - _, err = io.Copy(ioutil.Discard, ws.frameReader) - if err != nil { - return err - } - ws.frameReader = nil - } -again: - frame, err := ws.frameReaderFactory.NewFrameReader() - if err != nil { - return err - } - frame, err = ws.frameHandler.HandleFrame(frame) - if err != nil { - return err - } - if frame == nil { - goto again - } - maxPayloadBytes := ws.MaxPayloadBytes - if maxPayloadBytes == 0 { - maxPayloadBytes = DefaultMaxPayloadBytes - } - if hf, ok := frame.(*hybiFrameReader); ok && hf.header.Length > int64(maxPayloadBytes) { - // payload size exceeds limit, no need to call Unmarshal - // - // set frameReader to current oversized frame so that - // the next call to this function can drain leftover - // data before processing the next frame - ws.frameReader = frame - return ErrFrameTooLarge - } - payloadType := frame.PayloadType() - data, err := ioutil.ReadAll(frame) - if err != nil { - return err - } - return cd.Unmarshal(data, payloadType, v) -} - -func marshal(v interface{}) (msg []byte, payloadType byte, err error) { - switch data := v.(type) { - case string: - return []byte(data), TextFrame, nil - case []byte: - return data, BinaryFrame, nil - } - return nil, UnknownFrame, ErrNotSupported -} - -func unmarshal(msg []byte, payloadType byte, v interface{}) (err error) { - switch data := v.(type) { - case *string: - *data = string(msg) - return nil - case *[]byte: - *data = msg - return nil - } - return ErrNotSupported -} - -/* -Message is a codec to send/receive text/binary data in a frame on WebSocket connection. -To send/receive text frame, use string type. -To send/receive binary frame, use []byte type. - -Trivial usage: - - import "websocket" - - // receive text frame - var message string - websocket.Message.Receive(ws, &message) - - // send text frame - message = "hello" - websocket.Message.Send(ws, message) - - // receive binary frame - var data []byte - websocket.Message.Receive(ws, &data) - - // send binary frame - data = []byte{0, 1, 2} - websocket.Message.Send(ws, data) - -*/ -var Message = Codec{marshal, unmarshal} - -func jsonMarshal(v interface{}) (msg []byte, payloadType byte, err error) { - msg, err = json.Marshal(v) - return msg, TextFrame, err -} - -func jsonUnmarshal(msg []byte, payloadType byte, v interface{}) (err error) { - return json.Unmarshal(msg, v) -} - -/* -JSON is a codec to send/receive JSON data in a frame from a WebSocket connection. - -Trivial usage: - - import "websocket" - - type T struct { - Msg string - Count int - } - - // receive JSON type T - var data T - websocket.JSON.Receive(ws, &data) - - // send JSON type T - websocket.JSON.Send(ws, data) -*/ -var JSON = Codec{jsonMarshal, jsonUnmarshal} diff --git a/vendor/golang.org/x/net/websocket/websocket_test.go b/vendor/golang.org/x/net/websocket/websocket_test.go deleted file mode 100644 index 2054ce85a..000000000 --- a/vendor/golang.org/x/net/websocket/websocket_test.go +++ /dev/null @@ -1,665 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package websocket - -import ( - "bytes" - "crypto/rand" - "fmt" - "io" - "log" - "net" - "net/http" - "net/http/httptest" - "net/url" - "reflect" - "runtime" - "strings" - "sync" - "testing" - "time" -) - -var serverAddr string -var once sync.Once - -func echoServer(ws *Conn) { - defer ws.Close() - io.Copy(ws, ws) -} - -type Count struct { - S string - N int -} - -func countServer(ws *Conn) { - defer ws.Close() - for { - var count Count - err := JSON.Receive(ws, &count) - if err != nil { - return - } - count.N++ - count.S = strings.Repeat(count.S, count.N) - err = JSON.Send(ws, count) - if err != nil { - return - } - } -} - -type testCtrlAndDataHandler struct { - hybiFrameHandler -} - -func (h *testCtrlAndDataHandler) WritePing(b []byte) (int, error) { - h.hybiFrameHandler.conn.wio.Lock() - defer h.hybiFrameHandler.conn.wio.Unlock() - w, err := h.hybiFrameHandler.conn.frameWriterFactory.NewFrameWriter(PingFrame) - if err != nil { - return 0, err - } - n, err := w.Write(b) - w.Close() - return n, err -} - -func ctrlAndDataServer(ws *Conn) { - defer ws.Close() - h := &testCtrlAndDataHandler{hybiFrameHandler: hybiFrameHandler{conn: ws}} - ws.frameHandler = h - - go func() { - for i := 0; ; i++ { - var b []byte - if i%2 != 0 { // with or without payload - b = []byte(fmt.Sprintf("#%d-CONTROL-FRAME-FROM-SERVER", i)) - } - if _, err := h.WritePing(b); err != nil { - break - } - if _, err := h.WritePong(b); err != nil { // unsolicited pong - break - } - time.Sleep(10 * time.Millisecond) - } - }() - - b := make([]byte, 128) - for { - n, err := ws.Read(b) - if err != nil { - break - } - if _, err := ws.Write(b[:n]); err != nil { - break - } - } -} - -func subProtocolHandshake(config *Config, req *http.Request) error { - for _, proto := range config.Protocol { - if proto == "chat" { - config.Protocol = []string{proto} - return nil - } - } - return ErrBadWebSocketProtocol -} - -func subProtoServer(ws *Conn) { - for _, proto := range ws.Config().Protocol { - io.WriteString(ws, proto) - } -} - -func startServer() { - http.Handle("/echo", Handler(echoServer)) - http.Handle("/count", Handler(countServer)) - http.Handle("/ctrldata", Handler(ctrlAndDataServer)) - subproto := Server{ - Handshake: subProtocolHandshake, - Handler: Handler(subProtoServer), - } - http.Handle("/subproto", subproto) - server := httptest.NewServer(nil) - serverAddr = server.Listener.Addr().String() - log.Print("Test WebSocket server listening on ", serverAddr) -} - -func newConfig(t *testing.T, path string) *Config { - config, _ := NewConfig(fmt.Sprintf("ws://%s%s", serverAddr, path), "http://localhost") - return config -} - -func TestEcho(t *testing.T) { - once.Do(startServer) - - // websocket.Dial() - client, err := net.Dial("tcp", serverAddr) - if err != nil { - t.Fatal("dialing", err) - } - conn, err := NewClient(newConfig(t, "/echo"), client) - if err != nil { - t.Errorf("WebSocket handshake error: %v", err) - return - } - - msg := []byte("hello, world\n") - if _, err := conn.Write(msg); err != nil { - t.Errorf("Write: %v", err) - } - var actual_msg = make([]byte, 512) - n, err := conn.Read(actual_msg) - if err != nil { - t.Errorf("Read: %v", err) - } - actual_msg = actual_msg[0:n] - if !bytes.Equal(msg, actual_msg) { - t.Errorf("Echo: expected %q got %q", msg, actual_msg) - } - conn.Close() -} - -func TestAddr(t *testing.T) { - once.Do(startServer) - - // websocket.Dial() - client, err := net.Dial("tcp", serverAddr) - if err != nil { - t.Fatal("dialing", err) - } - conn, err := NewClient(newConfig(t, "/echo"), client) - if err != nil { - t.Errorf("WebSocket handshake error: %v", err) - return - } - - ra := conn.RemoteAddr().String() - if !strings.HasPrefix(ra, "ws://") || !strings.HasSuffix(ra, "/echo") { - t.Errorf("Bad remote addr: %v", ra) - } - la := conn.LocalAddr().String() - if !strings.HasPrefix(la, "http://") { - t.Errorf("Bad local addr: %v", la) - } - conn.Close() -} - -func TestCount(t *testing.T) { - once.Do(startServer) - - // websocket.Dial() - client, err := net.Dial("tcp", serverAddr) - if err != nil { - t.Fatal("dialing", err) - } - conn, err := NewClient(newConfig(t, "/count"), client) - if err != nil { - t.Errorf("WebSocket handshake error: %v", err) - return - } - - var count Count - count.S = "hello" - if err := JSON.Send(conn, count); err != nil { - t.Errorf("Write: %v", err) - } - if err := JSON.Receive(conn, &count); err != nil { - t.Errorf("Read: %v", err) - } - if count.N != 1 { - t.Errorf("count: expected %d got %d", 1, count.N) - } - if count.S != "hello" { - t.Errorf("count: expected %q got %q", "hello", count.S) - } - if err := JSON.Send(conn, count); err != nil { - t.Errorf("Write: %v", err) - } - if err := JSON.Receive(conn, &count); err != nil { - t.Errorf("Read: %v", err) - } - if count.N != 2 { - t.Errorf("count: expected %d got %d", 2, count.N) - } - if count.S != "hellohello" { - t.Errorf("count: expected %q got %q", "hellohello", count.S) - } - conn.Close() -} - -func TestWithQuery(t *testing.T) { - once.Do(startServer) - - client, err := net.Dial("tcp", serverAddr) - if err != nil { - t.Fatal("dialing", err) - } - - config := newConfig(t, "/echo") - config.Location, err = url.ParseRequestURI(fmt.Sprintf("ws://%s/echo?q=v", serverAddr)) - if err != nil { - t.Fatal("location url", err) - } - - ws, err := NewClient(config, client) - if err != nil { - t.Errorf("WebSocket handshake: %v", err) - return - } - ws.Close() -} - -func testWithProtocol(t *testing.T, subproto []string) (string, error) { - once.Do(startServer) - - client, err := net.Dial("tcp", serverAddr) - if err != nil { - t.Fatal("dialing", err) - } - - config := newConfig(t, "/subproto") - config.Protocol = subproto - - ws, err := NewClient(config, client) - if err != nil { - return "", err - } - msg := make([]byte, 16) - n, err := ws.Read(msg) - if err != nil { - return "", err - } - ws.Close() - return string(msg[:n]), nil -} - -func TestWithProtocol(t *testing.T) { - proto, err := testWithProtocol(t, []string{"chat"}) - if err != nil { - t.Errorf("SubProto: unexpected error: %v", err) - } - if proto != "chat" { - t.Errorf("SubProto: expected %q, got %q", "chat", proto) - } -} - -func TestWithTwoProtocol(t *testing.T) { - proto, err := testWithProtocol(t, []string{"test", "chat"}) - if err != nil { - t.Errorf("SubProto: unexpected error: %v", err) - } - if proto != "chat" { - t.Errorf("SubProto: expected %q, got %q", "chat", proto) - } -} - -func TestWithBadProtocol(t *testing.T) { - _, err := testWithProtocol(t, []string{"test"}) - if err != ErrBadStatus { - t.Errorf("SubProto: expected %v, got %v", ErrBadStatus, err) - } -} - -func TestHTTP(t *testing.T) { - once.Do(startServer) - - // If the client did not send a handshake that matches the protocol - // specification, the server MUST return an HTTP response with an - // appropriate error code (such as 400 Bad Request) - resp, err := http.Get(fmt.Sprintf("http://%s/echo", serverAddr)) - if err != nil { - t.Errorf("Get: error %#v", err) - return - } - if resp == nil { - t.Error("Get: resp is null") - return - } - if resp.StatusCode != http.StatusBadRequest { - t.Errorf("Get: expected %q got %q", http.StatusBadRequest, resp.StatusCode) - } -} - -func TestTrailingSpaces(t *testing.T) { - // http://code.google.com/p/go/issues/detail?id=955 - // The last runs of this create keys with trailing spaces that should not be - // generated by the client. - once.Do(startServer) - config := newConfig(t, "/echo") - for i := 0; i < 30; i++ { - // body - ws, err := DialConfig(config) - if err != nil { - t.Errorf("Dial #%d failed: %v", i, err) - break - } - ws.Close() - } -} - -func TestDialConfigBadVersion(t *testing.T) { - once.Do(startServer) - config := newConfig(t, "/echo") - config.Version = 1234 - - _, err := DialConfig(config) - - if dialerr, ok := err.(*DialError); ok { - if dialerr.Err != ErrBadProtocolVersion { - t.Errorf("dial expected err %q but got %q", ErrBadProtocolVersion, dialerr.Err) - } - } -} - -func TestDialConfigWithDialer(t *testing.T) { - once.Do(startServer) - config := newConfig(t, "/echo") - config.Dialer = &net.Dialer{ - Deadline: time.Now().Add(-time.Minute), - } - _, err := DialConfig(config) - dialerr, ok := err.(*DialError) - if !ok { - t.Fatalf("DialError expected, got %#v", err) - } - neterr, ok := dialerr.Err.(*net.OpError) - if !ok { - t.Fatalf("net.OpError error expected, got %#v", dialerr.Err) - } - if !neterr.Timeout() { - t.Fatalf("expected timeout error, got %#v", neterr) - } -} - -func TestSmallBuffer(t *testing.T) { - // http://code.google.com/p/go/issues/detail?id=1145 - // Read should be able to handle reading a fragment of a frame. - once.Do(startServer) - - // websocket.Dial() - client, err := net.Dial("tcp", serverAddr) - if err != nil { - t.Fatal("dialing", err) - } - conn, err := NewClient(newConfig(t, "/echo"), client) - if err != nil { - t.Errorf("WebSocket handshake error: %v", err) - return - } - - msg := []byte("hello, world\n") - if _, err := conn.Write(msg); err != nil { - t.Errorf("Write: %v", err) - } - var small_msg = make([]byte, 8) - n, err := conn.Read(small_msg) - if err != nil { - t.Errorf("Read: %v", err) - } - if !bytes.Equal(msg[:len(small_msg)], small_msg) { - t.Errorf("Echo: expected %q got %q", msg[:len(small_msg)], small_msg) - } - var second_msg = make([]byte, len(msg)) - n, err = conn.Read(second_msg) - if err != nil { - t.Errorf("Read: %v", err) - } - second_msg = second_msg[0:n] - if !bytes.Equal(msg[len(small_msg):], second_msg) { - t.Errorf("Echo: expected %q got %q", msg[len(small_msg):], second_msg) - } - conn.Close() -} - -var parseAuthorityTests = []struct { - in *url.URL - out string -}{ - { - &url.URL{ - Scheme: "ws", - Host: "www.google.com", - }, - "www.google.com:80", - }, - { - &url.URL{ - Scheme: "wss", - Host: "www.google.com", - }, - "www.google.com:443", - }, - { - &url.URL{ - Scheme: "ws", - Host: "www.google.com:80", - }, - "www.google.com:80", - }, - { - &url.URL{ - Scheme: "wss", - Host: "www.google.com:443", - }, - "www.google.com:443", - }, - // some invalid ones for parseAuthority. parseAuthority doesn't - // concern itself with the scheme unless it actually knows about it - { - &url.URL{ - Scheme: "http", - Host: "www.google.com", - }, - "www.google.com", - }, - { - &url.URL{ - Scheme: "http", - Host: "www.google.com:80", - }, - "www.google.com:80", - }, - { - &url.URL{ - Scheme: "asdf", - Host: "127.0.0.1", - }, - "127.0.0.1", - }, - { - &url.URL{ - Scheme: "asdf", - Host: "www.google.com", - }, - "www.google.com", - }, -} - -func TestParseAuthority(t *testing.T) { - for _, tt := range parseAuthorityTests { - out := parseAuthority(tt.in) - if out != tt.out { - t.Errorf("got %v; want %v", out, tt.out) - } - } -} - -type closerConn struct { - net.Conn - closed int // count of the number of times Close was called -} - -func (c *closerConn) Close() error { - c.closed++ - return c.Conn.Close() -} - -func TestClose(t *testing.T) { - if runtime.GOOS == "plan9" { - t.Skip("see golang.org/issue/11454") - } - - once.Do(startServer) - - conn, err := net.Dial("tcp", serverAddr) - if err != nil { - t.Fatal("dialing", err) - } - - cc := closerConn{Conn: conn} - - client, err := NewClient(newConfig(t, "/echo"), &cc) - if err != nil { - t.Fatalf("WebSocket handshake: %v", err) - } - - // set the deadline to ten minutes ago, which will have expired by the time - // client.Close sends the close status frame. - conn.SetDeadline(time.Now().Add(-10 * time.Minute)) - - if err := client.Close(); err == nil { - t.Errorf("ws.Close(): expected error, got %v", err) - } - if cc.closed < 1 { - t.Fatalf("ws.Close(): expected underlying ws.rwc.Close to be called > 0 times, got: %v", cc.closed) - } -} - -var originTests = []struct { - req *http.Request - origin *url.URL -}{ - { - req: &http.Request{ - Header: http.Header{ - "Origin": []string{"http://www.example.com"}, - }, - }, - origin: &url.URL{ - Scheme: "http", - Host: "www.example.com", - }, - }, - { - req: &http.Request{}, - }, -} - -func TestOrigin(t *testing.T) { - conf := newConfig(t, "/echo") - conf.Version = ProtocolVersionHybi13 - for i, tt := range originTests { - origin, err := Origin(conf, tt.req) - if err != nil { - t.Error(err) - continue - } - if !reflect.DeepEqual(origin, tt.origin) { - t.Errorf("#%d: got origin %v; want %v", i, origin, tt.origin) - continue - } - } -} - -func TestCtrlAndData(t *testing.T) { - once.Do(startServer) - - c, err := net.Dial("tcp", serverAddr) - if err != nil { - t.Fatal(err) - } - ws, err := NewClient(newConfig(t, "/ctrldata"), c) - if err != nil { - t.Fatal(err) - } - defer ws.Close() - - h := &testCtrlAndDataHandler{hybiFrameHandler: hybiFrameHandler{conn: ws}} - ws.frameHandler = h - - b := make([]byte, 128) - for i := 0; i < 2; i++ { - data := []byte(fmt.Sprintf("#%d-DATA-FRAME-FROM-CLIENT", i)) - if _, err := ws.Write(data); err != nil { - t.Fatalf("#%d: %v", i, err) - } - var ctrl []byte - if i%2 != 0 { // with or without payload - ctrl = []byte(fmt.Sprintf("#%d-CONTROL-FRAME-FROM-CLIENT", i)) - } - if _, err := h.WritePing(ctrl); err != nil { - t.Fatalf("#%d: %v", i, err) - } - n, err := ws.Read(b) - if err != nil { - t.Fatalf("#%d: %v", i, err) - } - if !bytes.Equal(b[:n], data) { - t.Fatalf("#%d: got %v; want %v", i, b[:n], data) - } - } -} - -func TestCodec_ReceiveLimited(t *testing.T) { - const limit = 2048 - var payloads [][]byte - for _, size := range []int{ - 1024, - 2048, - 4096, // receive of this message would be interrupted due to limit - 2048, // this one is to make sure next receive recovers discarding leftovers - } { - b := make([]byte, size) - rand.Read(b) - payloads = append(payloads, b) - } - handlerDone := make(chan struct{}) - limitedHandler := func(ws *Conn) { - defer close(handlerDone) - ws.MaxPayloadBytes = limit - defer ws.Close() - for i, p := range payloads { - t.Logf("payload #%d (size %d, exceeds limit: %v)", i, len(p), len(p) > limit) - var recv []byte - err := Message.Receive(ws, &recv) - switch err { - case nil: - case ErrFrameTooLarge: - if len(p) <= limit { - t.Fatalf("unexpected frame size limit: expected %d bytes of payload having limit at %d", len(p), limit) - } - continue - default: - t.Fatalf("unexpected error: %v (want either nil or ErrFrameTooLarge)", err) - } - if len(recv) > limit { - t.Fatalf("received %d bytes of payload having limit at %d", len(recv), limit) - } - if !bytes.Equal(p, recv) { - t.Fatalf("received payload differs:\ngot:\t%v\nwant:\t%v", recv, p) - } - } - } - server := httptest.NewServer(Handler(limitedHandler)) - defer server.CloseClientConnections() - defer server.Close() - addr := server.Listener.Addr().String() - ws, err := Dial("ws://"+addr+"/", "", "http://localhost/") - if err != nil { - t.Fatal(err) - } - defer ws.Close() - for i, p := range payloads { - if err := Message.Send(ws, p); err != nil { - t.Fatalf("payload #%d (size %d): %v", i, len(p), err) - } - } - <-handlerDone -} diff --git a/vendor/golang.org/x/net/xsrftoken/xsrf.go b/vendor/golang.org/x/net/xsrftoken/xsrf.go deleted file mode 100644 index 881bf199f..000000000 --- a/vendor/golang.org/x/net/xsrftoken/xsrf.go +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package xsrftoken provides methods for generating and validating secure XSRF tokens. -package xsrftoken // import "golang.org/x/net/xsrftoken" - -import ( - "crypto/hmac" - "crypto/sha1" - "crypto/subtle" - "encoding/base64" - "fmt" - "strconv" - "strings" - "time" -) - -// Timeout is the duration for which XSRF tokens are valid. -// It is exported so clients may set cookie timeouts that match generated tokens. -const Timeout = 24 * time.Hour - -// clean sanitizes a string for inclusion in a token by replacing all ":"s. -func clean(s string) string { - return strings.Replace(s, ":", "_", -1) -} - -// Generate returns a URL-safe secure XSRF token that expires in 24 hours. -// -// key is a secret key for your application. -// userID is a unique identifier for the user. -// actionID is the action the user is taking (e.g. POSTing to a particular path). -func Generate(key, userID, actionID string) string { - return generateTokenAtTime(key, userID, actionID, time.Now()) -} - -// generateTokenAtTime is like Generate, but returns a token that expires 24 hours from now. -func generateTokenAtTime(key, userID, actionID string, now time.Time) string { - // Round time up and convert to milliseconds. - milliTime := (now.UnixNano() + 1e6 - 1) / 1e6 - - h := hmac.New(sha1.New, []byte(key)) - fmt.Fprintf(h, "%s:%s:%d", clean(userID), clean(actionID), milliTime) - - // Get the padded base64 string then removing the padding. - tok := string(h.Sum(nil)) - tok = base64.URLEncoding.EncodeToString([]byte(tok)) - tok = strings.TrimRight(tok, "=") - - return fmt.Sprintf("%s:%d", tok, milliTime) -} - -// Valid reports whether a token is a valid, unexpired token returned by Generate. -func Valid(token, key, userID, actionID string) bool { - return validTokenAtTime(token, key, userID, actionID, time.Now()) -} - -// validTokenAtTime reports whether a token is valid at the given time. -func validTokenAtTime(token, key, userID, actionID string, now time.Time) bool { - // Extract the issue time of the token. - sep := strings.LastIndex(token, ":") - if sep < 0 { - return false - } - millis, err := strconv.ParseInt(token[sep+1:], 10, 64) - if err != nil { - return false - } - issueTime := time.Unix(0, millis*1e6) - - // Check that the token is not expired. - if now.Sub(issueTime) >= Timeout { - return false - } - - // Check that the token is not from the future. - // Allow 1 minute grace period in case the token is being verified on a - // machine whose clock is behind the machine that issued the token. - if issueTime.After(now.Add(1 * time.Minute)) { - return false - } - - expected := generateTokenAtTime(key, userID, actionID, issueTime) - - // Check that the token matches the expected value. - // Use constant time comparison to avoid timing attacks. - return subtle.ConstantTimeCompare([]byte(token), []byte(expected)) == 1 -} diff --git a/vendor/golang.org/x/net/xsrftoken/xsrf_test.go b/vendor/golang.org/x/net/xsrftoken/xsrf_test.go deleted file mode 100644 index 6c8e7d9b5..000000000 --- a/vendor/golang.org/x/net/xsrftoken/xsrf_test.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package xsrftoken - -import ( - "encoding/base64" - "testing" - "time" -) - -const ( - key = "quay" - userID = "12345678" - actionID = "POST /form" -) - -var ( - now = time.Now() - oneMinuteFromNow = now.Add(1 * time.Minute) -) - -func TestValidToken(t *testing.T) { - tok := generateTokenAtTime(key, userID, actionID, now) - if !validTokenAtTime(tok, key, userID, actionID, oneMinuteFromNow) { - t.Error("One second later: Expected token to be valid") - } - if !validTokenAtTime(tok, key, userID, actionID, now.Add(Timeout-1*time.Nanosecond)) { - t.Error("Just before timeout: Expected token to be valid") - } - if !validTokenAtTime(tok, key, userID, actionID, now.Add(-1*time.Minute+1*time.Millisecond)) { - t.Error("One minute in the past: Expected token to be valid") - } -} - -// TestSeparatorReplacement tests that separators are being correctly substituted -func TestSeparatorReplacement(t *testing.T) { - tok := generateTokenAtTime("foo:bar", "baz", "wah", now) - tok2 := generateTokenAtTime("foo", "bar:baz", "wah", now) - if tok == tok2 { - t.Errorf("Expected generated tokens to be different") - } -} - -func TestInvalidToken(t *testing.T) { - invalidTokenTests := []struct { - name, key, userID, actionID string - t time.Time - }{ - {"Bad key", "foobar", userID, actionID, oneMinuteFromNow}, - {"Bad userID", key, "foobar", actionID, oneMinuteFromNow}, - {"Bad actionID", key, userID, "foobar", oneMinuteFromNow}, - {"Expired", key, userID, actionID, now.Add(Timeout + 1*time.Millisecond)}, - {"More than 1 minute from the future", key, userID, actionID, now.Add(-1*time.Nanosecond - 1*time.Minute)}, - } - - tok := generateTokenAtTime(key, userID, actionID, now) - for _, itt := range invalidTokenTests { - if validTokenAtTime(tok, itt.key, itt.userID, itt.actionID, itt.t) { - t.Errorf("%v: Expected token to be invalid", itt.name) - } - } -} - -// TestValidateBadData primarily tests that no unexpected panics are triggered -// during parsing -func TestValidateBadData(t *testing.T) { - badDataTests := []struct { - name, tok string - }{ - {"Invalid Base64", "ASDab24(@)$*=="}, - {"No delimiter", base64.URLEncoding.EncodeToString([]byte("foobar12345678"))}, - {"Invalid time", base64.URLEncoding.EncodeToString([]byte("foobar:foobar"))}, - {"Wrong length", "1234" + generateTokenAtTime(key, userID, actionID, now)}, - } - - for _, bdt := range badDataTests { - if validTokenAtTime(bdt.tok, key, userID, actionID, oneMinuteFromNow) { - t.Errorf("%v: Expected token to be invalid", bdt.name) - } - } -} diff --git a/vendor/golang.org/x/sys/.gitattributes b/vendor/golang.org/x/sys/.gitattributes deleted file mode 100644 index d2f212e5d..000000000 --- a/vendor/golang.org/x/sys/.gitattributes +++ /dev/null @@ -1,10 +0,0 @@ -# Treat all files in this repo as binary, with no git magic updating -# line endings. Windows users contributing to Go will need to use a -# modern version of git and editors capable of LF line endings. -# -# We'll prevent accidental CRLF line endings from entering the repo -# via the git-review gofmt checks. -# -# See golang.org/issue/9281 - -* -text diff --git a/vendor/golang.org/x/sys/.gitignore b/vendor/golang.org/x/sys/.gitignore deleted file mode 100644 index 8339fd61d..000000000 --- a/vendor/golang.org/x/sys/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Add no patterns to .hgignore except for files generated by the build. -last-change diff --git a/vendor/golang.org/x/sys/CONTRIBUTING.md b/vendor/golang.org/x/sys/CONTRIBUTING.md deleted file mode 100644 index 88dff59bc..000000000 --- a/vendor/golang.org/x/sys/CONTRIBUTING.md +++ /dev/null @@ -1,31 +0,0 @@ -# Contributing to Go - -Go is an open source project. - -It is the work of hundreds of contributors. We appreciate your help! - - -## Filing issues - -When [filing an issue](https://golang.org/issue/new), make sure to answer these five questions: - -1. What version of Go are you using (`go version`)? -2. What operating system and processor architecture are you using? -3. What did you do? -4. What did you expect to see? -5. What did you see instead? - -General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker. -The gophers there will answer or ask you to file an issue if you've tripped over a bug. - -## Contributing code - -Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) -before sending patches. - -**We do not accept GitHub pull requests** -(we use [Gerrit](https://code.google.com/p/gerrit/) instead for code review). - -Unless otherwise noted, the Go source files are distributed under -the BSD-style license found in the LICENSE file. - diff --git a/vendor/golang.org/x/sys/README b/vendor/golang.org/x/sys/README deleted file mode 100644 index bd422b40c..000000000 --- a/vendor/golang.org/x/sys/README +++ /dev/null @@ -1,3 +0,0 @@ -This repository holds supplemental Go packages for low-level interactions with the operating system. - -To submit changes to this repository, see http://golang.org/doc/contribute.html. diff --git a/vendor/golang.org/x/sys/codereview.cfg b/vendor/golang.org/x/sys/codereview.cfg deleted file mode 100644 index 3f8b14b64..000000000 --- a/vendor/golang.org/x/sys/codereview.cfg +++ /dev/null @@ -1 +0,0 @@ -issuerepo: golang/go diff --git a/vendor/golang.org/x/sys/plan9/asm.s b/vendor/golang.org/x/sys/plan9/asm.s deleted file mode 100644 index d4ca868f1..000000000 --- a/vendor/golang.org/x/sys/plan9/asm.s +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#include "textflag.h" - -TEXT ·use(SB),NOSPLIT,$0 - RET diff --git a/vendor/golang.org/x/sys/plan9/asm_plan9_386.s b/vendor/golang.org/x/sys/plan9/asm_plan9_386.s deleted file mode 100644 index bc5cab1f3..000000000 --- a/vendor/golang.org/x/sys/plan9/asm_plan9_386.s +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#include "textflag.h" - -// -// System call support for 386, Plan 9 -// - -// Just jump to package syscall's implementation for all these functions. -// The runtime may know about them. - -TEXT ·Syscall(SB),NOSPLIT,$0-32 - JMP syscall·Syscall(SB) - -TEXT ·Syscall6(SB),NOSPLIT,$0-44 - JMP syscall·Syscall6(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-28 - JMP syscall·RawSyscall(SB) - -TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 - JMP syscall·RawSyscall6(SB) - -TEXT ·seek(SB),NOSPLIT,$0-36 - JMP syscall·seek(SB) - -TEXT ·exit(SB),NOSPLIT,$4-4 - JMP syscall·exit(SB) diff --git a/vendor/golang.org/x/sys/plan9/asm_plan9_amd64.s b/vendor/golang.org/x/sys/plan9/asm_plan9_amd64.s deleted file mode 100644 index d3448e675..000000000 --- a/vendor/golang.org/x/sys/plan9/asm_plan9_amd64.s +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#include "textflag.h" - -// -// System call support for amd64, Plan 9 -// - -// Just jump to package syscall's implementation for all these functions. -// The runtime may know about them. - -TEXT ·Syscall(SB),NOSPLIT,$0-64 - JMP syscall·Syscall(SB) - -TEXT ·Syscall6(SB),NOSPLIT,$0-88 - JMP syscall·Syscall6(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-56 - JMP syscall·RawSyscall(SB) - -TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 - JMP syscall·RawSyscall6(SB) - -TEXT ·seek(SB),NOSPLIT,$0-56 - JMP syscall·seek(SB) - -TEXT ·exit(SB),NOSPLIT,$8-8 - JMP syscall·exit(SB) diff --git a/vendor/golang.org/x/sys/plan9/const_plan9.go b/vendor/golang.org/x/sys/plan9/const_plan9.go deleted file mode 100644 index b4e85a3a9..000000000 --- a/vendor/golang.org/x/sys/plan9/const_plan9.go +++ /dev/null @@ -1,70 +0,0 @@ -package plan9 - -// Plan 9 Constants - -// Open modes -const ( - O_RDONLY = 0 - O_WRONLY = 1 - O_RDWR = 2 - O_TRUNC = 16 - O_CLOEXEC = 32 - O_EXCL = 0x1000 -) - -// Rfork flags -const ( - RFNAMEG = 1 << 0 - RFENVG = 1 << 1 - RFFDG = 1 << 2 - RFNOTEG = 1 << 3 - RFPROC = 1 << 4 - RFMEM = 1 << 5 - RFNOWAIT = 1 << 6 - RFCNAMEG = 1 << 10 - RFCENVG = 1 << 11 - RFCFDG = 1 << 12 - RFREND = 1 << 13 - RFNOMNT = 1 << 14 -) - -// Qid.Type bits -const ( - QTDIR = 0x80 - QTAPPEND = 0x40 - QTEXCL = 0x20 - QTMOUNT = 0x10 - QTAUTH = 0x08 - QTTMP = 0x04 - QTFILE = 0x00 -) - -// Dir.Mode bits -const ( - DMDIR = 0x80000000 - DMAPPEND = 0x40000000 - DMEXCL = 0x20000000 - DMMOUNT = 0x10000000 - DMAUTH = 0x08000000 - DMTMP = 0x04000000 - DMREAD = 0x4 - DMWRITE = 0x2 - DMEXEC = 0x1 -) - -const ( - STATMAX = 65535 - ERRMAX = 128 - STATFIXLEN = 49 -) - -// Mount and bind flags -const ( - MREPL = 0x0000 - MBEFORE = 0x0001 - MAFTER = 0x0002 - MORDER = 0x0003 - MCREATE = 0x0004 - MCACHE = 0x0010 - MMASK = 0x0017 -) diff --git a/vendor/golang.org/x/sys/plan9/dir_plan9.go b/vendor/golang.org/x/sys/plan9/dir_plan9.go deleted file mode 100644 index 0955e0c53..000000000 --- a/vendor/golang.org/x/sys/plan9/dir_plan9.go +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Plan 9 directory marshalling. See intro(5). - -package plan9 - -import "errors" - -var ( - ErrShortStat = errors.New("stat buffer too short") - ErrBadStat = errors.New("malformed stat buffer") - ErrBadName = errors.New("bad character in file name") -) - -// A Qid represents a 9P server's unique identification for a file. -type Qid struct { - Path uint64 // the file server's unique identification for the file - Vers uint32 // version number for given Path - Type uint8 // the type of the file (plan9.QTDIR for example) -} - -// A Dir contains the metadata for a file. -type Dir struct { - // system-modified data - Type uint16 // server type - Dev uint32 // server subtype - - // file data - Qid Qid // unique id from server - Mode uint32 // permissions - Atime uint32 // last read time - Mtime uint32 // last write time - Length int64 // file length - Name string // last element of path - Uid string // owner name - Gid string // group name - Muid string // last modifier name -} - -var nullDir = Dir{ - Type: ^uint16(0), - Dev: ^uint32(0), - Qid: Qid{ - Path: ^uint64(0), - Vers: ^uint32(0), - Type: ^uint8(0), - }, - Mode: ^uint32(0), - Atime: ^uint32(0), - Mtime: ^uint32(0), - Length: ^int64(0), -} - -// Null assigns special "don't touch" values to members of d to -// avoid modifying them during plan9.Wstat. -func (d *Dir) Null() { *d = nullDir } - -// Marshal encodes a 9P stat message corresponding to d into b -// -// If there isn't enough space in b for a stat message, ErrShortStat is returned. -func (d *Dir) Marshal(b []byte) (n int, err error) { - n = STATFIXLEN + len(d.Name) + len(d.Uid) + len(d.Gid) + len(d.Muid) - if n > len(b) { - return n, ErrShortStat - } - - for _, c := range d.Name { - if c == '/' { - return n, ErrBadName - } - } - - b = pbit16(b, uint16(n)-2) - b = pbit16(b, d.Type) - b = pbit32(b, d.Dev) - b = pbit8(b, d.Qid.Type) - b = pbit32(b, d.Qid.Vers) - b = pbit64(b, d.Qid.Path) - b = pbit32(b, d.Mode) - b = pbit32(b, d.Atime) - b = pbit32(b, d.Mtime) - b = pbit64(b, uint64(d.Length)) - b = pstring(b, d.Name) - b = pstring(b, d.Uid) - b = pstring(b, d.Gid) - b = pstring(b, d.Muid) - - return n, nil -} - -// UnmarshalDir decodes a single 9P stat message from b and returns the resulting Dir. -// -// If b is too small to hold a valid stat message, ErrShortStat is returned. -// -// If the stat message itself is invalid, ErrBadStat is returned. -func UnmarshalDir(b []byte) (*Dir, error) { - if len(b) < STATFIXLEN { - return nil, ErrShortStat - } - size, buf := gbit16(b) - if len(b) != int(size)+2 { - return nil, ErrBadStat - } - b = buf - - var d Dir - d.Type, b = gbit16(b) - d.Dev, b = gbit32(b) - d.Qid.Type, b = gbit8(b) - d.Qid.Vers, b = gbit32(b) - d.Qid.Path, b = gbit64(b) - d.Mode, b = gbit32(b) - d.Atime, b = gbit32(b) - d.Mtime, b = gbit32(b) - - n, b := gbit64(b) - d.Length = int64(n) - - var ok bool - if d.Name, b, ok = gstring(b); !ok { - return nil, ErrBadStat - } - if d.Uid, b, ok = gstring(b); !ok { - return nil, ErrBadStat - } - if d.Gid, b, ok = gstring(b); !ok { - return nil, ErrBadStat - } - if d.Muid, b, ok = gstring(b); !ok { - return nil, ErrBadStat - } - - return &d, nil -} - -// pbit8 copies the 8-bit number v to b and returns the remaining slice of b. -func pbit8(b []byte, v uint8) []byte { - b[0] = byte(v) - return b[1:] -} - -// pbit16 copies the 16-bit number v to b in little-endian order and returns the remaining slice of b. -func pbit16(b []byte, v uint16) []byte { - b[0] = byte(v) - b[1] = byte(v >> 8) - return b[2:] -} - -// pbit32 copies the 32-bit number v to b in little-endian order and returns the remaining slice of b. -func pbit32(b []byte, v uint32) []byte { - b[0] = byte(v) - b[1] = byte(v >> 8) - b[2] = byte(v >> 16) - b[3] = byte(v >> 24) - return b[4:] -} - -// pbit64 copies the 64-bit number v to b in little-endian order and returns the remaining slice of b. -func pbit64(b []byte, v uint64) []byte { - b[0] = byte(v) - b[1] = byte(v >> 8) - b[2] = byte(v >> 16) - b[3] = byte(v >> 24) - b[4] = byte(v >> 32) - b[5] = byte(v >> 40) - b[6] = byte(v >> 48) - b[7] = byte(v >> 56) - return b[8:] -} - -// pstring copies the string s to b, prepending it with a 16-bit length in little-endian order, and -// returning the remaining slice of b.. -func pstring(b []byte, s string) []byte { - b = pbit16(b, uint16(len(s))) - n := copy(b, s) - return b[n:] -} - -// gbit8 reads an 8-bit number from b and returns it with the remaining slice of b. -func gbit8(b []byte) (uint8, []byte) { - return uint8(b[0]), b[1:] -} - -// gbit16 reads a 16-bit number in little-endian order from b and returns it with the remaining slice of b. -func gbit16(b []byte) (uint16, []byte) { - return uint16(b[0]) | uint16(b[1])<<8, b[2:] -} - -// gbit32 reads a 32-bit number in little-endian order from b and returns it with the remaining slice of b. -func gbit32(b []byte) (uint32, []byte) { - return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24, b[4:] -} - -// gbit64 reads a 64-bit number in little-endian order from b and returns it with the remaining slice of b. -func gbit64(b []byte) (uint64, []byte) { - lo := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 - hi := uint32(b[4]) | uint32(b[5])<<8 | uint32(b[6])<<16 | uint32(b[7])<<24 - return uint64(lo) | uint64(hi)<<32, b[8:] -} - -// gstring reads a string from b, prefixed with a 16-bit length in little-endian order. -// It returns the string with the remaining slice of b and a boolean. If the length is -// greater than the number of bytes in b, the boolean will be false. -func gstring(b []byte) (string, []byte, bool) { - n, b := gbit16(b) - if int(n) > len(b) { - return "", b, false - } - return string(b[:n]), b[n:], true -} diff --git a/vendor/golang.org/x/sys/plan9/env_plan9.go b/vendor/golang.org/x/sys/plan9/env_plan9.go deleted file mode 100644 index 25a96e7ea..000000000 --- a/vendor/golang.org/x/sys/plan9/env_plan9.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Plan 9 environment variables. - -package plan9 - -import ( - "syscall" -) - -func Getenv(key string) (value string, found bool) { - return syscall.Getenv(key) -} - -func Setenv(key, value string) error { - return syscall.Setenv(key, value) -} - -func Clearenv() { - syscall.Clearenv() -} - -func Environ() []string { - return syscall.Environ() -} diff --git a/vendor/golang.org/x/sys/plan9/env_unset.go b/vendor/golang.org/x/sys/plan9/env_unset.go deleted file mode 100644 index c37fc26e4..000000000 --- a/vendor/golang.org/x/sys/plan9/env_unset.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.4 - -package plan9 - -import "syscall" - -func Unsetenv(key string) error { - // This was added in Go 1.4. - return syscall.Unsetenv(key) -} diff --git a/vendor/golang.org/x/sys/plan9/errors_plan9.go b/vendor/golang.org/x/sys/plan9/errors_plan9.go deleted file mode 100644 index 110cf6a30..000000000 --- a/vendor/golang.org/x/sys/plan9/errors_plan9.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package plan9 - -import "syscall" - -// Constants -const ( - // Invented values to support what package os expects. - O_CREAT = 0x02000 - O_APPEND = 0x00400 - O_NOCTTY = 0x00000 - O_NONBLOCK = 0x00000 - O_SYNC = 0x00000 - O_ASYNC = 0x00000 - - S_IFMT = 0x1f000 - S_IFIFO = 0x1000 - S_IFCHR = 0x2000 - S_IFDIR = 0x4000 - S_IFBLK = 0x6000 - S_IFREG = 0x8000 - S_IFLNK = 0xa000 - S_IFSOCK = 0xc000 -) - -// Errors -var ( - EINVAL = syscall.NewError("bad arg in system call") - ENOTDIR = syscall.NewError("not a directory") - EISDIR = syscall.NewError("file is a directory") - ENOENT = syscall.NewError("file does not exist") - EEXIST = syscall.NewError("file already exists") - EMFILE = syscall.NewError("no free file descriptors") - EIO = syscall.NewError("i/o error") - ENAMETOOLONG = syscall.NewError("file name too long") - EINTR = syscall.NewError("interrupted") - EPERM = syscall.NewError("permission denied") - EBUSY = syscall.NewError("no free devices") - ETIMEDOUT = syscall.NewError("connection timed out") - EPLAN9 = syscall.NewError("not supported by plan 9") - - // The following errors do not correspond to any - // Plan 9 system messages. Invented to support - // what package os and others expect. - EACCES = syscall.NewError("access permission denied") - EAFNOSUPPORT = syscall.NewError("address family not supported by protocol") -) diff --git a/vendor/golang.org/x/sys/plan9/mkall.sh b/vendor/golang.org/x/sys/plan9/mkall.sh deleted file mode 100755 index 9f73c6066..000000000 --- a/vendor/golang.org/x/sys/plan9/mkall.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2009 The Go Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -# The plan9 package provides access to the raw system call -# interface of the underlying operating system. Porting Go to -# a new architecture/operating system combination requires -# some manual effort, though there are tools that automate -# much of the process. The auto-generated files have names -# beginning with z. -# -# This script runs or (given -n) prints suggested commands to generate z files -# for the current system. Running those commands is not automatic. -# This script is documentation more than anything else. -# -# * asm_${GOOS}_${GOARCH}.s -# -# This hand-written assembly file implements system call dispatch. -# There are three entry points: -# -# func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr); -# func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr); -# func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr); -# -# The first and second are the standard ones; they differ only in -# how many arguments can be passed to the kernel. -# The third is for low-level use by the ForkExec wrapper; -# unlike the first two, it does not call into the scheduler to -# let it know that a system call is running. -# -# * syscall_${GOOS}.go -# -# This hand-written Go file implements system calls that need -# special handling and lists "//sys" comments giving prototypes -# for ones that can be auto-generated. Mksyscall reads those -# comments to generate the stubs. -# -# * syscall_${GOOS}_${GOARCH}.go -# -# Same as syscall_${GOOS}.go except that it contains code specific -# to ${GOOS} on one particular architecture. -# -# * types_${GOOS}.c -# -# This hand-written C file includes standard C headers and then -# creates typedef or enum names beginning with a dollar sign -# (use of $ in variable names is a gcc extension). The hardest -# part about preparing this file is figuring out which headers to -# include and which symbols need to be #defined to get the -# actual data structures that pass through to the kernel system calls. -# Some C libraries present alternate versions for binary compatibility -# and translate them on the way in and out of system calls, but -# there is almost always a #define that can get the real ones. -# See types_darwin.c and types_linux.c for examples. -# -# * zerror_${GOOS}_${GOARCH}.go -# -# This machine-generated file defines the system's error numbers, -# error strings, and signal numbers. The generator is "mkerrors.sh". -# Usually no arguments are needed, but mkerrors.sh will pass its -# arguments on to godefs. -# -# * zsyscall_${GOOS}_${GOARCH}.go -# -# Generated by mksyscall.pl; see syscall_${GOOS}.go above. -# -# * zsysnum_${GOOS}_${GOARCH}.go -# -# Generated by mksysnum_${GOOS}. -# -# * ztypes_${GOOS}_${GOARCH}.go -# -# Generated by godefs; see types_${GOOS}.c above. - -GOOSARCH="${GOOS}_${GOARCH}" - -# defaults -mksyscall="./mksyscall.pl" -mkerrors="./mkerrors.sh" -zerrors="zerrors_$GOOSARCH.go" -mksysctl="" -zsysctl="zsysctl_$GOOSARCH.go" -mksysnum= -mktypes= -run="sh" - -case "$1" in --syscalls) - for i in zsyscall*go - do - sed 1q $i | sed 's;^// ;;' | sh > _$i && gofmt < _$i > $i - rm _$i - done - exit 0 - ;; --n) - run="cat" - shift -esac - -case "$#" in -0) - ;; -*) - echo 'usage: mkall.sh [-n]' 1>&2 - exit 2 -esac - -case "$GOOSARCH" in -_* | *_ | _) - echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2 - exit 1 - ;; -plan9_386) - mkerrors= - mksyscall="./mksyscall.pl -l32 -plan9" - mksysnum="./mksysnum_plan9.sh /n/sources/plan9/sys/src/libc/9syscall/sys.h" - mktypes="XXX" - ;; -*) - echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2 - exit 1 - ;; -esac - -( - if [ -n "$mkerrors" ]; then echo "$mkerrors |gofmt >$zerrors"; fi - case "$GOOS" in - plan9) - syscall_goos="syscall_$GOOS.go" - if [ -n "$mksyscall" ]; then echo "$mksyscall $syscall_goos syscall_$GOOSARCH.go |gofmt >zsyscall_$GOOSARCH.go"; fi - ;; - esac - if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi - if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi - if [ -n "$mktypes" ]; then echo "$mktypes types_$GOOS.go |gofmt >ztypes_$GOOSARCH.go"; fi -) | $run diff --git a/vendor/golang.org/x/sys/plan9/mkerrors.sh b/vendor/golang.org/x/sys/plan9/mkerrors.sh deleted file mode 100755 index 052c86d94..000000000 --- a/vendor/golang.org/x/sys/plan9/mkerrors.sh +++ /dev/null @@ -1,246 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2009 The Go Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -# Generate Go code listing errors and other #defined constant -# values (ENAMETOOLONG etc.), by asking the preprocessor -# about the definitions. - -unset LANG -export LC_ALL=C -export LC_CTYPE=C - -CC=${CC:-gcc} - -uname=$(uname) - -includes=' -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -' - -ccflags="$@" - -# Write go tool cgo -godefs input. -( - echo package plan9 - echo - echo '/*' - indirect="includes_$(uname)" - echo "${!indirect} $includes" - echo '*/' - echo 'import "C"' - echo - echo 'const (' - - # The gcc command line prints all the #defines - # it encounters while processing the input - echo "${!indirect} $includes" | $CC -x c - -E -dM $ccflags | - awk ' - $1 != "#define" || $2 ~ /\(/ || $3 == "" {next} - - $2 ~ /^E([ABCD]X|[BIS]P|[SD]I|S|FL)$/ {next} # 386 registers - $2 ~ /^(SIGEV_|SIGSTKSZ|SIGRT(MIN|MAX))/ {next} - $2 ~ /^(SCM_SRCRT)$/ {next} - $2 ~ /^(MAP_FAILED)$/ {next} - - $2 !~ /^ETH_/ && - $2 !~ /^EPROC_/ && - $2 !~ /^EQUIV_/ && - $2 !~ /^EXPR_/ && - $2 ~ /^E[A-Z0-9_]+$/ || - $2 ~ /^B[0-9_]+$/ || - $2 ~ /^V[A-Z0-9]+$/ || - $2 ~ /^CS[A-Z0-9]/ || - $2 ~ /^I(SIG|CANON|CRNL|EXTEN|MAXBEL|STRIP|UTF8)$/ || - $2 ~ /^IGN/ || - $2 ~ /^IX(ON|ANY|OFF)$/ || - $2 ~ /^IN(LCR|PCK)$/ || - $2 ~ /(^FLU?SH)|(FLU?SH$)/ || - $2 ~ /^C(LOCAL|READ)$/ || - $2 == "BRKINT" || - $2 == "HUPCL" || - $2 == "PENDIN" || - $2 == "TOSTOP" || - $2 ~ /^PAR/ || - $2 ~ /^SIG[^_]/ || - $2 ~ /^O[CNPFP][A-Z]+[^_][A-Z]+$/ || - $2 ~ /^IN_/ || - $2 ~ /^LOCK_(SH|EX|NB|UN)$/ || - $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ || - $2 == "ICMPV6_FILTER" || - $2 == "SOMAXCONN" || - $2 == "NAME_MAX" || - $2 == "IFNAMSIZ" || - $2 ~ /^CTL_(MAXNAME|NET|QUERY)$/ || - $2 ~ /^SYSCTL_VERS/ || - $2 ~ /^(MS|MNT)_/ || - $2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ || - $2 ~ /^(O|F|FD|NAME|S|PTRACE|PT)_/ || - $2 ~ /^LINUX_REBOOT_CMD_/ || - $2 ~ /^LINUX_REBOOT_MAGIC[12]$/ || - $2 !~ "NLA_TYPE_MASK" && - $2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P)_/ || - $2 ~ /^SIOC/ || - $2 ~ /^TIOC/ || - $2 !~ "RTF_BITS" && - $2 ~ /^(IFF|IFT|NET_RT|RTM|RTF|RTV|RTA|RTAX)_/ || - $2 ~ /^BIOC/ || - $2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ || - $2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|NOFILE|STACK)|RLIM_INFINITY/ || - $2 ~ /^PRIO_(PROCESS|PGRP|USER)/ || - $2 ~ /^CLONE_[A-Z_]+/ || - $2 !~ /^(BPF_TIMEVAL)$/ && - $2 ~ /^(BPF|DLT)_/ || - $2 !~ "WMESGLEN" && - $2 ~ /^W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", $2, $2)} - $2 ~ /^__WCOREFLAG$/ {next} - $2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)} - - {next} - ' | sort - - echo ')' -) >_const.go - -# Pull out the error names for later. -errors=$( - echo '#include ' | $CC -x c - -E -dM $ccflags | - awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print $2 }' | - sort -) - -# Pull out the signal names for later. -signals=$( - echo '#include ' | $CC -x c - -E -dM $ccflags | - awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' | - egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' | - sort -) - -# Again, writing regexps to a file. -echo '#include ' | $CC -x c - -E -dM $ccflags | - awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print "^\t" $2 "[ \t]*=" }' | - sort >_error.grep -echo '#include ' | $CC -x c - -E -dM $ccflags | - awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' | - egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' | - sort >_signal.grep - -echo '// mkerrors.sh' "$@" -echo '// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT' -echo -go tool cgo -godefs -- "$@" _const.go >_error.out -cat _error.out | grep -vf _error.grep | grep -vf _signal.grep -echo -echo '// Errors' -echo 'const (' -cat _error.out | grep -f _error.grep | sed 's/=\(.*\)/= Errno(\1)/' -echo ')' - -echo -echo '// Signals' -echo 'const (' -cat _error.out | grep -f _signal.grep | sed 's/=\(.*\)/= Signal(\1)/' -echo ')' - -# Run C program to print error and syscall strings. -( - echo -E " -#include -#include -#include -#include -#include -#include - -#define nelem(x) (sizeof(x)/sizeof((x)[0])) - -enum { A = 'A', Z = 'Z', a = 'a', z = 'z' }; // avoid need for single quotes below - -int errors[] = { -" - for i in $errors - do - echo -E ' '$i, - done - - echo -E " -}; - -int signals[] = { -" - for i in $signals - do - echo -E ' '$i, - done - - # Use -E because on some systems bash builtin interprets \n itself. - echo -E ' -}; - -static int -intcmp(const void *a, const void *b) -{ - return *(int*)a - *(int*)b; -} - -int -main(void) -{ - int i, j, e; - char buf[1024], *p; - - printf("\n\n// Error table\n"); - printf("var errors = [...]string {\n"); - qsort(errors, nelem(errors), sizeof errors[0], intcmp); - for(i=0; i 0 && errors[i-1] == e) - continue; - strcpy(buf, strerror(e)); - // lowercase first letter: Bad -> bad, but STREAM -> STREAM. - if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z) - buf[0] += a - A; - printf("\t%d: \"%s\",\n", e, buf); - } - printf("}\n\n"); - - printf("\n\n// Signal table\n"); - printf("var signals = [...]string {\n"); - qsort(signals, nelem(signals), sizeof signals[0], intcmp); - for(i=0; i 0 && signals[i-1] == e) - continue; - strcpy(buf, strsignal(e)); - // lowercase first letter: Bad -> bad, but STREAM -> STREAM. - if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z) - buf[0] += a - A; - // cut trailing : number. - p = strrchr(buf, ":"[0]); - if(p) - *p = '\0'; - printf("\t%d: \"%s\",\n", e, buf); - } - printf("}\n\n"); - - return 0; -} - -' -) >_errors.c - -$CC $ccflags -o _errors _errors.c && $GORUN ./_errors && rm -f _errors.c _errors _const.go _error.grep _signal.grep _error.out diff --git a/vendor/golang.org/x/sys/plan9/mksyscall.pl b/vendor/golang.org/x/sys/plan9/mksyscall.pl deleted file mode 100755 index ce8e1e4f3..000000000 --- a/vendor/golang.org/x/sys/plan9/mksyscall.pl +++ /dev/null @@ -1,319 +0,0 @@ -#!/usr/bin/env perl -# Copyright 2009 The Go Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -# This program reads a file containing function prototypes -# (like syscall_plan9.go) and generates system call bodies. -# The prototypes are marked by lines beginning with "//sys" -# and read like func declarations if //sys is replaced by func, but: -# * The parameter lists must give a name for each argument. -# This includes return parameters. -# * The parameter lists must give a type for each argument: -# the (x, y, z int) shorthand is not allowed. -# * If the return parameter is an error number, it must be named errno. - -# A line beginning with //sysnb is like //sys, except that the -# goroutine will not be suspended during the execution of the system -# call. This must only be used for system calls which can never -# block, as otherwise the system call could cause all goroutines to -# hang. - -use strict; - -my $cmdline = "mksyscall.pl " . join(' ', @ARGV); -my $errors = 0; -my $_32bit = ""; -my $plan9 = 0; -my $openbsd = 0; -my $netbsd = 0; -my $dragonfly = 0; -my $nacl = 0; -my $arm = 0; # 64-bit value should use (even, odd)-pair - -if($ARGV[0] eq "-b32") { - $_32bit = "big-endian"; - shift; -} elsif($ARGV[0] eq "-l32") { - $_32bit = "little-endian"; - shift; -} -if($ARGV[0] eq "-plan9") { - $plan9 = 1; - shift; -} -if($ARGV[0] eq "-openbsd") { - $openbsd = 1; - shift; -} -if($ARGV[0] eq "-netbsd") { - $netbsd = 1; - shift; -} -if($ARGV[0] eq "-dragonfly") { - $dragonfly = 1; - shift; -} -if($ARGV[0] eq "-nacl") { - $nacl = 1; - shift; -} -if($ARGV[0] eq "-arm") { - $arm = 1; - shift; -} - -if($ARGV[0] =~ /^-/) { - print STDERR "usage: mksyscall.pl [-b32 | -l32] [file ...]\n"; - exit 1; -} - -sub parseparamlist($) { - my ($list) = @_; - $list =~ s/^\s*//; - $list =~ s/\s*$//; - if($list eq "") { - return (); - } - return split(/\s*,\s*/, $list); -} - -sub parseparam($) { - my ($p) = @_; - if($p !~ /^(\S*) (\S*)$/) { - print STDERR "$ARGV:$.: malformed parameter: $p\n"; - $errors = 1; - return ("xx", "int"); - } - return ($1, $2); -} - -my $text = ""; -while(<>) { - chomp; - s/\s+/ /g; - s/^\s+//; - s/\s+$//; - my $nonblock = /^\/\/sysnb /; - next if !/^\/\/sys / && !$nonblock; - - # Line must be of the form - # func Open(path string, mode int, perm int) (fd int, errno error) - # Split into name, in params, out params. - if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)SYS_[A-Z0-9_]+))?$/) { - print STDERR "$ARGV:$.: malformed //sys declaration\n"; - $errors = 1; - next; - } - my ($func, $in, $out, $sysname) = ($2, $3, $4, $5); - - # Split argument lists on comma. - my @in = parseparamlist($in); - my @out = parseparamlist($out); - - # Try in vain to keep people from editing this file. - # The theory is that they jump into the middle of the file - # without reading the header. - $text .= "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n"; - - # Go function header. - my $out_decl = @out ? sprintf(" (%s)", join(', ', @out)) : ""; - $text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out_decl; - - # Check if err return available - my $errvar = ""; - foreach my $p (@out) { - my ($name, $type) = parseparam($p); - if($type eq "error") { - $errvar = $name; - last; - } - } - - # Prepare arguments to Syscall. - my @args = (); - my @uses = (); - my $n = 0; - foreach my $p (@in) { - my ($name, $type) = parseparam($p); - if($type =~ /^\*/) { - push @args, "uintptr(unsafe.Pointer($name))"; - } elsif($type eq "string" && $errvar ne "") { - $text .= "\tvar _p$n *byte\n"; - $text .= "\t_p$n, $errvar = BytePtrFromString($name)\n"; - $text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n"; - push @args, "uintptr(unsafe.Pointer(_p$n))"; - push @uses, "use(unsafe.Pointer(_p$n))"; - $n++; - } elsif($type eq "string") { - print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n"; - $text .= "\tvar _p$n *byte\n"; - $text .= "\t_p$n, _ = BytePtrFromString($name)\n"; - push @args, "uintptr(unsafe.Pointer(_p$n))"; - push @uses, "use(unsafe.Pointer(_p$n))"; - $n++; - } elsif($type =~ /^\[\](.*)/) { - # Convert slice into pointer, length. - # Have to be careful not to take address of &a[0] if len == 0: - # pass dummy pointer in that case. - # Used to pass nil, but some OSes or simulators reject write(fd, nil, 0). - $text .= "\tvar _p$n unsafe.Pointer\n"; - $text .= "\tif len($name) > 0 {\n\t\t_p$n = unsafe.Pointer(\&${name}[0])\n\t}"; - $text .= " else {\n\t\t_p$n = unsafe.Pointer(&_zero)\n\t}"; - $text .= "\n"; - push @args, "uintptr(_p$n)", "uintptr(len($name))"; - $n++; - } elsif($type eq "int64" && ($openbsd || $netbsd)) { - push @args, "0"; - if($_32bit eq "big-endian") { - push @args, "uintptr($name>>32)", "uintptr($name)"; - } elsif($_32bit eq "little-endian") { - push @args, "uintptr($name)", "uintptr($name>>32)"; - } else { - push @args, "uintptr($name)"; - } - } elsif($type eq "int64" && $dragonfly) { - if ($func !~ /^extp(read|write)/i) { - push @args, "0"; - } - if($_32bit eq "big-endian") { - push @args, "uintptr($name>>32)", "uintptr($name)"; - } elsif($_32bit eq "little-endian") { - push @args, "uintptr($name)", "uintptr($name>>32)"; - } else { - push @args, "uintptr($name)"; - } - } elsif($type eq "int64" && $_32bit ne "") { - if(@args % 2 && $arm) { - # arm abi specifies 64-bit argument uses - # (even, odd) pair - push @args, "0" - } - if($_32bit eq "big-endian") { - push @args, "uintptr($name>>32)", "uintptr($name)"; - } else { - push @args, "uintptr($name)", "uintptr($name>>32)"; - } - } else { - push @args, "uintptr($name)"; - } - } - - # Determine which form to use; pad args with zeros. - my $asm = "Syscall"; - if ($nonblock) { - $asm = "RawSyscall"; - } - if(@args <= 3) { - while(@args < 3) { - push @args, "0"; - } - } elsif(@args <= 6) { - $asm .= "6"; - while(@args < 6) { - push @args, "0"; - } - } elsif(@args <= 9) { - $asm .= "9"; - while(@args < 9) { - push @args, "0"; - } - } else { - print STDERR "$ARGV:$.: too many arguments to system call\n"; - } - - # System call number. - if($sysname eq "") { - $sysname = "SYS_$func"; - $sysname =~ s/([a-z])([A-Z])/${1}_$2/g; # turn FooBar into Foo_Bar - $sysname =~ y/a-z/A-Z/; - if($nacl) { - $sysname =~ y/A-Z/a-z/; - } - } - - # Actual call. - my $args = join(', ', @args); - my $call = "$asm($sysname, $args)"; - - # Assign return values. - my $body = ""; - my @ret = ("_", "_", "_"); - my $do_errno = 0; - for(my $i=0; $i<@out; $i++) { - my $p = $out[$i]; - my ($name, $type) = parseparam($p); - my $reg = ""; - if($name eq "err" && !$plan9) { - $reg = "e1"; - $ret[2] = $reg; - $do_errno = 1; - } elsif($name eq "err" && $plan9) { - $ret[0] = "r0"; - $ret[2] = "e1"; - next; - } else { - $reg = sprintf("r%d", $i); - $ret[$i] = $reg; - } - if($type eq "bool") { - $reg = "$reg != 0"; - } - if($type eq "int64" && $_32bit ne "") { - # 64-bit number in r1:r0 or r0:r1. - if($i+2 > @out) { - print STDERR "$ARGV:$.: not enough registers for int64 return\n"; - } - if($_32bit eq "big-endian") { - $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1); - } else { - $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i); - } - $ret[$i] = sprintf("r%d", $i); - $ret[$i+1] = sprintf("r%d", $i+1); - } - if($reg ne "e1" || $plan9) { - $body .= "\t$name = $type($reg)\n"; - } - } - if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") { - $text .= "\t$call\n"; - } else { - $text .= "\t$ret[0], $ret[1], $ret[2] := $call\n"; - } - foreach my $use (@uses) { - $text .= "\t$use\n"; - } - $text .= $body; - - if ($plan9 && $ret[2] eq "e1") { - $text .= "\tif int32(r0) == -1 {\n"; - $text .= "\t\terr = e1\n"; - $text .= "\t}\n"; - } elsif ($do_errno) { - $text .= "\tif e1 != 0 {\n"; - $text .= "\t\terr = e1\n"; - $text .= "\t}\n"; - } - $text .= "\treturn\n"; - $text .= "}\n\n"; -} - -chomp $text; -chomp $text; - -if($errors) { - exit 1; -} - -print <= 10 { - buf[i] = byte(val%10 + '0') - i-- - val /= 10 - } - buf[i] = byte(val + '0') - return string(buf[i:]) -} diff --git a/vendor/golang.org/x/sys/plan9/syscall.go b/vendor/golang.org/x/sys/plan9/syscall.go deleted file mode 100644 index df6f8c5b9..000000000 --- a/vendor/golang.org/x/sys/plan9/syscall.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build plan9 - -// Package plan9 contains an interface to the low-level operating system -// primitives. OS details vary depending on the underlying system, and -// by default, godoc will display the OS-specific documentation for the current -// system. If you want godoc to display documentation for another -// system, set $GOOS and $GOARCH to the desired system. For example, if -// you want to view documentation for freebsd/arm on linux/amd64, set $GOOS -// to freebsd and $GOARCH to arm. -// The primary use of this package is inside other packages that provide a more -// portable interface to the system, such as "os", "time" and "net". Use -// those packages rather than this one if you can. -// For details of the functions and data types in this package consult -// the manuals for the appropriate operating system. -// These calls return err == nil to indicate success; otherwise -// err represents an operating system error describing the failure and -// holds a value of type syscall.ErrorString. -package plan9 // import "golang.org/x/sys/plan9" - -import "unsafe" - -// ByteSliceFromString returns a NUL-terminated slice of bytes -// containing the text of s. If s contains a NUL byte at any -// location, it returns (nil, EINVAL). -func ByteSliceFromString(s string) ([]byte, error) { - for i := 0; i < len(s); i++ { - if s[i] == 0 { - return nil, EINVAL - } - } - a := make([]byte, len(s)+1) - copy(a, s) - return a, nil -} - -// BytePtrFromString returns a pointer to a NUL-terminated array of -// bytes containing the text of s. If s contains a NUL byte at any -// location, it returns (nil, EINVAL). -func BytePtrFromString(s string) (*byte, error) { - a, err := ByteSliceFromString(s) - if err != nil { - return nil, err - } - return &a[0], nil -} - -// Single-word zero for use when we need a valid pointer to 0 bytes. -// See mksyscall.pl. -var _zero uintptr - -func (ts *Timespec) Unix() (sec int64, nsec int64) { - return int64(ts.Sec), int64(ts.Nsec) -} - -func (tv *Timeval) Unix() (sec int64, nsec int64) { - return int64(tv.Sec), int64(tv.Usec) * 1000 -} - -func (ts *Timespec) Nano() int64 { - return int64(ts.Sec)*1e9 + int64(ts.Nsec) -} - -func (tv *Timeval) Nano() int64 { - return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 -} - -// use is a no-op, but the compiler cannot see that it is. -// Calling use(p) ensures that p is kept live until that point. -//go:noescape -func use(p unsafe.Pointer) diff --git a/vendor/golang.org/x/sys/plan9/syscall_plan9.go b/vendor/golang.org/x/sys/plan9/syscall_plan9.go deleted file mode 100644 index d39d07de1..000000000 --- a/vendor/golang.org/x/sys/plan9/syscall_plan9.go +++ /dev/null @@ -1,349 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Plan 9 system calls. -// This file is compiled as ordinary Go code, -// but it is also input to mksyscall, -// which parses the //sys lines and generates system call stubs. -// Note that sometimes we use a lowercase //sys name and -// wrap it in our own nicer implementation. - -package plan9 - -import ( - "syscall" - "unsafe" -) - -// A Note is a string describing a process note. -// It implements the os.Signal interface. -type Note string - -func (n Note) Signal() {} - -func (n Note) String() string { - return string(n) -} - -var ( - Stdin = 0 - Stdout = 1 - Stderr = 2 -) - -// For testing: clients can set this flag to force -// creation of IPv6 sockets to return EAFNOSUPPORT. -var SocketDisableIPv6 bool - -func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.ErrorString) -func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.ErrorString) -func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) -func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) - -func atoi(b []byte) (n uint) { - n = 0 - for i := 0; i < len(b); i++ { - n = n*10 + uint(b[i]-'0') - } - return -} - -func cstring(s []byte) string { - for i := range s { - if s[i] == 0 { - return string(s[0:i]) - } - } - return string(s) -} - -func errstr() string { - var buf [ERRMAX]byte - - RawSyscall(SYS_ERRSTR, uintptr(unsafe.Pointer(&buf[0])), uintptr(len(buf)), 0) - - buf[len(buf)-1] = 0 - return cstring(buf[:]) -} - -// Implemented in assembly to import from runtime. -func exit(code int) - -func Exit(code int) { exit(code) } - -func readnum(path string) (uint, error) { - var b [12]byte - - fd, e := Open(path, O_RDONLY) - if e != nil { - return 0, e - } - defer Close(fd) - - n, e := Pread(fd, b[:], 0) - - if e != nil { - return 0, e - } - - m := 0 - for ; m < n && b[m] == ' '; m++ { - } - - return atoi(b[m : n-1]), nil -} - -func Getpid() (pid int) { - n, _ := readnum("#c/pid") - return int(n) -} - -func Getppid() (ppid int) { - n, _ := readnum("#c/ppid") - return int(n) -} - -func Read(fd int, p []byte) (n int, err error) { - return Pread(fd, p, -1) -} - -func Write(fd int, p []byte) (n int, err error) { - return Pwrite(fd, p, -1) -} - -var ioSync int64 - -//sys fd2path(fd int, buf []byte) (err error) -func Fd2path(fd int) (path string, err error) { - var buf [512]byte - - e := fd2path(fd, buf[:]) - if e != nil { - return "", e - } - return cstring(buf[:]), nil -} - -//sys pipe(p *[2]int32) (err error) -func Pipe(p []int) (err error) { - if len(p) != 2 { - return syscall.ErrorString("bad arg in system call") - } - var pp [2]int32 - err = pipe(&pp) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - -// Underlying system call writes to newoffset via pointer. -// Implemented in assembly to avoid allocation. -func seek(placeholder uintptr, fd int, offset int64, whence int) (newoffset int64, err string) - -func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { - newoffset, e := seek(0, fd, offset, whence) - - if newoffset == -1 { - err = syscall.ErrorString(e) - } - return -} - -func Mkdir(path string, mode uint32) (err error) { - fd, err := Create(path, O_RDONLY, DMDIR|mode) - - if fd != -1 { - Close(fd) - } - - return -} - -type Waitmsg struct { - Pid int - Time [3]uint32 - Msg string -} - -func (w Waitmsg) Exited() bool { return true } -func (w Waitmsg) Signaled() bool { return false } - -func (w Waitmsg) ExitStatus() int { - if len(w.Msg) == 0 { - // a normal exit returns no message - return 0 - } - return 1 -} - -//sys await(s []byte) (n int, err error) -func Await(w *Waitmsg) (err error) { - var buf [512]byte - var f [5][]byte - - n, err := await(buf[:]) - - if err != nil || w == nil { - return - } - - nf := 0 - p := 0 - for i := 0; i < n && nf < len(f)-1; i++ { - if buf[i] == ' ' { - f[nf] = buf[p:i] - p = i + 1 - nf++ - } - } - f[nf] = buf[p:] - nf++ - - if nf != len(f) { - return syscall.ErrorString("invalid wait message") - } - w.Pid = int(atoi(f[0])) - w.Time[0] = uint32(atoi(f[1])) - w.Time[1] = uint32(atoi(f[2])) - w.Time[2] = uint32(atoi(f[3])) - w.Msg = cstring(f[4]) - if w.Msg == "''" { - // await() returns '' for no error - w.Msg = "" - } - return -} - -func Unmount(name, old string) (err error) { - fixwd() - oldp, err := BytePtrFromString(old) - if err != nil { - return err - } - oldptr := uintptr(unsafe.Pointer(oldp)) - - var r0 uintptr - var e syscall.ErrorString - - // bind(2) man page: If name is zero, everything bound or mounted upon old is unbound or unmounted. - if name == "" { - r0, _, e = Syscall(SYS_UNMOUNT, _zero, oldptr, 0) - } else { - namep, err := BytePtrFromString(name) - if err != nil { - return err - } - r0, _, e = Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(namep)), oldptr, 0) - } - - if int32(r0) == -1 { - err = e - } - return -} - -func Fchdir(fd int) (err error) { - path, err := Fd2path(fd) - - if err != nil { - return - } - - return Chdir(path) -} - -type Timespec struct { - Sec int32 - Nsec int32 -} - -type Timeval struct { - Sec int32 - Usec int32 -} - -func NsecToTimeval(nsec int64) (tv Timeval) { - nsec += 999 // round up to microsecond - tv.Usec = int32(nsec % 1e9 / 1e3) - tv.Sec = int32(nsec / 1e9) - return -} - -func nsec() int64 { - var scratch int64 - - r0, _, _ := Syscall(SYS_NSEC, uintptr(unsafe.Pointer(&scratch)), 0, 0) - // TODO(aram): remove hack after I fix _nsec in the pc64 kernel. - if r0 == 0 { - return scratch - } - return int64(r0) -} - -func Gettimeofday(tv *Timeval) error { - nsec := nsec() - *tv = NsecToTimeval(nsec) - return nil -} - -func Getpagesize() int { return 0x1000 } - -func Getegid() (egid int) { return -1 } -func Geteuid() (euid int) { return -1 } -func Getgid() (gid int) { return -1 } -func Getuid() (uid int) { return -1 } - -func Getgroups() (gids []int, err error) { - return make([]int, 0), nil -} - -//sys open(path string, mode int) (fd int, err error) -func Open(path string, mode int) (fd int, err error) { - fixwd() - return open(path, mode) -} - -//sys create(path string, mode int, perm uint32) (fd int, err error) -func Create(path string, mode int, perm uint32) (fd int, err error) { - fixwd() - return create(path, mode, perm) -} - -//sys remove(path string) (err error) -func Remove(path string) error { - fixwd() - return remove(path) -} - -//sys stat(path string, edir []byte) (n int, err error) -func Stat(path string, edir []byte) (n int, err error) { - fixwd() - return stat(path, edir) -} - -//sys bind(name string, old string, flag int) (err error) -func Bind(name string, old string, flag int) (err error) { - fixwd() - return bind(name, old, flag) -} - -//sys mount(fd int, afd int, old string, flag int, aname string) (err error) -func Mount(fd int, afd int, old string, flag int, aname string) (err error) { - fixwd() - return mount(fd, afd, old, flag, aname) -} - -//sys wstat(path string, edir []byte) (err error) -func Wstat(path string, edir []byte) (err error) { - fixwd() - return wstat(path, edir) -} - -//sys chdir(path string) (err error) -//sys Dup(oldfd int, newfd int) (fd int, err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) -//sys Close(fd int) (err error) -//sys Fstat(fd int, edir []byte) (n int, err error) -//sys Fwstat(fd int, edir []byte) (err error) diff --git a/vendor/golang.org/x/sys/plan9/syscall_test.go b/vendor/golang.org/x/sys/plan9/syscall_test.go deleted file mode 100644 index 8f829bad0..000000000 --- a/vendor/golang.org/x/sys/plan9/syscall_test.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build plan9 - -package plan9_test - -import ( - "testing" - - "golang.org/x/sys/plan9" -) - -func testSetGetenv(t *testing.T, key, value string) { - err := plan9.Setenv(key, value) - if err != nil { - t.Fatalf("Setenv failed to set %q: %v", value, err) - } - newvalue, found := plan9.Getenv(key) - if !found { - t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value) - } - if newvalue != value { - t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value) - } -} - -func TestEnv(t *testing.T) { - testSetGetenv(t, "TESTENV", "AVALUE") - // make sure TESTENV gets set to "", not deleted - testSetGetenv(t, "TESTENV", "") -} diff --git a/vendor/golang.org/x/sys/plan9/zsyscall_plan9_386.go b/vendor/golang.org/x/sys/plan9/zsyscall_plan9_386.go deleted file mode 100644 index b35598ad9..000000000 --- a/vendor/golang.org/x/sys/plan9/zsyscall_plan9_386.go +++ /dev/null @@ -1,292 +0,0 @@ -// mksyscall.pl -l32 -plan9 syscall_plan9.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT - -package plan9 - -import "unsafe" - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func fd2path(fd int, buf []byte) (err error) { - var _p0 unsafe.Pointer - if len(buf) > 0 { - _p0 = unsafe.Pointer(&buf[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall(SYS_FD2PATH, uintptr(fd), uintptr(_p0), uintptr(len(buf))) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func pipe(p *[2]int32) (err error) { - r0, _, e1 := Syscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func await(s []byte) (n int, err error) { - var _p0 unsafe.Pointer - if len(s) > 0 { - _p0 = unsafe.Pointer(&s[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall(SYS_AWAIT, uintptr(_p0), uintptr(len(s)), 0) - n = int(r0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func open(path string, mode int) (fd int, err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) - use(unsafe.Pointer(_p0)) - fd = int(r0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func create(path string, mode int, perm uint32) (fd int, err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - r0, _, e1 := Syscall(SYS_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) - use(unsafe.Pointer(_p0)) - fd = int(r0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func remove(path string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - r0, _, e1 := Syscall(SYS_REMOVE, uintptr(unsafe.Pointer(_p0)), 0, 0) - use(unsafe.Pointer(_p0)) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func stat(path string, edir []byte) (n int, err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - var _p1 unsafe.Pointer - if len(edir) > 0 { - _p1 = unsafe.Pointer(&edir[0]) - } else { - _p1 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(edir))) - use(unsafe.Pointer(_p0)) - n = int(r0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func bind(name string, old string, flag int) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(name) - if err != nil { - return - } - var _p1 *byte - _p1, err = BytePtrFromString(old) - if err != nil { - return - } - r0, _, e1 := Syscall(SYS_BIND, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) - use(unsafe.Pointer(_p0)) - use(unsafe.Pointer(_p1)) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func mount(fd int, afd int, old string, flag int, aname string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(old) - if err != nil { - return - } - var _p1 *byte - _p1, err = BytePtrFromString(aname) - if err != nil { - return - } - r0, _, e1 := Syscall6(SYS_MOUNT, uintptr(fd), uintptr(afd), uintptr(unsafe.Pointer(_p0)), uintptr(flag), uintptr(unsafe.Pointer(_p1)), 0) - use(unsafe.Pointer(_p0)) - use(unsafe.Pointer(_p1)) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func wstat(path string, edir []byte) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - var _p1 unsafe.Pointer - if len(edir) > 0 { - _p1 = unsafe.Pointer(&edir[0]) - } else { - _p1 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall(SYS_WSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(edir))) - use(unsafe.Pointer(_p0)) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func chdir(path string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - r0, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) - use(unsafe.Pointer(_p0)) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Dup(oldfd int, newfd int) (fd int, err error) { - r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), uintptr(newfd), 0) - fd = int(r0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Pread(fd int, p []byte, offset int64) (n int, err error) { - var _p0 unsafe.Pointer - if len(p) > 0 { - _p0 = unsafe.Pointer(&p[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0) - n = int(r0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { - var _p0 unsafe.Pointer - if len(p) > 0 { - _p0 = unsafe.Pointer(&p[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0) - n = int(r0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Close(fd int) (err error) { - r0, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Fstat(fd int, edir []byte) (n int, err error) { - var _p0 unsafe.Pointer - if len(edir) > 0 { - _p0 = unsafe.Pointer(&edir[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(_p0), uintptr(len(edir))) - n = int(r0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Fwstat(fd int, edir []byte) (err error) { - var _p0 unsafe.Pointer - if len(edir) > 0 { - _p0 = unsafe.Pointer(&edir[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall(SYS_FWSTAT, uintptr(fd), uintptr(_p0), uintptr(len(edir))) - if int32(r0) == -1 { - err = e1 - } - return -} diff --git a/vendor/golang.org/x/sys/plan9/zsyscall_plan9_amd64.go b/vendor/golang.org/x/sys/plan9/zsyscall_plan9_amd64.go deleted file mode 100644 index b35598ad9..000000000 --- a/vendor/golang.org/x/sys/plan9/zsyscall_plan9_amd64.go +++ /dev/null @@ -1,292 +0,0 @@ -// mksyscall.pl -l32 -plan9 syscall_plan9.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT - -package plan9 - -import "unsafe" - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func fd2path(fd int, buf []byte) (err error) { - var _p0 unsafe.Pointer - if len(buf) > 0 { - _p0 = unsafe.Pointer(&buf[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall(SYS_FD2PATH, uintptr(fd), uintptr(_p0), uintptr(len(buf))) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func pipe(p *[2]int32) (err error) { - r0, _, e1 := Syscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func await(s []byte) (n int, err error) { - var _p0 unsafe.Pointer - if len(s) > 0 { - _p0 = unsafe.Pointer(&s[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall(SYS_AWAIT, uintptr(_p0), uintptr(len(s)), 0) - n = int(r0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func open(path string, mode int) (fd int, err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) - use(unsafe.Pointer(_p0)) - fd = int(r0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func create(path string, mode int, perm uint32) (fd int, err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - r0, _, e1 := Syscall(SYS_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) - use(unsafe.Pointer(_p0)) - fd = int(r0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func remove(path string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - r0, _, e1 := Syscall(SYS_REMOVE, uintptr(unsafe.Pointer(_p0)), 0, 0) - use(unsafe.Pointer(_p0)) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func stat(path string, edir []byte) (n int, err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - var _p1 unsafe.Pointer - if len(edir) > 0 { - _p1 = unsafe.Pointer(&edir[0]) - } else { - _p1 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(edir))) - use(unsafe.Pointer(_p0)) - n = int(r0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func bind(name string, old string, flag int) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(name) - if err != nil { - return - } - var _p1 *byte - _p1, err = BytePtrFromString(old) - if err != nil { - return - } - r0, _, e1 := Syscall(SYS_BIND, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) - use(unsafe.Pointer(_p0)) - use(unsafe.Pointer(_p1)) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func mount(fd int, afd int, old string, flag int, aname string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(old) - if err != nil { - return - } - var _p1 *byte - _p1, err = BytePtrFromString(aname) - if err != nil { - return - } - r0, _, e1 := Syscall6(SYS_MOUNT, uintptr(fd), uintptr(afd), uintptr(unsafe.Pointer(_p0)), uintptr(flag), uintptr(unsafe.Pointer(_p1)), 0) - use(unsafe.Pointer(_p0)) - use(unsafe.Pointer(_p1)) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func wstat(path string, edir []byte) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - var _p1 unsafe.Pointer - if len(edir) > 0 { - _p1 = unsafe.Pointer(&edir[0]) - } else { - _p1 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall(SYS_WSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(edir))) - use(unsafe.Pointer(_p0)) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func chdir(path string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - r0, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) - use(unsafe.Pointer(_p0)) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Dup(oldfd int, newfd int) (fd int, err error) { - r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), uintptr(newfd), 0) - fd = int(r0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Pread(fd int, p []byte, offset int64) (n int, err error) { - var _p0 unsafe.Pointer - if len(p) > 0 { - _p0 = unsafe.Pointer(&p[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0) - n = int(r0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { - var _p0 unsafe.Pointer - if len(p) > 0 { - _p0 = unsafe.Pointer(&p[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0) - n = int(r0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Close(fd int) (err error) { - r0, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Fstat(fd int, edir []byte) (n int, err error) { - var _p0 unsafe.Pointer - if len(edir) > 0 { - _p0 = unsafe.Pointer(&edir[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(_p0), uintptr(len(edir))) - n = int(r0) - if int32(r0) == -1 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Fwstat(fd int, edir []byte) (err error) { - var _p0 unsafe.Pointer - if len(edir) > 0 { - _p0 = unsafe.Pointer(&edir[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall(SYS_FWSTAT, uintptr(fd), uintptr(_p0), uintptr(len(edir))) - if int32(r0) == -1 { - err = e1 - } - return -} diff --git a/vendor/golang.org/x/sys/plan9/zsysnum_plan9.go b/vendor/golang.org/x/sys/plan9/zsysnum_plan9.go deleted file mode 100644 index 22e8abd43..000000000 --- a/vendor/golang.org/x/sys/plan9/zsysnum_plan9.go +++ /dev/null @@ -1,49 +0,0 @@ -// mksysnum_plan9.sh /opt/plan9/sys/src/libc/9syscall/sys.h -// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT - -package plan9 - -const ( - SYS_SYSR1 = 0 - SYS_BIND = 2 - SYS_CHDIR = 3 - SYS_CLOSE = 4 - SYS_DUP = 5 - SYS_ALARM = 6 - SYS_EXEC = 7 - SYS_EXITS = 8 - SYS_FAUTH = 10 - SYS_SEGBRK = 12 - SYS_OPEN = 14 - SYS_OSEEK = 16 - SYS_SLEEP = 17 - SYS_RFORK = 19 - SYS_PIPE = 21 - SYS_CREATE = 22 - SYS_FD2PATH = 23 - SYS_BRK_ = 24 - SYS_REMOVE = 25 - SYS_NOTIFY = 28 - SYS_NOTED = 29 - SYS_SEGATTACH = 30 - SYS_SEGDETACH = 31 - SYS_SEGFREE = 32 - SYS_SEGFLUSH = 33 - SYS_RENDEZVOUS = 34 - SYS_UNMOUNT = 35 - SYS_SEMACQUIRE = 37 - SYS_SEMRELEASE = 38 - SYS_SEEK = 39 - SYS_FVERSION = 40 - SYS_ERRSTR = 41 - SYS_STAT = 42 - SYS_FSTAT = 43 - SYS_WSTAT = 44 - SYS_FWSTAT = 45 - SYS_MOUNT = 46 - SYS_AWAIT = 47 - SYS_PREAD = 50 - SYS_PWRITE = 51 - SYS_TSEMACQUIRE = 52 - SYS_NSEC = 53 -) diff --git a/vendor/golang.org/x/sys/unix/creds_test.go b/vendor/golang.org/x/sys/unix/creds_test.go deleted file mode 100644 index eaae7c367..000000000 --- a/vendor/golang.org/x/sys/unix/creds_test.go +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build linux - -package unix_test - -import ( - "bytes" - "net" - "os" - "syscall" - "testing" - - "golang.org/x/sys/unix" -) - -// TestSCMCredentials tests the sending and receiving of credentials -// (PID, UID, GID) in an ancillary message between two UNIX -// sockets. The SO_PASSCRED socket option is enabled on the sending -// socket for this to work. -func TestSCMCredentials(t *testing.T) { - fds, err := unix.Socketpair(unix.AF_LOCAL, unix.SOCK_STREAM, 0) - if err != nil { - t.Fatalf("Socketpair: %v", err) - } - defer unix.Close(fds[0]) - defer unix.Close(fds[1]) - - err = unix.SetsockoptInt(fds[0], unix.SOL_SOCKET, unix.SO_PASSCRED, 1) - if err != nil { - t.Fatalf("SetsockoptInt: %v", err) - } - - srvFile := os.NewFile(uintptr(fds[0]), "server") - defer srvFile.Close() - srv, err := net.FileConn(srvFile) - if err != nil { - t.Errorf("FileConn: %v", err) - return - } - defer srv.Close() - - cliFile := os.NewFile(uintptr(fds[1]), "client") - defer cliFile.Close() - cli, err := net.FileConn(cliFile) - if err != nil { - t.Errorf("FileConn: %v", err) - return - } - defer cli.Close() - - var ucred unix.Ucred - if os.Getuid() != 0 { - ucred.Pid = int32(os.Getpid()) - ucred.Uid = 0 - ucred.Gid = 0 - oob := unix.UnixCredentials(&ucred) - _, _, err := cli.(*net.UnixConn).WriteMsgUnix(nil, oob, nil) - if op, ok := err.(*net.OpError); ok { - err = op.Err - } - if sys, ok := err.(*os.SyscallError); ok { - err = sys.Err - } - if err != syscall.EPERM { - t.Fatalf("WriteMsgUnix failed with %v, want EPERM", err) - } - } - - ucred.Pid = int32(os.Getpid()) - ucred.Uid = uint32(os.Getuid()) - ucred.Gid = uint32(os.Getgid()) - oob := unix.UnixCredentials(&ucred) - - // this is going to send a dummy byte - n, oobn, err := cli.(*net.UnixConn).WriteMsgUnix(nil, oob, nil) - if err != nil { - t.Fatalf("WriteMsgUnix: %v", err) - } - if n != 0 { - t.Fatalf("WriteMsgUnix n = %d, want 0", n) - } - if oobn != len(oob) { - t.Fatalf("WriteMsgUnix oobn = %d, want %d", oobn, len(oob)) - } - - oob2 := make([]byte, 10*len(oob)) - n, oobn2, flags, _, err := srv.(*net.UnixConn).ReadMsgUnix(nil, oob2) - if err != nil { - t.Fatalf("ReadMsgUnix: %v", err) - } - if flags != 0 { - t.Fatalf("ReadMsgUnix flags = 0x%x, want 0", flags) - } - if n != 1 { - t.Fatalf("ReadMsgUnix n = %d, want 1 (dummy byte)", n) - } - if oobn2 != oobn { - // without SO_PASSCRED set on the socket, ReadMsgUnix will - // return zero oob bytes - t.Fatalf("ReadMsgUnix oobn = %d, want %d", oobn2, oobn) - } - oob2 = oob2[:oobn2] - if !bytes.Equal(oob, oob2) { - t.Fatal("ReadMsgUnix oob bytes don't match") - } - - scm, err := unix.ParseSocketControlMessage(oob2) - if err != nil { - t.Fatalf("ParseSocketControlMessage: %v", err) - } - newUcred, err := unix.ParseUnixCredentials(&scm[0]) - if err != nil { - t.Fatalf("ParseUnixCredentials: %v", err) - } - if *newUcred != ucred { - t.Fatalf("ParseUnixCredentials = %+v, want %+v", newUcred, ucred) - } -} diff --git a/vendor/golang.org/x/sys/unix/export_test.go b/vendor/golang.org/x/sys/unix/export_test.go deleted file mode 100644 index b4fdd970b..000000000 --- a/vendor/golang.org/x/sys/unix/export_test.go +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package unix - -var Itoa = itoa diff --git a/vendor/golang.org/x/sys/unix/mmap_unix_test.go b/vendor/golang.org/x/sys/unix/mmap_unix_test.go deleted file mode 100644 index 18ccec05f..000000000 --- a/vendor/golang.org/x/sys/unix/mmap_unix_test.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package unix_test - -import ( - "testing" - - "golang.org/x/sys/unix" -) - -func TestMmap(t *testing.T) { - b, err := unix.Mmap(-1, 0, unix.Getpagesize(), unix.PROT_NONE, unix.MAP_ANON|unix.MAP_PRIVATE) - if err != nil { - t.Fatalf("Mmap: %v", err) - } - if err := unix.Munmap(b); err != nil { - t.Fatalf("Munmap: %v", err) - } -} diff --git a/vendor/golang.org/x/sys/unix/syscall.go b/vendor/golang.org/x/sys/unix/syscall.go index a0bcf842c..571e6993c 100644 --- a/vendor/golang.org/x/sys/unix/syscall.go +++ b/vendor/golang.org/x/sys/unix/syscall.go @@ -19,7 +19,7 @@ // These calls return err == nil to indicate success; otherwise // err represents an operating system error describing the failure and // holds a value of type syscall.Errno. -package unix // import "golang.org/x/sys/unix" +package unix import "unsafe" diff --git a/vendor/golang.org/x/sys/unix/syscall_bsd_test.go b/vendor/golang.org/x/sys/unix/syscall_bsd_test.go deleted file mode 100644 index d8085a072..000000000 --- a/vendor/golang.org/x/sys/unix/syscall_bsd_test.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd openbsd - -package unix_test - -import ( - "os/exec" - "runtime" - "testing" - - "golang.org/x/sys/unix" -) - -const MNT_WAIT = 1 -const MNT_NOWAIT = 2 - -func TestGetfsstat(t *testing.T) { - const flags = MNT_NOWAIT // see golang.org/issue/16937 - n, err := unix.Getfsstat(nil, flags) - if err != nil { - t.Fatal(err) - } - - data := make([]unix.Statfs_t, n) - n2, err := unix.Getfsstat(data, flags) - if err != nil { - t.Fatal(err) - } - if n != n2 { - t.Errorf("Getfsstat(nil) = %d, but subsequent Getfsstat(slice) = %d", n, n2) - } - for i, stat := range data { - if stat == (unix.Statfs_t{}) { - t.Errorf("index %v is an empty Statfs_t struct", i) - } - } - if t.Failed() { - for i, stat := range data[:n2] { - t.Logf("data[%v] = %+v", i, stat) - } - mount, err := exec.Command("mount").CombinedOutput() - if err != nil { - t.Logf("mount: %v\n%s", err, mount) - } else { - t.Logf("mount: %s", mount) - } - } -} - -func TestSysctlRaw(t *testing.T) { - if runtime.GOOS == "openbsd" { - t.Skip("kern.proc.pid does not exist on OpenBSD") - } - - _, err := unix.SysctlRaw("kern.proc.pid", unix.Getpid()) - if err != nil { - t.Fatal(err) - } -} diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_test.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_test.go deleted file mode 100644 index cd13080ad..000000000 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_test.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build freebsd - -package unix_test - -import ( - "os" - "testing" - - "golang.org/x/sys/unix" -) - -func TestSysctUint64(t *testing.T) { - _, err := unix.SysctlUint64("vm.max_kernel_address") - if err != nil { - if os.Getenv("GO_BUILDER_NAME") == "freebsd-386-gce101" { - t.Skipf("Ignoring known failing test (golang.org/issue/15186). Failed with: %v", err) - } - t.Fatal(err) - } -} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_test.go b/vendor/golang.org/x/sys/unix/syscall_linux_test.go deleted file mode 100644 index 91184cae0..000000000 --- a/vendor/golang.org/x/sys/unix/syscall_linux_test.go +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build linux - -package unix_test - -import ( - "io/ioutil" - "os" - "testing" - "time" - - "golang.org/x/sys/unix" -) - -func TestPoll(t *testing.T) { - f, cleanup := mktmpfifo(t) - defer cleanup() - - const timeout = 100 - - ok := make(chan bool, 1) - go func() { - select { - case <-time.After(10 * timeout * time.Millisecond): - t.Errorf("Poll: failed to timeout after %d milliseconds", 10*timeout) - case <-ok: - } - }() - - fds := []unix.PollFd{{Fd: int32(f.Fd()), Events: unix.POLLIN}} - n, err := unix.Poll(fds, timeout) - ok <- true - if err != nil { - t.Errorf("Poll: unexpected error: %v", err) - return - } - if n != 0 { - t.Errorf("Poll: wrong number of events: got %v, expected %v", n, 0) - return - } -} - -func TestPpoll(t *testing.T) { - f, cleanup := mktmpfifo(t) - defer cleanup() - - const timeout = 100 * time.Millisecond - - ok := make(chan bool, 1) - go func() { - select { - case <-time.After(10 * timeout): - t.Errorf("Ppoll: failed to timeout after %d", 10*timeout) - case <-ok: - } - }() - - fds := []unix.PollFd{{Fd: int32(f.Fd()), Events: unix.POLLIN}} - timeoutTs := unix.NsecToTimespec(int64(timeout)) - n, err := unix.Ppoll(fds, &timeoutTs, nil) - ok <- true - if err != nil { - t.Errorf("Ppoll: unexpected error: %v", err) - return - } - if n != 0 { - t.Errorf("Ppoll: wrong number of events: got %v, expected %v", n, 0) - return - } -} - -// mktmpfifo creates a temporary FIFO and provides a cleanup function. -func mktmpfifo(t *testing.T) (*os.File, func()) { - err := unix.Mkfifo("fifo", 0666) - if err != nil { - t.Fatalf("mktmpfifo: failed to create FIFO: %v", err) - } - - f, err := os.OpenFile("fifo", os.O_RDWR, 0666) - if err != nil { - os.Remove("fifo") - t.Fatalf("mktmpfifo: failed to open FIFO: %v", err) - } - - return f, func() { - f.Close() - os.Remove("fifo") - } -} - -func TestTime(t *testing.T) { - var ut unix.Time_t - ut2, err := unix.Time(&ut) - if err != nil { - t.Fatalf("Time: %v", err) - } - if ut != ut2 { - t.Errorf("Time: return value %v should be equal to argument %v", ut2, ut) - } - - var now time.Time - - for i := 0; i < 10; i++ { - ut, err = unix.Time(nil) - if err != nil { - t.Fatalf("Time: %v", err) - } - - now = time.Now() - - if int64(ut) == now.Unix() { - return - } - } - - t.Errorf("Time: return value %v should be nearly equal to time.Now().Unix() %v", ut, now.Unix()) -} - -func TestUtime(t *testing.T) { - defer chtmpdir(t)() - - touch(t, "file1") - - buf := &unix.Utimbuf{ - Modtime: 12345, - } - - err := unix.Utime("file1", buf) - if err != nil { - t.Fatalf("Utime: %v", err) - } - - fi, err := os.Stat("file1") - if err != nil { - t.Fatal(err) - } - - if fi.ModTime().Unix() != 12345 { - t.Errorf("Utime: failed to change modtime: expected %v, got %v", 12345, fi.ModTime().Unix()) - } -} - -func TestGetrlimit(t *testing.T) { - var rlim unix.Rlimit - err := unix.Getrlimit(unix.RLIMIT_AS, &rlim) - if err != nil { - t.Fatalf("Getrlimit: %v", err) - } -} - -// utilities taken from os/os_test.go - -func touch(t *testing.T, name string) { - f, err := os.Create(name) - if err != nil { - t.Fatal(err) - } - if err := f.Close(); err != nil { - t.Fatal(err) - } -} - -// chtmpdir changes the working directory to a new temporary directory and -// provides a cleanup function. Used when PWD is read-only. -func chtmpdir(t *testing.T) func() { - oldwd, err := os.Getwd() - if err != nil { - t.Fatalf("chtmpdir: %v", err) - } - d, err := ioutil.TempDir("", "test") - if err != nil { - t.Fatalf("chtmpdir: %v", err) - } - if err := os.Chdir(d); err != nil { - t.Fatalf("chtmpdir: %v", err) - } - return func() { - if err := os.Chdir(oldwd); err != nil { - t.Fatalf("chtmpdir: %v", err) - } - os.RemoveAll(d) - } -} diff --git a/vendor/golang.org/x/sys/unix/syscall_test.go b/vendor/golang.org/x/sys/unix/syscall_test.go deleted file mode 100644 index 95eac92ac..000000000 --- a/vendor/golang.org/x/sys/unix/syscall_test.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package unix_test - -import ( - "fmt" - "testing" - - "golang.org/x/sys/unix" -) - -func testSetGetenv(t *testing.T, key, value string) { - err := unix.Setenv(key, value) - if err != nil { - t.Fatalf("Setenv failed to set %q: %v", value, err) - } - newvalue, found := unix.Getenv(key) - if !found { - t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value) - } - if newvalue != value { - t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value) - } -} - -func TestEnv(t *testing.T) { - testSetGetenv(t, "TESTENV", "AVALUE") - // make sure TESTENV gets set to "", not deleted - testSetGetenv(t, "TESTENV", "") -} - -func TestItoa(t *testing.T) { - // Make most negative integer: 0x8000... - i := 1 - for i<<1 != 0 { - i <<= 1 - } - if i >= 0 { - t.Fatal("bad math") - } - s := unix.Itoa(i) - f := fmt.Sprint(i) - if s != f { - t.Fatalf("itoa(%d) = %s, want %s", i, s, f) - } -} diff --git a/vendor/golang.org/x/sys/unix/syscall_unix_test.go b/vendor/golang.org/x/sys/unix/syscall_unix_test.go deleted file mode 100644 index 49208a000..000000000 --- a/vendor/golang.org/x/sys/unix/syscall_unix_test.go +++ /dev/null @@ -1,353 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package unix_test - -import ( - "flag" - "fmt" - "io/ioutil" - "net" - "os" - "os/exec" - "path/filepath" - "runtime" - "testing" - "time" - - "golang.org/x/sys/unix" -) - -// Tests that below functions, structures and constants are consistent -// on all Unix-like systems. -func _() { - // program scheduling priority functions and constants - var ( - _ func(int, int, int) error = unix.Setpriority - _ func(int, int) (int, error) = unix.Getpriority - ) - const ( - _ int = unix.PRIO_USER - _ int = unix.PRIO_PROCESS - _ int = unix.PRIO_PGRP - ) - - // termios constants - const ( - _ int = unix.TCIFLUSH - _ int = unix.TCIOFLUSH - _ int = unix.TCOFLUSH - ) - - // fcntl file locking structure and constants - var ( - _ = unix.Flock_t{ - Type: int16(0), - Whence: int16(0), - Start: int64(0), - Len: int64(0), - Pid: int32(0), - } - ) - const ( - _ = unix.F_GETLK - _ = unix.F_SETLK - _ = unix.F_SETLKW - ) -} - -// TestFcntlFlock tests whether the file locking structure matches -// the calling convention of each kernel. -func TestFcntlFlock(t *testing.T) { - name := filepath.Join(os.TempDir(), "TestFcntlFlock") - fd, err := unix.Open(name, unix.O_CREAT|unix.O_RDWR|unix.O_CLOEXEC, 0) - if err != nil { - t.Fatalf("Open failed: %v", err) - } - defer unix.Unlink(name) - defer unix.Close(fd) - flock := unix.Flock_t{ - Type: unix.F_RDLCK, - Start: 0, Len: 0, Whence: 1, - } - if err := unix.FcntlFlock(uintptr(fd), unix.F_GETLK, &flock); err != nil { - t.Fatalf("FcntlFlock failed: %v", err) - } -} - -// TestPassFD tests passing a file descriptor over a Unix socket. -// -// This test involved both a parent and child process. The parent -// process is invoked as a normal test, with "go test", which then -// runs the child process by running the current test binary with args -// "-test.run=^TestPassFD$" and an environment variable used to signal -// that the test should become the child process instead. -func TestPassFD(t *testing.T) { - switch runtime.GOOS { - case "dragonfly": - // TODO(jsing): Figure out why sendmsg is returning EINVAL. - t.Skip("skipping test on dragonfly") - case "solaris": - // TODO(aram): Figure out why ReadMsgUnix is returning empty message. - t.Skip("skipping test on solaris, see issue 7402") - } - if os.Getenv("GO_WANT_HELPER_PROCESS") == "1" { - passFDChild() - return - } - - tempDir, err := ioutil.TempDir("", "TestPassFD") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(tempDir) - - fds, err := unix.Socketpair(unix.AF_LOCAL, unix.SOCK_STREAM, 0) - if err != nil { - t.Fatalf("Socketpair: %v", err) - } - defer unix.Close(fds[0]) - defer unix.Close(fds[1]) - writeFile := os.NewFile(uintptr(fds[0]), "child-writes") - readFile := os.NewFile(uintptr(fds[1]), "parent-reads") - defer writeFile.Close() - defer readFile.Close() - - cmd := exec.Command(os.Args[0], "-test.run=^TestPassFD$", "--", tempDir) - cmd.Env = []string{"GO_WANT_HELPER_PROCESS=1"} - if lp := os.Getenv("LD_LIBRARY_PATH"); lp != "" { - cmd.Env = append(cmd.Env, "LD_LIBRARY_PATH="+lp) - } - cmd.ExtraFiles = []*os.File{writeFile} - - out, err := cmd.CombinedOutput() - if len(out) > 0 || err != nil { - t.Fatalf("child process: %q, %v", out, err) - } - - c, err := net.FileConn(readFile) - if err != nil { - t.Fatalf("FileConn: %v", err) - } - defer c.Close() - - uc, ok := c.(*net.UnixConn) - if !ok { - t.Fatalf("unexpected FileConn type; expected UnixConn, got %T", c) - } - - buf := make([]byte, 32) // expect 1 byte - oob := make([]byte, 32) // expect 24 bytes - closeUnix := time.AfterFunc(5*time.Second, func() { - t.Logf("timeout reading from unix socket") - uc.Close() - }) - _, oobn, _, _, err := uc.ReadMsgUnix(buf, oob) - closeUnix.Stop() - - scms, err := unix.ParseSocketControlMessage(oob[:oobn]) - if err != nil { - t.Fatalf("ParseSocketControlMessage: %v", err) - } - if len(scms) != 1 { - t.Fatalf("expected 1 SocketControlMessage; got scms = %#v", scms) - } - scm := scms[0] - gotFds, err := unix.ParseUnixRights(&scm) - if err != nil { - t.Fatalf("unix.ParseUnixRights: %v", err) - } - if len(gotFds) != 1 { - t.Fatalf("wanted 1 fd; got %#v", gotFds) - } - - f := os.NewFile(uintptr(gotFds[0]), "fd-from-child") - defer f.Close() - - got, err := ioutil.ReadAll(f) - want := "Hello from child process!\n" - if string(got) != want { - t.Errorf("child process ReadAll: %q, %v; want %q", got, err, want) - } -} - -// passFDChild is the child process used by TestPassFD. -func passFDChild() { - defer os.Exit(0) - - // Look for our fd. It should be fd 3, but we work around an fd leak - // bug here (http://golang.org/issue/2603) to let it be elsewhere. - var uc *net.UnixConn - for fd := uintptr(3); fd <= 10; fd++ { - f := os.NewFile(fd, "unix-conn") - var ok bool - netc, _ := net.FileConn(f) - uc, ok = netc.(*net.UnixConn) - if ok { - break - } - } - if uc == nil { - fmt.Println("failed to find unix fd") - return - } - - // Make a file f to send to our parent process on uc. - // We make it in tempDir, which our parent will clean up. - flag.Parse() - tempDir := flag.Arg(0) - f, err := ioutil.TempFile(tempDir, "") - if err != nil { - fmt.Printf("TempFile: %v", err) - return - } - - f.Write([]byte("Hello from child process!\n")) - f.Seek(0, 0) - - rights := unix.UnixRights(int(f.Fd())) - dummyByte := []byte("x") - n, oobn, err := uc.WriteMsgUnix(dummyByte, rights, nil) - if err != nil { - fmt.Printf("WriteMsgUnix: %v", err) - return - } - if n != 1 || oobn != len(rights) { - fmt.Printf("WriteMsgUnix = %d, %d; want 1, %d", n, oobn, len(rights)) - return - } -} - -// TestUnixRightsRoundtrip tests that UnixRights, ParseSocketControlMessage, -// and ParseUnixRights are able to successfully round-trip lists of file descriptors. -func TestUnixRightsRoundtrip(t *testing.T) { - testCases := [...][][]int{ - {{42}}, - {{1, 2}}, - {{3, 4, 5}}, - {{}}, - {{1, 2}, {3, 4, 5}, {}, {7}}, - } - for _, testCase := range testCases { - b := []byte{} - var n int - for _, fds := range testCase { - // Last assignment to n wins - n = len(b) + unix.CmsgLen(4*len(fds)) - b = append(b, unix.UnixRights(fds...)...) - } - // Truncate b - b = b[:n] - - scms, err := unix.ParseSocketControlMessage(b) - if err != nil { - t.Fatalf("ParseSocketControlMessage: %v", err) - } - if len(scms) != len(testCase) { - t.Fatalf("expected %v SocketControlMessage; got scms = %#v", len(testCase), scms) - } - for i, scm := range scms { - gotFds, err := unix.ParseUnixRights(&scm) - if err != nil { - t.Fatalf("ParseUnixRights: %v", err) - } - wantFds := testCase[i] - if len(gotFds) != len(wantFds) { - t.Fatalf("expected %v fds, got %#v", len(wantFds), gotFds) - } - for j, fd := range gotFds { - if fd != wantFds[j] { - t.Fatalf("expected fd %v, got %v", wantFds[j], fd) - } - } - } - } -} - -func TestRlimit(t *testing.T) { - var rlimit, zero unix.Rlimit - err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlimit) - if err != nil { - t.Fatalf("Getrlimit: save failed: %v", err) - } - if zero == rlimit { - t.Fatalf("Getrlimit: save failed: got zero value %#v", rlimit) - } - set := rlimit - set.Cur = set.Max - 1 - err = unix.Setrlimit(unix.RLIMIT_NOFILE, &set) - if err != nil { - t.Fatalf("Setrlimit: set failed: %#v %v", set, err) - } - var get unix.Rlimit - err = unix.Getrlimit(unix.RLIMIT_NOFILE, &get) - if err != nil { - t.Fatalf("Getrlimit: get failed: %v", err) - } - set = rlimit - set.Cur = set.Max - 1 - if set != get { - // Seems like Darwin requires some privilege to - // increase the soft limit of rlimit sandbox, though - // Setrlimit never reports an error. - switch runtime.GOOS { - case "darwin": - default: - t.Fatalf("Rlimit: change failed: wanted %#v got %#v", set, get) - } - } - err = unix.Setrlimit(unix.RLIMIT_NOFILE, &rlimit) - if err != nil { - t.Fatalf("Setrlimit: restore failed: %#v %v", rlimit, err) - } -} - -func TestSeekFailure(t *testing.T) { - _, err := unix.Seek(-1, 0, 0) - if err == nil { - t.Fatalf("Seek(-1, 0, 0) did not fail") - } - str := err.Error() // used to crash on Linux - t.Logf("Seek: %v", str) - if str == "" { - t.Fatalf("Seek(-1, 0, 0) return error with empty message") - } -} - -func TestDup(t *testing.T) { - file, err := ioutil.TempFile("", "TestDup") - if err != nil { - t.Fatalf("Tempfile failed: %v", err) - } - defer os.Remove(file.Name()) - defer file.Close() - f := int(file.Fd()) - - newFd, err := unix.Dup(f) - if err != nil { - t.Fatalf("Dup: %v", err) - } - - err = unix.Dup2(newFd, newFd+1) - if err != nil { - t.Fatalf("Dup2: %v", err) - } - - b1 := []byte("Test123") - b2 := make([]byte, 7) - _, err = unix.Write(newFd+1, b1) - if err != nil { - t.Fatalf("Write to dup2 fd failed: %v", err) - } - _, err = unix.Seek(f, 0, 0) - _, err = unix.Read(f, b2) - if err != nil { - t.Fatalf("Read back failed: %v", err) - } - if string(b1) != string(b2) { - t.Errorf("Dup: stdout write not in file, expected %v, got %v", string(b1), string(b2)) - } -} diff --git a/vendor/golang.org/x/sys/windows/asm_windows_386.s b/vendor/golang.org/x/sys/windows/asm_windows_386.s deleted file mode 100644 index 1c20dd2f8..000000000 --- a/vendor/golang.org/x/sys/windows/asm_windows_386.s +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// -// System calls for 386, Windows are implemented in runtime/syscall_windows.goc -// - -TEXT ·getprocaddress(SB), 7, $0-8 - JMP syscall·getprocaddress(SB) - -TEXT ·loadlibrary(SB), 7, $0-4 - JMP syscall·loadlibrary(SB) diff --git a/vendor/golang.org/x/sys/windows/asm_windows_amd64.s b/vendor/golang.org/x/sys/windows/asm_windows_amd64.s deleted file mode 100644 index 4d025ab55..000000000 --- a/vendor/golang.org/x/sys/windows/asm_windows_amd64.s +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// -// System calls for amd64, Windows are implemented in runtime/syscall_windows.goc -// - -TEXT ·getprocaddress(SB), 7, $0-32 - JMP syscall·getprocaddress(SB) - -TEXT ·loadlibrary(SB), 7, $0-8 - JMP syscall·loadlibrary(SB) diff --git a/vendor/golang.org/x/sys/windows/dll_windows.go b/vendor/golang.org/x/sys/windows/dll_windows.go deleted file mode 100644 index 0f6204674..000000000 --- a/vendor/golang.org/x/sys/windows/dll_windows.go +++ /dev/null @@ -1,378 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package windows - -import ( - "sync" - "sync/atomic" - "syscall" - "unsafe" -) - -// DLLError describes reasons for DLL load failures. -type DLLError struct { - Err error - ObjName string - Msg string -} - -func (e *DLLError) Error() string { return e.Msg } - -// Implemented in runtime/syscall_windows.goc; we provide jumps to them in our assembly file. -func loadlibrary(filename *uint16) (handle uintptr, err syscall.Errno) -func getprocaddress(handle uintptr, procname *uint8) (proc uintptr, err syscall.Errno) - -// A DLL implements access to a single DLL. -type DLL struct { - Name string - Handle Handle -} - -// LoadDLL loads DLL file into memory. -// -// Warning: using LoadDLL without an absolute path name is subject to -// DLL preloading attacks. To safely load a system DLL, use LazyDLL -// with System set to true, or use LoadLibraryEx directly. -func LoadDLL(name string) (dll *DLL, err error) { - namep, err := UTF16PtrFromString(name) - if err != nil { - return nil, err - } - h, e := loadlibrary(namep) - if e != 0 { - return nil, &DLLError{ - Err: e, - ObjName: name, - Msg: "Failed to load " + name + ": " + e.Error(), - } - } - d := &DLL{ - Name: name, - Handle: Handle(h), - } - return d, nil -} - -// MustLoadDLL is like LoadDLL but panics if load operation failes. -func MustLoadDLL(name string) *DLL { - d, e := LoadDLL(name) - if e != nil { - panic(e) - } - return d -} - -// FindProc searches DLL d for procedure named name and returns *Proc -// if found. It returns an error if search fails. -func (d *DLL) FindProc(name string) (proc *Proc, err error) { - namep, err := BytePtrFromString(name) - if err != nil { - return nil, err - } - a, e := getprocaddress(uintptr(d.Handle), namep) - if e != 0 { - return nil, &DLLError{ - Err: e, - ObjName: name, - Msg: "Failed to find " + name + " procedure in " + d.Name + ": " + e.Error(), - } - } - p := &Proc{ - Dll: d, - Name: name, - addr: a, - } - return p, nil -} - -// MustFindProc is like FindProc but panics if search fails. -func (d *DLL) MustFindProc(name string) *Proc { - p, e := d.FindProc(name) - if e != nil { - panic(e) - } - return p -} - -// Release unloads DLL d from memory. -func (d *DLL) Release() (err error) { - return FreeLibrary(d.Handle) -} - -// A Proc implements access to a procedure inside a DLL. -type Proc struct { - Dll *DLL - Name string - addr uintptr -} - -// Addr returns the address of the procedure represented by p. -// The return value can be passed to Syscall to run the procedure. -func (p *Proc) Addr() uintptr { - return p.addr -} - -//go:uintptrescapes - -// Call executes procedure p with arguments a. It will panic, if more then 15 arguments -// are supplied. -// -// The returned error is always non-nil, constructed from the result of GetLastError. -// Callers must inspect the primary return value to decide whether an error occurred -// (according to the semantics of the specific function being called) before consulting -// the error. The error will be guaranteed to contain windows.Errno. -func (p *Proc) Call(a ...uintptr) (r1, r2 uintptr, lastErr error) { - switch len(a) { - case 0: - return syscall.Syscall(p.Addr(), uintptr(len(a)), 0, 0, 0) - case 1: - return syscall.Syscall(p.Addr(), uintptr(len(a)), a[0], 0, 0) - case 2: - return syscall.Syscall(p.Addr(), uintptr(len(a)), a[0], a[1], 0) - case 3: - return syscall.Syscall(p.Addr(), uintptr(len(a)), a[0], a[1], a[2]) - case 4: - return syscall.Syscall6(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], 0, 0) - case 5: - return syscall.Syscall6(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], 0) - case 6: - return syscall.Syscall6(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5]) - case 7: - return syscall.Syscall9(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], 0, 0) - case 8: - return syscall.Syscall9(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], 0) - case 9: - return syscall.Syscall9(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]) - case 10: - return syscall.Syscall12(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], 0, 0) - case 11: - return syscall.Syscall12(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], 0) - case 12: - return syscall.Syscall12(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11]) - case 13: - return syscall.Syscall15(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], 0, 0) - case 14: - return syscall.Syscall15(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], 0) - case 15: - return syscall.Syscall15(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14]) - default: - panic("Call " + p.Name + " with too many arguments " + itoa(len(a)) + ".") - } - return -} - -// A LazyDLL implements access to a single DLL. -// It will delay the load of the DLL until the first -// call to its Handle method or to one of its -// LazyProc's Addr method. -type LazyDLL struct { - Name string - - // System determines whether the DLL must be loaded from the - // Windows System directory, bypassing the normal DLL search - // path. - System bool - - mu sync.Mutex - dll *DLL // non nil once DLL is loaded -} - -// Load loads DLL file d.Name into memory. It returns an error if fails. -// Load will not try to load DLL, if it is already loaded into memory. -func (d *LazyDLL) Load() error { - // Non-racy version of: - // if d.dll != nil { - if atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&d.dll))) != nil { - return nil - } - d.mu.Lock() - defer d.mu.Unlock() - if d.dll != nil { - return nil - } - - // kernel32.dll is special, since it's where LoadLibraryEx comes from. - // The kernel already special-cases its name, so it's always - // loaded from system32. - var dll *DLL - var err error - if d.Name == "kernel32.dll" { - dll, err = LoadDLL(d.Name) - } else { - dll, err = loadLibraryEx(d.Name, d.System) - } - if err != nil { - return err - } - - // Non-racy version of: - // d.dll = dll - atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(&d.dll)), unsafe.Pointer(dll)) - return nil -} - -// mustLoad is like Load but panics if search fails. -func (d *LazyDLL) mustLoad() { - e := d.Load() - if e != nil { - panic(e) - } -} - -// Handle returns d's module handle. -func (d *LazyDLL) Handle() uintptr { - d.mustLoad() - return uintptr(d.dll.Handle) -} - -// NewProc returns a LazyProc for accessing the named procedure in the DLL d. -func (d *LazyDLL) NewProc(name string) *LazyProc { - return &LazyProc{l: d, Name: name} -} - -// NewLazyDLL creates new LazyDLL associated with DLL file. -func NewLazyDLL(name string) *LazyDLL { - return &LazyDLL{Name: name} -} - -// NewLazySystemDLL is like NewLazyDLL, but will only -// search Windows System directory for the DLL if name is -// a base name (like "advapi32.dll"). -func NewLazySystemDLL(name string) *LazyDLL { - return &LazyDLL{Name: name, System: true} -} - -// A LazyProc implements access to a procedure inside a LazyDLL. -// It delays the lookup until the Addr method is called. -type LazyProc struct { - Name string - - mu sync.Mutex - l *LazyDLL - proc *Proc -} - -// Find searches DLL for procedure named p.Name. It returns -// an error if search fails. Find will not search procedure, -// if it is already found and loaded into memory. -func (p *LazyProc) Find() error { - // Non-racy version of: - // if p.proc == nil { - if atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&p.proc))) == nil { - p.mu.Lock() - defer p.mu.Unlock() - if p.proc == nil { - e := p.l.Load() - if e != nil { - return e - } - proc, e := p.l.dll.FindProc(p.Name) - if e != nil { - return e - } - // Non-racy version of: - // p.proc = proc - atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(&p.proc)), unsafe.Pointer(proc)) - } - } - return nil -} - -// mustFind is like Find but panics if search fails. -func (p *LazyProc) mustFind() { - e := p.Find() - if e != nil { - panic(e) - } -} - -// Addr returns the address of the procedure represented by p. -// The return value can be passed to Syscall to run the procedure. -func (p *LazyProc) Addr() uintptr { - p.mustFind() - return p.proc.Addr() -} - -//go:uintptrescapes - -// Call executes procedure p with arguments a. It will panic, if more then 15 arguments -// are supplied. -// -// The returned error is always non-nil, constructed from the result of GetLastError. -// Callers must inspect the primary return value to decide whether an error occurred -// (according to the semantics of the specific function being called) before consulting -// the error. The error will be guaranteed to contain windows.Errno. -func (p *LazyProc) Call(a ...uintptr) (r1, r2 uintptr, lastErr error) { - p.mustFind() - return p.proc.Call(a...) -} - -var canDoSearchSystem32Once struct { - sync.Once - v bool -} - -func initCanDoSearchSystem32() { - // https://msdn.microsoft.com/en-us/library/ms684179(v=vs.85).aspx says: - // "Windows 7, Windows Server 2008 R2, Windows Vista, and Windows - // Server 2008: The LOAD_LIBRARY_SEARCH_* flags are available on - // systems that have KB2533623 installed. To determine whether the - // flags are available, use GetProcAddress to get the address of the - // AddDllDirectory, RemoveDllDirectory, or SetDefaultDllDirectories - // function. If GetProcAddress succeeds, the LOAD_LIBRARY_SEARCH_* - // flags can be used with LoadLibraryEx." - canDoSearchSystem32Once.v = (modkernel32.NewProc("AddDllDirectory").Find() == nil) -} - -func canDoSearchSystem32() bool { - canDoSearchSystem32Once.Do(initCanDoSearchSystem32) - return canDoSearchSystem32Once.v -} - -func isBaseName(name string) bool { - for _, c := range name { - if c == ':' || c == '/' || c == '\\' { - return false - } - } - return true -} - -// loadLibraryEx wraps the Windows LoadLibraryEx function. -// -// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms684179(v=vs.85).aspx -// -// If name is not an absolute path, LoadLibraryEx searches for the DLL -// in a variety of automatic locations unless constrained by flags. -// See: https://msdn.microsoft.com/en-us/library/ff919712%28VS.85%29.aspx -func loadLibraryEx(name string, system bool) (*DLL, error) { - loadDLL := name - var flags uintptr - if system { - if canDoSearchSystem32() { - const LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800 - flags = LOAD_LIBRARY_SEARCH_SYSTEM32 - } else if isBaseName(name) { - // WindowsXP or unpatched Windows machine - // trying to load "foo.dll" out of the system - // folder, but LoadLibraryEx doesn't support - // that yet on their system, so emulate it. - windir, _ := Getenv("WINDIR") // old var; apparently works on XP - if windir == "" { - return nil, errString("%WINDIR% not defined") - } - loadDLL = windir + "\\System32\\" + name - } - } - h, err := LoadLibraryEx(loadDLL, 0, flags) - if err != nil { - return nil, err - } - return &DLL{Name: name, Handle: h}, nil -} - -type errString string - -func (s errString) Error() string { return string(s) } diff --git a/vendor/golang.org/x/sys/windows/env_unset.go b/vendor/golang.org/x/sys/windows/env_unset.go deleted file mode 100644 index 4ed03aeef..000000000 --- a/vendor/golang.org/x/sys/windows/env_unset.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows -// +build go1.4 - -package windows - -import "syscall" - -func Unsetenv(key string) error { - // This was added in Go 1.4. - return syscall.Unsetenv(key) -} diff --git a/vendor/golang.org/x/sys/windows/env_windows.go b/vendor/golang.org/x/sys/windows/env_windows.go deleted file mode 100644 index a9d8ef4b7..000000000 --- a/vendor/golang.org/x/sys/windows/env_windows.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Windows environment variables. - -package windows - -import "syscall" - -func Getenv(key string) (value string, found bool) { - return syscall.Getenv(key) -} - -func Setenv(key, value string) error { - return syscall.Setenv(key, value) -} - -func Clearenv() { - syscall.Clearenv() -} - -func Environ() []string { - return syscall.Environ() -} diff --git a/vendor/golang.org/x/sys/windows/eventlog.go b/vendor/golang.org/x/sys/windows/eventlog.go deleted file mode 100644 index 40af946e1..000000000 --- a/vendor/golang.org/x/sys/windows/eventlog.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package windows - -const ( - EVENTLOG_SUCCESS = 0 - EVENTLOG_ERROR_TYPE = 1 - EVENTLOG_WARNING_TYPE = 2 - EVENTLOG_INFORMATION_TYPE = 4 - EVENTLOG_AUDIT_SUCCESS = 8 - EVENTLOG_AUDIT_FAILURE = 16 -) - -//sys RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) [failretval==0] = advapi32.RegisterEventSourceW -//sys DeregisterEventSource(handle Handle) (err error) = advapi32.DeregisterEventSource -//sys ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) = advapi32.ReportEventW diff --git a/vendor/golang.org/x/sys/windows/exec_windows.go b/vendor/golang.org/x/sys/windows/exec_windows.go deleted file mode 100644 index 3606c3a8b..000000000 --- a/vendor/golang.org/x/sys/windows/exec_windows.go +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Fork, exec, wait, etc. - -package windows - -// EscapeArg rewrites command line argument s as prescribed -// in http://msdn.microsoft.com/en-us/library/ms880421. -// This function returns "" (2 double quotes) if s is empty. -// Alternatively, these transformations are done: -// - every back slash (\) is doubled, but only if immediately -// followed by double quote ("); -// - every double quote (") is escaped by back slash (\); -// - finally, s is wrapped with double quotes (arg -> "arg"), -// but only if there is space or tab inside s. -func EscapeArg(s string) string { - if len(s) == 0 { - return "\"\"" - } - n := len(s) - hasSpace := false - for i := 0; i < len(s); i++ { - switch s[i] { - case '"', '\\': - n++ - case ' ', '\t': - hasSpace = true - } - } - if hasSpace { - n += 2 - } - if n == len(s) { - return s - } - - qs := make([]byte, n) - j := 0 - if hasSpace { - qs[j] = '"' - j++ - } - slashes := 0 - for i := 0; i < len(s); i++ { - switch s[i] { - default: - slashes = 0 - qs[j] = s[i] - case '\\': - slashes++ - qs[j] = s[i] - case '"': - for ; slashes > 0; slashes-- { - qs[j] = '\\' - j++ - } - qs[j] = '\\' - j++ - qs[j] = s[i] - } - j++ - } - if hasSpace { - for ; slashes > 0; slashes-- { - qs[j] = '\\' - j++ - } - qs[j] = '"' - j++ - } - return string(qs[:j]) -} - -func CloseOnExec(fd Handle) { - SetHandleInformation(Handle(fd), HANDLE_FLAG_INHERIT, 0) -} - -// FullPath retrieves the full path of the specified file. -func FullPath(name string) (path string, err error) { - p, err := UTF16PtrFromString(name) - if err != nil { - return "", err - } - n := uint32(100) - for { - buf := make([]uint16, n) - n, err = GetFullPathName(p, uint32(len(buf)), &buf[0], nil) - if err != nil { - return "", err - } - if n <= uint32(len(buf)) { - return UTF16ToString(buf[:n]), nil - } - } -} diff --git a/vendor/golang.org/x/sys/windows/mksyscall.go b/vendor/golang.org/x/sys/windows/mksyscall.go deleted file mode 100644 index e1c88c9c7..000000000 --- a/vendor/golang.org/x/sys/windows/mksyscall.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package windows - -//go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go diff --git a/vendor/golang.org/x/sys/windows/race.go b/vendor/golang.org/x/sys/windows/race.go deleted file mode 100644 index 343e18ab6..000000000 --- a/vendor/golang.org/x/sys/windows/race.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows,race - -package windows - -import ( - "runtime" - "unsafe" -) - -const raceenabled = true - -func raceAcquire(addr unsafe.Pointer) { - runtime.RaceAcquire(addr) -} - -func raceReleaseMerge(addr unsafe.Pointer) { - runtime.RaceReleaseMerge(addr) -} - -func raceReadRange(addr unsafe.Pointer, len int) { - runtime.RaceReadRange(addr, len) -} - -func raceWriteRange(addr unsafe.Pointer, len int) { - runtime.RaceWriteRange(addr, len) -} diff --git a/vendor/golang.org/x/sys/windows/race0.go b/vendor/golang.org/x/sys/windows/race0.go deleted file mode 100644 index 17af843b9..000000000 --- a/vendor/golang.org/x/sys/windows/race0.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows,!race - -package windows - -import ( - "unsafe" -) - -const raceenabled = false - -func raceAcquire(addr unsafe.Pointer) { -} - -func raceReleaseMerge(addr unsafe.Pointer) { -} - -func raceReadRange(addr unsafe.Pointer, len int) { -} - -func raceWriteRange(addr unsafe.Pointer, len int) { -} diff --git a/vendor/golang.org/x/sys/windows/registry/export_test.go b/vendor/golang.org/x/sys/windows/registry/export_test.go deleted file mode 100644 index 8badf6fdc..000000000 --- a/vendor/golang.org/x/sys/windows/registry/export_test.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package registry - -func (k Key) SetValue(name string, valtype uint32, data []byte) error { - return k.setValue(name, valtype, data) -} diff --git a/vendor/golang.org/x/sys/windows/registry/key.go b/vendor/golang.org/x/sys/windows/registry/key.go deleted file mode 100644 index d0beb1956..000000000 --- a/vendor/golang.org/x/sys/windows/registry/key.go +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -// Package registry provides access to the Windows registry. -// -// Here is a simple example, opening a registry key and reading a string value from it. -// -// k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE) -// if err != nil { -// log.Fatal(err) -// } -// defer k.Close() -// -// s, _, err := k.GetStringValue("SystemRoot") -// if err != nil { -// log.Fatal(err) -// } -// fmt.Printf("Windows system root is %q\n", s) -// -package registry - -import ( - "io" - "syscall" - "time" -) - -const ( - // Registry key security and access rights. - // See https://msdn.microsoft.com/en-us/library/windows/desktop/ms724878.aspx - // for details. - ALL_ACCESS = 0xf003f - CREATE_LINK = 0x00020 - CREATE_SUB_KEY = 0x00004 - ENUMERATE_SUB_KEYS = 0x00008 - EXECUTE = 0x20019 - NOTIFY = 0x00010 - QUERY_VALUE = 0x00001 - READ = 0x20019 - SET_VALUE = 0x00002 - WOW64_32KEY = 0x00200 - WOW64_64KEY = 0x00100 - WRITE = 0x20006 -) - -// Key is a handle to an open Windows registry key. -// Keys can be obtained by calling OpenKey; there are -// also some predefined root keys such as CURRENT_USER. -// Keys can be used directly in the Windows API. -type Key syscall.Handle - -const ( - // Windows defines some predefined root keys that are always open. - // An application can use these keys as entry points to the registry. - // Normally these keys are used in OpenKey to open new keys, - // but they can also be used anywhere a Key is required. - CLASSES_ROOT = Key(syscall.HKEY_CLASSES_ROOT) - CURRENT_USER = Key(syscall.HKEY_CURRENT_USER) - LOCAL_MACHINE = Key(syscall.HKEY_LOCAL_MACHINE) - USERS = Key(syscall.HKEY_USERS) - CURRENT_CONFIG = Key(syscall.HKEY_CURRENT_CONFIG) - PERFORMANCE_DATA = Key(syscall.HKEY_PERFORMANCE_DATA) -) - -// Close closes open key k. -func (k Key) Close() error { - return syscall.RegCloseKey(syscall.Handle(k)) -} - -// OpenKey opens a new key with path name relative to key k. -// It accepts any open key, including CURRENT_USER and others, -// and returns the new key and an error. -// The access parameter specifies desired access rights to the -// key to be opened. -func OpenKey(k Key, path string, access uint32) (Key, error) { - p, err := syscall.UTF16PtrFromString(path) - if err != nil { - return 0, err - } - var subkey syscall.Handle - err = syscall.RegOpenKeyEx(syscall.Handle(k), p, 0, access, &subkey) - if err != nil { - return 0, err - } - return Key(subkey), nil -} - -// OpenRemoteKey opens a predefined registry key on another -// computer pcname. The key to be opened is specified by k, but -// can only be one of LOCAL_MACHINE, PERFORMANCE_DATA or USERS. -// If pcname is "", OpenRemoteKey returns local computer key. -func OpenRemoteKey(pcname string, k Key) (Key, error) { - var err error - var p *uint16 - if pcname != "" { - p, err = syscall.UTF16PtrFromString(`\\` + pcname) - if err != nil { - return 0, err - } - } - var remoteKey syscall.Handle - err = regConnectRegistry(p, syscall.Handle(k), &remoteKey) - if err != nil { - return 0, err - } - return Key(remoteKey), nil -} - -// ReadSubKeyNames returns the names of subkeys of key k. -// The parameter n controls the number of returned names, -// analogous to the way os.File.Readdirnames works. -func (k Key) ReadSubKeyNames(n int) ([]string, error) { - ki, err := k.Stat() - if err != nil { - return nil, err - } - names := make([]string, 0, ki.SubKeyCount) - buf := make([]uint16, ki.MaxSubKeyLen+1) // extra room for terminating zero byte -loopItems: - for i := uint32(0); ; i++ { - if n > 0 { - if len(names) == n { - return names, nil - } - } - l := uint32(len(buf)) - for { - err := syscall.RegEnumKeyEx(syscall.Handle(k), i, &buf[0], &l, nil, nil, nil, nil) - if err == nil { - break - } - if err == syscall.ERROR_MORE_DATA { - // Double buffer size and try again. - l = uint32(2 * len(buf)) - buf = make([]uint16, l) - continue - } - if err == _ERROR_NO_MORE_ITEMS { - break loopItems - } - return names, err - } - names = append(names, syscall.UTF16ToString(buf[:l])) - } - if n > len(names) { - return names, io.EOF - } - return names, nil -} - -// CreateKey creates a key named path under open key k. -// CreateKey returns the new key and a boolean flag that reports -// whether the key already existed. -// The access parameter specifies the access rights for the key -// to be created. -func CreateKey(k Key, path string, access uint32) (newk Key, openedExisting bool, err error) { - var h syscall.Handle - var d uint32 - err = regCreateKeyEx(syscall.Handle(k), syscall.StringToUTF16Ptr(path), - 0, nil, _REG_OPTION_NON_VOLATILE, access, nil, &h, &d) - if err != nil { - return 0, false, err - } - return Key(h), d == _REG_OPENED_EXISTING_KEY, nil -} - -// DeleteKey deletes the subkey path of key k and its values. -func DeleteKey(k Key, path string) error { - return regDeleteKey(syscall.Handle(k), syscall.StringToUTF16Ptr(path)) -} - -// A KeyInfo describes the statistics of a key. It is returned by Stat. -type KeyInfo struct { - SubKeyCount uint32 - MaxSubKeyLen uint32 // size of the key's subkey with the longest name, in Unicode characters, not including the terminating zero byte - ValueCount uint32 - MaxValueNameLen uint32 // size of the key's longest value name, in Unicode characters, not including the terminating zero byte - MaxValueLen uint32 // longest data component among the key's values, in bytes - lastWriteTime syscall.Filetime -} - -// ModTime returns the key's last write time. -func (ki *KeyInfo) ModTime() time.Time { - return time.Unix(0, ki.lastWriteTime.Nanoseconds()) -} - -// Stat retrieves information about the open key k. -func (k Key) Stat() (*KeyInfo, error) { - var ki KeyInfo - err := syscall.RegQueryInfoKey(syscall.Handle(k), nil, nil, nil, - &ki.SubKeyCount, &ki.MaxSubKeyLen, nil, &ki.ValueCount, - &ki.MaxValueNameLen, &ki.MaxValueLen, nil, &ki.lastWriteTime) - if err != nil { - return nil, err - } - return &ki, nil -} diff --git a/vendor/golang.org/x/sys/windows/registry/mksyscall.go b/vendor/golang.org/x/sys/windows/registry/mksyscall.go deleted file mode 100644 index 0ac95ffe7..000000000 --- a/vendor/golang.org/x/sys/windows/registry/mksyscall.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package registry - -//go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go syscall.go diff --git a/vendor/golang.org/x/sys/windows/registry/registry_test.go b/vendor/golang.org/x/sys/windows/registry/registry_test.go deleted file mode 100644 index 9c1b7820e..000000000 --- a/vendor/golang.org/x/sys/windows/registry/registry_test.go +++ /dev/null @@ -1,756 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package registry_test - -import ( - "bytes" - "crypto/rand" - "os" - "syscall" - "testing" - "time" - "unsafe" - - "golang.org/x/sys/windows/registry" -) - -func randKeyName(prefix string) string { - const numbers = "0123456789" - buf := make([]byte, 10) - rand.Read(buf) - for i, b := range buf { - buf[i] = numbers[b%byte(len(numbers))] - } - return prefix + string(buf) -} - -func TestReadSubKeyNames(t *testing.T) { - k, err := registry.OpenKey(registry.CLASSES_ROOT, "TypeLib", registry.ENUMERATE_SUB_KEYS|registry.QUERY_VALUE) - if err != nil { - t.Fatal(err) - } - defer k.Close() - - names, err := k.ReadSubKeyNames(-1) - if err != nil { - t.Fatal(err) - } - var foundStdOle bool - for _, name := range names { - // Every PC has "stdole 2.0 OLE Automation" library installed. - if name == "{00020430-0000-0000-C000-000000000046}" { - foundStdOle = true - } - } - if !foundStdOle { - t.Fatal("could not find stdole 2.0 OLE Automation") - } -} - -func TestCreateOpenDeleteKey(t *testing.T) { - k, err := registry.OpenKey(registry.CURRENT_USER, "Software", registry.QUERY_VALUE) - if err != nil { - t.Fatal(err) - } - defer k.Close() - - testKName := randKeyName("TestCreateOpenDeleteKey_") - - testK, exist, err := registry.CreateKey(k, testKName, registry.CREATE_SUB_KEY) - if err != nil { - t.Fatal(err) - } - defer testK.Close() - - if exist { - t.Fatalf("key %q already exists", testKName) - } - - testKAgain, exist, err := registry.CreateKey(k, testKName, registry.CREATE_SUB_KEY) - if err != nil { - t.Fatal(err) - } - defer testKAgain.Close() - - if !exist { - t.Fatalf("key %q should already exist", testKName) - } - - testKOpened, err := registry.OpenKey(k, testKName, registry.ENUMERATE_SUB_KEYS) - if err != nil { - t.Fatal(err) - } - defer testKOpened.Close() - - err = registry.DeleteKey(k, testKName) - if err != nil { - t.Fatal(err) - } - - testKOpenedAgain, err := registry.OpenKey(k, testKName, registry.ENUMERATE_SUB_KEYS) - if err == nil { - defer testKOpenedAgain.Close() - t.Fatalf("key %q should already been deleted", testKName) - } - if err != registry.ErrNotExist { - t.Fatalf(`unexpected error ("not exist" expected): %v`, err) - } -} - -func equalStringSlice(a, b []string) bool { - if len(a) != len(b) { - return false - } - if a == nil { - return true - } - for i := range a { - if a[i] != b[i] { - return false - } - } - return true -} - -type ValueTest struct { - Type uint32 - Name string - Value interface{} - WillFail bool -} - -var ValueTests = []ValueTest{ - {Type: registry.SZ, Name: "String1", Value: ""}, - {Type: registry.SZ, Name: "String2", Value: "\000", WillFail: true}, - {Type: registry.SZ, Name: "String3", Value: "Hello World"}, - {Type: registry.SZ, Name: "String4", Value: "Hello World\000", WillFail: true}, - {Type: registry.EXPAND_SZ, Name: "ExpString1", Value: ""}, - {Type: registry.EXPAND_SZ, Name: "ExpString2", Value: "\000", WillFail: true}, - {Type: registry.EXPAND_SZ, Name: "ExpString3", Value: "Hello World"}, - {Type: registry.EXPAND_SZ, Name: "ExpString4", Value: "Hello\000World", WillFail: true}, - {Type: registry.EXPAND_SZ, Name: "ExpString5", Value: "%PATH%"}, - {Type: registry.EXPAND_SZ, Name: "ExpString6", Value: "%NO_SUCH_VARIABLE%"}, - {Type: registry.EXPAND_SZ, Name: "ExpString7", Value: "%PATH%;."}, - {Type: registry.BINARY, Name: "Binary1", Value: []byte{}}, - {Type: registry.BINARY, Name: "Binary2", Value: []byte{1, 2, 3}}, - {Type: registry.BINARY, Name: "Binary3", Value: []byte{3, 2, 1, 0, 1, 2, 3}}, - {Type: registry.DWORD, Name: "Dword1", Value: uint64(0)}, - {Type: registry.DWORD, Name: "Dword2", Value: uint64(1)}, - {Type: registry.DWORD, Name: "Dword3", Value: uint64(0xff)}, - {Type: registry.DWORD, Name: "Dword4", Value: uint64(0xffff)}, - {Type: registry.QWORD, Name: "Qword1", Value: uint64(0)}, - {Type: registry.QWORD, Name: "Qword2", Value: uint64(1)}, - {Type: registry.QWORD, Name: "Qword3", Value: uint64(0xff)}, - {Type: registry.QWORD, Name: "Qword4", Value: uint64(0xffff)}, - {Type: registry.QWORD, Name: "Qword5", Value: uint64(0xffffff)}, - {Type: registry.QWORD, Name: "Qword6", Value: uint64(0xffffffff)}, - {Type: registry.MULTI_SZ, Name: "MultiString1", Value: []string{"a", "b", "c"}}, - {Type: registry.MULTI_SZ, Name: "MultiString2", Value: []string{"abc", "", "cba"}}, - {Type: registry.MULTI_SZ, Name: "MultiString3", Value: []string{""}}, - {Type: registry.MULTI_SZ, Name: "MultiString4", Value: []string{"abcdef"}}, - {Type: registry.MULTI_SZ, Name: "MultiString5", Value: []string{"\000"}, WillFail: true}, - {Type: registry.MULTI_SZ, Name: "MultiString6", Value: []string{"a\000b"}, WillFail: true}, - {Type: registry.MULTI_SZ, Name: "MultiString7", Value: []string{"ab", "\000", "cd"}, WillFail: true}, - {Type: registry.MULTI_SZ, Name: "MultiString8", Value: []string{"\000", "cd"}, WillFail: true}, - {Type: registry.MULTI_SZ, Name: "MultiString9", Value: []string{"ab", "\000"}, WillFail: true}, -} - -func setValues(t *testing.T, k registry.Key) { - for _, test := range ValueTests { - var err error - switch test.Type { - case registry.SZ: - err = k.SetStringValue(test.Name, test.Value.(string)) - case registry.EXPAND_SZ: - err = k.SetExpandStringValue(test.Name, test.Value.(string)) - case registry.MULTI_SZ: - err = k.SetStringsValue(test.Name, test.Value.([]string)) - case registry.BINARY: - err = k.SetBinaryValue(test.Name, test.Value.([]byte)) - case registry.DWORD: - err = k.SetDWordValue(test.Name, uint32(test.Value.(uint64))) - case registry.QWORD: - err = k.SetQWordValue(test.Name, test.Value.(uint64)) - default: - t.Fatalf("unsupported type %d for %s value", test.Type, test.Name) - } - if test.WillFail { - if err == nil { - t.Fatalf("setting %s value %q should fail, but succeeded", test.Name, test.Value) - } - } else { - if err != nil { - t.Fatal(err) - } - } - } -} - -func enumerateValues(t *testing.T, k registry.Key) { - names, err := k.ReadValueNames(-1) - if err != nil { - t.Error(err) - return - } - haveNames := make(map[string]bool) - for _, n := range names { - haveNames[n] = false - } - for _, test := range ValueTests { - wantFound := !test.WillFail - _, haveFound := haveNames[test.Name] - if wantFound && !haveFound { - t.Errorf("value %s is not found while enumerating", test.Name) - } - if haveFound && !wantFound { - t.Errorf("value %s is found while enumerating, but expected to fail", test.Name) - } - if haveFound { - delete(haveNames, test.Name) - } - } - for n, v := range haveNames { - t.Errorf("value %s (%v) is found while enumerating, but has not been cretaed", n, v) - } -} - -func testErrNotExist(t *testing.T, name string, err error) { - if err == nil { - t.Errorf("%s value should not exist", name) - return - } - if err != registry.ErrNotExist { - t.Errorf("reading %s value should return 'not exist' error, but got: %s", name, err) - return - } -} - -func testErrUnexpectedType(t *testing.T, test ValueTest, gottype uint32, err error) { - if err == nil { - t.Errorf("GetXValue(%q) should not succeed", test.Name) - return - } - if err != registry.ErrUnexpectedType { - t.Errorf("reading %s value should return 'unexpected key value type' error, but got: %s", test.Name, err) - return - } - if gottype != test.Type { - t.Errorf("want %s value type %v, got %v", test.Name, test.Type, gottype) - return - } -} - -func testGetStringValue(t *testing.T, k registry.Key, test ValueTest) { - got, gottype, err := k.GetStringValue(test.Name) - if err != nil { - t.Errorf("GetStringValue(%s) failed: %v", test.Name, err) - return - } - if got != test.Value { - t.Errorf("want %s value %q, got %q", test.Name, test.Value, got) - return - } - if gottype != test.Type { - t.Errorf("want %s value type %v, got %v", test.Name, test.Type, gottype) - return - } - if gottype == registry.EXPAND_SZ { - _, err = registry.ExpandString(got) - if err != nil { - t.Errorf("ExpandString(%s) failed: %v", got, err) - return - } - } -} - -func testGetIntegerValue(t *testing.T, k registry.Key, test ValueTest) { - got, gottype, err := k.GetIntegerValue(test.Name) - if err != nil { - t.Errorf("GetIntegerValue(%s) failed: %v", test.Name, err) - return - } - if got != test.Value.(uint64) { - t.Errorf("want %s value %v, got %v", test.Name, test.Value, got) - return - } - if gottype != test.Type { - t.Errorf("want %s value type %v, got %v", test.Name, test.Type, gottype) - return - } -} - -func testGetBinaryValue(t *testing.T, k registry.Key, test ValueTest) { - got, gottype, err := k.GetBinaryValue(test.Name) - if err != nil { - t.Errorf("GetBinaryValue(%s) failed: %v", test.Name, err) - return - } - if !bytes.Equal(got, test.Value.([]byte)) { - t.Errorf("want %s value %v, got %v", test.Name, test.Value, got) - return - } - if gottype != test.Type { - t.Errorf("want %s value type %v, got %v", test.Name, test.Type, gottype) - return - } -} - -func testGetStringsValue(t *testing.T, k registry.Key, test ValueTest) { - got, gottype, err := k.GetStringsValue(test.Name) - if err != nil { - t.Errorf("GetStringsValue(%s) failed: %v", test.Name, err) - return - } - if !equalStringSlice(got, test.Value.([]string)) { - t.Errorf("want %s value %#v, got %#v", test.Name, test.Value, got) - return - } - if gottype != test.Type { - t.Errorf("want %s value type %v, got %v", test.Name, test.Type, gottype) - return - } -} - -func testGetValue(t *testing.T, k registry.Key, test ValueTest, size int) { - if size <= 0 { - return - } - // read data with no buffer - gotsize, gottype, err := k.GetValue(test.Name, nil) - if err != nil { - t.Errorf("GetValue(%s, [%d]byte) failed: %v", test.Name, size, err) - return - } - if gotsize != size { - t.Errorf("want %s value size of %d, got %v", test.Name, size, gotsize) - return - } - if gottype != test.Type { - t.Errorf("want %s value type %v, got %v", test.Name, test.Type, gottype) - return - } - // read data with short buffer - gotsize, gottype, err = k.GetValue(test.Name, make([]byte, size-1)) - if err == nil { - t.Errorf("GetValue(%s, [%d]byte) should fail, but suceeded", test.Name, size-1) - return - } - if err != registry.ErrShortBuffer { - t.Errorf("reading %s value should return 'short buffer' error, but got: %s", test.Name, err) - return - } - if gotsize != size { - t.Errorf("want %s value size of %d, got %v", test.Name, size, gotsize) - return - } - if gottype != test.Type { - t.Errorf("want %s value type %v, got %v", test.Name, test.Type, gottype) - return - } - // read full data - gotsize, gottype, err = k.GetValue(test.Name, make([]byte, size)) - if err != nil { - t.Errorf("GetValue(%s, [%d]byte) failed: %v", test.Name, size, err) - return - } - if gotsize != size { - t.Errorf("want %s value size of %d, got %v", test.Name, size, gotsize) - return - } - if gottype != test.Type { - t.Errorf("want %s value type %v, got %v", test.Name, test.Type, gottype) - return - } - // check GetValue returns ErrNotExist as required - _, _, err = k.GetValue(test.Name+"_not_there", make([]byte, size)) - if err == nil { - t.Errorf("GetValue(%q) should not succeed", test.Name) - return - } - if err != registry.ErrNotExist { - t.Errorf("GetValue(%q) should return 'not exist' error, but got: %s", test.Name, err) - return - } -} - -func testValues(t *testing.T, k registry.Key) { - for _, test := range ValueTests { - switch test.Type { - case registry.SZ, registry.EXPAND_SZ: - if test.WillFail { - _, _, err := k.GetStringValue(test.Name) - testErrNotExist(t, test.Name, err) - } else { - testGetStringValue(t, k, test) - _, gottype, err := k.GetIntegerValue(test.Name) - testErrUnexpectedType(t, test, gottype, err) - // Size of utf16 string in bytes is not perfect, - // but correct for current test values. - // Size also includes terminating 0. - testGetValue(t, k, test, (len(test.Value.(string))+1)*2) - } - _, _, err := k.GetStringValue(test.Name + "_string_not_created") - testErrNotExist(t, test.Name+"_string_not_created", err) - case registry.DWORD, registry.QWORD: - testGetIntegerValue(t, k, test) - _, gottype, err := k.GetBinaryValue(test.Name) - testErrUnexpectedType(t, test, gottype, err) - _, _, err = k.GetIntegerValue(test.Name + "_int_not_created") - testErrNotExist(t, test.Name+"_int_not_created", err) - size := 8 - if test.Type == registry.DWORD { - size = 4 - } - testGetValue(t, k, test, size) - case registry.BINARY: - testGetBinaryValue(t, k, test) - _, gottype, err := k.GetStringsValue(test.Name) - testErrUnexpectedType(t, test, gottype, err) - _, _, err = k.GetBinaryValue(test.Name + "_byte_not_created") - testErrNotExist(t, test.Name+"_byte_not_created", err) - testGetValue(t, k, test, len(test.Value.([]byte))) - case registry.MULTI_SZ: - if test.WillFail { - _, _, err := k.GetStringsValue(test.Name) - testErrNotExist(t, test.Name, err) - } else { - testGetStringsValue(t, k, test) - _, gottype, err := k.GetStringValue(test.Name) - testErrUnexpectedType(t, test, gottype, err) - size := 0 - for _, s := range test.Value.([]string) { - size += len(s) + 1 // nil terminated - } - size += 1 // extra nil at the end - size *= 2 // count bytes, not uint16 - testGetValue(t, k, test, size) - } - _, _, err := k.GetStringsValue(test.Name + "_strings_not_created") - testErrNotExist(t, test.Name+"_strings_not_created", err) - default: - t.Errorf("unsupported type %d for %s value", test.Type, test.Name) - continue - } - } -} - -func testStat(t *testing.T, k registry.Key) { - subk, _, err := registry.CreateKey(k, "subkey", registry.CREATE_SUB_KEY) - if err != nil { - t.Error(err) - return - } - defer subk.Close() - - defer registry.DeleteKey(k, "subkey") - - ki, err := k.Stat() - if err != nil { - t.Error(err) - return - } - if ki.SubKeyCount != 1 { - t.Error("key must have 1 subkey") - } - if ki.MaxSubKeyLen != 6 { - t.Error("key max subkey name length must be 6") - } - if ki.ValueCount != 24 { - t.Errorf("key must have 24 values, but is %d", ki.ValueCount) - } - if ki.MaxValueNameLen != 12 { - t.Errorf("key max value name length must be 10, but is %d", ki.MaxValueNameLen) - } - if ki.MaxValueLen != 38 { - t.Errorf("key max value length must be 38, but is %d", ki.MaxValueLen) - } - if mt, ct := ki.ModTime(), time.Now(); ct.Sub(mt) > 100*time.Millisecond { - t.Errorf("key mod time is not close to current time: mtime=%v current=%v delta=%v", mt, ct, ct.Sub(mt)) - } -} - -func deleteValues(t *testing.T, k registry.Key) { - for _, test := range ValueTests { - if test.WillFail { - continue - } - err := k.DeleteValue(test.Name) - if err != nil { - t.Error(err) - continue - } - } - names, err := k.ReadValueNames(-1) - if err != nil { - t.Error(err) - return - } - if len(names) != 0 { - t.Errorf("some values remain after deletion: %v", names) - } -} - -func TestValues(t *testing.T) { - softwareK, err := registry.OpenKey(registry.CURRENT_USER, "Software", registry.QUERY_VALUE) - if err != nil { - t.Fatal(err) - } - defer softwareK.Close() - - testKName := randKeyName("TestValues_") - - k, exist, err := registry.CreateKey(softwareK, testKName, registry.CREATE_SUB_KEY|registry.QUERY_VALUE|registry.SET_VALUE) - if err != nil { - t.Fatal(err) - } - defer k.Close() - - if exist { - t.Fatalf("key %q already exists", testKName) - } - - defer registry.DeleteKey(softwareK, testKName) - - setValues(t, k) - - enumerateValues(t, k) - - testValues(t, k) - - testStat(t, k) - - deleteValues(t, k) -} - -func walkKey(t *testing.T, k registry.Key, kname string) { - names, err := k.ReadValueNames(-1) - if err != nil { - t.Fatalf("reading value names of %s failed: %v", kname, err) - } - for _, name := range names { - _, valtype, err := k.GetValue(name, nil) - if err != nil { - t.Fatalf("reading value type of %s of %s failed: %v", name, kname, err) - } - switch valtype { - case registry.NONE: - case registry.SZ: - _, _, err := k.GetStringValue(name) - if err != nil { - t.Error(err) - } - case registry.EXPAND_SZ: - s, _, err := k.GetStringValue(name) - if err != nil { - t.Error(err) - } - _, err = registry.ExpandString(s) - if err != nil { - t.Error(err) - } - case registry.DWORD, registry.QWORD: - _, _, err := k.GetIntegerValue(name) - if err != nil { - t.Error(err) - } - case registry.BINARY: - _, _, err := k.GetBinaryValue(name) - if err != nil { - t.Error(err) - } - case registry.MULTI_SZ: - _, _, err := k.GetStringsValue(name) - if err != nil { - t.Error(err) - } - case registry.FULL_RESOURCE_DESCRIPTOR, registry.RESOURCE_LIST, registry.RESOURCE_REQUIREMENTS_LIST: - // TODO: not implemented - default: - t.Fatalf("value type %d of %s of %s failed: %v", valtype, name, kname, err) - } - } - - names, err = k.ReadSubKeyNames(-1) - if err != nil { - t.Fatalf("reading sub-keys of %s failed: %v", kname, err) - } - for _, name := range names { - func() { - subk, err := registry.OpenKey(k, name, registry.ENUMERATE_SUB_KEYS|registry.QUERY_VALUE) - if err != nil { - if err == syscall.ERROR_ACCESS_DENIED { - // ignore error, if we are not allowed to access this key - return - } - t.Fatalf("opening sub-keys %s of %s failed: %v", name, kname, err) - } - defer subk.Close() - - walkKey(t, subk, kname+`\`+name) - }() - } -} - -func TestWalkFullRegistry(t *testing.T) { - if testing.Short() { - t.Skip("skipping long running test in short mode") - } - walkKey(t, registry.CLASSES_ROOT, "CLASSES_ROOT") - walkKey(t, registry.CURRENT_USER, "CURRENT_USER") - walkKey(t, registry.LOCAL_MACHINE, "LOCAL_MACHINE") - walkKey(t, registry.USERS, "USERS") - walkKey(t, registry.CURRENT_CONFIG, "CURRENT_CONFIG") -} - -func TestExpandString(t *testing.T) { - got, err := registry.ExpandString("%PATH%") - if err != nil { - t.Fatal(err) - } - want := os.Getenv("PATH") - if got != want { - t.Errorf("want %q string expanded, got %q", want, got) - } -} - -func TestInvalidValues(t *testing.T) { - softwareK, err := registry.OpenKey(registry.CURRENT_USER, "Software", registry.QUERY_VALUE) - if err != nil { - t.Fatal(err) - } - defer softwareK.Close() - - testKName := randKeyName("TestInvalidValues_") - - k, exist, err := registry.CreateKey(softwareK, testKName, registry.CREATE_SUB_KEY|registry.QUERY_VALUE|registry.SET_VALUE) - if err != nil { - t.Fatal(err) - } - defer k.Close() - - if exist { - t.Fatalf("key %q already exists", testKName) - } - - defer registry.DeleteKey(softwareK, testKName) - - var tests = []struct { - Type uint32 - Name string - Data []byte - }{ - {registry.DWORD, "Dword1", nil}, - {registry.DWORD, "Dword2", []byte{1, 2, 3}}, - {registry.QWORD, "Qword1", nil}, - {registry.QWORD, "Qword2", []byte{1, 2, 3}}, - {registry.QWORD, "Qword3", []byte{1, 2, 3, 4, 5, 6, 7}}, - {registry.MULTI_SZ, "MultiString1", nil}, - {registry.MULTI_SZ, "MultiString2", []byte{0}}, - {registry.MULTI_SZ, "MultiString3", []byte{'a', 'b', 0}}, - {registry.MULTI_SZ, "MultiString4", []byte{'a', 0, 0, 'b', 0}}, - {registry.MULTI_SZ, "MultiString5", []byte{'a', 0, 0}}, - } - - for _, test := range tests { - err := k.SetValue(test.Name, test.Type, test.Data) - if err != nil { - t.Fatalf("SetValue for %q failed: %v", test.Name, err) - } - } - - for _, test := range tests { - switch test.Type { - case registry.DWORD, registry.QWORD: - value, valType, err := k.GetIntegerValue(test.Name) - if err == nil { - t.Errorf("GetIntegerValue(%q) succeeded. Returns type=%d value=%v", test.Name, valType, value) - } - case registry.MULTI_SZ: - value, valType, err := k.GetStringsValue(test.Name) - if err == nil { - if len(value) != 0 { - t.Errorf("GetStringsValue(%q) succeeded. Returns type=%d value=%v", test.Name, valType, value) - } - } - default: - t.Errorf("unsupported type %d for %s value", test.Type, test.Name) - } - } -} - -func TestGetMUIStringValue(t *testing.T) { - if err := registry.LoadRegLoadMUIString(); err != nil { - t.Skip("regLoadMUIString not supported; skipping") - } - if err := procGetDynamicTimeZoneInformation.Find(); err != nil { - t.Skipf("%s not supported; skipping", procGetDynamicTimeZoneInformation.Name) - } - var dtzi DynamicTimezoneinformation - if _, err := GetDynamicTimeZoneInformation(&dtzi); err != nil { - t.Fatal(err) - } - tzKeyName := syscall.UTF16ToString(dtzi.TimeZoneKeyName[:]) - timezoneK, err := registry.OpenKey(registry.LOCAL_MACHINE, - `SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\`+tzKeyName, registry.READ) - if err != nil { - t.Fatal(err) - } - defer timezoneK.Close() - - type testType struct { - name string - want string - } - var tests = []testType{ - {"MUI_Std", syscall.UTF16ToString(dtzi.StandardName[:])}, - } - if dtzi.DynamicDaylightTimeDisabled == 0 { - tests = append(tests, testType{"MUI_Dlt", syscall.UTF16ToString(dtzi.DaylightName[:])}) - } - - for _, test := range tests { - got, err := timezoneK.GetMUIStringValue(test.name) - if err != nil { - t.Error("GetMUIStringValue:", err) - } - - if got != test.want { - t.Errorf("GetMUIStringValue: %s: Got %q, want %q", test.name, got, test.want) - } - } -} - -type DynamicTimezoneinformation struct { - Bias int32 - StandardName [32]uint16 - StandardDate syscall.Systemtime - StandardBias int32 - DaylightName [32]uint16 - DaylightDate syscall.Systemtime - DaylightBias int32 - TimeZoneKeyName [128]uint16 - DynamicDaylightTimeDisabled uint8 -} - -var ( - kernel32DLL = syscall.NewLazyDLL("kernel32") - - procGetDynamicTimeZoneInformation = kernel32DLL.NewProc("GetDynamicTimeZoneInformation") -) - -func GetDynamicTimeZoneInformation(dtzi *DynamicTimezoneinformation) (rc uint32, err error) { - r0, _, e1 := syscall.Syscall(procGetDynamicTimeZoneInformation.Addr(), 1, uintptr(unsafe.Pointer(dtzi)), 0, 0) - rc = uint32(r0) - if rc == 0xffffffff { - if e1 != 0 { - err = error(e1) - } else { - err = syscall.EINVAL - } - } - return -} diff --git a/vendor/golang.org/x/sys/windows/registry/syscall.go b/vendor/golang.org/x/sys/windows/registry/syscall.go deleted file mode 100644 index e66643cba..000000000 --- a/vendor/golang.org/x/sys/windows/registry/syscall.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package registry - -import "syscall" - -const ( - _REG_OPTION_NON_VOLATILE = 0 - - _REG_CREATED_NEW_KEY = 1 - _REG_OPENED_EXISTING_KEY = 2 - - _ERROR_NO_MORE_ITEMS syscall.Errno = 259 -) - -func LoadRegLoadMUIString() error { - return procRegLoadMUIStringW.Find() -} - -//sys regCreateKeyEx(key syscall.Handle, subkey *uint16, reserved uint32, class *uint16, options uint32, desired uint32, sa *syscall.SecurityAttributes, result *syscall.Handle, disposition *uint32) (regerrno error) = advapi32.RegCreateKeyExW -//sys regDeleteKey(key syscall.Handle, subkey *uint16) (regerrno error) = advapi32.RegDeleteKeyW -//sys regSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype uint32, buf *byte, bufsize uint32) (regerrno error) = advapi32.RegSetValueExW -//sys regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) = advapi32.RegEnumValueW -//sys regDeleteValue(key syscall.Handle, name *uint16) (regerrno error) = advapi32.RegDeleteValueW -//sys regLoadMUIString(key syscall.Handle, name *uint16, buf *uint16, buflen uint32, buflenCopied *uint32, flags uint32, dir *uint16) (regerrno error) = advapi32.RegLoadMUIStringW -//sys regConnectRegistry(machinename *uint16, key syscall.Handle, result *syscall.Handle) (regerrno error) = advapi32.RegConnectRegistryW - -//sys expandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, err error) = kernel32.ExpandEnvironmentStringsW diff --git a/vendor/golang.org/x/sys/windows/registry/value.go b/vendor/golang.org/x/sys/windows/registry/value.go deleted file mode 100644 index 71d4e15ba..000000000 --- a/vendor/golang.org/x/sys/windows/registry/value.go +++ /dev/null @@ -1,384 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package registry - -import ( - "errors" - "io" - "syscall" - "unicode/utf16" - "unsafe" -) - -const ( - // Registry value types. - NONE = 0 - SZ = 1 - EXPAND_SZ = 2 - BINARY = 3 - DWORD = 4 - DWORD_BIG_ENDIAN = 5 - LINK = 6 - MULTI_SZ = 7 - RESOURCE_LIST = 8 - FULL_RESOURCE_DESCRIPTOR = 9 - RESOURCE_REQUIREMENTS_LIST = 10 - QWORD = 11 -) - -var ( - // ErrShortBuffer is returned when the buffer was too short for the operation. - ErrShortBuffer = syscall.ERROR_MORE_DATA - - // ErrNotExist is returned when a registry key or value does not exist. - ErrNotExist = syscall.ERROR_FILE_NOT_FOUND - - // ErrUnexpectedType is returned by Get*Value when the value's type was unexpected. - ErrUnexpectedType = errors.New("unexpected key value type") -) - -// GetValue retrieves the type and data for the specified value associated -// with an open key k. It fills up buffer buf and returns the retrieved -// byte count n. If buf is too small to fit the stored value it returns -// ErrShortBuffer error along with the required buffer size n. -// If no buffer is provided, it returns true and actual buffer size n. -// If no buffer is provided, GetValue returns the value's type only. -// If the value does not exist, the error returned is ErrNotExist. -// -// GetValue is a low level function. If value's type is known, use the appropriate -// Get*Value function instead. -func (k Key) GetValue(name string, buf []byte) (n int, valtype uint32, err error) { - pname, err := syscall.UTF16PtrFromString(name) - if err != nil { - return 0, 0, err - } - var pbuf *byte - if len(buf) > 0 { - pbuf = (*byte)(unsafe.Pointer(&buf[0])) - } - l := uint32(len(buf)) - err = syscall.RegQueryValueEx(syscall.Handle(k), pname, nil, &valtype, pbuf, &l) - if err != nil { - return int(l), valtype, err - } - return int(l), valtype, nil -} - -func (k Key) getValue(name string, buf []byte) (date []byte, valtype uint32, err error) { - p, err := syscall.UTF16PtrFromString(name) - if err != nil { - return nil, 0, err - } - var t uint32 - n := uint32(len(buf)) - for { - err = syscall.RegQueryValueEx(syscall.Handle(k), p, nil, &t, (*byte)(unsafe.Pointer(&buf[0])), &n) - if err == nil { - return buf[:n], t, nil - } - if err != syscall.ERROR_MORE_DATA { - return nil, 0, err - } - if n <= uint32(len(buf)) { - return nil, 0, err - } - buf = make([]byte, n) - } -} - -// GetStringValue retrieves the string value for the specified -// value name associated with an open key k. It also returns the value's type. -// If value does not exist, GetStringValue returns ErrNotExist. -// If value is not SZ or EXPAND_SZ, it will return the correct value -// type and ErrUnexpectedType. -func (k Key) GetStringValue(name string) (val string, valtype uint32, err error) { - data, typ, err2 := k.getValue(name, make([]byte, 64)) - if err2 != nil { - return "", typ, err2 - } - switch typ { - case SZ, EXPAND_SZ: - default: - return "", typ, ErrUnexpectedType - } - if len(data) == 0 { - return "", typ, nil - } - u := (*[1 << 29]uint16)(unsafe.Pointer(&data[0]))[:] - return syscall.UTF16ToString(u), typ, nil -} - -// GetMUIStringValue retrieves the localized string value for -// the specified value name associated with an open key k. -// If the value name doesn't exist or the localized string value -// can't be resolved, GetMUIStringValue returns ErrNotExist. -// GetMUIStringValue panics if the system doesn't support -// regLoadMUIString; use LoadRegLoadMUIString to check if -// regLoadMUIString is supported before calling this function. -func (k Key) GetMUIStringValue(name string) (string, error) { - pname, err := syscall.UTF16PtrFromString(name) - if err != nil { - return "", err - } - - buf := make([]uint16, 1024) - var buflen uint32 - var pdir *uint16 - - err = regLoadMUIString(syscall.Handle(k), pname, &buf[0], uint32(len(buf)), &buflen, 0, pdir) - if err == syscall.ERROR_FILE_NOT_FOUND { // Try fallback path - - // Try to resolve the string value using the system directory as - // a DLL search path; this assumes the string value is of the form - // @[path]\dllname,-strID but with no path given, e.g. @tzres.dll,-320. - - // This approach works with tzres.dll but may have to be revised - // in the future to allow callers to provide custom search paths. - - var s string - s, err = ExpandString("%SystemRoot%\\system32\\") - if err != nil { - return "", err - } - pdir, err = syscall.UTF16PtrFromString(s) - if err != nil { - return "", err - } - - err = regLoadMUIString(syscall.Handle(k), pname, &buf[0], uint32(len(buf)), &buflen, 0, pdir) - } - - for err == syscall.ERROR_MORE_DATA { // Grow buffer if needed - if buflen <= uint32(len(buf)) { - break // Buffer not growing, assume race; break - } - buf = make([]uint16, buflen) - err = regLoadMUIString(syscall.Handle(k), pname, &buf[0], uint32(len(buf)), &buflen, 0, pdir) - } - - if err != nil { - return "", err - } - - return syscall.UTF16ToString(buf), nil -} - -// ExpandString expands environment-variable strings and replaces -// them with the values defined for the current user. -// Use ExpandString to expand EXPAND_SZ strings. -func ExpandString(value string) (string, error) { - if value == "" { - return "", nil - } - p, err := syscall.UTF16PtrFromString(value) - if err != nil { - return "", err - } - r := make([]uint16, 100) - for { - n, err := expandEnvironmentStrings(p, &r[0], uint32(len(r))) - if err != nil { - return "", err - } - if n <= uint32(len(r)) { - u := (*[1 << 29]uint16)(unsafe.Pointer(&r[0]))[:] - return syscall.UTF16ToString(u), nil - } - r = make([]uint16, n) - } -} - -// GetStringsValue retrieves the []string value for the specified -// value name associated with an open key k. It also returns the value's type. -// If value does not exist, GetStringsValue returns ErrNotExist. -// If value is not MULTI_SZ, it will return the correct value -// type and ErrUnexpectedType. -func (k Key) GetStringsValue(name string) (val []string, valtype uint32, err error) { - data, typ, err2 := k.getValue(name, make([]byte, 64)) - if err2 != nil { - return nil, typ, err2 - } - if typ != MULTI_SZ { - return nil, typ, ErrUnexpectedType - } - if len(data) == 0 { - return nil, typ, nil - } - p := (*[1 << 29]uint16)(unsafe.Pointer(&data[0]))[:len(data)/2] - if len(p) == 0 { - return nil, typ, nil - } - if p[len(p)-1] == 0 { - p = p[:len(p)-1] // remove terminating null - } - val = make([]string, 0, 5) - from := 0 - for i, c := range p { - if c == 0 { - val = append(val, string(utf16.Decode(p[from:i]))) - from = i + 1 - } - } - return val, typ, nil -} - -// GetIntegerValue retrieves the integer value for the specified -// value name associated with an open key k. It also returns the value's type. -// If value does not exist, GetIntegerValue returns ErrNotExist. -// If value is not DWORD or QWORD, it will return the correct value -// type and ErrUnexpectedType. -func (k Key) GetIntegerValue(name string) (val uint64, valtype uint32, err error) { - data, typ, err2 := k.getValue(name, make([]byte, 8)) - if err2 != nil { - return 0, typ, err2 - } - switch typ { - case DWORD: - if len(data) != 4 { - return 0, typ, errors.New("DWORD value is not 4 bytes long") - } - return uint64(*(*uint32)(unsafe.Pointer(&data[0]))), DWORD, nil - case QWORD: - if len(data) != 8 { - return 0, typ, errors.New("QWORD value is not 8 bytes long") - } - return uint64(*(*uint64)(unsafe.Pointer(&data[0]))), QWORD, nil - default: - return 0, typ, ErrUnexpectedType - } -} - -// GetBinaryValue retrieves the binary value for the specified -// value name associated with an open key k. It also returns the value's type. -// If value does not exist, GetBinaryValue returns ErrNotExist. -// If value is not BINARY, it will return the correct value -// type and ErrUnexpectedType. -func (k Key) GetBinaryValue(name string) (val []byte, valtype uint32, err error) { - data, typ, err2 := k.getValue(name, make([]byte, 64)) - if err2 != nil { - return nil, typ, err2 - } - if typ != BINARY { - return nil, typ, ErrUnexpectedType - } - return data, typ, nil -} - -func (k Key) setValue(name string, valtype uint32, data []byte) error { - p, err := syscall.UTF16PtrFromString(name) - if err != nil { - return err - } - if len(data) == 0 { - return regSetValueEx(syscall.Handle(k), p, 0, valtype, nil, 0) - } - return regSetValueEx(syscall.Handle(k), p, 0, valtype, &data[0], uint32(len(data))) -} - -// SetDWordValue sets the data and type of a name value -// under key k to value and DWORD. -func (k Key) SetDWordValue(name string, value uint32) error { - return k.setValue(name, DWORD, (*[4]byte)(unsafe.Pointer(&value))[:]) -} - -// SetQWordValue sets the data and type of a name value -// under key k to value and QWORD. -func (k Key) SetQWordValue(name string, value uint64) error { - return k.setValue(name, QWORD, (*[8]byte)(unsafe.Pointer(&value))[:]) -} - -func (k Key) setStringValue(name string, valtype uint32, value string) error { - v, err := syscall.UTF16FromString(value) - if err != nil { - return err - } - buf := (*[1 << 29]byte)(unsafe.Pointer(&v[0]))[:len(v)*2] - return k.setValue(name, valtype, buf) -} - -// SetStringValue sets the data and type of a name value -// under key k to value and SZ. The value must not contain a zero byte. -func (k Key) SetStringValue(name, value string) error { - return k.setStringValue(name, SZ, value) -} - -// SetExpandStringValue sets the data and type of a name value -// under key k to value and EXPAND_SZ. The value must not contain a zero byte. -func (k Key) SetExpandStringValue(name, value string) error { - return k.setStringValue(name, EXPAND_SZ, value) -} - -// SetStringsValue sets the data and type of a name value -// under key k to value and MULTI_SZ. The value strings -// must not contain a zero byte. -func (k Key) SetStringsValue(name string, value []string) error { - ss := "" - for _, s := range value { - for i := 0; i < len(s); i++ { - if s[i] == 0 { - return errors.New("string cannot have 0 inside") - } - } - ss += s + "\x00" - } - v := utf16.Encode([]rune(ss + "\x00")) - buf := (*[1 << 29]byte)(unsafe.Pointer(&v[0]))[:len(v)*2] - return k.setValue(name, MULTI_SZ, buf) -} - -// SetBinaryValue sets the data and type of a name value -// under key k to value and BINARY. -func (k Key) SetBinaryValue(name string, value []byte) error { - return k.setValue(name, BINARY, value) -} - -// DeleteValue removes a named value from the key k. -func (k Key) DeleteValue(name string) error { - return regDeleteValue(syscall.Handle(k), syscall.StringToUTF16Ptr(name)) -} - -// ReadValueNames returns the value names of key k. -// The parameter n controls the number of returned names, -// analogous to the way os.File.Readdirnames works. -func (k Key) ReadValueNames(n int) ([]string, error) { - ki, err := k.Stat() - if err != nil { - return nil, err - } - names := make([]string, 0, ki.ValueCount) - buf := make([]uint16, ki.MaxValueNameLen+1) // extra room for terminating null character -loopItems: - for i := uint32(0); ; i++ { - if n > 0 { - if len(names) == n { - return names, nil - } - } - l := uint32(len(buf)) - for { - err := regEnumValue(syscall.Handle(k), i, &buf[0], &l, nil, nil, nil, nil) - if err == nil { - break - } - if err == syscall.ERROR_MORE_DATA { - // Double buffer size and try again. - l = uint32(2 * len(buf)) - buf = make([]uint16, l) - continue - } - if err == _ERROR_NO_MORE_ITEMS { - break loopItems - } - return names, err - } - names = append(names, syscall.UTF16ToString(buf[:l])) - } - if n > len(names) { - return names, io.EOF - } - return names, nil -} diff --git a/vendor/golang.org/x/sys/windows/registry/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/registry/zsyscall_windows.go deleted file mode 100644 index ceebdd772..000000000 --- a/vendor/golang.org/x/sys/windows/registry/zsyscall_windows.go +++ /dev/null @@ -1,120 +0,0 @@ -// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT - -package registry - -import ( - "syscall" - "unsafe" - - "golang.org/x/sys/windows" -) - -var _ unsafe.Pointer - -// Do the interface allocations only once for common -// Errno values. -const ( - errnoERROR_IO_PENDING = 997 -) - -var ( - errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) -) - -// errnoErr returns common boxed Errno values, to prevent -// allocations at runtime. -func errnoErr(e syscall.Errno) error { - switch e { - case 0: - return nil - case errnoERROR_IO_PENDING: - return errERROR_IO_PENDING - } - // TODO: add more here, after collecting data on the common - // error values see on Windows. (perhaps when running - // all.bat?) - return e -} - -var ( - modadvapi32 = windows.NewLazySystemDLL("advapi32.dll") - modkernel32 = windows.NewLazySystemDLL("kernel32.dll") - - procRegCreateKeyExW = modadvapi32.NewProc("RegCreateKeyExW") - procRegDeleteKeyW = modadvapi32.NewProc("RegDeleteKeyW") - procRegSetValueExW = modadvapi32.NewProc("RegSetValueExW") - procRegEnumValueW = modadvapi32.NewProc("RegEnumValueW") - procRegDeleteValueW = modadvapi32.NewProc("RegDeleteValueW") - procRegLoadMUIStringW = modadvapi32.NewProc("RegLoadMUIStringW") - procRegConnectRegistryW = modadvapi32.NewProc("RegConnectRegistryW") - procExpandEnvironmentStringsW = modkernel32.NewProc("ExpandEnvironmentStringsW") -) - -func regCreateKeyEx(key syscall.Handle, subkey *uint16, reserved uint32, class *uint16, options uint32, desired uint32, sa *syscall.SecurityAttributes, result *syscall.Handle, disposition *uint32) (regerrno error) { - r0, _, _ := syscall.Syscall9(procRegCreateKeyExW.Addr(), 9, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(reserved), uintptr(unsafe.Pointer(class)), uintptr(options), uintptr(desired), uintptr(unsafe.Pointer(sa)), uintptr(unsafe.Pointer(result)), uintptr(unsafe.Pointer(disposition))) - if r0 != 0 { - regerrno = syscall.Errno(r0) - } - return -} - -func regDeleteKey(key syscall.Handle, subkey *uint16) (regerrno error) { - r0, _, _ := syscall.Syscall(procRegDeleteKeyW.Addr(), 2, uintptr(key), uintptr(unsafe.Pointer(subkey)), 0) - if r0 != 0 { - regerrno = syscall.Errno(r0) - } - return -} - -func regSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype uint32, buf *byte, bufsize uint32) (regerrno error) { - r0, _, _ := syscall.Syscall6(procRegSetValueExW.Addr(), 6, uintptr(key), uintptr(unsafe.Pointer(valueName)), uintptr(reserved), uintptr(vtype), uintptr(unsafe.Pointer(buf)), uintptr(bufsize)) - if r0 != 0 { - regerrno = syscall.Errno(r0) - } - return -} - -func regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) { - r0, _, _ := syscall.Syscall9(procRegEnumValueW.Addr(), 8, uintptr(key), uintptr(index), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(valtype)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(buflen)), 0) - if r0 != 0 { - regerrno = syscall.Errno(r0) - } - return -} - -func regDeleteValue(key syscall.Handle, name *uint16) (regerrno error) { - r0, _, _ := syscall.Syscall(procRegDeleteValueW.Addr(), 2, uintptr(key), uintptr(unsafe.Pointer(name)), 0) - if r0 != 0 { - regerrno = syscall.Errno(r0) - } - return -} - -func regLoadMUIString(key syscall.Handle, name *uint16, buf *uint16, buflen uint32, buflenCopied *uint32, flags uint32, dir *uint16) (regerrno error) { - r0, _, _ := syscall.Syscall9(procRegLoadMUIStringW.Addr(), 7, uintptr(key), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buf)), uintptr(buflen), uintptr(unsafe.Pointer(buflenCopied)), uintptr(flags), uintptr(unsafe.Pointer(dir)), 0, 0) - if r0 != 0 { - regerrno = syscall.Errno(r0) - } - return -} - -func regConnectRegistry(machinename *uint16, key syscall.Handle, result *syscall.Handle) (regerrno error) { - r0, _, _ := syscall.Syscall(procRegConnectRegistryW.Addr(), 3, uintptr(unsafe.Pointer(machinename)), uintptr(key), uintptr(unsafe.Pointer(result))) - if r0 != 0 { - regerrno = syscall.Errno(r0) - } - return -} - -func expandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, err error) { - r0, _, e1 := syscall.Syscall(procExpandEnvironmentStringsW.Addr(), 3, uintptr(unsafe.Pointer(src)), uintptr(unsafe.Pointer(dst)), uintptr(size)) - n = uint32(r0) - if n == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} diff --git a/vendor/golang.org/x/sys/windows/security_windows.go b/vendor/golang.org/x/sys/windows/security_windows.go deleted file mode 100644 index ca09bdd70..000000000 --- a/vendor/golang.org/x/sys/windows/security_windows.go +++ /dev/null @@ -1,435 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package windows - -import ( - "syscall" - "unsafe" -) - -const ( - STANDARD_RIGHTS_REQUIRED = 0xf0000 - STANDARD_RIGHTS_READ = 0x20000 - STANDARD_RIGHTS_WRITE = 0x20000 - STANDARD_RIGHTS_EXECUTE = 0x20000 - STANDARD_RIGHTS_ALL = 0x1F0000 -) - -const ( - NameUnknown = 0 - NameFullyQualifiedDN = 1 - NameSamCompatible = 2 - NameDisplay = 3 - NameUniqueId = 6 - NameCanonical = 7 - NameUserPrincipal = 8 - NameCanonicalEx = 9 - NameServicePrincipal = 10 - NameDnsDomain = 12 -) - -// This function returns 1 byte BOOLEAN rather than the 4 byte BOOL. -// http://blogs.msdn.com/b/drnick/archive/2007/12/19/windows-and-upn-format-credentials.aspx -//sys TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) [failretval&0xff==0] = secur32.TranslateNameW -//sys GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) [failretval&0xff==0] = secur32.GetUserNameExW - -// TranslateAccountName converts a directory service -// object name from one format to another. -func TranslateAccountName(username string, from, to uint32, initSize int) (string, error) { - u, e := UTF16PtrFromString(username) - if e != nil { - return "", e - } - n := uint32(50) - for { - b := make([]uint16, n) - e = TranslateName(u, from, to, &b[0], &n) - if e == nil { - return UTF16ToString(b[:n]), nil - } - if e != ERROR_INSUFFICIENT_BUFFER { - return "", e - } - if n <= uint32(len(b)) { - return "", e - } - } -} - -const ( - // do not reorder - NetSetupUnknownStatus = iota - NetSetupUnjoined - NetSetupWorkgroupName - NetSetupDomainName -) - -type UserInfo10 struct { - Name *uint16 - Comment *uint16 - UsrComment *uint16 - FullName *uint16 -} - -//sys NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) = netapi32.NetUserGetInfo -//sys NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) = netapi32.NetGetJoinInformation -//sys NetApiBufferFree(buf *byte) (neterr error) = netapi32.NetApiBufferFree - -const ( - // do not reorder - SidTypeUser = 1 + iota - SidTypeGroup - SidTypeDomain - SidTypeAlias - SidTypeWellKnownGroup - SidTypeDeletedAccount - SidTypeInvalid - SidTypeUnknown - SidTypeComputer - SidTypeLabel -) - -type SidIdentifierAuthority struct { - Value [6]byte -} - -var ( - SECURITY_NULL_SID_AUTHORITY = SidIdentifierAuthority{[6]byte{0, 0, 0, 0, 0, 0}} - SECURITY_WORLD_SID_AUTHORITY = SidIdentifierAuthority{[6]byte{0, 0, 0, 0, 0, 1}} - SECURITY_LOCAL_SID_AUTHORITY = SidIdentifierAuthority{[6]byte{0, 0, 0, 0, 0, 2}} - SECURITY_CREATOR_SID_AUTHORITY = SidIdentifierAuthority{[6]byte{0, 0, 0, 0, 0, 3}} - SECURITY_NON_UNIQUE_AUTHORITY = SidIdentifierAuthority{[6]byte{0, 0, 0, 0, 0, 4}} - SECURITY_NT_AUTHORITY = SidIdentifierAuthority{[6]byte{0, 0, 0, 0, 0, 5}} - SECURITY_MANDATORY_LABEL_AUTHORITY = SidIdentifierAuthority{[6]byte{0, 0, 0, 0, 0, 16}} -) - -const ( - SECURITY_NULL_RID = 0 - SECURITY_WORLD_RID = 0 - SECURITY_LOCAL_RID = 0 - SECURITY_CREATOR_OWNER_RID = 0 - SECURITY_CREATOR_GROUP_RID = 1 - SECURITY_DIALUP_RID = 1 - SECURITY_NETWORK_RID = 2 - SECURITY_BATCH_RID = 3 - SECURITY_INTERACTIVE_RID = 4 - SECURITY_LOGON_IDS_RID = 5 - SECURITY_SERVICE_RID = 6 - SECURITY_LOCAL_SYSTEM_RID = 18 - SECURITY_BUILTIN_DOMAIN_RID = 32 - SECURITY_PRINCIPAL_SELF_RID = 10 - SECURITY_CREATOR_OWNER_SERVER_RID = 0x2 - SECURITY_CREATOR_GROUP_SERVER_RID = 0x3 - SECURITY_LOGON_IDS_RID_COUNT = 0x3 - SECURITY_ANONYMOUS_LOGON_RID = 0x7 - SECURITY_PROXY_RID = 0x8 - SECURITY_ENTERPRISE_CONTROLLERS_RID = 0x9 - SECURITY_SERVER_LOGON_RID = SECURITY_ENTERPRISE_CONTROLLERS_RID - SECURITY_AUTHENTICATED_USER_RID = 0xb - SECURITY_RESTRICTED_CODE_RID = 0xc - SECURITY_NT_NON_UNIQUE_RID = 0x15 -) - -//sys LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) = advapi32.LookupAccountSidW -//sys LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) = advapi32.LookupAccountNameW -//sys ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) = advapi32.ConvertSidToStringSidW -//sys ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) = advapi32.ConvertStringSidToSidW -//sys GetLengthSid(sid *SID) (len uint32) = advapi32.GetLengthSid -//sys CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) = advapi32.CopySid -//sys AllocateAndInitializeSid(identAuth *SidIdentifierAuthority, subAuth byte, subAuth0 uint32, subAuth1 uint32, subAuth2 uint32, subAuth3 uint32, subAuth4 uint32, subAuth5 uint32, subAuth6 uint32, subAuth7 uint32, sid **SID) (err error) = advapi32.AllocateAndInitializeSid -//sys FreeSid(sid *SID) (err error) [failretval!=0] = advapi32.FreeSid -//sys EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) = advapi32.EqualSid - -// The security identifier (SID) structure is a variable-length -// structure used to uniquely identify users or groups. -type SID struct{} - -// StringToSid converts a string-format security identifier -// sid into a valid, functional sid. -func StringToSid(s string) (*SID, error) { - var sid *SID - p, e := UTF16PtrFromString(s) - if e != nil { - return nil, e - } - e = ConvertStringSidToSid(p, &sid) - if e != nil { - return nil, e - } - defer LocalFree((Handle)(unsafe.Pointer(sid))) - return sid.Copy() -} - -// LookupSID retrieves a security identifier sid for the account -// and the name of the domain on which the account was found. -// System specify target computer to search. -func LookupSID(system, account string) (sid *SID, domain string, accType uint32, err error) { - if len(account) == 0 { - return nil, "", 0, syscall.EINVAL - } - acc, e := UTF16PtrFromString(account) - if e != nil { - return nil, "", 0, e - } - var sys *uint16 - if len(system) > 0 { - sys, e = UTF16PtrFromString(system) - if e != nil { - return nil, "", 0, e - } - } - n := uint32(50) - dn := uint32(50) - for { - b := make([]byte, n) - db := make([]uint16, dn) - sid = (*SID)(unsafe.Pointer(&b[0])) - e = LookupAccountName(sys, acc, sid, &n, &db[0], &dn, &accType) - if e == nil { - return sid, UTF16ToString(db), accType, nil - } - if e != ERROR_INSUFFICIENT_BUFFER { - return nil, "", 0, e - } - if n <= uint32(len(b)) { - return nil, "", 0, e - } - } -} - -// String converts sid to a string format -// suitable for display, storage, or transmission. -func (sid *SID) String() (string, error) { - var s *uint16 - e := ConvertSidToStringSid(sid, &s) - if e != nil { - return "", e - } - defer LocalFree((Handle)(unsafe.Pointer(s))) - return UTF16ToString((*[256]uint16)(unsafe.Pointer(s))[:]), nil -} - -// Len returns the length, in bytes, of a valid security identifier sid. -func (sid *SID) Len() int { - return int(GetLengthSid(sid)) -} - -// Copy creates a duplicate of security identifier sid. -func (sid *SID) Copy() (*SID, error) { - b := make([]byte, sid.Len()) - sid2 := (*SID)(unsafe.Pointer(&b[0])) - e := CopySid(uint32(len(b)), sid2, sid) - if e != nil { - return nil, e - } - return sid2, nil -} - -// LookupAccount retrieves the name of the account for this sid -// and the name of the first domain on which this sid is found. -// System specify target computer to search for. -func (sid *SID) LookupAccount(system string) (account, domain string, accType uint32, err error) { - var sys *uint16 - if len(system) > 0 { - sys, err = UTF16PtrFromString(system) - if err != nil { - return "", "", 0, err - } - } - n := uint32(50) - dn := uint32(50) - for { - b := make([]uint16, n) - db := make([]uint16, dn) - e := LookupAccountSid(sys, sid, &b[0], &n, &db[0], &dn, &accType) - if e == nil { - return UTF16ToString(b), UTF16ToString(db), accType, nil - } - if e != ERROR_INSUFFICIENT_BUFFER { - return "", "", 0, e - } - if n <= uint32(len(b)) { - return "", "", 0, e - } - } -} - -const ( - // do not reorder - TOKEN_ASSIGN_PRIMARY = 1 << iota - TOKEN_DUPLICATE - TOKEN_IMPERSONATE - TOKEN_QUERY - TOKEN_QUERY_SOURCE - TOKEN_ADJUST_PRIVILEGES - TOKEN_ADJUST_GROUPS - TOKEN_ADJUST_DEFAULT - - TOKEN_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | - TOKEN_ASSIGN_PRIMARY | - TOKEN_DUPLICATE | - TOKEN_IMPERSONATE | - TOKEN_QUERY | - TOKEN_QUERY_SOURCE | - TOKEN_ADJUST_PRIVILEGES | - TOKEN_ADJUST_GROUPS | - TOKEN_ADJUST_DEFAULT - TOKEN_READ = STANDARD_RIGHTS_READ | TOKEN_QUERY - TOKEN_WRITE = STANDARD_RIGHTS_WRITE | - TOKEN_ADJUST_PRIVILEGES | - TOKEN_ADJUST_GROUPS | - TOKEN_ADJUST_DEFAULT - TOKEN_EXECUTE = STANDARD_RIGHTS_EXECUTE -) - -const ( - // do not reorder - TokenUser = 1 + iota - TokenGroups - TokenPrivileges - TokenOwner - TokenPrimaryGroup - TokenDefaultDacl - TokenSource - TokenType - TokenImpersonationLevel - TokenStatistics - TokenRestrictedSids - TokenSessionId - TokenGroupsAndPrivileges - TokenSessionReference - TokenSandBoxInert - TokenAuditPolicy - TokenOrigin - TokenElevationType - TokenLinkedToken - TokenElevation - TokenHasRestrictions - TokenAccessInformation - TokenVirtualizationAllowed - TokenVirtualizationEnabled - TokenIntegrityLevel - TokenUIAccess - TokenMandatoryPolicy - TokenLogonSid - MaxTokenInfoClass -) - -type SIDAndAttributes struct { - Sid *SID - Attributes uint32 -} - -type Tokenuser struct { - User SIDAndAttributes -} - -type Tokenprimarygroup struct { - PrimaryGroup *SID -} - -type Tokengroups struct { - GroupCount uint32 - Groups [1]SIDAndAttributes -} - -//sys OpenProcessToken(h Handle, access uint32, token *Token) (err error) = advapi32.OpenProcessToken -//sys GetTokenInformation(t Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) = advapi32.GetTokenInformation -//sys GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) = userenv.GetUserProfileDirectoryW - -// An access token contains the security information for a logon session. -// The system creates an access token when a user logs on, and every -// process executed on behalf of the user has a copy of the token. -// The token identifies the user, the user's groups, and the user's -// privileges. The system uses the token to control access to securable -// objects and to control the ability of the user to perform various -// system-related operations on the local computer. -type Token Handle - -// OpenCurrentProcessToken opens the access token -// associated with current process. -func OpenCurrentProcessToken() (Token, error) { - p, e := GetCurrentProcess() - if e != nil { - return 0, e - } - var t Token - e = OpenProcessToken(p, TOKEN_QUERY, &t) - if e != nil { - return 0, e - } - return t, nil -} - -// Close releases access to access token. -func (t Token) Close() error { - return CloseHandle(Handle(t)) -} - -// getInfo retrieves a specified type of information about an access token. -func (t Token) getInfo(class uint32, initSize int) (unsafe.Pointer, error) { - n := uint32(initSize) - for { - b := make([]byte, n) - e := GetTokenInformation(t, class, &b[0], uint32(len(b)), &n) - if e == nil { - return unsafe.Pointer(&b[0]), nil - } - if e != ERROR_INSUFFICIENT_BUFFER { - return nil, e - } - if n <= uint32(len(b)) { - return nil, e - } - } -} - -// GetTokenUser retrieves access token t user account information. -func (t Token) GetTokenUser() (*Tokenuser, error) { - i, e := t.getInfo(TokenUser, 50) - if e != nil { - return nil, e - } - return (*Tokenuser)(i), nil -} - -// GetTokenGroups retrieves group accounts associated with access token t. -func (t Token) GetTokenGroups() (*Tokengroups, error) { - i, e := t.getInfo(TokenGroups, 50) - if e != nil { - return nil, e - } - return (*Tokengroups)(i), nil -} - -// GetTokenPrimaryGroup retrieves access token t primary group information. -// A pointer to a SID structure representing a group that will become -// the primary group of any objects created by a process using this access token. -func (t Token) GetTokenPrimaryGroup() (*Tokenprimarygroup, error) { - i, e := t.getInfo(TokenPrimaryGroup, 50) - if e != nil { - return nil, e - } - return (*Tokenprimarygroup)(i), nil -} - -// GetUserProfileDirectory retrieves path to the -// root directory of the access token t user's profile. -func (t Token) GetUserProfileDirectory() (string, error) { - n := uint32(100) - for { - b := make([]uint16, n) - e := GetUserProfileDirectory(t, &b[0], &n) - if e == nil { - return UTF16ToString(b), nil - } - if e != ERROR_INSUFFICIENT_BUFFER { - return "", e - } - if n <= uint32(len(b)) { - return "", e - } - } -} diff --git a/vendor/golang.org/x/sys/windows/service.go b/vendor/golang.org/x/sys/windows/service.go deleted file mode 100644 index 1c11d392f..000000000 --- a/vendor/golang.org/x/sys/windows/service.go +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package windows - -const ( - SC_MANAGER_CONNECT = 1 - SC_MANAGER_CREATE_SERVICE = 2 - SC_MANAGER_ENUMERATE_SERVICE = 4 - SC_MANAGER_LOCK = 8 - SC_MANAGER_QUERY_LOCK_STATUS = 16 - SC_MANAGER_MODIFY_BOOT_CONFIG = 32 - SC_MANAGER_ALL_ACCESS = 0xf003f -) - -//sys OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) [failretval==0] = advapi32.OpenSCManagerW - -const ( - SERVICE_KERNEL_DRIVER = 1 - SERVICE_FILE_SYSTEM_DRIVER = 2 - SERVICE_ADAPTER = 4 - SERVICE_RECOGNIZER_DRIVER = 8 - SERVICE_WIN32_OWN_PROCESS = 16 - SERVICE_WIN32_SHARE_PROCESS = 32 - SERVICE_WIN32 = SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS - SERVICE_INTERACTIVE_PROCESS = 256 - SERVICE_DRIVER = SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | SERVICE_RECOGNIZER_DRIVER - SERVICE_TYPE_ALL = SERVICE_WIN32 | SERVICE_ADAPTER | SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS - - SERVICE_BOOT_START = 0 - SERVICE_SYSTEM_START = 1 - SERVICE_AUTO_START = 2 - SERVICE_DEMAND_START = 3 - SERVICE_DISABLED = 4 - - SERVICE_ERROR_IGNORE = 0 - SERVICE_ERROR_NORMAL = 1 - SERVICE_ERROR_SEVERE = 2 - SERVICE_ERROR_CRITICAL = 3 - - SC_STATUS_PROCESS_INFO = 0 - - SERVICE_STOPPED = 1 - SERVICE_START_PENDING = 2 - SERVICE_STOP_PENDING = 3 - SERVICE_RUNNING = 4 - SERVICE_CONTINUE_PENDING = 5 - SERVICE_PAUSE_PENDING = 6 - SERVICE_PAUSED = 7 - SERVICE_NO_CHANGE = 0xffffffff - - SERVICE_ACCEPT_STOP = 1 - SERVICE_ACCEPT_PAUSE_CONTINUE = 2 - SERVICE_ACCEPT_SHUTDOWN = 4 - SERVICE_ACCEPT_PARAMCHANGE = 8 - SERVICE_ACCEPT_NETBINDCHANGE = 16 - SERVICE_ACCEPT_HARDWAREPROFILECHANGE = 32 - SERVICE_ACCEPT_POWEREVENT = 64 - SERVICE_ACCEPT_SESSIONCHANGE = 128 - - SERVICE_CONTROL_STOP = 1 - SERVICE_CONTROL_PAUSE = 2 - SERVICE_CONTROL_CONTINUE = 3 - SERVICE_CONTROL_INTERROGATE = 4 - SERVICE_CONTROL_SHUTDOWN = 5 - SERVICE_CONTROL_PARAMCHANGE = 6 - SERVICE_CONTROL_NETBINDADD = 7 - SERVICE_CONTROL_NETBINDREMOVE = 8 - SERVICE_CONTROL_NETBINDENABLE = 9 - SERVICE_CONTROL_NETBINDDISABLE = 10 - SERVICE_CONTROL_DEVICEEVENT = 11 - SERVICE_CONTROL_HARDWAREPROFILECHANGE = 12 - SERVICE_CONTROL_POWEREVENT = 13 - SERVICE_CONTROL_SESSIONCHANGE = 14 - - SERVICE_ACTIVE = 1 - SERVICE_INACTIVE = 2 - SERVICE_STATE_ALL = 3 - - SERVICE_QUERY_CONFIG = 1 - SERVICE_CHANGE_CONFIG = 2 - SERVICE_QUERY_STATUS = 4 - SERVICE_ENUMERATE_DEPENDENTS = 8 - SERVICE_START = 16 - SERVICE_STOP = 32 - SERVICE_PAUSE_CONTINUE = 64 - SERVICE_INTERROGATE = 128 - SERVICE_USER_DEFINED_CONTROL = 256 - SERVICE_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SERVICE_QUERY_CONFIG | SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_START | SERVICE_STOP | SERVICE_PAUSE_CONTINUE | SERVICE_INTERROGATE | SERVICE_USER_DEFINED_CONTROL - SERVICE_RUNS_IN_SYSTEM_PROCESS = 1 - SERVICE_CONFIG_DESCRIPTION = 1 - SERVICE_CONFIG_FAILURE_ACTIONS = 2 - - NO_ERROR = 0 -) - -type SERVICE_STATUS struct { - ServiceType uint32 - CurrentState uint32 - ControlsAccepted uint32 - Win32ExitCode uint32 - ServiceSpecificExitCode uint32 - CheckPoint uint32 - WaitHint uint32 -} - -type SERVICE_TABLE_ENTRY struct { - ServiceName *uint16 - ServiceProc uintptr -} - -type QUERY_SERVICE_CONFIG struct { - ServiceType uint32 - StartType uint32 - ErrorControl uint32 - BinaryPathName *uint16 - LoadOrderGroup *uint16 - TagId uint32 - Dependencies *uint16 - ServiceStartName *uint16 - DisplayName *uint16 -} - -type SERVICE_DESCRIPTION struct { - Description *uint16 -} - -//sys CloseServiceHandle(handle Handle) (err error) = advapi32.CloseServiceHandle -//sys CreateService(mgr Handle, serviceName *uint16, displayName *uint16, access uint32, srvType uint32, startType uint32, errCtl uint32, pathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16) (handle Handle, err error) [failretval==0] = advapi32.CreateServiceW -//sys OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) [failretval==0] = advapi32.OpenServiceW -//sys DeleteService(service Handle) (err error) = advapi32.DeleteService -//sys StartService(service Handle, numArgs uint32, argVectors **uint16) (err error) = advapi32.StartServiceW -//sys QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) = advapi32.QueryServiceStatus -//sys ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err error) = advapi32.ControlService -//sys StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) = advapi32.StartServiceCtrlDispatcherW -//sys SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error) = advapi32.SetServiceStatus -//sys ChangeServiceConfig(service Handle, serviceType uint32, startType uint32, errorControl uint32, binaryPathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16, displayName *uint16) (err error) = advapi32.ChangeServiceConfigW -//sys QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceConfigW -//sys ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) = advapi32.ChangeServiceConfig2W -//sys QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceConfig2W diff --git a/vendor/golang.org/x/sys/windows/str.go b/vendor/golang.org/x/sys/windows/str.go deleted file mode 100644 index 917cc2aae..000000000 --- a/vendor/golang.org/x/sys/windows/str.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package windows - -func itoa(val int) string { // do it here rather than with fmt to avoid dependency - if val < 0 { - return "-" + itoa(-val) - } - var buf [32]byte // big enough for int64 - i := len(buf) - 1 - for val >= 10 { - buf[i] = byte(val%10 + '0') - i-- - val /= 10 - } - buf[i] = byte(val + '0') - return string(buf[i:]) -} diff --git a/vendor/golang.org/x/sys/windows/svc/debug/log.go b/vendor/golang.org/x/sys/windows/svc/debug/log.go deleted file mode 100644 index e51ab42a1..000000000 --- a/vendor/golang.org/x/sys/windows/svc/debug/log.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package debug - -import ( - "os" - "strconv" -) - -// Log interface allows different log implementations to be used. -type Log interface { - Close() error - Info(eid uint32, msg string) error - Warning(eid uint32, msg string) error - Error(eid uint32, msg string) error -} - -// ConsoleLog provides access to the console. -type ConsoleLog struct { - Name string -} - -// New creates new ConsoleLog. -func New(source string) *ConsoleLog { - return &ConsoleLog{Name: source} -} - -// Close closes console log l. -func (l *ConsoleLog) Close() error { - return nil -} - -func (l *ConsoleLog) report(kind string, eid uint32, msg string) error { - s := l.Name + "." + kind + "(" + strconv.Itoa(int(eid)) + "): " + msg + "\n" - _, err := os.Stdout.Write([]byte(s)) - return err -} - -// Info writes an information event msg with event id eid to the console l. -func (l *ConsoleLog) Info(eid uint32, msg string) error { - return l.report("info", eid, msg) -} - -// Warning writes an warning event msg with event id eid to the console l. -func (l *ConsoleLog) Warning(eid uint32, msg string) error { - return l.report("warn", eid, msg) -} - -// Error writes an error event msg with event id eid to the console l. -func (l *ConsoleLog) Error(eid uint32, msg string) error { - return l.report("error", eid, msg) -} diff --git a/vendor/golang.org/x/sys/windows/svc/debug/service.go b/vendor/golang.org/x/sys/windows/svc/debug/service.go deleted file mode 100644 index d5ab94b2c..000000000 --- a/vendor/golang.org/x/sys/windows/svc/debug/service.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -// Package debug provides facilities to execute svc.Handler on console. -// -package debug - -import ( - "os" - "os/signal" - "syscall" - - "golang.org/x/sys/windows/svc" -) - -// Run executes service name by calling appropriate handler function. -// The process is running on console, unlike real service. Use Ctrl+C to -// send "Stop" command to your service. -func Run(name string, handler svc.Handler) error { - cmds := make(chan svc.ChangeRequest) - changes := make(chan svc.Status) - - sig := make(chan os.Signal) - signal.Notify(sig) - - go func() { - status := svc.Status{State: svc.Stopped} - for { - select { - case <-sig: - cmds <- svc.ChangeRequest{svc.Stop, status} - case status = <-changes: - } - } - }() - - _, errno := handler.Execute([]string{name}, cmds, changes) - if errno != 0 { - return syscall.Errno(errno) - } - return nil -} diff --git a/vendor/golang.org/x/sys/windows/svc/event.go b/vendor/golang.org/x/sys/windows/svc/event.go deleted file mode 100644 index 0508e2288..000000000 --- a/vendor/golang.org/x/sys/windows/svc/event.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package svc - -import ( - "errors" - - "golang.org/x/sys/windows" -) - -// event represents auto-reset, initially non-signaled Windows event. -// It is used to communicate between go and asm parts of this package. -type event struct { - h windows.Handle -} - -func newEvent() (*event, error) { - h, err := windows.CreateEvent(nil, 0, 0, nil) - if err != nil { - return nil, err - } - return &event{h: h}, nil -} - -func (e *event) Close() error { - return windows.CloseHandle(e.h) -} - -func (e *event) Set() error { - return windows.SetEvent(e.h) -} - -func (e *event) Wait() error { - s, err := windows.WaitForSingleObject(e.h, windows.INFINITE) - switch s { - case windows.WAIT_OBJECT_0: - break - case windows.WAIT_FAILED: - return err - default: - return errors.New("unexpected result from WaitForSingleObject") - } - return nil -} diff --git a/vendor/golang.org/x/sys/windows/svc/eventlog/install.go b/vendor/golang.org/x/sys/windows/svc/eventlog/install.go deleted file mode 100644 index c76a3760a..000000000 --- a/vendor/golang.org/x/sys/windows/svc/eventlog/install.go +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package eventlog - -import ( - "errors" - - "golang.org/x/sys/windows" - "golang.org/x/sys/windows/registry" -) - -const ( - // Log levels. - Info = windows.EVENTLOG_INFORMATION_TYPE - Warning = windows.EVENTLOG_WARNING_TYPE - Error = windows.EVENTLOG_ERROR_TYPE -) - -const addKeyName = `SYSTEM\CurrentControlSet\Services\EventLog\Application` - -// Install modifies PC registry to allow logging with an event source src. -// It adds all required keys and values to the event log registry key. -// Install uses msgFile as the event message file. If useExpandKey is true, -// the event message file is installed as REG_EXPAND_SZ value, -// otherwise as REG_SZ. Use bitwise of log.Error, log.Warning and -// log.Info to specify events supported by the new event source. -func Install(src, msgFile string, useExpandKey bool, eventsSupported uint32) error { - appkey, err := registry.OpenKey(registry.LOCAL_MACHINE, addKeyName, registry.CREATE_SUB_KEY) - if err != nil { - return err - } - defer appkey.Close() - - sk, alreadyExist, err := registry.CreateKey(appkey, src, registry.SET_VALUE) - if err != nil { - return err - } - defer sk.Close() - if alreadyExist { - return errors.New(addKeyName + `\` + src + " registry key already exists") - } - - err = sk.SetDWordValue("CustomSource", 1) - if err != nil { - return err - } - if useExpandKey { - err = sk.SetExpandStringValue("EventMessageFile", msgFile) - } else { - err = sk.SetStringValue("EventMessageFile", msgFile) - } - if err != nil { - return err - } - err = sk.SetDWordValue("TypesSupported", eventsSupported) - if err != nil { - return err - } - return nil -} - -// InstallAsEventCreate is the same as Install, but uses -// %SystemRoot%\System32\EventCreate.exe as the event message file. -func InstallAsEventCreate(src string, eventsSupported uint32) error { - return Install(src, "%SystemRoot%\\System32\\EventCreate.exe", true, eventsSupported) -} - -// Remove deletes all registry elements installed by the correspondent Install. -func Remove(src string) error { - appkey, err := registry.OpenKey(registry.LOCAL_MACHINE, addKeyName, registry.SET_VALUE) - if err != nil { - return err - } - defer appkey.Close() - return registry.DeleteKey(appkey, src) -} diff --git a/vendor/golang.org/x/sys/windows/svc/eventlog/log.go b/vendor/golang.org/x/sys/windows/svc/eventlog/log.go deleted file mode 100644 index 46e5153d0..000000000 --- a/vendor/golang.org/x/sys/windows/svc/eventlog/log.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -// Package eventlog implements access to Windows event log. -// -package eventlog - -import ( - "errors" - "syscall" - - "golang.org/x/sys/windows" -) - -// Log provides access to the system log. -type Log struct { - Handle windows.Handle -} - -// Open retrieves a handle to the specified event log. -func Open(source string) (*Log, error) { - return OpenRemote("", source) -} - -// OpenRemote does the same as Open, but on different computer host. -func OpenRemote(host, source string) (*Log, error) { - if source == "" { - return nil, errors.New("Specify event log source") - } - var s *uint16 - if host != "" { - s = syscall.StringToUTF16Ptr(host) - } - h, err := windows.RegisterEventSource(s, syscall.StringToUTF16Ptr(source)) - if err != nil { - return nil, err - } - return &Log{Handle: h}, nil -} - -// Close closes event log l. -func (l *Log) Close() error { - return windows.DeregisterEventSource(l.Handle) -} - -func (l *Log) report(etype uint16, eid uint32, msg string) error { - ss := []*uint16{syscall.StringToUTF16Ptr(msg)} - return windows.ReportEvent(l.Handle, etype, 0, eid, 0, 1, 0, &ss[0], nil) -} - -// Info writes an information event msg with event id eid to the end of event log l. -// When EventCreate.exe is used, eid must be between 1 and 1000. -func (l *Log) Info(eid uint32, msg string) error { - return l.report(windows.EVENTLOG_INFORMATION_TYPE, eid, msg) -} - -// Warning writes an warning event msg with event id eid to the end of event log l. -// When EventCreate.exe is used, eid must be between 1 and 1000. -func (l *Log) Warning(eid uint32, msg string) error { - return l.report(windows.EVENTLOG_WARNING_TYPE, eid, msg) -} - -// Error writes an error event msg with event id eid to the end of event log l. -// When EventCreate.exe is used, eid must be between 1 and 1000. -func (l *Log) Error(eid uint32, msg string) error { - return l.report(windows.EVENTLOG_ERROR_TYPE, eid, msg) -} diff --git a/vendor/golang.org/x/sys/windows/svc/eventlog/log_test.go b/vendor/golang.org/x/sys/windows/svc/eventlog/log_test.go deleted file mode 100644 index 4dd8ad9e7..000000000 --- a/vendor/golang.org/x/sys/windows/svc/eventlog/log_test.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package eventlog_test - -import ( - "testing" - - "golang.org/x/sys/windows/svc/eventlog" -) - -func TestLog(t *testing.T) { - if testing.Short() { - t.Skip("skipping test in short mode - it modifies system logs") - } - - const name = "mylog" - const supports = eventlog.Error | eventlog.Warning | eventlog.Info - err := eventlog.InstallAsEventCreate(name, supports) - if err != nil { - t.Fatalf("Install failed: %s", err) - } - defer func() { - err = eventlog.Remove(name) - if err != nil { - t.Fatalf("Remove failed: %s", err) - } - }() - - l, err := eventlog.Open(name) - if err != nil { - t.Fatalf("Open failed: %s", err) - } - defer l.Close() - - err = l.Info(1, "info") - if err != nil { - t.Fatalf("Info failed: %s", err) - } - err = l.Warning(2, "warning") - if err != nil { - t.Fatalf("Warning failed: %s", err) - } - err = l.Error(3, "error") - if err != nil { - t.Fatalf("Error failed: %s", err) - } -} diff --git a/vendor/golang.org/x/sys/windows/svc/example/beep.go b/vendor/golang.org/x/sys/windows/svc/example/beep.go deleted file mode 100644 index dcf23408d..000000000 --- a/vendor/golang.org/x/sys/windows/svc/example/beep.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package main - -import ( - "syscall" -) - -// BUG(brainman): MessageBeep Windows api is broken on Windows 7, -// so this example does not beep when runs as service on Windows 7. - -var ( - beepFunc = syscall.MustLoadDLL("user32.dll").MustFindProc("MessageBeep") -) - -func beep() { - beepFunc.Call(0xffffffff) -} diff --git a/vendor/golang.org/x/sys/windows/svc/example/install.go b/vendor/golang.org/x/sys/windows/svc/example/install.go deleted file mode 100644 index 39cb00d2a..000000000 --- a/vendor/golang.org/x/sys/windows/svc/example/install.go +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package main - -import ( - "fmt" - "os" - "path/filepath" - - "golang.org/x/sys/windows/svc/eventlog" - "golang.org/x/sys/windows/svc/mgr" -) - -func exePath() (string, error) { - prog := os.Args[0] - p, err := filepath.Abs(prog) - if err != nil { - return "", err - } - fi, err := os.Stat(p) - if err == nil { - if !fi.Mode().IsDir() { - return p, nil - } - err = fmt.Errorf("%s is directory", p) - } - if filepath.Ext(p) == "" { - p += ".exe" - fi, err := os.Stat(p) - if err == nil { - if !fi.Mode().IsDir() { - return p, nil - } - err = fmt.Errorf("%s is directory", p) - } - } - return "", err -} - -func installService(name, desc string) error { - exepath, err := exePath() - if err != nil { - return err - } - m, err := mgr.Connect() - if err != nil { - return err - } - defer m.Disconnect() - s, err := m.OpenService(name) - if err == nil { - s.Close() - return fmt.Errorf("service %s already exists", name) - } - s, err = m.CreateService(name, exepath, mgr.Config{DisplayName: desc}, "is", "auto-started") - if err != nil { - return err - } - defer s.Close() - err = eventlog.InstallAsEventCreate(name, eventlog.Error|eventlog.Warning|eventlog.Info) - if err != nil { - s.Delete() - return fmt.Errorf("SetupEventLogSource() failed: %s", err) - } - return nil -} - -func removeService(name string) error { - m, err := mgr.Connect() - if err != nil { - return err - } - defer m.Disconnect() - s, err := m.OpenService(name) - if err != nil { - return fmt.Errorf("service %s is not installed", name) - } - defer s.Close() - err = s.Delete() - if err != nil { - return err - } - err = eventlog.Remove(name) - if err != nil { - return fmt.Errorf("RemoveEventLogSource() failed: %s", err) - } - return nil -} diff --git a/vendor/golang.org/x/sys/windows/svc/example/main.go b/vendor/golang.org/x/sys/windows/svc/example/main.go deleted file mode 100644 index dc96c081a..000000000 --- a/vendor/golang.org/x/sys/windows/svc/example/main.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -// Example service program that beeps. -// -// The program demonstrates how to create Windows service and -// install / remove it on a computer. It also shows how to -// stop / start / pause / continue any service, and how to -// write to event log. It also shows how to use debug -// facilities available in debug package. -// -package main - -import ( - "fmt" - "log" - "os" - "strings" - - "golang.org/x/sys/windows/svc" -) - -func usage(errmsg string) { - fmt.Fprintf(os.Stderr, - "%s\n\n"+ - "usage: %s \n"+ - " where is one of\n"+ - " install, remove, debug, start, stop, pause or continue.\n", - errmsg, os.Args[0]) - os.Exit(2) -} - -func main() { - const svcName = "myservice" - - isIntSess, err := svc.IsAnInteractiveSession() - if err != nil { - log.Fatalf("failed to determine if we are running in an interactive session: %v", err) - } - if !isIntSess { - runService(svcName, false) - return - } - - if len(os.Args) < 2 { - usage("no command specified") - } - - cmd := strings.ToLower(os.Args[1]) - switch cmd { - case "debug": - runService(svcName, true) - return - case "install": - err = installService(svcName, "my service") - case "remove": - err = removeService(svcName) - case "start": - err = startService(svcName) - case "stop": - err = controlService(svcName, svc.Stop, svc.Stopped) - case "pause": - err = controlService(svcName, svc.Pause, svc.Paused) - case "continue": - err = controlService(svcName, svc.Continue, svc.Running) - default: - usage(fmt.Sprintf("invalid command %s", cmd)) - } - if err != nil { - log.Fatalf("failed to %s %s: %v", cmd, svcName, err) - } - return -} diff --git a/vendor/golang.org/x/sys/windows/svc/example/manage.go b/vendor/golang.org/x/sys/windows/svc/example/manage.go deleted file mode 100644 index 782dbd96c..000000000 --- a/vendor/golang.org/x/sys/windows/svc/example/manage.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package main - -import ( - "fmt" - "time" - - "golang.org/x/sys/windows/svc" - "golang.org/x/sys/windows/svc/mgr" -) - -func startService(name string) error { - m, err := mgr.Connect() - if err != nil { - return err - } - defer m.Disconnect() - s, err := m.OpenService(name) - if err != nil { - return fmt.Errorf("could not access service: %v", err) - } - defer s.Close() - err = s.Start("is", "manual-started") - if err != nil { - return fmt.Errorf("could not start service: %v", err) - } - return nil -} - -func controlService(name string, c svc.Cmd, to svc.State) error { - m, err := mgr.Connect() - if err != nil { - return err - } - defer m.Disconnect() - s, err := m.OpenService(name) - if err != nil { - return fmt.Errorf("could not access service: %v", err) - } - defer s.Close() - status, err := s.Control(c) - if err != nil { - return fmt.Errorf("could not send control=%d: %v", c, err) - } - timeout := time.Now().Add(10 * time.Second) - for status.State != to { - if timeout.Before(time.Now()) { - return fmt.Errorf("timeout waiting for service to go to state=%d", to) - } - time.Sleep(300 * time.Millisecond) - status, err = s.Query() - if err != nil { - return fmt.Errorf("could not retrieve service status: %v", err) - } - } - return nil -} diff --git a/vendor/golang.org/x/sys/windows/svc/example/service.go b/vendor/golang.org/x/sys/windows/svc/example/service.go deleted file mode 100644 index 237e80984..000000000 --- a/vendor/golang.org/x/sys/windows/svc/example/service.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package main - -import ( - "fmt" - "time" - - "golang.org/x/sys/windows/svc" - "golang.org/x/sys/windows/svc/debug" - "golang.org/x/sys/windows/svc/eventlog" -) - -var elog debug.Log - -type myservice struct{} - -func (m *myservice) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (ssec bool, errno uint32) { - const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown | svc.AcceptPauseAndContinue - changes <- svc.Status{State: svc.StartPending} - fasttick := time.Tick(500 * time.Millisecond) - slowtick := time.Tick(2 * time.Second) - tick := fasttick - changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted} -loop: - for { - select { - case <-tick: - beep() - elog.Info(1, "beep") - case c := <-r: - switch c.Cmd { - case svc.Interrogate: - changes <- c.CurrentStatus - // Testing deadlock from https://code.google.com/p/winsvc/issues/detail?id=4 - time.Sleep(100 * time.Millisecond) - changes <- c.CurrentStatus - case svc.Stop, svc.Shutdown: - break loop - case svc.Pause: - changes <- svc.Status{State: svc.Paused, Accepts: cmdsAccepted} - tick = slowtick - case svc.Continue: - changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted} - tick = fasttick - default: - elog.Error(1, fmt.Sprintf("unexpected control request #%d", c)) - } - } - } - changes <- svc.Status{State: svc.StopPending} - return -} - -func runService(name string, isDebug bool) { - var err error - if isDebug { - elog = debug.New(name) - } else { - elog, err = eventlog.Open(name) - if err != nil { - return - } - } - defer elog.Close() - - elog.Info(1, fmt.Sprintf("starting %s service", name)) - run := svc.Run - if isDebug { - run = debug.Run - } - err = run(name, &myservice{}) - if err != nil { - elog.Error(1, fmt.Sprintf("%s service failed: %v", name, err)) - return - } - elog.Info(1, fmt.Sprintf("%s service stopped", name)) -} diff --git a/vendor/golang.org/x/sys/windows/svc/go12.c b/vendor/golang.org/x/sys/windows/svc/go12.c deleted file mode 100644 index 6f1be1fa3..000000000 --- a/vendor/golang.org/x/sys/windows/svc/go12.c +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows -// +build !go1.3 - -// copied from pkg/runtime -typedef unsigned int uint32; -typedef unsigned long long int uint64; -#ifdef _64BIT -typedef uint64 uintptr; -#else -typedef uint32 uintptr; -#endif - -// from sys_386.s or sys_amd64.s -void ·servicemain(void); - -void -·getServiceMain(uintptr *r) -{ - *r = (uintptr)·servicemain; -} diff --git a/vendor/golang.org/x/sys/windows/svc/go12.go b/vendor/golang.org/x/sys/windows/svc/go12.go deleted file mode 100644 index 6f0a924ea..000000000 --- a/vendor/golang.org/x/sys/windows/svc/go12.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows -// +build !go1.3 - -package svc - -// from go12.c -func getServiceMain(r *uintptr) diff --git a/vendor/golang.org/x/sys/windows/svc/go13.go b/vendor/golang.org/x/sys/windows/svc/go13.go deleted file mode 100644 index 432a9e796..000000000 --- a/vendor/golang.org/x/sys/windows/svc/go13.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows -// +build go1.3 - -package svc - -import "unsafe" - -const ptrSize = 4 << (^uintptr(0) >> 63) // unsafe.Sizeof(uintptr(0)) but an ideal const - -// Should be a built-in for unsafe.Pointer? -func add(p unsafe.Pointer, x uintptr) unsafe.Pointer { - return unsafe.Pointer(uintptr(p) + x) -} - -// funcPC returns the entry PC of the function f. -// It assumes that f is a func value. Otherwise the behavior is undefined. -func funcPC(f interface{}) uintptr { - return **(**uintptr)(add(unsafe.Pointer(&f), ptrSize)) -} - -// from sys_386.s and sys_amd64.s -func servicectlhandler(ctl uint32) uintptr -func servicemain(argc uint32, argv **uint16) - -func getServiceMain(r *uintptr) { - *r = funcPC(servicemain) -} diff --git a/vendor/golang.org/x/sys/windows/svc/mgr/config.go b/vendor/golang.org/x/sys/windows/svc/mgr/config.go deleted file mode 100644 index 0a6edba4f..000000000 --- a/vendor/golang.org/x/sys/windows/svc/mgr/config.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package mgr - -import ( - "syscall" - "unicode/utf16" - "unsafe" - - "golang.org/x/sys/windows" -) - -const ( - // Service start types. - StartManual = windows.SERVICE_DEMAND_START // the service must be started manually - StartAutomatic = windows.SERVICE_AUTO_START // the service will start by itself whenever the computer reboots - StartDisabled = windows.SERVICE_DISABLED // the service cannot be started - - // The severity of the error, and action taken, - // if this service fails to start. - ErrorCritical = windows.SERVICE_ERROR_CRITICAL - ErrorIgnore = windows.SERVICE_ERROR_IGNORE - ErrorNormal = windows.SERVICE_ERROR_NORMAL - ErrorSevere = windows.SERVICE_ERROR_SEVERE -) - -// TODO(brainman): Password is not returned by windows.QueryServiceConfig, not sure how to get it. - -type Config struct { - ServiceType uint32 - StartType uint32 - ErrorControl uint32 - BinaryPathName string // fully qualified path to the service binary file, can also include arguments for an auto-start service - LoadOrderGroup string - TagId uint32 - Dependencies []string - ServiceStartName string // name of the account under which the service should run - DisplayName string - Password string - Description string -} - -func toString(p *uint16) string { - if p == nil { - return "" - } - return syscall.UTF16ToString((*[4096]uint16)(unsafe.Pointer(p))[:]) -} - -func toStringSlice(ps *uint16) []string { - if ps == nil { - return nil - } - r := make([]string, 0) - for from, i, p := 0, 0, (*[1 << 24]uint16)(unsafe.Pointer(ps)); true; i++ { - if p[i] == 0 { - // empty string marks the end - if i <= from { - break - } - r = append(r, string(utf16.Decode(p[from:i]))) - from = i + 1 - } - } - return r -} - -// Config retrieves service s configuration paramteres. -func (s *Service) Config() (Config, error) { - var p *windows.QUERY_SERVICE_CONFIG - n := uint32(1024) - for { - b := make([]byte, n) - p = (*windows.QUERY_SERVICE_CONFIG)(unsafe.Pointer(&b[0])) - err := windows.QueryServiceConfig(s.Handle, p, n, &n) - if err == nil { - break - } - if err.(syscall.Errno) != syscall.ERROR_INSUFFICIENT_BUFFER { - return Config{}, err - } - if n <= uint32(len(b)) { - return Config{}, err - } - } - - var p2 *windows.SERVICE_DESCRIPTION - n = uint32(1024) - for { - b := make([]byte, n) - p2 = (*windows.SERVICE_DESCRIPTION)(unsafe.Pointer(&b[0])) - err := windows.QueryServiceConfig2(s.Handle, - windows.SERVICE_CONFIG_DESCRIPTION, &b[0], n, &n) - if err == nil { - break - } - if err.(syscall.Errno) != syscall.ERROR_INSUFFICIENT_BUFFER { - return Config{}, err - } - if n <= uint32(len(b)) { - return Config{}, err - } - } - - return Config{ - ServiceType: p.ServiceType, - StartType: p.StartType, - ErrorControl: p.ErrorControl, - BinaryPathName: toString(p.BinaryPathName), - LoadOrderGroup: toString(p.LoadOrderGroup), - TagId: p.TagId, - Dependencies: toStringSlice(p.Dependencies), - ServiceStartName: toString(p.ServiceStartName), - DisplayName: toString(p.DisplayName), - Description: toString(p2.Description), - }, nil -} - -func updateDescription(handle windows.Handle, desc string) error { - d := windows.SERVICE_DESCRIPTION{toPtr(desc)} - return windows.ChangeServiceConfig2(handle, - windows.SERVICE_CONFIG_DESCRIPTION, (*byte)(unsafe.Pointer(&d))) -} - -// UpdateConfig updates service s configuration parameters. -func (s *Service) UpdateConfig(c Config) error { - err := windows.ChangeServiceConfig(s.Handle, c.ServiceType, c.StartType, - c.ErrorControl, toPtr(c.BinaryPathName), toPtr(c.LoadOrderGroup), - nil, toStringBlock(c.Dependencies), toPtr(c.ServiceStartName), - toPtr(c.Password), toPtr(c.DisplayName)) - if err != nil { - return err - } - return updateDescription(s.Handle, c.Description) -} diff --git a/vendor/golang.org/x/sys/windows/svc/mgr/mgr.go b/vendor/golang.org/x/sys/windows/svc/mgr/mgr.go deleted file mode 100644 index da8ceb6ed..000000000 --- a/vendor/golang.org/x/sys/windows/svc/mgr/mgr.go +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -// Package mgr can be used to manage Windows service programs. -// It can be used to install and remove them. It can also start, -// stop and pause them. The package can query / change current -// service state and config parameters. -// -package mgr - -import ( - "syscall" - "unicode/utf16" - - "golang.org/x/sys/windows" -) - -// Mgr is used to manage Windows service. -type Mgr struct { - Handle windows.Handle -} - -// Connect establishes a connection to the service control manager. -func Connect() (*Mgr, error) { - return ConnectRemote("") -} - -// ConnectRemote establishes a connection to the -// service control manager on computer named host. -func ConnectRemote(host string) (*Mgr, error) { - var s *uint16 - if host != "" { - s = syscall.StringToUTF16Ptr(host) - } - h, err := windows.OpenSCManager(s, nil, windows.SC_MANAGER_ALL_ACCESS) - if err != nil { - return nil, err - } - return &Mgr{Handle: h}, nil -} - -// Disconnect closes connection to the service control manager m. -func (m *Mgr) Disconnect() error { - return windows.CloseServiceHandle(m.Handle) -} - -func toPtr(s string) *uint16 { - if len(s) == 0 { - return nil - } - return syscall.StringToUTF16Ptr(s) -} - -// toStringBlock terminates strings in ss with 0, and then -// concatenates them together. It also adds extra 0 at the end. -func toStringBlock(ss []string) *uint16 { - if len(ss) == 0 { - return nil - } - t := "" - for _, s := range ss { - if s != "" { - t += s + "\x00" - } - } - if t == "" { - return nil - } - t += "\x00" - return &utf16.Encode([]rune(t))[0] -} - -// CreateService installs new service name on the system. -// The service will be executed by running exepath binary. -// Use config c to specify service parameters. -// If service StartType is set to StartAutomatic, -// args will be passed to svc.Handle.Execute. -func (m *Mgr) CreateService(name, exepath string, c Config, args ...string) (*Service, error) { - if c.StartType == 0 { - c.StartType = StartManual - } - if c.ErrorControl == 0 { - c.ErrorControl = ErrorNormal - } - if c.ServiceType == 0 { - c.ServiceType = windows.SERVICE_WIN32_OWN_PROCESS - } - s := syscall.EscapeArg(exepath) - for _, v := range args { - s += " " + syscall.EscapeArg(v) - } - h, err := windows.CreateService(m.Handle, toPtr(name), toPtr(c.DisplayName), - windows.SERVICE_ALL_ACCESS, c.ServiceType, - c.StartType, c.ErrorControl, toPtr(s), toPtr(c.LoadOrderGroup), - nil, toStringBlock(c.Dependencies), toPtr(c.ServiceStartName), toPtr(c.Password)) - if err != nil { - return nil, err - } - if c.Description != "" { - err = updateDescription(h, c.Description) - if err != nil { - return nil, err - } - } - return &Service{Name: name, Handle: h}, nil -} - -// OpenService retrieves access to service name, so it can -// be interrogated and controlled. -func (m *Mgr) OpenService(name string) (*Service, error) { - h, err := windows.OpenService(m.Handle, syscall.StringToUTF16Ptr(name), windows.SERVICE_ALL_ACCESS) - if err != nil { - return nil, err - } - return &Service{Name: name, Handle: h}, nil -} diff --git a/vendor/golang.org/x/sys/windows/svc/mgr/mgr_test.go b/vendor/golang.org/x/sys/windows/svc/mgr/mgr_test.go deleted file mode 100644 index 78be970c0..000000000 --- a/vendor/golang.org/x/sys/windows/svc/mgr/mgr_test.go +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package mgr_test - -import ( - "os" - "path/filepath" - "sort" - "strings" - "syscall" - "testing" - "time" - - "golang.org/x/sys/windows/svc/mgr" -) - -func TestOpenLanManServer(t *testing.T) { - m, err := mgr.Connect() - if err != nil { - if errno, ok := err.(syscall.Errno); ok && errno == syscall.ERROR_ACCESS_DENIED { - t.Skip("Skipping test: we don't have rights to manage services.") - } - t.Fatalf("SCM connection failed: %s", err) - } - defer m.Disconnect() - - s, err := m.OpenService("LanmanServer") - if err != nil { - t.Fatalf("OpenService(lanmanserver) failed: %s", err) - } - defer s.Close() - - _, err = s.Config() - if err != nil { - t.Fatalf("Config failed: %s", err) - } -} - -func install(t *testing.T, m *mgr.Mgr, name, exepath string, c mgr.Config) { - // Sometimes it takes a while for the service to get - // removed after previous test run. - for i := 0; ; i++ { - s, err := m.OpenService(name) - if err != nil { - break - } - s.Close() - - if i > 10 { - t.Fatalf("service %s already exists", name) - } - time.Sleep(300 * time.Millisecond) - } - - s, err := m.CreateService(name, exepath, c) - if err != nil { - t.Fatalf("CreateService(%s) failed: %v", name, err) - } - defer s.Close() -} - -func depString(d []string) string { - if len(d) == 0 { - return "" - } - for i := range d { - d[i] = strings.ToLower(d[i]) - } - ss := sort.StringSlice(d) - ss.Sort() - return strings.Join([]string(ss), " ") -} - -func testConfig(t *testing.T, s *mgr.Service, should mgr.Config) mgr.Config { - is, err := s.Config() - if err != nil { - t.Fatalf("Config failed: %s", err) - } - if should.DisplayName != is.DisplayName { - t.Fatalf("config mismatch: DisplayName is %q, but should have %q", is.DisplayName, should.DisplayName) - } - if should.StartType != is.StartType { - t.Fatalf("config mismatch: StartType is %v, but should have %v", is.StartType, should.StartType) - } - if should.Description != is.Description { - t.Fatalf("config mismatch: Description is %q, but should have %q", is.Description, should.Description) - } - if depString(should.Dependencies) != depString(is.Dependencies) { - t.Fatalf("config mismatch: Dependencies is %v, but should have %v", is.Dependencies, should.Dependencies) - } - return is -} - -func remove(t *testing.T, s *mgr.Service) { - err := s.Delete() - if err != nil { - t.Fatalf("Delete failed: %s", err) - } -} - -func TestMyService(t *testing.T) { - if testing.Short() { - t.Skip("skipping test in short mode - it modifies system services") - } - - const name = "myservice" - - m, err := mgr.Connect() - if err != nil { - if errno, ok := err.(syscall.Errno); ok && errno == syscall.ERROR_ACCESS_DENIED { - t.Skip("Skipping test: we don't have rights to manage services.") - } - t.Fatalf("SCM connection failed: %s", err) - } - defer m.Disconnect() - - c := mgr.Config{ - StartType: mgr.StartDisabled, - DisplayName: "my service", - Description: "my service is just a test", - Dependencies: []string{"LanmanServer", "W32Time"}, - } - - exename := os.Args[0] - exepath, err := filepath.Abs(exename) - if err != nil { - t.Fatalf("filepath.Abs(%s) failed: %s", exename, err) - } - - install(t, m, name, exepath, c) - - s, err := m.OpenService(name) - if err != nil { - t.Fatalf("service %s is not installed", name) - } - defer s.Close() - - c.BinaryPathName = exepath - c = testConfig(t, s, c) - - c.StartType = mgr.StartManual - err = s.UpdateConfig(c) - if err != nil { - t.Fatalf("UpdateConfig failed: %v", err) - } - - testConfig(t, s, c) - - remove(t, s) -} diff --git a/vendor/golang.org/x/sys/windows/svc/mgr/service.go b/vendor/golang.org/x/sys/windows/svc/mgr/service.go deleted file mode 100644 index 465f3c3d2..000000000 --- a/vendor/golang.org/x/sys/windows/svc/mgr/service.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package mgr - -import ( - "syscall" - - "golang.org/x/sys/windows" - "golang.org/x/sys/windows/svc" -) - -// TODO(brainman): Use EnumDependentServices to enumerate dependent services. - -// TODO(brainman): Use EnumServicesStatus to enumerate services in the specified service control manager database. - -// Service is used to access Windows service. -type Service struct { - Name string - Handle windows.Handle -} - -// Delete marks service s for deletion from the service control manager database. -func (s *Service) Delete() error { - return windows.DeleteService(s.Handle) -} - -// Close relinquish access to the service s. -func (s *Service) Close() error { - return windows.CloseServiceHandle(s.Handle) -} - -// Start starts service s. -// args will be passed to svc.Handler.Execute. -func (s *Service) Start(args ...string) error { - var p **uint16 - if len(args) > 0 { - vs := make([]*uint16, len(args)) - for i, _ := range vs { - vs[i] = syscall.StringToUTF16Ptr(args[i]) - } - p = &vs[0] - } - return windows.StartService(s.Handle, uint32(len(args)), p) -} - -// Control sends state change request c to the servce s. -func (s *Service) Control(c svc.Cmd) (svc.Status, error) { - var t windows.SERVICE_STATUS - err := windows.ControlService(s.Handle, uint32(c), &t) - if err != nil { - return svc.Status{}, err - } - return svc.Status{ - State: svc.State(t.CurrentState), - Accepts: svc.Accepted(t.ControlsAccepted), - }, nil -} - -// Query returns current status of service s. -func (s *Service) Query() (svc.Status, error) { - var t windows.SERVICE_STATUS - err := windows.QueryServiceStatus(s.Handle, &t) - if err != nil { - return svc.Status{}, err - } - return svc.Status{ - State: svc.State(t.CurrentState), - Accepts: svc.Accepted(t.ControlsAccepted), - }, nil -} diff --git a/vendor/golang.org/x/sys/windows/svc/security.go b/vendor/golang.org/x/sys/windows/svc/security.go deleted file mode 100644 index 6fbc9236e..000000000 --- a/vendor/golang.org/x/sys/windows/svc/security.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package svc - -import ( - "unsafe" - - "golang.org/x/sys/windows" -) - -func allocSid(subAuth0 uint32) (*windows.SID, error) { - var sid *windows.SID - err := windows.AllocateAndInitializeSid(&windows.SECURITY_NT_AUTHORITY, - 1, subAuth0, 0, 0, 0, 0, 0, 0, 0, &sid) - if err != nil { - return nil, err - } - return sid, nil -} - -// IsAnInteractiveSession determines if calling process is running interactively. -// It queries the process token for membership in the Interactive group. -// http://stackoverflow.com/questions/2668851/how-do-i-detect-that-my-application-is-running-as-service-or-in-an-interactive-s -func IsAnInteractiveSession() (bool, error) { - interSid, err := allocSid(windows.SECURITY_INTERACTIVE_RID) - if err != nil { - return false, err - } - defer windows.FreeSid(interSid) - - serviceSid, err := allocSid(windows.SECURITY_SERVICE_RID) - if err != nil { - return false, err - } - defer windows.FreeSid(serviceSid) - - t, err := windows.OpenCurrentProcessToken() - if err != nil { - return false, err - } - defer t.Close() - - gs, err := t.GetTokenGroups() - if err != nil { - return false, err - } - p := unsafe.Pointer(&gs.Groups[0]) - groups := (*[2 << 20]windows.SIDAndAttributes)(p)[:gs.GroupCount] - for _, g := range groups { - if windows.EqualSid(g.Sid, interSid) { - return true, nil - } - if windows.EqualSid(g.Sid, serviceSid) { - return false, nil - } - } - return false, nil -} diff --git a/vendor/golang.org/x/sys/windows/svc/service.go b/vendor/golang.org/x/sys/windows/svc/service.go deleted file mode 100644 index 9864f7a72..000000000 --- a/vendor/golang.org/x/sys/windows/svc/service.go +++ /dev/null @@ -1,316 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -// Package svc provides everything required to build Windows service. -// -package svc - -import ( - "errors" - "runtime" - "syscall" - "unsafe" - - "golang.org/x/sys/windows" -) - -// State describes service execution state (Stopped, Running and so on). -type State uint32 - -const ( - Stopped = State(windows.SERVICE_STOPPED) - StartPending = State(windows.SERVICE_START_PENDING) - StopPending = State(windows.SERVICE_STOP_PENDING) - Running = State(windows.SERVICE_RUNNING) - ContinuePending = State(windows.SERVICE_CONTINUE_PENDING) - PausePending = State(windows.SERVICE_PAUSE_PENDING) - Paused = State(windows.SERVICE_PAUSED) -) - -// Cmd represents service state change request. It is sent to a service -// by the service manager, and should be actioned upon by the service. -type Cmd uint32 - -const ( - Stop = Cmd(windows.SERVICE_CONTROL_STOP) - Pause = Cmd(windows.SERVICE_CONTROL_PAUSE) - Continue = Cmd(windows.SERVICE_CONTROL_CONTINUE) - Interrogate = Cmd(windows.SERVICE_CONTROL_INTERROGATE) - Shutdown = Cmd(windows.SERVICE_CONTROL_SHUTDOWN) -) - -// Accepted is used to describe commands accepted by the service. -// Note that Interrogate is always accepted. -type Accepted uint32 - -const ( - AcceptStop = Accepted(windows.SERVICE_ACCEPT_STOP) - AcceptShutdown = Accepted(windows.SERVICE_ACCEPT_SHUTDOWN) - AcceptPauseAndContinue = Accepted(windows.SERVICE_ACCEPT_PAUSE_CONTINUE) -) - -// Status combines State and Accepted commands to fully describe running service. -type Status struct { - State State - Accepts Accepted - CheckPoint uint32 // used to report progress during a lengthy operation - WaitHint uint32 // estimated time required for a pending operation, in milliseconds -} - -// ChangeRequest is sent to the service Handler to request service status change. -type ChangeRequest struct { - Cmd Cmd - CurrentStatus Status -} - -// Handler is the interface that must be implemented to build Windows service. -type Handler interface { - - // Execute will be called by the package code at the start of - // the service, and the service will exit once Execute completes. - // Inside Execute you must read service change requests from r and - // act accordingly. You must keep service control manager up to date - // about state of your service by writing into s as required. - // args contains service name followed by argument strings passed - // to the service. - // You can provide service exit code in exitCode return parameter, - // with 0 being "no error". You can also indicate if exit code, - // if any, is service specific or not by using svcSpecificEC - // parameter. - Execute(args []string, r <-chan ChangeRequest, s chan<- Status) (svcSpecificEC bool, exitCode uint32) -} - -var ( - // These are used by asm code. - goWaitsH uintptr - cWaitsH uintptr - ssHandle uintptr - sName *uint16 - sArgc uintptr - sArgv **uint16 - ctlHandlerProc uintptr - cSetEvent uintptr - cWaitForSingleObject uintptr - cRegisterServiceCtrlHandlerW uintptr -) - -func init() { - k := syscall.MustLoadDLL("kernel32.dll") - cSetEvent = k.MustFindProc("SetEvent").Addr() - cWaitForSingleObject = k.MustFindProc("WaitForSingleObject").Addr() - a := syscall.MustLoadDLL("advapi32.dll") - cRegisterServiceCtrlHandlerW = a.MustFindProc("RegisterServiceCtrlHandlerW").Addr() -} - -type ctlEvent struct { - cmd Cmd - errno uint32 -} - -// service provides access to windows service api. -type service struct { - name string - h windows.Handle - cWaits *event - goWaits *event - c chan ctlEvent - handler Handler -} - -func newService(name string, handler Handler) (*service, error) { - var s service - var err error - s.name = name - s.c = make(chan ctlEvent) - s.handler = handler - s.cWaits, err = newEvent() - if err != nil { - return nil, err - } - s.goWaits, err = newEvent() - if err != nil { - s.cWaits.Close() - return nil, err - } - return &s, nil -} - -func (s *service) close() error { - s.cWaits.Close() - s.goWaits.Close() - return nil -} - -type exitCode struct { - isSvcSpecific bool - errno uint32 -} - -func (s *service) updateStatus(status *Status, ec *exitCode) error { - if s.h == 0 { - return errors.New("updateStatus with no service status handle") - } - var t windows.SERVICE_STATUS - t.ServiceType = windows.SERVICE_WIN32_OWN_PROCESS - t.CurrentState = uint32(status.State) - if status.Accepts&AcceptStop != 0 { - t.ControlsAccepted |= windows.SERVICE_ACCEPT_STOP - } - if status.Accepts&AcceptShutdown != 0 { - t.ControlsAccepted |= windows.SERVICE_ACCEPT_SHUTDOWN - } - if status.Accepts&AcceptPauseAndContinue != 0 { - t.ControlsAccepted |= windows.SERVICE_ACCEPT_PAUSE_CONTINUE - } - if ec.errno == 0 { - t.Win32ExitCode = windows.NO_ERROR - t.ServiceSpecificExitCode = windows.NO_ERROR - } else if ec.isSvcSpecific { - t.Win32ExitCode = uint32(windows.ERROR_SERVICE_SPECIFIC_ERROR) - t.ServiceSpecificExitCode = ec.errno - } else { - t.Win32ExitCode = ec.errno - t.ServiceSpecificExitCode = windows.NO_ERROR - } - t.CheckPoint = status.CheckPoint - t.WaitHint = status.WaitHint - return windows.SetServiceStatus(s.h, &t) -} - -const ( - sysErrSetServiceStatusFailed = uint32(syscall.APPLICATION_ERROR) + iota - sysErrNewThreadInCallback -) - -func (s *service) run() { - s.goWaits.Wait() - s.h = windows.Handle(ssHandle) - argv := (*[100]*int16)(unsafe.Pointer(sArgv))[:sArgc] - args := make([]string, len(argv)) - for i, a := range argv { - args[i] = syscall.UTF16ToString((*[1 << 20]uint16)(unsafe.Pointer(a))[:]) - } - - cmdsToHandler := make(chan ChangeRequest) - changesFromHandler := make(chan Status) - exitFromHandler := make(chan exitCode) - - go func() { - ss, errno := s.handler.Execute(args, cmdsToHandler, changesFromHandler) - exitFromHandler <- exitCode{ss, errno} - }() - - status := Status{State: Stopped} - ec := exitCode{isSvcSpecific: true, errno: 0} - var outch chan ChangeRequest - inch := s.c - var cmd Cmd -loop: - for { - select { - case r := <-inch: - if r.errno != 0 { - ec.errno = r.errno - break loop - } - inch = nil - outch = cmdsToHandler - cmd = r.cmd - case outch <- ChangeRequest{cmd, status}: - inch = s.c - outch = nil - case c := <-changesFromHandler: - err := s.updateStatus(&c, &ec) - if err != nil { - // best suitable error number - ec.errno = sysErrSetServiceStatusFailed - if err2, ok := err.(syscall.Errno); ok { - ec.errno = uint32(err2) - } - break loop - } - status = c - case ec = <-exitFromHandler: - break loop - } - } - - s.updateStatus(&Status{State: Stopped}, &ec) - s.cWaits.Set() -} - -func newCallback(fn interface{}) (cb uintptr, err error) { - defer func() { - r := recover() - if r == nil { - return - } - cb = 0 - switch v := r.(type) { - case string: - err = errors.New(v) - case error: - err = v - default: - err = errors.New("unexpected panic in syscall.NewCallback") - } - }() - return syscall.NewCallback(fn), nil -} - -// BUG(brainman): There is no mechanism to run multiple services -// inside one single executable. Perhaps, it can be overcome by -// using RegisterServiceCtrlHandlerEx Windows api. - -// Run executes service name by calling appropriate handler function. -func Run(name string, handler Handler) error { - runtime.LockOSThread() - - tid := windows.GetCurrentThreadId() - - s, err := newService(name, handler) - if err != nil { - return err - } - - ctlHandler := func(ctl uint32) uintptr { - e := ctlEvent{cmd: Cmd(ctl)} - // We assume that this callback function is running on - // the same thread as Run. Nowhere in MS documentation - // I could find statement to guarantee that. So putting - // check here to verify, otherwise things will go bad - // quickly, if ignored. - i := windows.GetCurrentThreadId() - if i != tid { - e.errno = sysErrNewThreadInCallback - } - s.c <- e - return 0 - } - - var svcmain uintptr - getServiceMain(&svcmain) - t := []windows.SERVICE_TABLE_ENTRY{ - {syscall.StringToUTF16Ptr(s.name), svcmain}, - {nil, 0}, - } - - goWaitsH = uintptr(s.goWaits.h) - cWaitsH = uintptr(s.cWaits.h) - sName = t[0].ServiceName - ctlHandlerProc, err = newCallback(ctlHandler) - if err != nil { - return err - } - - go s.run() - - err = windows.StartServiceCtrlDispatcher(&t[0]) - if err != nil { - return err - } - return nil -} diff --git a/vendor/golang.org/x/sys/windows/svc/svc_test.go b/vendor/golang.org/x/sys/windows/svc/svc_test.go deleted file mode 100644 index 764da54a5..000000000 --- a/vendor/golang.org/x/sys/windows/svc/svc_test.go +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package svc_test - -import ( - "io/ioutil" - "os" - "os/exec" - "path/filepath" - "testing" - "time" - - "golang.org/x/sys/windows/svc" - "golang.org/x/sys/windows/svc/mgr" -) - -func getState(t *testing.T, s *mgr.Service) svc.State { - status, err := s.Query() - if err != nil { - t.Fatalf("Query(%s) failed: %s", s.Name, err) - } - return status.State -} - -func testState(t *testing.T, s *mgr.Service, want svc.State) { - have := getState(t, s) - if have != want { - t.Fatalf("%s state is=%d want=%d", s.Name, have, want) - } -} - -func waitState(t *testing.T, s *mgr.Service, want svc.State) { - for i := 0; ; i++ { - have := getState(t, s) - if have == want { - return - } - if i > 10 { - t.Fatalf("%s state is=%d, waiting timeout", s.Name, have) - } - time.Sleep(300 * time.Millisecond) - } -} - -func TestExample(t *testing.T) { - if testing.Short() { - t.Skip("skipping test in short mode - it modifies system services") - } - - const name = "myservice" - - m, err := mgr.Connect() - if err != nil { - t.Fatalf("SCM connection failed: %s", err) - } - defer m.Disconnect() - - dir, err := ioutil.TempDir("", "svc") - if err != nil { - t.Fatalf("failed to create temp directory: %v", err) - } - defer os.RemoveAll(dir) - - exepath := filepath.Join(dir, "a.exe") - o, err := exec.Command("go", "build", "-o", exepath, "golang.org/x/sys/windows/svc/example").CombinedOutput() - if err != nil { - t.Fatalf("failed to build service program: %v\n%v", err, string(o)) - } - - s, err := m.OpenService(name) - if err == nil { - err = s.Delete() - if err != nil { - s.Close() - t.Fatalf("Delete failed: %s", err) - } - s.Close() - } - s, err = m.CreateService(name, exepath, mgr.Config{DisplayName: "my service"}, "is", "auto-started") - if err != nil { - t.Fatalf("CreateService(%s) failed: %v", name, err) - } - defer s.Close() - - testState(t, s, svc.Stopped) - err = s.Start("is", "manual-started") - if err != nil { - t.Fatalf("Start(%s) failed: %s", s.Name, err) - } - waitState(t, s, svc.Running) - time.Sleep(1 * time.Second) - - // testing deadlock from issues 4. - _, err = s.Control(svc.Interrogate) - if err != nil { - t.Fatalf("Control(%s) failed: %s", s.Name, err) - } - _, err = s.Control(svc.Interrogate) - if err != nil { - t.Fatalf("Control(%s) failed: %s", s.Name, err) - } - time.Sleep(1 * time.Second) - - _, err = s.Control(svc.Stop) - if err != nil { - t.Fatalf("Control(%s) failed: %s", s.Name, err) - } - waitState(t, s, svc.Stopped) - - err = s.Delete() - if err != nil { - t.Fatalf("Delete failed: %s", err) - } -} diff --git a/vendor/golang.org/x/sys/windows/svc/sys_386.s b/vendor/golang.org/x/sys/windows/svc/sys_386.s deleted file mode 100644 index 5e11bfadb..000000000 --- a/vendor/golang.org/x/sys/windows/svc/sys_386.s +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -// func servicemain(argc uint32, argv **uint16) -TEXT ·servicemain(SB),7,$0 - MOVL argc+0(FP), AX - MOVL AX, ·sArgc(SB) - MOVL argv+4(FP), AX - MOVL AX, ·sArgv(SB) - - PUSHL BP - PUSHL BX - PUSHL SI - PUSHL DI - - SUBL $12, SP - - MOVL ·sName(SB), AX - MOVL AX, (SP) - MOVL $·servicectlhandler(SB), AX - MOVL AX, 4(SP) - MOVL ·cRegisterServiceCtrlHandlerW(SB), AX - MOVL SP, BP - CALL AX - MOVL BP, SP - CMPL AX, $0 - JE exit - MOVL AX, ·ssHandle(SB) - - MOVL ·goWaitsH(SB), AX - MOVL AX, (SP) - MOVL ·cSetEvent(SB), AX - MOVL SP, BP - CALL AX - MOVL BP, SP - - MOVL ·cWaitsH(SB), AX - MOVL AX, (SP) - MOVL $-1, AX - MOVL AX, 4(SP) - MOVL ·cWaitForSingleObject(SB), AX - MOVL SP, BP - CALL AX - MOVL BP, SP - -exit: - ADDL $12, SP - - POPL DI - POPL SI - POPL BX - POPL BP - - MOVL 0(SP), CX - ADDL $12, SP - JMP CX - -// I do not know why, but this seems to be the only way to call -// ctlHandlerProc on Windows 7. - -// func servicectlhandler(ctl uint32) uintptr -TEXT ·servicectlhandler(SB),7,$0 - MOVL ·ctlHandlerProc(SB), CX - JMP CX diff --git a/vendor/golang.org/x/sys/windows/svc/sys_amd64.s b/vendor/golang.org/x/sys/windows/svc/sys_amd64.s deleted file mode 100644 index 87dbec839..000000000 --- a/vendor/golang.org/x/sys/windows/svc/sys_amd64.s +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -// func servicemain(argc uint32, argv **uint16) -TEXT ·servicemain(SB),7,$0 - MOVL CX, ·sArgc(SB) - MOVL DX, ·sArgv(SB) - - SUBQ $32, SP // stack for the first 4 syscall params - - MOVQ ·sName(SB), CX - MOVQ $·servicectlhandler(SB), DX - MOVQ ·cRegisterServiceCtrlHandlerW(SB), AX - CALL AX - CMPQ AX, $0 - JE exit - MOVQ AX, ·ssHandle(SB) - - MOVQ ·goWaitsH(SB), CX - MOVQ ·cSetEvent(SB), AX - CALL AX - - MOVQ ·cWaitsH(SB), CX - MOVQ $4294967295, DX - MOVQ ·cWaitForSingleObject(SB), AX - CALL AX - -exit: - ADDQ $32, SP - RET - -// I do not know why, but this seems to be the only way to call -// ctlHandlerProc on Windows 7. - -// func servicectlhandler(ctl uint32) uintptr -TEXT ·servicectlhandler(SB),7,$0 - MOVQ ·ctlHandlerProc(SB), AX - JMP AX diff --git a/vendor/golang.org/x/sys/windows/syscall.go b/vendor/golang.org/x/sys/windows/syscall.go deleted file mode 100644 index 4e2fbe86e..000000000 --- a/vendor/golang.org/x/sys/windows/syscall.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -// Package windows contains an interface to the low-level operating system -// primitives. OS details vary depending on the underlying system, and -// by default, godoc will display the OS-specific documentation for the current -// system. If you want godoc to display syscall documentation for another -// system, set $GOOS and $GOARCH to the desired system. For example, if -// you want to view documentation for freebsd/arm on linux/amd64, set $GOOS -// to freebsd and $GOARCH to arm. -// The primary use of this package is inside other packages that provide a more -// portable interface to the system, such as "os", "time" and "net". Use -// those packages rather than this one if you can. -// For details of the functions and data types in this package consult -// the manuals for the appropriate operating system. -// These calls return err == nil to indicate success; otherwise -// err represents an operating system error describing the failure and -// holds a value of type syscall.Errno. -package windows // import "golang.org/x/sys/windows" - -import ( - "syscall" -) - -// ByteSliceFromString returns a NUL-terminated slice of bytes -// containing the text of s. If s contains a NUL byte at any -// location, it returns (nil, syscall.EINVAL). -func ByteSliceFromString(s string) ([]byte, error) { - for i := 0; i < len(s); i++ { - if s[i] == 0 { - return nil, syscall.EINVAL - } - } - a := make([]byte, len(s)+1) - copy(a, s) - return a, nil -} - -// BytePtrFromString returns a pointer to a NUL-terminated array of -// bytes containing the text of s. If s contains a NUL byte at any -// location, it returns (nil, syscall.EINVAL). -func BytePtrFromString(s string) (*byte, error) { - a, err := ByteSliceFromString(s) - if err != nil { - return nil, err - } - return &a[0], nil -} - -// Single-word zero for use when we need a valid pointer to 0 bytes. -// See mksyscall.pl. -var _zero uintptr - -func (ts *Timespec) Unix() (sec int64, nsec int64) { - return int64(ts.Sec), int64(ts.Nsec) -} - -func (tv *Timeval) Unix() (sec int64, nsec int64) { - return int64(tv.Sec), int64(tv.Usec) * 1000 -} - -func (ts *Timespec) Nano() int64 { - return int64(ts.Sec)*1e9 + int64(ts.Nsec) -} - -func (tv *Timeval) Nano() int64 { - return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 -} diff --git a/vendor/golang.org/x/sys/windows/syscall_test.go b/vendor/golang.org/x/sys/windows/syscall_test.go deleted file mode 100644 index 62588b91b..000000000 --- a/vendor/golang.org/x/sys/windows/syscall_test.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package windows_test - -import ( - "testing" - - "golang.org/x/sys/windows" -) - -func testSetGetenv(t *testing.T, key, value string) { - err := windows.Setenv(key, value) - if err != nil { - t.Fatalf("Setenv failed to set %q: %v", value, err) - } - newvalue, found := windows.Getenv(key) - if !found { - t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value) - } - if newvalue != value { - t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value) - } -} - -func TestEnv(t *testing.T) { - testSetGetenv(t, "TESTENV", "AVALUE") - // make sure TESTENV gets set to "", not deleted - testSetGetenv(t, "TESTENV", "") -} diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go deleted file mode 100644 index 592d73e03..000000000 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ /dev/null @@ -1,989 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Windows system calls. - -package windows - -import ( - errorspkg "errors" - "sync" - "syscall" - "unicode/utf16" - "unsafe" -) - -type Handle uintptr - -const InvalidHandle = ^Handle(0) - -// StringToUTF16 is deprecated. Use UTF16FromString instead. -// If s contains a NUL byte this function panics instead of -// returning an error. -func StringToUTF16(s string) []uint16 { - a, err := UTF16FromString(s) - if err != nil { - panic("windows: string with NUL passed to StringToUTF16") - } - return a -} - -// UTF16FromString returns the UTF-16 encoding of the UTF-8 string -// s, with a terminating NUL added. If s contains a NUL byte at any -// location, it returns (nil, syscall.EINVAL). -func UTF16FromString(s string) ([]uint16, error) { - for i := 0; i < len(s); i++ { - if s[i] == 0 { - return nil, syscall.EINVAL - } - } - return utf16.Encode([]rune(s + "\x00")), nil -} - -// UTF16ToString returns the UTF-8 encoding of the UTF-16 sequence s, -// with a terminating NUL removed. -func UTF16ToString(s []uint16) string { - for i, v := range s { - if v == 0 { - s = s[0:i] - break - } - } - return string(utf16.Decode(s)) -} - -// StringToUTF16Ptr is deprecated. Use UTF16PtrFromString instead. -// If s contains a NUL byte this function panics instead of -// returning an error. -func StringToUTF16Ptr(s string) *uint16 { return &StringToUTF16(s)[0] } - -// UTF16PtrFromString returns pointer to the UTF-16 encoding of -// the UTF-8 string s, with a terminating NUL added. If s -// contains a NUL byte at any location, it returns (nil, syscall.EINVAL). -func UTF16PtrFromString(s string) (*uint16, error) { - a, err := UTF16FromString(s) - if err != nil { - return nil, err - } - return &a[0], nil -} - -func Getpagesize() int { return 4096 } - -// Converts a Go function to a function pointer conforming -// to the stdcall or cdecl calling convention. This is useful when -// interoperating with Windows code requiring callbacks. -// Implemented in runtime/syscall_windows.goc -func NewCallback(fn interface{}) uintptr -func NewCallbackCDecl(fn interface{}) uintptr - -// windows api calls - -//sys GetLastError() (lasterr error) -//sys LoadLibrary(libname string) (handle Handle, err error) = LoadLibraryW -//sys LoadLibraryEx(libname string, zero Handle, flags uintptr) (handle Handle, err error) = LoadLibraryExW -//sys FreeLibrary(handle Handle) (err error) -//sys GetProcAddress(module Handle, procname string) (proc uintptr, err error) -//sys GetVersion() (ver uint32, err error) -//sys FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) = FormatMessageW -//sys ExitProcess(exitcode uint32) -//sys CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile int32) (handle Handle, err error) [failretval==InvalidHandle] = CreateFileW -//sys ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) -//sys WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) -//sys SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) [failretval==0xffffffff] -//sys CloseHandle(handle Handle) (err error) -//sys GetStdHandle(stdhandle int) (handle Handle, err error) [failretval==InvalidHandle] -//sys findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) [failretval==InvalidHandle] = FindFirstFileW -//sys findNextFile1(handle Handle, data *win32finddata1) (err error) = FindNextFileW -//sys FindClose(handle Handle) (err error) -//sys GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) -//sys GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) = GetCurrentDirectoryW -//sys SetCurrentDirectory(path *uint16) (err error) = SetCurrentDirectoryW -//sys CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) = CreateDirectoryW -//sys RemoveDirectory(path *uint16) (err error) = RemoveDirectoryW -//sys DeleteFile(path *uint16) (err error) = DeleteFileW -//sys MoveFile(from *uint16, to *uint16) (err error) = MoveFileW -//sys MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) = MoveFileExW -//sys GetComputerName(buf *uint16, n *uint32) (err error) = GetComputerNameW -//sys GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) = GetComputerNameExW -//sys SetEndOfFile(handle Handle) (err error) -//sys GetSystemTimeAsFileTime(time *Filetime) -//sys GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) [failretval==0xffffffff] -//sys CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) -//sys GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) -//sys PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) -//sys CancelIo(s Handle) (err error) -//sys CancelIoEx(s Handle, o *Overlapped) (err error) -//sys CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) = CreateProcessW -//sys OpenProcess(da uint32, inheritHandle bool, pid uint32) (handle Handle, err error) -//sys TerminateProcess(handle Handle, exitcode uint32) (err error) -//sys GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) -//sys GetStartupInfo(startupInfo *StartupInfo) (err error) = GetStartupInfoW -//sys GetCurrentProcess() (pseudoHandle Handle, err error) -//sys GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) -//sys DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) -//sys WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) [failretval==0xffffffff] -//sys GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) = GetTempPathW -//sys CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error) -//sys GetFileType(filehandle Handle) (n uint32, err error) -//sys CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) = advapi32.CryptAcquireContextW -//sys CryptReleaseContext(provhandle Handle, flags uint32) (err error) = advapi32.CryptReleaseContext -//sys CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) = advapi32.CryptGenRandom -//sys GetEnvironmentStrings() (envs *uint16, err error) [failretval==nil] = kernel32.GetEnvironmentStringsW -//sys FreeEnvironmentStrings(envs *uint16) (err error) = kernel32.FreeEnvironmentStringsW -//sys GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) = kernel32.GetEnvironmentVariableW -//sys SetEnvironmentVariable(name *uint16, value *uint16) (err error) = kernel32.SetEnvironmentVariableW -//sys SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) -//sys GetFileAttributes(name *uint16) (attrs uint32, err error) [failretval==INVALID_FILE_ATTRIBUTES] = kernel32.GetFileAttributesW -//sys SetFileAttributes(name *uint16, attrs uint32) (err error) = kernel32.SetFileAttributesW -//sys GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) = kernel32.GetFileAttributesExW -//sys GetCommandLine() (cmd *uint16) = kernel32.GetCommandLineW -//sys CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) [failretval==nil] = shell32.CommandLineToArgvW -//sys LocalFree(hmem Handle) (handle Handle, err error) [failretval!=0] -//sys SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) -//sys FlushFileBuffers(handle Handle) (err error) -//sys GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) = kernel32.GetFullPathNameW -//sys GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) = kernel32.GetLongPathNameW -//sys GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) = kernel32.GetShortPathNameW -//sys CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) = kernel32.CreateFileMappingW -//sys MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) -//sys UnmapViewOfFile(addr uintptr) (err error) -//sys FlushViewOfFile(addr uintptr, length uintptr) (err error) -//sys VirtualLock(addr uintptr, length uintptr) (err error) -//sys VirtualUnlock(addr uintptr, length uintptr) (err error) -//sys TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) = mswsock.TransmitFile -//sys ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) = kernel32.ReadDirectoryChangesW -//sys CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) = crypt32.CertOpenSystemStoreW -//sys CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) [failretval==InvalidHandle] = crypt32.CertOpenStore -//sys CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) [failretval==nil] = crypt32.CertEnumCertificatesInStore -//sys CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) = crypt32.CertAddCertificateContextToStore -//sys CertCloseStore(store Handle, flags uint32) (err error) = crypt32.CertCloseStore -//sys CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) = crypt32.CertGetCertificateChain -//sys CertFreeCertificateChain(ctx *CertChainContext) = crypt32.CertFreeCertificateChain -//sys CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) [failretval==nil] = crypt32.CertCreateCertificateContext -//sys CertFreeCertificateContext(ctx *CertContext) (err error) = crypt32.CertFreeCertificateContext -//sys CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) = crypt32.CertVerifyCertificateChainPolicy -//sys RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) = advapi32.RegOpenKeyExW -//sys RegCloseKey(key Handle) (regerrno error) = advapi32.RegCloseKey -//sys RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *uint32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteTime *Filetime) (regerrno error) = advapi32.RegQueryInfoKeyW -//sys RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) = advapi32.RegEnumKeyExW -//sys RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) = advapi32.RegQueryValueExW -//sys getCurrentProcessId() (pid uint32) = kernel32.GetCurrentProcessId -//sys GetConsoleMode(console Handle, mode *uint32) (err error) = kernel32.GetConsoleMode -//sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) = kernel32.WriteConsoleW -//sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) = kernel32.ReadConsoleW -//sys CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.CreateToolhelp32Snapshot -//sys Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) = kernel32.Process32FirstW -//sys Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) = kernel32.Process32NextW -//sys DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBufferSize uint32, outBuffer *byte, outBufferSize uint32, bytesReturned *uint32, overlapped *Overlapped) (err error) -// This function returns 1 byte BOOLEAN rather than the 4 byte BOOL. -//sys CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) [failretval&0xff==0] = CreateSymbolicLinkW -//sys CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) [failretval&0xff==0] = CreateHardLinkW -//sys GetCurrentThreadId() (id uint32) -//sys CreateEvent(eventAttrs *syscall.SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) = kernel32.CreateEventW -//sys SetEvent(event Handle) (err error) = kernel32.SetEvent - -// syscall interface implementation for other packages - -func Exit(code int) { ExitProcess(uint32(code)) } - -func makeInheritSa() *SecurityAttributes { - var sa SecurityAttributes - sa.Length = uint32(unsafe.Sizeof(sa)) - sa.InheritHandle = 1 - return &sa -} - -func Open(path string, mode int, perm uint32) (fd Handle, err error) { - if len(path) == 0 { - return InvalidHandle, ERROR_FILE_NOT_FOUND - } - pathp, err := UTF16PtrFromString(path) - if err != nil { - return InvalidHandle, err - } - var access uint32 - switch mode & (O_RDONLY | O_WRONLY | O_RDWR) { - case O_RDONLY: - access = GENERIC_READ - case O_WRONLY: - access = GENERIC_WRITE - case O_RDWR: - access = GENERIC_READ | GENERIC_WRITE - } - if mode&O_CREAT != 0 { - access |= GENERIC_WRITE - } - if mode&O_APPEND != 0 { - access &^= GENERIC_WRITE - access |= FILE_APPEND_DATA - } - sharemode := uint32(FILE_SHARE_READ | FILE_SHARE_WRITE) - var sa *SecurityAttributes - if mode&O_CLOEXEC == 0 { - sa = makeInheritSa() - } - var createmode uint32 - switch { - case mode&(O_CREAT|O_EXCL) == (O_CREAT | O_EXCL): - createmode = CREATE_NEW - case mode&(O_CREAT|O_TRUNC) == (O_CREAT | O_TRUNC): - createmode = CREATE_ALWAYS - case mode&O_CREAT == O_CREAT: - createmode = OPEN_ALWAYS - case mode&O_TRUNC == O_TRUNC: - createmode = TRUNCATE_EXISTING - default: - createmode = OPEN_EXISTING - } - h, e := CreateFile(pathp, access, sharemode, sa, createmode, FILE_ATTRIBUTE_NORMAL, 0) - return h, e -} - -func Read(fd Handle, p []byte) (n int, err error) { - var done uint32 - e := ReadFile(fd, p, &done, nil) - if e != nil { - if e == ERROR_BROKEN_PIPE { - // NOTE(brainman): work around ERROR_BROKEN_PIPE is returned on reading EOF from stdin - return 0, nil - } - return 0, e - } - if raceenabled { - if done > 0 { - raceWriteRange(unsafe.Pointer(&p[0]), int(done)) - } - raceAcquire(unsafe.Pointer(&ioSync)) - } - return int(done), nil -} - -func Write(fd Handle, p []byte) (n int, err error) { - if raceenabled { - raceReleaseMerge(unsafe.Pointer(&ioSync)) - } - var done uint32 - e := WriteFile(fd, p, &done, nil) - if e != nil { - return 0, e - } - if raceenabled && done > 0 { - raceReadRange(unsafe.Pointer(&p[0]), int(done)) - } - return int(done), nil -} - -var ioSync int64 - -func Seek(fd Handle, offset int64, whence int) (newoffset int64, err error) { - var w uint32 - switch whence { - case 0: - w = FILE_BEGIN - case 1: - w = FILE_CURRENT - case 2: - w = FILE_END - } - hi := int32(offset >> 32) - lo := int32(offset) - // use GetFileType to check pipe, pipe can't do seek - ft, _ := GetFileType(fd) - if ft == FILE_TYPE_PIPE { - return 0, syscall.EPIPE - } - rlo, e := SetFilePointer(fd, lo, &hi, w) - if e != nil { - return 0, e - } - return int64(hi)<<32 + int64(rlo), nil -} - -func Close(fd Handle) (err error) { - return CloseHandle(fd) -} - -var ( - Stdin = getStdHandle(STD_INPUT_HANDLE) - Stdout = getStdHandle(STD_OUTPUT_HANDLE) - Stderr = getStdHandle(STD_ERROR_HANDLE) -) - -func getStdHandle(h int) (fd Handle) { - r, _ := GetStdHandle(h) - CloseOnExec(r) - return r -} - -const ImplementsGetwd = true - -func Getwd() (wd string, err error) { - b := make([]uint16, 300) - n, e := GetCurrentDirectory(uint32(len(b)), &b[0]) - if e != nil { - return "", e - } - return string(utf16.Decode(b[0:n])), nil -} - -func Chdir(path string) (err error) { - pathp, err := UTF16PtrFromString(path) - if err != nil { - return err - } - return SetCurrentDirectory(pathp) -} - -func Mkdir(path string, mode uint32) (err error) { - pathp, err := UTF16PtrFromString(path) - if err != nil { - return err - } - return CreateDirectory(pathp, nil) -} - -func Rmdir(path string) (err error) { - pathp, err := UTF16PtrFromString(path) - if err != nil { - return err - } - return RemoveDirectory(pathp) -} - -func Unlink(path string) (err error) { - pathp, err := UTF16PtrFromString(path) - if err != nil { - return err - } - return DeleteFile(pathp) -} - -func Rename(oldpath, newpath string) (err error) { - from, err := UTF16PtrFromString(oldpath) - if err != nil { - return err - } - to, err := UTF16PtrFromString(newpath) - if err != nil { - return err - } - return MoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING) -} - -func ComputerName() (name string, err error) { - var n uint32 = MAX_COMPUTERNAME_LENGTH + 1 - b := make([]uint16, n) - e := GetComputerName(&b[0], &n) - if e != nil { - return "", e - } - return string(utf16.Decode(b[0:n])), nil -} - -func Ftruncate(fd Handle, length int64) (err error) { - curoffset, e := Seek(fd, 0, 1) - if e != nil { - return e - } - defer Seek(fd, curoffset, 0) - _, e = Seek(fd, length, 0) - if e != nil { - return e - } - e = SetEndOfFile(fd) - if e != nil { - return e - } - return nil -} - -func Gettimeofday(tv *Timeval) (err error) { - var ft Filetime - GetSystemTimeAsFileTime(&ft) - *tv = NsecToTimeval(ft.Nanoseconds()) - return nil -} - -func Pipe(p []Handle) (err error) { - if len(p) != 2 { - return syscall.EINVAL - } - var r, w Handle - e := CreatePipe(&r, &w, makeInheritSa(), 0) - if e != nil { - return e - } - p[0] = r - p[1] = w - return nil -} - -func Utimes(path string, tv []Timeval) (err error) { - if len(tv) != 2 { - return syscall.EINVAL - } - pathp, e := UTF16PtrFromString(path) - if e != nil { - return e - } - h, e := CreateFile(pathp, - FILE_WRITE_ATTRIBUTES, FILE_SHARE_WRITE, nil, - OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0) - if e != nil { - return e - } - defer Close(h) - a := NsecToFiletime(tv[0].Nanoseconds()) - w := NsecToFiletime(tv[1].Nanoseconds()) - return SetFileTime(h, nil, &a, &w) -} - -func UtimesNano(path string, ts []Timespec) (err error) { - if len(ts) != 2 { - return syscall.EINVAL - } - pathp, e := UTF16PtrFromString(path) - if e != nil { - return e - } - h, e := CreateFile(pathp, - FILE_WRITE_ATTRIBUTES, FILE_SHARE_WRITE, nil, - OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0) - if e != nil { - return e - } - defer Close(h) - a := NsecToFiletime(TimespecToNsec(ts[0])) - w := NsecToFiletime(TimespecToNsec(ts[1])) - return SetFileTime(h, nil, &a, &w) -} - -func Fsync(fd Handle) (err error) { - return FlushFileBuffers(fd) -} - -func Chmod(path string, mode uint32) (err error) { - if mode == 0 { - return syscall.EINVAL - } - p, e := UTF16PtrFromString(path) - if e != nil { - return e - } - attrs, e := GetFileAttributes(p) - if e != nil { - return e - } - if mode&S_IWRITE != 0 { - attrs &^= FILE_ATTRIBUTE_READONLY - } else { - attrs |= FILE_ATTRIBUTE_READONLY - } - return SetFileAttributes(p, attrs) -} - -func LoadCancelIoEx() error { - return procCancelIoEx.Find() -} - -func LoadSetFileCompletionNotificationModes() error { - return procSetFileCompletionNotificationModes.Find() -} - -// net api calls - -const socket_error = uintptr(^uint32(0)) - -//sys WSAStartup(verreq uint32, data *WSAData) (sockerr error) = ws2_32.WSAStartup -//sys WSACleanup() (err error) [failretval==socket_error] = ws2_32.WSACleanup -//sys WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) [failretval==socket_error] = ws2_32.WSAIoctl -//sys socket(af int32, typ int32, protocol int32) (handle Handle, err error) [failretval==InvalidHandle] = ws2_32.socket -//sys Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) [failretval==socket_error] = ws2_32.setsockopt -//sys Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) [failretval==socket_error] = ws2_32.getsockopt -//sys bind(s Handle, name unsafe.Pointer, namelen int32) (err error) [failretval==socket_error] = ws2_32.bind -//sys connect(s Handle, name unsafe.Pointer, namelen int32) (err error) [failretval==socket_error] = ws2_32.connect -//sys getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) [failretval==socket_error] = ws2_32.getsockname -//sys getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) [failretval==socket_error] = ws2_32.getpeername -//sys listen(s Handle, backlog int32) (err error) [failretval==socket_error] = ws2_32.listen -//sys shutdown(s Handle, how int32) (err error) [failretval==socket_error] = ws2_32.shutdown -//sys Closesocket(s Handle) (err error) [failretval==socket_error] = ws2_32.closesocket -//sys AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) = mswsock.AcceptEx -//sys GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) = mswsock.GetAcceptExSockaddrs -//sys WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) [failretval==socket_error] = ws2_32.WSARecv -//sys WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) [failretval==socket_error] = ws2_32.WSASend -//sys WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) [failretval==socket_error] = ws2_32.WSARecvFrom -//sys WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) [failretval==socket_error] = ws2_32.WSASendTo -//sys GetHostByName(name string) (h *Hostent, err error) [failretval==nil] = ws2_32.gethostbyname -//sys GetServByName(name string, proto string) (s *Servent, err error) [failretval==nil] = ws2_32.getservbyname -//sys Ntohs(netshort uint16) (u uint16) = ws2_32.ntohs -//sys GetProtoByName(name string) (p *Protoent, err error) [failretval==nil] = ws2_32.getprotobyname -//sys DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) = dnsapi.DnsQuery_W -//sys DnsRecordListFree(rl *DNSRecord, freetype uint32) = dnsapi.DnsRecordListFree -//sys DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) = dnsapi.DnsNameCompare_W -//sys GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) = ws2_32.GetAddrInfoW -//sys FreeAddrInfoW(addrinfo *AddrinfoW) = ws2_32.FreeAddrInfoW -//sys GetIfEntry(pIfRow *MibIfRow) (errcode error) = iphlpapi.GetIfEntry -//sys GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) = iphlpapi.GetAdaptersInfo -//sys SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) = kernel32.SetFileCompletionNotificationModes -//sys WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) [failretval==-1] = ws2_32.WSAEnumProtocolsW -//sys GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) = iphlpapi.GetAdaptersAddresses -//sys GetACP() (acp uint32) = kernel32.GetACP -//sys MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) = kernel32.MultiByteToWideChar - -// For testing: clients can set this flag to force -// creation of IPv6 sockets to return EAFNOSUPPORT. -var SocketDisableIPv6 bool - -type RawSockaddrInet4 struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]uint8 -} - -type RawSockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type RawSockaddr struct { - Family uint16 - Data [14]int8 -} - -type RawSockaddrAny struct { - Addr RawSockaddr - Pad [96]int8 -} - -type Sockaddr interface { - sockaddr() (ptr unsafe.Pointer, len int32, err error) // lowercase; only we can define Sockaddrs -} - -type SockaddrInet4 struct { - Port int - Addr [4]byte - raw RawSockaddrInet4 -} - -func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, int32, error) { - if sa.Port < 0 || sa.Port > 0xFFFF { - return nil, 0, syscall.EINVAL - } - sa.raw.Family = AF_INET - p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) - p[0] = byte(sa.Port >> 8) - p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } - return unsafe.Pointer(&sa.raw), int32(unsafe.Sizeof(sa.raw)), nil -} - -type SockaddrInet6 struct { - Port int - ZoneId uint32 - Addr [16]byte - raw RawSockaddrInet6 -} - -func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, int32, error) { - if sa.Port < 0 || sa.Port > 0xFFFF { - return nil, 0, syscall.EINVAL - } - sa.raw.Family = AF_INET6 - p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) - p[0] = byte(sa.Port >> 8) - p[1] = byte(sa.Port) - sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } - return unsafe.Pointer(&sa.raw), int32(unsafe.Sizeof(sa.raw)), nil -} - -type SockaddrUnix struct { - Name string -} - -func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, int32, error) { - // TODO(brainman): implement SockaddrUnix.sockaddr() - return nil, 0, syscall.EWINDOWS -} - -func (rsa *RawSockaddrAny) Sockaddr() (Sockaddr, error) { - switch rsa.Addr.Family { - case AF_UNIX: - return nil, syscall.EWINDOWS - - case AF_INET: - pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa)) - sa := new(SockaddrInet4) - p := (*[2]byte)(unsafe.Pointer(&pp.Port)) - sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } - return sa, nil - - case AF_INET6: - pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa)) - sa := new(SockaddrInet6) - p := (*[2]byte)(unsafe.Pointer(&pp.Port)) - sa.Port = int(p[0])<<8 + int(p[1]) - sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } - return sa, nil - } - return nil, syscall.EAFNOSUPPORT -} - -func Socket(domain, typ, proto int) (fd Handle, err error) { - if domain == AF_INET6 && SocketDisableIPv6 { - return InvalidHandle, syscall.EAFNOSUPPORT - } - return socket(int32(domain), int32(typ), int32(proto)) -} - -func SetsockoptInt(fd Handle, level, opt int, value int) (err error) { - v := int32(value) - return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&v)), int32(unsafe.Sizeof(v))) -} - -func Bind(fd Handle, sa Sockaddr) (err error) { - ptr, n, err := sa.sockaddr() - if err != nil { - return err - } - return bind(fd, ptr, n) -} - -func Connect(fd Handle, sa Sockaddr) (err error) { - ptr, n, err := sa.sockaddr() - if err != nil { - return err - } - return connect(fd, ptr, n) -} - -func Getsockname(fd Handle) (sa Sockaddr, err error) { - var rsa RawSockaddrAny - l := int32(unsafe.Sizeof(rsa)) - if err = getsockname(fd, &rsa, &l); err != nil { - return - } - return rsa.Sockaddr() -} - -func Getpeername(fd Handle) (sa Sockaddr, err error) { - var rsa RawSockaddrAny - l := int32(unsafe.Sizeof(rsa)) - if err = getpeername(fd, &rsa, &l); err != nil { - return - } - return rsa.Sockaddr() -} - -func Listen(s Handle, n int) (err error) { - return listen(s, int32(n)) -} - -func Shutdown(fd Handle, how int) (err error) { - return shutdown(fd, int32(how)) -} - -func WSASendto(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to Sockaddr, overlapped *Overlapped, croutine *byte) (err error) { - rsa, l, err := to.sockaddr() - if err != nil { - return err - } - return WSASendTo(s, bufs, bufcnt, sent, flags, (*RawSockaddrAny)(unsafe.Pointer(rsa)), l, overlapped, croutine) -} - -func LoadGetAddrInfo() error { - return procGetAddrInfoW.Find() -} - -var connectExFunc struct { - once sync.Once - addr uintptr - err error -} - -func LoadConnectEx() error { - connectExFunc.once.Do(func() { - var s Handle - s, connectExFunc.err = Socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) - if connectExFunc.err != nil { - return - } - defer CloseHandle(s) - var n uint32 - connectExFunc.err = WSAIoctl(s, - SIO_GET_EXTENSION_FUNCTION_POINTER, - (*byte)(unsafe.Pointer(&WSAID_CONNECTEX)), - uint32(unsafe.Sizeof(WSAID_CONNECTEX)), - (*byte)(unsafe.Pointer(&connectExFunc.addr)), - uint32(unsafe.Sizeof(connectExFunc.addr)), - &n, nil, 0) - }) - return connectExFunc.err -} - -func connectEx(s Handle, name unsafe.Pointer, namelen int32, sendBuf *byte, sendDataLen uint32, bytesSent *uint32, overlapped *Overlapped) (err error) { - r1, _, e1 := syscall.Syscall9(connectExFunc.addr, 7, uintptr(s), uintptr(name), uintptr(namelen), uintptr(unsafe.Pointer(sendBuf)), uintptr(sendDataLen), uintptr(unsafe.Pointer(bytesSent)), uintptr(unsafe.Pointer(overlapped)), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = error(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func ConnectEx(fd Handle, sa Sockaddr, sendBuf *byte, sendDataLen uint32, bytesSent *uint32, overlapped *Overlapped) error { - err := LoadConnectEx() - if err != nil { - return errorspkg.New("failed to find ConnectEx: " + err.Error()) - } - ptr, n, err := sa.sockaddr() - if err != nil { - return err - } - return connectEx(fd, ptr, n, sendBuf, sendDataLen, bytesSent, overlapped) -} - -// Invented structures to support what package os expects. -type Rusage struct { - CreationTime Filetime - ExitTime Filetime - KernelTime Filetime - UserTime Filetime -} - -type WaitStatus struct { - ExitCode uint32 -} - -func (w WaitStatus) Exited() bool { return true } - -func (w WaitStatus) ExitStatus() int { return int(w.ExitCode) } - -func (w WaitStatus) Signal() Signal { return -1 } - -func (w WaitStatus) CoreDump() bool { return false } - -func (w WaitStatus) Stopped() bool { return false } - -func (w WaitStatus) Continued() bool { return false } - -func (w WaitStatus) StopSignal() Signal { return -1 } - -func (w WaitStatus) Signaled() bool { return false } - -func (w WaitStatus) TrapCause() int { return -1 } - -// Timespec is an invented structure on Windows, but here for -// consistency with the corresponding package for other operating systems. -type Timespec struct { - Sec int64 - Nsec int64 -} - -func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } - -func NsecToTimespec(nsec int64) (ts Timespec) { - ts.Sec = nsec / 1e9 - ts.Nsec = nsec % 1e9 - return -} - -// TODO(brainman): fix all needed for net - -func Accept(fd Handle) (nfd Handle, sa Sockaddr, err error) { return 0, nil, syscall.EWINDOWS } -func Recvfrom(fd Handle, p []byte, flags int) (n int, from Sockaddr, err error) { - return 0, nil, syscall.EWINDOWS -} -func Sendto(fd Handle, p []byte, flags int, to Sockaddr) (err error) { return syscall.EWINDOWS } -func SetsockoptTimeval(fd Handle, level, opt int, tv *Timeval) (err error) { return syscall.EWINDOWS } - -// The Linger struct is wrong but we only noticed after Go 1. -// sysLinger is the real system call structure. - -// BUG(brainman): The definition of Linger is not appropriate for direct use -// with Setsockopt and Getsockopt. -// Use SetsockoptLinger instead. - -type Linger struct { - Onoff int32 - Linger int32 -} - -type sysLinger struct { - Onoff uint16 - Linger uint16 -} - -type IPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type IPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -func GetsockoptInt(fd Handle, level, opt int) (int, error) { return -1, syscall.EWINDOWS } - -func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) { - sys := sysLinger{Onoff: uint16(l.Onoff), Linger: uint16(l.Linger)} - return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&sys)), int32(unsafe.Sizeof(sys))) -} - -func SetsockoptInet4Addr(fd Handle, level, opt int, value [4]byte) (err error) { - return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&value[0])), 4) -} -func SetsockoptIPMreq(fd Handle, level, opt int, mreq *IPMreq) (err error) { - return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq))) -} -func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) { - return syscall.EWINDOWS -} - -func Getpid() (pid int) { return int(getCurrentProcessId()) } - -func FindFirstFile(name *uint16, data *Win32finddata) (handle Handle, err error) { - // NOTE(rsc): The Win32finddata struct is wrong for the system call: - // the two paths are each one uint16 short. Use the correct struct, - // a win32finddata1, and then copy the results out. - // There is no loss of expressivity here, because the final - // uint16, if it is used, is supposed to be a NUL, and Go doesn't need that. - // For Go 1.1, we might avoid the allocation of win32finddata1 here - // by adding a final Bug [2]uint16 field to the struct and then - // adjusting the fields in the result directly. - var data1 win32finddata1 - handle, err = findFirstFile1(name, &data1) - if err == nil { - copyFindData(data, &data1) - } - return -} - -func FindNextFile(handle Handle, data *Win32finddata) (err error) { - var data1 win32finddata1 - err = findNextFile1(handle, &data1) - if err == nil { - copyFindData(data, &data1) - } - return -} - -func getProcessEntry(pid int) (*ProcessEntry32, error) { - snapshot, err := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) - if err != nil { - return nil, err - } - defer CloseHandle(snapshot) - var procEntry ProcessEntry32 - procEntry.Size = uint32(unsafe.Sizeof(procEntry)) - if err = Process32First(snapshot, &procEntry); err != nil { - return nil, err - } - for { - if procEntry.ProcessID == uint32(pid) { - return &procEntry, nil - } - err = Process32Next(snapshot, &procEntry) - if err != nil { - return nil, err - } - } -} - -func Getppid() (ppid int) { - pe, err := getProcessEntry(Getpid()) - if err != nil { - return -1 - } - return int(pe.ParentProcessID) -} - -// TODO(brainman): fix all needed for os -func Fchdir(fd Handle) (err error) { return syscall.EWINDOWS } -func Link(oldpath, newpath string) (err error) { return syscall.EWINDOWS } -func Symlink(path, link string) (err error) { return syscall.EWINDOWS } - -func Fchmod(fd Handle, mode uint32) (err error) { return syscall.EWINDOWS } -func Chown(path string, uid int, gid int) (err error) { return syscall.EWINDOWS } -func Lchown(path string, uid int, gid int) (err error) { return syscall.EWINDOWS } -func Fchown(fd Handle, uid int, gid int) (err error) { return syscall.EWINDOWS } - -func Getuid() (uid int) { return -1 } -func Geteuid() (euid int) { return -1 } -func Getgid() (gid int) { return -1 } -func Getegid() (egid int) { return -1 } -func Getgroups() (gids []int, err error) { return nil, syscall.EWINDOWS } - -type Signal int - -func (s Signal) Signal() {} - -func (s Signal) String() string { - if 0 <= s && int(s) < len(signals) { - str := signals[s] - if str != "" { - return str - } - } - return "signal " + itoa(int(s)) -} - -func LoadCreateSymbolicLink() error { - return procCreateSymbolicLinkW.Find() -} - -// Readlink returns the destination of the named symbolic link. -func Readlink(path string, buf []byte) (n int, err error) { - fd, err := CreateFile(StringToUTF16Ptr(path), GENERIC_READ, 0, nil, OPEN_EXISTING, - FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, 0) - if err != nil { - return -1, err - } - defer CloseHandle(fd) - - rdbbuf := make([]byte, MAXIMUM_REPARSE_DATA_BUFFER_SIZE) - var bytesReturned uint32 - err = DeviceIoControl(fd, FSCTL_GET_REPARSE_POINT, nil, 0, &rdbbuf[0], uint32(len(rdbbuf)), &bytesReturned, nil) - if err != nil { - return -1, err - } - - rdb := (*reparseDataBuffer)(unsafe.Pointer(&rdbbuf[0])) - var s string - switch rdb.ReparseTag { - case IO_REPARSE_TAG_SYMLINK: - data := (*symbolicLinkReparseBuffer)(unsafe.Pointer(&rdb.reparseBuffer)) - p := (*[0xffff]uint16)(unsafe.Pointer(&data.PathBuffer[0])) - s = UTF16ToString(p[data.PrintNameOffset/2 : (data.PrintNameLength-data.PrintNameOffset)/2]) - case IO_REPARSE_TAG_MOUNT_POINT: - data := (*mountPointReparseBuffer)(unsafe.Pointer(&rdb.reparseBuffer)) - p := (*[0xffff]uint16)(unsafe.Pointer(&data.PathBuffer[0])) - s = UTF16ToString(p[data.PrintNameOffset/2 : (data.PrintNameLength-data.PrintNameOffset)/2]) - default: - // the path is not a symlink or junction but another type of reparse - // point - return -1, syscall.ENOENT - } - n = copy(buf, []byte(s)) - - return n, nil -} diff --git a/vendor/golang.org/x/sys/windows/syscall_windows_test.go b/vendor/golang.org/x/sys/windows/syscall_windows_test.go deleted file mode 100644 index 0f73c11ba..000000000 --- a/vendor/golang.org/x/sys/windows/syscall_windows_test.go +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package windows_test - -import ( - "io/ioutil" - "os" - "path/filepath" - "syscall" - "testing" - "unsafe" - - "golang.org/x/sys/windows" -) - -func TestWin32finddata(t *testing.T) { - dir, err := ioutil.TempDir("", "go-build") - if err != nil { - t.Fatalf("failed to create temp directory: %v", err) - } - defer os.RemoveAll(dir) - - path := filepath.Join(dir, "long_name.and_extension") - f, err := os.Create(path) - if err != nil { - t.Fatalf("failed to create %v: %v", path, err) - } - f.Close() - - type X struct { - fd windows.Win32finddata - got byte - pad [10]byte // to protect ourselves - - } - var want byte = 2 // it is unlikely to have this character in the filename - x := X{got: want} - - pathp, _ := windows.UTF16PtrFromString(path) - h, err := windows.FindFirstFile(pathp, &(x.fd)) - if err != nil { - t.Fatalf("FindFirstFile failed: %v", err) - } - err = windows.FindClose(h) - if err != nil { - t.Fatalf("FindClose failed: %v", err) - } - - if x.got != want { - t.Fatalf("memory corruption: want=%d got=%d", want, x.got) - } -} - -func TestFormatMessage(t *testing.T) { - dll := windows.MustLoadDLL("pdh.dll") - - pdhOpenQuery := func(datasrc *uint16, userdata uint32, query *windows.Handle) (errno uintptr) { - r0, _, _ := syscall.Syscall(dll.MustFindProc("PdhOpenQueryW").Addr(), 3, uintptr(unsafe.Pointer(datasrc)), uintptr(userdata), uintptr(unsafe.Pointer(query))) - return r0 - } - - pdhCloseQuery := func(query windows.Handle) (errno uintptr) { - r0, _, _ := syscall.Syscall(dll.MustFindProc("PdhCloseQuery").Addr(), 1, uintptr(query), 0, 0) - return r0 - } - - var q windows.Handle - name, err := windows.UTF16PtrFromString("no_such_source") - if err != nil { - t.Fatal(err) - } - errno := pdhOpenQuery(name, 0, &q) - if errno == 0 { - pdhCloseQuery(q) - t.Fatal("PdhOpenQuery succeeded, but expected to fail.") - } - - const flags uint32 = syscall.FORMAT_MESSAGE_FROM_HMODULE | syscall.FORMAT_MESSAGE_ARGUMENT_ARRAY | syscall.FORMAT_MESSAGE_IGNORE_INSERTS - buf := make([]uint16, 300) - _, err = windows.FormatMessage(flags, uintptr(dll.Handle), uint32(errno), 0, buf, nil) - if err != nil { - t.Fatal("FormatMessage for handle=%x and errno=%x failed: %v", dll.Handle, errno, err) - } -} - -func abort(funcname string, err error) { - panic(funcname + " failed: " + err.Error()) -} - -func ExampleLoadLibrary() { - h, err := windows.LoadLibrary("kernel32.dll") - if err != nil { - abort("LoadLibrary", err) - } - defer windows.FreeLibrary(h) - proc, err := windows.GetProcAddress(h, "GetVersion") - if err != nil { - abort("GetProcAddress", err) - } - r, _, _ := syscall.Syscall(uintptr(proc), 0, 0, 0, 0) - major := byte(r) - minor := uint8(r >> 8) - build := uint16(r >> 16) - print("windows version ", major, ".", minor, " (Build ", build, ")\n") -} diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go deleted file mode 100644 index f10ebbf2b..000000000 --- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ /dev/null @@ -1,2270 +0,0 @@ -// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT - -package windows - -import ( - "syscall" - "unsafe" -) - -var _ unsafe.Pointer - -// Do the interface allocations only once for common -// Errno values. -const ( - errnoERROR_IO_PENDING = 997 -) - -var ( - errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) -) - -// errnoErr returns common boxed Errno values, to prevent -// allocations at runtime. -func errnoErr(e syscall.Errno) error { - switch e { - case 0: - return nil - case errnoERROR_IO_PENDING: - return errERROR_IO_PENDING - } - // TODO: add more here, after collecting data on the common - // error values see on Windows. (perhaps when running - // all.bat?) - return e -} - -var ( - modadvapi32 = NewLazySystemDLL("advapi32.dll") - modkernel32 = NewLazySystemDLL("kernel32.dll") - modshell32 = NewLazySystemDLL("shell32.dll") - modmswsock = NewLazySystemDLL("mswsock.dll") - modcrypt32 = NewLazySystemDLL("crypt32.dll") - modws2_32 = NewLazySystemDLL("ws2_32.dll") - moddnsapi = NewLazySystemDLL("dnsapi.dll") - modiphlpapi = NewLazySystemDLL("iphlpapi.dll") - modsecur32 = NewLazySystemDLL("secur32.dll") - modnetapi32 = NewLazySystemDLL("netapi32.dll") - moduserenv = NewLazySystemDLL("userenv.dll") - - procRegisterEventSourceW = modadvapi32.NewProc("RegisterEventSourceW") - procDeregisterEventSource = modadvapi32.NewProc("DeregisterEventSource") - procReportEventW = modadvapi32.NewProc("ReportEventW") - procOpenSCManagerW = modadvapi32.NewProc("OpenSCManagerW") - procCloseServiceHandle = modadvapi32.NewProc("CloseServiceHandle") - procCreateServiceW = modadvapi32.NewProc("CreateServiceW") - procOpenServiceW = modadvapi32.NewProc("OpenServiceW") - procDeleteService = modadvapi32.NewProc("DeleteService") - procStartServiceW = modadvapi32.NewProc("StartServiceW") - procQueryServiceStatus = modadvapi32.NewProc("QueryServiceStatus") - procControlService = modadvapi32.NewProc("ControlService") - procStartServiceCtrlDispatcherW = modadvapi32.NewProc("StartServiceCtrlDispatcherW") - procSetServiceStatus = modadvapi32.NewProc("SetServiceStatus") - procChangeServiceConfigW = modadvapi32.NewProc("ChangeServiceConfigW") - procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW") - procChangeServiceConfig2W = modadvapi32.NewProc("ChangeServiceConfig2W") - procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W") - procGetLastError = modkernel32.NewProc("GetLastError") - procLoadLibraryW = modkernel32.NewProc("LoadLibraryW") - procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW") - procFreeLibrary = modkernel32.NewProc("FreeLibrary") - procGetProcAddress = modkernel32.NewProc("GetProcAddress") - procGetVersion = modkernel32.NewProc("GetVersion") - procFormatMessageW = modkernel32.NewProc("FormatMessageW") - procExitProcess = modkernel32.NewProc("ExitProcess") - procCreateFileW = modkernel32.NewProc("CreateFileW") - procReadFile = modkernel32.NewProc("ReadFile") - procWriteFile = modkernel32.NewProc("WriteFile") - procSetFilePointer = modkernel32.NewProc("SetFilePointer") - procCloseHandle = modkernel32.NewProc("CloseHandle") - procGetStdHandle = modkernel32.NewProc("GetStdHandle") - procFindFirstFileW = modkernel32.NewProc("FindFirstFileW") - procFindNextFileW = modkernel32.NewProc("FindNextFileW") - procFindClose = modkernel32.NewProc("FindClose") - procGetFileInformationByHandle = modkernel32.NewProc("GetFileInformationByHandle") - procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW") - procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW") - procCreateDirectoryW = modkernel32.NewProc("CreateDirectoryW") - procRemoveDirectoryW = modkernel32.NewProc("RemoveDirectoryW") - procDeleteFileW = modkernel32.NewProc("DeleteFileW") - procMoveFileW = modkernel32.NewProc("MoveFileW") - procMoveFileExW = modkernel32.NewProc("MoveFileExW") - procGetComputerNameW = modkernel32.NewProc("GetComputerNameW") - procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW") - procSetEndOfFile = modkernel32.NewProc("SetEndOfFile") - procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime") - procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation") - procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort") - procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus") - procPostQueuedCompletionStatus = modkernel32.NewProc("PostQueuedCompletionStatus") - procCancelIo = modkernel32.NewProc("CancelIo") - procCancelIoEx = modkernel32.NewProc("CancelIoEx") - procCreateProcessW = modkernel32.NewProc("CreateProcessW") - procOpenProcess = modkernel32.NewProc("OpenProcess") - procTerminateProcess = modkernel32.NewProc("TerminateProcess") - procGetExitCodeProcess = modkernel32.NewProc("GetExitCodeProcess") - procGetStartupInfoW = modkernel32.NewProc("GetStartupInfoW") - procGetCurrentProcess = modkernel32.NewProc("GetCurrentProcess") - procGetProcessTimes = modkernel32.NewProc("GetProcessTimes") - procDuplicateHandle = modkernel32.NewProc("DuplicateHandle") - procWaitForSingleObject = modkernel32.NewProc("WaitForSingleObject") - procGetTempPathW = modkernel32.NewProc("GetTempPathW") - procCreatePipe = modkernel32.NewProc("CreatePipe") - procGetFileType = modkernel32.NewProc("GetFileType") - procCryptAcquireContextW = modadvapi32.NewProc("CryptAcquireContextW") - procCryptReleaseContext = modadvapi32.NewProc("CryptReleaseContext") - procCryptGenRandom = modadvapi32.NewProc("CryptGenRandom") - procGetEnvironmentStringsW = modkernel32.NewProc("GetEnvironmentStringsW") - procFreeEnvironmentStringsW = modkernel32.NewProc("FreeEnvironmentStringsW") - procGetEnvironmentVariableW = modkernel32.NewProc("GetEnvironmentVariableW") - procSetEnvironmentVariableW = modkernel32.NewProc("SetEnvironmentVariableW") - procSetFileTime = modkernel32.NewProc("SetFileTime") - procGetFileAttributesW = modkernel32.NewProc("GetFileAttributesW") - procSetFileAttributesW = modkernel32.NewProc("SetFileAttributesW") - procGetFileAttributesExW = modkernel32.NewProc("GetFileAttributesExW") - procGetCommandLineW = modkernel32.NewProc("GetCommandLineW") - procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW") - procLocalFree = modkernel32.NewProc("LocalFree") - procSetHandleInformation = modkernel32.NewProc("SetHandleInformation") - procFlushFileBuffers = modkernel32.NewProc("FlushFileBuffers") - procGetFullPathNameW = modkernel32.NewProc("GetFullPathNameW") - procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW") - procGetShortPathNameW = modkernel32.NewProc("GetShortPathNameW") - procCreateFileMappingW = modkernel32.NewProc("CreateFileMappingW") - procMapViewOfFile = modkernel32.NewProc("MapViewOfFile") - procUnmapViewOfFile = modkernel32.NewProc("UnmapViewOfFile") - procFlushViewOfFile = modkernel32.NewProc("FlushViewOfFile") - procVirtualLock = modkernel32.NewProc("VirtualLock") - procVirtualUnlock = modkernel32.NewProc("VirtualUnlock") - procTransmitFile = modmswsock.NewProc("TransmitFile") - procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW") - procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW") - procCertOpenStore = modcrypt32.NewProc("CertOpenStore") - procCertEnumCertificatesInStore = modcrypt32.NewProc("CertEnumCertificatesInStore") - procCertAddCertificateContextToStore = modcrypt32.NewProc("CertAddCertificateContextToStore") - procCertCloseStore = modcrypt32.NewProc("CertCloseStore") - procCertGetCertificateChain = modcrypt32.NewProc("CertGetCertificateChain") - procCertFreeCertificateChain = modcrypt32.NewProc("CertFreeCertificateChain") - procCertCreateCertificateContext = modcrypt32.NewProc("CertCreateCertificateContext") - procCertFreeCertificateContext = modcrypt32.NewProc("CertFreeCertificateContext") - procCertVerifyCertificateChainPolicy = modcrypt32.NewProc("CertVerifyCertificateChainPolicy") - procRegOpenKeyExW = modadvapi32.NewProc("RegOpenKeyExW") - procRegCloseKey = modadvapi32.NewProc("RegCloseKey") - procRegQueryInfoKeyW = modadvapi32.NewProc("RegQueryInfoKeyW") - procRegEnumKeyExW = modadvapi32.NewProc("RegEnumKeyExW") - procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW") - procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId") - procGetConsoleMode = modkernel32.NewProc("GetConsoleMode") - procWriteConsoleW = modkernel32.NewProc("WriteConsoleW") - procReadConsoleW = modkernel32.NewProc("ReadConsoleW") - procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot") - procProcess32FirstW = modkernel32.NewProc("Process32FirstW") - procProcess32NextW = modkernel32.NewProc("Process32NextW") - procDeviceIoControl = modkernel32.NewProc("DeviceIoControl") - procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW") - procCreateHardLinkW = modkernel32.NewProc("CreateHardLinkW") - procGetCurrentThreadId = modkernel32.NewProc("GetCurrentThreadId") - procCreateEventW = modkernel32.NewProc("CreateEventW") - procSetEvent = modkernel32.NewProc("SetEvent") - procWSAStartup = modws2_32.NewProc("WSAStartup") - procWSACleanup = modws2_32.NewProc("WSACleanup") - procWSAIoctl = modws2_32.NewProc("WSAIoctl") - procsocket = modws2_32.NewProc("socket") - procsetsockopt = modws2_32.NewProc("setsockopt") - procgetsockopt = modws2_32.NewProc("getsockopt") - procbind = modws2_32.NewProc("bind") - procconnect = modws2_32.NewProc("connect") - procgetsockname = modws2_32.NewProc("getsockname") - procgetpeername = modws2_32.NewProc("getpeername") - proclisten = modws2_32.NewProc("listen") - procshutdown = modws2_32.NewProc("shutdown") - procclosesocket = modws2_32.NewProc("closesocket") - procAcceptEx = modmswsock.NewProc("AcceptEx") - procGetAcceptExSockaddrs = modmswsock.NewProc("GetAcceptExSockaddrs") - procWSARecv = modws2_32.NewProc("WSARecv") - procWSASend = modws2_32.NewProc("WSASend") - procWSARecvFrom = modws2_32.NewProc("WSARecvFrom") - procWSASendTo = modws2_32.NewProc("WSASendTo") - procgethostbyname = modws2_32.NewProc("gethostbyname") - procgetservbyname = modws2_32.NewProc("getservbyname") - procntohs = modws2_32.NewProc("ntohs") - procgetprotobyname = modws2_32.NewProc("getprotobyname") - procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W") - procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree") - procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W") - procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW") - procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW") - procGetIfEntry = modiphlpapi.NewProc("GetIfEntry") - procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo") - procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes") - procWSAEnumProtocolsW = modws2_32.NewProc("WSAEnumProtocolsW") - procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses") - procGetACP = modkernel32.NewProc("GetACP") - procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar") - procTranslateNameW = modsecur32.NewProc("TranslateNameW") - procGetUserNameExW = modsecur32.NewProc("GetUserNameExW") - procNetUserGetInfo = modnetapi32.NewProc("NetUserGetInfo") - procNetGetJoinInformation = modnetapi32.NewProc("NetGetJoinInformation") - procNetApiBufferFree = modnetapi32.NewProc("NetApiBufferFree") - procLookupAccountSidW = modadvapi32.NewProc("LookupAccountSidW") - procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW") - procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW") - procConvertStringSidToSidW = modadvapi32.NewProc("ConvertStringSidToSidW") - procGetLengthSid = modadvapi32.NewProc("GetLengthSid") - procCopySid = modadvapi32.NewProc("CopySid") - procAllocateAndInitializeSid = modadvapi32.NewProc("AllocateAndInitializeSid") - procFreeSid = modadvapi32.NewProc("FreeSid") - procEqualSid = modadvapi32.NewProc("EqualSid") - procOpenProcessToken = modadvapi32.NewProc("OpenProcessToken") - procGetTokenInformation = modadvapi32.NewProc("GetTokenInformation") - procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW") -) - -func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall(procRegisterEventSourceW.Addr(), 2, uintptr(unsafe.Pointer(uncServerName)), uintptr(unsafe.Pointer(sourceName)), 0) - handle = Handle(r0) - if handle == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func DeregisterEventSource(handle Handle) (err error) { - r1, _, e1 := syscall.Syscall(procDeregisterEventSource.Addr(), 1, uintptr(handle), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) { - r1, _, e1 := syscall.Syscall9(procReportEventW.Addr(), 9, uintptr(log), uintptr(etype), uintptr(category), uintptr(eventId), uintptr(usrSId), uintptr(numStrings), uintptr(dataSize), uintptr(unsafe.Pointer(strings)), uintptr(unsafe.Pointer(rawData))) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall(procOpenSCManagerW.Addr(), 3, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(databaseName)), uintptr(access)) - handle = Handle(r0) - if handle == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CloseServiceHandle(handle Handle) (err error) { - r1, _, e1 := syscall.Syscall(procCloseServiceHandle.Addr(), 1, uintptr(handle), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CreateService(mgr Handle, serviceName *uint16, displayName *uint16, access uint32, srvType uint32, startType uint32, errCtl uint32, pathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall15(procCreateServiceW.Addr(), 13, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(unsafe.Pointer(displayName)), uintptr(access), uintptr(srvType), uintptr(startType), uintptr(errCtl), uintptr(unsafe.Pointer(pathName)), uintptr(unsafe.Pointer(loadOrderGroup)), uintptr(unsafe.Pointer(tagId)), uintptr(unsafe.Pointer(dependencies)), uintptr(unsafe.Pointer(serviceStartName)), uintptr(unsafe.Pointer(password)), 0, 0) - handle = Handle(r0) - if handle == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall(procOpenServiceW.Addr(), 3, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(access)) - handle = Handle(r0) - if handle == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func DeleteService(service Handle) (err error) { - r1, _, e1 := syscall.Syscall(procDeleteService.Addr(), 1, uintptr(service), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func StartService(service Handle, numArgs uint32, argVectors **uint16) (err error) { - r1, _, e1 := syscall.Syscall(procStartServiceW.Addr(), 3, uintptr(service), uintptr(numArgs), uintptr(unsafe.Pointer(argVectors))) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) { - r1, _, e1 := syscall.Syscall(procQueryServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(status)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err error) { - r1, _, e1 := syscall.Syscall(procControlService.Addr(), 3, uintptr(service), uintptr(control), uintptr(unsafe.Pointer(status))) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) { - r1, _, e1 := syscall.Syscall(procStartServiceCtrlDispatcherW.Addr(), 1, uintptr(unsafe.Pointer(serviceTable)), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error) { - r1, _, e1 := syscall.Syscall(procSetServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(serviceStatus)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func ChangeServiceConfig(service Handle, serviceType uint32, startType uint32, errorControl uint32, binaryPathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16, displayName *uint16) (err error) { - r1, _, e1 := syscall.Syscall12(procChangeServiceConfigW.Addr(), 11, uintptr(service), uintptr(serviceType), uintptr(startType), uintptr(errorControl), uintptr(unsafe.Pointer(binaryPathName)), uintptr(unsafe.Pointer(loadOrderGroup)), uintptr(unsafe.Pointer(tagId)), uintptr(unsafe.Pointer(dependencies)), uintptr(unsafe.Pointer(serviceStartName)), uintptr(unsafe.Pointer(password)), uintptr(unsafe.Pointer(displayName)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) { - r1, _, e1 := syscall.Syscall6(procQueryServiceConfigW.Addr(), 4, uintptr(service), uintptr(unsafe.Pointer(serviceConfig)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) { - r1, _, e1 := syscall.Syscall(procChangeServiceConfig2W.Addr(), 3, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(info))) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) { - r1, _, e1 := syscall.Syscall6(procQueryServiceConfig2W.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetLastError() (lasterr error) { - r0, _, _ := syscall.Syscall(procGetLastError.Addr(), 0, 0, 0, 0) - if r0 != 0 { - lasterr = syscall.Errno(r0) - } - return -} - -func LoadLibrary(libname string) (handle Handle, err error) { - var _p0 *uint16 - _p0, err = syscall.UTF16PtrFromString(libname) - if err != nil { - return - } - return _LoadLibrary(_p0) -} - -func _LoadLibrary(libname *uint16) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(libname)), 0, 0) - handle = Handle(r0) - if handle == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func LoadLibraryEx(libname string, zero Handle, flags uintptr) (handle Handle, err error) { - var _p0 *uint16 - _p0, err = syscall.UTF16PtrFromString(libname) - if err != nil { - return - } - return _LoadLibraryEx(_p0, zero, flags) -} - -func _LoadLibraryEx(libname *uint16, zero Handle, flags uintptr) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall(procLoadLibraryExW.Addr(), 3, uintptr(unsafe.Pointer(libname)), uintptr(zero), uintptr(flags)) - handle = Handle(r0) - if handle == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func FreeLibrary(handle Handle) (err error) { - r1, _, e1 := syscall.Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetProcAddress(module Handle, procname string) (proc uintptr, err error) { - var _p0 *byte - _p0, err = syscall.BytePtrFromString(procname) - if err != nil { - return - } - return _GetProcAddress(module, _p0) -} - -func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) { - r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), uintptr(unsafe.Pointer(procname)), 0) - proc = uintptr(r0) - if proc == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetVersion() (ver uint32, err error) { - r0, _, e1 := syscall.Syscall(procGetVersion.Addr(), 0, 0, 0, 0) - ver = uint32(r0) - if ver == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) { - var _p0 *uint16 - if len(buf) > 0 { - _p0 = &buf[0] - } - r0, _, e1 := syscall.Syscall9(procFormatMessageW.Addr(), 7, uintptr(flags), uintptr(msgsrc), uintptr(msgid), uintptr(langid), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(args)), 0, 0) - n = uint32(r0) - if n == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func ExitProcess(exitcode uint32) { - syscall.Syscall(procExitProcess.Addr(), 1, uintptr(exitcode), 0, 0) - return -} - -func CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile int32) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall9(procCreateFileW.Addr(), 7, uintptr(unsafe.Pointer(name)), uintptr(access), uintptr(mode), uintptr(unsafe.Pointer(sa)), uintptr(createmode), uintptr(attrs), uintptr(templatefile), 0, 0) - handle = Handle(r0) - if handle == InvalidHandle { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) { - var _p0 *byte - if len(buf) > 0 { - _p0 = &buf[0] - } - r1, _, e1 := syscall.Syscall6(procReadFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) { - var _p0 *byte - if len(buf) > 0 { - _p0 = &buf[0] - } - r1, _, e1 := syscall.Syscall6(procWriteFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) { - r0, _, e1 := syscall.Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0) - newlowoffset = uint32(r0) - if newlowoffset == 0xffffffff { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CloseHandle(handle Handle) (err error) { - r1, _, e1 := syscall.Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetStdHandle(stdhandle int) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall(procGetStdHandle.Addr(), 1, uintptr(stdhandle), 0, 0) - handle = Handle(r0) - if handle == InvalidHandle { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall(procFindFirstFileW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(data)), 0) - handle = Handle(r0) - if handle == InvalidHandle { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func findNextFile1(handle Handle, data *win32finddata1) (err error) { - r1, _, e1 := syscall.Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func FindClose(handle Handle) (err error) { - r1, _, e1 := syscall.Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) { - r1, _, e1 := syscall.Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) { - r0, _, e1 := syscall.Syscall(procGetCurrentDirectoryW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0) - n = uint32(r0) - if n == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func SetCurrentDirectory(path *uint16) (err error) { - r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) { - r1, _, e1 := syscall.Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func RemoveDirectory(path *uint16) (err error) { - r1, _, e1 := syscall.Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func DeleteFile(path *uint16) (err error) { - r1, _, e1 := syscall.Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func MoveFile(from *uint16, to *uint16) (err error) { - r1, _, e1 := syscall.Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) { - r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags)) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetComputerName(buf *uint16, n *uint32) (err error) { - r1, _, e1 := syscall.Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) { - r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nametype), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n))) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func SetEndOfFile(handle Handle) (err error) { - r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetSystemTimeAsFileTime(time *Filetime) { - syscall.Syscall(procGetSystemTimeAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0) - return -} - -func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) { - r0, _, e1 := syscall.Syscall(procGetTimeZoneInformation.Addr(), 1, uintptr(unsafe.Pointer(tzi)), 0, 0) - rc = uint32(r0) - if rc == 0xffffffff { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0) - handle = Handle(r0) - if handle == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) { - r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) { - r1, _, e1 := syscall.Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CancelIo(s Handle) (err error) { - r1, _, e1 := syscall.Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CancelIoEx(s Handle, o *Overlapped) (err error) { - r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(s), uintptr(unsafe.Pointer(o)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) { - var _p0 uint32 - if inheritHandles { - _p0 = 1 - } else { - _p0 = 0 - } - r1, _, e1 := syscall.Syscall12(procCreateProcessW.Addr(), 10, uintptr(unsafe.Pointer(appName)), uintptr(unsafe.Pointer(commandLine)), uintptr(unsafe.Pointer(procSecurity)), uintptr(unsafe.Pointer(threadSecurity)), uintptr(_p0), uintptr(creationFlags), uintptr(unsafe.Pointer(env)), uintptr(unsafe.Pointer(currentDir)), uintptr(unsafe.Pointer(startupInfo)), uintptr(unsafe.Pointer(outProcInfo)), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func OpenProcess(da uint32, inheritHandle bool, pid uint32) (handle Handle, err error) { - var _p0 uint32 - if inheritHandle { - _p0 = 1 - } else { - _p0 = 0 - } - r0, _, e1 := syscall.Syscall(procOpenProcess.Addr(), 3, uintptr(da), uintptr(_p0), uintptr(pid)) - handle = Handle(r0) - if handle == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func TerminateProcess(handle Handle, exitcode uint32) (err error) { - r1, _, e1 := syscall.Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) { - r1, _, e1 := syscall.Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetStartupInfo(startupInfo *StartupInfo) (err error) { - r1, _, e1 := syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetCurrentProcess() (pseudoHandle Handle, err error) { - r0, _, e1 := syscall.Syscall(procGetCurrentProcess.Addr(), 0, 0, 0, 0) - pseudoHandle = Handle(r0) - if pseudoHandle == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) { - r1, _, e1 := syscall.Syscall6(procGetProcessTimes.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(creationTime)), uintptr(unsafe.Pointer(exitTime)), uintptr(unsafe.Pointer(kernelTime)), uintptr(unsafe.Pointer(userTime)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) { - var _p0 uint32 - if bInheritHandle { - _p0 = 1 - } else { - _p0 = 0 - } - r1, _, e1 := syscall.Syscall9(procDuplicateHandle.Addr(), 7, uintptr(hSourceProcessHandle), uintptr(hSourceHandle), uintptr(hTargetProcessHandle), uintptr(unsafe.Pointer(lpTargetHandle)), uintptr(dwDesiredAccess), uintptr(_p0), uintptr(dwOptions), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) { - r0, _, e1 := syscall.Syscall(procWaitForSingleObject.Addr(), 2, uintptr(handle), uintptr(waitMilliseconds), 0) - event = uint32(r0) - if event == 0xffffffff { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) { - r0, _, e1 := syscall.Syscall(procGetTempPathW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0) - n = uint32(r0) - if n == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error) { - r1, _, e1 := syscall.Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetFileType(filehandle Handle) (n uint32, err error) { - r0, _, e1 := syscall.Syscall(procGetFileType.Addr(), 1, uintptr(filehandle), 0, 0) - n = uint32(r0) - if n == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) { - r1, _, e1 := syscall.Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CryptReleaseContext(provhandle Handle, flags uint32) (err error) { - r1, _, e1 := syscall.Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) { - r1, _, e1 := syscall.Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf))) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetEnvironmentStrings() (envs *uint16, err error) { - r0, _, e1 := syscall.Syscall(procGetEnvironmentStringsW.Addr(), 0, 0, 0, 0) - envs = (*uint16)(unsafe.Pointer(r0)) - if envs == nil { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func FreeEnvironmentStrings(envs *uint16) (err error) { - r1, _, e1 := syscall.Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) { - r0, _, e1 := syscall.Syscall(procGetEnvironmentVariableW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(size)) - n = uint32(r0) - if n == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func SetEnvironmentVariable(name *uint16, value *uint16) (err error) { - r1, _, e1 := syscall.Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) { - r1, _, e1 := syscall.Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetFileAttributes(name *uint16) (attrs uint32, err error) { - r0, _, e1 := syscall.Syscall(procGetFileAttributesW.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0) - attrs = uint32(r0) - if attrs == INVALID_FILE_ATTRIBUTES { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func SetFileAttributes(name *uint16, attrs uint32) (err error) { - r1, _, e1 := syscall.Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) { - r1, _, e1 := syscall.Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info))) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetCommandLine() (cmd *uint16) { - r0, _, _ := syscall.Syscall(procGetCommandLineW.Addr(), 0, 0, 0, 0) - cmd = (*uint16)(unsafe.Pointer(r0)) - return -} - -func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) { - r0, _, e1 := syscall.Syscall(procCommandLineToArgvW.Addr(), 2, uintptr(unsafe.Pointer(cmd)), uintptr(unsafe.Pointer(argc)), 0) - argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0)) - if argv == nil { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func LocalFree(hmem Handle) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall(procLocalFree.Addr(), 1, uintptr(hmem), 0, 0) - handle = Handle(r0) - if handle != 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) { - r1, _, e1 := syscall.Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags)) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func FlushFileBuffers(handle Handle) (err error) { - r1, _, e1 := syscall.Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) { - r0, _, e1 := syscall.Syscall6(procGetFullPathNameW.Addr(), 4, uintptr(unsafe.Pointer(path)), uintptr(buflen), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(fname)), 0, 0) - n = uint32(r0) - if n == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) { - r0, _, e1 := syscall.Syscall(procGetLongPathNameW.Addr(), 3, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(buf)), uintptr(buflen)) - n = uint32(r0) - if n == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) { - r0, _, e1 := syscall.Syscall(procGetShortPathNameW.Addr(), 3, uintptr(unsafe.Pointer(longpath)), uintptr(unsafe.Pointer(shortpath)), uintptr(buflen)) - n = uint32(r0) - if n == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall6(procCreateFileMappingW.Addr(), 6, uintptr(fhandle), uintptr(unsafe.Pointer(sa)), uintptr(prot), uintptr(maxSizeHigh), uintptr(maxSizeLow), uintptr(unsafe.Pointer(name))) - handle = Handle(r0) - if handle == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) { - r0, _, e1 := syscall.Syscall6(procMapViewOfFile.Addr(), 5, uintptr(handle), uintptr(access), uintptr(offsetHigh), uintptr(offsetLow), uintptr(length), 0) - addr = uintptr(r0) - if addr == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func UnmapViewOfFile(addr uintptr) (err error) { - r1, _, e1 := syscall.Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func FlushViewOfFile(addr uintptr, length uintptr) (err error) { - r1, _, e1 := syscall.Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func VirtualLock(addr uintptr, length uintptr) (err error) { - r1, _, e1 := syscall.Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func VirtualUnlock(addr uintptr, length uintptr) (err error) { - r1, _, e1 := syscall.Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) { - r1, _, e1 := syscall.Syscall9(procTransmitFile.Addr(), 7, uintptr(s), uintptr(handle), uintptr(bytesToWrite), uintptr(bytsPerSend), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(transmitFileBuf)), uintptr(flags), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) { - var _p0 uint32 - if watchSubTree { - _p0 = 1 - } else { - _p0 = 0 - } - r1, _, e1 := syscall.Syscall9(procReadDirectoryChangesW.Addr(), 8, uintptr(handle), uintptr(unsafe.Pointer(buf)), uintptr(buflen), uintptr(_p0), uintptr(mask), uintptr(unsafe.Pointer(retlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) { - r0, _, e1 := syscall.Syscall(procCertOpenSystemStoreW.Addr(), 2, uintptr(hprov), uintptr(unsafe.Pointer(name)), 0) - store = Handle(r0) - if store == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall6(procCertOpenStore.Addr(), 5, uintptr(storeProvider), uintptr(msgAndCertEncodingType), uintptr(cryptProv), uintptr(flags), uintptr(para), 0) - handle = Handle(r0) - if handle == InvalidHandle { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) { - r0, _, e1 := syscall.Syscall(procCertEnumCertificatesInStore.Addr(), 2, uintptr(store), uintptr(unsafe.Pointer(prevContext)), 0) - context = (*CertContext)(unsafe.Pointer(r0)) - if context == nil { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) { - r1, _, e1 := syscall.Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CertCloseStore(store Handle, flags uint32) (err error) { - r1, _, e1 := syscall.Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) { - r1, _, e1 := syscall.Syscall9(procCertGetCertificateChain.Addr(), 8, uintptr(engine), uintptr(unsafe.Pointer(leaf)), uintptr(unsafe.Pointer(time)), uintptr(additionalStore), uintptr(unsafe.Pointer(para)), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(chainCtx)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CertFreeCertificateChain(ctx *CertChainContext) { - syscall.Syscall(procCertFreeCertificateChain.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0) - return -} - -func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) { - r0, _, e1 := syscall.Syscall(procCertCreateCertificateContext.Addr(), 3, uintptr(certEncodingType), uintptr(unsafe.Pointer(certEncoded)), uintptr(encodedLen)) - context = (*CertContext)(unsafe.Pointer(r0)) - if context == nil { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CertFreeCertificateContext(ctx *CertContext) (err error) { - r1, _, e1 := syscall.Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) { - r1, _, e1 := syscall.Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) { - r0, _, _ := syscall.Syscall6(procRegOpenKeyExW.Addr(), 5, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(options), uintptr(desiredAccess), uintptr(unsafe.Pointer(result)), 0) - if r0 != 0 { - regerrno = syscall.Errno(r0) - } - return -} - -func RegCloseKey(key Handle) (regerrno error) { - r0, _, _ := syscall.Syscall(procRegCloseKey.Addr(), 1, uintptr(key), 0, 0) - if r0 != 0 { - regerrno = syscall.Errno(r0) - } - return -} - -func RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *uint32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteTime *Filetime) (regerrno error) { - r0, _, _ := syscall.Syscall12(procRegQueryInfoKeyW.Addr(), 12, uintptr(key), uintptr(unsafe.Pointer(class)), uintptr(unsafe.Pointer(classLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(subkeysLen)), uintptr(unsafe.Pointer(maxSubkeyLen)), uintptr(unsafe.Pointer(maxClassLen)), uintptr(unsafe.Pointer(valuesLen)), uintptr(unsafe.Pointer(maxValueNameLen)), uintptr(unsafe.Pointer(maxValueLen)), uintptr(unsafe.Pointer(saLen)), uintptr(unsafe.Pointer(lastWriteTime))) - if r0 != 0 { - regerrno = syscall.Errno(r0) - } - return -} - -func RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) { - r0, _, _ := syscall.Syscall9(procRegEnumKeyExW.Addr(), 8, uintptr(key), uintptr(index), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(class)), uintptr(unsafe.Pointer(classLen)), uintptr(unsafe.Pointer(lastWriteTime)), 0) - if r0 != 0 { - regerrno = syscall.Errno(r0) - } - return -} - -func RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) { - r0, _, _ := syscall.Syscall6(procRegQueryValueExW.Addr(), 6, uintptr(key), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(valtype)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(buflen))) - if r0 != 0 { - regerrno = syscall.Errno(r0) - } - return -} - -func getCurrentProcessId() (pid uint32) { - r0, _, _ := syscall.Syscall(procGetCurrentProcessId.Addr(), 0, 0, 0, 0) - pid = uint32(r0) - return -} - -func GetConsoleMode(console Handle, mode *uint32) (err error) { - r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) { - r1, _, e1 := syscall.Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) { - r1, _, e1 := syscall.Syscall6(procReadConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), uintptr(unsafe.Pointer(inputControl)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall(procCreateToolhelp32Snapshot.Addr(), 2, uintptr(flags), uintptr(processId), 0) - handle = Handle(r0) - if handle == InvalidHandle { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) { - r1, _, e1 := syscall.Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) { - r1, _, e1 := syscall.Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBufferSize uint32, outBuffer *byte, outBufferSize uint32, bytesReturned *uint32, overlapped *Overlapped) (err error) { - r1, _, e1 := syscall.Syscall9(procDeviceIoControl.Addr(), 8, uintptr(handle), uintptr(ioControlCode), uintptr(unsafe.Pointer(inBuffer)), uintptr(inBufferSize), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferSize), uintptr(unsafe.Pointer(bytesReturned)), uintptr(unsafe.Pointer(overlapped)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) { - r1, _, e1 := syscall.Syscall(procCreateSymbolicLinkW.Addr(), 3, uintptr(unsafe.Pointer(symlinkfilename)), uintptr(unsafe.Pointer(targetfilename)), uintptr(flags)) - if r1&0xff == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) { - r1, _, e1 := syscall.Syscall(procCreateHardLinkW.Addr(), 3, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(existingfilename)), uintptr(reserved)) - if r1&0xff == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetCurrentThreadId() (id uint32) { - r0, _, _ := syscall.Syscall(procGetCurrentThreadId.Addr(), 0, 0, 0, 0) - id = uint32(r0) - return -} - -func CreateEvent(eventAttrs *syscall.SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0) - handle = Handle(r0) - if handle == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func SetEvent(event Handle) (err error) { - r1, _, e1 := syscall.Syscall(procSetEvent.Addr(), 1, uintptr(event), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func WSAStartup(verreq uint32, data *WSAData) (sockerr error) { - r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0) - if r0 != 0 { - sockerr = syscall.Errno(r0) - } - return -} - -func WSACleanup() (err error) { - r1, _, e1 := syscall.Syscall(procWSACleanup.Addr(), 0, 0, 0, 0) - if r1 == socket_error { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) { - r1, _, e1 := syscall.Syscall9(procWSAIoctl.Addr(), 9, uintptr(s), uintptr(iocc), uintptr(unsafe.Pointer(inbuf)), uintptr(cbif), uintptr(unsafe.Pointer(outbuf)), uintptr(cbob), uintptr(unsafe.Pointer(cbbr)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine)) - if r1 == socket_error { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func socket(af int32, typ int32, protocol int32) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall(procsocket.Addr(), 3, uintptr(af), uintptr(typ), uintptr(protocol)) - handle = Handle(r0) - if handle == InvalidHandle { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) { - r1, _, e1 := syscall.Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0) - if r1 == socket_error { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) { - r1, _, e1 := syscall.Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0) - if r1 == socket_error { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) { - r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen)) - if r1 == socket_error { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) { - r1, _, e1 := syscall.Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen)) - if r1 == socket_error { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) { - r1, _, e1 := syscall.Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) - if r1 == socket_error { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) { - r1, _, e1 := syscall.Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) - if r1 == socket_error { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func listen(s Handle, backlog int32) (err error) { - r1, _, e1 := syscall.Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0) - if r1 == socket_error { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func shutdown(s Handle, how int32) (err error) { - r1, _, e1 := syscall.Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0) - if r1 == socket_error { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func Closesocket(s Handle) (err error) { - r1, _, e1 := syscall.Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0) - if r1 == socket_error { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) { - r1, _, e1 := syscall.Syscall9(procAcceptEx.Addr(), 8, uintptr(ls), uintptr(as), uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(overlapped)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) { - syscall.Syscall9(procGetAcceptExSockaddrs.Addr(), 8, uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(lrsa)), uintptr(unsafe.Pointer(lrsalen)), uintptr(unsafe.Pointer(rrsa)), uintptr(unsafe.Pointer(rrsalen)), 0) - return -} - -func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) { - r1, _, e1 := syscall.Syscall9(procWSARecv.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0) - if r1 == socket_error { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) { - r1, _, e1 := syscall.Syscall9(procWSASend.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0) - if r1 == socket_error { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) { - r1, _, e1 := syscall.Syscall9(procWSARecvFrom.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine))) - if r1 == socket_error { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) { - r1, _, e1 := syscall.Syscall9(procWSASendTo.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(to)), uintptr(tolen), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine))) - if r1 == socket_error { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetHostByName(name string) (h *Hostent, err error) { - var _p0 *byte - _p0, err = syscall.BytePtrFromString(name) - if err != nil { - return - } - return _GetHostByName(_p0) -} - -func _GetHostByName(name *byte) (h *Hostent, err error) { - r0, _, e1 := syscall.Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0) - h = (*Hostent)(unsafe.Pointer(r0)) - if h == nil { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetServByName(name string, proto string) (s *Servent, err error) { - var _p0 *byte - _p0, err = syscall.BytePtrFromString(name) - if err != nil { - return - } - var _p1 *byte - _p1, err = syscall.BytePtrFromString(proto) - if err != nil { - return - } - return _GetServByName(_p0, _p1) -} - -func _GetServByName(name *byte, proto *byte) (s *Servent, err error) { - r0, _, e1 := syscall.Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0) - s = (*Servent)(unsafe.Pointer(r0)) - if s == nil { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func Ntohs(netshort uint16) (u uint16) { - r0, _, _ := syscall.Syscall(procntohs.Addr(), 1, uintptr(netshort), 0, 0) - u = uint16(r0) - return -} - -func GetProtoByName(name string) (p *Protoent, err error) { - var _p0 *byte - _p0, err = syscall.BytePtrFromString(name) - if err != nil { - return - } - return _GetProtoByName(_p0) -} - -func _GetProtoByName(name *byte) (p *Protoent, err error) { - r0, _, e1 := syscall.Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0) - p = (*Protoent)(unsafe.Pointer(r0)) - if p == nil { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) { - var _p0 *uint16 - _p0, status = syscall.UTF16PtrFromString(name) - if status != nil { - return - } - return _DnsQuery(_p0, qtype, options, extra, qrs, pr) -} - -func _DnsQuery(name *uint16, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) { - r0, _, _ := syscall.Syscall6(procDnsQuery_W.Addr(), 6, uintptr(unsafe.Pointer(name)), uintptr(qtype), uintptr(options), uintptr(unsafe.Pointer(extra)), uintptr(unsafe.Pointer(qrs)), uintptr(unsafe.Pointer(pr))) - if r0 != 0 { - status = syscall.Errno(r0) - } - return -} - -func DnsRecordListFree(rl *DNSRecord, freetype uint32) { - syscall.Syscall(procDnsRecordListFree.Addr(), 2, uintptr(unsafe.Pointer(rl)), uintptr(freetype), 0) - return -} - -func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) { - r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0) - same = r0 != 0 - return -} - -func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) { - r0, _, _ := syscall.Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0) - if r0 != 0 { - sockerr = syscall.Errno(r0) - } - return -} - -func FreeAddrInfoW(addrinfo *AddrinfoW) { - syscall.Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0) - return -} - -func GetIfEntry(pIfRow *MibIfRow) (errcode error) { - r0, _, _ := syscall.Syscall(procGetIfEntry.Addr(), 1, uintptr(unsafe.Pointer(pIfRow)), 0, 0) - if r0 != 0 { - errcode = syscall.Errno(r0) - } - return -} - -func GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) { - r0, _, _ := syscall.Syscall(procGetAdaptersInfo.Addr(), 2, uintptr(unsafe.Pointer(ai)), uintptr(unsafe.Pointer(ol)), 0) - if r0 != 0 { - errcode = syscall.Errno(r0) - } - return -} - -func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) { - r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) { - r0, _, e1 := syscall.Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength))) - n = int32(r0) - if n == -1 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) { - r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0) - if r0 != 0 { - errcode = syscall.Errno(r0) - } - return -} - -func GetACP() (acp uint32) { - r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0) - acp = uint32(r0) - return -} - -func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) { - r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar)) - nwrite = int32(r0) - if nwrite == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) { - r1, _, e1 := syscall.Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0) - if r1&0xff == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) { - r1, _, e1 := syscall.Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize))) - if r1&0xff == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) { - r0, _, _ := syscall.Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0) - if r0 != 0 { - neterr = syscall.Errno(r0) - } - return -} - -func NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) { - r0, _, _ := syscall.Syscall(procNetGetJoinInformation.Addr(), 3, uintptr(unsafe.Pointer(server)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(bufType))) - if r0 != 0 { - neterr = syscall.Errno(r0) - } - return -} - -func NetApiBufferFree(buf *byte) (neterr error) { - r0, _, _ := syscall.Syscall(procNetApiBufferFree.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0) - if r0 != 0 { - neterr = syscall.Errno(r0) - } - return -} - -func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) { - r1, _, e1 := syscall.Syscall9(procLookupAccountSidW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) { - r1, _, e1 := syscall.Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) { - r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) { - r1, _, e1 := syscall.Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetLengthSid(sid *SID) (len uint32) { - r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) - len = uint32(r0) - return -} - -func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) { - r1, _, e1 := syscall.Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid))) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func AllocateAndInitializeSid(identAuth *SidIdentifierAuthority, subAuth byte, subAuth0 uint32, subAuth1 uint32, subAuth2 uint32, subAuth3 uint32, subAuth4 uint32, subAuth5 uint32, subAuth6 uint32, subAuth7 uint32, sid **SID) (err error) { - r1, _, e1 := syscall.Syscall12(procAllocateAndInitializeSid.Addr(), 11, uintptr(unsafe.Pointer(identAuth)), uintptr(subAuth), uintptr(subAuth0), uintptr(subAuth1), uintptr(subAuth2), uintptr(subAuth3), uintptr(subAuth4), uintptr(subAuth5), uintptr(subAuth6), uintptr(subAuth7), uintptr(unsafe.Pointer(sid)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func FreeSid(sid *SID) (err error) { - r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) - if r1 != 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) { - r0, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid1)), uintptr(unsafe.Pointer(sid2)), 0) - isEqual = r0 != 0 - return -} - -func OpenProcessToken(h Handle, access uint32, token *Token) (err error) { - r1, _, e1 := syscall.Syscall(procOpenProcessToken.Addr(), 3, uintptr(h), uintptr(access), uintptr(unsafe.Pointer(token))) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetTokenInformation(t Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) { - r1, _, e1 := syscall.Syscall6(procGetTokenInformation.Addr(), 5, uintptr(t), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} - -func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) { - r1, _, e1 := syscall.Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen))) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } - } - return -} diff --git a/vendor/golang.org/x/sys/windows/ztypes_windows.go b/vendor/golang.org/x/sys/windows/ztypes_windows.go deleted file mode 100644 index 1fe19d1d7..000000000 --- a/vendor/golang.org/x/sys/windows/ztypes_windows.go +++ /dev/null @@ -1,1242 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package windows - -import "syscall" - -const ( - // Windows errors. - ERROR_FILE_NOT_FOUND syscall.Errno = 2 - ERROR_PATH_NOT_FOUND syscall.Errno = 3 - ERROR_ACCESS_DENIED syscall.Errno = 5 - ERROR_NO_MORE_FILES syscall.Errno = 18 - ERROR_HANDLE_EOF syscall.Errno = 38 - ERROR_NETNAME_DELETED syscall.Errno = 64 - ERROR_FILE_EXISTS syscall.Errno = 80 - ERROR_BROKEN_PIPE syscall.Errno = 109 - ERROR_BUFFER_OVERFLOW syscall.Errno = 111 - ERROR_INSUFFICIENT_BUFFER syscall.Errno = 122 - ERROR_MOD_NOT_FOUND syscall.Errno = 126 - ERROR_PROC_NOT_FOUND syscall.Errno = 127 - ERROR_ALREADY_EXISTS syscall.Errno = 183 - ERROR_ENVVAR_NOT_FOUND syscall.Errno = 203 - ERROR_MORE_DATA syscall.Errno = 234 - ERROR_OPERATION_ABORTED syscall.Errno = 995 - ERROR_IO_PENDING syscall.Errno = 997 - ERROR_SERVICE_SPECIFIC_ERROR syscall.Errno = 1066 - ERROR_NOT_FOUND syscall.Errno = 1168 - ERROR_PRIVILEGE_NOT_HELD syscall.Errno = 1314 - WSAEACCES syscall.Errno = 10013 - WSAECONNRESET syscall.Errno = 10054 -) - -const ( - // Invented values to support what package os expects. - O_RDONLY = 0x00000 - O_WRONLY = 0x00001 - O_RDWR = 0x00002 - O_CREAT = 0x00040 - O_EXCL = 0x00080 - O_NOCTTY = 0x00100 - O_TRUNC = 0x00200 - O_NONBLOCK = 0x00800 - O_APPEND = 0x00400 - O_SYNC = 0x01000 - O_ASYNC = 0x02000 - O_CLOEXEC = 0x80000 -) - -const ( - // More invented values for signals - SIGHUP = Signal(0x1) - SIGINT = Signal(0x2) - SIGQUIT = Signal(0x3) - SIGILL = Signal(0x4) - SIGTRAP = Signal(0x5) - SIGABRT = Signal(0x6) - SIGBUS = Signal(0x7) - SIGFPE = Signal(0x8) - SIGKILL = Signal(0x9) - SIGSEGV = Signal(0xb) - SIGPIPE = Signal(0xd) - SIGALRM = Signal(0xe) - SIGTERM = Signal(0xf) -) - -var signals = [...]string{ - 1: "hangup", - 2: "interrupt", - 3: "quit", - 4: "illegal instruction", - 5: "trace/breakpoint trap", - 6: "aborted", - 7: "bus error", - 8: "floating point exception", - 9: "killed", - 10: "user defined signal 1", - 11: "segmentation fault", - 12: "user defined signal 2", - 13: "broken pipe", - 14: "alarm clock", - 15: "terminated", -} - -const ( - GENERIC_READ = 0x80000000 - GENERIC_WRITE = 0x40000000 - GENERIC_EXECUTE = 0x20000000 - GENERIC_ALL = 0x10000000 - - FILE_LIST_DIRECTORY = 0x00000001 - FILE_APPEND_DATA = 0x00000004 - FILE_WRITE_ATTRIBUTES = 0x00000100 - - FILE_SHARE_READ = 0x00000001 - FILE_SHARE_WRITE = 0x00000002 - FILE_SHARE_DELETE = 0x00000004 - FILE_ATTRIBUTE_READONLY = 0x00000001 - FILE_ATTRIBUTE_HIDDEN = 0x00000002 - FILE_ATTRIBUTE_SYSTEM = 0x00000004 - FILE_ATTRIBUTE_DIRECTORY = 0x00000010 - FILE_ATTRIBUTE_ARCHIVE = 0x00000020 - FILE_ATTRIBUTE_NORMAL = 0x00000080 - FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400 - - INVALID_FILE_ATTRIBUTES = 0xffffffff - - CREATE_NEW = 1 - CREATE_ALWAYS = 2 - OPEN_EXISTING = 3 - OPEN_ALWAYS = 4 - TRUNCATE_EXISTING = 5 - - FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000 - FILE_FLAG_BACKUP_SEMANTICS = 0x02000000 - FILE_FLAG_OVERLAPPED = 0x40000000 - - HANDLE_FLAG_INHERIT = 0x00000001 - STARTF_USESTDHANDLES = 0x00000100 - STARTF_USESHOWWINDOW = 0x00000001 - DUPLICATE_CLOSE_SOURCE = 0x00000001 - DUPLICATE_SAME_ACCESS = 0x00000002 - - STD_INPUT_HANDLE = -10 - STD_OUTPUT_HANDLE = -11 - STD_ERROR_HANDLE = -12 - - FILE_BEGIN = 0 - FILE_CURRENT = 1 - FILE_END = 2 - - LANG_ENGLISH = 0x09 - SUBLANG_ENGLISH_US = 0x01 - - FORMAT_MESSAGE_ALLOCATE_BUFFER = 256 - FORMAT_MESSAGE_IGNORE_INSERTS = 512 - FORMAT_MESSAGE_FROM_STRING = 1024 - FORMAT_MESSAGE_FROM_HMODULE = 2048 - FORMAT_MESSAGE_FROM_SYSTEM = 4096 - FORMAT_MESSAGE_ARGUMENT_ARRAY = 8192 - FORMAT_MESSAGE_MAX_WIDTH_MASK = 255 - - MAX_PATH = 260 - MAX_LONG_PATH = 32768 - - MAX_COMPUTERNAME_LENGTH = 15 - - TIME_ZONE_ID_UNKNOWN = 0 - TIME_ZONE_ID_STANDARD = 1 - - TIME_ZONE_ID_DAYLIGHT = 2 - IGNORE = 0 - INFINITE = 0xffffffff - - WAIT_TIMEOUT = 258 - WAIT_ABANDONED = 0x00000080 - WAIT_OBJECT_0 = 0x00000000 - WAIT_FAILED = 0xFFFFFFFF - - CREATE_NEW_PROCESS_GROUP = 0x00000200 - CREATE_UNICODE_ENVIRONMENT = 0x00000400 - - PROCESS_TERMINATE = 1 - PROCESS_QUERY_INFORMATION = 0x00000400 - SYNCHRONIZE = 0x00100000 - - PAGE_READONLY = 0x02 - PAGE_READWRITE = 0x04 - PAGE_WRITECOPY = 0x08 - PAGE_EXECUTE_READ = 0x20 - PAGE_EXECUTE_READWRITE = 0x40 - PAGE_EXECUTE_WRITECOPY = 0x80 - - FILE_MAP_COPY = 0x01 - FILE_MAP_WRITE = 0x02 - FILE_MAP_READ = 0x04 - FILE_MAP_EXECUTE = 0x20 - - CTRL_C_EVENT = 0 - CTRL_BREAK_EVENT = 1 - - // Windows reserves errors >= 1<<29 for application use. - APPLICATION_ERROR = 1 << 29 -) - -const ( - // flags for CreateToolhelp32Snapshot - TH32CS_SNAPHEAPLIST = 0x01 - TH32CS_SNAPPROCESS = 0x02 - TH32CS_SNAPTHREAD = 0x04 - TH32CS_SNAPMODULE = 0x08 - TH32CS_SNAPMODULE32 = 0x10 - TH32CS_SNAPALL = TH32CS_SNAPHEAPLIST | TH32CS_SNAPMODULE | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD - TH32CS_INHERIT = 0x80000000 -) - -const ( - // filters for ReadDirectoryChangesW - FILE_NOTIFY_CHANGE_FILE_NAME = 0x001 - FILE_NOTIFY_CHANGE_DIR_NAME = 0x002 - FILE_NOTIFY_CHANGE_ATTRIBUTES = 0x004 - FILE_NOTIFY_CHANGE_SIZE = 0x008 - FILE_NOTIFY_CHANGE_LAST_WRITE = 0x010 - FILE_NOTIFY_CHANGE_LAST_ACCESS = 0x020 - FILE_NOTIFY_CHANGE_CREATION = 0x040 - FILE_NOTIFY_CHANGE_SECURITY = 0x100 -) - -const ( - // do not reorder - FILE_ACTION_ADDED = iota + 1 - FILE_ACTION_REMOVED - FILE_ACTION_MODIFIED - FILE_ACTION_RENAMED_OLD_NAME - FILE_ACTION_RENAMED_NEW_NAME -) - -const ( - // wincrypt.h - PROV_RSA_FULL = 1 - PROV_RSA_SIG = 2 - PROV_DSS = 3 - PROV_FORTEZZA = 4 - PROV_MS_EXCHANGE = 5 - PROV_SSL = 6 - PROV_RSA_SCHANNEL = 12 - PROV_DSS_DH = 13 - PROV_EC_ECDSA_SIG = 14 - PROV_EC_ECNRA_SIG = 15 - PROV_EC_ECDSA_FULL = 16 - PROV_EC_ECNRA_FULL = 17 - PROV_DH_SCHANNEL = 18 - PROV_SPYRUS_LYNKS = 20 - PROV_RNG = 21 - PROV_INTEL_SEC = 22 - PROV_REPLACE_OWF = 23 - PROV_RSA_AES = 24 - CRYPT_VERIFYCONTEXT = 0xF0000000 - CRYPT_NEWKEYSET = 0x00000008 - CRYPT_DELETEKEYSET = 0x00000010 - CRYPT_MACHINE_KEYSET = 0x00000020 - CRYPT_SILENT = 0x00000040 - CRYPT_DEFAULT_CONTAINER_OPTIONAL = 0x00000080 - - USAGE_MATCH_TYPE_AND = 0 - USAGE_MATCH_TYPE_OR = 1 - - X509_ASN_ENCODING = 0x00000001 - PKCS_7_ASN_ENCODING = 0x00010000 - - CERT_STORE_PROV_MEMORY = 2 - - CERT_STORE_ADD_ALWAYS = 4 - - CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG = 0x00000004 - - CERT_TRUST_NO_ERROR = 0x00000000 - CERT_TRUST_IS_NOT_TIME_VALID = 0x00000001 - CERT_TRUST_IS_REVOKED = 0x00000004 - CERT_TRUST_IS_NOT_SIGNATURE_VALID = 0x00000008 - CERT_TRUST_IS_NOT_VALID_FOR_USAGE = 0x00000010 - CERT_TRUST_IS_UNTRUSTED_ROOT = 0x00000020 - CERT_TRUST_REVOCATION_STATUS_UNKNOWN = 0x00000040 - CERT_TRUST_IS_CYCLIC = 0x00000080 - CERT_TRUST_INVALID_EXTENSION = 0x00000100 - CERT_TRUST_INVALID_POLICY_CONSTRAINTS = 0x00000200 - CERT_TRUST_INVALID_BASIC_CONSTRAINTS = 0x00000400 - CERT_TRUST_INVALID_NAME_CONSTRAINTS = 0x00000800 - CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT = 0x00001000 - CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT = 0x00002000 - CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT = 0x00004000 - CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT = 0x00008000 - CERT_TRUST_IS_OFFLINE_REVOCATION = 0x01000000 - CERT_TRUST_NO_ISSUANCE_CHAIN_POLICY = 0x02000000 - CERT_TRUST_IS_EXPLICIT_DISTRUST = 0x04000000 - CERT_TRUST_HAS_NOT_SUPPORTED_CRITICAL_EXT = 0x08000000 - - CERT_CHAIN_POLICY_BASE = 1 - CERT_CHAIN_POLICY_AUTHENTICODE = 2 - CERT_CHAIN_POLICY_AUTHENTICODE_TS = 3 - CERT_CHAIN_POLICY_SSL = 4 - CERT_CHAIN_POLICY_BASIC_CONSTRAINTS = 5 - CERT_CHAIN_POLICY_NT_AUTH = 6 - CERT_CHAIN_POLICY_MICROSOFT_ROOT = 7 - CERT_CHAIN_POLICY_EV = 8 - - CERT_E_EXPIRED = 0x800B0101 - CERT_E_ROLE = 0x800B0103 - CERT_E_PURPOSE = 0x800B0106 - CERT_E_UNTRUSTEDROOT = 0x800B0109 - CERT_E_CN_NO_MATCH = 0x800B010F - - AUTHTYPE_CLIENT = 1 - AUTHTYPE_SERVER = 2 -) - -var ( - OID_PKIX_KP_SERVER_AUTH = []byte("1.3.6.1.5.5.7.3.1\x00") - OID_SERVER_GATED_CRYPTO = []byte("1.3.6.1.4.1.311.10.3.3\x00") - OID_SGC_NETSCAPE = []byte("2.16.840.1.113730.4.1\x00") -) - -// Invented values to support what package os expects. -type Timeval struct { - Sec int32 - Usec int32 -} - -func (tv *Timeval) Nanoseconds() int64 { - return (int64(tv.Sec)*1e6 + int64(tv.Usec)) * 1e3 -} - -func NsecToTimeval(nsec int64) (tv Timeval) { - tv.Sec = int32(nsec / 1e9) - tv.Usec = int32(nsec % 1e9 / 1e3) - return -} - -type SecurityAttributes struct { - Length uint32 - SecurityDescriptor uintptr - InheritHandle uint32 -} - -type Overlapped struct { - Internal uintptr - InternalHigh uintptr - Offset uint32 - OffsetHigh uint32 - HEvent Handle -} - -type FileNotifyInformation struct { - NextEntryOffset uint32 - Action uint32 - FileNameLength uint32 - FileName uint16 -} - -type Filetime struct { - LowDateTime uint32 - HighDateTime uint32 -} - -// Nanoseconds returns Filetime ft in nanoseconds -// since Epoch (00:00:00 UTC, January 1, 1970). -func (ft *Filetime) Nanoseconds() int64 { - // 100-nanosecond intervals since January 1, 1601 - nsec := int64(ft.HighDateTime)<<32 + int64(ft.LowDateTime) - // change starting time to the Epoch (00:00:00 UTC, January 1, 1970) - nsec -= 116444736000000000 - // convert into nanoseconds - nsec *= 100 - return nsec -} - -func NsecToFiletime(nsec int64) (ft Filetime) { - // convert into 100-nanosecond - nsec /= 100 - // change starting time to January 1, 1601 - nsec += 116444736000000000 - // split into high / low - ft.LowDateTime = uint32(nsec & 0xffffffff) - ft.HighDateTime = uint32(nsec >> 32 & 0xffffffff) - return ft -} - -type Win32finddata struct { - FileAttributes uint32 - CreationTime Filetime - LastAccessTime Filetime - LastWriteTime Filetime - FileSizeHigh uint32 - FileSizeLow uint32 - Reserved0 uint32 - Reserved1 uint32 - FileName [MAX_PATH - 1]uint16 - AlternateFileName [13]uint16 -} - -// This is the actual system call structure. -// Win32finddata is what we committed to in Go 1. -type win32finddata1 struct { - FileAttributes uint32 - CreationTime Filetime - LastAccessTime Filetime - LastWriteTime Filetime - FileSizeHigh uint32 - FileSizeLow uint32 - Reserved0 uint32 - Reserved1 uint32 - FileName [MAX_PATH]uint16 - AlternateFileName [14]uint16 -} - -func copyFindData(dst *Win32finddata, src *win32finddata1) { - dst.FileAttributes = src.FileAttributes - dst.CreationTime = src.CreationTime - dst.LastAccessTime = src.LastAccessTime - dst.LastWriteTime = src.LastWriteTime - dst.FileSizeHigh = src.FileSizeHigh - dst.FileSizeLow = src.FileSizeLow - dst.Reserved0 = src.Reserved0 - dst.Reserved1 = src.Reserved1 - - // The src is 1 element bigger than dst, but it must be NUL. - copy(dst.FileName[:], src.FileName[:]) - copy(dst.AlternateFileName[:], src.AlternateFileName[:]) -} - -type ByHandleFileInformation struct { - FileAttributes uint32 - CreationTime Filetime - LastAccessTime Filetime - LastWriteTime Filetime - VolumeSerialNumber uint32 - FileSizeHigh uint32 - FileSizeLow uint32 - NumberOfLinks uint32 - FileIndexHigh uint32 - FileIndexLow uint32 -} - -const ( - GetFileExInfoStandard = 0 - GetFileExMaxInfoLevel = 1 -) - -type Win32FileAttributeData struct { - FileAttributes uint32 - CreationTime Filetime - LastAccessTime Filetime - LastWriteTime Filetime - FileSizeHigh uint32 - FileSizeLow uint32 -} - -// ShowWindow constants -const ( - // winuser.h - SW_HIDE = 0 - SW_NORMAL = 1 - SW_SHOWNORMAL = 1 - SW_SHOWMINIMIZED = 2 - SW_SHOWMAXIMIZED = 3 - SW_MAXIMIZE = 3 - SW_SHOWNOACTIVATE = 4 - SW_SHOW = 5 - SW_MINIMIZE = 6 - SW_SHOWMINNOACTIVE = 7 - SW_SHOWNA = 8 - SW_RESTORE = 9 - SW_SHOWDEFAULT = 10 - SW_FORCEMINIMIZE = 11 -) - -type StartupInfo struct { - Cb uint32 - _ *uint16 - Desktop *uint16 - Title *uint16 - X uint32 - Y uint32 - XSize uint32 - YSize uint32 - XCountChars uint32 - YCountChars uint32 - FillAttribute uint32 - Flags uint32 - ShowWindow uint16 - _ uint16 - _ *byte - StdInput Handle - StdOutput Handle - StdErr Handle -} - -type ProcessInformation struct { - Process Handle - Thread Handle - ProcessId uint32 - ThreadId uint32 -} - -type ProcessEntry32 struct { - Size uint32 - Usage uint32 - ProcessID uint32 - DefaultHeapID uintptr - ModuleID uint32 - Threads uint32 - ParentProcessID uint32 - PriClassBase int32 - Flags uint32 - ExeFile [MAX_PATH]uint16 -} - -type Systemtime struct { - Year uint16 - Month uint16 - DayOfWeek uint16 - Day uint16 - Hour uint16 - Minute uint16 - Second uint16 - Milliseconds uint16 -} - -type Timezoneinformation struct { - Bias int32 - StandardName [32]uint16 - StandardDate Systemtime - StandardBias int32 - DaylightName [32]uint16 - DaylightDate Systemtime - DaylightBias int32 -} - -// Socket related. - -const ( - AF_UNSPEC = 0 - AF_UNIX = 1 - AF_INET = 2 - AF_INET6 = 23 - AF_NETBIOS = 17 - - SOCK_STREAM = 1 - SOCK_DGRAM = 2 - SOCK_RAW = 3 - SOCK_SEQPACKET = 5 - - IPPROTO_IP = 0 - IPPROTO_IPV6 = 0x29 - IPPROTO_TCP = 6 - IPPROTO_UDP = 17 - - SOL_SOCKET = 0xffff - SO_REUSEADDR = 4 - SO_KEEPALIVE = 8 - SO_DONTROUTE = 16 - SO_BROADCAST = 32 - SO_LINGER = 128 - SO_RCVBUF = 0x1002 - SO_SNDBUF = 0x1001 - SO_UPDATE_ACCEPT_CONTEXT = 0x700b - SO_UPDATE_CONNECT_CONTEXT = 0x7010 - - IOC_OUT = 0x40000000 - IOC_IN = 0x80000000 - IOC_VENDOR = 0x18000000 - IOC_INOUT = IOC_IN | IOC_OUT - IOC_WS2 = 0x08000000 - SIO_GET_EXTENSION_FUNCTION_POINTER = IOC_INOUT | IOC_WS2 | 6 - SIO_KEEPALIVE_VALS = IOC_IN | IOC_VENDOR | 4 - SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12 - - // cf. http://support.microsoft.com/default.aspx?scid=kb;en-us;257460 - - IP_TOS = 0x3 - IP_TTL = 0x4 - IP_MULTICAST_IF = 0x9 - IP_MULTICAST_TTL = 0xa - IP_MULTICAST_LOOP = 0xb - IP_ADD_MEMBERSHIP = 0xc - IP_DROP_MEMBERSHIP = 0xd - - IPV6_V6ONLY = 0x1b - IPV6_UNICAST_HOPS = 0x4 - IPV6_MULTICAST_IF = 0x9 - IPV6_MULTICAST_HOPS = 0xa - IPV6_MULTICAST_LOOP = 0xb - IPV6_JOIN_GROUP = 0xc - IPV6_LEAVE_GROUP = 0xd - - SOMAXCONN = 0x7fffffff - - TCP_NODELAY = 1 - - SHUT_RD = 0 - SHUT_WR = 1 - SHUT_RDWR = 2 - - WSADESCRIPTION_LEN = 256 - WSASYS_STATUS_LEN = 128 -) - -type WSABuf struct { - Len uint32 - Buf *byte -} - -// Invented values to support what package os expects. -const ( - S_IFMT = 0x1f000 - S_IFIFO = 0x1000 - S_IFCHR = 0x2000 - S_IFDIR = 0x4000 - S_IFBLK = 0x6000 - S_IFREG = 0x8000 - S_IFLNK = 0xa000 - S_IFSOCK = 0xc000 - S_ISUID = 0x800 - S_ISGID = 0x400 - S_ISVTX = 0x200 - S_IRUSR = 0x100 - S_IWRITE = 0x80 - S_IWUSR = 0x80 - S_IXUSR = 0x40 -) - -const ( - FILE_TYPE_CHAR = 0x0002 - FILE_TYPE_DISK = 0x0001 - FILE_TYPE_PIPE = 0x0003 - FILE_TYPE_REMOTE = 0x8000 - FILE_TYPE_UNKNOWN = 0x0000 -) - -type Hostent struct { - Name *byte - Aliases **byte - AddrType uint16 - Length uint16 - AddrList **byte -} - -type Protoent struct { - Name *byte - Aliases **byte - Proto uint16 -} - -const ( - DNS_TYPE_A = 0x0001 - DNS_TYPE_NS = 0x0002 - DNS_TYPE_MD = 0x0003 - DNS_TYPE_MF = 0x0004 - DNS_TYPE_CNAME = 0x0005 - DNS_TYPE_SOA = 0x0006 - DNS_TYPE_MB = 0x0007 - DNS_TYPE_MG = 0x0008 - DNS_TYPE_MR = 0x0009 - DNS_TYPE_NULL = 0x000a - DNS_TYPE_WKS = 0x000b - DNS_TYPE_PTR = 0x000c - DNS_TYPE_HINFO = 0x000d - DNS_TYPE_MINFO = 0x000e - DNS_TYPE_MX = 0x000f - DNS_TYPE_TEXT = 0x0010 - DNS_TYPE_RP = 0x0011 - DNS_TYPE_AFSDB = 0x0012 - DNS_TYPE_X25 = 0x0013 - DNS_TYPE_ISDN = 0x0014 - DNS_TYPE_RT = 0x0015 - DNS_TYPE_NSAP = 0x0016 - DNS_TYPE_NSAPPTR = 0x0017 - DNS_TYPE_SIG = 0x0018 - DNS_TYPE_KEY = 0x0019 - DNS_TYPE_PX = 0x001a - DNS_TYPE_GPOS = 0x001b - DNS_TYPE_AAAA = 0x001c - DNS_TYPE_LOC = 0x001d - DNS_TYPE_NXT = 0x001e - DNS_TYPE_EID = 0x001f - DNS_TYPE_NIMLOC = 0x0020 - DNS_TYPE_SRV = 0x0021 - DNS_TYPE_ATMA = 0x0022 - DNS_TYPE_NAPTR = 0x0023 - DNS_TYPE_KX = 0x0024 - DNS_TYPE_CERT = 0x0025 - DNS_TYPE_A6 = 0x0026 - DNS_TYPE_DNAME = 0x0027 - DNS_TYPE_SINK = 0x0028 - DNS_TYPE_OPT = 0x0029 - DNS_TYPE_DS = 0x002B - DNS_TYPE_RRSIG = 0x002E - DNS_TYPE_NSEC = 0x002F - DNS_TYPE_DNSKEY = 0x0030 - DNS_TYPE_DHCID = 0x0031 - DNS_TYPE_UINFO = 0x0064 - DNS_TYPE_UID = 0x0065 - DNS_TYPE_GID = 0x0066 - DNS_TYPE_UNSPEC = 0x0067 - DNS_TYPE_ADDRS = 0x00f8 - DNS_TYPE_TKEY = 0x00f9 - DNS_TYPE_TSIG = 0x00fa - DNS_TYPE_IXFR = 0x00fb - DNS_TYPE_AXFR = 0x00fc - DNS_TYPE_MAILB = 0x00fd - DNS_TYPE_MAILA = 0x00fe - DNS_TYPE_ALL = 0x00ff - DNS_TYPE_ANY = 0x00ff - DNS_TYPE_WINS = 0xff01 - DNS_TYPE_WINSR = 0xff02 - DNS_TYPE_NBSTAT = 0xff01 -) - -const ( - DNS_INFO_NO_RECORDS = 0x251D -) - -const ( - // flags inside DNSRecord.Dw - DnsSectionQuestion = 0x0000 - DnsSectionAnswer = 0x0001 - DnsSectionAuthority = 0x0002 - DnsSectionAdditional = 0x0003 -) - -type DNSSRVData struct { - Target *uint16 - Priority uint16 - Weight uint16 - Port uint16 - Pad uint16 -} - -type DNSPTRData struct { - Host *uint16 -} - -type DNSMXData struct { - NameExchange *uint16 - Preference uint16 - Pad uint16 -} - -type DNSTXTData struct { - StringCount uint16 - StringArray [1]*uint16 -} - -type DNSRecord struct { - Next *DNSRecord - Name *uint16 - Type uint16 - Length uint16 - Dw uint32 - Ttl uint32 - Reserved uint32 - Data [40]byte -} - -const ( - TF_DISCONNECT = 1 - TF_REUSE_SOCKET = 2 - TF_WRITE_BEHIND = 4 - TF_USE_DEFAULT_WORKER = 0 - TF_USE_SYSTEM_THREAD = 16 - TF_USE_KERNEL_APC = 32 -) - -type TransmitFileBuffers struct { - Head uintptr - HeadLength uint32 - Tail uintptr - TailLength uint32 -} - -const ( - IFF_UP = 1 - IFF_BROADCAST = 2 - IFF_LOOPBACK = 4 - IFF_POINTTOPOINT = 8 - IFF_MULTICAST = 16 -) - -const SIO_GET_INTERFACE_LIST = 0x4004747F - -// TODO(mattn): SockaddrGen is union of sockaddr/sockaddr_in/sockaddr_in6_old. -// will be fixed to change variable type as suitable. - -type SockaddrGen [24]byte - -type InterfaceInfo struct { - Flags uint32 - Address SockaddrGen - BroadcastAddress SockaddrGen - Netmask SockaddrGen -} - -type IpAddressString struct { - String [16]byte -} - -type IpMaskString IpAddressString - -type IpAddrString struct { - Next *IpAddrString - IpAddress IpAddressString - IpMask IpMaskString - Context uint32 -} - -const MAX_ADAPTER_NAME_LENGTH = 256 -const MAX_ADAPTER_DESCRIPTION_LENGTH = 128 -const MAX_ADAPTER_ADDRESS_LENGTH = 8 - -type IpAdapterInfo struct { - Next *IpAdapterInfo - ComboIndex uint32 - AdapterName [MAX_ADAPTER_NAME_LENGTH + 4]byte - Description [MAX_ADAPTER_DESCRIPTION_LENGTH + 4]byte - AddressLength uint32 - Address [MAX_ADAPTER_ADDRESS_LENGTH]byte - Index uint32 - Type uint32 - DhcpEnabled uint32 - CurrentIpAddress *IpAddrString - IpAddressList IpAddrString - GatewayList IpAddrString - DhcpServer IpAddrString - HaveWins bool - PrimaryWinsServer IpAddrString - SecondaryWinsServer IpAddrString - LeaseObtained int64 - LeaseExpires int64 -} - -const MAXLEN_PHYSADDR = 8 -const MAX_INTERFACE_NAME_LEN = 256 -const MAXLEN_IFDESCR = 256 - -type MibIfRow struct { - Name [MAX_INTERFACE_NAME_LEN]uint16 - Index uint32 - Type uint32 - Mtu uint32 - Speed uint32 - PhysAddrLen uint32 - PhysAddr [MAXLEN_PHYSADDR]byte - AdminStatus uint32 - OperStatus uint32 - LastChange uint32 - InOctets uint32 - InUcastPkts uint32 - InNUcastPkts uint32 - InDiscards uint32 - InErrors uint32 - InUnknownProtos uint32 - OutOctets uint32 - OutUcastPkts uint32 - OutNUcastPkts uint32 - OutDiscards uint32 - OutErrors uint32 - OutQLen uint32 - DescrLen uint32 - Descr [MAXLEN_IFDESCR]byte -} - -type CertContext struct { - EncodingType uint32 - EncodedCert *byte - Length uint32 - CertInfo uintptr - Store Handle -} - -type CertChainContext struct { - Size uint32 - TrustStatus CertTrustStatus - ChainCount uint32 - Chains **CertSimpleChain - LowerQualityChainCount uint32 - LowerQualityChains **CertChainContext - HasRevocationFreshnessTime uint32 - RevocationFreshnessTime uint32 -} - -type CertSimpleChain struct { - Size uint32 - TrustStatus CertTrustStatus - NumElements uint32 - Elements **CertChainElement - TrustListInfo uintptr - HasRevocationFreshnessTime uint32 - RevocationFreshnessTime uint32 -} - -type CertChainElement struct { - Size uint32 - CertContext *CertContext - TrustStatus CertTrustStatus - RevocationInfo *CertRevocationInfo - IssuanceUsage *CertEnhKeyUsage - ApplicationUsage *CertEnhKeyUsage - ExtendedErrorInfo *uint16 -} - -type CertRevocationInfo struct { - Size uint32 - RevocationResult uint32 - RevocationOid *byte - OidSpecificInfo uintptr - HasFreshnessTime uint32 - FreshnessTime uint32 - CrlInfo uintptr // *CertRevocationCrlInfo -} - -type CertTrustStatus struct { - ErrorStatus uint32 - InfoStatus uint32 -} - -type CertUsageMatch struct { - Type uint32 - Usage CertEnhKeyUsage -} - -type CertEnhKeyUsage struct { - Length uint32 - UsageIdentifiers **byte -} - -type CertChainPara struct { - Size uint32 - RequestedUsage CertUsageMatch - RequstedIssuancePolicy CertUsageMatch - URLRetrievalTimeout uint32 - CheckRevocationFreshnessTime uint32 - RevocationFreshnessTime uint32 - CacheResync *Filetime -} - -type CertChainPolicyPara struct { - Size uint32 - Flags uint32 - ExtraPolicyPara uintptr -} - -type SSLExtraCertChainPolicyPara struct { - Size uint32 - AuthType uint32 - Checks uint32 - ServerName *uint16 -} - -type CertChainPolicyStatus struct { - Size uint32 - Error uint32 - ChainIndex uint32 - ElementIndex uint32 - ExtraPolicyStatus uintptr -} - -const ( - // do not reorder - HKEY_CLASSES_ROOT = 0x80000000 + iota - HKEY_CURRENT_USER - HKEY_LOCAL_MACHINE - HKEY_USERS - HKEY_PERFORMANCE_DATA - HKEY_CURRENT_CONFIG - HKEY_DYN_DATA - - KEY_QUERY_VALUE = 1 - KEY_SET_VALUE = 2 - KEY_CREATE_SUB_KEY = 4 - KEY_ENUMERATE_SUB_KEYS = 8 - KEY_NOTIFY = 16 - KEY_CREATE_LINK = 32 - KEY_WRITE = 0x20006 - KEY_EXECUTE = 0x20019 - KEY_READ = 0x20019 - KEY_WOW64_64KEY = 0x0100 - KEY_WOW64_32KEY = 0x0200 - KEY_ALL_ACCESS = 0xf003f -) - -const ( - // do not reorder - REG_NONE = iota - REG_SZ - REG_EXPAND_SZ - REG_BINARY - REG_DWORD_LITTLE_ENDIAN - REG_DWORD_BIG_ENDIAN - REG_LINK - REG_MULTI_SZ - REG_RESOURCE_LIST - REG_FULL_RESOURCE_DESCRIPTOR - REG_RESOURCE_REQUIREMENTS_LIST - REG_QWORD_LITTLE_ENDIAN - REG_DWORD = REG_DWORD_LITTLE_ENDIAN - REG_QWORD = REG_QWORD_LITTLE_ENDIAN -) - -type AddrinfoW struct { - Flags int32 - Family int32 - Socktype int32 - Protocol int32 - Addrlen uintptr - Canonname *uint16 - Addr uintptr - Next *AddrinfoW -} - -const ( - AI_PASSIVE = 1 - AI_CANONNAME = 2 - AI_NUMERICHOST = 4 -) - -type GUID struct { - Data1 uint32 - Data2 uint16 - Data3 uint16 - Data4 [8]byte -} - -var WSAID_CONNECTEX = GUID{ - 0x25a207b9, - 0xddf3, - 0x4660, - [8]byte{0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}, -} - -const ( - FILE_SKIP_COMPLETION_PORT_ON_SUCCESS = 1 - FILE_SKIP_SET_EVENT_ON_HANDLE = 2 -) - -const ( - WSAPROTOCOL_LEN = 255 - MAX_PROTOCOL_CHAIN = 7 - BASE_PROTOCOL = 1 - LAYERED_PROTOCOL = 0 - - XP1_CONNECTIONLESS = 0x00000001 - XP1_GUARANTEED_DELIVERY = 0x00000002 - XP1_GUARANTEED_ORDER = 0x00000004 - XP1_MESSAGE_ORIENTED = 0x00000008 - XP1_PSEUDO_STREAM = 0x00000010 - XP1_GRACEFUL_CLOSE = 0x00000020 - XP1_EXPEDITED_DATA = 0x00000040 - XP1_CONNECT_DATA = 0x00000080 - XP1_DISCONNECT_DATA = 0x00000100 - XP1_SUPPORT_BROADCAST = 0x00000200 - XP1_SUPPORT_MULTIPOINT = 0x00000400 - XP1_MULTIPOINT_CONTROL_PLANE = 0x00000800 - XP1_MULTIPOINT_DATA_PLANE = 0x00001000 - XP1_QOS_SUPPORTED = 0x00002000 - XP1_UNI_SEND = 0x00008000 - XP1_UNI_RECV = 0x00010000 - XP1_IFS_HANDLES = 0x00020000 - XP1_PARTIAL_MESSAGE = 0x00040000 - XP1_SAN_SUPPORT_SDP = 0x00080000 - - PFL_MULTIPLE_PROTO_ENTRIES = 0x00000001 - PFL_RECOMMENDED_PROTO_ENTRY = 0x00000002 - PFL_HIDDEN = 0x00000004 - PFL_MATCHES_PROTOCOL_ZERO = 0x00000008 - PFL_NETWORKDIRECT_PROVIDER = 0x00000010 -) - -type WSAProtocolInfo struct { - ServiceFlags1 uint32 - ServiceFlags2 uint32 - ServiceFlags3 uint32 - ServiceFlags4 uint32 - ProviderFlags uint32 - ProviderId GUID - CatalogEntryId uint32 - ProtocolChain WSAProtocolChain - Version int32 - AddressFamily int32 - MaxSockAddr int32 - MinSockAddr int32 - SocketType int32 - Protocol int32 - ProtocolMaxOffset int32 - NetworkByteOrder int32 - SecurityScheme int32 - MessageSize uint32 - ProviderReserved uint32 - ProtocolName [WSAPROTOCOL_LEN + 1]uint16 -} - -type WSAProtocolChain struct { - ChainLen int32 - ChainEntries [MAX_PROTOCOL_CHAIN]uint32 -} - -type TCPKeepalive struct { - OnOff uint32 - Time uint32 - Interval uint32 -} - -type symbolicLinkReparseBuffer struct { - SubstituteNameOffset uint16 - SubstituteNameLength uint16 - PrintNameOffset uint16 - PrintNameLength uint16 - Flags uint32 - PathBuffer [1]uint16 -} - -type mountPointReparseBuffer struct { - SubstituteNameOffset uint16 - SubstituteNameLength uint16 - PrintNameOffset uint16 - PrintNameLength uint16 - PathBuffer [1]uint16 -} - -type reparseDataBuffer struct { - ReparseTag uint32 - ReparseDataLength uint16 - Reserved uint16 - - // GenericReparseBuffer - reparseBuffer byte -} - -const ( - FSCTL_GET_REPARSE_POINT = 0x900A8 - MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16 * 1024 - IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003 - IO_REPARSE_TAG_SYMLINK = 0xA000000C - SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1 -) - -const ( - ComputerNameNetBIOS = 0 - ComputerNameDnsHostname = 1 - ComputerNameDnsDomain = 2 - ComputerNameDnsFullyQualified = 3 - ComputerNamePhysicalNetBIOS = 4 - ComputerNamePhysicalDnsHostname = 5 - ComputerNamePhysicalDnsDomain = 6 - ComputerNamePhysicalDnsFullyQualified = 7 - ComputerNameMax = 8 -) - -const ( - MOVEFILE_REPLACE_EXISTING = 0x1 - MOVEFILE_COPY_ALLOWED = 0x2 - MOVEFILE_DELAY_UNTIL_REBOOT = 0x4 - MOVEFILE_WRITE_THROUGH = 0x8 - MOVEFILE_CREATE_HARDLINK = 0x10 - MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20 -) - -const GAA_FLAG_INCLUDE_PREFIX = 0x00000010 - -const ( - IF_TYPE_OTHER = 1 - IF_TYPE_ETHERNET_CSMACD = 6 - IF_TYPE_ISO88025_TOKENRING = 9 - IF_TYPE_PPP = 23 - IF_TYPE_SOFTWARE_LOOPBACK = 24 - IF_TYPE_ATM = 37 - IF_TYPE_IEEE80211 = 71 - IF_TYPE_TUNNEL = 131 - IF_TYPE_IEEE1394 = 144 -) - -type SocketAddress struct { - Sockaddr *syscall.RawSockaddrAny - SockaddrLength int32 -} - -type IpAdapterUnicastAddress struct { - Length uint32 - Flags uint32 - Next *IpAdapterUnicastAddress - Address SocketAddress - PrefixOrigin int32 - SuffixOrigin int32 - DadState int32 - ValidLifetime uint32 - PreferredLifetime uint32 - LeaseLifetime uint32 - OnLinkPrefixLength uint8 -} - -type IpAdapterAnycastAddress struct { - Length uint32 - Flags uint32 - Next *IpAdapterAnycastAddress - Address SocketAddress -} - -type IpAdapterMulticastAddress struct { - Length uint32 - Flags uint32 - Next *IpAdapterMulticastAddress - Address SocketAddress -} - -type IpAdapterDnsServerAdapter struct { - Length uint32 - Reserved uint32 - Next *IpAdapterDnsServerAdapter - Address SocketAddress -} - -type IpAdapterPrefix struct { - Length uint32 - Flags uint32 - Next *IpAdapterPrefix - Address SocketAddress - PrefixLength uint32 -} - -type IpAdapterAddresses struct { - Length uint32 - IfIndex uint32 - Next *IpAdapterAddresses - AdapterName *byte - FirstUnicastAddress *IpAdapterUnicastAddress - FirstAnycastAddress *IpAdapterAnycastAddress - FirstMulticastAddress *IpAdapterMulticastAddress - FirstDnsServerAddress *IpAdapterDnsServerAdapter - DnsSuffix *uint16 - Description *uint16 - FriendlyName *uint16 - PhysicalAddress [syscall.MAX_ADAPTER_ADDRESS_LENGTH]byte - PhysicalAddressLength uint32 - Flags uint32 - Mtu uint32 - IfType uint32 - OperStatus uint32 - Ipv6IfIndex uint32 - ZoneIndices [16]uint32 - FirstPrefix *IpAdapterPrefix - /* more fields might be present here. */ -} - -const ( - IfOperStatusUp = 1 - IfOperStatusDown = 2 - IfOperStatusTesting = 3 - IfOperStatusUnknown = 4 - IfOperStatusDormant = 5 - IfOperStatusNotPresent = 6 - IfOperStatusLowerLayerDown = 7 -) diff --git a/vendor/golang.org/x/sys/windows/ztypes_windows_386.go b/vendor/golang.org/x/sys/windows/ztypes_windows_386.go deleted file mode 100644 index 10f33be0b..000000000 --- a/vendor/golang.org/x/sys/windows/ztypes_windows_386.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package windows - -type WSAData struct { - Version uint16 - HighVersion uint16 - Description [WSADESCRIPTION_LEN + 1]byte - SystemStatus [WSASYS_STATUS_LEN + 1]byte - MaxSockets uint16 - MaxUdpDg uint16 - VendorInfo *byte -} - -type Servent struct { - Name *byte - Aliases **byte - Port uint16 - Proto *byte -} diff --git a/vendor/golang.org/x/sys/windows/ztypes_windows_amd64.go b/vendor/golang.org/x/sys/windows/ztypes_windows_amd64.go deleted file mode 100644 index 3f272c249..000000000 --- a/vendor/golang.org/x/sys/windows/ztypes_windows_amd64.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package windows - -type WSAData struct { - Version uint16 - HighVersion uint16 - MaxSockets uint16 - MaxUdpDg uint16 - VendorInfo *byte - Description [WSADESCRIPTION_LEN + 1]byte - SystemStatus [WSASYS_STATUS_LEN + 1]byte -} - -type Servent struct { - Name *byte - Aliases **byte - Proto *byte - Port uint16 -} diff --git a/vendor/golang.org/x/time/CONTRIBUTING.md b/vendor/golang.org/x/time/CONTRIBUTING.md deleted file mode 100644 index 88dff59bc..000000000 --- a/vendor/golang.org/x/time/CONTRIBUTING.md +++ /dev/null @@ -1,31 +0,0 @@ -# Contributing to Go - -Go is an open source project. - -It is the work of hundreds of contributors. We appreciate your help! - - -## Filing issues - -When [filing an issue](https://golang.org/issue/new), make sure to answer these five questions: - -1. What version of Go are you using (`go version`)? -2. What operating system and processor architecture are you using? -3. What did you do? -4. What did you expect to see? -5. What did you see instead? - -General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker. -The gophers there will answer or ask you to file an issue if you've tripped over a bug. - -## Contributing code - -Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) -before sending patches. - -**We do not accept GitHub pull requests** -(we use [Gerrit](https://code.google.com/p/gerrit/) instead for code review). - -Unless otherwise noted, the Go source files are distributed under -the BSD-style license found in the LICENSE file. - diff --git a/vendor/golang.org/x/time/README b/vendor/golang.org/x/time/README deleted file mode 100644 index 144e347b4..000000000 --- a/vendor/golang.org/x/time/README +++ /dev/null @@ -1 +0,0 @@ -This repository provides supplementary Go time packages. diff --git a/vendor/golang.org/x/time/rate/rate_test.go b/vendor/golang.org/x/time/rate/rate_test.go deleted file mode 100644 index e8add694f..000000000 --- a/vendor/golang.org/x/time/rate/rate_test.go +++ /dev/null @@ -1,449 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.7 - -package rate - -import ( - "context" - "math" - "runtime" - "sync" - "sync/atomic" - "testing" - "time" -) - -func TestLimit(t *testing.T) { - if Limit(10) == Inf { - t.Errorf("Limit(10) == Inf should be false") - } -} - -func closeEnough(a, b Limit) bool { - return (math.Abs(float64(a)/float64(b)) - 1.0) < 1e-9 -} - -func TestEvery(t *testing.T) { - cases := []struct { - interval time.Duration - lim Limit - }{ - {0, Inf}, - {-1, Inf}, - {1 * time.Nanosecond, Limit(1e9)}, - {1 * time.Microsecond, Limit(1e6)}, - {1 * time.Millisecond, Limit(1e3)}, - {10 * time.Millisecond, Limit(100)}, - {100 * time.Millisecond, Limit(10)}, - {1 * time.Second, Limit(1)}, - {2 * time.Second, Limit(0.5)}, - {time.Duration(2.5 * float64(time.Second)), Limit(0.4)}, - {4 * time.Second, Limit(0.25)}, - {10 * time.Second, Limit(0.1)}, - {time.Duration(math.MaxInt64), Limit(1e9 / float64(math.MaxInt64))}, - } - for _, tc := range cases { - lim := Every(tc.interval) - if !closeEnough(lim, tc.lim) { - t.Errorf("Every(%v) = %v want %v", tc.interval, lim, tc.lim) - } - } -} - -const ( - d = 100 * time.Millisecond -) - -var ( - t0 = time.Now() - t1 = t0.Add(time.Duration(1) * d) - t2 = t0.Add(time.Duration(2) * d) - t3 = t0.Add(time.Duration(3) * d) - t4 = t0.Add(time.Duration(4) * d) - t5 = t0.Add(time.Duration(5) * d) - t9 = t0.Add(time.Duration(9) * d) -) - -type allow struct { - t time.Time - n int - ok bool -} - -func run(t *testing.T, lim *Limiter, allows []allow) { - for i, allow := range allows { - ok := lim.AllowN(allow.t, allow.n) - if ok != allow.ok { - t.Errorf("step %d: lim.AllowN(%v, %v) = %v want %v", - i, allow.t, allow.n, ok, allow.ok) - } - } -} - -func TestLimiterBurst1(t *testing.T) { - run(t, NewLimiter(10, 1), []allow{ - {t0, 1, true}, - {t0, 1, false}, - {t0, 1, false}, - {t1, 1, true}, - {t1, 1, false}, - {t1, 1, false}, - {t2, 2, false}, // burst size is 1, so n=2 always fails - {t2, 1, true}, - {t2, 1, false}, - }) -} - -func TestLimiterBurst3(t *testing.T) { - run(t, NewLimiter(10, 3), []allow{ - {t0, 2, true}, - {t0, 2, false}, - {t0, 1, true}, - {t0, 1, false}, - {t1, 4, false}, - {t2, 1, true}, - {t3, 1, true}, - {t4, 1, true}, - {t4, 1, true}, - {t4, 1, false}, - {t4, 1, false}, - {t9, 3, true}, - {t9, 0, true}, - }) -} - -func TestLimiterJumpBackwards(t *testing.T) { - run(t, NewLimiter(10, 3), []allow{ - {t1, 1, true}, // start at t1 - {t0, 1, true}, // jump back to t0, two tokens remain - {t0, 1, true}, - {t0, 1, false}, - {t0, 1, false}, - {t1, 1, true}, // got a token - {t1, 1, false}, - {t1, 1, false}, - {t2, 1, true}, // got another token - {t2, 1, false}, - {t2, 1, false}, - }) -} - -func TestSimultaneousRequests(t *testing.T) { - const ( - limit = 1 - burst = 5 - numRequests = 15 - ) - var ( - wg sync.WaitGroup - numOK = uint32(0) - ) - - // Very slow replenishing bucket. - lim := NewLimiter(limit, burst) - - // Tries to take a token, atomically updates the counter and decreases the wait - // group counter. - f := func() { - defer wg.Done() - if ok := lim.Allow(); ok { - atomic.AddUint32(&numOK, 1) - } - } - - wg.Add(numRequests) - for i := 0; i < numRequests; i++ { - go f() - } - wg.Wait() - if numOK != burst { - t.Errorf("numOK = %d, want %d", numOK, burst) - } -} - -func TestLongRunningQPS(t *testing.T) { - if testing.Short() { - t.Skip("skipping in short mode") - } - if runtime.GOOS == "openbsd" { - t.Skip("low resolution time.Sleep invalidates test (golang.org/issue/14183)") - return - } - - // The test runs for a few seconds executing many requests and then checks - // that overall number of requests is reasonable. - const ( - limit = 100 - burst = 100 - ) - var numOK = int32(0) - - lim := NewLimiter(limit, burst) - - var wg sync.WaitGroup - f := func() { - if ok := lim.Allow(); ok { - atomic.AddInt32(&numOK, 1) - } - wg.Done() - } - - start := time.Now() - end := start.Add(5 * time.Second) - for time.Now().Before(end) { - wg.Add(1) - go f() - - // This will still offer ~500 requests per second, but won't consume - // outrageous amount of CPU. - time.Sleep(2 * time.Millisecond) - } - wg.Wait() - elapsed := time.Since(start) - ideal := burst + (limit * float64(elapsed) / float64(time.Second)) - - // We should never get more requests than allowed. - if want := int32(ideal + 1); numOK > want { - t.Errorf("numOK = %d, want %d (ideal %f)", numOK, want, ideal) - } - // We should get very close to the number of requests allowed. - if want := int32(0.999 * ideal); numOK < want { - t.Errorf("numOK = %d, want %d (ideal %f)", numOK, want, ideal) - } -} - -type request struct { - t time.Time - n int - act time.Time - ok bool -} - -// dFromDuration converts a duration to a multiple of the global constant d -func dFromDuration(dur time.Duration) int { - // Adding a millisecond to be swallowed by the integer division - // because we don't care about small inaccuracies - return int((dur + time.Millisecond) / d) -} - -// dSince returns multiples of d since t0 -func dSince(t time.Time) int { - return dFromDuration(t.Sub(t0)) -} - -func runReserve(t *testing.T, lim *Limiter, req request) *Reservation { - return runReserveMax(t, lim, req, InfDuration) -} - -func runReserveMax(t *testing.T, lim *Limiter, req request, maxReserve time.Duration) *Reservation { - r := lim.reserveN(req.t, req.n, maxReserve) - if r.ok && (dSince(r.timeToAct) != dSince(req.act)) || r.ok != req.ok { - t.Errorf("lim.reserveN(t%d, %v, %v) = (t%d, %v) want (t%d, %v)", - dSince(req.t), req.n, maxReserve, dSince(r.timeToAct), r.ok, dSince(req.act), req.ok) - } - return &r -} - -func TestSimpleReserve(t *testing.T) { - lim := NewLimiter(10, 2) - - runReserve(t, lim, request{t0, 2, t0, true}) - runReserve(t, lim, request{t0, 2, t2, true}) - runReserve(t, lim, request{t3, 2, t4, true}) -} - -func TestMix(t *testing.T) { - lim := NewLimiter(10, 2) - - runReserve(t, lim, request{t0, 3, t1, false}) // should return false because n > Burst - runReserve(t, lim, request{t0, 2, t0, true}) - run(t, lim, []allow{{t1, 2, false}}) // not enought tokens - don't allow - runReserve(t, lim, request{t1, 2, t2, true}) - run(t, lim, []allow{{t1, 1, false}}) // negative tokens - don't allow - run(t, lim, []allow{{t3, 1, true}}) -} - -func TestCancelInvalid(t *testing.T) { - lim := NewLimiter(10, 2) - - runReserve(t, lim, request{t0, 2, t0, true}) - r := runReserve(t, lim, request{t0, 3, t3, false}) - r.CancelAt(t0) // should have no effect - runReserve(t, lim, request{t0, 2, t2, true}) // did not get extra tokens -} - -func TestCancelLast(t *testing.T) { - lim := NewLimiter(10, 2) - - runReserve(t, lim, request{t0, 2, t0, true}) - r := runReserve(t, lim, request{t0, 2, t2, true}) - r.CancelAt(t1) // got 2 tokens back - runReserve(t, lim, request{t1, 2, t2, true}) -} - -func TestCancelTooLate(t *testing.T) { - lim := NewLimiter(10, 2) - - runReserve(t, lim, request{t0, 2, t0, true}) - r := runReserve(t, lim, request{t0, 2, t2, true}) - r.CancelAt(t3) // too late to cancel - should have no effect - runReserve(t, lim, request{t3, 2, t4, true}) -} - -func TestCancel0Tokens(t *testing.T) { - lim := NewLimiter(10, 2) - - runReserve(t, lim, request{t0, 2, t0, true}) - r := runReserve(t, lim, request{t0, 1, t1, true}) - runReserve(t, lim, request{t0, 1, t2, true}) - r.CancelAt(t0) // got 0 tokens back - runReserve(t, lim, request{t0, 1, t3, true}) -} - -func TestCancel1Token(t *testing.T) { - lim := NewLimiter(10, 2) - - runReserve(t, lim, request{t0, 2, t0, true}) - r := runReserve(t, lim, request{t0, 2, t2, true}) - runReserve(t, lim, request{t0, 1, t3, true}) - r.CancelAt(t2) // got 1 token back - runReserve(t, lim, request{t2, 2, t4, true}) -} - -func TestCancelMulti(t *testing.T) { - lim := NewLimiter(10, 4) - - runReserve(t, lim, request{t0, 4, t0, true}) - rA := runReserve(t, lim, request{t0, 3, t3, true}) - runReserve(t, lim, request{t0, 1, t4, true}) - rC := runReserve(t, lim, request{t0, 1, t5, true}) - rC.CancelAt(t1) // get 1 token back - rA.CancelAt(t1) // get 2 tokens back, as if C was never reserved - runReserve(t, lim, request{t1, 3, t5, true}) -} - -func TestReserveJumpBack(t *testing.T) { - lim := NewLimiter(10, 2) - - runReserve(t, lim, request{t1, 2, t1, true}) // start at t1 - runReserve(t, lim, request{t0, 1, t1, true}) // should violate Limit,Burst - runReserve(t, lim, request{t2, 2, t3, true}) -} - -func TestReserveJumpBackCancel(t *testing.T) { - lim := NewLimiter(10, 2) - - runReserve(t, lim, request{t1, 2, t1, true}) // start at t1 - r := runReserve(t, lim, request{t1, 2, t3, true}) - runReserve(t, lim, request{t1, 1, t4, true}) - r.CancelAt(t0) // cancel at t0, get 1 token back - runReserve(t, lim, request{t1, 2, t4, true}) // should violate Limit,Burst -} - -func TestReserveSetLimit(t *testing.T) { - lim := NewLimiter(5, 2) - - runReserve(t, lim, request{t0, 2, t0, true}) - runReserve(t, lim, request{t0, 2, t4, true}) - lim.SetLimitAt(t2, 10) - runReserve(t, lim, request{t2, 1, t4, true}) // violates Limit and Burst -} - -func TestReserveSetLimitCancel(t *testing.T) { - lim := NewLimiter(5, 2) - - runReserve(t, lim, request{t0, 2, t0, true}) - r := runReserve(t, lim, request{t0, 2, t4, true}) - lim.SetLimitAt(t2, 10) - r.CancelAt(t2) // 2 tokens back - runReserve(t, lim, request{t2, 2, t3, true}) -} - -func TestReserveMax(t *testing.T) { - lim := NewLimiter(10, 2) - maxT := d - - runReserveMax(t, lim, request{t0, 2, t0, true}, maxT) - runReserveMax(t, lim, request{t0, 1, t1, true}, maxT) // reserve for close future - runReserveMax(t, lim, request{t0, 1, t2, false}, maxT) // time to act too far in the future -} - -type wait struct { - name string - ctx context.Context - n int - delay int // in multiples of d - nilErr bool -} - -func runWait(t *testing.T, lim *Limiter, w wait) { - start := time.Now() - err := lim.WaitN(w.ctx, w.n) - delay := time.Now().Sub(start) - if (w.nilErr && err != nil) || (!w.nilErr && err == nil) || w.delay != dFromDuration(delay) { - errString := "" - if !w.nilErr { - errString = "" - } - t.Errorf("lim.WaitN(%v, lim, %v) = %v with delay %v ; want %v with delay %v", - w.name, w.n, err, delay, errString, d*time.Duration(w.delay)) - } -} - -func TestWaitSimple(t *testing.T) { - lim := NewLimiter(10, 3) - - ctx, cancel := context.WithCancel(context.Background()) - cancel() - runWait(t, lim, wait{"already-cancelled", ctx, 1, 0, false}) - - runWait(t, lim, wait{"exceed-burst-error", context.Background(), 4, 0, false}) - - runWait(t, lim, wait{"act-now", context.Background(), 2, 0, true}) - runWait(t, lim, wait{"act-later", context.Background(), 3, 2, true}) -} - -func TestWaitCancel(t *testing.T) { - lim := NewLimiter(10, 3) - - ctx, cancel := context.WithCancel(context.Background()) - runWait(t, lim, wait{"act-now", ctx, 2, 0, true}) // after this lim.tokens = 1 - go func() { - time.Sleep(d) - cancel() - }() - runWait(t, lim, wait{"will-cancel", ctx, 3, 1, false}) - // should get 3 tokens back, and have lim.tokens = 2 - t.Logf("tokens:%v last:%v lastEvent:%v", lim.tokens, lim.last, lim.lastEvent) - runWait(t, lim, wait{"act-now-after-cancel", context.Background(), 2, 0, true}) -} - -func TestWaitTimeout(t *testing.T) { - lim := NewLimiter(10, 3) - - ctx, cancel := context.WithTimeout(context.Background(), d) - defer cancel() - runWait(t, lim, wait{"act-now", ctx, 2, 0, true}) - runWait(t, lim, wait{"w-timeout-err", ctx, 3, 0, false}) -} - -func TestWaitInf(t *testing.T) { - lim := NewLimiter(Inf, 0) - - runWait(t, lim, wait{"exceed-burst-no-error", context.Background(), 3, 0, true}) -} - -func BenchmarkAllowN(b *testing.B) { - lim := NewLimiter(Every(1*time.Second), 1) - now := time.Now() - b.ReportAllocs() - b.ResetTimer() - b.RunParallel(func(pb *testing.PB) { - for pb.Next() { - lim.AllowN(now, 1) - } - }) -}