├── .gitignore ├── .travis.yml ├── Dockerfile ├── README.md ├── account ├── accountserver.go ├── authenticationrequest.go ├── charserver.go ├── charserverdefintion.go ├── charserverinstance.go ├── charserverstore.go ├── config.go ├── gamehandler.go ├── inmemorycharserverstore.go ├── inmemorycharserverstore_test.go ├── interhandler.go ├── main.go ├── pingrequest.go ├── quitnotification.go └── server.go ├── char ├── accountclient.go ├── accountinterconfig.go ├── config.go ├── gamehandler.go ├── main.go └── server.go ├── config ├── account.yml ├── char.yml ├── database.yml └── inter.yml ├── data ├── packetdb.txt └── packets.yml ├── database ├── authcookie.go ├── config.go └── database.go ├── docker-compose.yml ├── glide.lock ├── glide.yaml ├── inter ├── client.go ├── config.go ├── goodbytenotification.go ├── hellorequest.go ├── helloresponse.go ├── interclient.go ├── main.go ├── pingrequest.go ├── server.go ├── servertype.go └── servertype_string.go ├── main.go ├── net ├── gameclient.go ├── handler.go ├── handlerfunc.go ├── packethandler.go ├── rpcclient.go ├── rpchandler.go └── server.go ├── packets ├── accountacceptlogin.go ├── accountlogin.go ├── characceptenter.go ├── characceptmakechar.go ├── characterinfo.go ├── charblockcharacter.go ├── chardeletechar3cancel.go ├── chardeletechar3cancelack.go ├── chardeletechar3reserved.go ├── chardeletechar3reservedack.go ├── charenter.go ├── charmakechar.go ├── charnotifyzoneserver.go ├── charrefuseenter.go ├── charrefusemakechar.go ├── charselectchar.go ├── charslotsinfo.go ├── definition.go ├── incomingpacket.go ├── incomingtypemap.go ├── nullpacket.go ├── outgoingpacket.go ├── outgoingtypemap.go ├── packetdatabase.go ├── packetversion.go ├── ping.go ├── position.go ├── position2.go ├── rawpacket.go ├── secondpasswordlogin.go ├── zoneacceptenter.go ├── zoneacknamerequest.go ├── zoneaid.go ├── zoneenter.go ├── zonenamerequest.go ├── zonenotifyactorinit.go ├── zonenotifyban.go ├── zonenotifynewentry.go ├── zonenotifyplayermove.go ├── zonenotifytime.go ├── zonerefuseenter.go ├── zonerequestmove.go ├── zonerequesttime.go └── zonerestartack.go ├── rpc ├── LICENSE ├── README.md ├── client.go ├── codec.go └── utils.go ├── script ├── convert-packetdb.js └── mkpacket ├── utils ├── config.go ├── migrations │ └── migrations.go ├── ticker.go ├── timer.go └── timerbag.go ├── vendor ├── github.com │ ├── Sirupsen │ │ └── logrus │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── CHANGELOG.md │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── alt_exit.go │ │ │ ├── alt_exit_test.go │ │ │ ├── doc.go │ │ │ ├── entry.go │ │ │ ├── entry_test.go │ │ │ ├── examples │ │ │ ├── basic │ │ │ │ └── basic.go │ │ │ └── hook │ │ │ │ └── hook.go │ │ │ ├── exported.go │ │ │ ├── formatter.go │ │ │ ├── formatter_bench_test.go │ │ │ ├── hook_test.go │ │ │ ├── hooks.go │ │ │ ├── hooks │ │ │ ├── syslog │ │ │ │ ├── README.md │ │ │ │ ├── syslog.go │ │ │ │ └── syslog_test.go │ │ │ └── test │ │ │ │ ├── test.go │ │ │ │ └── test_test.go │ │ │ ├── json_formatter.go │ │ │ ├── json_formatter_test.go │ │ │ ├── logger.go │ │ │ ├── logger_bench_test.go │ │ │ ├── logrus.go │ │ │ ├── logrus_test.go │ │ │ ├── terminal_appengine.go │ │ │ ├── terminal_bsd.go │ │ │ ├── terminal_linux.go │ │ │ ├── terminal_notwindows.go │ │ │ ├── terminal_solaris.go │ │ │ ├── terminal_windows.go │ │ │ ├── text_formatter.go │ │ │ ├── text_formatter_test.go │ │ │ └── writer.go │ ├── davecgh │ │ └── go-spew │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── cov_report.sh │ │ │ ├── spew │ │ │ ├── bypass.go │ │ │ ├── bypasssafe.go │ │ │ ├── common.go │ │ │ ├── common_test.go │ │ │ ├── config.go │ │ │ ├── doc.go │ │ │ ├── dump.go │ │ │ ├── dump_test.go │ │ │ ├── dumpcgo_test.go │ │ │ ├── dumpnocgo_test.go │ │ │ ├── example_test.go │ │ │ ├── format.go │ │ │ ├── format_test.go │ │ │ ├── internal_test.go │ │ │ ├── internalunsafe_test.go │ │ │ ├── spew.go │ │ │ ├── spew_test.go │ │ │ └── testdata │ │ │ │ └── dumpcgo.go │ │ │ └── test_coverage.txt │ ├── docopt │ │ └── docopt-go │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── docopt.go │ │ │ ├── docopt_test.go │ │ │ ├── example_test.go │ │ │ ├── examples │ │ │ ├── arguments │ │ │ │ └── arguments_example.go │ │ │ ├── calculator │ │ │ │ └── calculator_example.go │ │ │ ├── config_file │ │ │ │ └── config_file_example.go │ │ │ ├── counted │ │ │ │ └── counted_example.go │ │ │ ├── git │ │ │ │ ├── branch │ │ │ │ │ └── git_branch.go │ │ │ │ ├── checkout │ │ │ │ │ └── git_checkout.go │ │ │ │ ├── clone │ │ │ │ │ └── git_clone.go │ │ │ │ ├── git.go │ │ │ │ ├── push │ │ │ │ │ └── git_push.go │ │ │ │ └── remote │ │ │ │ │ └── git_remote.go │ │ │ ├── naval_fate │ │ │ │ └── naval_fate.go │ │ │ ├── odd_even │ │ │ │ └── odd_even_example.go │ │ │ ├── options │ │ │ │ └── options_example.go │ │ │ ├── options_shortcut │ │ │ │ └── options_shortcut_example.go │ │ │ ├── quick │ │ │ │ └── quick_example.go │ │ │ └── type_assert │ │ │ │ └── type_assert_example.go │ │ │ ├── test_golang.docopt │ │ │ └── testcases.docopt │ ├── fatih │ │ └── color │ │ │ ├── .travis.yml │ │ │ ├── LICENSE.md │ │ │ ├── README.md │ │ │ ├── color.go │ │ │ ├── color_test.go │ │ │ └── doc.go │ ├── go-yaml │ │ └── yaml │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── LICENSE.libyaml │ │ │ ├── README.md │ │ │ ├── apic.go │ │ │ ├── decode.go │ │ │ ├── decode_test.go │ │ │ ├── emitterc.go │ │ │ ├── encode.go │ │ │ ├── encode_test.go │ │ │ ├── parserc.go │ │ │ ├── readerc.go │ │ │ ├── resolve.go │ │ │ ├── scannerc.go │ │ │ ├── sorter.go │ │ │ ├── suite_test.go │ │ │ ├── writerc.go │ │ │ ├── yaml.go │ │ │ ├── yamlh.go │ │ │ └── yamlprivateh.go │ ├── jinzhu │ │ ├── gorm │ │ │ ├── .codeclimate.yml │ │ │ ├── .gitignore │ │ │ ├── CONTRIBUTING.md │ │ │ ├── License │ │ │ ├── README.md │ │ │ ├── association.go │ │ │ ├── association_test.go │ │ │ ├── callback.go │ │ │ ├── callback_create.go │ │ │ ├── callback_delete.go │ │ │ ├── callback_query.go │ │ │ ├── callback_query_preload.go │ │ │ ├── callback_save.go │ │ │ ├── callback_system_test.go │ │ │ ├── callback_update.go │ │ │ ├── callbacks_test.go │ │ │ ├── create_test.go │ │ │ ├── customize_column_test.go │ │ │ ├── delete_test.go │ │ │ ├── dialect.go │ │ │ ├── dialect_common.go │ │ │ ├── dialect_mysql.go │ │ │ ├── dialect_postgres.go │ │ │ ├── dialect_sqlite3.go │ │ │ ├── dialects │ │ │ │ ├── mssql │ │ │ │ │ └── mssql.go │ │ │ │ ├── mysql │ │ │ │ │ └── mysql.go │ │ │ │ ├── postgres │ │ │ │ │ └── postgres.go │ │ │ │ └── sqlite │ │ │ │ │ └── sqlite.go │ │ │ ├── embedded_struct_test.go │ │ │ ├── errors.go │ │ │ ├── errors_test.go │ │ │ ├── field.go │ │ │ ├── field_test.go │ │ │ ├── interface.go │ │ │ ├── join_table_handler.go │ │ │ ├── join_table_test.go │ │ │ ├── logger.go │ │ │ ├── main.go │ │ │ ├── main_test.go │ │ │ ├── migration_test.go │ │ │ ├── model.go │ │ │ ├── model_struct.go │ │ │ ├── multi_primary_keys_test.go │ │ │ ├── pointer_test.go │ │ │ ├── polymorphic_test.go │ │ │ ├── preload_test.go │ │ │ ├── query_test.go │ │ │ ├── scaner_test.go │ │ │ ├── scope.go │ │ │ ├── scope_test.go │ │ │ ├── search.go │ │ │ ├── search_test.go │ │ │ ├── test_all.sh │ │ │ ├── update_test.go │ │ │ ├── utils.go │ │ │ ├── utils_test.go │ │ │ └── wercker.yml │ │ └── inflection │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── inflections.go │ │ │ └── inflections_test.go │ ├── lib │ │ └── pq │ │ │ ├── .gitignore │ │ │ ├── .travis.sh │ │ │ ├── .travis.yml │ │ │ ├── CONTRIBUTING.md │ │ │ ├── LICENSE.md │ │ │ ├── README.md │ │ │ ├── array.go │ │ │ ├── array_test.go │ │ │ ├── bench_test.go │ │ │ ├── buf.go │ │ │ ├── certs │ │ │ ├── README │ │ │ ├── bogus_root.crt │ │ │ ├── postgresql.crt │ │ │ ├── postgresql.key │ │ │ ├── root.crt │ │ │ ├── server.crt │ │ │ └── server.key │ │ │ ├── conn.go │ │ │ ├── conn_test.go │ │ │ ├── copy.go │ │ │ ├── copy_test.go │ │ │ ├── doc.go │ │ │ ├── encode.go │ │ │ ├── encode_test.go │ │ │ ├── error.go │ │ │ ├── go18_test.go │ │ │ ├── hstore │ │ │ ├── hstore.go │ │ │ └── hstore_test.go │ │ │ ├── issues_test.go │ │ │ ├── listen_example │ │ │ └── doc.go │ │ │ ├── notify.go │ │ │ ├── notify_test.go │ │ │ ├── oid │ │ │ ├── doc.go │ │ │ ├── gen.go │ │ │ └── types.go │ │ │ ├── ssl_test.go │ │ │ ├── url.go │ │ │ ├── url_test.go │ │ │ ├── user_posix.go │ │ │ └── user_windows.go │ ├── mattes │ │ └── migrate │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── Dockerfile │ │ │ ├── LICENSE │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── docker-compose.yml │ │ │ ├── driver │ │ │ ├── bash │ │ │ │ ├── README.md │ │ │ │ ├── bash.go │ │ │ │ └── bash_test.go │ │ │ ├── cassandra │ │ │ │ ├── README.md │ │ │ │ ├── cassandra.go │ │ │ │ └── cassandra_test.go │ │ │ ├── driver.go │ │ │ ├── mysql │ │ │ │ ├── README.md │ │ │ │ ├── mysql.go │ │ │ │ └── mysql_test.go │ │ │ ├── postgres │ │ │ │ ├── README.md │ │ │ │ ├── postgres.go │ │ │ │ └── postgres_test.go │ │ │ ├── registry.go │ │ │ └── sqlite3 │ │ │ │ ├── README.md │ │ │ │ ├── sqlite3.go │ │ │ │ └── sqlite3_test.go │ │ │ ├── file │ │ │ ├── file.go │ │ │ └── file_test.go │ │ │ ├── main.go │ │ │ ├── migrate │ │ │ ├── direction │ │ │ │ └── direction.go │ │ │ ├── migrate.go │ │ │ └── migrate_test.go │ │ │ ├── pipe │ │ │ └── pipe.go │ │ │ └── version.go │ ├── mattn │ │ ├── go-colorable │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── _example │ │ │ │ └── main.go │ │ │ ├── _example2 │ │ │ │ └── main.go │ │ │ ├── colorable_others.go │ │ │ ├── colorable_test.go │ │ │ ├── colorable_windows.go │ │ │ └── noncolorable.go │ │ └── go-isatty │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── _example │ │ │ └── example.go │ │ │ ├── doc.go │ │ │ ├── isatty_appengine.go │ │ │ ├── isatty_bsd.go │ │ │ ├── isatty_linux.go │ │ │ ├── isatty_solaris.go │ │ │ └── isatty_windows.go │ ├── o1egl │ │ └── gormrus │ │ │ ├── .gitignore │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ └── logger.go │ ├── pmezard │ │ └── go-difflib │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ └── difflib │ │ │ ├── difflib.go │ │ │ └── difflib_test.go │ └── stretchr │ │ └── testify │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── Godeps │ │ ├── Godeps.json │ │ └── Readme │ │ ├── LICENCE.txt │ │ ├── LICENSE │ │ ├── README.md │ │ ├── _codegen │ │ └── main.go │ │ ├── assert │ │ ├── assertion_forward.go │ │ ├── assertion_forward.go.tmpl │ │ ├── assertions.go │ │ ├── assertions_test.go │ │ ├── doc.go │ │ ├── errors.go │ │ ├── forward_assertions.go │ │ ├── forward_assertions_test.go │ │ ├── http_assertions.go │ │ └── http_assertions_test.go │ │ ├── doc.go │ │ ├── http │ │ ├── doc.go │ │ ├── test_response_writer.go │ │ └── test_round_tripper.go │ │ ├── mock │ │ ├── doc.go │ │ ├── mock.go │ │ └── mock_test.go │ │ ├── package_test.go │ │ ├── require │ │ ├── doc.go │ │ ├── forward_requirements.go │ │ ├── forward_requirements_test.go │ │ ├── require.go │ │ ├── require.go.tmpl │ │ ├── require_forward.go │ │ ├── require_forward.go.tmpl │ │ ├── requirements.go │ │ └── requirements_test.go │ │ ├── suite │ │ ├── doc.go │ │ ├── interfaces.go │ │ ├── suite.go │ │ └── suite_test.go │ │ └── vendor │ │ └── github.com │ │ ├── davecgh │ │ └── go-spew │ │ │ ├── LICENSE │ │ │ └── spew │ │ │ ├── bypass.go │ │ │ ├── bypasssafe.go │ │ │ ├── common.go │ │ │ ├── config.go │ │ │ ├── doc.go │ │ │ ├── dump.go │ │ │ ├── format.go │ │ │ └── spew.go │ │ ├── pmezard │ │ └── go-difflib │ │ │ ├── LICENSE │ │ │ └── difflib │ │ │ └── difflib.go │ │ └── stretchr │ │ └── objx │ │ ├── .gitignore │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── accessors.go │ │ ├── codegen │ │ ├── array-access.txt │ │ ├── index.html │ │ ├── template.txt │ │ └── types_list.txt │ │ ├── constants.go │ │ ├── conversions.go │ │ ├── doc.go │ │ ├── map.go │ │ ├── mutations.go │ │ ├── security.go │ │ ├── tests.go │ │ ├── type_specific_codegen.go │ │ └── value.go ├── golang.org │ └── x │ │ └── sys │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── AUTHORS │ │ ├── CONTRIBUTING.md │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ ├── PATENTS │ │ ├── README │ │ ├── codereview.cfg │ │ ├── plan9 │ │ ├── asm.s │ │ ├── asm_plan9_386.s │ │ ├── asm_plan9_amd64.s │ │ ├── const_plan9.go │ │ ├── dir_plan9.go │ │ ├── env_plan9.go │ │ ├── env_unset.go │ │ ├── errors_plan9.go │ │ ├── mkall.sh │ │ ├── mkerrors.sh │ │ ├── mksyscall.pl │ │ ├── mksysnum_plan9.sh │ │ ├── pwd_go15_plan9.go │ │ ├── pwd_plan9.go │ │ ├── race.go │ │ ├── race0.go │ │ ├── str.go │ │ ├── syscall.go │ │ ├── syscall_plan9.go │ │ ├── syscall_test.go │ │ ├── zsyscall_plan9_386.go │ │ ├── zsyscall_plan9_amd64.go │ │ └── zsysnum_plan9.go │ │ ├── unix │ │ ├── .gitignore │ │ ├── asm.s │ │ ├── asm_darwin_386.s │ │ ├── asm_darwin_amd64.s │ │ ├── asm_darwin_arm.s │ │ ├── asm_darwin_arm64.s │ │ ├── asm_dragonfly_amd64.s │ │ ├── asm_freebsd_386.s │ │ ├── asm_freebsd_amd64.s │ │ ├── asm_freebsd_arm.s │ │ ├── asm_linux_386.s │ │ ├── asm_linux_amd64.s │ │ ├── asm_linux_arm.s │ │ ├── asm_linux_arm64.s │ │ ├── asm_linux_mips64x.s │ │ ├── asm_linux_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 │ │ ├── creds_test.go │ │ ├── env_unix.go │ │ ├── env_unset.go │ │ ├── export_test.go │ │ ├── flock.go │ │ ├── flock_linux_32bit.go │ │ ├── gccgo.go │ │ ├── gccgo_c.c │ │ ├── gccgo_linux_amd64.go │ │ ├── gccgo_linux_sparc64.go │ │ ├── mkall.sh │ │ ├── mkerrors.sh │ │ ├── mkpost.go │ │ ├── mksyscall.pl │ │ ├── mksyscall_solaris.pl │ │ ├── mksysctl_openbsd.pl │ │ ├── mksysnum_darwin.pl │ │ ├── mksysnum_dragonfly.pl │ │ ├── mksysnum_freebsd.pl │ │ ├── mksysnum_linux.pl │ │ ├── mksysnum_netbsd.pl │ │ ├── mksysnum_openbsd.pl │ │ ├── mmap_unix_test.go │ │ ├── race.go │ │ ├── race0.go │ │ ├── sockcmsg_linux.go │ │ ├── sockcmsg_unix.go │ │ ├── str.go │ │ ├── syscall.go │ │ ├── syscall_bsd.go │ │ ├── syscall_bsd_test.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_freebsd_test.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_linux_test.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_test.go │ │ ├── syscall_unix.go │ │ ├── syscall_unix_gc.go │ │ ├── syscall_unix_test.go │ │ ├── types_darwin.go │ │ ├── types_dragonfly.go │ │ ├── types_freebsd.go │ │ ├── types_linux.go │ │ ├── types_netbsd.go │ │ ├── types_openbsd.go │ │ ├── types_solaris.go │ │ ├── zerrors_darwin_386.go │ │ ├── zerrors_darwin_amd64.go │ │ ├── zerrors_darwin_arm.go │ │ ├── zerrors_darwin_arm64.go │ │ ├── zerrors_dragonfly_amd64.go │ │ ├── zerrors_freebsd_386.go │ │ ├── zerrors_freebsd_amd64.go │ │ ├── zerrors_freebsd_arm.go │ │ ├── zerrors_linux_386.go │ │ ├── zerrors_linux_amd64.go │ │ ├── zerrors_linux_arm.go │ │ ├── zerrors_linux_arm64.go │ │ ├── zerrors_linux_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 │ │ └── windows │ │ ├── asm_windows_386.s │ │ ├── asm_windows_amd64.s │ │ ├── dll_windows.go │ │ ├── env_unset.go │ │ ├── env_windows.go │ │ ├── eventlog.go │ │ ├── exec_windows.go │ │ ├── mksyscall.go │ │ ├── race.go │ │ ├── race0.go │ │ ├── registry │ │ ├── export_test.go │ │ ├── key.go │ │ ├── mksyscall.go │ │ ├── registry_test.go │ │ ├── syscall.go │ │ ├── value.go │ │ └── zsyscall_windows.go │ │ ├── security_windows.go │ │ ├── service.go │ │ ├── str.go │ │ ├── svc │ │ ├── debug │ │ │ ├── log.go │ │ │ └── service.go │ │ ├── event.go │ │ ├── eventlog │ │ │ ├── install.go │ │ │ ├── log.go │ │ │ └── log_test.go │ │ ├── example │ │ │ ├── beep.go │ │ │ ├── install.go │ │ │ ├── main.go │ │ │ ├── manage.go │ │ │ └── service.go │ │ ├── go12.c │ │ ├── go12.go │ │ ├── go13.go │ │ ├── mgr │ │ │ ├── config.go │ │ │ ├── mgr.go │ │ │ ├── mgr_test.go │ │ │ └── service.go │ │ ├── security.go │ │ ├── service.go │ │ ├── svc_test.go │ │ ├── sys_386.s │ │ └── sys_amd64.s │ │ ├── syscall.go │ │ ├── syscall_test.go │ │ ├── syscall_windows.go │ │ ├── syscall_windows_test.go │ │ ├── zsyscall_windows.go │ │ ├── ztypes_windows.go │ │ ├── ztypes_windows_386.go │ │ └── ztypes_windows_amd64.go └── gopkg.in │ ├── bsm │ └── ratelimit.v1 │ │ ├── .travis.yml │ │ ├── Makefile │ │ ├── README.md │ │ ├── ratelimit.go │ │ └── ratelimit_test.go │ └── redis.v5 │ ├── .gitignore │ ├── .travis.yml │ ├── CHANGELOG.md │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── bench_test.go │ ├── cluster.go │ ├── cluster_test.go │ ├── command.go │ ├── command_test.go │ ├── commands.go │ ├── commands_test.go │ ├── doc.go │ ├── example_instrumentation_test.go │ ├── example_test.go │ ├── export_test.go │ ├── internal │ ├── consistenthash │ │ ├── consistenthash.go │ │ └── consistenthash_test.go │ ├── errors.go │ ├── hashtag │ │ ├── hashtag.go │ │ └── hashtag_test.go │ ├── log.go │ ├── pool │ │ ├── bench_test.go │ │ ├── conn.go │ │ ├── main_test.go │ │ ├── pool.go │ │ ├── pool_single.go │ │ ├── pool_sticky.go │ │ └── pool_test.go │ ├── proto │ │ ├── proto.go │ │ ├── proto_test.go │ │ ├── reader.go │ │ ├── reader_test.go │ │ ├── writebuffer.go │ │ └── writebuffer_test.go │ └── util.go │ ├── iterator.go │ ├── iterator_test.go │ ├── main_test.go │ ├── options.go │ ├── options_test.go │ ├── parser.go │ ├── pipeline.go │ ├── pipeline_test.go │ ├── pool_test.go │ ├── pubsub.go │ ├── pubsub_test.go │ ├── race_test.go │ ├── redis.go │ ├── redis_test.go │ ├── result.go │ ├── ring.go │ ├── ring_test.go │ ├── script.go │ ├── sentinel.go │ ├── sentinel_test.go │ ├── testdata │ └── redis.conf │ ├── tx.go │ └── tx_test.go └── zone ├── client.go ├── main.go ├── server.go └── timemanager.go /.gitignore: -------------------------------------------------------------------------------- 1 | zeus-server 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | sudo: true 4 | language: generic 5 | 6 | services: 7 | - docker 8 | 9 | env: 10 | global: 11 | - DOCKER_COMPOSE_VERSION=1.9.0-rc3 12 | 13 | before_install: 14 | - sudo rm /usr/local/bin/docker-compose 15 | - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose 16 | - chmod +x docker-compose 17 | - sudo mv docker-compose /usr/local/bin 18 | 19 | script: 20 | - docker-compose run test 21 | 22 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.7 2 | 3 | ADD . /go/src/github.com/zeusproject/zeus-server 4 | 5 | WORKDIR /go/src/github.com/zeusproject/zeus-server 6 | 7 | RUN go build 8 | 9 | -------------------------------------------------------------------------------- /account/accountserver.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import "github.com/zeusproject/zeus-server/packets" 4 | 5 | type AccountServer interface { 6 | CharServerStore() CharServerStore 7 | PacketDB() *packets.PacketDatabase 8 | } 9 | -------------------------------------------------------------------------------- /account/authenticationrequest.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import "net" 4 | 5 | type AuthenticationRequest struct { 6 | ID string 7 | Key string 8 | 9 | PublicIP net.IP 10 | PublicPort int 11 | } 12 | -------------------------------------------------------------------------------- /account/charserver.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import "math/rand" 4 | 5 | type CharServer struct { 6 | *CharServerDefinition 7 | 8 | OnlinePlayers int 9 | Instances []*CharServerInstance 10 | } 11 | 12 | func (cs *CharServer) RandomInstance() *CharServerInstance { 13 | if len(cs.Instances) == 0 { 14 | return nil 15 | } 16 | 17 | i := rand.Int() % len(cs.Instances) 18 | 19 | return cs.Instances[i] 20 | } 21 | -------------------------------------------------------------------------------- /account/charserverdefintion.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | type CharServerDefinition struct { 4 | ID string `yaml:"id"` 5 | Key string `yaml:"key"` 6 | Name string `yaml:"name"` 7 | Enabled bool `yaml:"enabled"` 8 | } 9 | -------------------------------------------------------------------------------- /account/charserverinstance.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import "net" 4 | 5 | type CharServerInstance struct { 6 | PublicIP net.IP 7 | PublicPort int 8 | } 9 | 10 | func (i *CharServerInstance) Equal(other *CharServerInstance) bool { 11 | return i.PublicIP.Equal(other.PublicIP) && i.PublicPort == other.PublicPort 12 | } 13 | -------------------------------------------------------------------------------- /account/charserverstore.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | type CharServerStore interface { 4 | Servers() ([]*CharServer, error) 5 | RegisterInstance(id string, instance *CharServerInstance) error 6 | UpdateOnlineCount(id string, count int) error 7 | DeregisterInstance(id string, instance *CharServerInstance) error 8 | } 9 | -------------------------------------------------------------------------------- /account/config.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | type Config struct { 4 | Endpoint string `yaml:"endpoint"` 5 | InterEndpoint string `yaml:"inter_endpoint"` 6 | PacketVersion uint32 `yaml:"packet_version"` 7 | 8 | CharServers []*CharServerDefinition `yaml:"char_servers"` 9 | } 10 | -------------------------------------------------------------------------------- /account/main.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "github.com/Sirupsen/logrus" 5 | "os" 6 | "os/signal" 7 | "syscall" 8 | ) 9 | 10 | func Run(args map[string]interface{}) { 11 | logrus.SetLevel(logrus.DebugLevel) 12 | 13 | l := NewServer() 14 | 15 | sig := make(chan os.Signal) 16 | signal.Notify(sig, syscall.SIGINT) 17 | 18 | err := l.Run() 19 | 20 | if err != nil { 21 | logrus.WithError(err).Fatal("error starting server") 22 | return 23 | } 24 | 25 | for s := range sig { 26 | if s == syscall.SIGINT { 27 | l.Close() 28 | os.Exit(0) 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /account/pingrequest.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | type PingRequest struct { 4 | } 5 | -------------------------------------------------------------------------------- /account/quitnotification.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | type QuitNotification struct { 4 | } 5 | -------------------------------------------------------------------------------- /char/accountinterconfig.go: -------------------------------------------------------------------------------- 1 | package char 2 | 3 | type AccountInterConfig struct { 4 | Endpoint string `yaml:"endpoint"` 5 | ID string `yaml:"id"` 6 | Key string `yaml:"key"` 7 | PublicIP string `yaml:"public_ip"` 8 | PublicPort int `yaml:"public_port"` 9 | } 10 | -------------------------------------------------------------------------------- /char/config.go: -------------------------------------------------------------------------------- 1 | package char 2 | 3 | type Config struct { 4 | Endpoint string `yaml:"endpoint"` 5 | PacketVersion uint32 `yaml:"packet_version"` 6 | 7 | AccountInter AccountInterConfig `yaml:"account_inter"` 8 | } 9 | -------------------------------------------------------------------------------- /char/main.go: -------------------------------------------------------------------------------- 1 | package char 2 | 3 | import ( 4 | "github.com/Sirupsen/logrus" 5 | "os" 6 | "os/signal" 7 | "syscall" 8 | ) 9 | 10 | func Run(args map[string]interface{}) { 11 | logrus.SetLevel(logrus.DebugLevel) 12 | 13 | l := NewServer() 14 | 15 | sig := make(chan os.Signal) 16 | signal.Notify(sig, syscall.SIGINT) 17 | 18 | err := l.Run() 19 | 20 | if err != nil { 21 | logrus.WithError(err).Fatal("error starting server") 22 | return 23 | } 24 | 25 | for s := range sig { 26 | if s == syscall.SIGINT { 27 | l.Close() 28 | os.Exit(0) 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /config/account.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | endpoint: :6900 4 | inter_endpoint: :6901 5 | 6 | packet_version: 20151104 7 | 8 | char_servers: 9 | - id: test 10 | key: test 11 | name: Test Server 12 | enabled: true 13 | 14 | -------------------------------------------------------------------------------- /config/char.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | endpoint: :7000 4 | packet_version: 20151104 5 | 6 | account_inter: 7 | endpoint: account:6901 8 | id: test 9 | key: test 10 | public_ip: 127.0.0.1 11 | public_port: 7000 12 | 13 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | redis: 4 | address: redis:6379 5 | database: 0 6 | 7 | postgres: 8 | host: postgres 9 | port: 5432 10 | user: postgres 11 | password: zeus 12 | database: postgres 13 | options: 14 | sslmode: disable 15 | 16 | -------------------------------------------------------------------------------- /config/inter.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | endpoint: :4000 4 | secret: deadbeefsupersecret 5 | packer_version: 20151104 6 | 7 | -------------------------------------------------------------------------------- /database/authcookie.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | import "math/rand" 4 | 5 | type AuthCookieKind int 6 | 7 | //go:generate stringer -type=AuthCookieKind 8 | const ( 9 | _ AuthCookieKind = iota 10 | 11 | AccountAuthCookie 12 | InterAuthCookie 13 | ) 14 | 15 | const AuthCookieKindMask = 1 << 63 16 | 17 | type AuthCookie struct { 18 | Cookie uint64 19 | AccountID uint32 20 | } 21 | 22 | type AuthCookieStore interface { 23 | Create(cookie AuthCookie) error 24 | VerifyAndConsume(cookie AuthCookie) (bool, error) 25 | } 26 | 27 | func GenerateAuthCookie(accountID uint32, kind AuthCookieKind) AuthCookie { 28 | cookie := uint64(rand.Int63()) 29 | 30 | if kind == AccountAuthCookie { 31 | cookie |= AuthCookieKindMask 32 | } else { 33 | cookie &^= AuthCookieKindMask 34 | } 35 | 36 | return AuthCookie{ 37 | Cookie: cookie, 38 | AccountID: accountID, 39 | } 40 | } 41 | 42 | func (ac AuthCookie) Kind() AuthCookieKind { 43 | if ac.Cookie&AuthCookieKindMask != 0 { 44 | return AccountAuthCookie 45 | } else { 46 | return InterAuthCookie 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /database/config.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | import ( 4 | "fmt" 5 | "net/url" 6 | ) 7 | 8 | type Config struct { 9 | Redis RedisConfig `yaml:"redis"` 10 | Postgres PostgresConfig `yaml:"postgres"` 11 | } 12 | 13 | type RedisConfig struct { 14 | Address string `yaml:"address"` 15 | Password string `yaml:"password"` 16 | Database int `yaml:"database"` 17 | } 18 | 19 | type PostgresConfig struct { 20 | Host string `yaml:"host"` 21 | Port int `yaml:"port"` 22 | User string `yaml:"user"` 23 | Password string `yaml:"password"` 24 | Database string `yaml:"database"` 25 | Options map[string]string `yaml:"options"` 26 | } 27 | 28 | func (c *PostgresConfig) ConnectionUrl() string { 29 | query := make(url.Values) 30 | 31 | for k, v := range c.Options { 32 | query[k] = []string{v} 33 | } 34 | 35 | url := &url.URL{ 36 | Scheme: "postgres", 37 | User: url.UserPassword(c.User, c.Password), 38 | Host: fmt.Sprintf("%s:%d", c.Host, c.Port), 39 | Path: c.Database, 40 | RawQuery: query.Encode(), 41 | } 42 | 43 | return url.String() 44 | } 45 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | base: 5 | build: . 6 | 7 | account: 8 | extends: base 9 | command: go run main.go server account 10 | expose: 11 | - 6900 12 | - 6901 13 | ports: 14 | - 6900:6900 15 | volumes: 16 | - .:/go/src/github.com/zeusproject/zeus-server 17 | 18 | char: 19 | extends: base 20 | command: go run main.go server char 21 | expose: 22 | - 7000 23 | ports: 24 | - 7000:7000 25 | volumes: 26 | - .:/go/src/github.com/zeusproject/zeus-server 27 | 28 | inter: 29 | extends: base 30 | command: go run main.go server inter 31 | expose: 32 | - 4000 33 | volumes: 34 | - .:/go/src/github.com/zeusproject/zeus-server 35 | 36 | zone: 37 | extends: base 38 | command: go run main.go server zone 39 | expose: 40 | - 4500 41 | ports: 42 | - 4500:4500 43 | volumes: 44 | - .:/go/src/github.com/zeusproject/zeus-server 45 | 46 | postgres: 47 | image: postgres:9.5 48 | environment: 49 | POSTGRES_PASSWORD: zeus 50 | 51 | redis: 52 | image: redis:3.2 53 | 54 | -------------------------------------------------------------------------------- /glide.yaml: -------------------------------------------------------------------------------- 1 | package: github.com/zeusproject/zeus-server 2 | import: 3 | - package: github.com/Sirupsen/logrus 4 | version: ^0.11.0 5 | - package: github.com/docopt/docopt-go 6 | version: ^0.6.2 7 | - package: github.com/go-yaml/yaml 8 | -------------------------------------------------------------------------------- /inter/config.go: -------------------------------------------------------------------------------- 1 | package inter 2 | 3 | type Config struct { 4 | Endpoint string `yaml:"endpoint"` 5 | Secret string `yaml:"secret"` 6 | PacketVersion uint32 `yaml:"packet_version"` 7 | } 8 | -------------------------------------------------------------------------------- /inter/goodbytenotification.go: -------------------------------------------------------------------------------- 1 | package inter 2 | 3 | type GoodbyeNotification struct { 4 | } 5 | -------------------------------------------------------------------------------- /inter/hellorequest.go: -------------------------------------------------------------------------------- 1 | package inter 2 | 3 | type HelloRequest struct { 4 | Secret string 5 | Type ServerType 6 | } 7 | -------------------------------------------------------------------------------- /inter/helloresponse.go: -------------------------------------------------------------------------------- 1 | package inter 2 | 3 | type HelloResponse struct { 4 | } 5 | -------------------------------------------------------------------------------- /inter/interclient.go: -------------------------------------------------------------------------------- 1 | package inter 2 | 3 | import ( 4 | gonet "net" 5 | 6 | "github.com/zeusproject/zeus-server/net" 7 | ) 8 | 9 | type InterClient struct { 10 | *net.RpcClient 11 | } 12 | 13 | func NewInterClient(endpoint string) (*InterClient, error) { 14 | client, err := gonet.Dial("tcp", endpoint) 15 | 16 | if err != nil { 17 | return nil, err 18 | } 19 | 20 | c := &InterClient{} 21 | 22 | c.RpcClient = net.NewRpcClient(client, c) 23 | 24 | // Setup callbacks 25 | c.Register("ping", c.handlePing) 26 | 27 | return c, nil 28 | } 29 | 30 | func (c *InterClient) Authenticate(secret string, serverType ServerType) (*HelloResponse, error) { 31 | var res HelloResponse 32 | 33 | err := c.Call("hello", &HelloRequest{ 34 | Secret: secret, 35 | Type: serverType, 36 | }, &res) 37 | 38 | if err != nil { 39 | return nil, err 40 | } 41 | 42 | return &res, nil 43 | } 44 | 45 | func (c *InterClient) handlePing(req *PingRequest, res *bool) error { 46 | c.Notify("ping", &PingRequest{}) 47 | 48 | *res = true 49 | 50 | return nil 51 | } 52 | 53 | func (c *InterClient) OnDisconnect(err error) { 54 | } 55 | -------------------------------------------------------------------------------- /inter/main.go: -------------------------------------------------------------------------------- 1 | package inter 2 | 3 | import ( 4 | "github.com/Sirupsen/logrus" 5 | "os" 6 | "os/signal" 7 | "syscall" 8 | ) 9 | 10 | func Run(args map[string]interface{}) { 11 | logrus.SetLevel(logrus.DebugLevel) 12 | 13 | l := NewServer() 14 | 15 | sig := make(chan os.Signal) 16 | signal.Notify(sig, syscall.SIGINT) 17 | 18 | err := l.Run() 19 | 20 | if err != nil { 21 | logrus.WithError(err).Fatal("error starting server") 22 | return 23 | } 24 | 25 | for s := range sig { 26 | if s == syscall.SIGINT { 27 | l.Close() 28 | os.Exit(0) 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /inter/pingrequest.go: -------------------------------------------------------------------------------- 1 | package inter 2 | 3 | type PingRequest struct { 4 | } 5 | -------------------------------------------------------------------------------- /inter/servertype.go: -------------------------------------------------------------------------------- 1 | package inter 2 | 3 | type ServerType int 4 | 5 | const ( 6 | _ ServerType = iota 7 | 8 | AccountServer 9 | CharServer 10 | ZoneServer 11 | ) 12 | -------------------------------------------------------------------------------- /inter/servertype_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -type=ServerType"; DO NOT EDIT 2 | 3 | package inter 4 | 5 | import "fmt" 6 | 7 | const _ServerType_name = "AccountServerCharServerZoneServer" 8 | 9 | var _ServerType_index = [...]uint8{0, 13, 23, 33} 10 | 11 | func (i ServerType) String() string { 12 | i -= 1 13 | if i < 0 || i >= ServerType(len(_ServerType_index)-1) { 14 | return fmt.Sprintf("ServerType(%d)", i+1) 15 | } 16 | return _ServerType_name[_ServerType_index[i]:_ServerType_index[i+1]] 17 | } 18 | -------------------------------------------------------------------------------- /net/handler.go: -------------------------------------------------------------------------------- 1 | package net 2 | 3 | import "net" 4 | 5 | type Handler interface { 6 | Accept(conn net.Conn) 7 | } 8 | -------------------------------------------------------------------------------- /net/handlerfunc.go: -------------------------------------------------------------------------------- 1 | package net 2 | 3 | import "net" 4 | 5 | type HandlerFn struct { 6 | Fn func(conn net.Conn) 7 | } 8 | 9 | func (h HandlerFn) Accept(conn net.Conn) { 10 | h.Fn(conn) 11 | } 12 | -------------------------------------------------------------------------------- /net/packethandler.go: -------------------------------------------------------------------------------- 1 | package net 2 | 3 | import "github.com/zeusproject/zeus-server/packets" 4 | 5 | type PacketHandler interface { 6 | HandlePacket(d *packets.Definition, p packets.IncomingPacket) 7 | OnDisconnect(err error) 8 | } 9 | -------------------------------------------------------------------------------- /net/rpchandler.go: -------------------------------------------------------------------------------- 1 | package net 2 | 3 | type RpcHandler interface { 4 | OnDisconnect(err error) 5 | } 6 | -------------------------------------------------------------------------------- /net/server.go: -------------------------------------------------------------------------------- 1 | package net 2 | 3 | import ( 4 | "net" 5 | 6 | "github.com/Sirupsen/logrus" 7 | ) 8 | 9 | type Server struct { 10 | handler Handler 11 | listener net.Listener 12 | log *logrus.Entry 13 | } 14 | 15 | func NewServer(handler Handler) *Server { 16 | return &Server{ 17 | handler: handler, 18 | log: logrus.WithField("component", "server"), 19 | } 20 | } 21 | 22 | func (s *Server) Listen(endpoint string) error { 23 | l, err := net.Listen("tcp", endpoint) 24 | 25 | if err != nil { 26 | return err 27 | } 28 | 29 | s.listener = l 30 | 31 | go s.run() 32 | 33 | return nil 34 | } 35 | 36 | func (s *Server) Stop() error { 37 | return s.listener.Close() 38 | } 39 | 40 | func (s *Server) run() { 41 | conn, err := s.listener.Accept() 42 | 43 | if err != nil { 44 | s.log.WithError(err).Error("error accepting client") 45 | return 46 | } 47 | 48 | s.handler.Accept(conn) 49 | s.run() 50 | } 51 | -------------------------------------------------------------------------------- /packets/accountacceptlogin.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | import ( 4 | "net" 5 | ) 6 | 7 | type AccountAcceptLogin struct { 8 | AuthenticationCode uint32 9 | AccountID uint32 10 | AccountLevel uint32 11 | Sex byte 12 | Servers []CharServer 13 | } 14 | 15 | type CharServer struct { 16 | IP net.IP 17 | Port uint16 18 | Name string 19 | Users uint16 20 | State uint16 21 | Property uint16 22 | } 23 | 24 | func (r *AccountAcceptLogin) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 25 | p.Grow(43 + len(r.Servers)*32) 26 | 27 | p.Write(r.AuthenticationCode) 28 | p.Write(r.AccountID) 29 | p.Write(r.AccountLevel) 30 | p.Skip(30) 31 | p.Write(r.Sex) 32 | 33 | for _, s := range r.Servers { 34 | p.Write(s.IP.To4()) 35 | p.Write(s.Port) 36 | p.WriteString(20, s.Name) 37 | p.Write(s.Users) 38 | p.Write(s.State) 39 | p.Write(s.Property) 40 | } 41 | 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /packets/accountlogin.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type AccountLogin struct { 4 | Version uint32 5 | Username string 6 | Password string 7 | ClientType byte 8 | } 9 | 10 | func (r *AccountLogin) Parse(db *PacketDatabase, d *Definition, p *RawPacket) error { 11 | p.Read(&r.Version) 12 | p.ReadString(24, &r.Username) 13 | p.ReadString(24, &r.Password) 14 | p.Read(&r.ClientType) 15 | 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /packets/characceptenter.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type CharAcceptEnter struct { 4 | TotalSlotCount byte 5 | PremiumSlotStart byte 6 | PremiumSlotEnd byte 7 | Chars []*CharacterInfo 8 | } 9 | 10 | func (r *CharAcceptEnter) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 11 | p.Grow(23) 12 | 13 | p.Write(r.TotalSlotCount) 14 | p.Write(r.PremiumSlotStart) 15 | p.Write(r.PremiumSlotEnd) 16 | p.Skip(20) 17 | 18 | for _, ch := range r.Chars { 19 | ch.Write(db, d, p) 20 | } 21 | 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /packets/characceptmakechar.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type CharAcceptMakeChar struct { 4 | CharInfo *CharacterInfo 5 | } 6 | 7 | func (r *CharAcceptMakeChar) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 8 | r.CharInfo.Write(db, d, p) 9 | 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /packets/charblockcharacter.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type CharBlockCharacter struct { 4 | } 5 | 6 | func (r *CharBlockCharacter) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 7 | return nil 8 | } 9 | -------------------------------------------------------------------------------- /packets/chardeletechar3cancel.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type CharDeleteChar3Cancel struct { 4 | CharID uint 5 | } 6 | 7 | func (r *CharDeleteChar3Cancel) Parse(db *PacketDatabase, d *Definition, p *RawPacket) error { 8 | p.Read(&r.CharID) 9 | 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /packets/chardeletechar3cancelack.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type CharDeleteChar3CancelAck struct { 4 | CharID uint 5 | Result int 6 | } 7 | 8 | func (r *CharDeleteChar3CancelAck) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 9 | p.Write(uint32(r.CharID)) 10 | p.Write(r.Result) 11 | 12 | return nil 13 | } 14 | -------------------------------------------------------------------------------- /packets/chardeletechar3reserved.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type CharDeleteChar3Reserved struct { 4 | CharID uint 5 | } 6 | 7 | func (r *CharDeleteChar3Reserved) Parse(db *PacketDatabase, d *Definition, p *RawPacket) error { 8 | p.Read(&r.CharID) 9 | 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /packets/chardeletechar3reservedack.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type CharDeleteChar3ReservedAck struct { 4 | CharID uint 5 | Result int 6 | DeleteReservedDate uint32 7 | } 8 | 9 | func (r *CharDeleteChar3ReservedAck) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 10 | p.Write(uint32(r.CharID)) 11 | p.Write(r.Result) 12 | p.Write(r.DeleteReservedDate) 13 | 14 | return nil 15 | } 16 | -------------------------------------------------------------------------------- /packets/charenter.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type CharEnter struct { 4 | AccountID uint32 5 | AuthenticationCode uint32 6 | UserLevel uint32 7 | ClientType uint16 8 | Sex byte 9 | } 10 | 11 | func (r *CharEnter) Parse(db *PacketDatabase, d *Definition, p *RawPacket) error { 12 | p.Read(&r.AccountID) 13 | p.Read(&r.AuthenticationCode) 14 | p.Read(&r.UserLevel) 15 | p.Read(&r.ClientType) 16 | p.Read(&r.Sex) 17 | 18 | return nil 19 | } 20 | -------------------------------------------------------------------------------- /packets/charmakechar.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type CharMakeChar struct { 4 | Name string 5 | Slot byte 6 | HairColor uint16 7 | HairStyle uint16 8 | StartingJobID uint16 9 | Unknown uint16 // or [2]byte 10 | Sex byte 11 | } 12 | 13 | func (r *CharMakeChar) Parse(db *PacketDatabase, d *Definition, p *RawPacket) error { 14 | p.ReadString(24, &r.Name) 15 | p.Read(&r.Slot) 16 | p.Read(&r.HairColor) 17 | p.Read(&r.HairStyle) 18 | p.Read(&r.StartingJobID) 19 | p.Read(&r.Unknown) 20 | p.Read(&r.Sex) 21 | 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /packets/charnotifyzoneserver.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | import "net" 4 | 5 | type CharNotifyZoneServer struct { 6 | CharID uint 7 | MapName string 8 | Address net.IP 9 | Port uint16 10 | } 11 | 12 | func (r *CharNotifyZoneServer) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 13 | p.Write(uint32(r.CharID)) 14 | p.WriteString(16, r.MapName) 15 | p.Write(r.Address.To4()) 16 | p.Write(uint16(r.Port)) 17 | 18 | return nil 19 | } 20 | -------------------------------------------------------------------------------- /packets/charrefuseenter.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type CharRefuseEnter struct { 4 | Reason byte 5 | } 6 | 7 | func (r *CharRefuseEnter) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 8 | p.Write(r.Reason) 9 | 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /packets/charrefusemakechar.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type CharRefuseMakeChar struct { 4 | ErrorCode byte 5 | } 6 | 7 | func (r *CharRefuseMakeChar) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 8 | p.Write(r.ErrorCode) 9 | 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /packets/charselectchar.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type CharSelectChar struct { 4 | Slot byte 5 | } 6 | 7 | func (r *CharSelectChar) Parse(db *PacketDatabase, d *Definition, p *RawPacket) error { 8 | p.Read(&r.Slot) 9 | 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /packets/charslotsinfo.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type CharSlotsInfo struct { 4 | NormalSlots byte 5 | PremiumSlots byte 6 | BillingSlots byte 7 | ProducibleSlots byte 8 | ValidSlots byte 9 | Chars []*CharacterInfo 10 | } 11 | 12 | func (r *CharSlotsInfo) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 13 | p.Grow(25) 14 | 15 | p.Write(r.NormalSlots) 16 | p.Write(r.PremiumSlots) 17 | p.Write(r.BillingSlots) 18 | p.Write(r.ProducibleSlots) 19 | p.Write(r.ValidSlots) 20 | p.Skip(20) 21 | 22 | for _, ch := range r.Chars { 23 | ch.Write(db, d, p) 24 | } 25 | 26 | return nil 27 | } 28 | -------------------------------------------------------------------------------- /packets/definition.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type Definition struct { 4 | Name string 5 | ID uint16 6 | Size int 7 | Parser IncomingPacket 8 | Writer OutgoingPacket 9 | } 10 | -------------------------------------------------------------------------------- /packets/incomingpacket.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type IncomingPacket interface { 4 | Parse(db *PacketDatabase, d *Definition, r *RawPacket) error 5 | } 6 | -------------------------------------------------------------------------------- /packets/incomingtypemap.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | var incomingTypeMap = map[string]IncomingPacket{ 4 | "SS_NULL": &NullPacket{}, 5 | "SS_PING": &Ping{}, 6 | 7 | "CA_LOGIN": &AccountLogin{}, 8 | 9 | "CH_ENTER": &CharEnter{}, 10 | "CH_SELECT_CHAR": &CharSelectChar{}, 11 | "CH_MAKE_CHAR": &CharMakeChar{}, 12 | "CH_DELETE_CHAR3_RESERVED": &CharDeleteChar3Reserved{}, 13 | "CH_DELETE_CHAR3": &NullPacket{}, //&CharDeleteChar3{}, 14 | "CH_DELETE_CHAR3_CANCEL": &CharDeleteChar3Cancel{}, 15 | 16 | "CZ_ENTER": &ZoneEnter{}, 17 | "CZ_REQUEST_TIME": &ZoneRequestTime{}, 18 | "CZ_NOTIFY_ACTORINIT": &ZoneNotifyActorInit{}, 19 | "CZ_REQNAME": &ZoneNameRequest{}, 20 | "CZ_REQUEST_MOVE": &ZoneRequestMove{}, 21 | } 22 | -------------------------------------------------------------------------------- /packets/nullpacket.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type NullPacket struct { 4 | Raw *RawPacket 5 | } 6 | 7 | func (r *NullPacket) Parse(db *PacketDatabase, d *Definition, p *RawPacket) error { 8 | r.Raw = p 9 | return nil 10 | } 11 | 12 | func (r *NullPacket) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 13 | return nil 14 | } 15 | -------------------------------------------------------------------------------- /packets/outgoingpacket.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type OutgoingPacket interface { 4 | Write(db *PacketDatabase, d *Definition, r *RawPacket) error 5 | } 6 | -------------------------------------------------------------------------------- /packets/outgoingtypemap.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | var outgoingTypeMap = map[string]OutgoingPacket{ 4 | "SS_NULL": &NullPacket{}, 5 | 6 | "AC_ACCEPT_LOGIN": &AccountAcceptLogin{}, 7 | 8 | "HC_ACCEPT_ENTER": &CharAcceptEnter{}, 9 | "HC_REFUSE_ENTER": &CharRefuseEnter{}, 10 | "HC_SLOT_INFO": &CharSlotsInfo{}, 11 | "HC_BLOCK_CHARACTER": &CharBlockCharacter{}, 12 | "HC_SECOND_PASSWD_LOGIN": &CharSecondPasswordLogin{}, 13 | "HC_NOTIFY_ZONESVR": &CharNotifyZoneServer{}, 14 | "HC_REFUSE_MAKE_CHAR": &CharRefuseMakeChar{}, 15 | "HC_ACCEPT_MAKE_CHAR": &CharAcceptMakeChar{}, 16 | "HC_DELETE_CHAR3_RESERVED": &CharDeleteChar3ReservedAck{}, 17 | "HC_DELETE_CHAR3": &NullPacket{}, //&CharDeleteChar3Ack{}, 18 | "HC_DELETE_CHAR3_CANCEL": &CharDeleteChar3CancelAck{}, 19 | 20 | "ZC_AID": &ZoneAid{}, 21 | "ZC_ACCEPT_ENTER": &ZoneAcceptEnter{}, 22 | "ZC_NOTIFY_TIME": &ZoneNotifyTime{}, 23 | "ZC_ACK_REQNAME": &ZoneAckNameRequest{}, 24 | "ZC_NOTIFY_PLAYERMOVE": &ZoneNotifyPlayerMove{}, 25 | "ZC_REFUSE_ENTER": &ZoneRefuseEnter{}, 26 | "ZC_RESTART_ACK": &ZoneRestartAck{}, 27 | "ZC_NOTIFY_BAN": &ZoneNotifyBan{}, 28 | "ZC_NOTIFY_NEWENTRY": &ZoneNotifyNewEntry{}, 29 | } 30 | -------------------------------------------------------------------------------- /packets/ping.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type Ping struct { 4 | AccountID uint32 5 | } 6 | 7 | func (r *Ping) Parse(db *PacketDatabase, d *Definition, p *RawPacket) error { 8 | p.Read(&r.AccountID) 9 | 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /packets/position.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type Position struct { 4 | X uint16 5 | Y uint16 6 | Direction byte 7 | } 8 | 9 | func (r *Position) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 10 | p.Write([]byte{ 11 | byte(r.X >> 2), 12 | byte((r.X << 6) | ((r.Y >> 4) & 0x3F)), 13 | byte((r.Y << 4) | (uint16(r.Direction) & 0xF)), 14 | }) 15 | 16 | return nil 17 | } 18 | 19 | func (r *Position) Parse(db *PacketDatabase, d *Definition, p *RawPacket) error { 20 | raw := make([]byte, 3) 21 | 22 | p.Read(raw) 23 | 24 | r.X = uint16(((raw[0] & 0xFF) << 2) | (raw[1] >> 6)) 25 | r.Y = uint16(((raw[1] & 0x3F) << 4) | (raw[2] >> 4)) 26 | r.Direction = raw[2] & 0xF 27 | 28 | return nil 29 | } 30 | -------------------------------------------------------------------------------- /packets/position2.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type Position2 struct { 4 | X0 uint16 5 | Y0 uint16 6 | X1 uint16 7 | Y1 uint16 8 | SX uint16 9 | SY uint16 10 | } 11 | 12 | func (r *Position2) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 13 | p.Write([]byte{ 14 | byte(r.X0 >> 2), 15 | byte((r.X0 << 6) | ((r.Y0 >> 4) & 0x3f)), 16 | byte((r.Y0 << 4) | ((r.X1 >> 6) & 0x0f)), 17 | byte((r.X1 << 2) | ((r.Y1 >> 8) & 0x03)), 18 | byte(r.Y1), 19 | byte((r.SX << 4) | (r.SY & 0x0f)), 20 | }) 21 | 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /packets/secondpasswordlogin.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type CharSecondPasswordLogin struct { 4 | Seed uint32 5 | AccountID uint32 6 | Result uint16 7 | } 8 | 9 | func (r *CharSecondPasswordLogin) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 10 | p.Write(r.Seed) 11 | p.Write(r.AccountID) 12 | p.Write(r.Result) 13 | 14 | return nil 15 | } 16 | -------------------------------------------------------------------------------- /packets/zoneacceptenter.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type ZoneAcceptEnter struct { 4 | Tick uint32 5 | Position Position 6 | XSize byte 7 | YSize byte 8 | Font uint16 9 | Sex bool 10 | } 11 | 12 | func (r *ZoneAcceptEnter) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 13 | p.Write(uint32(r.Tick)) 14 | 15 | r.Position.Write(db, d, p) 16 | 17 | p.Write(byte(r.XSize)) 18 | p.Write(byte(r.YSize)) 19 | p.Write(uint16(r.Font)) 20 | 21 | if r.Sex { 22 | p.Write(byte(1)) 23 | } else { 24 | p.Write(byte(0)) 25 | } 26 | 27 | return nil 28 | } 29 | -------------------------------------------------------------------------------- /packets/zoneacknamerequest.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type ZoneAckNameRequest struct { 4 | ID uint32 5 | Name string 6 | } 7 | 8 | func (r *ZoneAckNameRequest) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 9 | p.Write(r.ID) 10 | p.WriteString(24, r.Name) 11 | 12 | return nil 13 | } 14 | -------------------------------------------------------------------------------- /packets/zoneaid.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type ZoneAid struct { 4 | AccountID uint32 5 | } 6 | 7 | func (r *ZoneAid) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 8 | p.Write(r.AccountID) 9 | 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /packets/zoneenter.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type ZoneEnter struct { 4 | AccountID uint32 5 | CharID uint32 6 | AuthenticationCode uint32 7 | Tick uint32 8 | Sex bool 9 | } 10 | 11 | func (r *ZoneEnter) Parse(db *PacketDatabase, d *Definition, p *RawPacket) error { 12 | p.Read(&r.AccountID) 13 | p.Read(&r.CharID) 14 | p.Read(&r.AuthenticationCode) 15 | p.Read(&r.Tick) 16 | p.Read(&r.Sex) 17 | 18 | return nil 19 | } 20 | -------------------------------------------------------------------------------- /packets/zonenamerequest.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type ZoneNameRequest struct { 4 | ID uint32 5 | } 6 | 7 | func (r *ZoneNameRequest) Parse(db *PacketDatabase, d *Definition, p *RawPacket) error { 8 | p.Read(&r.ID) 9 | 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /packets/zonenotifyactorinit.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type ZoneNotifyActorInit struct { 4 | } 5 | 6 | func (r *ZoneNotifyActorInit) Parse(db *PacketDatabase, d *Definition, p *RawPacket) error { 7 | return nil 8 | } 9 | -------------------------------------------------------------------------------- /packets/zonenotifyban.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type ZoneNotifyBan struct { 4 | Reason byte 5 | } 6 | 7 | func (r *ZoneNotifyBan) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 8 | p.Write(r.Reason) 9 | 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /packets/zonenotifynewentry.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type ZoneNotifyNewEntry struct { 4 | Type byte 5 | Aid uint32 6 | Gid uint32 7 | Speed uint16 8 | BodyState uint16 9 | HealthState uint16 10 | EffectState uint32 11 | Job uint16 12 | Head uint16 13 | Weapon uint32 14 | HeadBottom uint16 15 | HeadTop uint16 16 | HeadMid uint16 17 | HairColor uint16 18 | ClothesColor uint16 19 | HeadDirection uint16 20 | Robe uint16 21 | GuildID uint32 22 | GuildEmblemVersion uint16 23 | Honor uint16 24 | Virtue uint32 25 | IsPK bool 26 | Gender bool 27 | Position Position 28 | XSize byte 29 | YSize byte 30 | CLevel uint16 31 | Font uint16 32 | MaxHP uint32 33 | HP uint32 34 | IsBoss bool 35 | Body uint16 36 | Name string 37 | } 38 | 39 | func (r *ZoneNotifyNewEntry) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 40 | return nil 41 | } 42 | -------------------------------------------------------------------------------- /packets/zonenotifyplayermove.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type ZoneNotifyPlayerMove struct { 4 | Tick uint32 5 | Position Position2 6 | } 7 | 8 | func (r *ZoneNotifyPlayerMove) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 9 | p.Write(r.Tick) 10 | r.Position.Write(db, d, p) 11 | 12 | return nil 13 | } 14 | -------------------------------------------------------------------------------- /packets/zonenotifytime.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type ZoneNotifyTime struct { 4 | Tick uint32 5 | } 6 | 7 | func (r *ZoneNotifyTime) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 8 | p.Write(r.Tick) 9 | 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /packets/zonerefuseenter.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type ZoneRefuseEnter struct { 4 | Reason byte 5 | } 6 | 7 | func (r *ZoneRefuseEnter) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 8 | p.Write(r.Reason) 9 | 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /packets/zonerequestmove.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type ZoneRequestMove struct { 4 | Position Position 5 | } 6 | 7 | func (r *ZoneRequestMove) Parse(db *PacketDatabase, d *Definition, p *RawPacket) error { 8 | r.Position.Parse(db, d, p) 9 | 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /packets/zonerequesttime.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type ZoneRequestTime struct { 4 | Tick uint32 5 | } 6 | 7 | func (r *ZoneRequestTime) Parse(db *PacketDatabase, d *Definition, p *RawPacket) error { 8 | p.Read(&r.Tick) 9 | 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /packets/zonerestartack.go: -------------------------------------------------------------------------------- 1 | package packets 2 | 3 | type ZoneRestartAck struct { 4 | Reason byte 5 | } 6 | 7 | func (r *ZoneRestartAck) Write(db *PacketDatabase, d *Definition, p *RawPacket) error { 8 | p.Write(r.Reason) 9 | 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /rpc/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Cenk Altı 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. -------------------------------------------------------------------------------- /utils/config.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "github.com/go-yaml/yaml" 5 | "io/ioutil" 6 | "path" 7 | ) 8 | 9 | func LoadConfig(name string, config interface{}) error { 10 | file, err := ioutil.ReadFile(path.Join("./config", name+".yml")) 11 | 12 | if err != nil { 13 | return err 14 | } 15 | 16 | return yaml.Unmarshal(file, config) 17 | } 18 | -------------------------------------------------------------------------------- /utils/ticker.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import "time" 4 | 5 | type Ticker struct { 6 | *time.Ticker 7 | Duration time.Duration 8 | } 9 | -------------------------------------------------------------------------------- /utils/timer.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import "time" 4 | 5 | type Timer struct { 6 | *time.Timer 7 | Duration time.Duration 8 | 9 | bag *TimerBag 10 | prev, next *Timer 11 | } 12 | 13 | func (t *Timer) Reset() { 14 | t.Timer.Stop() 15 | t.Timer.Reset(t.Duration) 16 | } 17 | 18 | func (t *Timer) Close() { 19 | t.Stop() 20 | t.bag.remove(t) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/.gitignore: -------------------------------------------------------------------------------- 1 | logrus 2 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.3 4 | - 1.4 5 | - 1.5 6 | - 1.6 7 | - tip 8 | install: 9 | - go get -t ./... 10 | script: GOMAXPROCS=4 GORACE="halt_on_error=1" go test -race -v ./... 11 | -------------------------------------------------------------------------------- /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/examples/basic/basic.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/Sirupsen/logrus" 5 | ) 6 | 7 | var log = logrus.New() 8 | 9 | func init() { 10 | log.Formatter = new(logrus.JSONFormatter) 11 | log.Formatter = new(logrus.TextFormatter) // default 12 | log.Level = logrus.DebugLevel 13 | } 14 | 15 | func main() { 16 | defer func() { 17 | err := recover() 18 | if err != nil { 19 | log.WithFields(logrus.Fields{ 20 | "omg": true, 21 | "err": err, 22 | "number": 100, 23 | }).Fatal("The ice breaks!") 24 | } 25 | }() 26 | 27 | log.WithFields(logrus.Fields{ 28 | "animal": "walrus", 29 | "number": 8, 30 | }).Debug("Started observing beach") 31 | 32 | log.WithFields(logrus.Fields{ 33 | "animal": "walrus", 34 | "size": 10, 35 | }).Info("A group of walrus emerges from the ocean") 36 | 37 | log.WithFields(logrus.Fields{ 38 | "omg": true, 39 | "number": 122, 40 | }).Warn("The group's number increased tremendously!") 41 | 42 | log.WithFields(logrus.Fields{ 43 | "temperature": -4, 44 | }).Debug("Temperature changes") 45 | 46 | log.WithFields(logrus.Fields{ 47 | "animal": "orca", 48 | "size": 9009, 49 | }).Panic("It's over 9000!") 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/examples/hook/hook.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/Sirupsen/logrus" 5 | "gopkg.in/gemnasium/logrus-airbrake-hook.v2" 6 | ) 7 | 8 | var log = logrus.New() 9 | 10 | func init() { 11 | log.Formatter = new(logrus.TextFormatter) // default 12 | log.Hooks.Add(airbrake.NewHook(123, "xyz", "development")) 13 | } 14 | 15 | func main() { 16 | log.WithFields(logrus.Fields{ 17 | "animal": "walrus", 18 | "size": 10, 19 | }).Info("A group of walrus emerges from the ocean") 20 | 21 | log.WithFields(logrus.Fields{ 22 | "omg": true, 23 | "number": 122, 24 | }).Warn("The group's number increased tremendously!") 25 | 26 | log.WithFields(logrus.Fields{ 27 | "omg": true, 28 | "number": 100, 29 | }).Fatal("The ice breaks!") 30 | } 31 | -------------------------------------------------------------------------------- /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/hooks/syslog/README.md: -------------------------------------------------------------------------------- 1 | # Syslog Hooks for Logrus :walrus: 2 | 3 | ## Usage 4 | 5 | ```go 6 | import ( 7 | "log/syslog" 8 | "github.com/Sirupsen/logrus" 9 | logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog" 10 | ) 11 | 12 | func main() { 13 | log := logrus.New() 14 | hook, err := logrus_syslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "") 15 | 16 | if err == nil { 17 | log.Hooks.Add(hook) 18 | } 19 | } 20 | ``` 21 | 22 | If you want to connect to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "/var/run/log"). Just assign empty string to the first two parameters of `NewSyslogHook`. It should look like the following. 23 | 24 | ```go 25 | import ( 26 | "log/syslog" 27 | "github.com/Sirupsen/logrus" 28 | logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog" 29 | ) 30 | 31 | func main() { 32 | log := logrus.New() 33 | hook, err := logrus_syslog.NewSyslogHook("", "", syslog.LOG_INFO, "") 34 | 35 | if err == nil { 36 | log.Hooks.Add(hook) 37 | } 38 | } 39 | ``` -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks/syslog/syslog_test.go: -------------------------------------------------------------------------------- 1 | package logrus_syslog 2 | 3 | import ( 4 | "github.com/Sirupsen/logrus" 5 | "log/syslog" 6 | "testing" 7 | ) 8 | 9 | func TestLocalhostAddAndPrint(t *testing.T) { 10 | log := logrus.New() 11 | hook, err := NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "") 12 | 13 | if err != nil { 14 | t.Errorf("Unable to connect to local syslog.") 15 | } 16 | 17 | log.Hooks.Add(hook) 18 | 19 | for _, level := range hook.Levels() { 20 | if len(log.Hooks[level]) != 1 { 21 | t.Errorf("SyslogHook was not added. The length of log.Hooks[%v]: %v", level, len(log.Hooks[level])) 22 | } 23 | } 24 | 25 | log.Info("Congratulations!") 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks/test/test_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/Sirupsen/logrus" 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | func TestAllHooks(t *testing.T) { 11 | 12 | assert := assert.New(t) 13 | 14 | logger, hook := NewNullLogger() 15 | assert.Nil(hook.LastEntry()) 16 | assert.Equal(0, len(hook.Entries)) 17 | 18 | logger.Error("Hello error") 19 | assert.Equal(logrus.ErrorLevel, hook.LastEntry().Level) 20 | assert.Equal("Hello error", hook.LastEntry().Message) 21 | assert.Equal(1, len(hook.Entries)) 22 | 23 | logger.Warn("Hello warning") 24 | assert.Equal(logrus.WarnLevel, hook.LastEntry().Level) 25 | assert.Equal("Hello warning", hook.LastEntry().Message) 26 | assert.Equal(2, len(hook.Entries)) 27 | 28 | hook.Reset() 29 | assert.Nil(hook.LastEntry()) 30 | assert.Equal(0, len(hook.Entries)) 31 | 32 | hook = NewGlobal() 33 | 34 | logrus.Error("Hello error") 35 | assert.Equal(logrus.ErrorLevel, hook.LastEntry().Level) 36 | assert.Equal("Hello error", hook.LastEntry().Message) 37 | assert.Equal(1, len(hook.Entries)) 38 | 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/json_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | ) 7 | 8 | type JSONFormatter struct { 9 | // TimestampFormat sets the format used for marshaling timestamps. 10 | TimestampFormat string 11 | } 12 | 13 | func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { 14 | data := make(Fields, len(entry.Data)+3) 15 | for k, v := range entry.Data { 16 | switch v := v.(type) { 17 | case error: 18 | // Otherwise errors are ignored by `encoding/json` 19 | // https://github.com/Sirupsen/logrus/issues/137 20 | data[k] = v.Error() 21 | default: 22 | data[k] = v 23 | } 24 | } 25 | prefixFieldClashes(data) 26 | 27 | timestampFormat := f.TimestampFormat 28 | if timestampFormat == "" { 29 | timestampFormat = DefaultTimestampFormat 30 | } 31 | 32 | data["time"] = entry.Time.Format(timestampFormat) 33 | data["msg"] = entry.Message 34 | data["level"] = entry.Level.String() 35 | 36 | serialized, err := json.Marshal(data) 37 | if err != nil { 38 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) 39 | } 40 | return append(serialized, '\n'), nil 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package logrus 4 | 5 | // IsTerminal returns true if stderr's file descriptor is a terminal. 6 | func IsTerminal() bool { 7 | return true 8 | } 9 | -------------------------------------------------------------------------------- /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 | "syscall" 13 | "unsafe" 14 | ) 15 | 16 | // IsTerminal returns true if stderr's file descriptor is a terminal. 17 | func IsTerminal() bool { 18 | fd := syscall.Stderr 19 | var termios Termios 20 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 21 | return err == 0 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris,!appengine 2 | 3 | package logrus 4 | 5 | import ( 6 | "os" 7 | 8 | "golang.org/x/sys/unix" 9 | ) 10 | 11 | // IsTerminal returns true if the given file descriptor is a terminal. 12 | func IsTerminal() bool { 13 | _, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA) 14 | return err == nil 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_windows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build windows,!appengine 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 16 | 17 | var ( 18 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 19 | ) 20 | 21 | // IsTerminal returns true if stderr's file descriptor is a terminal. 22 | func IsTerminal() bool { 23 | fd := syscall.Stderr 24 | var st uint32 25 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 26 | return r != 0 && e == 0 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.5.4 4 | - 1.6.3 5 | - 1.7 6 | install: 7 | - go get -v golang.org/x/tools/cmd/cover 8 | script: 9 | - go test -v -tags=safe ./spew 10 | - go test -v -tags=testcgo ./spew -covermode=count -coverprofile=profile.cov 11 | after_success: 12 | - go get -v github.com/mattn/goveralls 13 | - export PATH=$PATH:$HOME/gopath/bin 14 | - goveralls -coverprofile=profile.cov -service=travis-ci 15 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2012-2013 Dave Collins 4 | 5 | Permission to use, copy, modify, and distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/cov_report.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script uses gocov to generate a test coverage report. 4 | # The gocov tool my be obtained with the following command: 5 | # go get github.com/axw/gocov/gocov 6 | # 7 | # It will be installed to $GOPATH/bin, so ensure that location is in your $PATH. 8 | 9 | # Check for gocov. 10 | if ! type gocov >/dev/null 2>&1; then 11 | echo >&2 "This script requires the gocov tool." 12 | echo >&2 "You may obtain it with the following command:" 13 | echo >&2 "go get github.com/axw/gocov/gocov" 14 | exit 1 15 | fi 16 | 17 | # Only run the cgo tests if gcc is installed. 18 | if type gcc >/dev/null 2>&1; then 19 | (cd spew && gocov test -tags testcgo | gocov report) 20 | else 21 | (cd spew && gocov test | gocov report) 22 | fi 23 | -------------------------------------------------------------------------------- /vendor/github.com/docopt/docopt-go/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | 24 | # coverage droppings 25 | profile.cov 26 | -------------------------------------------------------------------------------- /vendor/github.com/docopt/docopt-go/.travis.yml: -------------------------------------------------------------------------------- 1 | # Travis CI (http://travis-ci.org/) is a continuous integration 2 | # service for open source projects. This file configures it 3 | # to run unit tests for docopt-go. 4 | 5 | language: go 6 | 7 | go: 8 | - 1.4 9 | - 1.5 10 | - tip 11 | 12 | matrix: 13 | fast_finish: true 14 | 15 | before_install: 16 | - go get golang.org/x/tools/cmd/vet 17 | - go get golang.org/x/tools/cmd/cover 18 | - go get github.com/golang/lint/golint 19 | - go get github.com/mattn/goveralls 20 | 21 | install: 22 | - go get -d -v ./... && go build -v ./... 23 | 24 | script: 25 | - go vet -x ./... 26 | - $HOME/gopath/bin/golint ./... 27 | - go test -v ./... 28 | - go test -covermode=count -coverprofile=profile.cov . 29 | 30 | after_script: 31 | - $HOME/gopath/bin/goveralls -coverprofile=profile.cov -service=travis-ci 32 | -------------------------------------------------------------------------------- /vendor/github.com/docopt/docopt-go/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Keith Batten 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/docopt/docopt-go/example_test.go: -------------------------------------------------------------------------------- 1 | package docopt 2 | 3 | import ( 4 | "fmt" 5 | "sort" 6 | ) 7 | 8 | func ExampleParse() { 9 | usage := `Usage: 10 | config_example tcp [] [--force] [--timeout=] 11 | config_example serial [--baud=] [--timeout=] 12 | config_example -h | --help | --version` 13 | // parse the command line `comfig_example tcp 127.0.0.1 --force` 14 | argv := []string{"tcp", "127.0.0.1", "--force"} 15 | arguments, _ := Parse(usage, argv, true, "0.1.1rc", false) 16 | // sort the keys of the arguments map 17 | var keys []string 18 | for k := range arguments { 19 | keys = append(keys, k) 20 | } 21 | sort.Strings(keys) 22 | // print the argument keys and values 23 | for _, k := range keys { 24 | fmt.Printf("%9s %v\n", k, arguments[k]) 25 | } 26 | // output: 27 | // --baud 28 | // --force true 29 | // --help false 30 | // --timeout 31 | // --version false 32 | // -h false 33 | // 127.0.0.1 34 | // 35 | // serial false 36 | // tcp true 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/docopt/docopt-go/examples/arguments/arguments_example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/docopt/docopt-go" 6 | ) 7 | 8 | func main() { 9 | usage := `Usage: arguments_example [-vqrh] [FILE] ... 10 | arguments_example (--left | --right) CORRECTION FILE 11 | 12 | Process FILE and optionally apply correction to either left-hand side or 13 | right-hand side. 14 | 15 | Arguments: 16 | FILE optional input file 17 | CORRECTION correction angle, needs FILE, --left or --right to be present 18 | 19 | Options: 20 | -h --help 21 | -v verbose mode 22 | -q quiet mode 23 | -r make report 24 | --left use left-hand side 25 | --right use right-hand side` 26 | 27 | arguments, _ := docopt.Parse(usage, nil, true, "", false) 28 | fmt.Println(arguments) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/docopt/docopt-go/examples/calculator/calculator_example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/docopt/docopt-go" 6 | ) 7 | 8 | func main() { 9 | usage := `Not a serious example. 10 | 11 | Usage: 12 | calculator_example ( ( + | - | * | / ) )... 13 | calculator_example [( , )]... 14 | calculator_example (-h | --help) 15 | 16 | Examples: 17 | calculator_example 1 + 2 + 3 + 4 + 5 18 | calculator_example 1 + 2 '*' 3 / 4 - 5 # note quotes around '*' 19 | calculator_example sum 10 , 20 , 30 , 40 20 | 21 | Options: 22 | -h, --help 23 | ` 24 | arguments, _ := docopt.Parse(usage, nil, true, "", false) 25 | fmt.Println(arguments) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/docopt/docopt-go/examples/counted/counted_example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/docopt/docopt-go" 6 | ) 7 | 8 | func main() { 9 | usage := `Usage: counted_example --help 10 | counted_example -v... 11 | counted_example go [go] 12 | counted_example (--path=)... 13 | counted_example 14 | 15 | Try: counted_example -vvvvvvvvvv 16 | counted_example go go 17 | counted_example --path ./here --path ./there 18 | counted_example this.txt that.txt` 19 | 20 | arguments, _ := docopt.Parse(usage, nil, true, "", false) 21 | fmt.Println(arguments) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/docopt/docopt-go/examples/git/checkout/git_checkout.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "fmt" 5 | "github.com/docopt/docopt-go" 6 | ) 7 | 8 | func main() { 9 | usage := `usage: git checkout [options] 10 | git checkout [options] -- ... 11 | 12 | options: 13 | -q, --quiet suppress progress reporting 14 | -b create and checkout a new branch 15 | -B create/reset and checkout a branch 16 | -l create reflog for new branch 17 | -t, --track set upstream info for new branch 18 | --orphan 19 | new unparented branch 20 | -2, --ours checkout our version for unmerged files 21 | -3, --theirs checkout their version for unmerged files 22 | -f, --force force checkout (throw away local modifications) 23 | -m, --merge perform a 3-way merge with the new branch 24 | --conflict