├── .dockerignore ├── .gitignore ├── .travis.yml ├── COPYRIGHT.txt ├── Dockerfile ├── GeoIP2-City.mmdb ├── LICENSE ├── LICENSE.txt ├── README.md ├── geoip.proto ├── main.go ├── proto └── geoip.pb.go ├── service.go ├── service_test.go └── vendor ├── github.com ├── Sirupsen │ └── logrus │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── doc.go │ │ ├── entry.go │ │ ├── exported.go │ │ ├── formatter.go │ │ ├── hooks.go │ │ ├── json_formatter.go │ │ ├── logger.go │ │ ├── logrus.go │ │ ├── terminal_bsd.go │ │ ├── terminal_linux.go │ │ ├── terminal_notwindows.go │ │ ├── terminal_solaris.go │ │ ├── terminal_windows.go │ │ ├── text_formatter.go │ │ └── writer.go ├── golang │ └── protobuf │ │ ├── LICENSE │ │ └── proto │ │ ├── Makefile │ │ ├── clone.go │ │ ├── decode.go │ │ ├── encode.go │ │ ├── equal.go │ │ ├── extensions.go │ │ ├── lib.go │ │ ├── message_set.go │ │ ├── pointer_reflect.go │ │ ├── pointer_unsafe.go │ │ ├── properties.go │ │ ├── text.go │ │ └── text_parser.go └── oschwald │ └── maxminddb-golang │ ├── LICENSE │ ├── README.md │ ├── appveyor.yml │ ├── decoder.go │ ├── errors.go │ ├── key_appengine.go │ ├── key_other.go │ ├── mmap_unix.go │ ├── mmap_windows.go │ ├── reader.go │ ├── reader_appengine.go │ ├── reader_other.go │ ├── traverse.go │ └── verifier.go ├── golang.org └── x │ ├── net │ ├── LICENSE │ ├── PATENTS │ ├── context │ │ ├── context.go │ │ ├── go17.go │ │ └── pre_go17.go │ ├── http2 │ │ ├── Dockerfile │ │ ├── Makefile │ │ ├── README │ │ ├── client_conn_pool.go │ │ ├── configure_transport.go │ │ ├── errors.go │ │ ├── fixed_buffer.go │ │ ├── flow.go │ │ ├── frame.go │ │ ├── go16.go │ │ ├── go17.go │ │ ├── gotrack.go │ │ ├── headermap.go │ │ ├── hpack │ │ │ ├── encode.go │ │ │ ├── hpack.go │ │ │ ├── huffman.go │ │ │ └── tables.go │ │ ├── http2.go │ │ ├── not_go16.go │ │ ├── not_go17.go │ │ ├── pipe.go │ │ ├── server.go │ │ ├── transport.go │ │ ├── write.go │ │ └── writesched.go │ ├── internal │ │ └── timeseries │ │ │ └── timeseries.go │ ├── lex │ │ └── httplex │ │ │ └── httplex.go │ └── trace │ │ ├── events.go │ │ ├── histogram.go │ │ └── trace.go │ └── sys │ ├── LICENSE │ ├── PATENTS │ ├── unix │ ├── asm.s │ ├── asm_darwin_386.s │ ├── asm_darwin_amd64.s │ ├── asm_darwin_arm.s │ ├── asm_darwin_arm64.s │ ├── asm_dragonfly_amd64.s │ ├── asm_freebsd_386.s │ ├── asm_freebsd_amd64.s │ ├── asm_freebsd_arm.s │ ├── asm_linux_386.s │ ├── asm_linux_amd64.s │ ├── asm_linux_arm.s │ ├── asm_linux_arm64.s │ ├── asm_linux_mips64x.s │ ├── asm_linux_ppc64x.s │ ├── asm_linux_s390x.s │ ├── asm_netbsd_386.s │ ├── asm_netbsd_amd64.s │ ├── asm_netbsd_arm.s │ ├── asm_openbsd_386.s │ ├── asm_openbsd_amd64.s │ ├── asm_solaris_amd64.s │ ├── bluetooth_linux.go │ ├── constants.go │ ├── env_unix.go │ ├── env_unset.go │ ├── flock.go │ ├── flock_linux_32bit.go │ ├── gccgo.go │ ├── gccgo_c.c │ ├── gccgo_linux_amd64.go │ ├── mkall.sh │ ├── mkerrors.sh │ ├── mkpost.go │ ├── mksyscall.pl │ ├── mksyscall_solaris.pl │ ├── mksysctl_openbsd.pl │ ├── mksysnum_darwin.pl │ ├── mksysnum_dragonfly.pl │ ├── mksysnum_freebsd.pl │ ├── mksysnum_linux.pl │ ├── mksysnum_netbsd.pl │ ├── mksysnum_openbsd.pl │ ├── race.go │ ├── race0.go │ ├── sockcmsg_linux.go │ ├── sockcmsg_unix.go │ ├── str.go │ ├── syscall.go │ ├── syscall_bsd.go │ ├── syscall_darwin.go │ ├── syscall_darwin_386.go │ ├── syscall_darwin_amd64.go │ ├── syscall_darwin_arm.go │ ├── syscall_darwin_arm64.go │ ├── syscall_dragonfly.go │ ├── syscall_dragonfly_amd64.go │ ├── syscall_freebsd.go │ ├── syscall_freebsd_386.go │ ├── syscall_freebsd_amd64.go │ ├── syscall_freebsd_arm.go │ ├── syscall_linux.go │ ├── syscall_linux_386.go │ ├── syscall_linux_amd64.go │ ├── syscall_linux_arm.go │ ├── syscall_linux_arm64.go │ ├── syscall_linux_mips64x.go │ ├── syscall_linux_ppc64x.go │ ├── syscall_linux_s390x.go │ ├── syscall_netbsd.go │ ├── syscall_netbsd_386.go │ ├── syscall_netbsd_amd64.go │ ├── syscall_netbsd_arm.go │ ├── syscall_no_getwd.go │ ├── syscall_openbsd.go │ ├── syscall_openbsd_386.go │ ├── syscall_openbsd_amd64.go │ ├── syscall_solaris.go │ ├── syscall_solaris_amd64.go │ ├── syscall_unix.go │ ├── types_darwin.go │ ├── types_dragonfly.go │ ├── types_freebsd.go │ ├── types_linux.go │ ├── types_netbsd.go │ ├── types_openbsd.go │ ├── types_solaris.go │ ├── zerrors_darwin_386.go │ ├── zerrors_darwin_amd64.go │ ├── zerrors_darwin_arm.go │ ├── zerrors_darwin_arm64.go │ ├── zerrors_dragonfly_amd64.go │ ├── zerrors_freebsd_386.go │ ├── zerrors_freebsd_amd64.go │ ├── zerrors_freebsd_arm.go │ ├── zerrors_linux_386.go │ ├── zerrors_linux_amd64.go │ ├── zerrors_linux_arm.go │ ├── zerrors_linux_arm64.go │ ├── zerrors_linux_mips64.go │ ├── zerrors_linux_mips64le.go │ ├── zerrors_linux_ppc64.go │ ├── zerrors_linux_ppc64le.go │ ├── zerrors_linux_s390x.go │ ├── zerrors_netbsd_386.go │ ├── zerrors_netbsd_amd64.go │ ├── zerrors_netbsd_arm.go │ ├── zerrors_openbsd_386.go │ ├── zerrors_openbsd_amd64.go │ ├── zerrors_solaris_amd64.go │ ├── zsyscall_darwin_386.go │ ├── zsyscall_darwin_amd64.go │ ├── zsyscall_darwin_arm.go │ ├── zsyscall_darwin_arm64.go │ ├── zsyscall_dragonfly_amd64.go │ ├── zsyscall_freebsd_386.go │ ├── zsyscall_freebsd_amd64.go │ ├── zsyscall_freebsd_arm.go │ ├── zsyscall_linux_386.go │ ├── zsyscall_linux_amd64.go │ ├── zsyscall_linux_arm.go │ ├── zsyscall_linux_arm64.go │ ├── zsyscall_linux_mips64.go │ ├── zsyscall_linux_mips64le.go │ ├── zsyscall_linux_ppc64.go │ ├── zsyscall_linux_ppc64le.go │ ├── zsyscall_linux_s390x.go │ ├── zsyscall_netbsd_386.go │ ├── zsyscall_netbsd_amd64.go │ ├── zsyscall_netbsd_arm.go │ ├── zsyscall_openbsd_386.go │ ├── zsyscall_openbsd_amd64.go │ ├── zsyscall_solaris_amd64.go │ ├── zsysctl_openbsd.go │ ├── zsysnum_darwin_386.go │ ├── zsysnum_darwin_amd64.go │ ├── zsysnum_darwin_arm.go │ ├── zsysnum_darwin_arm64.go │ ├── zsysnum_dragonfly_amd64.go │ ├── zsysnum_freebsd_386.go │ ├── zsysnum_freebsd_amd64.go │ ├── zsysnum_freebsd_arm.go │ ├── zsysnum_linux_386.go │ ├── zsysnum_linux_amd64.go │ ├── zsysnum_linux_arm.go │ ├── zsysnum_linux_arm64.go │ ├── zsysnum_linux_mips64.go │ ├── zsysnum_linux_mips64le.go │ ├── zsysnum_linux_ppc64.go │ ├── zsysnum_linux_ppc64le.go │ ├── zsysnum_linux_s390x.go │ ├── zsysnum_netbsd_386.go │ ├── zsysnum_netbsd_amd64.go │ ├── zsysnum_netbsd_arm.go │ ├── zsysnum_openbsd_386.go │ ├── zsysnum_openbsd_amd64.go │ ├── zsysnum_solaris_amd64.go │ ├── ztypes_darwin_386.go │ ├── ztypes_darwin_amd64.go │ ├── ztypes_darwin_arm.go │ ├── ztypes_darwin_arm64.go │ ├── ztypes_dragonfly_amd64.go │ ├── ztypes_freebsd_386.go │ ├── ztypes_freebsd_amd64.go │ ├── ztypes_freebsd_arm.go │ ├── ztypes_linux_386.go │ ├── ztypes_linux_amd64.go │ ├── ztypes_linux_arm.go │ ├── ztypes_linux_arm64.go │ ├── ztypes_linux_mips64.go │ ├── ztypes_linux_mips64le.go │ ├── ztypes_linux_ppc64.go │ ├── ztypes_linux_ppc64le.go │ ├── ztypes_linux_s390x.go │ ├── ztypes_netbsd_386.go │ ├── ztypes_netbsd_amd64.go │ ├── ztypes_netbsd_arm.go │ ├── ztypes_openbsd_386.go │ ├── ztypes_openbsd_amd64.go │ └── ztypes_solaris_amd64.go │ └── windows │ ├── asm_windows_386.s │ ├── asm_windows_amd64.s │ ├── dll_windows.go │ ├── env_unset.go │ ├── env_windows.go │ ├── eventlog.go │ ├── exec_windows.go │ ├── race.go │ ├── race0.go │ ├── security_windows.go │ ├── service.go │ ├── str.go │ ├── syscall.go │ ├── syscall_windows.go │ ├── zsyscall_windows.go │ ├── ztypes_windows.go │ ├── ztypes_windows_386.go │ └── ztypes_windows_amd64.go ├── google.golang.org └── grpc │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── Makefile │ ├── PATENTS │ ├── README.md │ ├── backoff.go │ ├── balancer.go │ ├── call.go │ ├── clientconn.go │ ├── codegen.sh │ ├── codes │ ├── code_string.go │ └── codes.go │ ├── coverage.sh │ ├── credentials │ ├── credentials.go │ ├── credentials_util_go17.go │ └── credentials_util_pre_go17.go │ ├── doc.go │ ├── grpclog │ └── logger.go │ ├── interceptor.go │ ├── internal │ └── internal.go │ ├── metadata │ └── metadata.go │ ├── naming │ └── naming.go │ ├── peer │ └── peer.go │ ├── rpc_util.go │ ├── server.go │ ├── stream.go │ ├── trace.go │ └── transport │ ├── control.go │ ├── go16.go │ ├── go17.go │ ├── handler_server.go │ ├── http2_client.go │ ├── http2_server.go │ ├── http_util.go │ ├── pre_go16.go │ └── transport.go └── vendor.json /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | pkg 3 | bin 4 | .godeps/pkg 5 | .godeps/bin 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | bin 26 | .godeps 27 | .cache 28 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | 3 | services: 4 | - docker 5 | 6 | before_install: 7 | - docker build -t xtaci/geoip . 8 | 9 | before_script: 10 | script: 11 | - exit 0 12 | -------------------------------------------------------------------------------- /COPYRIGHT.txt: -------------------------------------------------------------------------------- 1 | Database and Contents Copyright (c) 2014 MaxMind, Inc. 2 | 3 | This database is confidential and proprietary to MaxMind, Inc., and may not be 4 | reproduced, published or disclosed to others without company authorization. 5 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:latest 2 | MAINTAINER xtaci 3 | COPY . /go/src/geoip 4 | RUN go install geoip 5 | ENTRYPOINT ["/go/bin/geoip"] 6 | EXPOSE 50000 7 | -------------------------------------------------------------------------------- /GeoIP2-City.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gonet2/geoip/657aab53757136bb4316563077eb0aeb4087f773/GeoIP2-City.mmdb -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 gonet2 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # geoip 2 | [![Build Status](https://travis-ci.org/gonet2/geoip.svg?branch=master)](https://travis-ci.org/gonet2/geoip) 3 | 4 | # 设计思路 5 | 查询IP归属地,基于maxmind的geoip2库做的封装,如果需要最新的准确的数据,需要向maxmind购买。 6 | (query geo-locations of IP, if you need accurate & updated data, please purchase from maxmind.com, thanks. ) 7 | 8 | > 问: 为什么选择maxmind的geoip2库? 9 | > 答: maxmind的geoip2的库设计为一个支持mmap的二叉树文件,查询时间复杂度为O(logN), 文件大小不超过100M,极其紧凑,省内存,速度快,零配置,是目前见过的最好的方案。 10 | 11 | ## 使用 12 | 参考测试用例 13 | 14 | ## 安装 15 | 参考Dockerfile 16 | -------------------------------------------------------------------------------- /geoip.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package proto; 4 | 5 | // geoip service definition 6 | service GeoIPService { 7 | rpc QueryCountry (GeoIP.IP) returns (GeoIP.Name); // 查询IP所属国家 8 | rpc QuerySubdivision (GeoIP.IP) returns (GeoIP.Name); // 查询IP所属地区 9 | rpc QueryCity (GeoIP.IP) returns (GeoIP.Name); // 查询IP所属城市 10 | } 11 | 12 | message GeoIP { 13 | // The request message containing ip address 14 | message IP{ 15 | string ip = 1; 16 | } 17 | 18 | message Name { 19 | string name = 1; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | pb "geoip/proto" 5 | "net" 6 | "os" 7 | 8 | log "github.com/Sirupsen/logrus" 9 | "google.golang.org/grpc" 10 | ) 11 | 12 | const ( 13 | _port = ":50000" 14 | ) 15 | 16 | func main() { 17 | // 监听 18 | lis, err := net.Listen("tcp", _port) 19 | if err != nil { 20 | log.Panic(err) 21 | os.Exit(-1) 22 | } 23 | log.Info("listening on ", lis.Addr()) 24 | 25 | // 注册服务 26 | s := grpc.NewServer() 27 | ins := &server{} 28 | ins.init() 29 | pb.RegisterGeoIPServiceServer(s, ins) 30 | 31 | // 开始服务 32 | s.Serve(lis) 33 | } 34 | -------------------------------------------------------------------------------- /service.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "errors" 5 | pb "geoip/proto" 6 | "net" 7 | "os" 8 | "strings" 9 | 10 | "github.com/oschwald/maxminddb-golang" 11 | 12 | log "github.com/Sirupsen/logrus" 13 | "golang.org/x/net/context" 14 | ) 15 | 16 | const ( 17 | SERVICE = "[GEOIP]" 18 | ) 19 | 20 | var ( 21 | ERROR_CANNOT_QUERY_IP = errors.New("cannot query ip") 22 | ) 23 | 24 | // read the following fields only 25 | type City struct { 26 | City struct { 27 | Names map[string]string `maxminddb:"names"` 28 | } `maxminddb:"city"` 29 | 30 | Country struct { 31 | GeoNameID uint `maxminddb:"geoname_id"` 32 | IsoCode string `maxminddb:"iso_code"` 33 | } `maxminddb:"country"` 34 | 35 | Subdivisions []struct { 36 | Names map[string]string `maxminddb:"names"` 37 | } `maxminddb:"subdivisions"` 38 | } 39 | 40 | type server struct { 41 | mmdb *maxminddb.Reader 42 | } 43 | 44 | func (s *server) init() { 45 | // 载入IP表 46 | log.Debug("Loading GEOIP City...") 47 | reader, err := maxminddb.Open(s.data_path()) 48 | if err != nil { 49 | log.Panic(err) 50 | os.Exit(-1) 51 | } 52 | 53 | s.mmdb = reader 54 | log.Debug("GEOIP City Load Complete.") 55 | } 56 | 57 | // get correct data path from GOPATH 58 | func (s *server) data_path() (path string) { 59 | paths := strings.Split(os.Getenv("GOPATH"), ":") 60 | for k := range paths { 61 | path = paths[k] + "/src/geoip/GeoIP2-City.mmdb" 62 | _, err := os.Lstat(path) 63 | if err == nil { 64 | return path 65 | } 66 | } 67 | return 68 | } 69 | 70 | func (s *server) query(ip net.IP) *City { 71 | city := &City{} 72 | err := s.mmdb.Lookup(ip, city) 73 | if err != nil { 74 | log.Error(err) 75 | return nil 76 | } 77 | 78 | return city 79 | } 80 | 81 | // 查询IP所属国家 82 | func (s *server) QueryCountry(ctx context.Context, in *pb.GeoIP_IP) (*pb.GeoIP_Name, error) { 83 | ip := net.ParseIP(in.Ip) 84 | if city := s.query(ip); city != nil { 85 | return &pb.GeoIP_Name{Name: city.Country.IsoCode}, nil 86 | } 87 | return nil, ERROR_CANNOT_QUERY_IP 88 | } 89 | 90 | // 查询IP所属城市 91 | func (s *server) QueryCity(ctx context.Context, in *pb.GeoIP_IP) (*pb.GeoIP_Name, error) { 92 | ip := net.ParseIP(in.Ip) 93 | if city := s.query(ip); city != nil { 94 | return &pb.GeoIP_Name{Name: city.City.Names["en"]}, nil 95 | } 96 | return nil, ERROR_CANNOT_QUERY_IP 97 | } 98 | 99 | // 查询IP所属地区(省) 100 | func (s *server) QuerySubdivision(ctx context.Context, in *pb.GeoIP_IP) (*pb.GeoIP_Name, error) { 101 | ip := net.ParseIP(in.Ip) 102 | if city := s.query(ip); city != nil { 103 | if len(city.Subdivisions) > 0 { 104 | return &pb.GeoIP_Name{Name: city.Subdivisions[0].Names["en"]}, nil 105 | } 106 | return nil, ERROR_CANNOT_QUERY_IP 107 | } 108 | return nil, ERROR_CANNOT_QUERY_IP 109 | } 110 | -------------------------------------------------------------------------------- /service_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "golang.org/x/net/context" 5 | "google.golang.org/grpc" 6 | "log" 7 | pb "proto" 8 | "testing" 9 | ) 10 | 11 | const ( 12 | address = "localhost:50000" 13 | default_ip = "106.187.101.141" 14 | ) 15 | 16 | func TestGeoIP(t *testing.T) { 17 | // Set up a connection to the server. 18 | conn, err := grpc.Dial(address) 19 | if err != nil { 20 | log.Fatalf("did not connect: %v", err) 21 | } 22 | defer conn.Close() 23 | c := pb.NewGeoIPServiceClient(conn) 24 | 25 | // Contact the server and print out its response. 26 | r, err := c.QueryCountry(context.Background(), &pb.GeoIP_IP{Ip: default_ip}) 27 | if err != nil { 28 | log.Fatalf("could not query: %v", err) 29 | } 30 | log.Printf("Country: %s", r.Name) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.10.0 2 | 3 | * feature: Add a test hook (#180) 4 | * feature: `ParseLevel` is now case-insensitive (#326) 5 | * feature: `FieldLogger` interface that generalizes `Logger` and `Entry` (#308) 6 | * performance: avoid re-allocations on `WithFields` (#335) 7 | 8 | # 0.9.0 9 | 10 | * logrus/text_formatter: don't emit empty msg 11 | * logrus/hooks/airbrake: move out of main repository 12 | * logrus/hooks/sentry: move out of main repository 13 | * logrus/hooks/papertrail: move out of main repository 14 | * logrus/hooks/bugsnag: move out of main repository 15 | * logrus/core: run tests with `-race` 16 | * logrus/core: detect TTY based on `stderr` 17 | * logrus/core: support `WithError` on logger 18 | * logrus/core: Solaris support 19 | 20 | # 0.8.7 21 | 22 | * logrus/core: fix possible race (#216) 23 | * logrus/doc: small typo fixes and doc improvements 24 | 25 | 26 | # 0.8.6 27 | 28 | * hooks/raven: allow passing an initialized client 29 | 30 | # 0.8.5 31 | 32 | * logrus/core: revert #208 33 | 34 | # 0.8.4 35 | 36 | * formatter/text: fix data race (#218) 37 | 38 | # 0.8.3 39 | 40 | * logrus/core: fix entry log level (#208) 41 | * logrus/core: improve performance of text formatter by 40% 42 | * logrus/core: expose `LevelHooks` type 43 | * logrus/core: add support for DragonflyBSD and NetBSD 44 | * formatter/text: print structs more verbosely 45 | 46 | # 0.8.2 47 | 48 | * logrus: fix more Fatal family functions 49 | 50 | # 0.8.1 51 | 52 | * logrus: fix not exiting on `Fatalf` and `Fatalln` 53 | 54 | # 0.8.0 55 | 56 | * logrus: defaults to stderr instead of stdout 57 | * hooks/sentry: add special field for `*http.Request` 58 | * formatter/text: ignore Windows for colors 59 | 60 | # 0.7.3 61 | 62 | * formatter/\*: allow configuration of timestamp layout 63 | 64 | # 0.7.2 65 | 66 | * formatter/text: Add configuration option for time format (#158) 67 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Simon Eskildsen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package logrus is a structured logger for Go, completely API compatible with the standard library logger. 3 | 4 | 5 | The simplest way to use Logrus is simply the package-level exported logger: 6 | 7 | package main 8 | 9 | import ( 10 | log "github.com/Sirupsen/logrus" 11 | ) 12 | 13 | func main() { 14 | log.WithFields(log.Fields{ 15 | "animal": "walrus", 16 | "number": 1, 17 | "size": 10, 18 | }).Info("A walrus appears") 19 | } 20 | 21 | Output: 22 | time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10 23 | 24 | For a full guide visit https://github.com/Sirupsen/logrus 25 | */ 26 | package logrus 27 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import "time" 4 | 5 | const DefaultTimestampFormat = time.RFC3339 6 | 7 | // The Formatter interface is used to implement a custom Formatter. It takes an 8 | // `Entry`. It exposes all the fields, including the default ones: 9 | // 10 | // * `entry.Data["msg"]`. The message passed from Info, Warn, Error .. 11 | // * `entry.Data["time"]`. The timestamp. 12 | // * `entry.Data["level"]. The level the entry was logged at. 13 | // 14 | // Any additional fields added with `WithField` or `WithFields` are also in 15 | // `entry.Data`. Format is expected to return an array of bytes which are then 16 | // logged to `logger.Out`. 17 | type Formatter interface { 18 | Format(*Entry) ([]byte, error) 19 | } 20 | 21 | // This is to not silently overwrite `time`, `msg` and `level` fields when 22 | // dumping it. If this code wasn't there doing: 23 | // 24 | // logrus.WithField("level", 1).Info("hello") 25 | // 26 | // Would just silently drop the user provided level. Instead with this code 27 | // it'll logged as: 28 | // 29 | // {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."} 30 | // 31 | // It's not exported because it's still using Data in an opinionated way. It's to 32 | // avoid code duplication between the two default formatters. 33 | func prefixFieldClashes(data Fields) { 34 | if t, ok := data["time"]; ok { 35 | data["fields.time"] = t 36 | } 37 | 38 | if m, ok := data["msg"]; ok { 39 | data["fields.msg"] = m 40 | } 41 | 42 | if l, ok := data["level"]; ok { 43 | data["fields.level"] = l 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | // A hook to be fired when logging on the logging levels returned from 4 | // `Levels()` on your implementation of the interface. Note that this is not 5 | // fired in a goroutine or a channel with workers, you should handle such 6 | // functionality yourself if your call is non-blocking and you don't wish for 7 | // the logging calls for levels returned from `Levels()` to block. 8 | type Hook interface { 9 | Levels() []Level 10 | Fire(*Entry) error 11 | } 12 | 13 | // Internal type for storing the hooks on a logger instance. 14 | type LevelHooks map[Level][]Hook 15 | 16 | // Add a hook to an instance of logger. This is called with 17 | // `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface. 18 | func (hooks LevelHooks) Add(hook Hook) { 19 | for _, level := range hook.Levels() { 20 | hooks[level] = append(hooks[level], hook) 21 | } 22 | } 23 | 24 | // Fire all the hooks for the passed level. Used by `entry.log` to fire 25 | // appropriate hooks for a log entry. 26 | func (hooks LevelHooks) Fire(level Level, entry *Entry) error { 27 | for _, hook := range hooks[level] { 28 | if err := hook.Fire(entry); err != nil { 29 | return err 30 | } 31 | } 32 | 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/json_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | ) 7 | 8 | type JSONFormatter struct { 9 | // TimestampFormat sets the format used for marshaling timestamps. 10 | TimestampFormat string 11 | } 12 | 13 | func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { 14 | data := make(Fields, len(entry.Data)+3) 15 | for k, v := range entry.Data { 16 | switch v := v.(type) { 17 | case error: 18 | // Otherwise errors are ignored by `encoding/json` 19 | // https://github.com/Sirupsen/logrus/issues/137 20 | data[k] = v.Error() 21 | default: 22 | data[k] = v 23 | } 24 | } 25 | prefixFieldClashes(data) 26 | 27 | timestampFormat := f.TimestampFormat 28 | if timestampFormat == "" { 29 | timestampFormat = DefaultTimestampFormat 30 | } 31 | 32 | data["time"] = entry.Time.Format(timestampFormat) 33 | data["msg"] = entry.Message 34 | data["level"] = entry.Level.String() 35 | 36 | serialized, err := json.Marshal(data) 37 | if err != nil { 38 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) 39 | } 40 | return append(serialized, '\n'), nil 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/logrus.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "strings" 7 | ) 8 | 9 | // Fields type, used to pass to `WithFields`. 10 | type Fields map[string]interface{} 11 | 12 | // Level type 13 | type Level uint8 14 | 15 | // Convert the Level to a string. E.g. PanicLevel becomes "panic". 16 | func (level Level) String() string { 17 | switch level { 18 | case DebugLevel: 19 | return "debug" 20 | case InfoLevel: 21 | return "info" 22 | case WarnLevel: 23 | return "warning" 24 | case ErrorLevel: 25 | return "error" 26 | case FatalLevel: 27 | return "fatal" 28 | case PanicLevel: 29 | return "panic" 30 | } 31 | 32 | return "unknown" 33 | } 34 | 35 | // ParseLevel takes a string level and returns the Logrus log level constant. 36 | func ParseLevel(lvl string) (Level, error) { 37 | switch strings.ToLower(lvl) { 38 | case "panic": 39 | return PanicLevel, nil 40 | case "fatal": 41 | return FatalLevel, nil 42 | case "error": 43 | return ErrorLevel, nil 44 | case "warn", "warning": 45 | return WarnLevel, nil 46 | case "info": 47 | return InfoLevel, nil 48 | case "debug": 49 | return DebugLevel, nil 50 | } 51 | 52 | var l Level 53 | return l, fmt.Errorf("not a valid logrus Level: %q", lvl) 54 | } 55 | 56 | // A constant exposing all logging levels 57 | var AllLevels = []Level{ 58 | PanicLevel, 59 | FatalLevel, 60 | ErrorLevel, 61 | WarnLevel, 62 | InfoLevel, 63 | DebugLevel, 64 | } 65 | 66 | // These are the different logging levels. You can set the logging level to log 67 | // on your instance of logger, obtained with `logrus.New()`. 68 | const ( 69 | // PanicLevel level, highest level of severity. Logs and then calls panic with the 70 | // message passed to Debug, Info, ... 71 | PanicLevel Level = iota 72 | // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the 73 | // logging level is set to Panic. 74 | FatalLevel 75 | // ErrorLevel level. Logs. Used for errors that should definitely be noted. 76 | // Commonly used for hooks to send errors to an error tracking service. 77 | ErrorLevel 78 | // WarnLevel level. Non-critical entries that deserve eyes. 79 | WarnLevel 80 | // InfoLevel level. General operational entries about what's going on inside the 81 | // application. 82 | InfoLevel 83 | // DebugLevel level. Usually only enabled when debugging. Very verbose logging. 84 | DebugLevel 85 | ) 86 | 87 | // Won't compile if StdLogger can't be realized by a log.Logger 88 | var ( 89 | _ StdLogger = &log.Logger{} 90 | _ StdLogger = &Entry{} 91 | _ StdLogger = &Logger{} 92 | ) 93 | 94 | // StdLogger is what your logrus-enabled library should take, that way 95 | // it'll accept a stdlib logger and a logrus logger. There's no standard 96 | // interface, this is the closest we get, unfortunately. 97 | type StdLogger interface { 98 | Print(...interface{}) 99 | Printf(string, ...interface{}) 100 | Println(...interface{}) 101 | 102 | Fatal(...interface{}) 103 | Fatalf(string, ...interface{}) 104 | Fatalln(...interface{}) 105 | 106 | Panic(...interface{}) 107 | Panicf(string, ...interface{}) 108 | Panicln(...interface{}) 109 | } 110 | 111 | // The FieldLogger interface generalizes the Entry and Logger types 112 | type FieldLogger interface { 113 | WithField(key string, value interface{}) *Entry 114 | WithFields(fields Fields) *Entry 115 | WithError(err error) *Entry 116 | 117 | Debugf(format string, args ...interface{}) 118 | Infof(format string, args ...interface{}) 119 | Printf(format string, args ...interface{}) 120 | Warnf(format string, args ...interface{}) 121 | Warningf(format string, args ...interface{}) 122 | Errorf(format string, args ...interface{}) 123 | Fatalf(format string, args ...interface{}) 124 | Panicf(format string, args ...interface{}) 125 | 126 | Debug(args ...interface{}) 127 | Info(args ...interface{}) 128 | Print(args ...interface{}) 129 | Warn(args ...interface{}) 130 | Warning(args ...interface{}) 131 | Error(args ...interface{}) 132 | Fatal(args ...interface{}) 133 | Panic(args ...interface{}) 134 | 135 | Debugln(args ...interface{}) 136 | Infoln(args ...interface{}) 137 | Println(args ...interface{}) 138 | Warnln(args ...interface{}) 139 | Warningln(args ...interface{}) 140 | Errorln(args ...interface{}) 141 | Fatalln(args ...interface{}) 142 | Panicln(args ...interface{}) 143 | } 144 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | 3 | package logrus 4 | 5 | import "syscall" 6 | 7 | const ioctlReadTermios = syscall.TIOCGETA 8 | 9 | type Termios syscall.Termios 10 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_linux.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2013 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package logrus 7 | 8 | import "syscall" 9 | 10 | const ioctlReadTermios = syscall.TCGETS 11 | 12 | type Termios syscall.Termios 13 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_notwindows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build linux darwin freebsd openbsd netbsd dragonfly 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | // IsTerminal returns true if stderr's file descriptor is a terminal. 16 | func IsTerminal() bool { 17 | fd := syscall.Stderr 18 | var termios Termios 19 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 20 | return err == 0 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | 3 | package logrus 4 | 5 | import ( 6 | "os" 7 | 8 | "golang.org/x/sys/unix" 9 | ) 10 | 11 | // IsTerminal returns true if the given file descriptor is a terminal. 12 | func IsTerminal() bool { 13 | _, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA) 14 | return err == nil 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_windows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build windows 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 16 | 17 | var ( 18 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 19 | ) 20 | 21 | // IsTerminal returns true if stderr's file descriptor is a terminal. 22 | func IsTerminal() bool { 23 | fd := syscall.Stderr 24 | var st uint32 25 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 26 | return r != 0 && e == 0 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/text_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "runtime" 7 | "sort" 8 | "strings" 9 | "time" 10 | ) 11 | 12 | const ( 13 | nocolor = 0 14 | red = 31 15 | green = 32 16 | yellow = 33 17 | blue = 34 18 | gray = 37 19 | ) 20 | 21 | var ( 22 | baseTimestamp time.Time 23 | isTerminal bool 24 | ) 25 | 26 | func init() { 27 | baseTimestamp = time.Now() 28 | isTerminal = IsTerminal() 29 | } 30 | 31 | func miniTS() int { 32 | return int(time.Since(baseTimestamp) / time.Second) 33 | } 34 | 35 | type TextFormatter struct { 36 | // Set to true to bypass checking for a TTY before outputting colors. 37 | ForceColors bool 38 | 39 | // Force disabling colors. 40 | DisableColors bool 41 | 42 | // Disable timestamp logging. useful when output is redirected to logging 43 | // system that already adds timestamps. 44 | DisableTimestamp bool 45 | 46 | // Enable logging the full timestamp when a TTY is attached instead of just 47 | // the time passed since beginning of execution. 48 | FullTimestamp bool 49 | 50 | // TimestampFormat to use for display when a full timestamp is printed 51 | TimestampFormat string 52 | 53 | // The fields are sorted by default for a consistent output. For applications 54 | // that log extremely frequently and don't use the JSON formatter this may not 55 | // be desired. 56 | DisableSorting bool 57 | } 58 | 59 | func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { 60 | var keys []string = make([]string, 0, len(entry.Data)) 61 | for k := range entry.Data { 62 | keys = append(keys, k) 63 | } 64 | 65 | if !f.DisableSorting { 66 | sort.Strings(keys) 67 | } 68 | 69 | b := &bytes.Buffer{} 70 | 71 | prefixFieldClashes(entry.Data) 72 | 73 | isColorTerminal := isTerminal && (runtime.GOOS != "windows") 74 | isColored := (f.ForceColors || isColorTerminal) && !f.DisableColors 75 | 76 | timestampFormat := f.TimestampFormat 77 | if timestampFormat == "" { 78 | timestampFormat = DefaultTimestampFormat 79 | } 80 | if isColored { 81 | f.printColored(b, entry, keys, timestampFormat) 82 | } else { 83 | if !f.DisableTimestamp { 84 | f.appendKeyValue(b, "time", entry.Time.Format(timestampFormat)) 85 | } 86 | f.appendKeyValue(b, "level", entry.Level.String()) 87 | if entry.Message != "" { 88 | f.appendKeyValue(b, "msg", entry.Message) 89 | } 90 | for _, key := range keys { 91 | f.appendKeyValue(b, key, entry.Data[key]) 92 | } 93 | } 94 | 95 | b.WriteByte('\n') 96 | return b.Bytes(), nil 97 | } 98 | 99 | func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []string, timestampFormat string) { 100 | var levelColor int 101 | switch entry.Level { 102 | case DebugLevel: 103 | levelColor = gray 104 | case WarnLevel: 105 | levelColor = yellow 106 | case ErrorLevel, FatalLevel, PanicLevel: 107 | levelColor = red 108 | default: 109 | levelColor = blue 110 | } 111 | 112 | levelText := strings.ToUpper(entry.Level.String())[0:4] 113 | 114 | if !f.FullTimestamp { 115 | fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, miniTS(), entry.Message) 116 | } else { 117 | fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %-44s ", levelColor, levelText, entry.Time.Format(timestampFormat), entry.Message) 118 | } 119 | for _, k := range keys { 120 | v := entry.Data[k] 121 | fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=%+v", levelColor, k, v) 122 | } 123 | } 124 | 125 | func needsQuoting(text string) bool { 126 | for _, ch := range text { 127 | if !((ch >= 'a' && ch <= 'z') || 128 | (ch >= 'A' && ch <= 'Z') || 129 | (ch >= '0' && ch <= '9') || 130 | ch == '-' || ch == '.') { 131 | return true 132 | } 133 | } 134 | return false 135 | } 136 | 137 | func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) { 138 | 139 | b.WriteString(key) 140 | b.WriteByte('=') 141 | 142 | switch value := value.(type) { 143 | case string: 144 | if !needsQuoting(value) { 145 | b.WriteString(value) 146 | } else { 147 | fmt.Fprintf(b, "%q", value) 148 | } 149 | case error: 150 | errmsg := value.Error() 151 | if !needsQuoting(errmsg) { 152 | b.WriteString(errmsg) 153 | } else { 154 | fmt.Fprintf(b, "%q", value) 155 | } 156 | default: 157 | fmt.Fprint(b, value) 158 | } 159 | 160 | b.WriteByte(' ') 161 | } 162 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/writer.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "runtime" 7 | ) 8 | 9 | func (logger *Logger) Writer() *io.PipeWriter { 10 | return logger.WriterLevel(InfoLevel) 11 | } 12 | 13 | func (logger *Logger) WriterLevel(level Level) *io.PipeWriter { 14 | reader, writer := io.Pipe() 15 | 16 | var printFunc func(args ...interface{}) 17 | switch level { 18 | case DebugLevel: 19 | printFunc = logger.Debug 20 | case InfoLevel: 21 | printFunc = logger.Info 22 | case WarnLevel: 23 | printFunc = logger.Warn 24 | case ErrorLevel: 25 | printFunc = logger.Error 26 | case FatalLevel: 27 | printFunc = logger.Fatal 28 | case PanicLevel: 29 | printFunc = logger.Panic 30 | default: 31 | printFunc = logger.Print 32 | } 33 | 34 | go logger.writerScanner(reader, printFunc) 35 | runtime.SetFinalizer(writer, writerFinalizer) 36 | 37 | return writer 38 | } 39 | 40 | func (logger *Logger) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) { 41 | scanner := bufio.NewScanner(reader) 42 | for scanner.Scan() { 43 | printFunc(scanner.Text()) 44 | } 45 | if err := scanner.Err(); err != nil { 46 | logger.Errorf("Error while reading from Writer: %s", err) 47 | } 48 | reader.Close() 49 | } 50 | 51 | func writerFinalizer(writer *io.PipeWriter) { 52 | writer.Close() 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/LICENSE: -------------------------------------------------------------------------------- 1 | Go support for Protocol Buffers - Google's data interchange format 2 | 3 | Copyright 2010 The Go Authors. All rights reserved. 4 | https://github.com/golang/protobuf 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following disclaimer 14 | in the documentation and/or other materials provided with the 15 | distribution. 16 | * Neither the name of Google Inc. nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | install: 33 | go install 34 | 35 | test: install generate-test-pbs 36 | go test 37 | 38 | 39 | generate-test-pbs: 40 | make install 41 | make -C testdata 42 | protoc --go_out=Mtestdata/test.proto=github.com/golang/protobuf/proto/testdata,Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any:. proto3_proto/proto3.proto 43 | make 44 | -------------------------------------------------------------------------------- /vendor/github.com/oschwald/maxminddb-golang/LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2015, Gregory J. Oschwald 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 10 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 12 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 14 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15 | PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /vendor/github.com/oschwald/maxminddb-golang/README.md: -------------------------------------------------------------------------------- 1 | # MaxMind DB Reader for Go # 2 | 3 | [![Build Status](https://travis-ci.org/oschwald/maxminddb-golang.png?branch=master)](https://travis-ci.org/oschwald/maxminddb-golang) 4 | [![Windows Build Status](https://ci.appveyor.com/api/projects/status/4j2f9oep8nnfrmov/branch/master?svg=true)](https://ci.appveyor.com/project/oschwald/maxminddb-golang/branch/master) 5 | [![GoDoc](https://godoc.org/github.com/oschwald/maxminddb-golang?status.png)](https://godoc.org/github.com/oschwald/maxminddb-golang) 6 | 7 | This is a Go reader for the MaxMind DB format. Although this can be used to 8 | read [GeoLite2](http://dev.maxmind.com/geoip/geoip2/geolite2/) and 9 | [GeoIP2](https://www.maxmind.com/en/geoip2-databases) databases, 10 | [geoip2](https://github.com/oschwald/geoip2-golang) provides a higher-level 11 | API for doing so. 12 | 13 | This is not an official MaxMind API. 14 | 15 | ## Installation ## 16 | 17 | ``` 18 | go get github.com/oschwald/maxminddb-golang 19 | ``` 20 | 21 | ## Usage ## 22 | 23 | [See GoDoc](http://godoc.org/github.com/oschwald/maxminddb-golang) for 24 | documentation and examples. 25 | 26 | ## Examples ## 27 | 28 | See [GoDoc](http://godoc.org/github.com/oschwald/maxminddb-golang) or 29 | `example_test.go` for examples. 30 | 31 | ## Contributing ## 32 | 33 | Contributions welcome! Please fork the repository and open a pull request 34 | with your changes. 35 | 36 | ## License ## 37 | 38 | This is free software, licensed under the ISC License. 39 | -------------------------------------------------------------------------------- /vendor/github.com/oschwald/maxminddb-golang/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | 3 | os: Windows Server 2012 R2 4 | 5 | clone_folder: c:\gopath\src\github.com\oschwald\maxminddb-golang 6 | 7 | environment: 8 | GOPATH: c:\gopath 9 | 10 | install: 11 | - echo %PATH% 12 | - echo %GOPATH% 13 | - git submodule update --init --recursive 14 | - go version 15 | - go env 16 | - go get -v -t ./... 17 | 18 | build_script: 19 | - go test -v ./... 20 | -------------------------------------------------------------------------------- /vendor/github.com/oschwald/maxminddb-golang/errors.go: -------------------------------------------------------------------------------- 1 | package maxminddb 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | // InvalidDatabaseError is returned when the database contains invalid data 9 | // and cannot be parsed. 10 | type InvalidDatabaseError struct { 11 | message string 12 | } 13 | 14 | func newInvalidDatabaseError(format string, args ...interface{}) InvalidDatabaseError { 15 | return InvalidDatabaseError{fmt.Sprintf(format, args...)} 16 | } 17 | 18 | func (e InvalidDatabaseError) Error() string { 19 | return e.message 20 | } 21 | 22 | // UnmarshalTypeError is returned when the value in the database cannot be 23 | // assigned to the specified data type. 24 | type UnmarshalTypeError struct { 25 | Value string // stringified copy of the database value that caused the error 26 | Type reflect.Type // type of the value that could not be assign to 27 | } 28 | 29 | func newUnmarshalTypeError(value interface{}, rType reflect.Type) UnmarshalTypeError { 30 | return UnmarshalTypeError{ 31 | Value: fmt.Sprintf("%v", value), 32 | Type: rType, 33 | } 34 | } 35 | 36 | func (e UnmarshalTypeError) Error() string { 37 | return fmt.Sprintf("maxminddb: cannot unmarshal %s into type %s", e.Value, e.Type.String()) 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/oschwald/maxminddb-golang/key_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package maxminddb 4 | 5 | func (d *decoder) decodeStructKey(offset uint) (string, uint, error) { 6 | return d.decodeKeyString(offset) 7 | } 8 | -------------------------------------------------------------------------------- /vendor/github.com/oschwald/maxminddb-golang/key_other.go: -------------------------------------------------------------------------------- 1 | // +build !appengine 2 | 3 | package maxminddb 4 | 5 | import ( 6 | "reflect" 7 | "unsafe" 8 | ) 9 | 10 | // decodeStructKey returns a string which points into the database. Don't keep 11 | // it around. 12 | func (d *decoder) decodeStructKey(offset uint) (string, uint, error) { 13 | typeNum, size, newOffset := d.decodeCtrlData(offset) 14 | switch typeNum { 15 | case _Pointer: 16 | pointer, ptrOffset := d.decodePointer(size, newOffset) 17 | s, _, err := d.decodeStructKey(pointer) 18 | return s, ptrOffset, err 19 | case _String: 20 | var s string 21 | val := (*reflect.StringHeader)(unsafe.Pointer(&s)) 22 | val.Data = uintptr(unsafe.Pointer(&d.buffer[newOffset])) 23 | val.Len = int(size) 24 | return s, newOffset + size, nil 25 | default: 26 | return "", 0, newInvalidDatabaseError("unexpected type when decoding struct key: %v", typeNum) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/oschwald/maxminddb-golang/mmap_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows,!appengine 2 | 3 | package maxminddb 4 | 5 | import ( 6 | "syscall" 7 | 8 | "golang.org/x/sys/unix" 9 | ) 10 | 11 | func mmap(fd int, length int) (data []byte, err error) { 12 | return unix.Mmap(fd, 0, length, syscall.PROT_READ, syscall.MAP_SHARED) 13 | } 14 | 15 | func munmap(b []byte) (err error) { 16 | return unix.Munmap(b) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/oschwald/maxminddb-golang/mmap_windows.go: -------------------------------------------------------------------------------- 1 | package maxminddb 2 | 3 | // Windows support largely borrowed from mmap-go. 4 | // 5 | // Copyright 2011 Evan Shaw. All rights reserved. 6 | // Use of this source code is governed by a BSD-style 7 | // license that can be found in the LICENSE file. 8 | 9 | import ( 10 | "errors" 11 | "os" 12 | "reflect" 13 | "sync" 14 | "unsafe" 15 | 16 | "golang.org/x/sys/windows" 17 | ) 18 | 19 | type memoryMap []byte 20 | 21 | // Windows 22 | var handleLock sync.Mutex 23 | var handleMap = map[uintptr]windows.Handle{} 24 | 25 | func mmap(fd int, length int) (data []byte, err error) { 26 | h, errno := windows.CreateFileMapping(windows.Handle(fd), nil, 27 | uint32(windows.PAGE_READONLY), 0, uint32(length), nil) 28 | if h == 0 { 29 | return nil, os.NewSyscallError("CreateFileMapping", errno) 30 | } 31 | 32 | addr, errno := windows.MapViewOfFile(h, uint32(windows.FILE_MAP_READ), 0, 33 | 0, uintptr(length)) 34 | if addr == 0 { 35 | return nil, os.NewSyscallError("MapViewOfFile", errno) 36 | } 37 | handleLock.Lock() 38 | handleMap[addr] = h 39 | handleLock.Unlock() 40 | 41 | m := memoryMap{} 42 | dh := m.header() 43 | dh.Data = addr 44 | dh.Len = length 45 | dh.Cap = dh.Len 46 | 47 | return m, nil 48 | } 49 | 50 | func (m *memoryMap) header() *reflect.SliceHeader { 51 | return (*reflect.SliceHeader)(unsafe.Pointer(m)) 52 | } 53 | 54 | func flush(addr, len uintptr) error { 55 | errno := windows.FlushViewOfFile(addr, len) 56 | return os.NewSyscallError("FlushViewOfFile", errno) 57 | } 58 | 59 | func munmap(b []byte) (err error) { 60 | m := memoryMap(b) 61 | dh := m.header() 62 | 63 | addr := dh.Data 64 | length := uintptr(dh.Len) 65 | 66 | flush(addr, length) 67 | err = windows.UnmapViewOfFile(addr) 68 | if err != nil { 69 | return err 70 | } 71 | 72 | handleLock.Lock() 73 | defer handleLock.Unlock() 74 | handle, ok := handleMap[addr] 75 | if !ok { 76 | // should be impossible; we would've errored above 77 | return errors.New("unknown base address") 78 | } 79 | delete(handleMap, addr) 80 | 81 | e := windows.CloseHandle(windows.Handle(handle)) 82 | return os.NewSyscallError("CloseHandle", e) 83 | } 84 | -------------------------------------------------------------------------------- /vendor/github.com/oschwald/maxminddb-golang/reader_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package maxminddb 4 | 5 | import "io/ioutil" 6 | 7 | // Open takes a string path to a MaxMind DB file and returns a Reader 8 | // structure or an error. The database file is opened using a memory map, 9 | // except on Google App Engine where mmap is not supported; there the database 10 | // is loaded into memory. Use the Close method on the Reader object to return 11 | // the resources to the system. 12 | func Open(file string) (*Reader, error) { 13 | bytes, err := ioutil.ReadFile(file) 14 | if err != nil { 15 | return nil, err 16 | } 17 | 18 | return FromBytes(bytes) 19 | } 20 | 21 | // Close unmaps the database file from virtual memory and returns the 22 | // resources to the system. If called on a Reader opened using FromBytes 23 | // or Open on Google App Engine, this method does nothing. 24 | func (r *Reader) Close() error { 25 | return nil 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/oschwald/maxminddb-golang/reader_other.go: -------------------------------------------------------------------------------- 1 | // +build !appengine 2 | 3 | package maxminddb 4 | 5 | import "os" 6 | 7 | // Open takes a string path to a MaxMind DB file and returns a Reader 8 | // structure or an error. The database file is opened using a memory map, 9 | // except on Google App Engine where mmap is not supported; there the database 10 | // is loaded into memory. Use the Close method on the Reader object to return 11 | // the resources to the system. 12 | func Open(file string) (*Reader, error) { 13 | mapFile, err := os.Open(file) 14 | if err != nil { 15 | return nil, err 16 | } 17 | defer func() { 18 | if rerr := mapFile.Close(); rerr != nil { 19 | err = rerr 20 | } 21 | }() 22 | 23 | stats, err := mapFile.Stat() 24 | if err != nil { 25 | return nil, err 26 | } 27 | 28 | fileSize := int(stats.Size()) 29 | mmap, err := mmap(int(mapFile.Fd()), fileSize) 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | reader, err := FromBytes(mmap) 35 | if err != nil { 36 | if err2 := munmap(mmap); err2 != nil { 37 | // failing to unmap the file is probably the more severe error 38 | return nil, err2 39 | } 40 | return nil, err 41 | } 42 | 43 | reader.hasMappedFile = true 44 | return reader, err 45 | } 46 | 47 | // Close unmaps the database file from virtual memory and returns the 48 | // resources to the system. If called on a Reader opened using FromBytes 49 | // or Open on Google App Engine, this method does nothing. 50 | func (r *Reader) Close() (err error) { 51 | if r.hasMappedFile { 52 | err = munmap(r.buffer) 53 | r.hasMappedFile = false 54 | } 55 | return err 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/oschwald/maxminddb-golang/traverse.go: -------------------------------------------------------------------------------- 1 | package maxminddb 2 | 3 | import "net" 4 | 5 | // Internal structure used to keep track of nodes we still need to visit. 6 | type netNode struct { 7 | ip net.IP 8 | bit uint 9 | pointer uint 10 | } 11 | 12 | // Networks represents a set of subnets that we are iterating over. 13 | type Networks struct { 14 | reader *Reader 15 | nodes []netNode // Nodes we still have to visit. 16 | lastNode netNode 17 | err error 18 | } 19 | 20 | // Networks returns an iterator that can be used to traverse all networks in 21 | // the database. 22 | // 23 | // Please note that a MaxMind DB may map IPv4 networks into several locations 24 | // in in an IPv6 database. This iterator will iterate over all of these 25 | // locations separately. 26 | func (r *Reader) Networks() *Networks { 27 | s := 4 28 | if r.Metadata.IPVersion == 6 { 29 | s = 16 30 | } 31 | return &Networks{ 32 | reader: r, 33 | nodes: []netNode{ 34 | { 35 | ip: make(net.IP, s), 36 | }, 37 | }, 38 | } 39 | } 40 | 41 | // Next prepares the next network for reading with the Network method. It 42 | // returns true if there is another network to be processed and false if there 43 | // are no more networks or if there is an error. 44 | func (n *Networks) Next() bool { 45 | for len(n.nodes) > 0 { 46 | node := n.nodes[len(n.nodes)-1] 47 | n.nodes = n.nodes[:len(n.nodes)-1] 48 | 49 | for { 50 | if node.pointer < n.reader.Metadata.NodeCount { 51 | ipRight := make(net.IP, len(node.ip)) 52 | copy(ipRight, node.ip) 53 | if len(ipRight) <= int(node.bit>>3) { 54 | n.err = newInvalidDatabaseError( 55 | "invalid search tree at %v/%v", ipRight, node.bit) 56 | return false 57 | } 58 | ipRight[node.bit>>3] |= 1 << uint(7-(node.bit%8)) 59 | 60 | rightPointer, err := n.reader.readNode(node.pointer, 1) 61 | if err != nil { 62 | n.err = err 63 | return false 64 | } 65 | 66 | node.bit++ 67 | n.nodes = append(n.nodes, netNode{ 68 | pointer: rightPointer, 69 | ip: ipRight, 70 | bit: node.bit, 71 | }) 72 | 73 | node.pointer, err = n.reader.readNode(node.pointer, 0) 74 | if err != nil { 75 | n.err = err 76 | return false 77 | } 78 | 79 | } else if node.pointer > n.reader.Metadata.NodeCount { 80 | n.lastNode = node 81 | return true 82 | } else { 83 | break 84 | } 85 | } 86 | } 87 | 88 | return false 89 | } 90 | 91 | // Network returns the current network or an error if there is a problem 92 | // decoding the data for the network. It takes a pointer to a result value to 93 | // decode the network's data into. 94 | func (n *Networks) Network(result interface{}) (*net.IPNet, error) { 95 | if err := n.reader.retrieveData(n.lastNode.pointer, result); err != nil { 96 | return nil, err 97 | } 98 | 99 | return &net.IPNet{ 100 | IP: n.lastNode.ip, 101 | Mask: net.CIDRMask(int(n.lastNode.bit), len(n.lastNode.ip)*8), 102 | }, nil 103 | } 104 | 105 | // Err returns an error, if any, that was encountered during iteration. 106 | func (n *Networks) Err() error { 107 | return n.err 108 | } 109 | -------------------------------------------------------------------------------- /vendor/github.com/oschwald/maxminddb-golang/verifier.go: -------------------------------------------------------------------------------- 1 | package maxminddb 2 | 3 | import "reflect" 4 | 5 | type verifier struct { 6 | reader *Reader 7 | } 8 | 9 | // Verify checks that the database is valid. It validates the search tree, 10 | // the data section, and the metadata section. This verifier is stricter than 11 | // the specification and may return errors on databases that are readable. 12 | func (r *Reader) Verify() error { 13 | v := verifier{r} 14 | if err := v.verifyMetadata(); err != nil { 15 | return err 16 | } 17 | 18 | return v.verifyDatabase() 19 | } 20 | 21 | func (v *verifier) verifyMetadata() error { 22 | metadata := v.reader.Metadata 23 | 24 | if metadata.BinaryFormatMajorVersion != 2 { 25 | return testError( 26 | "binary_format_major_version", 27 | 2, 28 | metadata.BinaryFormatMajorVersion, 29 | ) 30 | } 31 | 32 | if metadata.BinaryFormatMinorVersion != 0 { 33 | return testError( 34 | "binary_format_minor_version", 35 | 0, 36 | metadata.BinaryFormatMinorVersion, 37 | ) 38 | } 39 | 40 | if metadata.DatabaseType == "" { 41 | return testError( 42 | "database_type", 43 | "non-empty string", 44 | metadata.DatabaseType, 45 | ) 46 | } 47 | 48 | if len(metadata.Description) == 0 { 49 | return testError( 50 | "description", 51 | "non-empty slice", 52 | metadata.Description, 53 | ) 54 | } 55 | 56 | if metadata.IPVersion != 4 && metadata.IPVersion != 6 { 57 | return testError( 58 | "ip_version", 59 | "4 or 6", 60 | metadata.IPVersion, 61 | ) 62 | } 63 | 64 | if metadata.RecordSize != 24 && 65 | metadata.RecordSize != 28 && 66 | metadata.RecordSize != 32 { 67 | return testError( 68 | "record_size", 69 | "24, 28, or 32", 70 | metadata.RecordSize, 71 | ) 72 | } 73 | 74 | if metadata.NodeCount == 0 { 75 | return testError( 76 | "node_count", 77 | "positive integer", 78 | metadata.NodeCount, 79 | ) 80 | } 81 | return nil 82 | } 83 | 84 | func (v *verifier) verifyDatabase() error { 85 | offsets, err := v.verifySearchTree() 86 | if err != nil { 87 | return err 88 | } 89 | 90 | if err := v.verifyDataSectionSeparator(); err != nil { 91 | return err 92 | } 93 | 94 | return v.verifyDataSection(offsets) 95 | } 96 | 97 | func (v *verifier) verifySearchTree() (map[uint]bool, error) { 98 | offsets := make(map[uint]bool) 99 | 100 | it := v.reader.Networks() 101 | for it.Next() { 102 | offset, err := v.reader.resolveDataPointer(it.lastNode.pointer) 103 | if err != nil { 104 | return nil, err 105 | } 106 | offsets[uint(offset)] = true 107 | } 108 | if err := it.Err(); err != nil { 109 | return nil, err 110 | } 111 | return offsets, nil 112 | } 113 | 114 | func (v *verifier) verifyDataSectionSeparator() error { 115 | separatorStart := v.reader.Metadata.NodeCount * v.reader.Metadata.RecordSize / 4 116 | 117 | separator := v.reader.buffer[separatorStart : separatorStart+dataSectionSeparatorSize] 118 | 119 | for _, b := range separator { 120 | if b != 0 { 121 | return newInvalidDatabaseError("unexpected byte in data separator: %v", separator) 122 | } 123 | } 124 | return nil 125 | } 126 | 127 | func (v *verifier) verifyDataSection(offsets map[uint]bool) error { 128 | pointerCount := len(offsets) 129 | 130 | decoder := v.reader.decoder 131 | 132 | var offset uint 133 | bufferLen := uint(len(decoder.buffer)) 134 | for offset < bufferLen { 135 | var data interface{} 136 | rv := reflect.ValueOf(&data) 137 | newOffset, err := decoder.decode(offset, rv) 138 | if err != nil { 139 | return newInvalidDatabaseError("received decoding error (%v) at offset of %v", err, offset) 140 | } 141 | if newOffset <= offset { 142 | return newInvalidDatabaseError("data section offset unexpectedly went from %v to %v", offset, newOffset) 143 | } 144 | 145 | pointer := offset 146 | 147 | if _, ok := offsets[pointer]; ok { 148 | delete(offsets, pointer) 149 | } else { 150 | return newInvalidDatabaseError("found data (%v) at %v that the search tree does not point to", data, pointer) 151 | } 152 | 153 | offset = newOffset 154 | } 155 | 156 | if offset != bufferLen { 157 | return newInvalidDatabaseError( 158 | "unexpected data at the end of the data section (last offset: %v, end: %v)", 159 | offset, 160 | bufferLen, 161 | ) 162 | } 163 | 164 | if len(offsets) != 0 { 165 | return newInvalidDatabaseError( 166 | "found %v pointers (of %v) in the search tree that we did not see in the data section", 167 | len(offsets), 168 | pointerCount, 169 | ) 170 | } 171 | return nil 172 | } 173 | 174 | func testError( 175 | field string, 176 | expected interface{}, 177 | actual interface{}, 178 | ) error { 179 | return newInvalidDatabaseError( 180 | "%v - Expected: %v Actual: %v", 181 | field, 182 | expected, 183 | actual, 184 | ) 185 | } 186 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/go17.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | package context 8 | 9 | import ( 10 | "context" // standard library's context, as of Go 1.7 11 | "time" 12 | ) 13 | 14 | var ( 15 | todo = context.TODO() 16 | background = context.Background() 17 | ) 18 | 19 | // Canceled is the error returned by Context.Err when the context is canceled. 20 | var Canceled = context.Canceled 21 | 22 | // DeadlineExceeded is the error returned by Context.Err when the context's 23 | // deadline passes. 24 | var DeadlineExceeded = context.DeadlineExceeded 25 | 26 | // WithCancel returns a copy of parent with a new Done channel. The returned 27 | // context's Done channel is closed when the returned cancel function is called 28 | // or when the parent context's Done channel is closed, whichever happens first. 29 | // 30 | // Canceling this context releases resources associated with it, so code should 31 | // call cancel as soon as the operations running in this Context complete. 32 | func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { 33 | ctx, f := context.WithCancel(parent) 34 | return ctx, CancelFunc(f) 35 | } 36 | 37 | // WithDeadline returns a copy of the parent context with the deadline adjusted 38 | // to be no later than d. If the parent's deadline is already earlier than d, 39 | // WithDeadline(parent, d) is semantically equivalent to parent. The returned 40 | // context's Done channel is closed when the deadline expires, when the returned 41 | // cancel function is called, or when the parent context's Done channel is 42 | // closed, whichever happens first. 43 | // 44 | // Canceling this context releases resources associated with it, so code should 45 | // call cancel as soon as the operations running in this Context complete. 46 | func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { 47 | ctx, f := context.WithDeadline(parent, deadline) 48 | return ctx, CancelFunc(f) 49 | } 50 | 51 | // WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). 52 | // 53 | // Canceling this context releases resources associated with it, so code should 54 | // call cancel as soon as the operations running in this Context complete: 55 | // 56 | // func slowOperationWithTimeout(ctx context.Context) (Result, error) { 57 | // ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) 58 | // defer cancel() // releases resources if slowOperation completes before timeout elapses 59 | // return slowOperation(ctx) 60 | // } 61 | func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { 62 | return WithDeadline(parent, time.Now().Add(timeout)) 63 | } 64 | 65 | // WithValue returns a copy of parent in which the value associated with key is 66 | // val. 67 | // 68 | // Use context Values only for request-scoped data that transits processes and 69 | // APIs, not for passing optional parameters to functions. 70 | func WithValue(parent Context, key interface{}, val interface{}) Context { 71 | return context.WithValue(parent, key, val) 72 | } 73 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # This Dockerfile builds a recent curl with HTTP/2 client support, using 3 | # a recent nghttp2 build. 4 | # 5 | # See the Makefile for how to tag it. If Docker and that image is found, the 6 | # Go tests use this curl binary for integration tests. 7 | # 8 | 9 | FROM ubuntu:trusty 10 | 11 | RUN apt-get update && \ 12 | apt-get upgrade -y && \ 13 | apt-get install -y git-core build-essential wget 14 | 15 | RUN apt-get install -y --no-install-recommends \ 16 | autotools-dev libtool pkg-config zlib1g-dev \ 17 | libcunit1-dev libssl-dev libxml2-dev libevent-dev \ 18 | automake autoconf 19 | 20 | # The list of packages nghttp2 recommends for h2load: 21 | RUN apt-get install -y --no-install-recommends make binutils \ 22 | autoconf automake autotools-dev \ 23 | libtool pkg-config zlib1g-dev libcunit1-dev libssl-dev libxml2-dev \ 24 | libev-dev libevent-dev libjansson-dev libjemalloc-dev \ 25 | cython python3.4-dev python-setuptools 26 | 27 | # Note: setting NGHTTP2_VER before the git clone, so an old git clone isn't cached: 28 | ENV NGHTTP2_VER 895da9a 29 | RUN cd /root && git clone https://github.com/tatsuhiro-t/nghttp2.git 30 | 31 | WORKDIR /root/nghttp2 32 | RUN git reset --hard $NGHTTP2_VER 33 | RUN autoreconf -i 34 | RUN automake 35 | RUN autoconf 36 | RUN ./configure 37 | RUN make 38 | RUN make install 39 | 40 | WORKDIR /root 41 | RUN wget http://curl.haxx.se/download/curl-7.45.0.tar.gz 42 | RUN tar -zxvf curl-7.45.0.tar.gz 43 | WORKDIR /root/curl-7.45.0 44 | RUN ./configure --with-ssl --with-nghttp2=/usr/local 45 | RUN make 46 | RUN make install 47 | RUN ldconfig 48 | 49 | CMD ["-h"] 50 | ENTRYPOINT ["/usr/local/bin/curl"] 51 | 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/Makefile: -------------------------------------------------------------------------------- 1 | curlimage: 2 | docker build -t gohttp2/curl . 3 | 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/README: -------------------------------------------------------------------------------- 1 | This is a work-in-progress HTTP/2 implementation for Go. 2 | 3 | It will eventually live in the Go standard library and won't require 4 | any changes to your code to use. It will just be automatic. 5 | 6 | Status: 7 | 8 | * The server support is pretty good. A few things are missing 9 | but are being worked on. 10 | * The client work has just started but shares a lot of code 11 | is coming along much quicker. 12 | 13 | Docs are at https://godoc.org/golang.org/x/net/http2 14 | 15 | Demo test server at https://http2.golang.org/ 16 | 17 | Help & bug reports welcome! 18 | 19 | Contributing: https://golang.org/doc/contribute.html 20 | Bugs: https://golang.org/issue/new?title=x/net/http2:+ 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/configure_transport.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.6 6 | 7 | package http2 8 | 9 | import ( 10 | "crypto/tls" 11 | "fmt" 12 | "net/http" 13 | ) 14 | 15 | func configureTransport(t1 *http.Transport) (*Transport, error) { 16 | connPool := new(clientConnPool) 17 | t2 := &Transport{ 18 | ConnPool: noDialClientConnPool{connPool}, 19 | t1: t1, 20 | } 21 | connPool.t = t2 22 | if err := registerHTTPSProtocol(t1, noDialH2RoundTripper{t2}); err != nil { 23 | return nil, err 24 | } 25 | if t1.TLSClientConfig == nil { 26 | t1.TLSClientConfig = new(tls.Config) 27 | } 28 | if !strSliceContains(t1.TLSClientConfig.NextProtos, "h2") { 29 | t1.TLSClientConfig.NextProtos = append([]string{"h2"}, t1.TLSClientConfig.NextProtos...) 30 | } 31 | if !strSliceContains(t1.TLSClientConfig.NextProtos, "http/1.1") { 32 | t1.TLSClientConfig.NextProtos = append(t1.TLSClientConfig.NextProtos, "http/1.1") 33 | } 34 | upgradeFn := func(authority string, c *tls.Conn) http.RoundTripper { 35 | addr := authorityAddr("https", authority) 36 | if used, err := connPool.addConnIfNeeded(addr, t2, c); err != nil { 37 | go c.Close() 38 | return erringRoundTripper{err} 39 | } else if !used { 40 | // Turns out we don't need this c. 41 | // For example, two goroutines made requests to the same host 42 | // at the same time, both kicking off TCP dials. (since protocol 43 | // was unknown) 44 | go c.Close() 45 | } 46 | return t2 47 | } 48 | if m := t1.TLSNextProto; len(m) == 0 { 49 | t1.TLSNextProto = map[string]func(string, *tls.Conn) http.RoundTripper{ 50 | "h2": upgradeFn, 51 | } 52 | } else { 53 | m["h2"] = upgradeFn 54 | } 55 | return t2, nil 56 | } 57 | 58 | // registerHTTPSProtocol calls Transport.RegisterProtocol but 59 | // convering panics into errors. 60 | func registerHTTPSProtocol(t *http.Transport, rt http.RoundTripper) (err error) { 61 | defer func() { 62 | if e := recover(); e != nil { 63 | err = fmt.Errorf("%v", e) 64 | } 65 | }() 66 | t.RegisterProtocol("https", rt) 67 | return nil 68 | } 69 | 70 | // noDialH2RoundTripper is a RoundTripper which only tries to complete the request 71 | // if there's already has a cached connection to the host. 72 | type noDialH2RoundTripper struct{ t *Transport } 73 | 74 | func (rt noDialH2RoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { 75 | res, err := rt.t.RoundTrip(req) 76 | if err == ErrNoCachedConn { 77 | return nil, http.ErrSkipAltProtocol 78 | } 79 | return res, err 80 | } 81 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/errors.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package http2 6 | 7 | import ( 8 | "errors" 9 | "fmt" 10 | ) 11 | 12 | // An ErrCode is an unsigned 32-bit error code as defined in the HTTP/2 spec. 13 | type ErrCode uint32 14 | 15 | const ( 16 | ErrCodeNo ErrCode = 0x0 17 | ErrCodeProtocol ErrCode = 0x1 18 | ErrCodeInternal ErrCode = 0x2 19 | ErrCodeFlowControl ErrCode = 0x3 20 | ErrCodeSettingsTimeout ErrCode = 0x4 21 | ErrCodeStreamClosed ErrCode = 0x5 22 | ErrCodeFrameSize ErrCode = 0x6 23 | ErrCodeRefusedStream ErrCode = 0x7 24 | ErrCodeCancel ErrCode = 0x8 25 | ErrCodeCompression ErrCode = 0x9 26 | ErrCodeConnect ErrCode = 0xa 27 | ErrCodeEnhanceYourCalm ErrCode = 0xb 28 | ErrCodeInadequateSecurity ErrCode = 0xc 29 | ErrCodeHTTP11Required ErrCode = 0xd 30 | ) 31 | 32 | var errCodeName = map[ErrCode]string{ 33 | ErrCodeNo: "NO_ERROR", 34 | ErrCodeProtocol: "PROTOCOL_ERROR", 35 | ErrCodeInternal: "INTERNAL_ERROR", 36 | ErrCodeFlowControl: "FLOW_CONTROL_ERROR", 37 | ErrCodeSettingsTimeout: "SETTINGS_TIMEOUT", 38 | ErrCodeStreamClosed: "STREAM_CLOSED", 39 | ErrCodeFrameSize: "FRAME_SIZE_ERROR", 40 | ErrCodeRefusedStream: "REFUSED_STREAM", 41 | ErrCodeCancel: "CANCEL", 42 | ErrCodeCompression: "COMPRESSION_ERROR", 43 | ErrCodeConnect: "CONNECT_ERROR", 44 | ErrCodeEnhanceYourCalm: "ENHANCE_YOUR_CALM", 45 | ErrCodeInadequateSecurity: "INADEQUATE_SECURITY", 46 | ErrCodeHTTP11Required: "HTTP_1_1_REQUIRED", 47 | } 48 | 49 | func (e ErrCode) String() string { 50 | if s, ok := errCodeName[e]; ok { 51 | return s 52 | } 53 | return fmt.Sprintf("unknown error code 0x%x", uint32(e)) 54 | } 55 | 56 | // ConnectionError is an error that results in the termination of the 57 | // entire connection. 58 | type ConnectionError ErrCode 59 | 60 | func (e ConnectionError) Error() string { return fmt.Sprintf("connection error: %s", ErrCode(e)) } 61 | 62 | // StreamError is an error that only affects one stream within an 63 | // HTTP/2 connection. 64 | type StreamError struct { 65 | StreamID uint32 66 | Code ErrCode 67 | } 68 | 69 | func (e StreamError) Error() string { 70 | return fmt.Sprintf("stream error: stream ID %d; %v", e.StreamID, e.Code) 71 | } 72 | 73 | // 6.9.1 The Flow Control Window 74 | // "If a sender receives a WINDOW_UPDATE that causes a flow control 75 | // window to exceed this maximum it MUST terminate either the stream 76 | // or the connection, as appropriate. For streams, [...]; for the 77 | // connection, a GOAWAY frame with a FLOW_CONTROL_ERROR code." 78 | type goAwayFlowError struct{} 79 | 80 | func (goAwayFlowError) Error() string { return "connection exceeded flow control window size" } 81 | 82 | // connErrorReason wraps a ConnectionError with an informative error about why it occurs. 83 | 84 | // Errors of this type are only returned by the frame parser functions 85 | // and converted into ConnectionError(ErrCodeProtocol). 86 | type connError struct { 87 | Code ErrCode 88 | Reason string 89 | } 90 | 91 | func (e connError) Error() string { 92 | return fmt.Sprintf("http2: connection error: %v: %v", e.Code, e.Reason) 93 | } 94 | 95 | type pseudoHeaderError string 96 | 97 | func (e pseudoHeaderError) Error() string { 98 | return fmt.Sprintf("invalid pseudo-header %q", string(e)) 99 | } 100 | 101 | type duplicatePseudoHeaderError string 102 | 103 | func (e duplicatePseudoHeaderError) Error() string { 104 | return fmt.Sprintf("duplicate pseudo-header %q", string(e)) 105 | } 106 | 107 | type headerFieldNameError string 108 | 109 | func (e headerFieldNameError) Error() string { 110 | return fmt.Sprintf("invalid header field name %q", string(e)) 111 | } 112 | 113 | type headerFieldValueError string 114 | 115 | func (e headerFieldValueError) Error() string { 116 | return fmt.Sprintf("invalid header field value %q", string(e)) 117 | } 118 | 119 | var ( 120 | errMixPseudoHeaderTypes = errors.New("mix of request and response pseudo headers") 121 | errPseudoAfterRegular = errors.New("pseudo header field after regular") 122 | ) 123 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/fixed_buffer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package http2 6 | 7 | import ( 8 | "errors" 9 | ) 10 | 11 | // fixedBuffer is an io.ReadWriter backed by a fixed size buffer. 12 | // It never allocates, but moves old data as new data is written. 13 | type fixedBuffer struct { 14 | buf []byte 15 | r, w int 16 | } 17 | 18 | var ( 19 | errReadEmpty = errors.New("read from empty fixedBuffer") 20 | errWriteFull = errors.New("write on full fixedBuffer") 21 | ) 22 | 23 | // Read copies bytes from the buffer into p. 24 | // It is an error to read when no data is available. 25 | func (b *fixedBuffer) Read(p []byte) (n int, err error) { 26 | if b.r == b.w { 27 | return 0, errReadEmpty 28 | } 29 | n = copy(p, b.buf[b.r:b.w]) 30 | b.r += n 31 | if b.r == b.w { 32 | b.r = 0 33 | b.w = 0 34 | } 35 | return n, nil 36 | } 37 | 38 | // Len returns the number of bytes of the unread portion of the buffer. 39 | func (b *fixedBuffer) Len() int { 40 | return b.w - b.r 41 | } 42 | 43 | // Write copies bytes from p into the buffer. 44 | // It is an error to write more data than the buffer can hold. 45 | func (b *fixedBuffer) Write(p []byte) (n int, err error) { 46 | // Slide existing data to beginning. 47 | if b.r > 0 && len(p) > len(b.buf)-b.w { 48 | copy(b.buf, b.buf[b.r:b.w]) 49 | b.w -= b.r 50 | b.r = 0 51 | } 52 | 53 | // Write new data. 54 | n = copy(b.buf[b.w:], p) 55 | b.w += n 56 | if n < len(p) { 57 | err = errWriteFull 58 | } 59 | return n, err 60 | } 61 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/flow.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Flow control 6 | 7 | package http2 8 | 9 | // flow is the flow control window's size. 10 | type flow struct { 11 | // n is the number of DATA bytes we're allowed to send. 12 | // A flow is kept both on a conn and a per-stream. 13 | n int32 14 | 15 | // conn points to the shared connection-level flow that is 16 | // shared by all streams on that conn. It is nil for the flow 17 | // that's on the conn directly. 18 | conn *flow 19 | } 20 | 21 | func (f *flow) setConnFlow(cf *flow) { f.conn = cf } 22 | 23 | func (f *flow) available() int32 { 24 | n := f.n 25 | if f.conn != nil && f.conn.n < n { 26 | n = f.conn.n 27 | } 28 | return n 29 | } 30 | 31 | func (f *flow) take(n int32) { 32 | if n > f.available() { 33 | panic("internal error: took too much") 34 | } 35 | f.n -= n 36 | if f.conn != nil { 37 | f.conn.n -= n 38 | } 39 | } 40 | 41 | // add adds n bytes (positive or negative) to the flow control window. 42 | // It returns false if the sum would exceed 2^31-1. 43 | func (f *flow) add(n int32) bool { 44 | remain := (1<<31 - 1) - f.n 45 | if n > remain { 46 | return false 47 | } 48 | f.n += n 49 | return true 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/go16.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.6 6 | 7 | package http2 8 | 9 | import ( 10 | "crypto/tls" 11 | "net/http" 12 | "time" 13 | ) 14 | 15 | func transportExpectContinueTimeout(t1 *http.Transport) time.Duration { 16 | return t1.ExpectContinueTimeout 17 | } 18 | 19 | // isBadCipher reports whether the cipher is blacklisted by the HTTP/2 spec. 20 | func isBadCipher(cipher uint16) bool { 21 | switch cipher { 22 | case tls.TLS_RSA_WITH_RC4_128_SHA, 23 | tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, 24 | tls.TLS_RSA_WITH_AES_128_CBC_SHA, 25 | tls.TLS_RSA_WITH_AES_256_CBC_SHA, 26 | tls.TLS_RSA_WITH_AES_128_GCM_SHA256, 27 | tls.TLS_RSA_WITH_AES_256_GCM_SHA384, 28 | tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, 29 | tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, 30 | tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, 31 | tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, 32 | tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, 33 | tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, 34 | tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: 35 | // Reject cipher suites from Appendix A. 36 | // "This list includes those cipher suites that do not 37 | // offer an ephemeral key exchange and those that are 38 | // based on the TLS null, stream or block cipher type" 39 | return true 40 | default: 41 | return false 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/go17.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | package http2 8 | 9 | import ( 10 | "context" 11 | "net" 12 | "net/http" 13 | "net/http/httptrace" 14 | "time" 15 | ) 16 | 17 | type contextContext interface { 18 | context.Context 19 | } 20 | 21 | func serverConnBaseContext(c net.Conn, opts *ServeConnOpts) (ctx contextContext, cancel func()) { 22 | ctx, cancel = context.WithCancel(context.Background()) 23 | ctx = context.WithValue(ctx, http.LocalAddrContextKey, c.LocalAddr()) 24 | if hs := opts.baseConfig(); hs != nil { 25 | ctx = context.WithValue(ctx, http.ServerContextKey, hs) 26 | } 27 | return 28 | } 29 | 30 | func contextWithCancel(ctx contextContext) (_ contextContext, cancel func()) { 31 | return context.WithCancel(ctx) 32 | } 33 | 34 | func requestWithContext(req *http.Request, ctx contextContext) *http.Request { 35 | return req.WithContext(ctx) 36 | } 37 | 38 | type clientTrace httptrace.ClientTrace 39 | 40 | func reqContext(r *http.Request) context.Context { return r.Context() } 41 | 42 | func setResponseUncompressed(res *http.Response) { res.Uncompressed = true } 43 | 44 | func traceGotConn(req *http.Request, cc *ClientConn) { 45 | trace := httptrace.ContextClientTrace(req.Context()) 46 | if trace == nil || trace.GotConn == nil { 47 | return 48 | } 49 | ci := httptrace.GotConnInfo{Conn: cc.tconn} 50 | cc.mu.Lock() 51 | ci.Reused = cc.nextStreamID > 1 52 | ci.WasIdle = len(cc.streams) == 0 && ci.Reused 53 | if ci.WasIdle && !cc.lastActive.IsZero() { 54 | ci.IdleTime = time.Now().Sub(cc.lastActive) 55 | } 56 | cc.mu.Unlock() 57 | 58 | trace.GotConn(ci) 59 | } 60 | 61 | func traceWroteHeaders(trace *clientTrace) { 62 | if trace != nil && trace.WroteHeaders != nil { 63 | trace.WroteHeaders() 64 | } 65 | } 66 | 67 | func traceGot100Continue(trace *clientTrace) { 68 | if trace != nil && trace.Got100Continue != nil { 69 | trace.Got100Continue() 70 | } 71 | } 72 | 73 | func traceWait100Continue(trace *clientTrace) { 74 | if trace != nil && trace.Wait100Continue != nil { 75 | trace.Wait100Continue() 76 | } 77 | } 78 | 79 | func traceWroteRequest(trace *clientTrace, err error) { 80 | if trace != nil && trace.WroteRequest != nil { 81 | trace.WroteRequest(httptrace.WroteRequestInfo{Err: err}) 82 | } 83 | } 84 | 85 | func traceFirstResponseByte(trace *clientTrace) { 86 | if trace != nil && trace.GotFirstResponseByte != nil { 87 | trace.GotFirstResponseByte() 88 | } 89 | } 90 | 91 | func requestTrace(req *http.Request) *clientTrace { 92 | trace := httptrace.ContextClientTrace(req.Context()) 93 | return (*clientTrace)(trace) 94 | } 95 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/gotrack.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Defensive debug-only utility to track that functions run on the 6 | // goroutine that they're supposed to. 7 | 8 | package http2 9 | 10 | import ( 11 | "bytes" 12 | "errors" 13 | "fmt" 14 | "os" 15 | "runtime" 16 | "strconv" 17 | "sync" 18 | ) 19 | 20 | var DebugGoroutines = os.Getenv("DEBUG_HTTP2_GOROUTINES") == "1" 21 | 22 | type goroutineLock uint64 23 | 24 | func newGoroutineLock() goroutineLock { 25 | if !DebugGoroutines { 26 | return 0 27 | } 28 | return goroutineLock(curGoroutineID()) 29 | } 30 | 31 | func (g goroutineLock) check() { 32 | if !DebugGoroutines { 33 | return 34 | } 35 | if curGoroutineID() != uint64(g) { 36 | panic("running on the wrong goroutine") 37 | } 38 | } 39 | 40 | func (g goroutineLock) checkNotOn() { 41 | if !DebugGoroutines { 42 | return 43 | } 44 | if curGoroutineID() == uint64(g) { 45 | panic("running on the wrong goroutine") 46 | } 47 | } 48 | 49 | var goroutineSpace = []byte("goroutine ") 50 | 51 | func curGoroutineID() uint64 { 52 | bp := littleBuf.Get().(*[]byte) 53 | defer littleBuf.Put(bp) 54 | b := *bp 55 | b = b[:runtime.Stack(b, false)] 56 | // Parse the 4707 out of "goroutine 4707 [" 57 | b = bytes.TrimPrefix(b, goroutineSpace) 58 | i := bytes.IndexByte(b, ' ') 59 | if i < 0 { 60 | panic(fmt.Sprintf("No space found in %q", b)) 61 | } 62 | b = b[:i] 63 | n, err := parseUintBytes(b, 10, 64) 64 | if err != nil { 65 | panic(fmt.Sprintf("Failed to parse goroutine ID out of %q: %v", b, err)) 66 | } 67 | return n 68 | } 69 | 70 | var littleBuf = sync.Pool{ 71 | New: func() interface{} { 72 | buf := make([]byte, 64) 73 | return &buf 74 | }, 75 | } 76 | 77 | // parseUintBytes is like strconv.ParseUint, but using a []byte. 78 | func parseUintBytes(s []byte, base int, bitSize int) (n uint64, err error) { 79 | var cutoff, maxVal uint64 80 | 81 | if bitSize == 0 { 82 | bitSize = int(strconv.IntSize) 83 | } 84 | 85 | s0 := s 86 | switch { 87 | case len(s) < 1: 88 | err = strconv.ErrSyntax 89 | goto Error 90 | 91 | case 2 <= base && base <= 36: 92 | // valid base; nothing to do 93 | 94 | case base == 0: 95 | // Look for octal, hex prefix. 96 | switch { 97 | case s[0] == '0' && len(s) > 1 && (s[1] == 'x' || s[1] == 'X'): 98 | base = 16 99 | s = s[2:] 100 | if len(s) < 1 { 101 | err = strconv.ErrSyntax 102 | goto Error 103 | } 104 | case s[0] == '0': 105 | base = 8 106 | default: 107 | base = 10 108 | } 109 | 110 | default: 111 | err = errors.New("invalid base " + strconv.Itoa(base)) 112 | goto Error 113 | } 114 | 115 | n = 0 116 | cutoff = cutoff64(base) 117 | maxVal = 1<= base { 135 | n = 0 136 | err = strconv.ErrSyntax 137 | goto Error 138 | } 139 | 140 | if n >= cutoff { 141 | // n*base overflows 142 | n = 1<<64 - 1 143 | err = strconv.ErrRange 144 | goto Error 145 | } 146 | n *= uint64(base) 147 | 148 | n1 := n + uint64(v) 149 | if n1 < n || n1 > maxVal { 150 | // n+v overflows 151 | n = 1<<64 - 1 152 | err = strconv.ErrRange 153 | goto Error 154 | } 155 | n = n1 156 | } 157 | 158 | return n, nil 159 | 160 | Error: 161 | return n, &strconv.NumError{Func: "ParseUint", Num: string(s0), Err: err} 162 | } 163 | 164 | // Return the first number n such that n*base >= 1<<64. 165 | func cutoff64(base int) uint64 { 166 | if base < 2 { 167 | return 0 168 | } 169 | return (1<<64-1)/uint64(base) + 1 170 | } 171 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/headermap.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package http2 6 | 7 | import ( 8 | "net/http" 9 | "strings" 10 | ) 11 | 12 | var ( 13 | commonLowerHeader = map[string]string{} // Go-Canonical-Case -> lower-case 14 | commonCanonHeader = map[string]string{} // lower-case -> Go-Canonical-Case 15 | ) 16 | 17 | func init() { 18 | for _, v := range []string{ 19 | "accept", 20 | "accept-charset", 21 | "accept-encoding", 22 | "accept-language", 23 | "accept-ranges", 24 | "age", 25 | "access-control-allow-origin", 26 | "allow", 27 | "authorization", 28 | "cache-control", 29 | "content-disposition", 30 | "content-encoding", 31 | "content-language", 32 | "content-length", 33 | "content-location", 34 | "content-range", 35 | "content-type", 36 | "cookie", 37 | "date", 38 | "etag", 39 | "expect", 40 | "expires", 41 | "from", 42 | "host", 43 | "if-match", 44 | "if-modified-since", 45 | "if-none-match", 46 | "if-unmodified-since", 47 | "last-modified", 48 | "link", 49 | "location", 50 | "max-forwards", 51 | "proxy-authenticate", 52 | "proxy-authorization", 53 | "range", 54 | "referer", 55 | "refresh", 56 | "retry-after", 57 | "server", 58 | "set-cookie", 59 | "strict-transport-security", 60 | "trailer", 61 | "transfer-encoding", 62 | "user-agent", 63 | "vary", 64 | "via", 65 | "www-authenticate", 66 | } { 67 | chk := http.CanonicalHeaderKey(v) 68 | commonLowerHeader[chk] = v 69 | commonCanonHeader[v] = chk 70 | } 71 | } 72 | 73 | func lowerHeader(v string) string { 74 | if s, ok := commonLowerHeader[v]; ok { 75 | return s 76 | } 77 | return strings.ToLower(v) 78 | } 79 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/not_go16.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.6 6 | 7 | package http2 8 | 9 | import ( 10 | "crypto/tls" 11 | "net/http" 12 | "time" 13 | ) 14 | 15 | func configureTransport(t1 *http.Transport) (*Transport, error) { 16 | return nil, errTransportVersion 17 | } 18 | 19 | func transportExpectContinueTimeout(t1 *http.Transport) time.Duration { 20 | return 0 21 | 22 | } 23 | 24 | // isBadCipher reports whether the cipher is blacklisted by the HTTP/2 spec. 25 | func isBadCipher(cipher uint16) bool { 26 | switch cipher { 27 | case tls.TLS_RSA_WITH_RC4_128_SHA, 28 | tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, 29 | tls.TLS_RSA_WITH_AES_128_CBC_SHA, 30 | tls.TLS_RSA_WITH_AES_256_CBC_SHA, 31 | tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, 32 | tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, 33 | tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, 34 | tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, 35 | tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, 36 | tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, 37 | tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: 38 | // Reject cipher suites from Appendix A. 39 | // "This list includes those cipher suites that do not 40 | // offer an ephemeral key exchange and those that are 41 | // based on the TLS null, stream or block cipher type" 42 | return true 43 | default: 44 | return false 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/not_go17.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.7 6 | 7 | package http2 8 | 9 | import ( 10 | "net" 11 | "net/http" 12 | ) 13 | 14 | type contextContext interface{} 15 | 16 | type fakeContext struct{} 17 | 18 | func (fakeContext) Done() <-chan struct{} { return nil } 19 | func (fakeContext) Err() error { panic("should not be called") } 20 | 21 | func reqContext(r *http.Request) fakeContext { 22 | return fakeContext{} 23 | } 24 | 25 | func setResponseUncompressed(res *http.Response) { 26 | // Nothing. 27 | } 28 | 29 | type clientTrace struct{} 30 | 31 | func requestTrace(*http.Request) *clientTrace { return nil } 32 | func traceGotConn(*http.Request, *ClientConn) {} 33 | func traceFirstResponseByte(*clientTrace) {} 34 | func traceWroteHeaders(*clientTrace) {} 35 | func traceWroteRequest(*clientTrace, error) {} 36 | func traceGot100Continue(trace *clientTrace) {} 37 | func traceWait100Continue(trace *clientTrace) {} 38 | 39 | func nop() {} 40 | 41 | func serverConnBaseContext(c net.Conn, opts *ServeConnOpts) (ctx contextContext, cancel func()) { 42 | return nil, nop 43 | } 44 | 45 | func contextWithCancel(ctx contextContext) (_ contextContext, cancel func()) { 46 | return ctx, nop 47 | } 48 | 49 | func requestWithContext(req *http.Request, ctx contextContext) *http.Request { 50 | return req 51 | } 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/pipe.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package http2 6 | 7 | import ( 8 | "errors" 9 | "io" 10 | "sync" 11 | ) 12 | 13 | // pipe is a goroutine-safe io.Reader/io.Writer pair. It's like 14 | // io.Pipe except there are no PipeReader/PipeWriter halves, and the 15 | // underlying buffer is an interface. (io.Pipe is always unbuffered) 16 | type pipe struct { 17 | mu sync.Mutex 18 | c sync.Cond // c.L lazily initialized to &p.mu 19 | b pipeBuffer 20 | err error // read error once empty. non-nil means closed. 21 | breakErr error // immediate read error (caller doesn't see rest of b) 22 | donec chan struct{} // closed on error 23 | readFn func() // optional code to run in Read before error 24 | } 25 | 26 | type pipeBuffer interface { 27 | Len() int 28 | io.Writer 29 | io.Reader 30 | } 31 | 32 | func (p *pipe) Len() int { 33 | p.mu.Lock() 34 | defer p.mu.Unlock() 35 | return p.b.Len() 36 | } 37 | 38 | // Read waits until data is available and copies bytes 39 | // from the buffer into p. 40 | func (p *pipe) Read(d []byte) (n int, err error) { 41 | p.mu.Lock() 42 | defer p.mu.Unlock() 43 | if p.c.L == nil { 44 | p.c.L = &p.mu 45 | } 46 | for { 47 | if p.breakErr != nil { 48 | return 0, p.breakErr 49 | } 50 | if p.b.Len() > 0 { 51 | return p.b.Read(d) 52 | } 53 | if p.err != nil { 54 | if p.readFn != nil { 55 | p.readFn() // e.g. copy trailers 56 | p.readFn = nil // not sticky like p.err 57 | } 58 | return 0, p.err 59 | } 60 | p.c.Wait() 61 | } 62 | } 63 | 64 | var errClosedPipeWrite = errors.New("write on closed buffer") 65 | 66 | // Write copies bytes from p into the buffer and wakes a reader. 67 | // It is an error to write more data than the buffer can hold. 68 | func (p *pipe) Write(d []byte) (n int, err error) { 69 | p.mu.Lock() 70 | defer p.mu.Unlock() 71 | if p.c.L == nil { 72 | p.c.L = &p.mu 73 | } 74 | defer p.c.Signal() 75 | if p.err != nil { 76 | return 0, errClosedPipeWrite 77 | } 78 | return p.b.Write(d) 79 | } 80 | 81 | // CloseWithError causes the next Read (waking up a current blocked 82 | // Read if needed) to return the provided err after all data has been 83 | // read. 84 | // 85 | // The error must be non-nil. 86 | func (p *pipe) CloseWithError(err error) { p.closeWithError(&p.err, err, nil) } 87 | 88 | // BreakWithError causes the next Read (waking up a current blocked 89 | // Read if needed) to return the provided err immediately, without 90 | // waiting for unread data. 91 | func (p *pipe) BreakWithError(err error) { p.closeWithError(&p.breakErr, err, nil) } 92 | 93 | // closeWithErrorAndCode is like CloseWithError but also sets some code to run 94 | // in the caller's goroutine before returning the error. 95 | func (p *pipe) closeWithErrorAndCode(err error, fn func()) { p.closeWithError(&p.err, err, fn) } 96 | 97 | func (p *pipe) closeWithError(dst *error, err error, fn func()) { 98 | if err == nil { 99 | panic("err must be non-nil") 100 | } 101 | p.mu.Lock() 102 | defer p.mu.Unlock() 103 | if p.c.L == nil { 104 | p.c.L = &p.mu 105 | } 106 | defer p.c.Signal() 107 | if *dst != nil { 108 | // Already been done. 109 | return 110 | } 111 | p.readFn = fn 112 | *dst = err 113 | p.closeDoneLocked() 114 | } 115 | 116 | // requires p.mu be held. 117 | func (p *pipe) closeDoneLocked() { 118 | if p.donec == nil { 119 | return 120 | } 121 | // Close if unclosed. This isn't racy since we always 122 | // hold p.mu while closing. 123 | select { 124 | case <-p.donec: 125 | default: 126 | close(p.donec) 127 | } 128 | } 129 | 130 | // Err returns the error (if any) first set by BreakWithError or CloseWithError. 131 | func (p *pipe) Err() error { 132 | p.mu.Lock() 133 | defer p.mu.Unlock() 134 | if p.breakErr != nil { 135 | return p.breakErr 136 | } 137 | return p.err 138 | } 139 | 140 | // Done returns a channel which is closed if and when this pipe is closed 141 | // with CloseWithError. 142 | func (p *pipe) Done() <-chan struct{} { 143 | p.mu.Lock() 144 | defer p.mu.Unlock() 145 | if p.donec == nil { 146 | p.donec = make(chan struct{}) 147 | if p.err != nil || p.breakErr != nil { 148 | // Already hit an error. 149 | p.closeDoneLocked() 150 | } 151 | } 152 | return p.donec 153 | } 154 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | TEXT ·use(SB),NOSPLIT,$0 10 | RET 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for 386, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·socketcall(SB),NOSPLIT,$0-36 29 | JMP syscall·socketcall(SB) 30 | 31 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 32 | JMP syscall·rawsocketcall(SB) 33 | 34 | TEXT ·seek(SB),NOSPLIT,$0-28 35 | JMP syscall·seek(SB) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 29 | JMP syscall·gettimeofday(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | B syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | B syscall·RawSyscall6(SB) 27 | 28 | TEXT ·seek(SB),NOSPLIT,$0-32 29 | B syscall·seek(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | B syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | B syscall·RawSyscall6(SB) 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | JMP syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | JMP syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-64 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd openbsd netbsd dragonfly 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build darwin dragonfly freebsd linux netbsd openbsd 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 14 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 15 | var fcntl64Syscall uintptr = SYS_FCNTL 16 | 17 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 18 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 19 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 20 | if errno == 0 { 21 | return nil 22 | } 23 | return errno 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscall 15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 16 | 17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | syscall.Entersyscall() 19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 20 | syscall.Exitsyscall() 21 | return r, 0, syscall.Errno(errno) 22 | } 23 | 24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 25 | syscall.Entersyscall() 26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 27 | syscall.Exitsyscall() 28 | return r, 0, syscall.Errno(errno) 29 | } 30 | 31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 32 | syscall.Entersyscall() 33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 34 | syscall.Exitsyscall() 35 | return r, 0, syscall.Errno(errno) 36 | } 37 | 38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 40 | return r, 0, syscall.Errno(errno) 41 | } 42 | 43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret 24 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 25 | { 26 | struct ret r; 27 | 28 | errno = 0; 29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 30 | r.err = errno; 31 | return r; 32 | } 33 | 34 | // Define the use function in C so that it is not inlined. 35 | 36 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 37 | 38 | void 39 | use(void *p __attribute__ ((unused))) 40 | { 41 | } 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mkpost.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | // mkpost processes the output of cgo -godefs to 8 | // modify the generated types. It is used to clean up 9 | // the sys API in an architecture specific manner. 10 | // 11 | // mkpost is run after cgo -godefs by mkall.sh. 12 | package main 13 | 14 | import ( 15 | "fmt" 16 | "go/format" 17 | "io/ioutil" 18 | "log" 19 | "os" 20 | "regexp" 21 | ) 22 | 23 | func main() { 24 | b, err := ioutil.ReadAll(os.Stdin) 25 | if err != nil { 26 | log.Fatal(err) 27 | } 28 | s := string(b) 29 | 30 | goarch := os.Getenv("GOARCH") 31 | goos := os.Getenv("GOOS") 32 | if goarch == "s390x" && goos == "linux" { 33 | // Export the types of PtraceRegs fields. 34 | re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)") 35 | s = re.ReplaceAllString(s, "Ptrace$1") 36 | 37 | // Replace padding fields inserted by cgo with blank identifiers. 38 | re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*") 39 | s = re.ReplaceAllString(s, "_") 40 | 41 | // Replace other unwanted fields with blank identifiers. 42 | re = regexp.MustCompile("X_[A-Za-z0-9_]*") 43 | s = re.ReplaceAllString(s, "_") 44 | 45 | // Replace the control_regs union with a blank identifier for now. 46 | re = regexp.MustCompile("(Control_regs)\\s+\\[0\\]uint64") 47 | s = re.ReplaceAllString(s, "_ [0]uint64") 48 | } 49 | 50 | // gofmt 51 | b, err = format.Source([]byte(s)) 52 | if err != nil { 53 | log.Fatal(err) 54 | } 55 | 56 | // Append this command to the header to show where the new file 57 | // came from. 58 | re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)") 59 | b = re.ReplaceAll(b, []byte("$1 | go run mkpost.go")) 60 | 61 | fmt.Printf("%s", b) 62 | } 63 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_darwin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for Darwin from sys/syscall.h 7 | 8 | use strict; 9 | 10 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 11 | print STDERR "GOARCH or GOOS not defined in environment\n"; 12 | exit 1; 13 | } 14 | 15 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV); 16 | 17 | print <){ 29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){ 30 | my $name = $1; 31 | my $num = $2; 32 | $name =~ y/a-z/A-Z/; 33 | print " SYS_$name = $num;" 34 | } 35 | } 36 | 37 | print <){ 30 | if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){ 44 | next 45 | } 46 | 47 | print " $name = $num; // $proto\n"; 48 | 49 | # We keep Capsicum syscall numbers for FreeBSD 50 | # 9-STABLE here because we are not sure whether they 51 | # are mature and stable. 52 | if($num == 513){ 53 | print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n"; 54 | print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n"; 55 | print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n"; 56 | print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n"; 57 | } 58 | } 59 | } 60 | 61 | print < 999){ 29 | # ignore deprecated syscalls that are no longer implemented 30 | # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716 31 | return; 32 | } 33 | $name =~ y/a-z/A-Z/; 34 | print " SYS_$name = $num;\n"; 35 | } 36 | 37 | my $prev; 38 | open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc"; 39 | while(){ 40 | if(/^#define __NR_syscalls\s+/) { 41 | # ignore redefinitions of __NR_syscalls 42 | } 43 | elsif(/^#define __NR_(\w+)\s+([0-9]+)/){ 44 | $prev = $2; 45 | fmt($1, $2); 46 | } 47 | elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){ 48 | $prev = $2; 49 | fmt($1, $2); 50 | } 51 | elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){ 52 | fmt($1, $prev+$2) 53 | } 54 | } 55 | 56 | print <){ 31 | if($line =~ /^(.*)\\$/) { 32 | # Handle continuation 33 | $line = $1; 34 | $_ =~ s/^\s+//; 35 | $line .= $_; 36 | } else { 37 | # New line 38 | $line = $_; 39 | } 40 | next if $line =~ /\\$/; 41 | if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) { 42 | my $num = $1; 43 | my $proto = $6; 44 | my $compat = $8; 45 | my $name = "$7_$9"; 46 | 47 | $name = "$7_$11" if $11 ne ''; 48 | $name =~ y/a-z/A-Z/; 49 | 50 | if($compat eq '' || $compat eq '30' || $compat eq '50') { 51 | print " $name = $num; // $proto\n"; 52 | } 53 | } 54 | } 55 | 56 | print <){ 30 | if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $3; 33 | my $name = $4; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print < uint64(len(b)) { 66 | return nil, nil, EINVAL 67 | } 68 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil 69 | } 70 | 71 | // UnixRights encodes a set of open file descriptors into a socket 72 | // control message for sending to another process. 73 | func UnixRights(fds ...int) []byte { 74 | datalen := len(fds) * 4 75 | b := make([]byte, CmsgSpace(datalen)) 76 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 77 | h.Level = SOL_SOCKET 78 | h.Type = SCM_RIGHTS 79 | h.SetLen(CmsgLen(datalen)) 80 | data := cmsgData(h) 81 | for _, fd := range fds { 82 | *(*int32)(data) = int32(fd) 83 | data = unsafe.Pointer(uintptr(data) + 4) 84 | } 85 | return b 86 | } 87 | 88 | // ParseUnixRights decodes a socket control message that contains an 89 | // integer array of open file descriptors from another process. 90 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) { 91 | if m.Header.Level != SOL_SOCKET { 92 | return nil, EINVAL 93 | } 94 | if m.Header.Type != SCM_RIGHTS { 95 | return nil, EINVAL 96 | } 97 | fds := make([]int, len(m.Data)>>2) 98 | for i, j := 0, 0; i < len(m.Data); i += 4 { 99 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) 100 | j++ 101 | } 102 | return fds, nil 103 | } 104 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // The primary use of this package is inside other packages that provide a more 15 | // portable interface to the system, such as "os", "time" and "net". Use 16 | // those packages rather than this one if you can. 17 | // For details of the functions and data types in this package consult 18 | // the manuals for the appropriate operating system. 19 | // These calls return err == nil to indicate success; otherwise 20 | // err represents an operating system error describing the failure and 21 | // holds a value of type syscall.Errno. 22 | package unix // import "golang.org/x/sys/unix" 23 | 24 | import "unsafe" 25 | 26 | // ByteSliceFromString returns a NUL-terminated slice of bytes 27 | // containing the text of s. If s contains a NUL byte at any 28 | // location, it returns (nil, EINVAL). 29 | func ByteSliceFromString(s string) ([]byte, error) { 30 | for i := 0; i < len(s); i++ { 31 | if s[i] == 0 { 32 | return nil, EINVAL 33 | } 34 | } 35 | a := make([]byte, len(s)+1) 36 | copy(a, s) 37 | return a, nil 38 | } 39 | 40 | // BytePtrFromString returns a pointer to a NUL-terminated array of 41 | // bytes containing the text of s. If s contains a NUL byte at any 42 | // location, it returns (nil, EINVAL). 43 | func BytePtrFromString(s string) (*byte, error) { 44 | a, err := ByteSliceFromString(s) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return &a[0], nil 49 | } 50 | 51 | // Single-word zero for use when we need a valid pointer to 0 bytes. 52 | // See mkunix.pl. 53 | var _zero uintptr 54 | 55 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 56 | return int64(ts.Sec), int64(ts.Nsec) 57 | } 58 | 59 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 60 | return int64(tv.Sec), int64(tv.Usec) * 1000 61 | } 62 | 63 | func (ts *Timespec) Nano() int64 { 64 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 65 | } 66 | 67 | func (tv *Timeval) Nano() int64 { 68 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 69 | } 70 | 71 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 72 | 73 | // use is a no-op, but the compiler cannot see that it is. 74 | // Calling use(p) ensures that p is kept live until that point. 75 | //go:noescape 76 | func use(p unsafe.Pointer) 77 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = int32(sec) 38 | tv.Usec = int32(usec) 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint32(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint32(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) 15 | 16 | func Getpagesize() int { return 4096 } 17 | 18 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 19 | 20 | func NsecToTimespec(nsec int64) (ts Timespec) { 21 | ts.Sec = nsec / 1e9 22 | ts.Nsec = nsec % 1e9 23 | return 24 | } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = sec 40 | tv.Usec = usec 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint64(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint64(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 76 | 77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 78 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 79 | const SYS___SYSCTL = SYS_SYSCTL 80 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func Getpagesize() int { return 4096 } 13 | 14 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 15 | 16 | func NsecToTimespec(nsec int64) (ts Timespec) { 17 | ts.Sec = int32(nsec / 1e9) 18 | ts.Nsec = int32(nsec % 1e9) 19 | return 20 | } 21 | 22 | func NsecToTimeval(nsec int64) (tv Timeval) { 23 | nsec += 999 // round up to microsecond 24 | tv.Usec = int32(nsec % 1e9 / 1e3) 25 | tv.Sec = int32(nsec / 1e9) 26 | return 27 | } 28 | 29 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 30 | func Gettimeofday(tv *Timeval) (err error) { 31 | // The tv passed to gettimeofday must be non-nil 32 | // but is otherwise unused. The answers come back 33 | // in the two registers. 34 | sec, usec, err := gettimeofday(tv) 35 | tv.Sec = int32(sec) 36 | tv.Usec = int32(usec) 37 | return err 38 | } 39 | 40 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 41 | k.Ident = uint32(fd) 42 | k.Filter = int16(mode) 43 | k.Flags = uint16(flags) 44 | } 45 | 46 | func (iov *Iovec) SetLen(length int) { 47 | iov.Len = uint32(length) 48 | } 49 | 50 | func (msghdr *Msghdr) SetControllen(length int) { 51 | msghdr.Controllen = uint32(length) 52 | } 53 | 54 | func (cmsg *Cmsghdr) SetLen(length int) { 55 | cmsg.Len = uint32(length) 56 | } 57 | 58 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 59 | var length = uint64(count) 60 | 61 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 62 | 63 | written = int(length) 64 | 65 | if e1 != 0 { 66 | err = e1 67 | } 68 | return 69 | } 70 | 71 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 72 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 16384 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = sec 38 | tv.Usec = usec 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint64(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint64(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = nsec / 1e9 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int64(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_no_getwd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build dragonfly freebsd netbsd openbsd 6 | 7 | package unix 8 | 9 | const ImplementsGetwd = false 10 | 11 | func Getwd() (string, error) { return "", ENOTSUP } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = nsec / 1e9 15 | ts.Nsec = nsec % 1e9 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = nsec % 1e9 / 1e3 22 | tv.Sec = nsec / 1e9 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 10 | 11 | func NsecToTimespec(nsec int64) (ts Timespec) { 12 | ts.Sec = nsec / 1e9 13 | ts.Nsec = nsec % 1e9 14 | return 15 | } 16 | 17 | func NsecToTimeval(nsec int64) (tv Timeval) { 18 | nsec += 999 // round up to microsecond 19 | tv.Usec = nsec % 1e9 / 1e3 20 | tv.Sec = int64(nsec / 1e9) 21 | return 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (cmsg *Cmsghdr) SetLen(length int) { 29 | cmsg.Len = uint32(length) 30 | } 31 | 32 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 33 | // TODO(aram): implement this, see issue 5847. 34 | panic("unimplemented") 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | // TODO(aram): remove these before Go 1.3. 10 | const ( 11 | SYS_EXECVE = 59 12 | SYS_FCNTL = 62 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/asm_windows_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // 6 | // System calls for 386, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-8 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-4 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/asm_windows_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // 6 | // System calls for amd64, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-32 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-8 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | // +build go1.4 7 | 8 | package windows 9 | 10 | import "syscall" 11 | 12 | func Unsetenv(key string) error { 13 | // This was added in Go 1.4. 14 | return syscall.Unsetenv(key) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/env_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Windows environment variables. 6 | 7 | package windows 8 | 9 | import "syscall" 10 | 11 | func Getenv(key string) (value string, found bool) { 12 | return syscall.Getenv(key) 13 | } 14 | 15 | func Setenv(key, value string) error { 16 | return syscall.Setenv(key, value) 17 | } 18 | 19 | func Clearenv() { 20 | syscall.Clearenv() 21 | } 22 | 23 | func Environ() []string { 24 | return syscall.Environ() 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/eventlog.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package windows 8 | 9 | const ( 10 | EVENTLOG_SUCCESS = 0 11 | EVENTLOG_ERROR_TYPE = 1 12 | EVENTLOG_WARNING_TYPE = 2 13 | EVENTLOG_INFORMATION_TYPE = 4 14 | EVENTLOG_AUDIT_SUCCESS = 8 15 | EVENTLOG_AUDIT_FAILURE = 16 16 | ) 17 | 18 | //sys RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) [failretval==0] = advapi32.RegisterEventSourceW 19 | //sys DeregisterEventSource(handle Handle) (err error) = advapi32.DeregisterEventSource 20 | //sys ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) = advapi32.ReportEventW 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/exec_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Fork, exec, wait, etc. 6 | 7 | package windows 8 | 9 | // EscapeArg rewrites command line argument s as prescribed 10 | // in http://msdn.microsoft.com/en-us/library/ms880421. 11 | // This function returns "" (2 double quotes) if s is empty. 12 | // Alternatively, these transformations are done: 13 | // - every back slash (\) is doubled, but only if immediately 14 | // followed by double quote ("); 15 | // - every double quote (") is escaped by back slash (\); 16 | // - finally, s is wrapped with double quotes (arg -> "arg"), 17 | // but only if there is space or tab inside s. 18 | func EscapeArg(s string) string { 19 | if len(s) == 0 { 20 | return "\"\"" 21 | } 22 | n := len(s) 23 | hasSpace := false 24 | for i := 0; i < len(s); i++ { 25 | switch s[i] { 26 | case '"', '\\': 27 | n++ 28 | case ' ', '\t': 29 | hasSpace = true 30 | } 31 | } 32 | if hasSpace { 33 | n += 2 34 | } 35 | if n == len(s) { 36 | return s 37 | } 38 | 39 | qs := make([]byte, n) 40 | j := 0 41 | if hasSpace { 42 | qs[j] = '"' 43 | j++ 44 | } 45 | slashes := 0 46 | for i := 0; i < len(s); i++ { 47 | switch s[i] { 48 | default: 49 | slashes = 0 50 | qs[j] = s[i] 51 | case '\\': 52 | slashes++ 53 | qs[j] = s[i] 54 | case '"': 55 | for ; slashes > 0; slashes-- { 56 | qs[j] = '\\' 57 | j++ 58 | } 59 | qs[j] = '\\' 60 | j++ 61 | qs[j] = s[i] 62 | } 63 | j++ 64 | } 65 | if hasSpace { 66 | for ; slashes > 0; slashes-- { 67 | qs[j] = '\\' 68 | j++ 69 | } 70 | qs[j] = '"' 71 | j++ 72 | } 73 | return string(qs[:j]) 74 | } 75 | 76 | func CloseOnExec(fd Handle) { 77 | SetHandleInformation(Handle(fd), HANDLE_FLAG_INHERIT, 0) 78 | } 79 | 80 | // FullPath retrieves the full path of the specified file. 81 | func FullPath(name string) (path string, err error) { 82 | p, err := UTF16PtrFromString(name) 83 | if err != nil { 84 | return "", err 85 | } 86 | n := uint32(100) 87 | for { 88 | buf := make([]uint16, n) 89 | n, err = GetFullPathName(p, uint32(len(buf)), &buf[0], nil) 90 | if err != nil { 91 | return "", err 92 | } 93 | if n <= uint32(len(buf)) { 94 | return UTF16ToString(buf[:n]), nil 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows,race 6 | 7 | package windows 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows,!race 6 | 7 | package windows 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package windows 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + itoa(-val) 12 | } 13 | var buf [32]byte // big enough for int64 14 | i := len(buf) - 1 15 | for val >= 10 { 16 | buf[i] = byte(val%10 + '0') 17 | i-- 18 | val /= 10 19 | } 20 | buf[i] = byte(val + '0') 21 | return string(buf[i:]) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | // Package windows contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display the OS-specific documentation for the current 10 | // system. If you want godoc to display syscall documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // The primary use of this package is inside other packages that provide a more 15 | // portable interface to the system, such as "os", "time" and "net". Use 16 | // those packages rather than this one if you can. 17 | // For details of the functions and data types in this package consult 18 | // the manuals for the appropriate operating system. 19 | // These calls return err == nil to indicate success; otherwise 20 | // err represents an operating system error describing the failure and 21 | // holds a value of type syscall.Errno. 22 | package windows // import "golang.org/x/sys/windows" 23 | 24 | import ( 25 | "syscall" 26 | ) 27 | 28 | // ByteSliceFromString returns a NUL-terminated slice of bytes 29 | // containing the text of s. If s contains a NUL byte at any 30 | // location, it returns (nil, syscall.EINVAL). 31 | func ByteSliceFromString(s string) ([]byte, error) { 32 | for i := 0; i < len(s); i++ { 33 | if s[i] == 0 { 34 | return nil, syscall.EINVAL 35 | } 36 | } 37 | a := make([]byte, len(s)+1) 38 | copy(a, s) 39 | return a, nil 40 | } 41 | 42 | // BytePtrFromString returns a pointer to a NUL-terminated array of 43 | // bytes containing the text of s. If s contains a NUL byte at any 44 | // location, it returns (nil, syscall.EINVAL). 45 | func BytePtrFromString(s string) (*byte, error) { 46 | a, err := ByteSliceFromString(s) 47 | if err != nil { 48 | return nil, err 49 | } 50 | return &a[0], nil 51 | } 52 | 53 | // Single-word zero for use when we need a valid pointer to 0 bytes. 54 | // See mksyscall.pl. 55 | var _zero uintptr 56 | 57 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 58 | return int64(ts.Sec), int64(ts.Nsec) 59 | } 60 | 61 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 62 | return int64(tv.Sec), int64(tv.Usec) * 1000 63 | } 64 | 65 | func (ts *Timespec) Nano() int64 { 66 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 67 | } 68 | 69 | func (tv *Timeval) Nano() int64 { 70 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 71 | } 72 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/ztypes_windows_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | Description [WSADESCRIPTION_LEN + 1]byte 11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 12 | MaxSockets uint16 13 | MaxUdpDg uint16 14 | VendorInfo *byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Port uint16 21 | Proto *byte 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/ztypes_windows_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | MaxSockets uint16 11 | MaxUdpDg uint16 12 | VendorInfo *byte 13 | Description [WSADESCRIPTION_LEN + 1]byte 14 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Proto *byte 21 | Port uint16 22 | } 23 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | We definitely welcome patches and contribution to grpc! Here are some guidelines 4 | and information about how to do so. 5 | 6 | ## Sending patches 7 | 8 | ### Getting started 9 | 10 | 1. Check out the code: 11 | 12 | $ go get google.golang.org/grpc 13 | $ cd $GOPATH/src/google.golang.org/grpc 14 | 15 | 1. Create a fork of the grpc-go repository. 16 | 1. Add your fork as a remote: 17 | 18 | $ git remote add fork git@github.com:$YOURGITHUBUSERNAME/grpc-go.git 19 | 20 | 1. Make changes, commit them. 21 | 1. Run the test suite: 22 | 23 | $ make test 24 | 25 | 1. Push your changes to your fork: 26 | 27 | $ git push fork ... 28 | 29 | 1. Open a pull request. 30 | 31 | ## Legal requirements 32 | 33 | In order to protect both you and ourselves, you will need to sign the 34 | [Contributor License Agreement](https://cla.developers.google.com/clas). 35 | 36 | ## Filing Issues 37 | When filing an issue, make sure to answer these five questions: 38 | 39 | 1. What version of Go are you using (`go version`)? 40 | 2. What operating system and processor architecture are you using? 41 | 3. What did you do? 42 | 4. What did you expect to see? 43 | 5. What did you see instead? 44 | 45 | ### Contributing code 46 | Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file. 47 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/Makefile: -------------------------------------------------------------------------------- 1 | all: test testrace 2 | 3 | deps: 4 | go get -d -v google.golang.org/grpc/... 5 | 6 | updatedeps: 7 | go get -d -v -u -f google.golang.org/grpc/... 8 | 9 | testdeps: 10 | go get -d -v -t google.golang.org/grpc/... 11 | 12 | updatetestdeps: 13 | go get -d -v -t -u -f google.golang.org/grpc/... 14 | 15 | build: deps 16 | go build google.golang.org/grpc/... 17 | 18 | proto: 19 | @ if ! which protoc > /dev/null; then \ 20 | echo "error: protoc not installed" >&2; \ 21 | exit 1; \ 22 | fi 23 | go get -u -v github.com/golang/protobuf/protoc-gen-go 24 | # use $$dir as the root for all proto files in the same directory 25 | for dir in $$(git ls-files '*.proto' | xargs -n1 dirname | uniq); do \ 26 | protoc -I $$dir --go_out=plugins=grpc:$$dir $$dir/*.proto; \ 27 | done 28 | 29 | test: testdeps 30 | go test -v -cpu 1,4 google.golang.org/grpc/... 31 | 32 | testrace: testdeps 33 | go test -v -race -cpu 1,4 google.golang.org/grpc/... 34 | 35 | clean: 36 | go clean -i google.golang.org/grpc/... 37 | 38 | coverage: testdeps 39 | ./coverage.sh --coveralls 40 | 41 | .PHONY: \ 42 | all \ 43 | deps \ 44 | updatedeps \ 45 | testdeps \ 46 | updatetestdeps \ 47 | build \ 48 | proto \ 49 | test \ 50 | testrace \ 51 | clean \ 52 | coverage 53 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the gRPC project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of gRPC, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of gRPC. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of gRPC or any code incorporated within this 19 | implementation of gRPC constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of gRPC 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/README.md: -------------------------------------------------------------------------------- 1 | #gRPC-Go 2 | 3 | [![Build Status](https://travis-ci.org/grpc/grpc-go.svg)](https://travis-ci.org/grpc/grpc-go) [![GoDoc](https://godoc.org/google.golang.org/grpc?status.svg)](https://godoc.org/google.golang.org/grpc) 4 | 5 | The Go implementation of [gRPC](http://www.grpc.io/): A high performance, open source, general RPC framework that puts mobile and HTTP/2 first. For more information see the [gRPC Quick Start](http://www.grpc.io/docs/) guide. 6 | 7 | Installation 8 | ------------ 9 | 10 | To install this package, you need to install Go and setup your Go workspace on your computer. The simplest way to install the library is to run: 11 | 12 | ``` 13 | $ go get google.golang.org/grpc 14 | ``` 15 | 16 | Prerequisites 17 | ------------- 18 | 19 | This requires Go 1.5 or later . 20 | 21 | Constraints 22 | ----------- 23 | The grpc package should only depend on standard Go packages and a small number of exceptions. If your contribution introduces new dependencies which are NOT in the [list](http://godoc.org/google.golang.org/grpc?imports), you need a discussion with gRPC-Go authors and consultants. 24 | 25 | Documentation 26 | ------------- 27 | See [API documentation](https://godoc.org/google.golang.org/grpc) for package and API descriptions and find examples in the [examples directory](examples/). 28 | 29 | Status 30 | ------ 31 | GA 32 | 33 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/backoff.go: -------------------------------------------------------------------------------- 1 | package grpc 2 | 3 | import ( 4 | "math/rand" 5 | "time" 6 | ) 7 | 8 | // DefaultBackoffConfig uses values specified for backoff in 9 | // https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. 10 | var ( 11 | DefaultBackoffConfig = BackoffConfig{ 12 | MaxDelay: 120 * time.Second, 13 | baseDelay: 1.0 * time.Second, 14 | factor: 1.6, 15 | jitter: 0.2, 16 | } 17 | ) 18 | 19 | // backoffStrategy defines the methodology for backing off after a grpc 20 | // connection failure. 21 | // 22 | // This is unexported until the gRPC project decides whether or not to allow 23 | // alternative backoff strategies. Once a decision is made, this type and its 24 | // method may be exported. 25 | type backoffStrategy interface { 26 | // backoff returns the amount of time to wait before the next retry given 27 | // the number of consecutive failures. 28 | backoff(retries int) time.Duration 29 | } 30 | 31 | // BackoffConfig defines the parameters for the default gRPC backoff strategy. 32 | type BackoffConfig struct { 33 | // MaxDelay is the upper bound of backoff delay. 34 | MaxDelay time.Duration 35 | 36 | // TODO(stevvooe): The following fields are not exported, as allowing 37 | // changes would violate the current gRPC specification for backoff. If 38 | // gRPC decides to allow more interesting backoff strategies, these fields 39 | // may be opened up in the future. 40 | 41 | // baseDelay is the amount of time to wait before retrying after the first 42 | // failure. 43 | baseDelay time.Duration 44 | 45 | // factor is applied to the backoff after each retry. 46 | factor float64 47 | 48 | // jitter provides a range to randomize backoff delays. 49 | jitter float64 50 | } 51 | 52 | func setDefaults(bc *BackoffConfig) { 53 | md := bc.MaxDelay 54 | *bc = DefaultBackoffConfig 55 | 56 | if md > 0 { 57 | bc.MaxDelay = md 58 | } 59 | } 60 | 61 | func (bc BackoffConfig) backoff(retries int) (t time.Duration) { 62 | if retries == 0 { 63 | return bc.baseDelay 64 | } 65 | backoff, max := float64(bc.baseDelay), float64(bc.MaxDelay) 66 | for backoff < max && retries > 0 { 67 | backoff *= bc.factor 68 | retries-- 69 | } 70 | if backoff > max { 71 | backoff = max 72 | } 73 | // Randomize backoff delays so that if a cluster of requests start at 74 | // the same time, they won't operate in lockstep. 75 | backoff *= 1 + bc.jitter*(rand.Float64()*2-1) 76 | if backoff < 0 { 77 | return 0 78 | } 79 | return time.Duration(backoff) 80 | } 81 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/codegen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script serves as an example to demonstrate how to generate the gRPC-Go 4 | # interface and the related messages from .proto file. 5 | # 6 | # It assumes the installation of i) Google proto buffer compiler at 7 | # https://github.com/google/protobuf (after v2.6.1) and ii) the Go codegen 8 | # plugin at https://github.com/golang/protobuf (after 2015-02-20). If you have 9 | # not, please install them first. 10 | # 11 | # We recommend running this script at $GOPATH/src. 12 | # 13 | # If this is not what you need, feel free to make your own scripts. Again, this 14 | # script is for demonstration purpose. 15 | # 16 | proto=$1 17 | protoc --go_out=plugins=grpc:. $proto 18 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/codes/code_string.go: -------------------------------------------------------------------------------- 1 | // generated by stringer -type=Code; DO NOT EDIT 2 | 3 | package codes 4 | 5 | import "fmt" 6 | 7 | const _Code_name = "OKCanceledUnknownInvalidArgumentDeadlineExceededNotFoundAlreadyExistsPermissionDeniedResourceExhaustedFailedPreconditionAbortedOutOfRangeUnimplementedInternalUnavailableDataLossUnauthenticated" 8 | 9 | var _Code_index = [...]uint8{0, 2, 10, 17, 32, 48, 56, 69, 85, 102, 120, 127, 137, 150, 158, 169, 177, 192} 10 | 11 | func (i Code) String() string { 12 | if i+1 >= Code(len(_Code_index)) { 13 | return fmt.Sprintf("Code(%d)", i) 14 | } 15 | return _Code_name[_Code_index[i]:_Code_index[i+1]] 16 | } 17 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | workdir=.cover 6 | profile="$workdir/cover.out" 7 | mode=set 8 | end2endtest="google.golang.org/grpc/test" 9 | 10 | generate_cover_data() { 11 | rm -rf "$workdir" 12 | mkdir "$workdir" 13 | 14 | for pkg in "$@"; do 15 | if [ $pkg == "google.golang.org/grpc" -o $pkg == "google.golang.org/grpc/transport" -o $pkg == "google.golang.org/grpc/metadata" -o $pkg == "google.golang.org/grpc/credentials" ] 16 | then 17 | f="$workdir/$(echo $pkg | tr / -)" 18 | go test -covermode="$mode" -coverprofile="$f.cover" "$pkg" 19 | go test -covermode="$mode" -coverpkg "$pkg" -coverprofile="$f.e2e.cover" "$end2endtest" 20 | fi 21 | done 22 | 23 | echo "mode: $mode" >"$profile" 24 | grep -h -v "^mode:" "$workdir"/*.cover >>"$profile" 25 | } 26 | 27 | show_cover_report() { 28 | go tool cover -${1}="$profile" 29 | } 30 | 31 | push_to_coveralls() { 32 | goveralls -coverprofile="$profile" 33 | } 34 | 35 | generate_cover_data $(go list ./...) 36 | show_cover_report func 37 | case "$1" in 38 | "") 39 | ;; 40 | --html) 41 | show_cover_report html ;; 42 | --coveralls) 43 | push_to_coveralls ;; 44 | *) 45 | echo >&2 "error: invalid option: $1" ;; 46 | esac 47 | rm -rf "$workdir" 48 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/credentials/credentials_util_go17.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | /* 4 | * 5 | * Copyright 2016, Google Inc. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are 10 | * met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above 15 | * copyright notice, this list of conditions and the following disclaimer 16 | * in the documentation and/or other materials provided with the 17 | * distribution. 18 | * * Neither the name of Google Inc. nor the names of its 19 | * contributors may be used to endorse or promote products derived from 20 | * this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | */ 35 | 36 | package credentials 37 | 38 | import ( 39 | "crypto/tls" 40 | ) 41 | 42 | // cloneTLSConfig returns a shallow clone of the exported 43 | // fields of cfg, ignoring the unexported sync.Once, which 44 | // contains a mutex and must not be copied. 45 | // 46 | // If cfg is nil, a new zero tls.Config is returned. 47 | // 48 | // TODO replace this function with official clone function. 49 | func cloneTLSConfig(cfg *tls.Config) *tls.Config { 50 | if cfg == nil { 51 | return &tls.Config{} 52 | } 53 | return &tls.Config{ 54 | Rand: cfg.Rand, 55 | Time: cfg.Time, 56 | Certificates: cfg.Certificates, 57 | NameToCertificate: cfg.NameToCertificate, 58 | GetCertificate: cfg.GetCertificate, 59 | RootCAs: cfg.RootCAs, 60 | NextProtos: cfg.NextProtos, 61 | ServerName: cfg.ServerName, 62 | ClientAuth: cfg.ClientAuth, 63 | ClientCAs: cfg.ClientCAs, 64 | InsecureSkipVerify: cfg.InsecureSkipVerify, 65 | CipherSuites: cfg.CipherSuites, 66 | PreferServerCipherSuites: cfg.PreferServerCipherSuites, 67 | SessionTicketsDisabled: cfg.SessionTicketsDisabled, 68 | SessionTicketKey: cfg.SessionTicketKey, 69 | ClientSessionCache: cfg.ClientSessionCache, 70 | MinVersion: cfg.MinVersion, 71 | MaxVersion: cfg.MaxVersion, 72 | CurvePreferences: cfg.CurvePreferences, 73 | DynamicRecordSizingDisabled: cfg.DynamicRecordSizingDisabled, 74 | Renegotiation: cfg.Renegotiation, 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/credentials/credentials_util_pre_go17.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7 2 | 3 | /* 4 | * 5 | * Copyright 2016, Google Inc. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are 10 | * met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above 15 | * copyright notice, this list of conditions and the following disclaimer 16 | * in the documentation and/or other materials provided with the 17 | * distribution. 18 | * * Neither the name of Google Inc. nor the names of its 19 | * contributors may be used to endorse or promote products derived from 20 | * this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | */ 35 | 36 | package credentials 37 | 38 | import ( 39 | "crypto/tls" 40 | ) 41 | 42 | // cloneTLSConfig returns a shallow clone of the exported 43 | // fields of cfg, ignoring the unexported sync.Once, which 44 | // contains a mutex and must not be copied. 45 | // 46 | // If cfg is nil, a new zero tls.Config is returned. 47 | // 48 | // TODO replace this function with official clone function. 49 | func cloneTLSConfig(cfg *tls.Config) *tls.Config { 50 | if cfg == nil { 51 | return &tls.Config{} 52 | } 53 | return &tls.Config{ 54 | Rand: cfg.Rand, 55 | Time: cfg.Time, 56 | Certificates: cfg.Certificates, 57 | NameToCertificate: cfg.NameToCertificate, 58 | GetCertificate: cfg.GetCertificate, 59 | RootCAs: cfg.RootCAs, 60 | NextProtos: cfg.NextProtos, 61 | ServerName: cfg.ServerName, 62 | ClientAuth: cfg.ClientAuth, 63 | ClientCAs: cfg.ClientCAs, 64 | InsecureSkipVerify: cfg.InsecureSkipVerify, 65 | CipherSuites: cfg.CipherSuites, 66 | PreferServerCipherSuites: cfg.PreferServerCipherSuites, 67 | SessionTicketsDisabled: cfg.SessionTicketsDisabled, 68 | SessionTicketKey: cfg.SessionTicketKey, 69 | ClientSessionCache: cfg.ClientSessionCache, 70 | MinVersion: cfg.MinVersion, 71 | MaxVersion: cfg.MaxVersion, 72 | CurvePreferences: cfg.CurvePreferences, 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package grpc implements an RPC system called gRPC. 3 | 4 | See www.grpc.io for more information about gRPC. 5 | */ 6 | package grpc // import "google.golang.org/grpc" 7 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/grpclog/logger.go: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2015, Google Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are 8 | * met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above 13 | * copyright notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 16 | * * Neither the name of Google Inc. nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | /* 35 | Package grpclog defines logging for grpc. 36 | */ 37 | package grpclog // import "google.golang.org/grpc/grpclog" 38 | 39 | import ( 40 | "log" 41 | "os" 42 | ) 43 | 44 | // Use golang's standard logger by default. 45 | // Access is not mutex-protected: do not modify except in init() 46 | // functions. 47 | var logger Logger = log.New(os.Stderr, "", log.LstdFlags) 48 | 49 | // Logger mimics golang's standard Logger as an interface. 50 | type Logger interface { 51 | Fatal(args ...interface{}) 52 | Fatalf(format string, args ...interface{}) 53 | Fatalln(args ...interface{}) 54 | Print(args ...interface{}) 55 | Printf(format string, args ...interface{}) 56 | Println(args ...interface{}) 57 | } 58 | 59 | // SetLogger sets the logger that is used in grpc. Call only from 60 | // init() functions. 61 | func SetLogger(l Logger) { 62 | logger = l 63 | } 64 | 65 | // Fatal is equivalent to Print() followed by a call to os.Exit() with a non-zero exit code. 66 | func Fatal(args ...interface{}) { 67 | logger.Fatal(args...) 68 | } 69 | 70 | // Fatalf is equivalent to Printf() followed by a call to os.Exit() with a non-zero exit code. 71 | func Fatalf(format string, args ...interface{}) { 72 | logger.Fatalf(format, args...) 73 | } 74 | 75 | // Fatalln is equivalent to Println() followed by a call to os.Exit()) with a non-zero exit code. 76 | func Fatalln(args ...interface{}) { 77 | logger.Fatalln(args...) 78 | } 79 | 80 | // Print prints to the logger. Arguments are handled in the manner of fmt.Print. 81 | func Print(args ...interface{}) { 82 | logger.Print(args...) 83 | } 84 | 85 | // Printf prints to the logger. Arguments are handled in the manner of fmt.Printf. 86 | func Printf(format string, args ...interface{}) { 87 | logger.Printf(format, args...) 88 | } 89 | 90 | // Println prints to the logger. Arguments are handled in the manner of fmt.Println. 91 | func Println(args ...interface{}) { 92 | logger.Println(args...) 93 | } 94 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/interceptor.go: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2016, Google Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are 8 | * met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above 13 | * copyright notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 16 | * * Neither the name of Google Inc. nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | package grpc 35 | 36 | import ( 37 | "golang.org/x/net/context" 38 | ) 39 | 40 | // UnaryServerInfo consists of various information about a unary RPC on 41 | // server side. All per-rpc information may be mutated by the interceptor. 42 | type UnaryServerInfo struct { 43 | // Server is the service implementation the user provides. This is read-only. 44 | Server interface{} 45 | // FullMethod is the full RPC method string, i.e., /package.service/method. 46 | FullMethod string 47 | } 48 | 49 | // UnaryHandler defines the handler invoked by UnaryServerInterceptor to complete the normal 50 | // execution of a unary RPC. 51 | type UnaryHandler func(ctx context.Context, req interface{}) (interface{}, error) 52 | 53 | // UnaryServerInterceptor provides a hook to intercept the execution of a unary RPC on the server. info 54 | // contains all the information of this RPC the interceptor can operate on. And handler is the wrapper 55 | // of the service method implementation. It is the responsibility of the interceptor to invoke handler 56 | // to complete the RPC. 57 | type UnaryServerInterceptor func(ctx context.Context, req interface{}, info *UnaryServerInfo, handler UnaryHandler) (resp interface{}, err error) 58 | 59 | // StreamServerInfo consists of various information about a streaming RPC on 60 | // server side. All per-rpc information may be mutated by the interceptor. 61 | type StreamServerInfo struct { 62 | // FullMethod is the full RPC method string, i.e., /package.service/method. 63 | FullMethod string 64 | // IsClientStream indicates whether the RPC is a client streaming RPC. 65 | IsClientStream bool 66 | // IsServerStream indicates whether the RPC is a server streaming RPC. 67 | IsServerStream bool 68 | } 69 | 70 | // StreamServerInterceptor provides a hook to intercept the execution of a streaming RPC on the server. 71 | // info contains all the information of this RPC the interceptor can operate on. And handler is the 72 | // service method implementation. It is the responsibility of the interceptor to invoke handler to 73 | // complete the RPC. 74 | type StreamServerInterceptor func(srv interface{}, ss ServerStream, info *StreamServerInfo, handler StreamHandler) error 75 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/internal/internal.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016, Google Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above 12 | * copyright notice, this list of conditions and the following disclaimer 13 | * in the documentation and/or other materials provided with the 14 | * distribution. 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | // Package internal contains gRPC-internal code for testing, to avoid polluting 34 | // the godoc of the top-level grpc package. 35 | package internal 36 | 37 | // TestingCloseConns closes all existing transports but keeps 38 | // grpcServer.lis accepting new connections. 39 | // 40 | // The provided grpcServer must be of type *grpc.Server. It is untyped 41 | // for circular dependency reasons. 42 | var TestingCloseConns func(grpcServer interface{}) 43 | 44 | // TestingUseHandlerImpl enables the http.Handler-based server implementation. 45 | // It must be called before Serve and requires TLS credentials. 46 | // 47 | // The provided grpcServer must be of type *grpc.Server. It is untyped 48 | // for circular dependency reasons. 49 | var TestingUseHandlerImpl func(grpcServer interface{}) 50 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/naming/naming.go: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014, Google Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are 8 | * met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above 13 | * copyright notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 16 | * * Neither the name of Google Inc. nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | // Package naming defines the naming API and related data structures for gRPC. 35 | // The interface is EXPERIMENTAL and may be suject to change. 36 | package naming 37 | 38 | // Operation defines the corresponding operations for a name resolution change. 39 | type Operation uint8 40 | 41 | const ( 42 | // Add indicates a new address is added. 43 | Add Operation = iota 44 | // Delete indicates an exisiting address is deleted. 45 | Delete 46 | ) 47 | 48 | // Update defines a name resolution update. Notice that it is not valid having both 49 | // empty string Addr and nil Metadata in an Update. 50 | type Update struct { 51 | // Op indicates the operation of the update. 52 | Op Operation 53 | // Addr is the updated address. It is empty string if there is no address update. 54 | Addr string 55 | // Metadata is the updated metadata. It is nil if there is no metadata update. 56 | // Metadata is not required for a custom naming implementation. 57 | Metadata interface{} 58 | } 59 | 60 | // Resolver creates a Watcher for a target to track its resolution changes. 61 | type Resolver interface { 62 | // Resolve creates a Watcher for target. 63 | Resolve(target string) (Watcher, error) 64 | } 65 | 66 | // Watcher watches for the updates on the specified target. 67 | type Watcher interface { 68 | // Next blocks until an update or error happens. It may return one or more 69 | // updates. The first call should get the full set of the results. It should 70 | // return an error if and only if Watcher cannot recover. 71 | Next() ([]*Update, error) 72 | // Close closes the Watcher. 73 | Close() 74 | } 75 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/peer/peer.go: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014, Google Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are 8 | * met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above 13 | * copyright notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 16 | * * Neither the name of Google Inc. nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | // Package peer defines various peer information associated with RPCs and 35 | // corresponding utils. 36 | package peer 37 | 38 | import ( 39 | "net" 40 | 41 | "golang.org/x/net/context" 42 | "google.golang.org/grpc/credentials" 43 | ) 44 | 45 | // Peer contains the information of the peer for an RPC. 46 | type Peer struct { 47 | // Addr is the peer address. 48 | Addr net.Addr 49 | // AuthInfo is the authentication information of the transport. 50 | // It is nil if there is no transport security being used. 51 | AuthInfo credentials.AuthInfo 52 | } 53 | 54 | type peerKey struct{} 55 | 56 | // NewContext creates a new context with peer information attached. 57 | func NewContext(ctx context.Context, p *Peer) context.Context { 58 | return context.WithValue(ctx, peerKey{}, p) 59 | } 60 | 61 | // FromContext returns the peer information in ctx if it exists. 62 | func FromContext(ctx context.Context) (p *Peer, ok bool) { 63 | p, ok = ctx.Value(peerKey{}).(*Peer) 64 | return 65 | } 66 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/trace.go: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2015, Google Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are 8 | * met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above 13 | * copyright notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 16 | * * Neither the name of Google Inc. nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | package grpc 35 | 36 | import ( 37 | "bytes" 38 | "fmt" 39 | "io" 40 | "net" 41 | "strings" 42 | "time" 43 | 44 | "golang.org/x/net/trace" 45 | ) 46 | 47 | // EnableTracing controls whether to trace RPCs using the golang.org/x/net/trace package. 48 | // This should only be set before any RPCs are sent or received by this program. 49 | var EnableTracing = true 50 | 51 | // methodFamily returns the trace family for the given method. 52 | // It turns "/pkg.Service/GetFoo" into "pkg.Service". 53 | func methodFamily(m string) string { 54 | m = strings.TrimPrefix(m, "/") // remove leading slash 55 | if i := strings.Index(m, "/"); i >= 0 { 56 | m = m[:i] // remove everything from second slash 57 | } 58 | if i := strings.LastIndex(m, "."); i >= 0 { 59 | m = m[i+1:] // cut down to last dotted component 60 | } 61 | return m 62 | } 63 | 64 | // traceInfo contains tracing information for an RPC. 65 | type traceInfo struct { 66 | tr trace.Trace 67 | firstLine firstLine 68 | } 69 | 70 | // firstLine is the first line of an RPC trace. 71 | type firstLine struct { 72 | client bool // whether this is a client (outgoing) RPC 73 | remoteAddr net.Addr 74 | deadline time.Duration // may be zero 75 | } 76 | 77 | func (f *firstLine) String() string { 78 | var line bytes.Buffer 79 | io.WriteString(&line, "RPC: ") 80 | if f.client { 81 | io.WriteString(&line, "to") 82 | } else { 83 | io.WriteString(&line, "from") 84 | } 85 | fmt.Fprintf(&line, " %v deadline:", f.remoteAddr) 86 | if f.deadline != 0 { 87 | fmt.Fprint(&line, f.deadline) 88 | } else { 89 | io.WriteString(&line, "none") 90 | } 91 | return line.String() 92 | } 93 | 94 | // payload represents an RPC request or response payload. 95 | type payload struct { 96 | sent bool // whether this is an outgoing payload 97 | msg interface{} // e.g. a proto.Message 98 | // TODO(dsymonds): add stringifying info to codec, and limit how much we hold here? 99 | } 100 | 101 | func (p payload) String() string { 102 | if p.sent { 103 | return fmt.Sprintf("sent: %v", p.msg) 104 | } 105 | return fmt.Sprintf("recv: %v", p.msg) 106 | } 107 | 108 | type fmtStringer struct { 109 | format string 110 | a []interface{} 111 | } 112 | 113 | func (f *fmtStringer) String() string { 114 | return fmt.Sprintf(f.format, f.a...) 115 | } 116 | 117 | type stringer string 118 | 119 | func (s stringer) String() string { return string(s) } 120 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/transport/go16.go: -------------------------------------------------------------------------------- 1 | // +build go1.6,!go1.7 2 | 3 | /* 4 | * Copyright 2016, Google Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are 9 | * met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Google Inc. nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | package transport 36 | 37 | import ( 38 | "net" 39 | 40 | "golang.org/x/net/context" 41 | ) 42 | 43 | // dialContext connects to the address on the named network. 44 | func dialContext(ctx context.Context, network, address string) (net.Conn, error) { 45 | return (&net.Dialer{Cancel: ctx.Done()}).Dial(network, address) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/transport/go17.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | /* 4 | * Copyright 2016, Google Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are 9 | * met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Google Inc. nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | package transport 36 | 37 | import ( 38 | "net" 39 | 40 | "golang.org/x/net/context" 41 | ) 42 | 43 | // dialContext connects to the address on the named network. 44 | func dialContext(ctx context.Context, network, address string) (net.Conn, error) { 45 | return (&net.Dialer{}).DialContext(ctx, network, address) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/transport/pre_go16.go: -------------------------------------------------------------------------------- 1 | // +build !go1.6 2 | 3 | /* 4 | * Copyright 2016, Google Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are 9 | * met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Google Inc. nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | package transport 36 | 37 | import ( 38 | "net" 39 | "time" 40 | 41 | "golang.org/x/net/context" 42 | ) 43 | 44 | // dialContext connects to the address on the named network. 45 | func dialContext(ctx context.Context, network, address string) (net.Conn, error) { 46 | var dialer net.Dialer 47 | if deadline, ok := ctx.Deadline(); ok { 48 | dialer.Timeout = deadline.Sub(time.Now()) 49 | } 50 | return dialer.Dial(network, address) 51 | } 52 | --------------------------------------------------------------------------------