├── .gitignore ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── build.sh ├── cfssl ├── bin │ ├── cfssl │ └── cfssljson └── gen.sh ├── cmd ├── emulator │ └── main.go ├── gamed │ └── main.go ├── gated │ └── main.go └── ucd │ └── main.go ├── conf ├── etcd │ ├── etcd.yaml.example │ └── keys │ │ ├── .gitkeep │ │ ├── ca.pem │ │ ├── client-key.pem │ │ └── client.pem ├── gamed.json.example ├── gated.json.example ├── sdk │ └── aliyun.json.example └── ucd.json.example ├── data └── .gitkeep ├── docker ├── gamed.sh ├── gated.sh └── ucd.sh ├── docs ├── proto.md └── srv.png ├── emulator ├── agent.go ├── app.go ├── client.go ├── handler.go └── show.go ├── gen_handler.py ├── gen_keys.sh ├── gen_proto.sh ├── internal ├── config │ └── config.go ├── crypt │ └── rsa.go ├── db │ └── db.go ├── dispatch │ └── dispatch.go ├── log │ └── log.go ├── logger │ └── logger.go ├── misc │ ├── math.go │ ├── net.go │ ├── time.go │ └── tls.go ├── naming │ ├── README.md │ └── naming.go └── pb │ ├── .gitkeep │ └── encoding │ ├── decoder.go │ ├── decoder_test.go │ └── protocol.go ├── pb ├── README.md ├── cfg │ ├── item.proto │ └── item_usage.proto ├── def │ ├── account.proto │ ├── app.proto │ ├── common.proto │ ├── event.proto │ ├── item.proto │ ├── mail.proto │ ├── rank.proto │ ├── server.proto │ ├── user.proto │ └── variable.proto ├── msg │ ├── account.proto │ ├── echo.proto │ ├── event.proto │ ├── item.proto │ ├── login.proto │ ├── logout.proto │ ├── mail.proto │ ├── rank.proto │ └── user.proto └── service │ └── game.proto ├── scripts └── docker │ ├── gamed.sh │ ├── gated.sh │ └── ucd.sh ├── sdk └── aliyun │ ├── config │ └── config.go │ ├── sms │ ├── sms.go │ └── sms_test.go │ └── util │ ├── util.go │ └── util_test.go ├── server ├── db │ ├── account.go │ ├── db.go │ ├── item.go │ ├── mail.go │ └── user.go ├── game │ ├── app.go │ ├── entity │ │ ├── session.go │ │ └── user.go │ ├── event │ │ └── event.go │ ├── handler │ │ ├── account.go │ │ ├── echo.go │ │ ├── event.go │ │ ├── item.go │ │ ├── login.go │ │ ├── logout.go │ │ ├── mail.go │ │ ├── rank.go │ │ └── user.go │ └── server.go ├── gate │ ├── app.go │ ├── entity │ │ ├── key.go │ │ ├── server.go │ │ └── user.go │ ├── handler │ │ ├── handler.go │ │ ├── intra_handler.go │ │ └── login.go │ └── server.go └── uc │ ├── app.go │ ├── entity │ └── service.go │ └── web │ ├── controller │ └── v1 │ │ ├── account │ │ ├── auth.go │ │ ├── bind_account.go │ │ ├── bind_phone.go │ │ ├── change_password.go │ │ ├── registry.go │ │ └── reset_password.go │ │ └── verification │ │ └── verification.go │ ├── route.go │ └── server.go ├── tools ├── darwin │ └── protoc │ │ ├── bin │ │ ├── protoc │ │ └── protoc-gen-go │ │ ├── include │ │ └── google │ │ │ └── protobuf │ │ │ ├── any.proto │ │ │ ├── api.proto │ │ │ ├── compiler │ │ │ └── plugin.proto │ │ │ ├── descriptor.proto │ │ │ ├── duration.proto │ │ │ ├── empty.proto │ │ │ ├── field_mask.proto │ │ │ ├── source_context.proto │ │ │ ├── struct.proto │ │ │ ├── timestamp.proto │ │ │ ├── type.proto │ │ │ └── wrappers.proto │ │ └── readme.txt └── linux │ └── protoc │ ├── bin │ ├── protoc │ └── protoc-gen-go │ ├── include │ └── google │ │ └── protobuf │ │ ├── any.proto │ │ ├── api.proto │ │ ├── compiler │ │ └── plugin.proto │ │ ├── descriptor.proto │ │ ├── duration.proto │ │ ├── empty.proto │ │ ├── field_mask.proto │ │ ├── source_context.proto │ │ ├── struct.proto │ │ ├── timestamp.proto │ │ ├── type.proto │ │ └── wrappers.proto │ └── readme.txt └── vendor ├── github.com ├── QSpike │ └── cmd │ │ ├── README.rst │ │ ├── cmd.go │ │ └── doc.go ├── Sirupsen │ └── logrus │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── alt_exit.go │ │ ├── doc.go │ │ ├── entry.go │ │ ├── exported.go │ │ ├── formatter.go │ │ ├── hooks.go │ │ ├── json_formatter.go │ │ ├── logger.go │ │ ├── logrus.go │ │ ├── terminal_appengine.go │ │ ├── terminal_bsd.go │ │ ├── terminal_linux.go │ │ ├── terminal_notwindows.go │ │ ├── terminal_solaris.go │ │ ├── terminal_windows.go │ │ ├── text_formatter.go │ │ └── writer.go ├── coreos │ └── etcd │ │ ├── LICENSE │ │ ├── NOTICE │ │ ├── auth │ │ └── authpb │ │ │ ├── auth.pb.go │ │ │ └── auth.proto │ │ ├── clientv3 │ │ ├── README.md │ │ ├── auth.go │ │ ├── balancer.go │ │ ├── client.go │ │ ├── cluster.go │ │ ├── compact_op.go │ │ ├── compare.go │ │ ├── config.go │ │ ├── doc.go │ │ ├── kv.go │ │ ├── lease.go │ │ ├── logger.go │ │ ├── maintenance.go │ │ ├── op.go │ │ ├── retry.go │ │ ├── sort.go │ │ ├── txn.go │ │ └── watch.go │ │ ├── etcdserver │ │ ├── api │ │ │ └── v3rpc │ │ │ │ └── rpctypes │ │ │ │ ├── doc.go │ │ │ │ ├── error.go │ │ │ │ └── md.go │ │ └── etcdserverpb │ │ │ ├── etcdserver.pb.go │ │ │ ├── etcdserver.proto │ │ │ ├── raft_internal.pb.go │ │ │ ├── raft_internal.proto │ │ │ ├── rpc.pb.go │ │ │ └── rpc.proto │ │ └── mvcc │ │ └── mvccpb │ │ ├── kv.pb.go │ │ └── kv.proto ├── dgrijalva │ └── jwt-go │ │ ├── LICENSE │ │ ├── MIGRATION_GUIDE.md │ │ ├── README.md │ │ ├── VERSION_HISTORY.md │ │ ├── claims.go │ │ ├── doc.go │ │ ├── ecdsa.go │ │ ├── ecdsa_utils.go │ │ ├── errors.go │ │ ├── hmac.go │ │ ├── map_claims.go │ │ ├── none.go │ │ ├── parser.go │ │ ├── rsa.go │ │ ├── rsa_pss.go │ │ ├── rsa_utils.go │ │ ├── signing_method.go │ │ └── token.go ├── flynn │ └── go-shlex │ │ ├── COPYING │ │ ├── Makefile │ │ ├── README.md │ │ └── shlex.go ├── garyburd │ └── redigo │ │ ├── LICENSE │ │ ├── internal │ │ └── commandinfo.go │ │ └── redis │ │ ├── conn.go │ │ ├── doc.go │ │ ├── go17.go │ │ ├── log.go │ │ ├── pool.go │ │ ├── pre_go17.go │ │ ├── pubsub.go │ │ ├── redis.go │ │ ├── reply.go │ │ ├── scan.go │ │ └── script.go ├── go-sql-driver │ └── mysql │ │ ├── AUTHORS │ │ ├── CHANGELOG.md │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── appengine.go │ │ ├── buffer.go │ │ ├── collations.go │ │ ├── connection.go │ │ ├── connection_go18.go │ │ ├── const.go │ │ ├── driver.go │ │ ├── dsn.go │ │ ├── errors.go │ │ ├── infile.go │ │ ├── packets.go │ │ ├── result.go │ │ ├── rows.go │ │ ├── statement.go │ │ ├── transaction.go │ │ ├── utils.go │ │ ├── utils_go17.go │ │ ├── utils_go18.go │ │ └── utils_legacy.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 │ │ └── ptypes │ │ │ └── any │ │ │ ├── any.pb.go │ │ │ └── any.proto │ └── snappy │ │ ├── AUTHORS │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ ├── README │ │ ├── decode.go │ │ ├── decode_amd64.go │ │ ├── decode_amd64.s │ │ ├── decode_other.go │ │ ├── encode.go │ │ ├── encode_amd64.go │ │ ├── encode_amd64.s │ │ ├── encode_other.go │ │ └── snappy.go ├── kesselborn │ └── go-getopt │ │ ├── History.md │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── README.md │ │ ├── TESTED_GO_RELEASE │ │ ├── TODO │ │ ├── config_file.go │ │ ├── config_sample.conf │ │ ├── getopt.go │ │ ├── option.go │ │ ├── option_stringifier.go │ │ ├── option_value.go │ │ ├── options.go │ │ ├── parsing_helper.go │ │ ├── subcommand_api │ │ ├── subcommand_options.go │ │ ├── subsubcommand_options.go │ │ └── visor_api ├── labstack │ ├── echo │ │ ├── Gopkg.lock │ │ ├── Gopkg.toml │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── README.md │ │ ├── bind.go │ │ ├── context.go │ │ ├── echo.go │ │ ├── echo_go1.8.go │ │ ├── group.go │ │ ├── log.go │ │ ├── middleware │ │ │ ├── basic_auth.go │ │ │ ├── body_dump.go │ │ │ ├── body_limit.go │ │ │ ├── compress.go │ │ │ ├── cors.go │ │ │ ├── csrf.go │ │ │ ├── jwt.go │ │ │ ├── key_auth.go │ │ │ ├── logger.go │ │ │ ├── method_override.go │ │ │ ├── middleware.go │ │ │ ├── proxy.go │ │ │ ├── recover.go │ │ │ ├── redirect.go │ │ │ ├── request_id.go │ │ │ ├── secure.go │ │ │ ├── slash.go │ │ │ └── static.go │ │ ├── response.go │ │ ├── router.go │ │ ├── util_go17.go │ │ └── util_go18.go │ └── gommon │ │ ├── LICENSE │ │ ├── bytes │ │ ├── README.md │ │ └── bytes.go │ │ ├── color │ │ ├── README.md │ │ └── color.go │ │ ├── log │ │ ├── README.md │ │ ├── color.go │ │ ├── log.go │ │ └── white.go │ │ └── random │ │ └── random.go ├── mattn │ ├── go-colorable │ │ ├── LICENSE │ │ ├── README.md │ │ ├── colorable_appengine.go │ │ ├── colorable_others.go │ │ ├── colorable_windows.go │ │ └── noncolorable.go │ └── go-isatty │ │ ├── LICENSE │ │ ├── README.md │ │ ├── doc.go │ │ ├── isatty_appengine.go │ │ ├── isatty_bsd.go │ │ ├── isatty_linux.go │ │ ├── isatty_others.go │ │ ├── isatty_solaris.go │ │ └── isatty_windows.go ├── peterh │ └── liner │ │ ├── COPYING │ │ ├── README.md │ │ ├── bsdinput.go │ │ ├── common.go │ │ ├── fallbackinput.go │ │ ├── input.go │ │ ├── input_darwin.go │ │ ├── input_linux.go │ │ ├── input_windows.go │ │ ├── line.go │ │ ├── output.go │ │ ├── output_windows.go │ │ ├── unixmode.go │ │ └── width.go ├── valyala │ ├── bytebufferpool │ │ ├── LICENSE │ │ ├── README.md │ │ ├── bytebuffer.go │ │ ├── doc.go │ │ └── pool.go │ └── fasttemplate │ │ ├── LICENSE │ │ ├── README.md │ │ ├── template.go │ │ ├── unsafe.go │ │ └── unsafe_gae.go └── youngtrips │ ├── anet │ ├── README.md │ ├── event.go │ ├── message.go │ ├── protocol.go │ ├── server.go │ └── session.go │ └── timerqueue │ ├── LICENSE │ ├── README.md │ └── timerqueue.go ├── golang.org └── x │ ├── crypto │ ├── LICENSE │ ├── PATENTS │ └── acme │ │ ├── acme.go │ │ ├── autocert │ │ ├── autocert.go │ │ ├── cache.go │ │ ├── listener.go │ │ └── renewal.go │ │ ├── jws.go │ │ └── types.go │ ├── net │ ├── LICENSE │ ├── PATENTS │ ├── context │ │ ├── context.go │ │ ├── go17.go │ │ └── pre_go17.go │ ├── http2 │ │ ├── Dockerfile │ │ ├── Makefile │ │ ├── README │ │ ├── ciphers.go │ │ ├── client_conn_pool.go │ │ ├── configure_transport.go │ │ ├── databuffer.go │ │ ├── errors.go │ │ ├── flow.go │ │ ├── frame.go │ │ ├── go16.go │ │ ├── go17.go │ │ ├── go17_not18.go │ │ ├── go18.go │ │ ├── go19.go │ │ ├── gotrack.go │ │ ├── headermap.go │ │ ├── hpack │ │ │ ├── encode.go │ │ │ ├── hpack.go │ │ │ ├── huffman.go │ │ │ └── tables.go │ │ ├── http2.go │ │ ├── not_go16.go │ │ ├── not_go17.go │ │ ├── not_go18.go │ │ ├── not_go19.go │ │ ├── pipe.go │ │ ├── server.go │ │ ├── transport.go │ │ ├── write.go │ │ ├── writesched.go │ │ ├── writesched_priority.go │ │ └── writesched_random.go │ ├── idna │ │ ├── idna.go │ │ ├── punycode.go │ │ ├── tables.go │ │ ├── trie.go │ │ └── trieval.go │ ├── internal │ │ └── timeseries │ │ │ └── timeseries.go │ ├── lex │ │ └── httplex │ │ │ └── httplex.go │ └── trace │ │ ├── events.go │ │ ├── histogram.go │ │ ├── trace.go │ │ ├── trace_go16.go │ │ └── trace_go17.go │ ├── sys │ ├── LICENSE │ ├── PATENTS │ └── unix │ │ ├── README.md │ │ ├── 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_mipsx.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 │ │ ├── dirent.go │ │ ├── endian_big.go │ │ ├── endian_little.go │ │ ├── env_unix.go │ │ ├── env_unset.go │ │ ├── flock.go │ │ ├── flock_linux_32bit.go │ │ ├── gccgo.go │ │ ├── gccgo_c.c │ │ ├── gccgo_linux_amd64.go │ │ ├── gccgo_linux_sparc64.go │ │ ├── mkall.sh │ │ ├── mkerrors.sh │ │ ├── mksyscall.pl │ │ ├── mksyscall_solaris.pl │ │ ├── mksysctl_openbsd.pl │ │ ├── mksysnum_darwin.pl │ │ ├── mksysnum_dragonfly.pl │ │ ├── mksysnum_freebsd.pl │ │ ├── mksysnum_netbsd.pl │ │ ├── mksysnum_openbsd.pl │ │ ├── openbsd_pledge.go │ │ ├── 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_amd64_gc.go │ │ ├── syscall_linux_arm.go │ │ ├── syscall_linux_arm64.go │ │ ├── syscall_linux_mips64x.go │ │ ├── syscall_linux_mipsx.go │ │ ├── syscall_linux_ppc64x.go │ │ ├── syscall_linux_s390x.go │ │ ├── syscall_linux_sparc64.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 │ │ ├── syscall_unix_gc.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_mips.go │ │ ├── zerrors_linux_mips64.go │ │ ├── zerrors_linux_mips64le.go │ │ ├── zerrors_linux_mipsle.go │ │ ├── zerrors_linux_ppc64.go │ │ ├── zerrors_linux_ppc64le.go │ │ ├── zerrors_linux_s390x.go │ │ ├── zerrors_linux_sparc64.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_mips.go │ │ ├── zsyscall_linux_mips64.go │ │ ├── zsyscall_linux_mips64le.go │ │ ├── zsyscall_linux_mipsle.go │ │ ├── zsyscall_linux_ppc64.go │ │ ├── zsyscall_linux_ppc64le.go │ │ ├── zsyscall_linux_s390x.go │ │ ├── zsyscall_linux_sparc64.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_mips.go │ │ ├── zsysnum_linux_mips64.go │ │ ├── zsysnum_linux_mips64le.go │ │ ├── zsysnum_linux_mipsle.go │ │ ├── zsysnum_linux_ppc64.go │ │ ├── zsysnum_linux_ppc64le.go │ │ ├── zsysnum_linux_s390x.go │ │ ├── zsysnum_linux_sparc64.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_mips.go │ │ ├── ztypes_linux_mips64.go │ │ ├── ztypes_linux_mips64le.go │ │ ├── ztypes_linux_mipsle.go │ │ ├── ztypes_linux_ppc64.go │ │ ├── ztypes_linux_ppc64le.go │ │ ├── ztypes_linux_s390x.go │ │ ├── ztypes_linux_sparc64.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 │ └── text │ ├── LICENSE │ ├── PATENTS │ ├── secure │ └── bidirule │ │ └── bidirule.go │ ├── transform │ └── transform.go │ └── unicode │ ├── bidi │ ├── bidi.go │ ├── bracket.go │ ├── core.go │ ├── prop.go │ ├── tables.go │ └── trieval.go │ └── norm │ ├── composition.go │ ├── forminfo.go │ ├── input.go │ ├── iter.go │ ├── normalize.go │ ├── readwriter.go │ ├── tables.go │ ├── transform.go │ └── trie.go ├── google.golang.org ├── genproto │ ├── LICENSE │ └── googleapis │ │ └── rpc │ │ └── status │ │ └── status.pb.go └── grpc │ ├── AUTHORS │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── backoff.go │ ├── balancer.go │ ├── call.go │ ├── clientconn.go │ ├── codec.go │ ├── codegen.sh │ ├── codes │ ├── code_string.go │ └── codes.go │ ├── coverage.sh │ ├── credentials │ ├── credentials.go │ ├── credentials_util_go17.go │ ├── credentials_util_go18.go │ └── credentials_util_pre_go17.go │ ├── doc.go │ ├── go16.go │ ├── go17.go │ ├── grpclb.go │ ├── grpclb │ └── grpc_lb_v1 │ │ ├── grpclb.pb.go │ │ └── grpclb.proto │ ├── grpclog │ ├── grpclog.go │ ├── logger.go │ └── loggerv2.go │ ├── interceptor.go │ ├── internal │ └── internal.go │ ├── keepalive │ └── keepalive.go │ ├── metadata │ └── metadata.go │ ├── naming │ └── naming.go │ ├── peer │ └── peer.go │ ├── proxy.go │ ├── rpc_util.go │ ├── server.go │ ├── stats │ ├── handlers.go │ └── stats.go │ ├── status │ └── status.go │ ├── stream.go │ ├── tap │ └── tap.go │ ├── trace.go │ └── transport │ ├── control.go │ ├── go16.go │ ├── go17.go │ ├── handler_server.go │ ├── http2_client.go │ ├── http2_server.go │ ├── http_util.go │ └── transport.go └── vendor.json /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .DS_Store 3 | *.swp 4 | *.~ 5 | bin/authd 6 | bin/emulator 7 | bin/gamed 8 | bin/gated 9 | bin/ucd 10 | ./pkg 11 | *.pyc 12 | libs/pb/*.pb.go 13 | tags 14 | src/tags 15 | config.git-hash 16 | emulator/protocol/*pb2.py 17 | cache/ 18 | *.tmp 19 | .build 20 | *.bz2 21 | logs/ 22 | .bin 23 | cfssl/*.json 24 | cfssl/*.csr 25 | cfssl/*.pem 26 | internal/pb/**/*.pb.go 27 | server/game/dispatcher.go 28 | data/*.csv 29 | conf/*.json 30 | conf/**/*.yaml 31 | conf/**/*.json 32 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine 2 | MAINTAINER Tuz 3 | 4 | RUN apk add tzdata --update && cp /usr/share/zoneinfo/Asia/Chongqing /etc/localtime 5 | RUN apk add ca-certificates 6 | RUN rm -rf /var/cache/apk/* 7 | 8 | WORKDIR /gohive 9 | VOLUME /gohive/conf 10 | VOLUME /gohive/data 11 | VOLUME /gohive/logs 12 | 13 | COPY .bin /gohive/bin 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Tuz(youngtrips@gmail.com) 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 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ## env 2 | CGO_ENABLED=0 3 | GOARCH=amd64 4 | GOOS=linux 5 | GO=go 6 | 7 | ## 8 | BASE_PATH=$(shell pwd) 9 | GOPATH=$(BASE_PATH)/.build 10 | PROJ_NAME = $(shell pwd |sed 's/^\(.*\)[/]//' ) 11 | APPS=$(shell ls cmd) 12 | 13 | all: build 14 | 15 | g: 16 | ./gen_proto.sh 17 | 18 | build: 19 | @if [ ! -L "$(GOPATH)/src/$(PROJ_NAME)" ]; then \ 20 | mkdir -p $(GOPATH)/src ; \ 21 | ln -s $(BASE_PATH) $(GOPATH)/src/$(PROJ_NAME) ; \ 22 | fi 23 | @for APP in $(APPS) ; do \ 24 | echo building $$APP ; \ 25 | CGO_ENABLED=$(CGO_ENABLED) GOPATH=$(GOPATH) $(GO) install $(PROJ_NAME)/cmd/$$APP ; \ 26 | mkdir -p bin ; \ 27 | cp -f $(GOPATH)/bin/* bin/ ; \ 28 | done 29 | 30 | clean: 31 | rm -rf $(GOPATH)/pkg 32 | rm -rf libs/pb/*.pb.go 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### brief 2 | 3 | Go语言实现的分布式游戏服务器,服务器间通过etcd服务器发现维护连接。 4 | 5 | ### build 6 | 7 | make g # generate proto 8 | make 9 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | GOPATH=`pwd` 4 | DST_PATH=.bin 5 | PROJ_NAME=gohive 6 | 7 | rm -rf .bin 8 | mkdir -p $DST_PATH 9 | 10 | cp $GOPATH/bin/ucd $DST_PATH/ 11 | cp $GOPATH/bin/gamed $DST_PATH 12 | cp $GOPATH/bin/gated $DST_PATH 13 | 14 | docker build --no-cache --rm=true -t $PROJ_NAME . 15 | -------------------------------------------------------------------------------- /cfssl/bin/cfssl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/youngtrips/gohive/177dc31a31baadb4995edb76843b0a83cb522e27/cfssl/bin/cfssl -------------------------------------------------------------------------------- /cfssl/bin/cfssljson: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/youngtrips/gohive/177dc31a31baadb4995edb76843b0a83cb522e27/cfssl/bin/cfssljson -------------------------------------------------------------------------------- /cfssl/gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export PATH=$PATH:"./bin" 4 | 5 | hostname=`hostname` 6 | address=`ifconfig -a | grep inet | grep -v "127.0.0.1" | grep -v inet6 | awk '{print $2}' | tr -d "addr:"` 7 | 8 | 9 | ips=($address) 10 | 11 | address='127.0.0.1' 12 | for ip in ${ips[@]};do 13 | address=${address},${ip} 14 | done 15 | 16 | echo "hostname: "$hostname 17 | echo "address : "$address 18 | 19 | echo '{"CN":"CN","key":{"algo":"rsa","size":2048}}' | cfssl gencert -initca - | cfssljson -bare ca - 20 | echo '{"signing":{"default":{"expiry":"43800h","usages":["signing","key encipherment","server auth","client auth"]}}}' > ca-config.json 21 | 22 | # 23 | export ADDRESS=$address 24 | export NAME=next 25 | echo '{"CN":"'$NAME'","hosts":[""],"key":{"algo":"rsa","size":2048}}' | cfssl gencert -config=ca-config.json -ca=ca.pem -ca-key=ca-key.pem -hostname="$ADDRESS" - | cfssljson -bare server 26 | 27 | # 28 | export ADDRESS= 29 | export NAME=client 30 | echo '{"CN":"'$NAME'","hosts":[""],"key":{"algo":"rsa","size":2048}}' | cfssl gencert -config=ca-config.json -ca=ca.pem -ca-key=ca-key.pem -hostname="$ADDRESS" - | cfssljson -bare $NAME 31 | 32 | -------------------------------------------------------------------------------- /cmd/emulator/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "gohive/emulator" 5 | ) 6 | 7 | func main() { 8 | app := emulator.New() 9 | app.Run() 10 | app.Close() 11 | } 12 | -------------------------------------------------------------------------------- /cmd/ucd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | 8 | getopt "github.com/kesselborn/go-getopt" 9 | "gohive/internal/config" 10 | "gohive/server/uc" 11 | ) 12 | 13 | var ( 14 | _VERSION_ = "unknown" 15 | _BUILDDATE_ = "unknown" 16 | 17 | pwd string 18 | ) 19 | 20 | func init() { 21 | pwd, _ = os.Getwd() 22 | } 23 | 24 | func main() { 25 | optionDefinition := getopt.Options{ 26 | "description", 27 | getopt.Definitions{ 28 | {"config|c", "config file", getopt.IsConfigFile | getopt.ExampleIsDefault, filepath.Join(config.PWD, "conf/ucd.json")}, 29 | {"version|v", "show version", getopt.Optional | getopt.Flag, nil}, 30 | }, 31 | } 32 | 33 | options, _, _, e := optionDefinition.ParseCommandLine() 34 | help, wantsHelp := options["help"] 35 | if e != nil || wantsHelp { 36 | exit_code := 0 37 | switch { 38 | case wantsHelp && help.String == "usage": 39 | fmt.Print(optionDefinition.Usage()) 40 | case wantsHelp && help.String == "help": 41 | fmt.Print(optionDefinition.Help()) 42 | default: 43 | fmt.Println("**** Error: ", e.Error(), "\n", optionDefinition.Help()) 44 | exit_code = e.ErrorCode 45 | } 46 | os.Exit(exit_code) 47 | } 48 | version, showVersion := options["version"] 49 | if showVersion && version.Bool { 50 | fmt.Printf("server version %s\n%s\n", _VERSION_, _BUILDDATE_) 51 | os.Exit(0) 52 | } 53 | 54 | cfg, err := config.Load(options["config"].String) 55 | if err != nil { 56 | panic(fmt.Sprintf("load config failed: %s", err)) 57 | } 58 | uc.Run(cfg) 59 | } 60 | -------------------------------------------------------------------------------- /conf/etcd/etcd.yaml.example: -------------------------------------------------------------------------------- 1 | endpoints: 2 | - 127.0.0.1:2379 3 | #auto-sync-interval: 100 4 | #dial-timeout: 200 5 | insecure-transport: false 6 | insecure-skip-tls-verify: false 7 | cert-file: conf/etcd/keys/client.pem 8 | key-file: conf/etcd/keys/client-key.pem 9 | ca-file: conf/etcd/keys/ca.pem 10 | -------------------------------------------------------------------------------- /conf/etcd/keys/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/youngtrips/gohive/177dc31a31baadb4995edb76843b0a83cb522e27/conf/etcd/keys/.gitkeep -------------------------------------------------------------------------------- /conf/etcd/keys/ca.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDDjCCAfagAwIBAgIUIFBZgAt7CakcgdXqW8XETa4rudcwDQYJKoZIhvcNAQEL 3 | BQAwDTELMAkGA1UEAxMCQ04wHhcNMTcwMTExMDI1MzAwWhcNMjIwMTEwMDI1MzAw 4 | WjANMQswCQYDVQQDEwJDTjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB 5 | AM8Y91G3lnRAY3PM9ktVnOnGBVxRxC6jIvW0X7IOMOGuzvIEH9LX27g5MdyNNf9x 6 | cFrmn1GI+Gf6V/XvvxrnzMjx+gP/5BL599biDVyIAM6wZqhK7+2y3Arcba4tKlFm 7 | 97emG2HoOWHMztsf6wCXVuL4+XB6nm9cvCzAmGHkQroR/GzS98e26MMfBC87TUtt 8 | jNLuVhEzmTQBUROrFWkf00jhSBuWc4uTBv5vJo4fmSWk8D/xlkUiWinwoon/eiMo 9 | BBk2wGDovcJpWkUQMMf6t82m3RoJsw570kp4UVWuQQG3vsL9I0QL9GpFTB+5/Jfx 10 | mtcVQo6GH5fbXUU/7sQeiOUCAwEAAaNmMGQwDgYDVR0PAQH/BAQDAgEGMBIGA1Ud 11 | EwEB/wQIMAYBAf8CAQIwHQYDVR0OBBYEFDNfVXSIqAUFy29K9dRhEUXm4M5SMB8G 12 | A1UdIwQYMBaAFDNfVXSIqAUFy29K9dRhEUXm4M5SMA0GCSqGSIb3DQEBCwUAA4IB 13 | AQABnHi7sDDHUYk7exm2IE8XlSLV+u+sYT/eFL/iPGCOlPXZ3sWL/y+4lO7B0fQI 14 | Yr27ipGihVYrf8LT7xG4KlnZUgEkO5j6tm+Tk14MuLwAs8EV2Sel9hUPk/d+jlC6 15 | cPFkHYyJOf+UMWu1Xi+iEb2u9mJjGCRegmGymCIEEwaORsYAe+RZ1Cid4m/HfvNg 16 | nvJcvRPIl9d7CMaO7xlgH708RwP5+6Xzx+5sJUB0HRDNgIPln6gysVZdhaAxJkjC 17 | aoQcMoCL19s3p6Zw7vyLy85SutDrWCUxjT+HhK4UoRyXXGmdVSAXrBtpqjHdmaqH 18 | 93oglOlR+Glj5UPhr8qjSpFx 19 | -----END CERTIFICATE----- 20 | -------------------------------------------------------------------------------- /conf/etcd/keys/client.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDOjCCAiKgAwIBAgIUZWIJgwMZ2RJvzFGROhSegnC14GwwDQYJKoZIhvcNAQEL 3 | BQAwDTELMAkGA1UEAxMCQ04wHhcNMTcwMTExMDI1MzAwWhcNMjIwMTEwMDI1MzAw 4 | WjARMQ8wDQYDVQQDEwZjbGllbnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK 5 | AoIBAQDOMmflIxm8ivE+hFLzp7Fsg77FOrw+0Rejg6G09PW4RrVShjlTyQ6Nv0Hj 6 | vXDjorZSCF7ImL1Blv5vO7pjXvEfO+RAamW3d+e59SfuWIGcMOaAULk3+fQNIIB/ 7 | kYE1+DveFPiwtLy9tcseUfm+QT+Mp6qVCiiI+3SL2gMhNP3X+0I4XMNCxuDK4NiQ 8 | M44TxmT6n1i3ipePx8ExJLkU1GYSv8Cye4c9bQJ5Mmn+Xu4Nk1Lblt/5rWi7FhjW 9 | ed9pfx5IrntGiYVKOSbJsy8bdIybmo5lPTEf+/LxJ+0Dq7Pi8WZMUhz+zS7NyXDc 10 | gLBqDyUpMpZ+hMhKQdu4rvEPVw7dAgMBAAGjgY0wgYowDgYDVR0PAQH/BAQDAgWg 11 | MB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMB0G 12 | A1UdDgQWBBT1uwMoP/LM2XiDqjpF36oFB6/TSTAfBgNVHSMEGDAWgBQzX1V0iKgF 13 | BctvSvXUYRFF5uDOUjALBgNVHREEBDACggAwDQYJKoZIhvcNAQELBQADggEBAMlV 14 | QjfI+HZ2WvMuXjcntCY2m2boYfcDKRIr4EC6WdxLmPUNbHujaeKgTZOwFW3qUpTy 15 | Qka2EQg8aJ79MBnvXFi/fgAvqg9+RvRlMtdAg8aRjAtpfSF7aoiOTjc/WZhC5njT 16 | 1Nky41L7hmZ+n+bgfWCauHyIhXyy83qg3z8dQfkVKo4oMKJVphBovyVcffaRg9ju 17 | A/sV5uWnckTW0IHTyIWtmwS2pBBXloZ4+QUSPiRwXbsg6WeIXk5h1oYJ2Pdmvo8f 18 | riumgg/sds7w9EKo74LqKWlakGbKh/2uXSkuR98F8j0MqagBccAkr3IG8OTCS79j 19 | KnA+YSXABrnHOjYb6xo= 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /conf/gamed.json.example: -------------------------------------------------------------------------------- 1 | { 2 | "id" : 2002, 3 | "type": 10, 4 | "services" : ["gate"], 5 | "etcd":{ 6 | "endpoints":"http://127.0.0.1:2379", 7 | "dial_timeout":200, 8 | "insecure_transport":false, 9 | "insecure_skip_tls_verify":false, 10 | "security" : { 11 | "ca_file":"keys/ca.pem", 12 | "cert_file":"keys/client.pem", 13 | "key_file":"keys/client-key.pem" 14 | } 15 | }, 16 | "redis" : { 17 | "host": "127.0.0.1", 18 | "port": 6379 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /conf/gated.json.example: -------------------------------------------------------------------------------- 1 | { 2 | "id":1001, 3 | "anet" : { 4 | "addr": ":3017", 5 | "advertise_addr": "192.168.1.109", 6 | "max_events" : 65535 7 | }, 8 | 9 | "grpc":{ 10 | "name" : "gate", 11 | "addr":":3018", 12 | "ssl_enable":false, 13 | "ssl_key":{ 14 | "ca_file":"cfssl/ca.pem", 15 | "cert_file":"cfssl/server.pem", 16 | "key_file":"cfssl/server-key.pem" 17 | } 18 | }, 19 | 20 | "etcd":{ 21 | "endpoints":"http://127.0.0.1:2379", 22 | "dial_timeout":200, 23 | "insecure_transport":false, 24 | "insecure_skip_tls_verify":false, 25 | "security" : { 26 | "ca_file":"keys/ca.pem", 27 | "cert_file":"keys/client.pem", 28 | "key_file":"keys/client-key.pem" 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /conf/sdk/aliyun.json.example: -------------------------------------------------------------------------------- 1 | { 2 | "access_key": "xxxxxxxxxxxxx", 3 | "access_secret": "yyyyyyyyyyyyyyyyyyyyyyy", 4 | "SMS" : { 5 | "url" : "http://dysmsapi.aliyuncs.com", 6 | "sign_name": "zzzzzzz", 7 | "template_code" : "aaaaaa" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /conf/ucd.json.example: -------------------------------------------------------------------------------- 1 | { 2 | "http" : { 3 | "mode": "debug", 4 | "host": "0.0.0.0", 5 | "port": 8082 6 | }, 7 | "redis" : { 8 | "host": "127.0.0.1", 9 | "port": 6379 10 | }, 11 | "etcd":{ 12 | "endpoints":"http://127.0.0.1:2379", 13 | "dial_timeout":200, 14 | "insecure_transport":false, 15 | "insecure_skip_tls_verify":false, 16 | "security" : { 17 | "ca_file":"keys/ca.pem", 18 | "cert_file":"keys/client.pem", 19 | "key_file":"keys/client-key.pem" 20 | } 21 | } 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/youngtrips/gohive/177dc31a31baadb4995edb76843b0a83cb522e27/data/.gitkeep -------------------------------------------------------------------------------- /docker/gamed.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | NAME=gamed1 4 | PWD=`pwd` 5 | IMAGES=lab.qeetap.com:5000/gohive:latest 6 | CMD=./bin/proxy 7 | 8 | docker stop $NAME 9 | docker rm -f $NAME 10 | 11 | docker run -d -v $PWD/conf:/gohive/conf -v $PWD/logs:/gohive/logs -v $PWD/data:/gohive/data --network="host" --restart=always --name $NAME $IMAGES $CMD 12 | -------------------------------------------------------------------------------- /docker/gated.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | NAME=gated1 4 | PWD=`pwd` 5 | IMAGES=lab.qeetap.com:5000/gohive:latest 6 | CMD=./bin/gated 7 | 8 | docker stop $NAME 9 | docker rm -f $NAME 10 | 11 | docker run -d -v $PWD/conf:/gohive/conf -v $PWD/logs:/gohive/logs --network="host" --restart=always --name $NAME $IMAGES $CMD 12 | -------------------------------------------------------------------------------- /docker/ucd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | NAME=ucd1 4 | PWD=`pwd` 5 | IMAGES=lab.qeetap.com:5000/gohive:latest 6 | CMD=./bin/ucd 7 | 8 | docker stop $NAME 9 | docker rm -f $NAME 10 | 11 | docker run -d -v $PWD/conf:/gohive/conf -v $PWD/logs:/gohive/logs --network="host" --restart=always --name $NAME $IMAGES $CMD 12 | -------------------------------------------------------------------------------- /docs/srv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/youngtrips/gohive/177dc31a31baadb4995edb76843b0a83cb522e27/docs/srv.png -------------------------------------------------------------------------------- /emulator/app.go: -------------------------------------------------------------------------------- 1 | package emulator 2 | 3 | import ( 4 | "github.com/QSpike/cmd" 5 | ) 6 | 7 | type Application struct { 8 | agents map[string]*Agent 9 | closed bool 10 | } 11 | 12 | func New() *Application { 13 | app := &Application{ 14 | agents: make(map[string]*Agent), 15 | closed: false, 16 | } 17 | app.init() 18 | return app 19 | } 20 | 21 | func (app *Application) init() { 22 | } 23 | 24 | func (app *Application) Close() { 25 | if app.closed { 26 | return 27 | } 28 | } 29 | 30 | func (app *Application) Run() { 31 | app.mainLoop() 32 | } 33 | 34 | func (app *Application) mainLoop() { 35 | c := cmd.New(new(Client)) 36 | c.Cmdloop() 37 | } 38 | -------------------------------------------------------------------------------- /emulator/handler.go: -------------------------------------------------------------------------------- 1 | package emulator 2 | 3 | import ( 4 | "github.com/youngtrips/anet" 5 | "gohive/internal/pb/def" 6 | "gohive/internal/pb/msg" 7 | ) 8 | 9 | func (self *Agent) onMessage(m *anet.Message) { 10 | switch m.Api { 11 | case "msg.Login.Res": 12 | onLoginRes(self, m.Payload.(*msg.Login_Res)) 13 | break 14 | } 15 | } 16 | 17 | func onLoginRes(agent *Agent, res *msg.Login_Res) { 18 | pp("loginRes code: %d", res.GetCode()) 19 | if res.GetCode() == int32(def.RC_OK) { 20 | pp("user: %+v", res.User) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /emulator/show.go: -------------------------------------------------------------------------------- 1 | package emulator 2 | 3 | import () 4 | -------------------------------------------------------------------------------- /gen_keys.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | openssl genrsa -out rsa_private_key.pem 2048 4 | openssl rsa -in rsa_private_key.pem -out rsa_public_key.pem -pubout 5 | openssl pkcs8 -topk8 -in rsa_private_key.pem -out pkcs8_rsa_private_key.pem -nocrypt 6 | 7 | -------------------------------------------------------------------------------- /internal/dispatch/dispatch.go: -------------------------------------------------------------------------------- 1 | package dispatch 2 | 3 | type MsgDispatcher interface { 4 | } 5 | -------------------------------------------------------------------------------- /internal/misc/math.go: -------------------------------------------------------------------------------- 1 | package misc 2 | 3 | import ( 4 | "strconv" 5 | ) 6 | 7 | func Max(a, b int32) int32 { 8 | if a > b { 9 | return a 10 | } 11 | return b 12 | } 13 | 14 | func Min(a, b int32) int32 { 15 | if a < b { 16 | return a 17 | } 18 | return b 19 | } 20 | 21 | func Abs(a int32) int32 { 22 | if a < 0 { 23 | return -a 24 | } 25 | return a 26 | } 27 | 28 | func Atoi32(a string) int32 { 29 | v, err := strconv.Atoi(a) 30 | if err != nil { 31 | return 0 32 | } 33 | return int32(v) 34 | } 35 | -------------------------------------------------------------------------------- /internal/misc/net.go: -------------------------------------------------------------------------------- 1 | package misc 2 | 3 | import ( 4 | "net" 5 | "strings" 6 | ) 7 | 8 | func GetWanIP() (string, error) { 9 | conn, err := net.Dial("udp", "www.baidu.com:80") 10 | if err != nil { 11 | return "", err 12 | } 13 | defer conn.Close() 14 | return strings.Split(conn.LocalAddr().String(), ":")[0], nil 15 | } 16 | -------------------------------------------------------------------------------- /internal/misc/time.go: -------------------------------------------------------------------------------- 1 | package misc 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | func Now() int64 { 8 | return time.Now().Unix() 9 | } 10 | 11 | func NowMS() int64 { 12 | return time.Now().UnixNano() / 1e6 13 | } 14 | 15 | func NowStr() string { 16 | return time.Now().Format("2006-01-02 15:04:05") 17 | } 18 | -------------------------------------------------------------------------------- /internal/misc/tls.go: -------------------------------------------------------------------------------- 1 | package misc 2 | 3 | import ( 4 | "crypto/tls" 5 | "crypto/x509" 6 | "errors" 7 | "io/ioutil" 8 | ) 9 | 10 | func LoadTLS(certFile string, keyFile string, caFile string, insecureSkipTLSVerify bool) (*tls.Config, error) { 11 | certificate, err := tls.LoadX509KeyPair( 12 | certFile, 13 | keyFile, 14 | ) 15 | if err != nil { 16 | return nil, err 17 | } 18 | certPool := x509.NewCertPool() 19 | if caFile != "" { 20 | bs, err := ioutil.ReadFile(caFile) 21 | if err != nil { 22 | return nil, err 23 | } 24 | 25 | if !certPool.AppendCertsFromPEM(bs) { 26 | return nil, errors.New("failed to append client certs") 27 | } 28 | } 29 | TLS := &tls.Config{ 30 | ClientAuth: tls.RequireAndVerifyClientCert, 31 | InsecureSkipVerify: insecureSkipTLSVerify, 32 | Certificates: []tls.Certificate{certificate}, 33 | ClientCAs: certPool, 34 | } 35 | return TLS, nil 36 | } 37 | 38 | /* 39 | tlscfg := &tls.Config{ 40 | MinVersion: tls.VersionTLS10, 41 | InsecureSkipVerify: yc.InsecureSkipTLSVerify, 42 | RootCAs: cp, 43 | } 44 | if cert != nil { 45 | tlscfg.Certificates = []tls.Certificate{*cert} 46 | } 47 | cfg.TLS = tlscfg 48 | 49 | */ 50 | -------------------------------------------------------------------------------- /internal/naming/README.md: -------------------------------------------------------------------------------- 1 | 2 | inspired by [gonet2](https://github.com/gonet2/game/blob/master/registry/registry.go) 3 | -------------------------------------------------------------------------------- /internal/pb/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/youngtrips/gohive/177dc31a31baadb4995edb76843b0a83cb522e27/internal/pb/.gitkeep -------------------------------------------------------------------------------- /internal/pb/encoding/decoder.go: -------------------------------------------------------------------------------- 1 | package encoding 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "reflect" 7 | 8 | "github.com/golang/protobuf/proto" 9 | ) 10 | 11 | func Decode(typeName string, payload []byte) (proto.Message, error) { 12 | //fmt.Printf("typeName: [%s]\n", typeName) 13 | typeValue := proto.MessageType(typeName) 14 | if typeValue == nil { 15 | return nil, errors.New(fmt.Sprintf("no such protocal type: %s", typeName)) 16 | } 17 | 18 | typeValue = typeValue.Elem() 19 | 20 | value := reflect.New(typeValue) 21 | msg := value.Interface().(proto.Message) 22 | if err := proto.Unmarshal(payload, msg); err != nil { 23 | return nil, err 24 | } 25 | return msg, nil 26 | } 27 | -------------------------------------------------------------------------------- /internal/pb/encoding/decoder_test.go: -------------------------------------------------------------------------------- 1 | package encoding 2 | 3 | import ( 4 | "testing" 5 | //log "github.com/Sirupsen/logrus" 6 | ) 7 | 8 | func TestDecoder(t *testing.T) { 9 | decode("proto.MatchMaking.Req", []byte{}) 10 | } 11 | -------------------------------------------------------------------------------- /pb/README.md: -------------------------------------------------------------------------------- 1 | ###PB定义 2 | 3 | * `cfg` 策划配置定义 4 | * `def` 基本对象定义 5 | * `msg` 网络消息 6 | -------------------------------------------------------------------------------- /pb/cfg/item.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package cfg; 4 | 5 | message Item { 6 | required int32 idx = 1; 7 | optional string icon = 2; 8 | } 9 | -------------------------------------------------------------------------------- /pb/cfg/item_usage.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package cfg; 4 | 5 | message ItemUsage { 6 | required int32 idx = 1; 7 | required int32 event = 2; 8 | optional int32 arg_a = 3; 9 | optional int32 arg_b = 4; 10 | } 11 | -------------------------------------------------------------------------------- /pb/def/account.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package def; 4 | 5 | message Account { 6 | required int64 id = 1; 7 | required string username = 2; 8 | required string password = 3; 9 | optional string device_id = 4; 10 | optional string phone = 6; 11 | optional int32 status = 8; 12 | optional int64 createtime = 10; 13 | } 14 | -------------------------------------------------------------------------------- /pb/def/app.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package def; 4 | -------------------------------------------------------------------------------- /pb/def/event.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package def; 4 | 5 | message Event { 6 | required int32 oper = 1; // 事件类型 7 | optional int32 arg_a = 2; // 参数A 8 | optional int32 arg_b = 3; // 参数B 9 | optional int64 arg_64 = 4; // 64位值参数 10 | optional string arg_str = 5; // 字符型参数 11 | } 12 | -------------------------------------------------------------------------------- /pb/def/item.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package def; 4 | 5 | message Item { 6 | required int64 id = 1; 7 | required int32 idx = 2; 8 | required int64 num = 3; 9 | required int64 create_time = 4; 10 | required int64 update_time = 5; 11 | } 12 | -------------------------------------------------------------------------------- /pb/def/mail.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package def; 4 | 5 | import "def/item.proto"; 6 | 7 | message Mail { 8 | required int64 id = 1; 9 | required int32 type = 2; 10 | required int64 from = 3; // sender 11 | required int64 to = 4; // receiver 12 | required int32 status = 5; 13 | optional string title = 6; 14 | optional string content = 7; 15 | required int64 create_time = 8; 16 | required int64 update_time = 9; 17 | repeated Item items = 10; 18 | } 19 | -------------------------------------------------------------------------------- /pb/def/rank.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package def; 4 | 5 | import "def/user.proto"; 6 | 7 | message Rank { 8 | message Item { 9 | required int32 rank = 1; 10 | required int64 val = 2; 11 | optional def.UserBrief user = 3; 12 | } 13 | required int32 type = 1; 14 | repeated Item items = 2; 15 | }; 16 | 17 | -------------------------------------------------------------------------------- /pb/def/server.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package def; 4 | 5 | message Server { 6 | required int32 id = 1; 7 | required int32 type = 2; 8 | required int32 status = 3; 9 | required int32 port = 4; 10 | required string ip = 5; 11 | required string version = 6; 12 | } 13 | -------------------------------------------------------------------------------- /pb/def/user.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package def; 4 | 5 | import "def/item.proto"; 6 | 7 | message User { 8 | required int64 id = 1; 9 | required int64 account = 2; // account id 10 | optional string name = 3; 11 | optional int32 icon = 4; 12 | optional int32 lvl = 5; 13 | optional int32 vip = 6; 14 | optional string motto = 7; 15 | required int32 status = 10; 16 | required int64 create_time = 11; 17 | required int64 update_time = 12; 18 | repeated Item items = 20; 19 | } 20 | 21 | 22 | message UserBrief { 23 | required int64 id = 1; 24 | required string name = 2; 25 | optional int32 icon = 3; 26 | optional int32 lvl = 4; 27 | optional int32 vip = 5; 28 | optional string motto = 6; 29 | } 30 | -------------------------------------------------------------------------------- /pb/def/variable.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package def; 4 | -------------------------------------------------------------------------------- /pb/msg/echo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package msg; 4 | 5 | message Echo { 6 | message Req { 7 | optional int64 val = 1; 8 | optional int64 ct = 2; 9 | } 10 | message Res { 11 | optional int64 val = 1; 12 | optional int64 ct = 2; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /pb/msg/event.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package msg; 4 | 5 | import "def/event.proto"; 6 | 7 | message SetEvent { 8 | message Req { 9 | required def.Event event = 1; 10 | } 11 | message Res { 12 | required int32 code = 2; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /pb/msg/item.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package msg; 4 | 5 | import "def/item.proto"; 6 | 7 | message GiftItems { 8 | message Req { 9 | required int64 dst_id = 1; 10 | required int32 item_idx = 2; 11 | required int32 item_num = 3; 12 | } 13 | message Res { 14 | required int32 code = 1; 15 | } 16 | } 17 | 18 | message GetItems { 19 | message Req { 20 | optional int32 idx = 1; 21 | } 22 | message Res { 23 | required int32 code = 1; 24 | repeated def.Item items = 2; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /pb/msg/login.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package msg; 4 | 5 | import "def/user.proto"; 6 | 7 | message Login { 8 | message Req { 9 | required string token = 1; 10 | } 11 | message Res { 12 | required int32 code = 1; 13 | optional def.User user = 2; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /pb/msg/logout.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package msg; 4 | 5 | message Logout { 6 | message Req { 7 | required int64 account = 1; 8 | } 9 | message Res { 10 | required int32 code = 1; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /pb/msg/mail.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package msg; 4 | 5 | import "def/mail.proto"; 6 | 7 | message GetMails { 8 | message Req { 9 | optional int64 id = 1; 10 | } 11 | message Res { 12 | required int32 code = 1; 13 | repeated def.Mail mails = 2; 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /pb/msg/rank.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package msg; 4 | 5 | import "def/rank.proto"; 6 | 7 | message GetRank { 8 | message Req { 9 | optional int32 type = 1; 10 | } 11 | message Res { 12 | required int32 code = 1; 13 | optional def.Rank rank = 2; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /pb/msg/user.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package msg; 4 | 5 | import "def/user.proto"; 6 | 7 | message GetUser { 8 | message Req { 9 | required int64 id = 1; 10 | } 11 | message Res { 12 | required int32 code = 1; 13 | optional def.User user = 2; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /pb/service/game.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package service; 4 | 5 | message Packet { 6 | int64 peer = 1; 7 | string api = 2; 8 | bytes payload = 3; 9 | } 10 | 11 | service GameService { 12 | rpc Stream(stream Packet) returns (stream Packet); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /scripts/docker/gamed.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | NAME=gamed1 4 | PWD=`pwd` 5 | #IMAGES=lab.qeetap.com/gohive:latest 6 | IMAGES=gohive 7 | CMD=./bin/gamed 8 | 9 | docker stop $NAME 10 | docker rm -f $NAME 11 | 12 | docker run -d -v $PWD/conf:/gohive/conf -v $PWD/logs:/gohive/logs -v $PWD/data:/gohive/data --network="host" --restart=always --name $NAME $IMAGES $CMD 13 | -------------------------------------------------------------------------------- /scripts/docker/gated.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | NAME=gated1 4 | PWD=`pwd` 5 | #IMAGES=lab.qeetap.com/gohive:latest 6 | IMAGES=gohive 7 | CMD=./bin/gated 8 | 9 | docker stop $NAME 10 | docker rm -f $NAME 11 | 12 | docker run -d -v $PWD/conf:/gohive/conf -v $PWD/logs:/gohive/logs --network="host" --restart=always --name $NAME $IMAGES $CMD 13 | -------------------------------------------------------------------------------- /scripts/docker/ucd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | NAME=ucd1 4 | PWD=`pwd` 5 | #IMAGES=lab.qeetap.com:gohive:latest 6 | IMAGES=gohive 7 | CMD=./bin/ucd 8 | 9 | docker stop $NAME 10 | docker rm -f $NAME 11 | 12 | docker run -d -v $PWD/conf:/gohive/conf -v $PWD/logs:/gohive/logs --network="host" --restart=always --name $NAME $IMAGES $CMD 13 | -------------------------------------------------------------------------------- /sdk/aliyun/config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "encoding/json" 5 | "io/ioutil" 6 | "os" 7 | "path/filepath" 8 | 9 | log "github.com/Sirupsen/logrus" 10 | ) 11 | 12 | type SMSParamInfo struct { 13 | Url string `json:"url"` 14 | SignName string `json:"sign_name"` 15 | TemplateCode string `json:"template_code"` 16 | } 17 | 18 | type SDKParamInfo struct { 19 | AccessKey string `json:"access_key"` 20 | AccessSecret string `json:"access_secret"` 21 | SMS SMSParamInfo `json:"SMS"` 22 | } 23 | 24 | var ( 25 | SDKParam SDKParamInfo 26 | ) 27 | 28 | func init() { 29 | PWD, _ := os.Getwd() 30 | data, err := ioutil.ReadFile(filepath.Join(PWD, "conf/sdk/aliyun.json")) 31 | if err != nil { 32 | log.Fatal(err) 33 | } 34 | if err := json.Unmarshal([]byte(data), &SDKParam); err != nil { 35 | log.Fatal(err) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sdk/aliyun/sms/sms_test.go: -------------------------------------------------------------------------------- 1 | package sms 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestSendCode(t *testing.T) { 8 | err := SendCode("15928010910", "123987") 9 | t.Logf("error: %s", err) 10 | } 11 | -------------------------------------------------------------------------------- /sdk/aliyun/util/util_test.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "io/ioutil" 5 | "net/http" 6 | "testing" 7 | ) 8 | 9 | func TestBuildParam(t *testing.T) { 10 | paras := make([]ParamInfo, 0) 11 | paras = append(paras, ParamInfo{"Action", "SendSms"}) 12 | paras = append(paras, ParamInfo{"Version", "2017-05-25"}) 13 | paras = append(paras, ParamInfo{"RegionId", "cn-hangzhou"}) 14 | paras = append(paras, ParamInfo{"PhoneNumbers", "15928010910"}) 15 | paras = append(paras, ParamInfo{"SignName", "电玩城101"}) 16 | paras = append(paras, ParamInfo{"TemplateParam", "{\"code\":\"91753\"}"}) 17 | paras = append(paras, ParamInfo{"TemplateCode", "SMS_78710086"}) 18 | paras = append(paras, ParamInfo{"OutId", "123"}) 19 | 20 | s := BuildParam("LTAIKabOLX7iW7bt", "35uo7vaJJBp7HmFbsmdLAhNI8LficI", "GET", paras) 21 | 22 | url := "http://dysmsapi.aliyuncs.com/?" + s 23 | t.Logf("%s", url) 24 | 25 | resp, err := http.Get(url) 26 | if err != nil { 27 | t.Logf("error: %s", err) 28 | } else { 29 | defer resp.Body.Close() 30 | if body, err := ioutil.ReadAll(resp.Body); err != nil { 31 | t.Logf("error: %s", err) 32 | } else { 33 | t.Logf("resp: %s", string(body)) 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /server/game/app.go: -------------------------------------------------------------------------------- 1 | package game 2 | 3 | import ( 4 | "os" 5 | 6 | "gohive/internal/config" 7 | "gohive/server/db" 8 | ) 9 | 10 | func Run(sc chan os.Signal, cfg *config.ServerInfo) { 11 | db.Open(cfg.Redis.Host, cfg.Redis.Port) 12 | defer db.Close() 13 | 14 | srv := newServer(cfg) 15 | srv.Run(sc) 16 | } 17 | -------------------------------------------------------------------------------- /server/game/entity/user.go: -------------------------------------------------------------------------------- 1 | package entity 2 | 3 | import ( 4 | log "github.com/Sirupsen/logrus" 5 | "gohive/server/db" 6 | ) 7 | 8 | var ( 9 | _users map[int64]*db.User 10 | _account_ids map[int64]int64 11 | ) 12 | 13 | func init() { 14 | _users = make(map[int64]*db.User) 15 | _account_ids = make(map[int64]int64) 16 | } 17 | 18 | func AddUser(user *db.User) { 19 | _users[user.ID()] = user 20 | _account_ids[user.AccID()] = user.ID() 21 | } 22 | 23 | func GetUser(id int64) *db.User { 24 | return _users[id] 25 | } 26 | 27 | func GetUserByAccount(accId int64) *db.User { 28 | userId, present := _account_ids[accId] 29 | if !present { 30 | return nil 31 | } 32 | return GetUser(userId) 33 | } 34 | 35 | func LoadUser(accId int64) *db.User { 36 | log.Infof("load user: accId[%d]", accId) 37 | user := GetUserByAccount(accId) 38 | if user != nil { 39 | return user 40 | } 41 | 42 | userId, err := db.GetUserId(accId) 43 | if err != nil { 44 | log.Info("getUserId by account failed: ", err) 45 | return nil 46 | } 47 | 48 | if user, err = db.LoadUser(userId); err != nil { 49 | log.Warn("loadUser failed: ", err) 50 | } 51 | if user == nil { 52 | user, err = db.CreateUser(accId) 53 | if err != nil { 54 | log.Error("create user failed: ", err) 55 | return nil 56 | } 57 | } 58 | AddUser(user) 59 | return user 60 | } 61 | 62 | func DelUser(accId int64) { 63 | user := GetUserByAccount(accId) 64 | if user != nil { 65 | delete(_users, user.ID()) 66 | delete(_account_ids, user.AccID()) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /server/game/event/event.go: -------------------------------------------------------------------------------- 1 | package event 2 | -------------------------------------------------------------------------------- /server/game/handler/account.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "gohive/internal/pb/msg" 5 | ) 6 | 7 | func OnAuthReq(req *msg.Auth_Req) *msg.Auth_Res { 8 | res := &msg.Auth_Res{} 9 | return res 10 | } 11 | 12 | func OnAuthRes(res *msg.Auth_Res) { 13 | } 14 | 15 | func OnRegistryReq(req *msg.Registry_Req) *msg.Registry_Res { 16 | res := &msg.Registry_Res{} 17 | return res 18 | } 19 | 20 | func OnRegistryRes(res *msg.Registry_Res) { 21 | } 22 | 23 | func OnBindAccountReq(req *msg.BindAccount_Req) *msg.BindAccount_Res { 24 | res := &msg.BindAccount_Res{} 25 | return res 26 | } 27 | 28 | func OnBindAccountRes(res *msg.BindAccount_Res) { 29 | } 30 | 31 | func OnBindPhoneReq(req *msg.BindPhone_Req) *msg.BindPhone_Res { 32 | res := &msg.BindPhone_Res{} 33 | return res 34 | } 35 | 36 | func OnBindPhoneRes(res *msg.BindPhone_Res) { 37 | } 38 | 39 | func OnVerificationCodeReq(req *msg.VerificationCode_Req) *msg.VerificationCode_Res { 40 | res := &msg.VerificationCode_Res{} 41 | return res 42 | } 43 | 44 | func OnVerificationCodeRes(res *msg.VerificationCode_Res) { 45 | } 46 | 47 | func OnResetPasswordReq(req *msg.ResetPassword_Req) *msg.ResetPassword_Res { 48 | res := &msg.ResetPassword_Res{} 49 | return res 50 | } 51 | 52 | func OnResetPasswordRes(res *msg.ResetPassword_Res) { 53 | } 54 | 55 | func OnChangePasswordReq(req *msg.ChangePassword_Req) *msg.ChangePassword_Res { 56 | res := &msg.ChangePassword_Res{} 57 | return res 58 | } 59 | 60 | func OnChangePasswordRes(res *msg.ChangePassword_Res) { 61 | } 62 | -------------------------------------------------------------------------------- /server/game/handler/echo.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "gohive/internal/pb/msg" 5 | ) 6 | 7 | func OnEchoReq(req *msg.Echo_Req) *msg.Echo_Res { 8 | res := &msg.Echo_Res{} 9 | return res 10 | } 11 | 12 | func OnEchoRes(res *msg.Echo_Res) { 13 | } 14 | -------------------------------------------------------------------------------- /server/game/handler/event.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "gohive/internal/pb/msg" 5 | ) 6 | 7 | func OnSetEventReq(req *msg.SetEvent_Req) *msg.SetEvent_Res { 8 | res := &msg.SetEvent_Res{} 9 | return res 10 | } 11 | 12 | func OnSetEventRes(res *msg.SetEvent_Res) { 13 | } 14 | -------------------------------------------------------------------------------- /server/game/handler/item.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "gohive/internal/pb/msg" 5 | ) 6 | 7 | func OnGiftItemsReq(req *msg.GiftItems_Req) *msg.GiftItems_Res { 8 | res := &msg.GiftItems_Res{} 9 | return res 10 | } 11 | 12 | func OnGiftItemsRes(res *msg.GiftItems_Res) { 13 | } 14 | 15 | func OnGetItemsReq(req *msg.GetItems_Req) *msg.GetItems_Res { 16 | res := &msg.GetItems_Res{} 17 | return res 18 | } 19 | 20 | func OnGetItemsRes(res *msg.GetItems_Res) { 21 | } 22 | -------------------------------------------------------------------------------- /server/game/handler/login.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "strconv" 5 | 6 | log "github.com/Sirupsen/logrus" 7 | "github.com/golang/protobuf/proto" 8 | "gohive/internal/pb/def" 9 | "gohive/internal/pb/msg" 10 | "gohive/server/game/entity" 11 | ) 12 | 13 | func OnLoginReq(req *msg.Login_Req) *msg.Login_Res { 14 | log.Infof("onLogin: %+v", req) 15 | 16 | accId, _ := strconv.ParseInt(req.GetToken(), 10, 64) 17 | user := entity.LoadUser(accId) 18 | if user == nil { 19 | return &msg.Login_Res{ 20 | Code: proto.Int32(int32(def.RC_LOGIN_USER_CREATE_FAILED)), 21 | } 22 | } 23 | res := &msg.Login_Res{ 24 | Code: proto.Int32(int32(def.RC_OK)), 25 | User: user.PB, 26 | } 27 | for _, item := range user.Items { 28 | res.User.Items = append(res.User.Items, item) 29 | } 30 | return res 31 | } 32 | 33 | func OnLoginRes(res *msg.Login_Res) { 34 | } 35 | -------------------------------------------------------------------------------- /server/game/handler/logout.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | log "github.com/Sirupsen/logrus" 5 | "github.com/golang/protobuf/proto" 6 | "gohive/internal/pb/def" 7 | "gohive/internal/pb/msg" 8 | "gohive/server/game/entity" 9 | ) 10 | 11 | func OnLogoutReq(req *msg.Logout_Req) *msg.Logout_Res { 12 | res := &msg.Logout_Res{ 13 | Code: proto.Int32(int32(def.RC_OK)), 14 | } 15 | entity.DelUser(req.GetAccount()) 16 | 17 | log.Info("logout: account:", req.GetAccount()) 18 | return res 19 | } 20 | 21 | func OnLogoutRes(res *msg.Logout_Res) { 22 | } 23 | -------------------------------------------------------------------------------- /server/game/handler/mail.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "gohive/internal/pb/msg" 5 | ) 6 | 7 | func OnGetMailsReq(req *msg.GetMails_Req) *msg.GetMails_Res { 8 | res := &msg.GetMails_Res{} 9 | return res 10 | } 11 | 12 | func OnGetMailsRes(res *msg.GetMails_Res) { 13 | } 14 | -------------------------------------------------------------------------------- /server/game/handler/rank.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "gohive/internal/pb/msg" 5 | ) 6 | 7 | func OnGetRankReq(req *msg.GetRank_Req) *msg.GetRank_Res { 8 | res := &msg.GetRank_Res{} 9 | return res 10 | } 11 | 12 | func OnGetRankRes(res *msg.GetRank_Res) { 13 | } 14 | -------------------------------------------------------------------------------- /server/game/handler/user.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "gohive/internal/pb/msg" 5 | ) 6 | 7 | func OnGetUserReq(req *msg.GetUser_Req) *msg.GetUser_Res { 8 | res := &msg.GetUser_Res{} 9 | return res 10 | } 11 | 12 | func OnGetUserRes(res *msg.GetUser_Res) { 13 | } 14 | -------------------------------------------------------------------------------- /server/gate/app.go: -------------------------------------------------------------------------------- 1 | package gate 2 | 3 | import ( 4 | "os" 5 | 6 | "gohive/internal/config" 7 | ) 8 | 9 | func Run(sc chan os.Signal, cfg *config.ServerInfo) { 10 | srv, _ := NewServer(sc, cfg) 11 | srv.Start() 12 | srv.Stop() 13 | } 14 | -------------------------------------------------------------------------------- /server/gate/entity/key.go: -------------------------------------------------------------------------------- 1 | package entity 2 | 3 | import ( 4 | "gohive/internal/crypt" 5 | 6 | log "github.com/Sirupsen/logrus" 7 | ) 8 | 9 | var ( 10 | PRIVATE_KEY string 11 | PUBLIC_KEY string 12 | ) 13 | 14 | func init() { 15 | privateKey, pubKey, err := crypt.GenRSAKeyPair(2048) 16 | if err != nil { 17 | log.Fatal("gen key pair failed: ", err) 18 | } else { 19 | PRIVATE_KEY = privateKey 20 | PUBLIC_KEY = pubKey 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /server/gate/entity/server.go: -------------------------------------------------------------------------------- 1 | package entity 2 | 3 | import ( 4 | "sync" 5 | 6 | log "github.com/Sirupsen/logrus" 7 | "github.com/golang/protobuf/proto" 8 | "gohive/internal/pb/service" 9 | ) 10 | 11 | type ServerAgent struct { 12 | Id int32 13 | wbuf chan *service.Packet 14 | } 15 | 16 | var ( 17 | _sa_lock sync.Mutex 18 | _sas map[int32]*ServerAgent 19 | ) 20 | 21 | func init() { 22 | _sas = make(map[int32]*ServerAgent) 23 | } 24 | 25 | func (sa *ServerAgent) Send(pkt *service.Packet) { 26 | } 27 | 28 | func (sa *ServerAgent) Forward(peer int64, msg proto.Message) error { 29 | 30 | data, err := proto.Marshal(msg) 31 | if err != nil { 32 | return err 33 | } 34 | pkt := &service.Packet{ 35 | Peer: peer, 36 | Api: proto.MessageName(msg), 37 | Payload: data, 38 | } 39 | 40 | sa.wbuf <- pkt 41 | log.Info("send pkt: ", pkt) 42 | return nil 43 | } 44 | 45 | func NewServerAgent(id int32, wbuf chan *service.Packet) *ServerAgent { 46 | 47 | sa := &ServerAgent{ 48 | Id: id, 49 | wbuf: wbuf, 50 | } 51 | 52 | _sa_lock.Lock() 53 | defer _sa_lock.Unlock() 54 | _sas[id] = sa 55 | return sa 56 | } 57 | 58 | func RandServerAgent() *ServerAgent { 59 | _sa_lock.Lock() 60 | defer _sa_lock.Unlock() 61 | for _, sa := range _sas { 62 | if sa != nil { 63 | return sa 64 | } 65 | } 66 | return nil 67 | } 68 | 69 | func GetServerAgent(id int32) *ServerAgent { 70 | _sa_lock.Lock() 71 | defer _sa_lock.Unlock() 72 | return _sas[id] 73 | } 74 | -------------------------------------------------------------------------------- /server/gate/handler/handler.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | log "github.com/Sirupsen/logrus" 5 | "github.com/golang/protobuf/proto" 6 | "gohive/internal/pb/def" 7 | "gohive/internal/pb/msg" 8 | "gohive/internal/pb/service" 9 | "gohive/server/gate/entity" 10 | ) 11 | 12 | func Dispatch(ua *entity.UserAgent, api string, m interface{}) { 13 | log.Info("dispatch: ", api, m) 14 | if api == "msg.Login.Req" { 15 | onLoginReq(ua, m.(*msg.Login_Req)) 16 | } else { 17 | if ua.Server > 0 { 18 | forward(ua, api, m) 19 | } else { 20 | res := &msg.Login_Res{ 21 | Code: proto.Int32(int32(def.RC_LOGIN_TOKEN_INVALID)), 22 | } 23 | ua.Send(res) 24 | } 25 | } 26 | } 27 | 28 | func forward(ua *entity.UserAgent, api string, m interface{}) { 29 | sa := entity.GetServerAgent(ua.Server) 30 | if sa == nil { 31 | log.Warn("invalid message: %s", api) 32 | return 33 | } 34 | 35 | data, err := proto.Marshal(m.(proto.Message)) 36 | if err != nil { 37 | log.Error("invalid message: %s %s", api, err) 38 | return 39 | } 40 | 41 | pkt := &service.Packet{ 42 | Peer: ua.Id, 43 | Api: api, 44 | Payload: data, 45 | } 46 | sa.Send(pkt) 47 | } 48 | -------------------------------------------------------------------------------- /server/gate/handler/intra_handler.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | log "github.com/Sirupsen/logrus" 5 | pb "gohive/internal/pb/service" 6 | "gohive/server/gate/entity" 7 | ) 8 | 9 | func IntraDispatch(sa *entity.ServerAgent, pkt *pb.Packet) { 10 | log.Info("onPacket: ", pkt) 11 | ua := entity.GetUserAgent(pkt.Peer) 12 | if ua == nil { 13 | log.Warn("no found userAgent: ", pkt.Peer) 14 | return 15 | } 16 | ua.RawSend(pkt.Api, pkt.Payload) 17 | if pkt.Api == "msg.Login.Res" { 18 | ua.Server = sa.Id 19 | } else if pkt.Api == "msg.Echo.Req" { 20 | 21 | sa.Send(&pb.Packet{ 22 | Api: "msg.Echo.Res", 23 | Payload: pkt.Payload, 24 | }) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /server/gate/handler/login.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "fmt" 5 | 6 | log "github.com/Sirupsen/logrus" 7 | "github.com/golang/protobuf/proto" 8 | "gohive/internal/pb/def" 9 | "gohive/internal/pb/msg" 10 | "gohive/server/db" 11 | "gohive/server/gate/entity" 12 | ) 13 | 14 | //anonymous 15 | func onLoginReq(ua *entity.UserAgent, req *msg.Login_Req) { 16 | log.Info("login token: ", req.GetToken()) 17 | // check token 18 | accId, code := db.CheckToken(req.GetToken(), entity.PUBLIC_KEY) 19 | if code != int32(def.RC_OK) { 20 | log.Info("login code: ", code) 21 | res := &msg.Login_Res{ 22 | Code: proto.Int32(code), 23 | } 24 | ua.Send(res) 25 | return 26 | } 27 | ua.BindAccount(accId) 28 | log.Info("AccountID: ", accId) 29 | sa := entity.GetServerAgent(ua.Server) 30 | if sa == nil { 31 | sa = entity.RandServerAgent() 32 | } 33 | if sa == nil { 34 | res := &msg.Login_Res{ 35 | Code: proto.Int32(int32(def.RC_GS_NOT_CONNECTED)), 36 | } 37 | ua.Send(res) 38 | } else { 39 | req.Token = proto.String(fmt.Sprintf("%d", accId)) 40 | sa.Forward(ua.Id, req) 41 | } 42 | } 43 | 44 | func onLoginRes(ua *entity.UserAgent, res *msg.Login_Res) { 45 | } 46 | -------------------------------------------------------------------------------- /server/uc/app.go: -------------------------------------------------------------------------------- 1 | package uc 2 | 3 | import ( 4 | log "github.com/Sirupsen/logrus" 5 | "gohive/internal/config" 6 | "gohive/internal/naming" 7 | "gohive/server/db" 8 | "gohive/server/uc/entity" 9 | "gohive/server/uc/web" 10 | ) 11 | 12 | func Run(cfg *config.ServerInfo) { 13 | log.Info(*cfg) 14 | db.Open(cfg.Redis.Host, cfg.Redis.Port) 15 | defer db.Close() 16 | 17 | conns := make(chan *naming.ConnInfo, 65535) 18 | p, err := naming.New(cfg.Etcd.Endpoints, nil, conns, false, "gate") 19 | if err != nil { 20 | log.Fatal(err) 21 | } 22 | go p.Run() 23 | go func() { 24 | for { 25 | select { 26 | case info, ok := <-conns: 27 | if ok { 28 | addr := info.Params["ip"] + ":" + info.Params["anetPort"] 29 | log.Infof("add service: %d %s %s", info.Id, addr, info.Params["key"]) 30 | entity.AddSerice(info.Id, addr, info.Params["key"]) 31 | } 32 | break 33 | } 34 | } 35 | }() 36 | 37 | web.Run(cfg) 38 | } 39 | -------------------------------------------------------------------------------- /server/uc/entity/service.go: -------------------------------------------------------------------------------- 1 | package entity 2 | 3 | import ( 4 | "sync" 5 | 6 | log "github.com/Sirupsen/logrus" 7 | ) 8 | 9 | var _ = log.Info 10 | 11 | type Service struct { 12 | Id int32 13 | Addr string 14 | Key string 15 | Load int32 16 | Status int32 17 | } 18 | 19 | var ( 20 | _srvMapping map[int32]*Service 21 | _srvList []int32 22 | _next int 23 | _srvLock sync.Mutex 24 | ) 25 | 26 | func init() { 27 | _srvMapping = make(map[int32]*Service) 28 | _next = -1 29 | _srvList = make([]int32, 0) 30 | } 31 | 32 | func AddSerice(id int32, addr string, key string) { 33 | _srvLock.Lock() 34 | defer _srvLock.Unlock() 35 | 36 | s, present := _srvMapping[id] 37 | if !present { 38 | _srvList = append(_srvList, id) 39 | s = &Service{ 40 | Id: id, 41 | Addr: addr, 42 | Key: key, 43 | Load: 0, 44 | Status: 0, 45 | } 46 | } else { 47 | s.Addr = addr 48 | s.Key = key 49 | } 50 | _srvMapping[id] = s 51 | } 52 | 53 | func GetService() *Service { 54 | _srvLock.Lock() 55 | defer _srvLock.Unlock() 56 | 57 | size := len(_srvList) 58 | if size <= 0 { 59 | return nil 60 | } 61 | _next = (_next + 1) % size 62 | return _srvMapping[_srvList[int32(_next)]] 63 | } 64 | -------------------------------------------------------------------------------- /server/uc/web/controller/v1/account/bind_account.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | 7 | "github.com/golang/protobuf/proto" 8 | "github.com/labstack/echo" 9 | "gohive/internal/pb/def" 10 | "gohive/internal/pb/msg" 11 | "gohive/server/db" 12 | ) 13 | 14 | func BindAccountHandler(c echo.Context) error { 15 | req := &msg.BindAccount_Req{} 16 | if err := c.Bind(req); err != nil { 17 | return c.String(http.StatusInternalServerError, fmt.Sprintf("%s", err)) 18 | } 19 | 20 | if db.FindAccount(req.GetUsername()) != nil { 21 | res := &msg.BindAccount_Res{ 22 | Code: proto.Int32(int32(def.RC_ACCOUNT_CREATE_DUPLICATE)), 23 | } 24 | return c.JSON(http.StatusOK, res) 25 | } 26 | 27 | acc := db.FindAccountByID(req.GetAccountId()) 28 | if acc == nil { 29 | res := &msg.BindAccount_Res{ 30 | Code: proto.Int32(int32(def.RC_ACCOUNT_NO_FOUND)), 31 | } 32 | return c.JSON(http.StatusOK, res) 33 | } 34 | 35 | if acc.GetUsername() != "" { 36 | res := &msg.BindAccount_Res{ 37 | Code: proto.Int32(int32(def.RC_ACCOUNT_NO_FOUND)), 38 | } 39 | return c.JSON(http.StatusOK, res) 40 | } 41 | 42 | ret := db.BindAccount(acc, req.GetUsername(), req.GetPassword()) 43 | res := &msg.BindAccount_Res{ 44 | Code: proto.Int32(ret), 45 | } 46 | return c.JSON(http.StatusOK, res) 47 | } 48 | -------------------------------------------------------------------------------- /server/uc/web/controller/v1/account/bind_phone.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | 7 | "github.com/golang/protobuf/proto" 8 | "github.com/labstack/echo" 9 | "gohive/internal/pb/def" 10 | "gohive/internal/pb/msg" 11 | "gohive/server/db" 12 | ) 13 | 14 | func BindPhoneHandler(c echo.Context) error { 15 | req := &msg.BindPhone_Req{} 16 | if err := c.Bind(req); err != nil { 17 | return c.String(http.StatusInternalServerError, fmt.Sprintf("%s", err)) 18 | } 19 | 20 | if db.FindAccountByPhone(req.GetPhone()) != nil { 21 | res := &msg.BindAccount_Res{ 22 | Code: proto.Int32(int32(def.RC_ACCOUNT_PHONE_INVALID)), 23 | } 24 | return c.JSON(http.StatusOK, res) 25 | } 26 | 27 | fmt.Printf("bindPhone: %d %s %s\n", req.GetAccountId(), req.GetPhone(), req.GetCode()) 28 | 29 | acc := db.FindAccountByID(req.GetAccountId()) 30 | if acc == nil { 31 | res := &msg.BindAccount_Res{ 32 | Code: proto.Int32(int32(def.RC_ACCOUNT_NO_FOUND)), 33 | } 34 | return c.JSON(http.StatusOK, res) 35 | } 36 | 37 | if !db.CheckAccount(acc, req.GetPassword()) { 38 | res := &msg.BindAccount_Res{ 39 | Code: proto.Int32(int32(def.RC_AUTH_INVALID_USER)), 40 | } 41 | return c.JSON(http.StatusOK, res) 42 | } 43 | 44 | if acc.GetPhone() != "" { 45 | res := &msg.BindAccount_Res{ 46 | Code: proto.Int32(int32(def.RC_ACCOUNT_NO_FOUND)), 47 | } 48 | return c.JSON(http.StatusOK, res) 49 | } 50 | 51 | ret := db.BindPhone(acc, req.GetPhone(), req.GetCode()) 52 | res := &msg.BindAccount_Res{ 53 | Code: proto.Int32(ret), 54 | } 55 | return c.JSON(http.StatusOK, res) 56 | } 57 | -------------------------------------------------------------------------------- /server/uc/web/controller/v1/account/change_password.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | 7 | "github.com/golang/protobuf/proto" 8 | "github.com/labstack/echo" 9 | "gohive/internal/pb/def" 10 | "gohive/internal/pb/msg" 11 | "gohive/server/db" 12 | ) 13 | 14 | func ChangePasswordHandler(c echo.Context) error { 15 | req := &msg.ChangePassword_Req{} 16 | if err := c.Bind(req); err != nil { 17 | return c.String(http.StatusInternalServerError, fmt.Sprintf("%s", err)) 18 | } 19 | 20 | code := int32(def.RC_OK) 21 | acc := db.FindAccountByID(req.GetAccountId()) 22 | if acc == nil { 23 | code = int32(def.RC_ACCOUNT_NO_FOUND) 24 | } else { 25 | fmt.Println("old passworld: ", req.GetPassword()) 26 | fmt.Println("new passworld: ", req.GetNewPassword()) 27 | if !db.CheckAccount(acc, req.GetPassword()) { 28 | code = int32(def.RC_AUTH_INVALID_USER) 29 | } else { 30 | code = db.ChangeAccountPassword(acc, req.GetNewPassword()) 31 | } 32 | } 33 | res := &msg.ChangePassword_Res{Code: proto.Int32(int32(code))} 34 | return c.JSON(http.StatusOK, res) 35 | } 36 | -------------------------------------------------------------------------------- /server/uc/web/controller/v1/account/registry.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | 7 | "github.com/golang/protobuf/proto" 8 | "github.com/labstack/echo" 9 | "gohive/internal/pb/def" 10 | "gohive/internal/pb/msg" 11 | "gohive/server/db" 12 | "gohive/server/uc/entity" 13 | ) 14 | 15 | func RegistryHandler(c echo.Context) error { 16 | req := &msg.Registry_Req{} 17 | if err := c.Bind(req); err != nil { 18 | return c.String(http.StatusInternalServerError, fmt.Sprintf("%s", err)) 19 | } 20 | 21 | res := &msg.Auth_Res{ 22 | Code: proto.Int32(int32(def.RC_OK)), 23 | } 24 | 25 | id, _ := db.GetAccountId(req.GetUsername()) 26 | if id > 0 { 27 | res.Code = proto.Int32(int32(def.RC_ACCOUNT_CREATE_DUPLICATE)) 28 | } else { 29 | if acc, err := db.CreateAccount(req.GetUsername(), req.GetPassword()); err != nil { 30 | res.Code = proto.Int32(int32(def.RC_ACCOUNT_CREATE_FAILED)) 31 | } else { 32 | service := entity.GetService() 33 | if service == nil { 34 | res.Code = proto.Int32(int32(def.RC_COMMON_SERVER_NOT_READY)) 35 | } else { 36 | if token, err := db.GenToken(acc, service.Key); err != nil { 37 | fmt.Printf("gen token failed: %s\n", err) 38 | return c.String(http.StatusInternalServerError, fmt.Sprintf("%s", err)) 39 | } else { 40 | res.Token = proto.String(token) 41 | res.Addr = proto.String(service.Addr) 42 | } 43 | } 44 | } 45 | } 46 | return c.JSON(http.StatusOK, res) 47 | } 48 | -------------------------------------------------------------------------------- /server/uc/web/controller/v1/account/reset_password.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | 7 | "github.com/golang/protobuf/proto" 8 | "github.com/labstack/echo" 9 | "gohive/internal/pb/def" 10 | "gohive/internal/pb/msg" 11 | "gohive/server/db" 12 | ) 13 | 14 | func ResetPasswordHandler(c echo.Context) error { 15 | req := &msg.ResetPassword_Req{} 16 | if err := c.Bind(req); err != nil { 17 | return c.String(http.StatusInternalServerError, fmt.Sprintf("%s", err)) 18 | } 19 | 20 | code := int32(def.RC_OK) 21 | 22 | if acc := db.FindAccountByID(req.GetAccountId()); acc == nil { 23 | code = int32(def.RC_ACCOUNT_NO_FOUND) 24 | } else { 25 | code = db.ResetAccountPassword(acc, req.GetNewPassword(), req.GetCode()) 26 | } 27 | res := &msg.ResetPassword_Res{Code: proto.Int32(code)} 28 | return c.JSON(http.StatusOK, res) 29 | } 30 | -------------------------------------------------------------------------------- /server/uc/web/controller/v1/verification/verification.go: -------------------------------------------------------------------------------- 1 | package verification 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | 7 | log "github.com/Sirupsen/logrus" 8 | "github.com/golang/protobuf/proto" 9 | "github.com/labstack/echo" 10 | "gohive/internal/pb/def" 11 | "gohive/internal/pb/msg" 12 | "gohive/sdk/aliyun/sms" 13 | "gohive/server/db" 14 | ) 15 | 16 | func GetCodeHandler(c echo.Context) error { 17 | req := &msg.VerificationCode_Req{} 18 | if err := c.Bind(req); err != nil { 19 | return c.String(http.StatusInternalServerError, fmt.Sprintf("%s", err)) 20 | } 21 | 22 | fmt.Println(req) 23 | code := def.RC_OK 24 | 25 | verifyInfo, err := db.GenVerification(req.GetPhone()) 26 | if err != nil { 27 | fmt.Println(err) 28 | code = def.RC_SERVER_INTERNAL_ERROR 29 | } 30 | fmt.Println(verifyInfo) 31 | log.Info("phone: ", req.GetPhone()) 32 | if err := sms.SendCode(req.GetPhone(), verifyInfo.Code); err != nil { 33 | log.Error("sms.SendCode: ", err) 34 | code = def.RC_SERVER_INTERNAL_ERROR 35 | } 36 | res := &msg.VerificationCode_Res{ 37 | Code: proto.Int32(int32(code)), 38 | } 39 | return c.JSON(http.StatusOK, res) 40 | } 41 | -------------------------------------------------------------------------------- /server/uc/web/route.go: -------------------------------------------------------------------------------- 1 | package web 2 | 3 | import ( 4 | "gohive/server/uc/web/controller/v1/account" 5 | "gohive/server/uc/web/controller/v1/verification" 6 | 7 | "github.com/labstack/echo" 8 | ) 9 | 10 | func route_init(e *echo.Echo) { 11 | g := e.Group("/v1") 12 | 13 | g.GET("/account/auth", account.AuthHandler) 14 | g.GET("/account/registry", account.RegistryHandler) 15 | g.GET("/account/bind/account", account.BindAccountHandler) 16 | g.GET("/account/bind/phone", account.BindPhoneHandler) 17 | g.GET("/account/password/reset", account.ResetPasswordHandler) 18 | g.GET("/account/password/change", account.ChangePasswordHandler) 19 | g.GET("/verification", verification.GetCodeHandler) 20 | 21 | g.POST("/account/auth", account.AuthHandler) 22 | g.POST("/account/registry", account.RegistryHandler) 23 | g.POST("/account/bind/account", account.BindAccountHandler) 24 | g.POST("/account/bind/phone", account.BindPhoneHandler) 25 | g.POST("/account/password/reset", account.ResetPasswordHandler) 26 | g.POST("/account/password/change", account.ChangePasswordHandler) 27 | g.POST("/verification", verification.GetCodeHandler) 28 | } 29 | -------------------------------------------------------------------------------- /server/uc/web/server.go: -------------------------------------------------------------------------------- 1 | package web 2 | 3 | import ( 4 | "fmt" 5 | 6 | log "github.com/Sirupsen/logrus" 7 | "github.com/labstack/echo" 8 | "github.com/labstack/echo/middleware" 9 | "gohive/internal/config" 10 | ) 11 | 12 | func Run(cfg *config.ServerInfo) { 13 | e := echo.New() 14 | e.Debug = true 15 | if cfg.Http.Mode == "debug" { 16 | e.Debug = true 17 | } else if cfg.Http.Mode == "prod" { 18 | e.Debug = false 19 | } 20 | 21 | e.Use(middleware.Logger()) 22 | e.Use(middleware.Recover()) 23 | 24 | route_init(e) 25 | 26 | addr := fmt.Sprintf("%s:%d", cfg.Http.Host, cfg.Http.Port) 27 | log.Info("listen on : ", addr) 28 | 29 | e.Start(addr) 30 | log.Info("quit...") 31 | } 32 | -------------------------------------------------------------------------------- /tools/darwin/protoc/bin/protoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/youngtrips/gohive/177dc31a31baadb4995edb76843b0a83cb522e27/tools/darwin/protoc/bin/protoc -------------------------------------------------------------------------------- /tools/darwin/protoc/bin/protoc-gen-go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/youngtrips/gohive/177dc31a31baadb4995edb76843b0a83cb522e27/tools/darwin/protoc/bin/protoc-gen-go -------------------------------------------------------------------------------- /tools/darwin/protoc/readme.txt: -------------------------------------------------------------------------------- 1 | Protocol Buffers - Google's data interchange format 2 | Copyright 2008 Google Inc. 3 | https://developers.google.com/protocol-buffers/ 4 | 5 | This package contains a precompiled binary version of the protocol buffer 6 | compiler (protoc). This binary is intended for users who want to use Protocol 7 | Buffers in languages other than C++ but do not want to compile protoc 8 | themselves. To install, simply place this binary somewhere in your PATH. 9 | 10 | Please refer to our official github site for more installation instructions: 11 | https://github.com/google/protobuf 12 | -------------------------------------------------------------------------------- /tools/linux/protoc/bin/protoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/youngtrips/gohive/177dc31a31baadb4995edb76843b0a83cb522e27/tools/linux/protoc/bin/protoc -------------------------------------------------------------------------------- /tools/linux/protoc/bin/protoc-gen-go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/youngtrips/gohive/177dc31a31baadb4995edb76843b0a83cb522e27/tools/linux/protoc/bin/protoc-gen-go -------------------------------------------------------------------------------- /tools/linux/protoc/readme.txt: -------------------------------------------------------------------------------- 1 | Protocol Buffers - Google's data interchange format 2 | Copyright 2008 Google Inc. 3 | https://developers.google.com/protocol-buffers/ 4 | 5 | This package contains a precompiled binary version of the protocol buffer 6 | compiler (protoc). This binary is intended for users who want to use Protocol 7 | Buffers in languages other than C++ but do not want to compile protoc 8 | themselves. To install, simply place this binary somewhere in your PATH. 9 | 10 | Please refer to our official github site for more installation instructions: 11 | https://github.com/google/protobuf 12 | -------------------------------------------------------------------------------- /vendor/github.com/QSpike/cmd/README.rst: -------------------------------------------------------------------------------- 1 | ============== 2 | cmd 3 | ============== 4 | 5 | golang 版本的 cmd.py 6 | 7 | 用两个现有库拼装: 8 | https://github.com/peterh/liner 9 | https://github.com/funkygao/cmd 10 | 11 | 12 | Usage 13 | ===== 14 | 15 | TODO 16 | ==== 17 | - 使用 shlex 18 | -------------------------------------------------------------------------------- /vendor/github.com/QSpike/cmd/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Python's cmd package in golang. 3 | 4 | Sample: 5 | type MyCmd struct {} 6 | func (this MyCmd) Help() { 7 | println("available commands:") 8 | println("list foo") 9 | } 10 | 11 | func (this MyCmd) Help_list() { 12 | println("Usage: list name") 13 | } 14 | 15 | func (this MyCmd) Do_list(name string) { 16 | println("name:", name, "received") 17 | } 18 | 19 | func (this MyCmd) Do_foo() { 20 | } 21 | 22 | c := cmd.New(new(MyCmd)) 23 | c.Cmdloop() 24 | */ 25 | package cmd 26 | -------------------------------------------------------------------------------- /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/terminal_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package logrus 4 | 5 | import "io" 6 | 7 | // IsTerminal returns true if stderr's file descriptor is a terminal. 8 | func IsTerminal(f io.Writer) bool { 9 | return true 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package logrus 5 | 6 | import "syscall" 7 | 8 | const ioctlReadTermios = syscall.TIOCGETA 9 | 10 | type Termios syscall.Termios 11 | -------------------------------------------------------------------------------- /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 | // +build !appengine 7 | 8 | package logrus 9 | 10 | import "syscall" 11 | 12 | const ioctlReadTermios = syscall.TCGETS 13 | 14 | type Termios syscall.Termios 15 | -------------------------------------------------------------------------------- /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 | // +build !appengine 8 | 9 | package logrus 10 | 11 | import ( 12 | "io" 13 | "os" 14 | "syscall" 15 | "unsafe" 16 | ) 17 | 18 | // IsTerminal returns true if stderr's file descriptor is a terminal. 19 | func IsTerminal(f io.Writer) bool { 20 | var termios Termios 21 | switch v := f.(type) { 22 | case *os.File: 23 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(v.Fd()), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 24 | return err == 0 25 | default: 26 | return false 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris,!appengine 2 | 3 | package logrus 4 | 5 | import ( 6 | "io" 7 | "os" 8 | 9 | "golang.org/x/sys/unix" 10 | ) 11 | 12 | // IsTerminal returns true if the given file descriptor is a terminal. 13 | func IsTerminal(f io.Writer) bool { 14 | switch v := f.(type) { 15 | case *os.File: 16 | _, err := unix.IoctlGetTermios(int(v.Fd()), unix.TCGETA) 17 | return err == nil 18 | default: 19 | return false 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /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 | return NewEntry(logger).WriterLevel(level) 15 | } 16 | 17 | func (entry *Entry) Writer() *io.PipeWriter { 18 | return entry.WriterLevel(InfoLevel) 19 | } 20 | 21 | func (entry *Entry) WriterLevel(level Level) *io.PipeWriter { 22 | reader, writer := io.Pipe() 23 | 24 | var printFunc func(args ...interface{}) 25 | 26 | switch level { 27 | case DebugLevel: 28 | printFunc = entry.Debug 29 | case InfoLevel: 30 | printFunc = entry.Info 31 | case WarnLevel: 32 | printFunc = entry.Warn 33 | case ErrorLevel: 34 | printFunc = entry.Error 35 | case FatalLevel: 36 | printFunc = entry.Fatal 37 | case PanicLevel: 38 | printFunc = entry.Panic 39 | default: 40 | printFunc = entry.Print 41 | } 42 | 43 | go entry.writerScanner(reader, printFunc) 44 | runtime.SetFinalizer(writer, writerFinalizer) 45 | 46 | return writer 47 | } 48 | 49 | func (entry *Entry) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) { 50 | scanner := bufio.NewScanner(reader) 51 | for scanner.Scan() { 52 | printFunc(scanner.Text()) 53 | } 54 | if err := scanner.Err(); err != nil { 55 | entry.Errorf("Error while reading from Writer: %s", err) 56 | } 57 | reader.Close() 58 | } 59 | 60 | func writerFinalizer(writer *io.PipeWriter) { 61 | writer.Close() 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/NOTICE: -------------------------------------------------------------------------------- 1 | CoreOS Project 2 | Copyright 2014 CoreOS, Inc 3 | 4 | This product includes software developed at CoreOS, Inc. 5 | (http://www.coreos.com/). 6 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/auth/authpb/auth.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package authpb; 3 | 4 | import "gogoproto/gogo.proto"; 5 | 6 | option (gogoproto.marshaler_all) = true; 7 | option (gogoproto.sizer_all) = true; 8 | option (gogoproto.unmarshaler_all) = true; 9 | option (gogoproto.goproto_getters_all) = false; 10 | option (gogoproto.goproto_enum_prefix_all) = false; 11 | 12 | // User is a single entry in the bucket authUsers 13 | message User { 14 | bytes name = 1; 15 | bytes password = 2; 16 | repeated string roles = 3; 17 | } 18 | 19 | // Permission is a single entity 20 | message Permission { 21 | enum Type { 22 | READ = 0; 23 | WRITE = 1; 24 | READWRITE = 2; 25 | } 26 | Type permType = 1; 27 | 28 | bytes key = 2; 29 | bytes range_end = 3; 30 | } 31 | 32 | // Role is a single entry in the bucket authRoles 33 | message Role { 34 | bytes name = 1; 35 | 36 | repeated Permission keyPermission = 2; 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/clientv3/sort.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package clientv3 16 | 17 | type SortTarget int 18 | type SortOrder int 19 | 20 | const ( 21 | SortNone SortOrder = iota 22 | SortAscend 23 | SortDescend 24 | ) 25 | 26 | const ( 27 | SortByKey SortTarget = iota 28 | SortByVersion 29 | SortByCreateRevision 30 | SortByModRevision 31 | SortByValue 32 | ) 33 | 34 | type SortOption struct { 35 | Target SortTarget 36 | Order SortOrder 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package rpctypes has types and values shared by the etcd server and client for v3 RPC interaction. 16 | package rpctypes 17 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes/md.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package rpctypes 16 | 17 | var ( 18 | MetadataRequireLeaderKey = "hasleader" 19 | MetadataHasLeader = "true" 20 | ) 21 | -------------------------------------------------------------------------------- /vendor/github.com/dgrijalva/jwt-go/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Dave Grijalva 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /vendor/github.com/dgrijalva/jwt-go/doc.go: -------------------------------------------------------------------------------- 1 | // Package jwt is a Go implementation of JSON Web Tokens: http://self-issued.info/docs/draft-jones-json-web-token.html 2 | // 3 | // See README.md for more info. 4 | package jwt 5 | -------------------------------------------------------------------------------- /vendor/github.com/dgrijalva/jwt-go/signing_method.go: -------------------------------------------------------------------------------- 1 | package jwt 2 | 3 | import ( 4 | "sync" 5 | ) 6 | 7 | var signingMethods = map[string]func() SigningMethod{} 8 | var signingMethodLock = new(sync.RWMutex) 9 | 10 | // Implement SigningMethod to add new methods for signing or verifying tokens. 11 | type SigningMethod interface { 12 | Verify(signingString, signature string, key interface{}) error // Returns nil if signature is valid 13 | Sign(signingString string, key interface{}) (string, error) // Returns encoded signature or error 14 | Alg() string // returns the alg identifier for this method (example: 'HS256') 15 | } 16 | 17 | // Register the "alg" name and a factory function for signing method. 18 | // This is typically done during init() in the method's implementation 19 | func RegisterSigningMethod(alg string, f func() SigningMethod) { 20 | signingMethodLock.Lock() 21 | defer signingMethodLock.Unlock() 22 | 23 | signingMethods[alg] = f 24 | } 25 | 26 | // Get a signing method from an "alg" string 27 | func GetSigningMethod(alg string) (method SigningMethod) { 28 | signingMethodLock.RLock() 29 | defer signingMethodLock.RUnlock() 30 | 31 | if methodF, ok := signingMethods[alg]; ok { 32 | method = methodF() 33 | } 34 | return 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/flynn/go-shlex/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Google Inc. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | include $(GOROOT)/src/Make.inc 16 | 17 | TARG=shlex 18 | GOFILES=\ 19 | shlex.go\ 20 | 21 | include $(GOROOT)/src/Make.pkg 22 | -------------------------------------------------------------------------------- /vendor/github.com/flynn/go-shlex/README.md: -------------------------------------------------------------------------------- 1 | go-shlex is a simple lexer for go that supports shell-style quoting, 2 | commenting, and escaping. 3 | -------------------------------------------------------------------------------- /vendor/github.com/garyburd/redigo/redis/go17.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | package redis 4 | 5 | import "crypto/tls" 6 | 7 | // similar cloneTLSClientConfig in the stdlib, but also honor skipVerify for the nil case 8 | func cloneTLSClientConfig(cfg *tls.Config, skipVerify bool) *tls.Config { 9 | if cfg == nil { 10 | return &tls.Config{InsecureSkipVerify: skipVerify} 11 | } 12 | return &tls.Config{ 13 | Rand: cfg.Rand, 14 | Time: cfg.Time, 15 | Certificates: cfg.Certificates, 16 | NameToCertificate: cfg.NameToCertificate, 17 | GetCertificate: cfg.GetCertificate, 18 | RootCAs: cfg.RootCAs, 19 | NextProtos: cfg.NextProtos, 20 | ServerName: cfg.ServerName, 21 | ClientAuth: cfg.ClientAuth, 22 | ClientCAs: cfg.ClientCAs, 23 | InsecureSkipVerify: cfg.InsecureSkipVerify, 24 | CipherSuites: cfg.CipherSuites, 25 | PreferServerCipherSuites: cfg.PreferServerCipherSuites, 26 | ClientSessionCache: cfg.ClientSessionCache, 27 | MinVersion: cfg.MinVersion, 28 | MaxVersion: cfg.MaxVersion, 29 | CurvePreferences: cfg.CurvePreferences, 30 | DynamicRecordSizingDisabled: cfg.DynamicRecordSizingDisabled, 31 | Renegotiation: cfg.Renegotiation, 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/garyburd/redigo/redis/pre_go17.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7 2 | 3 | package redis 4 | 5 | import "crypto/tls" 6 | 7 | // similar cloneTLSClientConfig in the stdlib, but also honor skipVerify for the nil case 8 | func cloneTLSClientConfig(cfg *tls.Config, skipVerify bool) *tls.Config { 9 | if cfg == nil { 10 | return &tls.Config{InsecureSkipVerify: skipVerify} 11 | } 12 | return &tls.Config{ 13 | Rand: cfg.Rand, 14 | Time: cfg.Time, 15 | Certificates: cfg.Certificates, 16 | NameToCertificate: cfg.NameToCertificate, 17 | GetCertificate: cfg.GetCertificate, 18 | RootCAs: cfg.RootCAs, 19 | NextProtos: cfg.NextProtos, 20 | ServerName: cfg.ServerName, 21 | ClientAuth: cfg.ClientAuth, 22 | ClientCAs: cfg.ClientCAs, 23 | InsecureSkipVerify: cfg.InsecureSkipVerify, 24 | CipherSuites: cfg.CipherSuites, 25 | PreferServerCipherSuites: cfg.PreferServerCipherSuites, 26 | ClientSessionCache: cfg.ClientSessionCache, 27 | MinVersion: cfg.MinVersion, 28 | MaxVersion: cfg.MaxVersion, 29 | CurvePreferences: cfg.CurvePreferences, 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | ## Reporting Issues 4 | 5 | Before creating a new Issue, please check first if a similar Issue [already exists](https://github.com/go-sql-driver/mysql/issues?state=open) or was [recently closed](https://github.com/go-sql-driver/mysql/issues?direction=desc&page=1&sort=updated&state=closed). 6 | 7 | ## Contributing Code 8 | 9 | By contributing to this project, you share your code under the Mozilla Public License 2, as specified in the LICENSE file. 10 | Don't forget to add yourself to the AUTHORS file. 11 | 12 | ### Code Review 13 | 14 | Everyone is invited to review and comment on pull requests. 15 | If it looks fine to you, comment with "LGTM" (Looks good to me). 16 | 17 | If changes are required, notice the reviewers with "PTAL" (Please take another look) after committing the fixes. 18 | 19 | Before merging the Pull Request, at least one [team member](https://github.com/go-sql-driver?tab=members) must have commented with "LGTM". 20 | 21 | ## Development Ideas 22 | 23 | If you are looking for ideas for code contributions, please check our [Development Ideas](https://github.com/go-sql-driver/mysql/wiki/Development-Ideas) Wiki page. 24 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/appengine.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2013 The Go-MySQL-Driver Authors. All rights reserved. 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 7 | // You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | // +build appengine 10 | 11 | package mysql 12 | 13 | import ( 14 | "appengine/cloudsql" 15 | ) 16 | 17 | func init() { 18 | RegisterDial("cloudsql", cloudsql.Dial) 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/result.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2012 The Go-MySQL-Driver Authors. All rights reserved. 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 7 | // You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | package mysql 10 | 11 | type mysqlResult struct { 12 | affectedRows int64 13 | insertId int64 14 | } 15 | 16 | func (res *mysqlResult) LastInsertId() (int64, error) { 17 | return res.insertId, nil 18 | } 19 | 20 | func (res *mysqlResult) RowsAffected() (int64, error) { 21 | return res.affectedRows, nil 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/transaction.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2012 The Go-MySQL-Driver Authors. All rights reserved. 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 7 | // You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | package mysql 10 | 11 | type mysqlTx struct { 12 | mc *mysqlConn 13 | } 14 | 15 | func (tx *mysqlTx) Commit() (err error) { 16 | if tx.mc == nil || tx.mc.closed.IsSet() { 17 | return ErrInvalidConn 18 | } 19 | err = tx.mc.exec("COMMIT") 20 | tx.mc = nil 21 | return 22 | } 23 | 24 | func (tx *mysqlTx) Rollback() (err error) { 25 | if tx.mc == nil || tx.mc.closed.IsSet() { 26 | return ErrInvalidConn 27 | } 28 | err = tx.mc.exec("ROLLBACK") 29 | tx.mc = nil 30 | return 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/utils_go18.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2017 The Go-MySQL-Driver Authors. All rights reserved. 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 7 | // You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | // +build go1.8 10 | 11 | package mysql 12 | 13 | import ( 14 | "crypto/tls" 15 | "database/sql" 16 | "database/sql/driver" 17 | "errors" 18 | ) 19 | 20 | func cloneTLSConfig(c *tls.Config) *tls.Config { 21 | return c.Clone() 22 | } 23 | 24 | func namedValueToValue(named []driver.NamedValue) ([]driver.Value, error) { 25 | dargs := make([]driver.Value, len(named)) 26 | for n, param := range named { 27 | if len(param.Name) > 0 { 28 | // TODO: support the use of Named Parameters #561 29 | return nil, errors.New("mysql: driver does not support the use of Named Parameters") 30 | } 31 | dargs[n] = param.Value 32 | } 33 | return dargs, nil 34 | } 35 | 36 | func mapIsolationLevel(level driver.IsolationLevel) (string, error) { 37 | switch sql.IsolationLevel(level) { 38 | case sql.LevelRepeatableRead: 39 | return "REPEATABLE READ", nil 40 | case sql.LevelReadCommitted: 41 | return "READ COMMITTED", nil 42 | case sql.LevelReadUncommitted: 43 | return "READ UNCOMMITTED", nil 44 | case sql.LevelSerializable: 45 | return "SERIALIZABLE", nil 46 | default: 47 | return "", errors.New("mysql: unsupported isolation level: " + string(level)) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/utils_legacy.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2017 The Go-MySQL-Driver Authors. All rights reserved. 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 7 | // You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | // +build !go1.7 10 | 11 | package mysql 12 | 13 | import "crypto/tls" 14 | 15 | func cloneTLSConfig(c *tls.Config) *tls.Config { 16 | clone := *c 17 | return &clone 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of Snappy-Go authors for copyright purposes. 2 | # This file is distinct from the CONTRIBUTORS files. 3 | # See the latter for an explanation. 4 | 5 | # Names should be added to this file as 6 | # Name or Organization 7 | # The email address is not required for organizations. 8 | 9 | # Please keep the list sorted. 10 | 11 | Damian Gryski 12 | Google Inc. 13 | Jan Mercl <0xjnml@gmail.com> 14 | Rodolfo Carvalho 15 | Sebastien Binet 16 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This is the official list of people who can contribute 2 | # (and typically have contributed) code to the Snappy-Go repository. 3 | # The AUTHORS file lists the copyright holders; this file 4 | # lists people. For example, Google employees are listed here 5 | # but not in AUTHORS, because Google holds the copyright. 6 | # 7 | # The submission process automatically checks to make sure 8 | # that people submitting code are listed in this file (by email address). 9 | # 10 | # Names should be added to this file only after verifying that 11 | # the individual or the individual's organization has agreed to 12 | # the appropriate Contributor License Agreement, found here: 13 | # 14 | # http://code.google.com/legal/individual-cla-v1.0.html 15 | # http://code.google.com/legal/corporate-cla-v1.0.html 16 | # 17 | # The agreement for individuals can be filled out on the web. 18 | # 19 | # When adding J Random Contributor's name to this file, 20 | # either J's name or J's organization's name should be 21 | # added to the AUTHORS file, depending on whether the 22 | # individual or corporate CLA was used. 23 | 24 | # Names should be added to this file like so: 25 | # Name 26 | 27 | # Please keep the list sorted. 28 | 29 | Damian Gryski 30 | Jan Mercl <0xjnml@gmail.com> 31 | Kai Backman 32 | Marc-Antoine Ruel 33 | Nigel Tao 34 | Rob Pike 35 | Rodolfo Carvalho 36 | Russ Cox 37 | Sebastien Binet 38 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 The Snappy-Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/decode_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Snappy-Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !appengine 6 | // +build gc 7 | // +build !noasm 8 | 9 | package snappy 10 | 11 | // decode has the same semantics as in decode_other.go. 12 | // 13 | //go:noescape 14 | func decode(dst, src []byte) int 15 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/encode_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Snappy-Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !appengine 6 | // +build gc 7 | // +build !noasm 8 | 9 | package snappy 10 | 11 | // emitLiteral has the same semantics as in encode_other.go. 12 | // 13 | //go:noescape 14 | func emitLiteral(dst, lit []byte) int 15 | 16 | // emitCopy has the same semantics as in encode_other.go. 17 | // 18 | //go:noescape 19 | func emitCopy(dst []byte, offset, length int) int 20 | 21 | // extendMatch has the same semantics as in encode_other.go. 22 | // 23 | //go:noescape 24 | func extendMatch(src []byte, i, j int) int 25 | 26 | // encodeBlock has the same semantics as in encode_other.go. 27 | // 28 | //go:noescape 29 | func encodeBlock(dst, src []byte) (d int) 30 | -------------------------------------------------------------------------------- /vendor/github.com/kesselborn/go-getopt/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011, SoundCloud Ltd., Daniel Bornkessel 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 9 | -------------------------------------------------------------------------------- /vendor/github.com/kesselborn/go-getopt/Makefile: -------------------------------------------------------------------------------- 1 | build: fmt 2 | go version > TESTED_GO_RELEASE 3 | go build -x 4 | 5 | install: 6 | go install 7 | 8 | fmt: 9 | gofmt -s=true -w */*.go *.go 10 | 11 | test: 12 | go test -v 13 | -------------------------------------------------------------------------------- /vendor/github.com/kesselborn/go-getopt/TESTED_GO_RELEASE: -------------------------------------------------------------------------------- 1 | go version weekly.2012-03-27 2 | -------------------------------------------------------------------------------- /vendor/github.com/kesselborn/go-getopt/TODO: -------------------------------------------------------------------------------- 1 | Error 2 | ==== 3 | * use error interface instead of *GetOptError 4 | 5 | Subcommands: 6 | ============ 7 | 8 | * Checks: generic options have to be present 9 | * Checks: "*" must not contain IsArgs 10 | * Checks: "*" IsSubcommand must be last 11 | * check: subcommand: command has to be first options 12 | * check: sub and subsub contains at least one option w/ IsSubCommand flag 13 | -------------------------------------------------------------------------------- /vendor/github.com/kesselborn/go-getopt/config_file.go: -------------------------------------------------------------------------------- 1 | package getopt 2 | 3 | import ( 4 | "io/ioutil" 5 | "regexp" 6 | "strings" 7 | ) 8 | 9 | func mapifyEnvironment(environment []string) (envArray map[string]string) { 10 | envArray = make(map[string]string) 11 | 12 | for _, cur := range environment { 13 | envVar := strings.Split(cur, "=") 14 | if len(envVar) > 1 { 15 | envArray[strings.TrimSpace(envVar[0])] = strings.TrimSpace(envVar[1]) 16 | } 17 | } 18 | 19 | return 20 | } 21 | 22 | func readConfigFile(path string) (configEntries []string, err *GetOptError) { 23 | // ignore all lines without a '=' and with invalid key names 24 | validConfigEntry := regexp.MustCompile("^[A-z0-9_.,]+=.*$") 25 | 26 | content, ioErr := ioutil.ReadFile(path) 27 | contentStringified := string(content) 28 | 29 | if ioErr != nil { 30 | err = &GetOptError{ConfigFileNotFound, ioErr.Error()} 31 | } else { 32 | for _, line := range strings.Split(contentStringified, "\n") { 33 | if validConfigEntry.MatchString(line) { 34 | configEntries = append(configEntries, line) 35 | } 36 | } 37 | } 38 | 39 | return 40 | } 41 | 42 | func processConfigFile(path string, environment map[string]string) (newEnvironment map[string]string, err *GetOptError) { 43 | newEnvironment = environment 44 | 45 | configEntries, err := readConfigFile(strings.TrimSpace(path)) 46 | 47 | if err == nil { 48 | for key, value := range mapifyEnvironment(configEntries) { 49 | if newEnvironment[key] == "" { 50 | newEnvironment[key] = value 51 | } 52 | } 53 | } 54 | 55 | return 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/kesselborn/go-getopt/config_sample.conf: -------------------------------------------------------------------------------- 1 | # this is a testing conf for getopt tests 2 | # getopt will only accept lines which have the form 3 | # [A-z0-9_.,]+=.* 4 | 5 | 6 | FOO=bar 7 | BAR=baz 8 | 9 | this is not a valid config line and will be ignored 10 | -------------------------------------------------------------------------------- /vendor/github.com/kesselborn/go-getopt/parsing_helper.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011, SoundCloud Ltd., Daniel Bornkessel 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // Source code and contact info at http://github.com/kesselborn/go-getopt 5 | 6 | package getopt 7 | 8 | import "strings" 9 | 10 | func parseShortOpt(option string) (opt string, val string, found bool) { 11 | if len(option) > 1 && option[0] == '-' && option[1] >= 'A' && option[1] <= 'z' { 12 | found = true 13 | opt = option[1:2] 14 | if len(option) > 2 { 15 | val = option[2:] 16 | } 17 | 18 | } 19 | 20 | return opt, val, found 21 | } 22 | 23 | func parseLongOpt(option string) (opt string, val string, found bool) { 24 | if len(option) > 3 && option[0:2] == "--" { 25 | found = true 26 | 27 | optTokens := strings.Split(option[2:], "=") 28 | 29 | opt = optTokens[0] 30 | 31 | if len(optTokens) > 1 { 32 | val = optTokens[1] 33 | } 34 | } 35 | 36 | return opt, val, found 37 | } 38 | 39 | func isValue(option string) bool { 40 | _, _, isShortOpt := parseShortOpt(option) 41 | _, _, isLongOpt := parseLongOpt(option) 42 | 43 | return !isShortOpt && !isLongOpt && !argumentsEnd(option) 44 | } 45 | 46 | func argumentsEnd(option string) bool { 47 | return option == OPTIONS_SEPARATOR 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/labstack/echo/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 LabStack 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/labstack/echo/Makefile: -------------------------------------------------------------------------------- 1 | dependency: 2 | go get -u github.com/golang/dep/cmd/dep 3 | dep ensure -update 4 | 5 | test: 6 | echo "" > coverage.txt 7 | for d in $(shell go list ./... | grep -v vendor); do \ 8 | go test -race -coverprofile=profile.out -covermode=atomic $$d; \ 9 | [ -f profile.out ] && cat profile.out >> coverage.txt && rm profile.out; \ 10 | done 11 | -------------------------------------------------------------------------------- /vendor/github.com/labstack/echo/echo_go1.8.go: -------------------------------------------------------------------------------- 1 | // +build go1.8 2 | 3 | package echo 4 | 5 | import ( 6 | stdContext "context" 7 | ) 8 | 9 | // Close immediately stops the server. 10 | // It internally calls `http.Server#Close()`. 11 | func (e *Echo) Close() error { 12 | if err := e.TLSServer.Close(); err != nil { 13 | return err 14 | } 15 | return e.Server.Close() 16 | } 17 | 18 | // Shutdown stops server the gracefully. 19 | // It internally calls `http.Server#Shutdown()`. 20 | func (e *Echo) Shutdown(ctx stdContext.Context) error { 21 | if err := e.TLSServer.Shutdown(ctx); err != nil { 22 | return err 23 | } 24 | return e.Server.Shutdown(ctx) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/labstack/echo/log.go: -------------------------------------------------------------------------------- 1 | package echo 2 | 3 | import ( 4 | "io" 5 | 6 | "github.com/labstack/gommon/log" 7 | ) 8 | 9 | type ( 10 | // Logger defines the logging interface. 11 | Logger interface { 12 | Output() io.Writer 13 | SetOutput(w io.Writer) 14 | Prefix() string 15 | SetPrefix(p string) 16 | Level() log.Lvl 17 | SetLevel(v log.Lvl) 18 | Print(i ...interface{}) 19 | Printf(format string, args ...interface{}) 20 | Printj(j log.JSON) 21 | Debug(i ...interface{}) 22 | Debugf(format string, args ...interface{}) 23 | Debugj(j log.JSON) 24 | Info(i ...interface{}) 25 | Infof(format string, args ...interface{}) 26 | Infoj(j log.JSON) 27 | Warn(i ...interface{}) 28 | Warnf(format string, args ...interface{}) 29 | Warnj(j log.JSON) 30 | Error(i ...interface{}) 31 | Errorf(format string, args ...interface{}) 32 | Errorj(j log.JSON) 33 | Fatal(i ...interface{}) 34 | Fatalj(j log.JSON) 35 | Fatalf(format string, args ...interface{}) 36 | Panic(i ...interface{}) 37 | Panicj(j log.JSON) 38 | Panicf(format string, args ...interface{}) 39 | } 40 | ) 41 | -------------------------------------------------------------------------------- /vendor/github.com/labstack/echo/middleware/middleware.go: -------------------------------------------------------------------------------- 1 | package middleware 2 | 3 | import "github.com/labstack/echo" 4 | 5 | type ( 6 | // Skipper defines a function to skip middleware. Returning true skips processing 7 | // the middleware. 8 | Skipper func(c echo.Context) bool 9 | ) 10 | 11 | // DefaultSkipper returns false which processes the middleware. 12 | func DefaultSkipper(echo.Context) bool { 13 | return false 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/labstack/echo/util_go17.go: -------------------------------------------------------------------------------- 1 | // +build go1.7,!go1.8 2 | 3 | package echo 4 | 5 | import ( 6 | "net/url" 7 | ) 8 | 9 | // PathUnescape is wraps `url.QueryUnescape` 10 | func PathUnescape(s string) (string, error) { 11 | return url.QueryUnescape(s) 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/labstack/echo/util_go18.go: -------------------------------------------------------------------------------- 1 | // +build go1.8 2 | 3 | package echo 4 | 5 | import "net/url" 6 | 7 | // PathUnescape is wraps `url.PathUnescape` 8 | func PathUnescape(s string) (string, error) { 9 | return url.PathUnescape(s) 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/labstack/gommon/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 labstack 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 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/labstack/gommon/bytes/README.md: -------------------------------------------------------------------------------- 1 | # Bytes 2 | 3 | - Format bytes integer to human readable bytes string. 4 | - Parse human readable bytes string to bytes integer. 5 | 6 | ## Installation 7 | 8 | ```go 9 | go get github.com/labstack/gommon/bytes 10 | ``` 11 | 12 | ## [Usage](https://github.com/labstack/gommon/blob/master/bytes/bytes_test.go) 13 | 14 | ### Format 15 | 16 | ```go 17 | println(bytes.Format(13231323)) 18 | ``` 19 | 20 | `12.62MB` 21 | 22 | ### Parse 23 | 24 | ```go 25 | b, _ = Parse("2M") 26 | println(b) 27 | ``` 28 | 29 | `2097152` 30 | -------------------------------------------------------------------------------- /vendor/github.com/labstack/gommon/log/README.md: -------------------------------------------------------------------------------- 1 | ## WORK IN PROGRESS 2 | 3 | ### Usage 4 | 5 | [log_test.go](log_test.go) 6 | -------------------------------------------------------------------------------- /vendor/github.com/labstack/gommon/log/color.go: -------------------------------------------------------------------------------- 1 | // +build !appengine 2 | 3 | package log 4 | 5 | import ( 6 | "io" 7 | 8 | "github.com/mattn/go-colorable" 9 | ) 10 | 11 | func output() io.Writer { 12 | return colorable.NewColorableStdout() 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/labstack/gommon/log/white.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package log 4 | 5 | import ( 6 | "io" 7 | "os" 8 | ) 9 | 10 | func output() io.Writer { 11 | return os.Stdout 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/labstack/gommon/random/random.go: -------------------------------------------------------------------------------- 1 | package random 2 | 3 | import ( 4 | "math/rand" 5 | "strings" 6 | "time" 7 | ) 8 | 9 | type ( 10 | Random struct { 11 | } 12 | ) 13 | 14 | // Charsets 15 | const ( 16 | Uppercase string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 17 | Lowercase = "abcdefghijklmnopqrstuvwxyz" 18 | Alphabetic = Uppercase + Lowercase 19 | Numeric = "0123456789" 20 | Alphanumeric = Alphabetic + Numeric 21 | Symbols = "`" + `~!@#$%^&*()-_+={}[]|\;:"<>,./?` 22 | Hex = Numeric + "abcdef" 23 | ) 24 | 25 | var ( 26 | global = New() 27 | ) 28 | 29 | func New() *Random { 30 | rand.Seed(time.Now().UnixNano()) 31 | return new(Random) 32 | } 33 | 34 | func (r *Random) String(length uint8, charsets ...string) string { 35 | charset := strings.Join(charsets, "") 36 | if charset == "" { 37 | charset = Alphanumeric 38 | } 39 | b := make([]byte, length) 40 | for i := range b { 41 | b[i] = charset[rand.Int63()%int64(len(charset))] 42 | } 43 | return string(b) 44 | } 45 | 46 | func String(length uint8, charsets ...string) string { 47 | return global.String(length, charsets...) 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yasuhiro Matsumoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package colorable 4 | 5 | import ( 6 | "io" 7 | "os" 8 | 9 | _ "github.com/mattn/go-isatty" 10 | ) 11 | 12 | // NewColorable return new instance of Writer which handle escape sequence. 13 | func NewColorable(file *os.File) io.Writer { 14 | if file == nil { 15 | panic("nil passed instead of *os.File to NewColorable()") 16 | } 17 | 18 | return file 19 | } 20 | 21 | // NewColorableStdout return new instance of Writer which handle escape sequence for stdout. 22 | func NewColorableStdout() io.Writer { 23 | return os.Stdout 24 | } 25 | 26 | // NewColorableStderr return new instance of Writer which handle escape sequence for stderr. 27 | func NewColorableStderr() io.Writer { 28 | return os.Stderr 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !appengine 3 | 4 | package colorable 5 | 6 | import ( 7 | "io" 8 | "os" 9 | 10 | _ "github.com/mattn/go-isatty" 11 | ) 12 | 13 | // NewColorable return new instance of Writer which handle escape sequence. 14 | func NewColorable(file *os.File) io.Writer { 15 | if file == nil { 16 | panic("nil passed instead of *os.File to NewColorable()") 17 | } 18 | 19 | return file 20 | } 21 | 22 | // NewColorableStdout return new instance of Writer which handle escape sequence for stdout. 23 | func NewColorableStdout() io.Writer { 24 | return os.Stdout 25 | } 26 | 27 | // NewColorableStderr return new instance of Writer which handle escape sequence for stderr. 28 | func NewColorableStderr() io.Writer { 29 | return os.Stderr 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/noncolorable.go: -------------------------------------------------------------------------------- 1 | package colorable 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | ) 7 | 8 | // NonColorable hold writer but remove escape sequence. 9 | type NonColorable struct { 10 | out io.Writer 11 | } 12 | 13 | // NewNonColorable return new instance of Writer which remove escape sequence from Writer. 14 | func NewNonColorable(w io.Writer) io.Writer { 15 | return &NonColorable{out: w} 16 | } 17 | 18 | // Write write data on console 19 | func (w *NonColorable) Write(data []byte) (n int, err error) { 20 | er := bytes.NewReader(data) 21 | var bw [1]byte 22 | loop: 23 | for { 24 | c1, err := er.ReadByte() 25 | if err != nil { 26 | break loop 27 | } 28 | if c1 != 0x1b { 29 | bw[0] = c1 30 | w.out.Write(bw[:]) 31 | continue 32 | } 33 | c2, err := er.ReadByte() 34 | if err != nil { 35 | break loop 36 | } 37 | if c2 != 0x5b { 38 | continue 39 | } 40 | 41 | var buf bytes.Buffer 42 | for { 43 | c, err := er.ReadByte() 44 | if err != nil { 45 | break loop 46 | } 47 | if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' { 48 | break 49 | } 50 | buf.Write([]byte(string(c))) 51 | } 52 | } 53 | 54 | return len(data), nil 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Yasuhiro MATSUMOTO 2 | 3 | MIT License (Expat) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/README.md: -------------------------------------------------------------------------------- 1 | # go-isatty 2 | 3 | [![Godoc Reference](https://godoc.org/github.com/mattn/go-isatty?status.svg)](http://godoc.org/github.com/mattn/go-isatty) 4 | [![Build Status](https://travis-ci.org/mattn/go-isatty.svg?branch=master)](https://travis-ci.org/mattn/go-isatty) 5 | [![Coverage Status](https://coveralls.io/repos/github/mattn/go-isatty/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-isatty?branch=master) 6 | [![Go Report Card](https://goreportcard.com/badge/mattn/go-isatty)](https://goreportcard.com/report/mattn/go-isatty) 7 | 8 | isatty for golang 9 | 10 | ## Usage 11 | 12 | ```go 13 | package main 14 | 15 | import ( 16 | "fmt" 17 | "github.com/mattn/go-isatty" 18 | "os" 19 | ) 20 | 21 | func main() { 22 | if isatty.IsTerminal(os.Stdout.Fd()) { 23 | fmt.Println("Is Terminal") 24 | } else if isatty.IsCygwinTerminal(os.Stdout.Fd()) { 25 | fmt.Println("Is Cygwin/MSYS2 Terminal") 26 | } else { 27 | fmt.Println("Is Not Terminal") 28 | } 29 | } 30 | ``` 31 | 32 | ## Installation 33 | 34 | ``` 35 | $ go get github.com/mattn/go-isatty 36 | ``` 37 | 38 | ## License 39 | 40 | MIT 41 | 42 | ## Author 43 | 44 | Yasuhiro Matsumoto (a.k.a mattn) 45 | 46 | ## Thanks 47 | 48 | * k-takata: base idea for IsCygwinTerminal 49 | 50 | https://github.com/k-takata/go-iscygpty 51 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/doc.go: -------------------------------------------------------------------------------- 1 | // Package isatty implements interface to isatty 2 | package isatty 3 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package isatty 4 | 5 | // IsTerminal returns true if the file descriptor is terminal which 6 | // is always false on on appengine classic which is a sandboxed PaaS. 7 | func IsTerminal(fd uintptr) bool { 8 | return false 9 | } 10 | 11 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 12 | // terminal. This is also always false on this environment. 13 | func IsCygwinTerminal(fd uintptr) bool { 14 | return false 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TCGETS 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 7 | // terminal. This is also always false on this environment. 8 | func IsCygwinTerminal(fd uintptr) bool { 9 | return false 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "golang.org/x/sys/unix" 8 | ) 9 | 10 | // IsTerminal returns true if the given file descriptor is a terminal. 11 | // see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c 12 | func IsTerminal(fd uintptr) bool { 13 | var termio unix.Termio 14 | err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio) 15 | return err == nil 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/peterh/liner/COPYING: -------------------------------------------------------------------------------- 1 | Copyright © 2012 Peter Harris 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a 4 | copy of this software and associated documentation files (the "Software"), 5 | to deal in the Software without restriction, including without limitation 6 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | and/or sell copies of the Software, and to permit persons to whom the 8 | Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice (including the next 11 | paragraph) shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | DEALINGS IN THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /vendor/github.com/peterh/liner/bsdinput.go: -------------------------------------------------------------------------------- 1 | // +build openbsd freebsd netbsd 2 | 3 | package liner 4 | 5 | import "syscall" 6 | 7 | const ( 8 | getTermios = syscall.TIOCGETA 9 | setTermios = syscall.TIOCSETA 10 | ) 11 | 12 | const ( 13 | // Input flags 14 | inpck = 0x010 15 | istrip = 0x020 16 | icrnl = 0x100 17 | ixon = 0x200 18 | 19 | // Output flags 20 | opost = 0x1 21 | 22 | // Control flags 23 | cs8 = 0x300 24 | 25 | // Local flags 26 | isig = 0x080 27 | icanon = 0x100 28 | iexten = 0x400 29 | ) 30 | 31 | type termios struct { 32 | Iflag uint32 33 | Oflag uint32 34 | Cflag uint32 35 | Lflag uint32 36 | Cc [20]byte 37 | Ispeed int32 38 | Ospeed int32 39 | } 40 | 41 | const cursorColumn = false 42 | -------------------------------------------------------------------------------- /vendor/github.com/peterh/liner/fallbackinput.go: -------------------------------------------------------------------------------- 1 | // +build !windows,!linux,!darwin,!openbsd,!freebsd,!netbsd 2 | 3 | package liner 4 | 5 | import ( 6 | "bufio" 7 | "errors" 8 | "os" 9 | ) 10 | 11 | // State represents an open terminal 12 | type State struct { 13 | commonState 14 | } 15 | 16 | // Prompt displays p, and then waits for user input. Prompt does not support 17 | // line editing on this operating system. 18 | func (s *State) Prompt(p string) (string, error) { 19 | return s.promptUnsupported(p) 20 | } 21 | 22 | // PasswordPrompt is not supported in this OS. 23 | func (s *State) PasswordPrompt(p string) (string, error) { 24 | return "", errors.New("liner: function not supported in this terminal") 25 | } 26 | 27 | // NewLiner initializes a new *State 28 | // 29 | // Note that this operating system uses a fallback mode without line 30 | // editing. Patches welcome. 31 | func NewLiner() *State { 32 | var s State 33 | s.r = bufio.NewReader(os.Stdin) 34 | return &s 35 | } 36 | 37 | // Close returns the terminal to its previous mode 38 | func (s *State) Close() error { 39 | return nil 40 | } 41 | 42 | // TerminalSupported returns false because line editing is not 43 | // supported on this platform. 44 | func TerminalSupported() bool { 45 | return false 46 | } 47 | 48 | type noopMode struct{} 49 | 50 | func (n noopMode) ApplyMode() error { 51 | return nil 52 | } 53 | 54 | // TerminalMode returns a noop InputModeSetter on this platform. 55 | func TerminalMode() (ModeApplier, error) { 56 | return noopMode{}, nil 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/peterh/liner/input_darwin.go: -------------------------------------------------------------------------------- 1 | // +build darwin 2 | 3 | package liner 4 | 5 | import "syscall" 6 | 7 | const ( 8 | getTermios = syscall.TIOCGETA 9 | setTermios = syscall.TIOCSETA 10 | ) 11 | 12 | const ( 13 | // Input flags 14 | inpck = 0x010 15 | istrip = 0x020 16 | icrnl = 0x100 17 | ixon = 0x200 18 | 19 | // Output flags 20 | opost = 0x1 21 | 22 | // Control flags 23 | cs8 = 0x300 24 | 25 | // Local flags 26 | isig = 0x080 27 | icanon = 0x100 28 | iexten = 0x400 29 | ) 30 | 31 | type termios struct { 32 | Iflag uintptr 33 | Oflag uintptr 34 | Cflag uintptr 35 | Lflag uintptr 36 | Cc [20]byte 37 | Ispeed uintptr 38 | Ospeed uintptr 39 | } 40 | 41 | // Terminal.app needs a column for the cursor when the input line is at the 42 | // bottom of the window. 43 | const cursorColumn = true 44 | -------------------------------------------------------------------------------- /vendor/github.com/peterh/liner/input_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | 3 | package liner 4 | 5 | import "syscall" 6 | 7 | const ( 8 | getTermios = syscall.TCGETS 9 | setTermios = syscall.TCSETS 10 | ) 11 | 12 | const ( 13 | icrnl = syscall.ICRNL 14 | inpck = syscall.INPCK 15 | istrip = syscall.ISTRIP 16 | ixon = syscall.IXON 17 | opost = syscall.OPOST 18 | cs8 = syscall.CS8 19 | isig = syscall.ISIG 20 | icanon = syscall.ICANON 21 | iexten = syscall.IEXTEN 22 | ) 23 | 24 | type termios struct { 25 | syscall.Termios 26 | } 27 | 28 | const cursorColumn = false 29 | -------------------------------------------------------------------------------- /vendor/github.com/peterh/liner/unixmode.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd openbsd netbsd 2 | 3 | package liner 4 | 5 | import ( 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | func (mode *termios) ApplyMode() error { 11 | _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(syscall.Stdin), setTermios, uintptr(unsafe.Pointer(mode))) 12 | 13 | if errno != 0 { 14 | return errno 15 | } 16 | return nil 17 | } 18 | 19 | // TerminalMode returns the current terminal input mode as an InputModeSetter. 20 | // 21 | // This function is provided for convenience, and should 22 | // not be necessary for most users of liner. 23 | func TerminalMode() (ModeApplier, error) { 24 | mode, errno := getMode(syscall.Stdin) 25 | 26 | if errno != 0 { 27 | return nil, errno 28 | } 29 | return mode, nil 30 | } 31 | 32 | func getMode(handle int) (*termios, syscall.Errno) { 33 | var mode termios 34 | _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(handle), getTermios, uintptr(unsafe.Pointer(&mode))) 35 | 36 | return &mode, errno 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/valyala/bytebufferpool/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Aliaksandr Valialkin, VertaMedia 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 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/valyala/bytebufferpool/README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/valyala/bytebufferpool.svg)](https://travis-ci.org/valyala/bytebufferpool) 2 | [![GoDoc](https://godoc.org/github.com/valyala/bytebufferpool?status.svg)](http://godoc.org/github.com/valyala/bytebufferpool) 3 | [![Go Report](http://goreportcard.com/badge/valyala/bytebufferpool)](http://goreportcard.com/report/valyala/bytebufferpool) 4 | 5 | # bytebufferpool 6 | 7 | An implementation of a pool of byte buffers with anti-memory-waste protection. 8 | 9 | The pool may waste limited amount of memory due to fragmentation. 10 | This amount equals to the maximum total size of the byte buffers 11 | in concurrent use. 12 | 13 | # Benchmark results 14 | Currently bytebufferpool is fastest and most effective buffer pool written in Go. 15 | 16 | You can find results [here](https://omgnull.github.io/go-benchmark/buffer/). 17 | 18 | # bytebufferpool users 19 | 20 | * [fasthttp](https://github.com/valyala/fasthttp) 21 | * [quicktemplate](https://github.com/valyala/quicktemplate) 22 | -------------------------------------------------------------------------------- /vendor/github.com/valyala/bytebufferpool/doc.go: -------------------------------------------------------------------------------- 1 | // Package bytebufferpool implements a pool of byte buffers 2 | // with anti-fragmentation protection. 3 | // 4 | // The pool may waste limited amount of memory due to fragmentation. 5 | // This amount equals to the maximum total size of the byte buffers 6 | // in concurrent use. 7 | package bytebufferpool 8 | -------------------------------------------------------------------------------- /vendor/github.com/valyala/fasttemplate/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Aliaksandr Valialkin 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 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/valyala/fasttemplate/unsafe.go: -------------------------------------------------------------------------------- 1 | // +build !appengine 2 | 3 | package fasttemplate 4 | 5 | import ( 6 | "reflect" 7 | "unsafe" 8 | ) 9 | 10 | func unsafeBytes2String(b []byte) string { 11 | return *(*string)(unsafe.Pointer(&b)) 12 | } 13 | 14 | func unsafeString2Bytes(s string) []byte { 15 | sh := (*reflect.StringHeader)(unsafe.Pointer(&s)) 16 | bh := reflect.SliceHeader{ 17 | Data: sh.Data, 18 | Len: sh.Len, 19 | Cap: sh.Len, 20 | } 21 | return *(*[]byte)(unsafe.Pointer(&bh)) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/valyala/fasttemplate/unsafe_gae.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package fasttemplate 4 | 5 | func unsafeBytes2String(b []byte) string { 6 | return string(b) 7 | } 8 | 9 | func unsafeString2Bytes(s string) []byte { 10 | return []byte(s) 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/youngtrips/anet/README.md: -------------------------------------------------------------------------------- 1 | async network library with golang 2 | 3 | -------------------------------------------------------------------------------- /vendor/github.com/youngtrips/anet/event.go: -------------------------------------------------------------------------------- 1 | package anet 2 | 3 | const ( 4 | EVENT_ACCEPT = 0x01 5 | EVENT_CONNECT_SUCCESS = 0x02 6 | EVENT_CONNECT_FAILED = 0x04 7 | EVENT_DISCONNECT = 0x08 8 | EVENT_MESSAGE = 0x10 9 | EVENT_RECV_ERROR = 0x20 10 | EVENT_SEND_ERROR = 0x40 11 | ) 12 | 13 | type Event struct { 14 | Type int8 15 | Session *Session 16 | Data interface{} 17 | } 18 | 19 | func newEvent(typ int8, session *Session, data interface{}) Event { 20 | return Event{ 21 | Type: typ, 22 | Session: session, 23 | Data: data, 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/youngtrips/anet/message.go: -------------------------------------------------------------------------------- 1 | package anet 2 | 3 | type Message struct { 4 | Api string 5 | Payload interface{} 6 | raw bool 7 | } 8 | 9 | func NewMessage(api string, payload interface{}) *Message { 10 | return &Message{ 11 | Api: api, 12 | Payload: payload, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/youngtrips/anet/protocol.go: -------------------------------------------------------------------------------- 1 | package anet 2 | 3 | type Protocol interface { 4 | Encode(api string, data interface{}) ([]byte, error) 5 | Decode(data []byte) (string, interface{}, error) 6 | } 7 | -------------------------------------------------------------------------------- /vendor/github.com/youngtrips/timerqueue/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Tuz 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 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/youngtrips/timerqueue/README.md: -------------------------------------------------------------------------------- 1 | timerqueue 2 | ========== 3 | 4 | Timerwheel is a timer implement with golang, inspired by linux kernel. 5 | 6 | Useage 7 | ------ 8 | 9 | go get github.com/youngtrips/timerqueue 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/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/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/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 | "net/http" 11 | "time" 12 | ) 13 | 14 | func transportExpectContinueTimeout(t1 *http.Transport) time.Duration { 15 | return t1.ExpectContinueTimeout 16 | } 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/go17_not18.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,!go1.8 6 | 7 | package http2 8 | 9 | import "crypto/tls" 10 | 11 | // temporary copy of Go 1.7's private tls.Config.clone: 12 | func cloneTLSConfig(c *tls.Config) *tls.Config { 13 | return &tls.Config{ 14 | Rand: c.Rand, 15 | Time: c.Time, 16 | Certificates: c.Certificates, 17 | NameToCertificate: c.NameToCertificate, 18 | GetCertificate: c.GetCertificate, 19 | RootCAs: c.RootCAs, 20 | NextProtos: c.NextProtos, 21 | ServerName: c.ServerName, 22 | ClientAuth: c.ClientAuth, 23 | ClientCAs: c.ClientCAs, 24 | InsecureSkipVerify: c.InsecureSkipVerify, 25 | CipherSuites: c.CipherSuites, 26 | PreferServerCipherSuites: c.PreferServerCipherSuites, 27 | SessionTicketsDisabled: c.SessionTicketsDisabled, 28 | SessionTicketKey: c.SessionTicketKey, 29 | ClientSessionCache: c.ClientSessionCache, 30 | MinVersion: c.MinVersion, 31 | MaxVersion: c.MaxVersion, 32 | CurvePreferences: c.CurvePreferences, 33 | DynamicRecordSizingDisabled: c.DynamicRecordSizingDisabled, 34 | Renegotiation: c.Renegotiation, 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/go18.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.8 6 | 7 | package http2 8 | 9 | import ( 10 | "crypto/tls" 11 | "io" 12 | "net/http" 13 | ) 14 | 15 | func cloneTLSConfig(c *tls.Config) *tls.Config { 16 | c2 := c.Clone() 17 | c2.GetClientCertificate = c.GetClientCertificate // golang.org/issue/19264 18 | return c2 19 | } 20 | 21 | var _ http.Pusher = (*responseWriter)(nil) 22 | 23 | // Push implements http.Pusher. 24 | func (w *responseWriter) Push(target string, opts *http.PushOptions) error { 25 | internalOpts := pushOptions{} 26 | if opts != nil { 27 | internalOpts.Method = opts.Method 28 | internalOpts.Header = opts.Header 29 | } 30 | return w.push(target, internalOpts) 31 | } 32 | 33 | func configureServer18(h1 *http.Server, h2 *Server) error { 34 | if h2.IdleTimeout == 0 { 35 | if h1.IdleTimeout != 0 { 36 | h2.IdleTimeout = h1.IdleTimeout 37 | } else { 38 | h2.IdleTimeout = h1.ReadTimeout 39 | } 40 | } 41 | return nil 42 | } 43 | 44 | func shouldLogPanic(panicValue interface{}) bool { 45 | return panicValue != nil && panicValue != http.ErrAbortHandler 46 | } 47 | 48 | func reqGetBody(req *http.Request) func() (io.ReadCloser, error) { 49 | return req.GetBody 50 | } 51 | 52 | func reqBodyIsNoBody(body io.ReadCloser) bool { 53 | return body == http.NoBody 54 | } 55 | 56 | func go18httpNoBody() io.ReadCloser { return http.NoBody } // for tests only 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/go19.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.9 6 | 7 | package http2 8 | 9 | import ( 10 | "net/http" 11 | ) 12 | 13 | func configureServer19(s *http.Server, conf *Server) error { 14 | s.RegisterOnShutdown(conf.state.startGracefulShutdown) 15 | return nil 16 | } 17 | -------------------------------------------------------------------------------- /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 | "net/http" 11 | "time" 12 | ) 13 | 14 | func configureTransport(t1 *http.Transport) (*Transport, error) { 15 | return nil, errTransportVersion 16 | } 17 | 18 | func transportExpectContinueTimeout(t1 *http.Transport) time.Duration { 19 | return 0 20 | 21 | } 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/not_go18.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.8 6 | 7 | package http2 8 | 9 | import ( 10 | "io" 11 | "net/http" 12 | ) 13 | 14 | func configureServer18(h1 *http.Server, h2 *Server) error { 15 | // No IdleTimeout to sync prior to Go 1.8. 16 | return nil 17 | } 18 | 19 | func shouldLogPanic(panicValue interface{}) bool { 20 | return panicValue != nil 21 | } 22 | 23 | func reqGetBody(req *http.Request) func() (io.ReadCloser, error) { 24 | return nil 25 | } 26 | 27 | func reqBodyIsNoBody(io.ReadCloser) bool { return false } 28 | 29 | func go18httpNoBody() io.ReadCloser { return nil } // for tests only 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/not_go19.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.9 6 | 7 | package http2 8 | 9 | import ( 10 | "net/http" 11 | ) 12 | 13 | func configureServer19(s *http.Server, conf *Server) error { 14 | // not supported prior to go1.9 15 | return nil 16 | } 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/trace/trace_go16.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 trace 8 | 9 | import "golang.org/x/net/context" 10 | 11 | // NewContext returns a copy of the parent context 12 | // and associates it with a Trace. 13 | func NewContext(ctx context.Context, tr Trace) context.Context { 14 | return context.WithValue(ctx, contextKey, tr) 15 | } 16 | 17 | // FromContext returns the Trace bound to the context, if any. 18 | func FromContext(ctx context.Context) (tr Trace, ok bool) { 19 | tr, ok = ctx.Value(contextKey).(Trace) 20 | return 21 | } 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/trace/trace_go17.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 trace 8 | 9 | import "context" 10 | 11 | // NewContext returns a copy of the parent context 12 | // and associates it with a Trace. 13 | func NewContext(ctx context.Context, tr Trace) context.Context { 14 | return context.WithValue(ctx, contextKey, tr) 15 | } 16 | 17 | // FromContext returns the Trace bound to the context, if any. 18 | func FromContext(ctx context.Context) (tr Trace, ok bool) { 19 | tr, ok = ctx.Value(contextKey).(Trace) 20 | return 21 | } 22 | -------------------------------------------------------------------------------- /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_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_mipsx.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 linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, 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-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 28 | JMP syscall·RawSyscall(SB) 29 | 30 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 31 | JMP syscall·RawSyscall6(SB) 32 | -------------------------------------------------------------------------------- /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-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 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/endian_big.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 ppc64 s390x mips mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.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 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /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 linux,mips linux,mipsle 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_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/gccgo_linux_sparc64.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 gccgo,linux,sparc64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern sysconf 12 | func realSysconf(name int) int64 13 | 14 | func sysconf(name int) (n int64, err syscall.Errno) { 15 | r := realSysconf(name) 16 | if r < 0 { 17 | return 0, syscall.GetErrno() 18 | } 19 | return r, 0 20 | } 21 | -------------------------------------------------------------------------------- /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 <){ 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 <= 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_linux_amd64_gc.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 amd64,linux 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /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/syscall_unix_gc.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 darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /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/text/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/unicode/norm/trie.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm 6 | 7 | type valueRange struct { 8 | value uint16 // header: value:stride 9 | lo, hi byte // header: lo:n 10 | } 11 | 12 | type sparseBlocks struct { 13 | values []valueRange 14 | offset []uint16 15 | } 16 | 17 | var nfcSparse = sparseBlocks{ 18 | values: nfcSparseValues[:], 19 | offset: nfcSparseOffset[:], 20 | } 21 | 22 | var nfkcSparse = sparseBlocks{ 23 | values: nfkcSparseValues[:], 24 | offset: nfkcSparseOffset[:], 25 | } 26 | 27 | var ( 28 | nfcData = newNfcTrie(0) 29 | nfkcData = newNfkcTrie(0) 30 | ) 31 | 32 | // lookupValue determines the type of block n and looks up the value for b. 33 | // For n < t.cutoff, the block is a simple lookup table. Otherwise, the block 34 | // is a list of ranges with an accompanying value. Given a matching range r, 35 | // the value for b is by r.value + (b - r.lo) * stride. 36 | func (t *sparseBlocks) lookup(n uint32, b byte) uint16 { 37 | offset := t.offset[n] 38 | header := t.values[offset] 39 | lo := offset + 1 40 | hi := lo + uint16(header.lo) 41 | for lo < hi { 42 | m := lo + (hi-lo)/2 43 | r := t.values[m] 44 | if r.lo <= b && b <= r.hi { 45 | return r.value + uint16(b-r.lo)*header.value 46 | } 47 | if b < r.lo { 48 | hi = m 49 | } else { 50 | lo = m + 1 51 | } 52 | } 53 | return 0 54 | } 55 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/AUTHORS: -------------------------------------------------------------------------------- 1 | Google Inc. 2 | -------------------------------------------------------------------------------- /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 | benchdeps: testdeps 13 | go get -d -v golang.org/x/perf/cmd/benchstat 14 | 15 | updatetestdeps: 16 | go get -d -v -t -u -f google.golang.org/grpc/... 17 | 18 | build: deps 19 | go build google.golang.org/grpc/... 20 | 21 | proto: 22 | @ if ! which protoc > /dev/null; then \ 23 | echo "error: protoc not installed" >&2; \ 24 | exit 1; \ 25 | fi 26 | go get -u -v github.com/golang/protobuf/protoc-gen-go 27 | # use $$dir as the root for all proto files in the same directory 28 | for dir in $$(git ls-files '*.proto' | xargs -n1 dirname | uniq); do \ 29 | protoc -I $$dir --go_out=plugins=grpc:$$dir $$dir/*.proto; \ 30 | done 31 | 32 | test: testdeps 33 | go test -v -cpu 1,4 google.golang.org/grpc/... 34 | 35 | testrace: testdeps 36 | go test -v -race -cpu 1,4 google.golang.org/grpc/... 37 | 38 | benchmark: benchdeps 39 | go test google.golang.org/grpc/benchmark/... -benchmem -bench=. | tee /tmp/tmp.result && benchstat /tmp/tmp.result && rm /tmp/tmp.result 40 | 41 | clean: 42 | go clean -i google.golang.org/grpc/... 43 | 44 | coverage: testdeps 45 | ./coverage.sh --coveralls 46 | 47 | .PHONY: \ 48 | all \ 49 | deps \ 50 | updatedeps \ 51 | testdeps \ 52 | updatetestdeps \ 53 | build \ 54 | proto \ 55 | test \ 56 | testrace \ 57 | clean \ 58 | coverage \ 59 | benchdeps \ 60 | benchmark 61 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/codegen.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env 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 | #!/usr/bin/env bash 2 | 3 | 4 | set -e 5 | 6 | workdir=.cover 7 | profile="$workdir/cover.out" 8 | mode=set 9 | end2endtest="google.golang.org/grpc/test" 10 | 11 | generate_cover_data() { 12 | rm -rf "$workdir" 13 | mkdir "$workdir" 14 | 15 | for pkg in "$@"; do 16 | 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" ] 17 | then 18 | f="$workdir/$(echo $pkg | tr / -)" 19 | go test -covermode="$mode" -coverprofile="$f.cover" "$pkg" 20 | go test -covermode="$mode" -coverpkg "$pkg" -coverprofile="$f.e2e.cover" "$end2endtest" 21 | fi 22 | done 23 | 24 | echo "mode: $mode" >"$profile" 25 | grep -h -v "^mode:" "$workdir"/*.cover >>"$profile" 26 | } 27 | 28 | show_cover_report() { 29 | go tool cover -${1}="$profile" 30 | } 31 | 32 | push_to_coveralls() { 33 | goveralls -coverprofile="$profile" 34 | } 35 | 36 | generate_cover_data $(go list ./...) 37 | show_cover_report func 38 | case "$1" in 39 | "") 40 | ;; 41 | --html) 42 | show_cover_report html ;; 43 | --coveralls) 44 | push_to_coveralls ;; 45 | *) 46 | echo >&2 "error: invalid option: $1" ;; 47 | esac 48 | rm -rf "$workdir" 49 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/credentials/credentials_util_go18.go: -------------------------------------------------------------------------------- 1 | // +build go1.8 2 | 3 | /* 4 | * 5 | * Copyright 2017 gRPC authors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | package credentials 22 | 23 | import ( 24 | "crypto/tls" 25 | ) 26 | 27 | // cloneTLSConfig returns a shallow clone of the exported 28 | // fields of cfg, ignoring the unexported sync.Once, which 29 | // contains a mutex and must not be copied. 30 | // 31 | // If cfg is nil, a new zero tls.Config is returned. 32 | func cloneTLSConfig(cfg *tls.Config) *tls.Config { 33 | if cfg == nil { 34 | return &tls.Config{} 35 | } 36 | 37 | return cfg.Clone() 38 | } 39 | -------------------------------------------------------------------------------- /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/internal/internal.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 gRPC authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | // Package internal contains gRPC-internal code for testing, to avoid polluting 19 | // the godoc of the top-level grpc package. 20 | package internal 21 | 22 | // TestingCloseConns closes all existing transports but keeps 23 | // grpcServer.lis accepting new connections. 24 | // 25 | // The provided grpcServer must be of type *grpc.Server. It is untyped 26 | // for circular dependency reasons. 27 | var TestingCloseConns func(grpcServer interface{}) 28 | 29 | // TestingUseHandlerImpl enables the http.Handler-based server implementation. 30 | // It must be called before Serve and requires TLS credentials. 31 | // 32 | // The provided grpcServer must be of type *grpc.Server. It is untyped 33 | // for circular dependency reasons. 34 | var TestingUseHandlerImpl func(grpcServer interface{}) 35 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/transport/go16.go: -------------------------------------------------------------------------------- 1 | // +build go1.6,!go1.7 2 | 3 | /* 4 | * 5 | * Copyright 2016 gRPC authors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | package transport 22 | 23 | import ( 24 | "net" 25 | 26 | "google.golang.org/grpc/codes" 27 | 28 | "golang.org/x/net/context" 29 | ) 30 | 31 | // dialContext connects to the address on the named network. 32 | func dialContext(ctx context.Context, network, address string) (net.Conn, error) { 33 | return (&net.Dialer{Cancel: ctx.Done()}).Dial(network, address) 34 | } 35 | 36 | // ContextErr converts the error from context package into a StreamError. 37 | func ContextErr(err error) StreamError { 38 | switch err { 39 | case context.DeadlineExceeded: 40 | return streamErrorf(codes.DeadlineExceeded, "%v", err) 41 | case context.Canceled: 42 | return streamErrorf(codes.Canceled, "%v", err) 43 | } 44 | return streamErrorf(codes.Internal, "Unexpected error from context packet: %v", err) 45 | } 46 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/transport/go17.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | /* 4 | * 5 | * Copyright 2016 gRPC authors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | package transport 22 | 23 | import ( 24 | "context" 25 | "net" 26 | 27 | "google.golang.org/grpc/codes" 28 | 29 | netctx "golang.org/x/net/context" 30 | ) 31 | 32 | // dialContext connects to the address on the named network. 33 | func dialContext(ctx context.Context, network, address string) (net.Conn, error) { 34 | return (&net.Dialer{}).DialContext(ctx, network, address) 35 | } 36 | 37 | // ContextErr converts the error from context package into a StreamError. 38 | func ContextErr(err error) StreamError { 39 | switch err { 40 | case context.DeadlineExceeded, netctx.DeadlineExceeded: 41 | return streamErrorf(codes.DeadlineExceeded, "%v", err) 42 | case context.Canceled, netctx.Canceled: 43 | return streamErrorf(codes.Canceled, "%v", err) 44 | } 45 | return streamErrorf(codes.Internal, "Unexpected error from context packet: %v", err) 46 | } 47 | --------------------------------------------------------------------------------