├── Godeps ├── Godeps.json ├── Readme └── _workspace │ ├── .gitignore │ └── src │ ├── github.com │ ├── go-gorp │ │ └── gorp │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── column.go │ │ │ ├── db.go │ │ │ ├── dialect.go │ │ │ ├── dialect_mysql.go │ │ │ ├── dialect_oracle.go │ │ │ ├── dialect_postgres.go │ │ │ ├── dialect_sqlite.go │ │ │ ├── dialect_sqlserver.go │ │ │ ├── errors.go │ │ │ ├── gorp.go │ │ │ ├── gorp_test.go │ │ │ ├── hooks.go │ │ │ ├── index.go │ │ │ ├── lockerror.go │ │ │ ├── logging.go │ │ │ ├── nulltypes.go │ │ │ ├── select.go │ │ │ ├── table.go │ │ │ ├── table_bindings.go │ │ │ ├── test_all.sh │ │ │ └── transaction.go │ ├── go-sql-driver │ │ └── mysql │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── AUTHORS │ │ │ ├── CHANGELOG.md │ │ │ ├── CONTRIBUTING.md │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── appengine.go │ │ │ ├── benchmark_test.go │ │ │ ├── buffer.go │ │ │ ├── collations.go │ │ │ ├── connection.go │ │ │ ├── const.go │ │ │ ├── driver.go │ │ │ ├── driver_test.go │ │ │ ├── errors.go │ │ │ ├── errors_test.go │ │ │ ├── infile.go │ │ │ ├── packets.go │ │ │ ├── result.go │ │ │ ├── rows.go │ │ │ ├── statement.go │ │ │ ├── transaction.go │ │ │ ├── utils.go │ │ │ └── utils_test.go │ ├── google │ │ └── certificate-transparency │ │ │ └── go │ │ │ ├── README.md │ │ │ ├── asn1 │ │ │ ├── asn1.go │ │ │ ├── asn1_test.go │ │ │ ├── common.go │ │ │ ├── marshal.go │ │ │ └── marshal_test.go │ │ │ ├── client │ │ │ ├── ctclient │ │ │ │ └── ctclient.go │ │ │ ├── getentries.go │ │ │ ├── logclient.go │ │ │ └── logclient_test.go │ │ │ ├── fixchain │ │ │ ├── containers.go │ │ │ ├── fix.go │ │ │ ├── fix_and_log.go │ │ │ ├── fix_and_log_test.go │ │ │ ├── fix_error.go │ │ │ ├── fix_error_test.go │ │ │ ├── fix_test.go │ │ │ ├── fixer.go │ │ │ ├── fixer_test.go │ │ │ ├── hash.go │ │ │ ├── hash_test.go │ │ │ ├── logger.go │ │ │ ├── logger_test.go │ │ │ ├── main │ │ │ │ └── fixchain.go │ │ │ ├── post.go │ │ │ ├── post_test.go │ │ │ ├── ratelimiter │ │ │ │ ├── limiter.go │ │ │ │ └── limiter_test.go │ │ │ ├── replacements.go │ │ │ ├── test_chains.go │ │ │ ├── test_functions.go │ │ │ ├── test_round_trippers.go │ │ │ ├── test_tests.go │ │ │ └── url_cache.go │ │ │ ├── gossip │ │ │ ├── handler.go │ │ │ ├── handler_test.go │ │ │ ├── main │ │ │ │ └── gossip_server.go │ │ │ ├── storage.go │ │ │ └── types.go │ │ │ ├── jsonclient │ │ │ ├── client.go │ │ │ └── client_test.go │ │ │ ├── merkletree │ │ │ ├── merkle_tree.go │ │ │ ├── merkle_tree_go.cc │ │ │ ├── merkle_tree_go.h │ │ │ ├── merkle_tree_interface.go │ │ │ ├── merkle_tree_test.go │ │ │ ├── merkle_verifier.go │ │ │ ├── merkle_verifier_test.go │ │ │ ├── tree_hasher.go │ │ │ ├── tree_hasher_test.go │ │ │ ├── wrap_merkle_tree.cc │ │ │ ├── wrap_merkle_tree_math.cc │ │ │ ├── wrap_serial_hasher.cc │ │ │ └── wrap_tree_hasher.cc │ │ │ ├── preload │ │ │ ├── dumpscts │ │ │ │ └── main │ │ │ │ │ └── dumpscts.go │ │ │ ├── main │ │ │ │ └── preload.go │ │ │ └── types.go │ │ │ ├── scanner │ │ │ ├── main │ │ │ │ └── scanner.go │ │ │ ├── scanner.go │ │ │ ├── scanner_test.go │ │ │ └── scanner_test_data.go │ │ │ ├── serialization.go │ │ │ ├── serialization_test.go │ │ │ ├── signatures.go │ │ │ ├── signatures_test.go │ │ │ ├── testdata │ │ │ └── keys.go │ │ │ ├── tls │ │ │ ├── signature.go │ │ │ ├── signature_test.go │ │ │ ├── tls.go │ │ │ ├── tls_test.go │ │ │ ├── types.go │ │ │ └── types_test.go │ │ │ ├── types.go │ │ │ ├── types_test.go │ │ │ ├── x509 │ │ │ ├── cert_pool.go │ │ │ ├── example_test.go │ │ │ ├── pem_decrypt.go │ │ │ ├── pem_decrypt_test.go │ │ │ ├── pkcs1.go │ │ │ ├── pkcs8.go │ │ │ ├── pkcs8_test.go │ │ │ ├── pkix │ │ │ │ └── pkix.go │ │ │ ├── root.go │ │ │ ├── root_bsd.go │ │ │ ├── root_cgo_darwin.go │ │ │ ├── root_darwin.go │ │ │ ├── root_darwin_arm_gen.go │ │ │ ├── root_darwin_armx.go │ │ │ ├── root_darwin_test.go │ │ │ ├── root_linux.go │ │ │ ├── root_nacl.go │ │ │ ├── root_nocgo_darwin.go │ │ │ ├── root_plan9.go │ │ │ ├── root_solaris.go │ │ │ ├── root_stub.go │ │ │ ├── root_unix.go │ │ │ ├── root_windows.go │ │ │ ├── sec1.go │ │ │ ├── sec1_test.go │ │ │ ├── sha2_windows_test.go │ │ │ ├── verify.go │ │ │ ├── verify_test.go │ │ │ ├── x509.go │ │ │ ├── x509_test.go │ │ │ └── x509_test_import.go │ │ │ └── x509util │ │ │ └── x509util.go │ ├── jpillora │ │ └── backoff │ │ │ ├── README.md │ │ │ ├── backoff.go │ │ │ └── backoff_test.go │ ├── oschwald │ │ ├── geoip2-golang │ │ │ ├── .gitmodules │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── example_test.go │ │ │ ├── reader.go │ │ │ ├── reader_test.go │ │ │ └── test-data │ │ │ │ ├── .gitattributes │ │ │ │ ├── .gitconfig │ │ │ │ ├── .gitignore │ │ │ │ ├── .perltidyallrc │ │ │ │ ├── .tidyallrc │ │ │ │ ├── LICENSE │ │ │ │ ├── MaxMind-DB-spec.md │ │ │ │ ├── README.md │ │ │ │ ├── perltidyrc │ │ │ │ ├── source-data │ │ │ │ ├── GeoIP2-Anonymous-IP-Test.json │ │ │ │ ├── GeoIP2-City-Test.json │ │ │ │ ├── GeoIP2-Connection-Type-Test.json │ │ │ │ ├── GeoIP2-Country-Test.json │ │ │ │ ├── GeoIP2-Domain-Test.json │ │ │ │ ├── GeoIP2-Enterprise-Test.json │ │ │ │ ├── GeoIP2-ISP-Test.json │ │ │ │ ├── GeoIP2-Precision-City-Test.json │ │ │ │ ├── GeoIP2-Precision-ISP-Test.json │ │ │ │ └── README │ │ │ │ ├── test-data │ │ │ │ ├── GeoIP2-Anonymous-IP-Test.mmdb │ │ │ │ ├── GeoIP2-City-Test-Broken-Double-Format.mmdb │ │ │ │ ├── GeoIP2-City-Test-Invalid-Node-Count.mmdb │ │ │ │ ├── GeoIP2-City-Test.mmdb │ │ │ │ ├── GeoIP2-Connection-Type-Test.mmdb │ │ │ │ ├── GeoIP2-Country-Test.mmdb │ │ │ │ ├── GeoIP2-Domain-Test.mmdb │ │ │ │ ├── GeoIP2-Enterprise-Test.mmdb │ │ │ │ ├── GeoIP2-ISP-Test.mmdb │ │ │ │ ├── GeoIP2-Precision-City-Test.mmdb │ │ │ │ ├── GeoIP2-Precision-ISP-Test.mmdb │ │ │ │ ├── MaxMind-DB-no-ipv4-search-tree.mmdb │ │ │ │ ├── MaxMind-DB-string-value-entries.mmdb │ │ │ │ ├── MaxMind-DB-test-broken-pointers-24.mmdb │ │ │ │ ├── MaxMind-DB-test-broken-search-tree-24.mmdb │ │ │ │ ├── MaxMind-DB-test-decoder.mmdb │ │ │ │ ├── MaxMind-DB-test-ipv4-24.mmdb │ │ │ │ ├── MaxMind-DB-test-ipv4-28.mmdb │ │ │ │ ├── MaxMind-DB-test-ipv4-32.mmdb │ │ │ │ ├── MaxMind-DB-test-ipv6-24.mmdb │ │ │ │ ├── MaxMind-DB-test-ipv6-28.mmdb │ │ │ │ ├── MaxMind-DB-test-ipv6-32.mmdb │ │ │ │ ├── MaxMind-DB-test-metadata-pointers.mmdb │ │ │ │ ├── MaxMind-DB-test-mixed-24.mmdb │ │ │ │ ├── MaxMind-DB-test-mixed-28.mmdb │ │ │ │ ├── MaxMind-DB-test-mixed-32.mmdb │ │ │ │ ├── MaxMind-DB-test-nested.mmdb │ │ │ │ ├── README.md │ │ │ │ ├── maps-with-pointers.raw │ │ │ │ └── write-test-data.pl │ │ │ │ └── tidyall.ini │ │ └── maxminddb-golang │ │ │ ├── .gitmodules │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── appveyor.yml │ │ │ ├── decoder.go │ │ │ ├── decoder_test.go │ │ │ ├── errors.go │ │ │ ├── example_test.go │ │ │ ├── key_appengine.go │ │ │ ├── key_other.go │ │ │ ├── mmap_unix.go │ │ │ ├── mmap_windows.go │ │ │ ├── reader.go │ │ │ ├── reader_appengine.go │ │ │ ├── reader_other.go │ │ │ ├── reader_test.go │ │ │ ├── test-data │ │ │ ├── .gitattributes │ │ │ ├── .gitconfig │ │ │ ├── .gitignore │ │ │ ├── .perltidyallrc │ │ │ ├── .tidyallrc │ │ │ ├── LICENSE │ │ │ ├── MaxMind-DB-spec.md │ │ │ ├── README.md │ │ │ ├── perltidyrc │ │ │ ├── source-data │ │ │ │ ├── GeoIP2-Anonymous-IP-Test.json │ │ │ │ ├── GeoIP2-City-Test.json │ │ │ │ ├── GeoIP2-Connection-Type-Test.json │ │ │ │ ├── GeoIP2-Country-Test.json │ │ │ │ ├── GeoIP2-Domain-Test.json │ │ │ │ ├── GeoIP2-Enterprise-Test.json │ │ │ │ ├── GeoIP2-ISP-Test.json │ │ │ │ ├── GeoIP2-Precision-City-Test.json │ │ │ │ ├── GeoIP2-Precision-ISP-Test.json │ │ │ │ └── README │ │ │ ├── test-data │ │ │ │ ├── GeoIP2-Anonymous-IP-Test.mmdb │ │ │ │ ├── GeoIP2-City-Test-Broken-Double-Format.mmdb │ │ │ │ ├── GeoIP2-City-Test-Invalid-Node-Count.mmdb │ │ │ │ ├── GeoIP2-City-Test.mmdb │ │ │ │ ├── GeoIP2-Connection-Type-Test.mmdb │ │ │ │ ├── GeoIP2-Country-Test.mmdb │ │ │ │ ├── GeoIP2-Domain-Test.mmdb │ │ │ │ ├── GeoIP2-Enterprise-Test.mmdb │ │ │ │ ├── GeoIP2-ISP-Test.mmdb │ │ │ │ ├── GeoIP2-Precision-City-Test.mmdb │ │ │ │ ├── GeoIP2-Precision-ISP-Test.mmdb │ │ │ │ ├── MaxMind-DB-no-ipv4-search-tree.mmdb │ │ │ │ ├── MaxMind-DB-string-value-entries.mmdb │ │ │ │ ├── MaxMind-DB-test-broken-pointers-24.mmdb │ │ │ │ ├── MaxMind-DB-test-broken-search-tree-24.mmdb │ │ │ │ ├── MaxMind-DB-test-decoder.mmdb │ │ │ │ ├── MaxMind-DB-test-ipv4-24.mmdb │ │ │ │ ├── MaxMind-DB-test-ipv4-28.mmdb │ │ │ │ ├── MaxMind-DB-test-ipv4-32.mmdb │ │ │ │ ├── MaxMind-DB-test-ipv6-24.mmdb │ │ │ │ ├── MaxMind-DB-test-ipv6-28.mmdb │ │ │ │ ├── MaxMind-DB-test-ipv6-32.mmdb │ │ │ │ ├── MaxMind-DB-test-metadata-pointers.mmdb │ │ │ │ ├── MaxMind-DB-test-mixed-24.mmdb │ │ │ │ ├── MaxMind-DB-test-mixed-28.mmdb │ │ │ │ ├── MaxMind-DB-test-mixed-32.mmdb │ │ │ │ ├── MaxMind-DB-test-nested.mmdb │ │ │ │ ├── README.md │ │ │ │ ├── maps-with-pointers.raw │ │ │ │ └── write-test-data.pl │ │ │ └── tidyall.ini │ │ │ ├── traverse.go │ │ │ ├── traverse_test.go │ │ │ ├── verifier.go │ │ │ └── verifier_test.go │ └── vharitonsky │ │ └── iniflags │ │ ├── .gitignore │ │ ├── LICENSE │ │ ├── README.md │ │ ├── iniflags.go │ │ ├── iniflags_test.go │ │ ├── test_bom.ini │ │ ├── test_config.ini │ │ ├── test_config2.ini │ │ └── test_setconfigfile.ini │ └── golang.org │ └── x │ ├── net │ ├── context │ │ ├── context.go │ │ ├── context_test.go │ │ ├── ctxhttp │ │ │ ├── ctxhttp.go │ │ │ ├── ctxhttp_17_test.go │ │ │ ├── ctxhttp_pre17.go │ │ │ ├── ctxhttp_pre17_test.go │ │ │ └── ctxhttp_test.go │ │ ├── go17.go │ │ ├── pre_go17.go │ │ └── withtimeout_test.go │ └── publicsuffix │ │ ├── gen.go │ │ ├── list.go │ │ ├── list_test.go │ │ ├── table.go │ │ └── table_test.go │ └── sys │ └── 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_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 │ ├── 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_arm.go │ ├── syscall_linux_arm64.go │ ├── syscall_linux_mips64x.go │ ├── syscall_linux_ppc64x.go │ ├── syscall_linux_s390x.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_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_mips64.go │ ├── zerrors_linux_mips64le.go │ ├── zerrors_linux_ppc64.go │ ├── zerrors_linux_ppc64le.go │ ├── zerrors_linux_s390x.go │ ├── zerrors_netbsd_386.go │ ├── zerrors_netbsd_amd64.go │ ├── zerrors_netbsd_arm.go │ ├── zerrors_openbsd_386.go │ ├── zerrors_openbsd_amd64.go │ ├── zerrors_solaris_amd64.go │ ├── zsyscall_darwin_386.go │ ├── zsyscall_darwin_amd64.go │ ├── zsyscall_darwin_arm.go │ ├── zsyscall_darwin_arm64.go │ ├── zsyscall_dragonfly_amd64.go │ ├── zsyscall_freebsd_386.go │ ├── zsyscall_freebsd_amd64.go │ ├── zsyscall_freebsd_arm.go │ ├── zsyscall_linux_386.go │ ├── zsyscall_linux_amd64.go │ ├── zsyscall_linux_arm.go │ ├── zsyscall_linux_arm64.go │ ├── zsyscall_linux_mips64.go │ ├── zsyscall_linux_mips64le.go │ ├── zsyscall_linux_ppc64.go │ ├── zsyscall_linux_ppc64le.go │ ├── zsyscall_linux_s390x.go │ ├── zsyscall_netbsd_386.go │ ├── zsyscall_netbsd_amd64.go │ ├── zsyscall_netbsd_arm.go │ ├── zsyscall_openbsd_386.go │ ├── zsyscall_openbsd_amd64.go │ ├── zsyscall_solaris_amd64.go │ ├── zsysctl_openbsd.go │ ├── zsysnum_darwin_386.go │ ├── zsysnum_darwin_amd64.go │ ├── zsysnum_darwin_arm.go │ ├── zsysnum_darwin_arm64.go │ ├── zsysnum_dragonfly_amd64.go │ ├── zsysnum_freebsd_386.go │ ├── zsysnum_freebsd_amd64.go │ ├── zsysnum_freebsd_arm.go │ ├── zsysnum_linux_386.go │ ├── zsysnum_linux_amd64.go │ ├── zsysnum_linux_arm.go │ ├── zsysnum_linux_arm64.go │ ├── zsysnum_linux_mips64.go │ ├── zsysnum_linux_mips64le.go │ ├── zsysnum_linux_ppc64.go │ ├── zsysnum_linux_ppc64le.go │ ├── zsysnum_linux_s390x.go │ ├── zsysnum_netbsd_386.go │ ├── zsysnum_netbsd_amd64.go │ ├── zsysnum_netbsd_arm.go │ ├── zsysnum_openbsd_386.go │ ├── zsysnum_openbsd_amd64.go │ ├── zsysnum_solaris_amd64.go │ ├── ztypes_darwin_386.go │ ├── ztypes_darwin_amd64.go │ ├── ztypes_darwin_arm.go │ ├── ztypes_darwin_arm64.go │ ├── ztypes_dragonfly_amd64.go │ ├── ztypes_freebsd_386.go │ ├── ztypes_freebsd_amd64.go │ ├── ztypes_freebsd_arm.go │ ├── ztypes_linux_386.go │ ├── ztypes_linux_amd64.go │ ├── ztypes_linux_arm.go │ ├── ztypes_linux_arm64.go │ ├── ztypes_linux_mips64.go │ ├── ztypes_linux_mips64le.go │ ├── ztypes_linux_ppc64.go │ ├── ztypes_linux_ppc64le.go │ ├── ztypes_linux_s390x.go │ ├── ztypes_netbsd_386.go │ ├── ztypes_netbsd_amd64.go │ ├── ztypes_netbsd_arm.go │ ├── ztypes_openbsd_386.go │ ├── ztypes_openbsd_amd64.go │ └── ztypes_solaris_amd64.go ├── LICENSE.txt ├── README.md ├── censysdata └── importer.go ├── cmd ├── ct-sql-netscan │ └── main.go ├── ct-sql │ └── main.go ├── get-cert │ └── get-cert.go └── telemetry-update │ └── main.go ├── db ├── dbconf.yml └── migrations │ ├── 20160608134225_initial.sql │ ├── 20160815094841_netscan-indicies.sql │ ├── 20160817112844_certificate-indicies.sql │ ├── 20160826153558_add_netscan_queue.sql │ ├── 20161014140240_add-firefox-pageload-telemetry.sql │ ├── 20161031093138_shard_new_old.sql │ ├── 20161031214332_use_dates_in_shard.sql │ ├── 20161103131125_remove_extra_indices.sql │ ├── 20161103164403_add_foreign_keys.sql │ └── 20161108011748_reduce_types_to_int.sql ├── firefox-telemetry └── firefox-telemetry.go ├── sqldb └── sqldb.go └── utils ├── config.go ├── conversions.go ├── folderdb.go └── progressmonitor.go /Godeps/Godeps.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImportPath": "github.com/jcjones/ct-sql", 3 | "GoVersion": "go1.6.2", 4 | "Packages": [ 5 | "./cmd/ct-sql/", 6 | "./cmd/ct-sql-netscan/", 7 | "./cmd/telemetry-update/", 8 | "./cmd/get-cert/" 9 | ], 10 | "Deps": [ 11 | { 12 | "ImportPath": "github.com/go-gorp/gorp", 13 | "Comment": "v1.7-180-g2f6d659", 14 | "Rev": "2f6d659f47d958a61a41cf8a5512d840330901bd" 15 | }, 16 | { 17 | "ImportPath": "github.com/go-sql-driver/mysql", 18 | "Comment": "v1.2-88-ga197e5d", 19 | "Rev": "a197e5d40516f2e9f74dcee085a5f2d4604e94df" 20 | }, 21 | { 22 | "ImportPath": "github.com/google/certificate-transparency/go", 23 | "Rev": "59647d288fd35bda8af7d18ca7a9be2feaa687e2" 24 | }, 25 | { 26 | "ImportPath": "github.com/jpillora/backoff", 27 | "Rev": "2ff7c4694083b5dbd71b21fd7cb7577477a74b31" 28 | }, 29 | { 30 | "ImportPath": "github.com/oschwald/geoip2-golang", 31 | "Comment": "v0.1.0-31-gb8dbdc3", 32 | "Rev": "b8dbdc368b6db46de50f7eecf7a7a31b4822aa00" 33 | }, 34 | { 35 | "ImportPath": "github.com/oschwald/maxminddb-golang", 36 | "Comment": "v0.2.0-52-g03a3fea", 37 | "Rev": "03a3feaec4e514002b446197c10e8ee50e39574c" 38 | }, 39 | { 40 | "ImportPath": "github.com/vharitonsky/iniflags", 41 | "Comment": "v.1.0-30-g743d690", 42 | "Rev": "743d6901e7ca8ab61ac533a8c49939ac8b560e72" 43 | }, 44 | { 45 | "ImportPath": "golang.org/x/net/context", 46 | "Rev": "4971afdc2f162e82d185353533d3cf16188a9f4e" 47 | }, 48 | { 49 | "ImportPath": "golang.org/x/net/publicsuffix", 50 | "Rev": "4971afdc2f162e82d185353533d3cf16188a9f4e" 51 | }, 52 | { 53 | "ImportPath": "golang.org/x/sys/unix", 54 | "Rev": "076b546753157f758b316e59bcb51e6807c04057" 55 | } 56 | ] 57 | } 58 | -------------------------------------------------------------------------------- /Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /Godeps/_workspace/.gitignore: -------------------------------------------------------------------------------- 1 | /pkg 2 | /bin 3 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/go-gorp/gorp/.gitignore: -------------------------------------------------------------------------------- 1 | _test 2 | _testmain.go 3 | _obj 4 | *~ 5 | *.6 6 | 6.out 7 | gorptest.bin 8 | tmp 9 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/go-gorp/gorp/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.3 4 | - 1.4 5 | - tip 6 | 7 | services: 8 | - mysql 9 | - postgres 10 | - sqlite3 11 | 12 | env: 13 | global: 14 | - secure: RriLxF6+2yMl67hdVv8ImXlu0h62mhcpqjaOgYNU+IEbUQ7hx96CKY6gkpYubW3BgApvF5RH6j3+HKvh2kGp0XhDOYOQCODfBSaSipZ5Aa5RKjsEYLtuVIobvJ80awR9hUeql69+WXs0/s72WThG0qTbOUY4pqHWfteeY235hWM= 15 | 16 | before_script: 17 | - mysql -e "CREATE DATABASE gorptest;" 18 | - mysql -u root -e "GRANT ALL ON gorptest.* TO gorptest@localhost IDENTIFIED BY 'gorptest'" 19 | - psql -c "CREATE DATABASE gorptest;" -U postgres 20 | - psql -c "CREATE USER "gorptest" WITH SUPERUSER PASSWORD 'gorptest';" -U postgres 21 | - go get github.com/lib/pq 22 | - go get github.com/mattn/go-sqlite3 23 | - go get github.com/ziutek/mymysql/godrv 24 | - go get github.com/go-sql-driver/mysql 25 | - go get golang.org/x/tools/cmd/cover 26 | - go get github.com/mattn/goveralls 27 | 28 | script: ./test_all.sh 29 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/go-gorp/gorp/LICENSE: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2012 James Cooper 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | 'Software'), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/go-gorp/gorp/errors.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 James Cooper. All rights reserved. 2 | // Use of this source code is governed by a MIT-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package gorp provides a simple way to marshal Go structs to and from 6 | // SQL databases. It uses the database/sql package, and should work with any 7 | // compliant database/sql driver. 8 | // 9 | // Source code and project home: 10 | // https://github.com/go-gorp/gorp 11 | 12 | package gorp 13 | 14 | import ( 15 | "fmt" 16 | ) 17 | 18 | // A non-fatal error, when a select query returns columns that do not exist 19 | // as fields in the struct it is being mapped to 20 | // TODO: discuss wether this needs an error. encoding/json silently ignores missing fields 21 | type NoFieldInTypeError struct { 22 | TypeName string 23 | MissingColNames []string 24 | } 25 | 26 | func (err *NoFieldInTypeError) Error() string { 27 | return fmt.Sprintf("gorp: no fields %+v in type %s", err.MissingColNames, err.TypeName) 28 | } 29 | 30 | // returns true if the error is non-fatal (ie, we shouldn't immediately return) 31 | func NonFatalError(err error) bool { 32 | switch err.(type) { 33 | case *NoFieldInTypeError: 34 | return true 35 | default: 36 | return false 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/go-gorp/gorp/hooks.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 James Cooper. All rights reserved. 2 | // Use of this source code is governed by a MIT-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package gorp provides a simple way to marshal Go structs to and from 6 | // SQL databases. It uses the database/sql package, and should work with any 7 | // compliant database/sql driver. 8 | // 9 | // Source code and project home: 10 | // https://github.com/go-gorp/gorp 11 | 12 | package gorp 13 | 14 | //++ TODO v2-phase3: HasPostGet => PostGetter, HasPostDelete => PostDeleter, etc. 15 | 16 | // PostUpdate() will be executed after the GET statement. 17 | type HasPostGet interface { 18 | PostGet(SqlExecutor) error 19 | } 20 | 21 | // PostUpdate() will be executed after the DELETE statement 22 | type HasPostDelete interface { 23 | PostDelete(SqlExecutor) error 24 | } 25 | 26 | // PostUpdate() will be executed after the UPDATE statement 27 | type HasPostUpdate interface { 28 | PostUpdate(SqlExecutor) error 29 | } 30 | 31 | // PostInsert() will be executed after the INSERT statement 32 | type HasPostInsert interface { 33 | PostInsert(SqlExecutor) error 34 | } 35 | 36 | // PreDelete() will be executed before the DELETE statement. 37 | type HasPreDelete interface { 38 | PreDelete(SqlExecutor) error 39 | } 40 | 41 | // PreUpdate() will be executed before UPDATE statement. 42 | type HasPreUpdate interface { 43 | PreUpdate(SqlExecutor) error 44 | } 45 | 46 | // PreInsert() will be executed before INSERT statement. 47 | type HasPreInsert interface { 48 | PreInsert(SqlExecutor) error 49 | } 50 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/go-gorp/gorp/index.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 James Cooper. All rights reserved. 2 | // Use of this source code is governed by a MIT-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package gorp provides a simple way to marshal Go structs to and from 6 | // SQL databases. It uses the database/sql package, and should work with any 7 | // compliant database/sql driver. 8 | // 9 | // Source code and project home: 10 | // https://github.com/go-gorp/gorp 11 | 12 | package gorp 13 | 14 | // IndexMap represents a mapping between a Go struct field and a single 15 | // index in a table. 16 | // Unique and MaxSize only inform the 17 | // CreateTables() function and are not used by Insert/Update/Delete/Get. 18 | type IndexMap struct { 19 | // Index name in db table 20 | IndexName string 21 | 22 | // If true, " unique" is added to create index statements. 23 | // Not used elsewhere 24 | Unique bool 25 | 26 | // Index type supported by Dialect 27 | // Postgres: B-tree, Hash, GiST and GIN. 28 | // Mysql: Btree, Hash. 29 | // Sqlite: nil. 30 | IndexType string 31 | 32 | // Columns name for single and multiple indexes 33 | columns []string 34 | } 35 | 36 | // Rename allows you to specify the index name in the table 37 | // 38 | // Example: table.IndMap("customer_test_idx").Rename("customer_idx") 39 | // 40 | func (idx *IndexMap) Rename(indname string) *IndexMap { 41 | idx.IndexName = indname 42 | return idx 43 | } 44 | 45 | // SetUnique adds "unique" to the create index statements for this 46 | // index, if b is true. 47 | func (idx *IndexMap) SetUnique(b bool) *IndexMap { 48 | idx.Unique = b 49 | return idx 50 | } 51 | 52 | // SetIndexType specifies the index type supported by chousen SQL Dialect 53 | func (idx *IndexMap) SetIndexType(indtype string) *IndexMap { 54 | idx.IndexType = indtype 55 | return idx 56 | } 57 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/go-gorp/gorp/lockerror.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 James Cooper. All rights reserved. 2 | // Use of this source code is governed by a MIT-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package gorp provides a simple way to marshal Go structs to and from 6 | // SQL databases. It uses the database/sql package, and should work with any 7 | // compliant database/sql driver. 8 | // 9 | // Source code and project home: 10 | // https://github.com/go-gorp/gorp 11 | 12 | package gorp 13 | 14 | import ( 15 | "fmt" 16 | "reflect" 17 | ) 18 | 19 | // OptimisticLockError is returned by Update() or Delete() if the 20 | // struct being modified has a Version field and the value is not equal to 21 | // the current value in the database 22 | type OptimisticLockError struct { 23 | // Table name where the lock error occurred 24 | TableName string 25 | 26 | // Primary key values of the row being updated/deleted 27 | Keys []interface{} 28 | 29 | // true if a row was found with those keys, indicating the 30 | // LocalVersion is stale. false if no value was found with those 31 | // keys, suggesting the row has been deleted since loaded, or 32 | // was never inserted to begin with 33 | RowExists bool 34 | 35 | // Version value on the struct passed to Update/Delete. This value is 36 | // out of sync with the database. 37 | LocalVersion int64 38 | } 39 | 40 | // Error returns a description of the cause of the lock error 41 | func (e OptimisticLockError) Error() string { 42 | if e.RowExists { 43 | return fmt.Sprintf("gorp: OptimisticLockError table=%s keys=%v out of date version=%d", e.TableName, e.Keys, e.LocalVersion) 44 | } 45 | 46 | return fmt.Sprintf("gorp: OptimisticLockError no row found for table=%s keys=%v", e.TableName, e.Keys) 47 | } 48 | 49 | func lockError(m *DbMap, exec SqlExecutor, tableName string, 50 | existingVer int64, elem reflect.Value, 51 | keys ...interface{}) (int64, error) { 52 | 53 | existing, err := get(m, exec, elem.Interface(), keys...) 54 | if err != nil { 55 | return -1, err 56 | } 57 | 58 | ole := OptimisticLockError{tableName, keys, true, existingVer} 59 | if existing == nil { 60 | ole.RowExists = false 61 | } 62 | return -1, ole 63 | } 64 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/go-gorp/gorp/logging.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 James Cooper. All rights reserved. 2 | // Use of this source code is governed by a MIT-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package gorp provides a simple way to marshal Go structs to and from 6 | // SQL databases. It uses the database/sql package, and should work with any 7 | // compliant database/sql driver. 8 | // 9 | // Source code and project home: 10 | // https://github.com/go-gorp/gorp 11 | 12 | package gorp 13 | 14 | import "fmt" 15 | 16 | type GorpLogger interface { 17 | Printf(format string, v ...interface{}) 18 | } 19 | 20 | // TraceOn turns on SQL statement logging for this DbMap. After this is 21 | // called, all SQL statements will be sent to the logger. If prefix is 22 | // a non-empty string, it will be written to the front of all logged 23 | // strings, which can aid in filtering log lines. 24 | // 25 | // Use TraceOn if you want to spy on the SQL statements that gorp 26 | // generates. 27 | // 28 | // Note that the base log.Logger type satisfies GorpLogger, but adapters can 29 | // easily be written for other logging packages (e.g., the golang-sanctioned 30 | // glog framework). 31 | func (m *DbMap) TraceOn(prefix string, logger GorpLogger) { 32 | m.logger = logger 33 | if prefix == "" { 34 | m.logPrefix = prefix 35 | } else { 36 | m.logPrefix = fmt.Sprintf("%s ", prefix) 37 | } 38 | } 39 | 40 | // TraceOff turns off tracing. It is idempotent. 41 | func (m *DbMap) TraceOff() { 42 | m.logger = nil 43 | m.logPrefix = "" 44 | } 45 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/go-gorp/gorp/nulltypes.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 James Cooper. All rights reserved. 2 | // Use of this source code is governed by a MIT-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package gorp provides a simple way to marshal Go structs to and from 6 | // SQL databases. It uses the database/sql package, and should work with any 7 | // compliant database/sql driver. 8 | // 9 | // Source code and project home: 10 | // https://github.com/go-gorp/gorp 11 | 12 | package gorp 13 | 14 | import ( 15 | "database/sql/driver" 16 | "time" 17 | ) 18 | 19 | // A nullable Time value 20 | type NullTime struct { 21 | Time time.Time 22 | Valid bool // Valid is true if Time is not NULL 23 | } 24 | 25 | // Scan implements the Scanner interface. 26 | func (nt *NullTime) Scan(value interface{}) error { 27 | switch t := value.(type) { 28 | case time.Time: 29 | nt.Time, nt.Valid = t, true 30 | case []byte: 31 | nt.Valid = false 32 | for _, dtfmt := range []string{ 33 | "2006-01-02 15:04:05.999999999", 34 | "2006-01-02T15:04:05.999999999", 35 | "2006-01-02 15:04:05", 36 | "2006-01-02T15:04:05", 37 | "2006-01-02 15:04", 38 | "2006-01-02T15:04", 39 | "2006-01-02", 40 | "2006-01-02 15:04:05-07:00", 41 | } { 42 | var err error 43 | if nt.Time, err = time.Parse(dtfmt, string(t)); err == nil { 44 | nt.Valid = true 45 | break 46 | } 47 | } 48 | } 49 | return nil 50 | } 51 | 52 | // Value implements the driver Valuer interface. 53 | func (nt NullTime) Value() (driver.Value, error) { 54 | if !nt.Valid { 55 | return nil, nil 56 | } 57 | return nt.Time, nil 58 | } 59 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/go-gorp/gorp/test_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # on macs, you may need to: 4 | # export GOBUILDFLAG=-ldflags -linkmode=external 5 | 6 | coveralls_testflags="-v -covermode=count -coverprofile=coverage.out" 7 | 8 | echo "Testing against mysql" 9 | export GORP_TEST_DSN=gorptest/gorptest/gorptest 10 | export GORP_TEST_DIALECT=mysql 11 | go test $coveralls_testflags $GOBUILDFLAG $@ . 12 | 13 | echo "Testing against gomysql" 14 | export GORP_TEST_DSN=gorptest:gorptest@/gorptest 15 | export GORP_TEST_DIALECT=gomysql 16 | go test $coveralls_testflags $GOBUILDFLAG $@ . 17 | 18 | echo "Testing against postgres" 19 | export GORP_TEST_DSN="user=gorptest password=gorptest dbname=gorptest sslmode=disable" 20 | export GORP_TEST_DIALECT=postgres 21 | go test $coveralls_testflags $GOBUILDFLAG $@ . 22 | 23 | echo "Testing against sqlite" 24 | export GORP_TEST_DSN=/tmp/gorptest.bin 25 | export GORP_TEST_DIALECT=sqlite 26 | go test $coveralls_testflags $GOBUILDFLAG $@ . 27 | rm -f /tmp/gorptest.bin 28 | 29 | case $(go version) in 30 | *go1.4*) 31 | if [ "$(type -p goveralls)" != "" ]; then 32 | goveralls -covermode=count -coverprofile=coverage.out -service=travis-ci 33 | elif [ -x $HOME/gopath/bin/goveralls ]; then 34 | $HOME/gopath/bin/goveralls -covermode=count -coverprofile=coverage.out -service=travis-ci 35 | fi 36 | ;; 37 | *) ;; 38 | esac 39 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/go-sql-driver/mysql/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .DS_Store? 3 | ._* 4 | .Spotlight-V100 5 | .Trashes 6 | Icon? 7 | ehthumbs.db 8 | Thumbs.db 9 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/go-sql-driver/mysql/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go: 4 | - 1.2 5 | - 1.3 6 | - 1.4 7 | - tip 8 | 9 | before_script: 10 | - mysql -e 'create database gotest;' 11 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/go-sql-driver/mysql/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of Go-MySQL-Driver authors for copyright purposes. 2 | 3 | # If you are submitting a patch, please add your name or the name of the 4 | # organization which holds the copyright to this list in alphabetical order. 5 | 6 | # Names should be added to this file as 7 | # Name 8 | # The email address is not required for organizations. 9 | # Please keep the list sorted. 10 | 11 | 12 | # Individual Persons 13 | 14 | Aaron Hopkins 15 | Arne Hormann 16 | Carlos Nieto 17 | Chris Moos 18 | DisposaBoy 19 | Frederick Mayle 20 | Gustavo Kristic 21 | Hanno Braun 22 | Henri Yandell 23 | INADA Naoki 24 | James Harr 25 | Jian Zhen 26 | Julien Schmidt 27 | Kamil Dziedzic 28 | Leonardo YongUk Kim 29 | Lucas Liu 30 | Luke Scott 31 | Michael Woolnough 32 | Nicola Peduzzi 33 | Runrioter Wung 34 | Xiaobing Jiang 35 | Xiuming Chen 36 | 37 | # Organizations 38 | 39 | Barracuda Networks, Inc. 40 | Google Inc. 41 | Stripe Inc. 42 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | Please provide the following minimum information: 8 | * Your Go-MySQL-Driver version (or git SHA) 9 | * Your Go version (run `go version` in your console) 10 | * A detailed issue description 11 | * Error Log if present 12 | * If possible, a short example 13 | 14 | 15 | ## Contributing Code 16 | 17 | By contributing to this project, you share your code under the Mozilla Public License 2, as specified in the LICENSE file. 18 | Don't forget to add yourself to the AUTHORS file. 19 | 20 | ### Pull Requests Checklist 21 | 22 | Please check the following points before submitting your pull request: 23 | - [x] Code compiles correctly 24 | - [x] Created tests, if possible 25 | - [x] All tests pass 26 | - [x] Extended the README / documentation, if necessary 27 | - [x] Added yourself to the AUTHORS file 28 | 29 | ### Code Review 30 | 31 | Everyone is invited to review and comment on pull requests. 32 | If it looks fine to you, comment with "LGTM" (Looks good to me). 33 | 34 | If changes are required, notice the reviewers with "PTAL" (Please take another look) after committing the fixes. 35 | 36 | Before merging the Pull Request, at least one [team member](https://github.com/go-sql-driver?tab=members) must have commented with "LGTM". 37 | 38 | ## Development Ideas 39 | 40 | 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. 41 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/go-sql-driver/mysql/errors_test.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 | package mysql 10 | 11 | import ( 12 | "bytes" 13 | "log" 14 | "testing" 15 | ) 16 | 17 | func TestErrorsSetLogger(t *testing.T) { 18 | previous := errLog 19 | defer func() { 20 | errLog = previous 21 | }() 22 | 23 | // set up logger 24 | const expected = "prefix: test\n" 25 | buffer := bytes.NewBuffer(make([]byte, 0, 64)) 26 | logger := log.New(buffer, "prefix: ", 0) 27 | 28 | // print 29 | SetLogger(logger) 30 | errLog.Print("test") 31 | 32 | // check result 33 | if actual := buffer.String(); actual != expected { 34 | t.Errorf("expected %q, got %q", expected, actual) 35 | } 36 | } 37 | 38 | func TestErrorsStrictIgnoreNotes(t *testing.T) { 39 | runTests(t, dsn+"&sql_notes=false", func(dbt *DBTest) { 40 | dbt.mustExec("DROP TABLE IF EXISTS does_not_exist") 41 | }) 42 | } 43 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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.netConn == nil { 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.netConn == nil { 26 | return ErrInvalidConn 27 | } 28 | err = tx.mc.exec("ROLLBACK") 29 | tx.mc = nil 30 | return 31 | } 32 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/README.md: -------------------------------------------------------------------------------- 1 | This is the really early beginnings of a certificate transparency log 2 | client written in Go, along with a log scanner tool. 3 | 4 | You'll need go v1.1 or higher to compile. 5 | 6 | # Installation 7 | 8 | This go code must be imported into your go workspace before you can 9 | use it, which can be done with: 10 | 11 | go get github.com/google/certificate-transparency/go/client 12 | go get github.com/google/certificate-transparency/go/scanner 13 | etc. 14 | 15 | # Building the binaries 16 | 17 | To compile the log scanner run: 18 | 19 | go build github.com/google/certificate-transparency/go/scanner/main/scanner.go 20 | 21 | # Contributing 22 | 23 | When sending pull requests, please ensure that everything's been run 24 | through ```gofmt``` beforehand so we can keep everything nice and 25 | tidy. 26 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/fixchain/containers.go: -------------------------------------------------------------------------------- 1 | package fixchain 2 | 3 | import ( 4 | "sync" 5 | 6 | "github.com/google/certificate-transparency/go/x509" 7 | ) 8 | 9 | type dedupedChain struct { 10 | certs []*x509.Certificate 11 | } 12 | 13 | func (d *dedupedChain) addCert(cert *x509.Certificate) { 14 | // Check that the certificate isn't being added twice. 15 | for _, c := range d.certs { 16 | if c.Equal(cert) { 17 | return 18 | } 19 | } 20 | d.certs = append(d.certs, cert) 21 | } 22 | 23 | func (d *dedupedChain) addCertToFront(cert *x509.Certificate) { 24 | // Check that the certificate isn't being added twice. 25 | for _, c := range d.certs { 26 | if c.Equal(cert) { 27 | return 28 | } 29 | } 30 | d.certs = append([]*x509.Certificate{cert}, d.certs...) 31 | } 32 | 33 | func newDedupedChain(chain []*x509.Certificate) *dedupedChain { 34 | d := &dedupedChain{} 35 | for _, cert := range chain { 36 | d.addCert(cert) 37 | } 38 | return d 39 | } 40 | 41 | type lockedMap struct { 42 | m map[[hashSize]byte]bool 43 | sync.RWMutex 44 | } 45 | 46 | func newLockedMap() *lockedMap { 47 | return &lockedMap{m: make(map[[hashSize]byte]bool)} 48 | } 49 | 50 | func (m *lockedMap) get(hash [hashSize]byte) bool { 51 | m.RLock() 52 | defer m.RUnlock() 53 | return m.m[hash] 54 | } 55 | 56 | func (m *lockedMap) set(hash [hashSize]byte, b bool) { 57 | m.Lock() 58 | defer m.Unlock() 59 | m.m[hash] = b 60 | } 61 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/fixchain/hash.go: -------------------------------------------------------------------------------- 1 | package fixchain 2 | 3 | import ( 4 | "crypto/sha256" 5 | "sort" 6 | 7 | "github.com/google/certificate-transparency/go/x509" 8 | ) 9 | 10 | const hashSize = sha256.Size 11 | 12 | var newHash = sha256.New 13 | 14 | func hash(c *x509.Certificate) (hash [hashSize]byte) { 15 | copy(hash[:], newHash().Sum(c.Raw)) 16 | return 17 | } 18 | 19 | func hashChain(ch []*x509.Certificate) (hash [hashSize]byte) { 20 | h := newHash() 21 | for _, c := range ch { 22 | h.Write(newHash().Sum(c.Raw)) 23 | } 24 | copy(hash[:], h.Sum(nil)) 25 | return 26 | } 27 | 28 | // hashBag hashes all of the certs in the chain, irrespective of their order. 29 | // Chains containing the same certs in the same order with no duplicates will 30 | // result in the same hash. Chains containing the same certs in different orders 31 | // with no duplicates will result in the same hash. Chains containing the same 32 | // certs (either in the same order or in different orders) that contain exactly 33 | // the same duplicated certs, will result in the same hash. If chains contain 34 | // the same certs (either in the same order or in different orders) and some 35 | // certs are duplicated, but the specific certs that are duplicated differ 36 | // and/or the number of times they are duplicated differ, these chains will 37 | // result in different hashes. 38 | func hashBag(chain []*x509.Certificate) [hashSize]byte { 39 | b := bag{certs: make([]*x509.Certificate, len(chain))} 40 | copy(b.certs, chain) 41 | sort.Sort(b) 42 | return hashChain(b.certs) 43 | } 44 | 45 | type bag struct { 46 | certs []*x509.Certificate 47 | } 48 | 49 | // sort.Sort(data Interface) for bag - uses data.Len, data.Less & data.Swap 50 | func (b bag) Len() int { return len(b.certs) } 51 | func (b bag) Less(i, j int) bool { 52 | ci := b.certs[i].Raw 53 | cj := b.certs[j].Raw 54 | if len(ci) != len(cj) { 55 | return len(ci) < len(cj) 56 | } 57 | for n := range ci { 58 | if ci[n] < cj[n] { 59 | return true 60 | } 61 | if ci[n] > cj[n] { 62 | return false 63 | } 64 | } 65 | return false 66 | } 67 | func (b bag) Swap(i, j int) { 68 | t := b.certs[i] 69 | b.certs[i] = b.certs[j] 70 | b.certs[j] = t 71 | } 72 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/fixchain/hash_test.go: -------------------------------------------------------------------------------- 1 | package fixchain 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestHashBag(t *testing.T) { 8 | hashBagTests := []struct { 9 | certList1 []string 10 | certList2 []string 11 | expEqual bool 12 | errMsg string 13 | }{ 14 | { 15 | []string{googleLeaf}, 16 | []string{thawteIntermediate}, 17 | false, 18 | "hash match between Bags containing different certs", 19 | }, 20 | { 21 | []string{googleLeaf, thawteIntermediate}, 22 | []string{thawteIntermediate, googleLeaf}, 23 | true, 24 | "hash mismatch between Bags containing the same certs", 25 | }, 26 | { 27 | []string{googleLeaf, thawteIntermediate}, 28 | []string{thawteIntermediate, googleLeaf, thawteIntermediate}, 29 | false, 30 | "hash match between Bags containing the same certs, but one with duplicates", 31 | }, 32 | } 33 | 34 | for i, test := range hashBagTests { 35 | certList1 := extractTestChain(t, i, test.certList1) 36 | certList2 := extractTestChain(t, i, test.certList2) 37 | if (hashBag(certList1) == hashBag(certList2)) != test.expEqual { 38 | t.Errorf("#%d: %s", i, test.errMsg) 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/fixchain/post.go: -------------------------------------------------------------------------------- 1 | package fixchain 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "fmt" 7 | "io/ioutil" 8 | "log" 9 | "net/http" 10 | 11 | "github.com/google/certificate-transparency/go/x509" 12 | ) 13 | 14 | // PostChainToLog attempts to post the given chain to the Certificate 15 | // Transparency log at the given url, using the given http client. 16 | // PostChainToLog returns a FixError if it is unable to post the chain either 17 | // because client.Post() failed, or the http response code returned was not 200. 18 | // It is up to the caller to handle such errors appropriately. 19 | func PostChainToLog(chain []*x509.Certificate, client *http.Client, url string) *FixError { 20 | // Format the chain ready to be posted to the log. 21 | type Chain struct { 22 | Chain [][]byte `json:"chain"` 23 | } 24 | var m Chain 25 | for _, c := range chain { 26 | m.Chain = append(m.Chain, c.Raw) 27 | } 28 | j, err := json.Marshal(m) 29 | if err != nil { 30 | log.Fatalf("Can't marshal: %s", err) 31 | } 32 | 33 | // Post the chain! 34 | resp, err := client.Post(url+"/ct/v1/add-chain", "application/json", bytes.NewReader(j)) 35 | if err != nil { 36 | return &FixError{ 37 | Type: PostFailed, 38 | Chain: chain, 39 | Error: fmt.Errorf("can't post: %s", err), 40 | } 41 | } 42 | 43 | defer resp.Body.Close() 44 | jo, err := ioutil.ReadAll(resp.Body) 45 | if err != nil { 46 | return &FixError{ 47 | Type: LogPostFailed, 48 | Chain: chain, 49 | Error: fmt.Errorf("can't read response: %s", err), 50 | } 51 | } 52 | 53 | if resp.StatusCode != 200 { 54 | return &FixError{ 55 | Type: LogPostFailed, 56 | Chain: chain, 57 | Error: fmt.Errorf("can't handle response code %d: %s", resp.StatusCode, jo), 58 | Code: resp.StatusCode, 59 | } 60 | } 61 | 62 | return nil 63 | } 64 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/fixchain/post_test.go: -------------------------------------------------------------------------------- 1 | package fixchain 2 | 3 | import ( 4 | "net/http" 5 | "testing" 6 | ) 7 | 8 | func TestPostChainToLog(t *testing.T) { 9 | for i, test := range postTests { 10 | client := &http.Client{Transport: &postTestRoundTripper{t: t, test: &test, testIndex: i}} 11 | ferr := PostChainToLog(extractTestChain(t, i, test.chain), client, test.url) 12 | 13 | if ferr == nil { 14 | if test.ferr.Type != None { 15 | t.Errorf("#%d: PostChainToLog() didn't return FixError, expected FixError of type %s", i, test.ferr.TypeString()) 16 | } 17 | } else { 18 | if ferr.Type != test.ferr.Type { 19 | t.Errorf("#%d: PostChainToLog() returned FixError of type %s, expected %s", i, ferr.TypeString(), test.ferr.TypeString()) 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/fixchain/ratelimiter/limiter.go: -------------------------------------------------------------------------------- 1 | // Package ratelimiter provides an exceedingly simple rate limiter. 2 | package ratelimiter 3 | 4 | import ( 5 | "github.com/juju/ratelimit" 6 | ) 7 | 8 | // Limiter is a simple rate limiter. 9 | type Limiter struct { 10 | bucket *ratelimit.Bucket 11 | } 12 | 13 | // Wait blocks for the amount of time required by the Limiter so as to not 14 | // exceed its rate. 15 | func (l *Limiter) Wait() { 16 | l.bucket.Wait(1) 17 | } 18 | 19 | // NewLimiter creates a new Limiter with a rate of limit per second. 20 | func NewLimiter(limit int) *Limiter { 21 | return &Limiter{bucket: ratelimit.NewBucketWithRate(float64(limit), 1)} 22 | } 23 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/fixchain/ratelimiter/limiter_test.go: -------------------------------------------------------------------------------- 1 | package ratelimiter 2 | 3 | import ( 4 | "sync" 5 | "sync/atomic" 6 | "testing" 7 | "time" 8 | ) 9 | 10 | var testlimits = []int{1, 10, 50, 100, 1000} 11 | 12 | func checkTicker(t *testing.T, tick *time.Ticker, count *int64, i, limit int) { 13 | for range tick.C { 14 | // Allow a count up to slightly more than the limit as scheduling of 15 | // goroutine vs the main thread could cause this check to not be 16 | // run quite in time for limit. 17 | allowed := int(float64(limit)*1.05) + 1 18 | v := atomic.LoadInt64(count) 19 | if v > int64(allowed) { 20 | t.Errorf("#%d: Too many operations per second. Expected ~%d, got %d", i, limit, v) 21 | } 22 | atomic.StoreInt64(count, 0) 23 | } 24 | } 25 | 26 | func TestRateLimiterSingleThreaded(t *testing.T) { 27 | for i, limit := range testlimits { 28 | l := NewLimiter(limit) 29 | count := int64(0) 30 | tick := time.NewTicker(time.Second) 31 | go checkTicker(t, tick, &count, i, limit) 32 | 33 | for i := 0; i < 3*limit; i++ { 34 | l.Wait() 35 | atomic.AddInt64(&count, 1) 36 | } 37 | tick.Stop() 38 | } 39 | } 40 | 41 | func TestRateLimiterGoroutines(t *testing.T) { 42 | for i, limit := range testlimits { 43 | l := NewLimiter(limit) 44 | count := int64(0) 45 | tick := time.NewTicker(time.Second) 46 | go checkTicker(t, tick, &count, i, limit) 47 | 48 | var wg sync.WaitGroup 49 | for i := 0; i < 3*limit; i++ { 50 | wg.Add(1) 51 | go func() { 52 | l.Wait() 53 | atomic.AddInt64(&count, 1) 54 | wg.Done() 55 | }() 56 | } 57 | wg.Wait() 58 | tick.Stop() 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/fixchain/url_cache.go: -------------------------------------------------------------------------------- 1 | package fixchain 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "log" 7 | "net/http" 8 | "sync" 9 | "sync/atomic" 10 | "time" 11 | ) 12 | 13 | type lockedCache struct { 14 | m map[string][]byte 15 | sync.RWMutex 16 | } 17 | 18 | func (c *lockedCache) get(str string) ([]byte, bool) { 19 | c.RLock() 20 | defer c.RUnlock() 21 | b, ok := c.m[str] 22 | return b, ok 23 | } 24 | 25 | func (c *lockedCache) set(str string, b []byte) { 26 | c.Lock() 27 | defer c.Unlock() 28 | c.m[str] = b 29 | } 30 | 31 | func newLockedCache() *lockedCache { 32 | return &lockedCache{m: make(map[string][]byte)} 33 | } 34 | 35 | type urlCache struct { 36 | client *http.Client 37 | cache *lockedCache 38 | 39 | hit uint32 40 | miss uint32 41 | errors uint32 42 | badStatus uint32 43 | readFail uint32 44 | } 45 | 46 | func (u *urlCache) getURL(url string) ([]byte, error) { 47 | r, ok := u.cache.get(url) 48 | if ok { 49 | atomic.AddUint32(&u.hit, 1) 50 | return r, nil 51 | } 52 | c, err := u.client.Get(url) 53 | if err != nil { 54 | atomic.AddUint32(&u.errors, 1) 55 | return nil, err 56 | } 57 | defer c.Body.Close() 58 | // TODO(katjoyce): Add caching of permanent errors. 59 | if c.StatusCode != 200 { 60 | atomic.AddUint32(&u.badStatus, 1) 61 | return nil, fmt.Errorf("can't deal with status %d", c.StatusCode) 62 | } 63 | r, err = ioutil.ReadAll(c.Body) 64 | if err != nil { 65 | atomic.AddUint32(&u.readFail, 1) 66 | return nil, err 67 | } 68 | atomic.AddUint32(&u.miss, 1) 69 | u.cache.set(url, r) 70 | return r, nil 71 | } 72 | 73 | func newURLCache(c *http.Client, logStats bool) *urlCache { 74 | u := &urlCache{cache: newLockedCache(), client: c} 75 | 76 | if logStats { 77 | t := time.NewTicker(time.Second) 78 | go func() { 79 | for range t.C { 80 | log.Printf("url cache: %d hits, %d misses, %d errors, "+ 81 | "%d bad status, %d read fail, %d cached", u.hit, 82 | u.miss, u.errors, u.badStatus, u.readFail, 83 | len(u.cache.m)) 84 | } 85 | }() 86 | } 87 | 88 | return u 89 | } 90 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/gossip/main/gossip_server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "errors" 5 | "flag" 6 | "fmt" 7 | "io/ioutil" 8 | "log" 9 | "net/http" 10 | "strings" 11 | 12 | ct "github.com/google/certificate-transparency/go" 13 | "github.com/google/certificate-transparency/go/gossip" 14 | ) 15 | 16 | var dbPath = flag.String("database", "/tmp/gossip.sq3", "Path to database.") 17 | var listenAddress = flag.String("listen", ":8080", "Listen address:port for HTTP server.") 18 | var logKeys = flag.String("log_public_keys", "", "Comma separated list of files containing trusted Logs' public keys in PEM format") 19 | 20 | func createVerifiers() (*gossip.SignatureVerifierMap, error) { 21 | m := make(gossip.SignatureVerifierMap) 22 | if len(*logKeys) == 0 { 23 | return nil, errors.New("--log_public_keys is empty") 24 | } 25 | keys := strings.Split(*logKeys, ",") 26 | for _, k := range keys { 27 | pem, err := ioutil.ReadFile(k) 28 | if err != nil { 29 | return nil, fmt.Errorf("failed to read specified PEM file %s: %v", k, err) 30 | } 31 | for len(pem) > 0 { 32 | key, id, rest, err := ct.PublicKeyFromPEM(pem) 33 | pem = rest 34 | if err != nil { 35 | return nil, fmt.Errorf("failed to read public key from PEM in file %s: %v", k, err) 36 | } 37 | sv, err := ct.NewSignatureVerifier(key) 38 | if err != nil { 39 | return nil, fmt.Errorf("Failed to create new SignatureVerifier: %v", err) 40 | } 41 | m[id] = *sv 42 | log.Printf("Loaded key for LogID %v", id) 43 | } 44 | } 45 | return &m, nil 46 | } 47 | 48 | func main() { 49 | flag.Parse() 50 | verifierMap, err := createVerifiers() 51 | if err != nil { 52 | log.Fatalf("Failed to load log public keys: %v", err) 53 | } 54 | log.Print("Starting gossip server.") 55 | 56 | storage := gossip.Storage{} 57 | if err := storage.Open(*dbPath); err != nil { 58 | log.Fatalf("Failed to open storage: %v", err) 59 | } 60 | defer storage.Close() 61 | 62 | handler := gossip.NewHandler(&storage, *verifierMap) 63 | serveMux := http.NewServeMux() 64 | serveMux.HandleFunc("/.well-known/ct/v1/sct-feedback", handler.HandleSCTFeedback) 65 | serveMux.HandleFunc("/.well-known/ct/v1/sth-pollination", handler.HandleSTHPollination) 66 | server := &http.Server{ 67 | Addr: *listenAddress, 68 | Handler: serveMux, 69 | } 70 | if err := server.ListenAndServe(); err != nil { 71 | log.Printf("Error serving: %v", err) 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/gossip/types.go: -------------------------------------------------------------------------------- 1 | package gossip 2 | 3 | import ( 4 | ct "github.com/google/certificate-transparency/go" 5 | ) 6 | 7 | // STHVersion reflects the STH Version field in RFC6862[-bis] 8 | type STHVersion int 9 | 10 | // STHVersion constants 11 | const ( 12 | STHVersion0 = 0 13 | STHVersion1 = 1 14 | ) 15 | 16 | // SCTFeedbackEntry represents a single piece of SCT feedback. 17 | type SCTFeedbackEntry struct { 18 | X509Chain []string `json:"x509_chain"` 19 | SCTData []string `json:"sct_data"` 20 | } 21 | 22 | // SCTFeedback represents a collection of SCTFeedback which a client might send together. 23 | type SCTFeedback struct { 24 | Feedback []SCTFeedbackEntry `json:"sct_feedback"` 25 | } 26 | 27 | // STHPollination represents a collection of STH pollination entries which a client might send together. 28 | type STHPollination struct { 29 | STHs []ct.SignedTreeHead `json:"sths"` 30 | } 31 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/merkletree/merkle_tree_interface.go: -------------------------------------------------------------------------------- 1 | package merkletree 2 | 3 | // MerkleTreeInterface represents the common interface for basic MerkleTree functions. 4 | type MerkleTreeInterface interface { 5 | // LeafCount returns the number of leaves in the tree 6 | LeafCount() uint64 7 | 8 | // LevelCount returns the number of levels in the tree 9 | LevelCount() uint64 10 | 11 | // AddLeaf adds the hash of |leaf| to the tree and returns the newly added 12 | // leaf index 13 | AddLeaf(leaf []byte) uint64 14 | 15 | // LeafHash returns the hash of the leaf at index |leaf| or a non-nil error. 16 | LeafHash(leaf uint64) ([]byte, error) 17 | 18 | // CurrentRoot returns the current root hash of the merkle tree. 19 | CurrentRoot() ([]byte, error) 20 | } 21 | 22 | // FullMerkleTreeInterface extends MerkleTreeInterface to the full range of 23 | // operations that only a non-compact tree representation can implement. 24 | type FullMerkleTreeInterface interface { 25 | MerkleTreeInterface 26 | 27 | // RootAtSnapshot returns the root hash at the tree size |snapshot| 28 | // which must be <= than the current tree size. 29 | RootAtSnapshot(snapshot uint64) ([]byte, error) 30 | 31 | // PathToCurrentRoot returns the Merkle path (or inclusion proof) from the 32 | // leaf hash at index |leaf| to the current root. 33 | PathToCurrentRoot(leaf uint64) ([]byte, error) 34 | 35 | // SnapshotConsistency returns a consistency proof between the two tree 36 | // sizes specified in |snapshot1| and |snapshot2|. 37 | SnapshotConsistency(snapshot1, snapshot2 uint64) ([]byte, error) 38 | } 39 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/merkletree/tree_hasher.go: -------------------------------------------------------------------------------- 1 | package merkletree 2 | 3 | const ( 4 | // LeafPrefix is the domain separation prefix for leaf hashes. 5 | LeafPrefix = 0 6 | 7 | // NodePrefix is the domain separation prefix for internal tree nodes. 8 | NodePrefix = 1 9 | ) 10 | 11 | // HasherFunc takes a slice of bytes and returns a cryptographic hash of those bytes. 12 | type HasherFunc func([]byte) []byte 13 | 14 | // TreeHasher performs the various hashing operations required when manipulating MerkleTrees. 15 | type TreeHasher struct { 16 | hasher HasherFunc 17 | } 18 | 19 | // NewTreeHasher returns a new TreeHasher based on the passed in hash. 20 | func NewTreeHasher(h HasherFunc) *TreeHasher { 21 | return &TreeHasher{ 22 | hasher: h, 23 | } 24 | } 25 | 26 | // HashEmpty returns the hash of the empty string. 27 | func (h TreeHasher) HashEmpty() []byte { 28 | return h.hasher([]byte{}) 29 | } 30 | 31 | // HashLeaf returns the hash of the passed in leaf, after applying domain separation. 32 | func (h TreeHasher) HashLeaf(leaf []byte) []byte { 33 | return h.hasher(append([]byte{LeafPrefix}, leaf...)) 34 | 35 | } 36 | 37 | // HashChildren returns the merkle hash of the two passed in children. 38 | func (h TreeHasher) HashChildren(left, right []byte) []byte { 39 | return h.hasher(append(append([]byte{NodePrefix}, left...), right...)) 40 | } 41 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/merkletree/wrap_merkle_tree.cc: -------------------------------------------------------------------------------- 1 | #include "merkletree/merkle_tree.cc" 2 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/merkletree/wrap_merkle_tree_math.cc: -------------------------------------------------------------------------------- 1 | #include "merkletree/merkle_tree_math.cc" 2 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/merkletree/wrap_serial_hasher.cc: -------------------------------------------------------------------------------- 1 | #include "merkletree/serial_hasher.cc" 2 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/merkletree/wrap_tree_hasher.cc: -------------------------------------------------------------------------------- 1 | #include "merkletree/tree_hasher.cc" 2 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/preload/dumpscts/main/dumpscts.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "compress/zlib" 5 | "encoding/gob" 6 | "flag" 7 | "io" 8 | "log" 9 | "os" 10 | 11 | "github.com/google/certificate-transparency/go/preload" 12 | ) 13 | 14 | var sctFile = flag.String("sct_file", "", "File to load SCTs & leaf data from") 15 | 16 | func main() { 17 | flag.Parse() 18 | var sctReader io.ReadCloser 19 | if *sctFile == "" { 20 | log.Fatal("Must specify --sct_file") 21 | } 22 | 23 | sctFileReader, err := os.Open(*sctFile) 24 | if err != nil { 25 | log.Fatal(err) 26 | } 27 | sctReader, err = zlib.NewReader(sctFileReader) 28 | if err != nil { 29 | log.Fatal(err) 30 | } 31 | defer func() { 32 | err := sctReader.Close() 33 | if err != nil && err != io.EOF { 34 | log.Fatalf("Error closing file: %s", err) 35 | } 36 | }() 37 | 38 | // TODO(alcutter) should probably store this stuff in a protobuf really. 39 | decoder := gob.NewDecoder(sctReader) 40 | var addedCert preload.AddedCert 41 | numAdded := 0 42 | numFailed := 0 43 | for { 44 | err = decoder.Decode(&addedCert) 45 | if err != nil { 46 | break 47 | } 48 | if addedCert.AddedOk { 49 | log.Println(addedCert.SignedCertificateTimestamp) 50 | numAdded++ 51 | } else { 52 | log.Printf("Cert was not added: %s", addedCert.ErrorMessage) 53 | numFailed++ 54 | } 55 | } 56 | log.Printf("Num certs added: %d, num failed: %d\n", numAdded, numFailed) 57 | } 58 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/preload/types.go: -------------------------------------------------------------------------------- 1 | package preload 2 | 3 | import ( 4 | ct "github.com/google/certificate-transparency/go" 5 | ) 6 | 7 | type AddedCert struct { 8 | CertDER ct.ASN1Cert 9 | SignedCertificateTimestamp ct.SignedCertificateTimestamp 10 | AddedOk bool 11 | ErrorMessage string 12 | } 13 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/tls/types.go: -------------------------------------------------------------------------------- 1 | package tls 2 | 3 | import "fmt" 4 | 5 | // DigitallySigned gives information about a signature, including the algorithm used 6 | // and the signature value. Defined in RFC 5246 s4.7. 7 | type DigitallySigned struct { 8 | Algorithm SignatureAndHashAlgorithm 9 | Signature []byte `tls:"minlen:0,maxlen:65535"` 10 | } 11 | 12 | // SignatureAndHashAlgorithm gives information about the algorithms used for a 13 | // signature. Defined in RFC 5246 s7.4.1.4.1. 14 | type SignatureAndHashAlgorithm struct { 15 | Hash HashAlgorithm `tls:"maxval:255"` 16 | Signature SignatureAlgorithm `tls:"maxval:255"` 17 | } 18 | 19 | // HashAlgorithm enum from RFC 5246 s7.4.1.4.1. 20 | type HashAlgorithm Enum 21 | 22 | // HashAlgorithm constants from RFC 5246 s7.4.1.4.1. 23 | const ( 24 | None HashAlgorithm = 0 25 | MD5 HashAlgorithm = 1 26 | SHA1 HashAlgorithm = 2 27 | SHA224 HashAlgorithm = 3 28 | SHA256 HashAlgorithm = 4 29 | SHA384 HashAlgorithm = 5 30 | SHA512 HashAlgorithm = 6 31 | ) 32 | 33 | func (h HashAlgorithm) String() string { 34 | switch h { 35 | case None: 36 | return "None" 37 | case MD5: 38 | return "MD5" 39 | case SHA1: 40 | return "SHA1" 41 | case SHA224: 42 | return "SHA224" 43 | case SHA256: 44 | return "SHA256" 45 | case SHA384: 46 | return "SHA384" 47 | case SHA512: 48 | return "SHA512" 49 | default: 50 | return fmt.Sprintf("UNKNOWN(%d)", h) 51 | } 52 | } 53 | 54 | // SignatureAlgorithm enum from RFC 5246 s7.4.1.4.1. 55 | type SignatureAlgorithm Enum 56 | 57 | // SignatureAlgorithm constants from RFC 5246 s7.4.1.4.1. 58 | const ( 59 | Anonymous SignatureAlgorithm = 0 60 | RSA SignatureAlgorithm = 1 61 | DSA SignatureAlgorithm = 2 62 | ECDSA SignatureAlgorithm = 3 63 | ) 64 | 65 | func (s SignatureAlgorithm) String() string { 66 | switch s { 67 | case Anonymous: 68 | return "Anonymous" 69 | case RSA: 70 | return "RSA" 71 | case DSA: 72 | return "DSA" 73 | case ECDSA: 74 | return "ECDSA" 75 | default: 76 | return fmt.Sprintf("UNKNOWN(%d)", s) 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/tls/types_test.go: -------------------------------------------------------------------------------- 1 | package tls 2 | 3 | import "testing" 4 | 5 | func TestHashAlgorithmString(t *testing.T) { 6 | var tests = []struct { 7 | algo HashAlgorithm 8 | want string 9 | }{ 10 | {None, "None"}, 11 | {MD5, "MD5"}, 12 | {SHA1, "SHA1"}, 13 | {SHA224, "SHA224"}, 14 | {SHA256, "SHA256"}, 15 | {SHA384, "SHA384"}, 16 | {SHA512, "SHA512"}, 17 | {99, "UNKNOWN(99)"}, 18 | } 19 | for _, test := range tests { 20 | if got := test.algo.String(); got != test.want { 21 | t.Errorf("%v.String()=%q; want %q", test.algo, got, test.want) 22 | } 23 | } 24 | } 25 | 26 | func TestSignatureAlgorithmString(t *testing.T) { 27 | var tests = []struct { 28 | algo SignatureAlgorithm 29 | want string 30 | }{ 31 | {Anonymous, "Anonymous"}, 32 | {RSA, "RSA"}, 33 | {DSA, "DSA"}, 34 | {ECDSA, "ECDSA"}, 35 | {99, "UNKNOWN(99)"}, 36 | } 37 | for _, test := range tests { 38 | if got := test.algo.String(); got != test.want { 39 | t.Errorf("%v.String()=%q; want %q", test.algo, got, test.want) 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/x509/pkcs8.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 x509 6 | 7 | import ( 8 | // START CT CHANGES 9 | "github.com/google/certificate-transparency/go/asn1" 10 | "github.com/google/certificate-transparency/go/x509/pkix" 11 | // END CT CHANGES 12 | "errors" 13 | "fmt" 14 | ) 15 | 16 | // pkcs8 reflects an ASN.1, PKCS#8 PrivateKey. See 17 | // ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-8/pkcs-8v1_2.asn 18 | // and RFC 5208. 19 | type pkcs8 struct { 20 | Version int 21 | Algo pkix.AlgorithmIdentifier 22 | PrivateKey []byte 23 | // optional attributes omitted. 24 | } 25 | 26 | // ParsePKCS8PrivateKey parses an unencrypted, PKCS#8 private key. 27 | // See RFC 5208. 28 | func ParsePKCS8PrivateKey(der []byte) (key interface{}, err error) { 29 | var privKey pkcs8 30 | if _, err := asn1.Unmarshal(der, &privKey); err != nil { 31 | return nil, err 32 | } 33 | switch { 34 | case privKey.Algo.Algorithm.Equal(oidPublicKeyRSA): 35 | key, err = ParsePKCS1PrivateKey(privKey.PrivateKey) 36 | if err != nil { 37 | return nil, errors.New("x509: failed to parse RSA private key embedded in PKCS#8: " + err.Error()) 38 | } 39 | return key, nil 40 | 41 | case privKey.Algo.Algorithm.Equal(oidPublicKeyECDSA): 42 | bytes := privKey.Algo.Parameters.FullBytes 43 | namedCurveOID := new(asn1.ObjectIdentifier) 44 | if _, err := asn1.Unmarshal(bytes, namedCurveOID); err != nil { 45 | namedCurveOID = nil 46 | } 47 | key, err = parseECPrivateKey(namedCurveOID, privKey.PrivateKey) 48 | if err != nil { 49 | return nil, errors.New("x509: failed to parse EC private key embedded in PKCS#8: " + err.Error()) 50 | } 51 | return key, nil 52 | 53 | default: 54 | return nil, fmt.Errorf("x509: PKCS#8 wrapping contained private key with unknown algorithm: %v", privKey.Algo.Algorithm) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/x509/root.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package x509 6 | 7 | import "sync" 8 | 9 | var ( 10 | once sync.Once 11 | systemRoots *CertPool 12 | systemRootsErr error 13 | ) 14 | 15 | func systemRootsPool() *CertPool { 16 | once.Do(initSystemRoots) 17 | return systemRoots 18 | } 19 | 20 | func initSystemRoots() { 21 | systemRoots, systemRootsErr = loadSystemRoots() 22 | } 23 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/x509/root_bsd.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 dragonfly freebsd netbsd openbsd 6 | 7 | package x509 8 | 9 | // Possible certificate files; stop after finding one. 10 | var certFiles = []string{ 11 | "/usr/local/share/certs/ca-root-nss.crt", // FreeBSD/DragonFly 12 | "/etc/ssl/cert.pem", // OpenBSD 13 | "/etc/openssl/certs/ca-certificates.crt", // NetBSD 14 | } 15 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/x509/root_darwin.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 | //go:generate go run root_darwin_arm_gen.go -output root_darwin_armx.go 6 | 7 | package x509 8 | 9 | import "os/exec" 10 | 11 | func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate, err error) { 12 | return nil, nil 13 | } 14 | 15 | func execSecurityRoots() (*CertPool, error) { 16 | cmd := exec.Command("/usr/bin/security", "find-certificate", "-a", "-p", "/System/Library/Keychains/SystemRootCertificates.keychain") 17 | data, err := cmd.Output() 18 | if err != nil { 19 | return nil, err 20 | } 21 | 22 | roots := NewCertPool() 23 | roots.AppendCertsFromPEM(data) 24 | return roots, nil 25 | } 26 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/x509/root_darwin_test.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 | package x509 6 | 7 | import ( 8 | "runtime" 9 | "testing" 10 | ) 11 | 12 | func TestSystemRoots(t *testing.T) { 13 | switch runtime.GOARCH { 14 | case "arm", "arm64": 15 | t.Skipf("skipping on %s/%s, no system root", runtime.GOOS, runtime.GOARCH) 16 | } 17 | 18 | sysRoots := systemRootsPool() // actual system roots 19 | execRoots, err := execSecurityRoots() // non-cgo roots 20 | 21 | if err != nil { 22 | t.Fatalf("failed to read system roots: %v", err) 23 | } 24 | 25 | for _, tt := range []*CertPool{sysRoots, execRoots} { 26 | if tt == nil { 27 | t.Fatal("no system roots") 28 | } 29 | // On Mavericks, there are 212 bundled certs; require only 30 | // 150 here, since this is just a sanity check, and the 31 | // exact number will vary over time. 32 | if want, have := 150, len(tt.certs); have < want { 33 | t.Fatalf("want at least %d system roots, have %d", want, have) 34 | } 35 | } 36 | 37 | // Check that the two cert pools are roughly the same; 38 | // |A∩B| > max(|A|, |B|) / 2 should be a reasonably robust check. 39 | 40 | isect := make(map[string]bool, len(sysRoots.certs)) 41 | for _, c := range sysRoots.certs { 42 | isect[string(c.Raw)] = true 43 | } 44 | 45 | have := 0 46 | for _, c := range execRoots.certs { 47 | if isect[string(c.Raw)] { 48 | have++ 49 | } 50 | } 51 | 52 | var want int 53 | if nsys, nexec := len(sysRoots.certs), len(execRoots.certs); nsys > nexec { 54 | want = nsys / 2 55 | } else { 56 | want = nexec / 2 57 | } 58 | 59 | if have < want { 60 | t.Errorf("insufficient overlap between cgo and non-cgo roots; want at least %d, have %d", want, have) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/x509/root_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package x509 6 | 7 | // Possible certificate files; stop after finding one. 8 | var certFiles = []string{ 9 | "/etc/ssl/certs/ca-certificates.crt", // Debian/Ubuntu/Gentoo etc. 10 | "/etc/pki/tls/certs/ca-bundle.crt", // Fedora/RHEL 11 | "/etc/ssl/ca-bundle.pem", // OpenSUSE 12 | "/etc/pki/tls/cacert.pem", // OpenELEC 13 | } 14 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/x509/root_nacl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package x509 6 | 7 | // Possible certificate files; stop after finding one. 8 | var certFiles = []string{} 9 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/x509/root_nocgo_darwin.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 !cgo 6 | 7 | package x509 8 | 9 | func loadSystemRoots() (*CertPool, error) { 10 | return execSecurityRoots() 11 | } 12 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/x509/root_plan9.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build plan9 6 | 7 | package x509 8 | 9 | import ( 10 | "io/ioutil" 11 | "os" 12 | ) 13 | 14 | // Possible certificate files; stop after finding one. 15 | var certFiles = []string{ 16 | "/sys/lib/tls/ca.pem", 17 | } 18 | 19 | func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate, err error) { 20 | return nil, nil 21 | } 22 | 23 | func loadSystemRoots() (*CertPool, error) { 24 | roots := NewCertPool() 25 | var bestErr error 26 | for _, file := range certFiles { 27 | data, err := ioutil.ReadFile(file) 28 | if err == nil { 29 | roots.AppendCertsFromPEM(data) 30 | return roots, nil 31 | } 32 | if bestErr == nil || (os.IsNotExist(bestErr) && !os.IsNotExist(err)) { 33 | bestErr = err 34 | } 35 | } 36 | return nil, bestErr 37 | } 38 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/x509/root_solaris.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package x509 6 | 7 | // Possible certificate files; stop after finding one. 8 | var certFiles = []string{ 9 | "/etc/certs/ca-certificates.crt", // Solaris 11.2+ 10 | "/etc/ssl/certs/ca-certificates.crt", // Joyent SmartOS 11 | "/etc/ssl/cacert.pem", // OmniOS 12 | } 13 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/x509/root_stub.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 | // +build darwin,!cgo 6 | 7 | package x509 8 | 9 | func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate, err error) { 10 | return nil, nil 11 | } 12 | 13 | func initSystemRoots() { 14 | } 15 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/x509/root_unix.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 | // +build dragonfly freebsd linux nacl netbsd openbsd solaris 6 | 7 | package x509 8 | 9 | import ( 10 | "io/ioutil" 11 | "os" 12 | ) 13 | 14 | // Possible directories with certificate files; stop after successfully 15 | // reading at least one file from a directory. 16 | var certDirectories = []string{ 17 | "/etc/ssl/certs", // SLES10/SLES11, https://golang.org/issue/12139 18 | "/system/etc/security/cacerts", // Android 19 | } 20 | 21 | func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate, err error) { 22 | return nil, nil 23 | } 24 | 25 | func loadSystemRoots() (*CertPool, error) { 26 | roots := NewCertPool() 27 | var firstErr error 28 | for _, file := range certFiles { 29 | data, err := ioutil.ReadFile(file) 30 | if err == nil { 31 | roots.AppendCertsFromPEM(data) 32 | return roots, nil 33 | } 34 | if firstErr == nil && !os.IsNotExist(err) { 35 | firstErr = err 36 | } 37 | } 38 | 39 | for _, directory := range certDirectories { 40 | fis, err := ioutil.ReadDir(directory) 41 | if err != nil { 42 | if firstErr == nil && !os.IsNotExist(err) { 43 | firstErr = err 44 | } 45 | continue 46 | } 47 | rootsAdded := false 48 | for _, fi := range fis { 49 | data, err := ioutil.ReadFile(directory + "/" + fi.Name()) 50 | if err == nil && roots.AppendCertsFromPEM(data) { 51 | rootsAdded = true 52 | } 53 | } 54 | if rootsAdded { 55 | return roots, nil 56 | } 57 | } 58 | 59 | return nil, firstErr 60 | } 61 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/x509/sha2_windows_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package x509 6 | 7 | import "syscall" 8 | 9 | func init() { 10 | v, err := syscall.GetVersion() 11 | if err != nil { 12 | return 13 | } 14 | if major := byte(v); major < 6 { 15 | // Windows XP SP2 and Windows 2003 do not support SHA2. 16 | // http://blogs.technet.com/b/pki/archive/2010/09/30/sha2-and-windows.aspx 17 | supportSHA2 = false 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/google/certificate-transparency/go/x509/x509_test_import.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 ignore 6 | 7 | // This file is run by the x509 tests to ensure that a program with minimal 8 | // imports can sign certificates without errors resulting from missing hash 9 | // functions. 10 | package main 11 | 12 | import ( 13 | "crypto/rand" 14 | // START CT CHANGES 15 | "github.com/google/certificate-transparency/go/x509" 16 | "github.com/google/certificate-transparency/go/x509/pkix" 17 | // END CT CHANGES 18 | "encoding/pem" 19 | "math/big" 20 | "time" 21 | ) 22 | 23 | func main() { 24 | block, _ := pem.Decode([]byte(pemPrivateKey)) 25 | rsaPriv, err := x509.ParsePKCS1PrivateKey(block.Bytes) 26 | if err != nil { 27 | panic("Failed to parse private key: " + err.Error()) 28 | } 29 | 30 | template := x509.Certificate{ 31 | SerialNumber: big.NewInt(1), 32 | Subject: pkix.Name{ 33 | CommonName: "test", 34 | Organization: []string{"Σ Acme Co"}, 35 | }, 36 | NotBefore: time.Unix(1000, 0), 37 | NotAfter: time.Unix(100000, 0), 38 | KeyUsage: x509.KeyUsageCertSign, 39 | } 40 | 41 | if _, err = x509.CreateCertificate(rand.Reader, &template, &template, &rsaPriv.PublicKey, rsaPriv); err != nil { 42 | panic("failed to create certificate with basic imports: " + err.Error()) 43 | } 44 | } 45 | 46 | var pemPrivateKey = `-----BEGIN RSA PRIVATE KEY----- 47 | MIIBOgIBAAJBALKZD0nEffqM1ACuak0bijtqE2QrI/KLADv7l3kK3ppMyCuLKoF0 48 | fd7Ai2KW5ToIwzFofvJcS/STa6HA5gQenRUCAwEAAQJBAIq9amn00aS0h/CrjXqu 49 | /ThglAXJmZhOMPVn4eiu7/ROixi9sex436MaVeMqSNf7Ex9a8fRNfWss7Sqd9eWu 50 | RTUCIQDasvGASLqmjeffBNLTXV2A5g4t+kLVCpsEIZAycV5GswIhANEPLmax0ME/ 51 | EO+ZJ79TJKN5yiGBRsv5yvx5UiHxajEXAiAhAol5N4EUyq6I9w1rYdhPMGpLfk7A 52 | IU2snfRJ6Nq2CQIgFrPsWRCkV+gOYcajD17rEqmuLrdIRexpg8N1DOSXoJ8CIGlS 53 | tAboUGBxTDq3ZroNism3DaMIbKPyYrAqhKov1h5V 54 | -----END RSA PRIVATE KEY----- 55 | ` 56 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/jpillora/backoff/backoff.go: -------------------------------------------------------------------------------- 1 | package backoff 2 | 3 | import ( 4 | "math" 5 | "math/rand" 6 | "time" 7 | ) 8 | 9 | //Backoff is a time.Duration counter. It starts at Min. 10 | //After every call to Duration() it is multiplied by Factor. 11 | //It is capped at Max. It returns to Min on every call to Reset(). 12 | //Used in conjunction with the time package. 13 | type Backoff struct { 14 | //Factor is the multiplying factor for each increment step 15 | attempts, Factor float64 16 | //Jitter eases contention by randomizing backoff steps 17 | Jitter bool 18 | //Min and Max are the minimum and maximum values of the counter 19 | Min, Max time.Duration 20 | } 21 | 22 | //Returns the current value of the counter and then 23 | //multiplies it Factor 24 | func (b *Backoff) Duration() time.Duration { 25 | //Zero-values are nonsensical, so we use 26 | //them to apply defaults 27 | if b.Min == 0 { 28 | b.Min = 100 * time.Millisecond 29 | } 30 | if b.Max == 0 { 31 | b.Max = 10 * time.Second 32 | } 33 | if b.Factor == 0 { 34 | b.Factor = 2 35 | } 36 | //calculate this duration 37 | dur := float64(b.Min) * math.Pow(b.Factor, b.attempts) 38 | if b.Jitter == true { 39 | dur = rand.Float64()*(dur-float64(b.Min)) + float64(b.Min) 40 | } 41 | //cap! 42 | if dur > float64(b.Max) { 43 | return b.Max 44 | } 45 | //bump attempts count 46 | b.attempts++ 47 | //return as a time.Duration 48 | return time.Duration(dur) 49 | } 50 | 51 | //Resets the current value of the counter back to Min 52 | func (b *Backoff) Reset() { 53 | b.attempts = 0 54 | } 55 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/jpillora/backoff/backoff_test.go: -------------------------------------------------------------------------------- 1 | package backoff 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | ) 7 | 8 | func Test1(t *testing.T) { 9 | 10 | b := &Backoff{ 11 | Min: 100 * time.Millisecond, 12 | Max: 10 * time.Second, 13 | Factor: 2, 14 | } 15 | 16 | equals(t, b.Duration(), 100*time.Millisecond) 17 | equals(t, b.Duration(), 200*time.Millisecond) 18 | equals(t, b.Duration(), 400*time.Millisecond) 19 | b.Reset() 20 | equals(t, b.Duration(), 100*time.Millisecond) 21 | } 22 | 23 | func Test2(t *testing.T) { 24 | 25 | b := &Backoff{ 26 | Min: 100 * time.Millisecond, 27 | Max: 10 * time.Second, 28 | Factor: 1.5, 29 | } 30 | 31 | equals(t, b.Duration(), 100*time.Millisecond) 32 | equals(t, b.Duration(), 150*time.Millisecond) 33 | equals(t, b.Duration(), 225*time.Millisecond) 34 | b.Reset() 35 | equals(t, b.Duration(), 100*time.Millisecond) 36 | } 37 | 38 | func Test3(t *testing.T) { 39 | 40 | b := &Backoff{ 41 | Min: 100 * time.Nanosecond, 42 | Max: 10 * time.Second, 43 | Factor: 1.75, 44 | } 45 | 46 | equals(t, b.Duration(), 100*time.Nanosecond) 47 | equals(t, b.Duration(), 175*time.Nanosecond) 48 | equals(t, b.Duration(), 306*time.Nanosecond) 49 | b.Reset() 50 | equals(t, b.Duration(), 100*time.Nanosecond) 51 | } 52 | 53 | func TestJitter(t *testing.T) { 54 | b := &Backoff{ 55 | Min: 100 * time.Millisecond, 56 | Max: 10 * time.Second, 57 | Factor: 2, 58 | Jitter: true, 59 | } 60 | 61 | equals(t, b.Duration(), 100*time.Millisecond) 62 | between(t, b.Duration(), 100*time.Millisecond, 200*time.Millisecond) 63 | between(t, b.Duration(), 100*time.Millisecond, 400*time.Millisecond) 64 | b.Reset() 65 | equals(t, b.Duration(), 100*time.Millisecond) 66 | } 67 | 68 | func between(t *testing.T, actual, low, high time.Duration) { 69 | if actual < low { 70 | t.Fatalf("Got %s, Expecting >= %s", actual, low) 71 | } 72 | if actual > high { 73 | t.Fatalf("Got %s, Expecting <= %s", actual, high) 74 | } 75 | } 76 | 77 | func equals(t *testing.T, d1, d2 time.Duration) { 78 | if d1 != d2 { 79 | t.Fatalf("Got %s, Expecting %s", d1, d2) 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "test-data"] 2 | path = test-data 3 | url = git://github.com/maxmind/MaxMind-DB.git 4 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.4 5 | - 1.5 6 | - 1.6 7 | - tip 8 | 9 | matrix: 10 | allow_failures: 11 | - go: tip 12 | 13 | before_install: 14 | - "if [[ $TRAVIS_GO_VERSION == 1.6 ]]; then go get -v github.com/golang/lint/golint; fi" 15 | 16 | script: 17 | - go test -race -cpu 1,4 -v 18 | - go test -race -v -tags appengine 19 | - "if [[ $TRAVIS_GO_VERSION == 1.6 ]]; then go vet ./...; fi" 20 | - "if [[ $TRAVIS_GO_VERSION == 1.6 ]]; then golint .; fi" 21 | 22 | sudo: false 23 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Gregory J. Oschwald 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 8 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 9 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 10 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 12 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 13 | PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/example_test.go: -------------------------------------------------------------------------------- 1 | package geoip2 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net" 7 | ) 8 | 9 | // Example provides a basic example of using the API. Use of the Country 10 | // method is analogous to that of the City method. 11 | func Example() { 12 | db, err := Open("test-data/test-data/GeoIP2-City-Test.mmdb") 13 | if err != nil { 14 | log.Fatal(err) 15 | } 16 | defer db.Close() 17 | // If you are using strings that may be invalid, check that ip is not nil 18 | ip := net.ParseIP("81.2.69.142") 19 | record, err := db.City(ip) 20 | if err != nil { 21 | log.Fatal(err) 22 | } 23 | fmt.Printf("Portuguese (BR) city name: %v\n", record.City.Names["pt-BR"]) 24 | fmt.Printf("English subdivision name: %v\n", record.Subdivisions[0].Names["en"]) 25 | fmt.Printf("Russian country name: %v\n", record.Country.Names["ru"]) 26 | fmt.Printf("ISO country code: %v\n", record.Country.IsoCode) 27 | fmt.Printf("Time zone: %v\n", record.Location.TimeZone) 28 | fmt.Printf("Coordinates: %v, %v\n", record.Location.Latitude, record.Location.Longitude) 29 | // Output: 30 | // Portuguese (BR) city name: Londres 31 | // English subdivision name: England 32 | // Russian country name: Великобритания 33 | // ISO country code: GB 34 | // Time zone: Europe/London 35 | // Coordinates: 51.5142, -0.0931 36 | } 37 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/.gitattributes: -------------------------------------------------------------------------------- 1 | *.mmdb diff=mmdb 2 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/.gitconfig: -------------------------------------------------------------------------------- 1 | [diff "mmdb"] 2 | textconv = hexdump -v -C 3 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/.gitignore: -------------------------------------------------------------------------------- 1 | /_site 2 | .tidyall.d 3 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/.perltidyallrc: -------------------------------------------------------------------------------- 1 | --blank-lines-before-packages=0 2 | --iterations=2 3 | --no-outdent-long-comments 4 | -bar 5 | -boc 6 | -ci=4 7 | -i=4 8 | -l=78 9 | -nolq 10 | -se 11 | -wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=" 12 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/.tidyallrc: -------------------------------------------------------------------------------- 1 | [PerlTidy] 2 | select = **/*.{pl,pm,t,psgi} 3 | ignore = blib/**/* 4 | argv = --profile=$ROOT/.perltidyallrc 5 | 6 | [JSON] 7 | select = **/*.json 8 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/LICENSE: -------------------------------------------------------------------------------- 1 | This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 2 | Unported License. To view a copy of this license, visit 3 | http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative 4 | Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. 5 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/README.md: -------------------------------------------------------------------------------- 1 | MaxMind DB is a binary file format that stores data indexed by IP address 2 | subnets (IPv4 or IPv6). 3 | 4 | This repository contains the spec for that format. 5 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/perltidyrc: -------------------------------------------------------------------------------- 1 | --blank-lines-before-packages=0 2 | --iterations=2 3 | --no-outdent-long-comments 4 | -b 5 | -bar 6 | -boc 7 | -ci=4 8 | -i=4 9 | -l=78 10 | -nolq 11 | -se 12 | -wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=" 13 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/source-data/GeoIP2-Anonymous-IP-Test.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "::1.2.0.0/112" : { 4 | "is_anonymous" : true, 5 | "is_anonymous_vpn" : true 6 | } 7 | }, 8 | { 9 | "::71.160.223.0/120" : { 10 | "is_anonymous" : true, 11 | "is_hosting_provider" : true 12 | } 13 | }, 14 | { 15 | "::186.30.236.0/120" : { 16 | "is_anonymous" : true, 17 | "is_public_proxy" : true 18 | } 19 | }, 20 | { 21 | "::65.0.0.0/109" : { 22 | "is_anonymous" : true, 23 | "is_tor_exit_node" : true 24 | } 25 | }, 26 | { 27 | "abcd:1000::/112" : { 28 | "is_anonymous" : true, 29 | "is_public_proxy" : true 30 | } 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/source-data/GeoIP2-Connection-Type-Test.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "::1.0.0.0/120" : { 4 | "connection_type" : "Dialup" 5 | } 6 | }, 7 | { 8 | "::1.0.1.0/120" : { 9 | "connection_type" : "Cable/DSL" 10 | } 11 | }, 12 | { 13 | "::1.0.2.0/119" : { 14 | "connection_type" : "Dialup" 15 | } 16 | }, 17 | { 18 | "::1.0.4.0/118" : { 19 | "connection_type" : "Dialup" 20 | } 21 | }, 22 | { 23 | "::1.0.8.0/117" : { 24 | "connection_type" : "Dialup" 25 | } 26 | }, 27 | { 28 | "::1.0.16.0/116" : { 29 | "connection_type" : "Dialup" 30 | } 31 | }, 32 | { 33 | "::1.0.32.0/115" : { 34 | "connection_type" : "Dialup" 35 | } 36 | }, 37 | { 38 | "::1.0.64.0/114" : { 39 | "connection_type" : "Dialup" 40 | } 41 | }, 42 | { 43 | "::1.0.128.0/113" : { 44 | "connection_type" : "Dialup" 45 | } 46 | }, 47 | { 48 | "::80.214.0.0/116" : { 49 | "connection_type" : "Cellular" 50 | } 51 | }, 52 | { 53 | "::96.1.0.0/112" : { 54 | "connection_type" : "Cable/DSL" 55 | } 56 | }, 57 | { 58 | "::96.10.0.0/111" : { 59 | "connection_type" : "Cable/DSL" 60 | } 61 | }, 62 | { 63 | "::96.69.0.0/112" : { 64 | "connection_type" : "Cable/DSL" 65 | } 66 | }, 67 | { 68 | "::96.94.0.0/111" : { 69 | "connection_type" : "Cable/DSL" 70 | } 71 | }, 72 | { 73 | "::108.96.0.0/107" : { 74 | "connection_type" : "Cellular" 75 | } 76 | }, 77 | { 78 | "::175.16.199.0/120" : { 79 | "connection_type" : "Dialup" 80 | } 81 | }, 82 | { 83 | "::187.156.138.0/120" : { 84 | "connection_type" : "Cable/DSL" 85 | } 86 | }, 87 | { 88 | "::201.243.200.0/120" : { 89 | "connection_type" : "Corporate" 90 | } 91 | }, 92 | { 93 | "::207.179.48.0/116" : { 94 | "connection_type" : "Cellular" 95 | } 96 | }, 97 | { 98 | "2003::/24" : { 99 | "connection_type" : "Cable/DSL" 100 | } 101 | } 102 | ] 103 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/source-data/README: -------------------------------------------------------------------------------- 1 | All of these but the City and Enterprise files are JSON dumps of the databases 2 | created by the GeoIP2 build integration tests 3 | (TestFor::MM::Integration::GeoIP2::Build). 4 | 5 | Additional data was added to match our legacy test databases. 6 | 7 | The City file is of unknown origin. 8 | 9 | The Enterprise file is a single example IP address, modified slightly to 10 | include all fields. 11 | 12 | The Precision files is the normal GeoIP2 files with an additional marker 13 | (128.101.101.101) to differentiate the two. 14 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-Anonymous-IP-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-Anonymous-IP-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-City-Test-Broken-Double-Format.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-City-Test-Broken-Double-Format.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-City-Test-Invalid-Node-Count.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-City-Test-Invalid-Node-Count.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-City-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-City-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-Connection-Type-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-Connection-Type-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-Country-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-Country-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-Domain-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-Domain-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-Enterprise-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-Enterprise-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-ISP-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-ISP-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-Precision-City-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-Precision-City-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-Precision-ISP-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/GeoIP2-Precision-ISP-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-string-value-entries.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-string-value-entries.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-broken-pointers-24.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-broken-pointers-24.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-broken-search-tree-24.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-broken-search-tree-24.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-decoder.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-decoder.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-ipv4-24.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-ipv4-24.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-ipv4-28.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-ipv4-28.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-ipv4-32.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-ipv4-32.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-ipv6-24.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-ipv6-24.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-ipv6-28.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-ipv6-28.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-ipv6-32.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-ipv6-32.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-metadata-pointers.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-metadata-pointers.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-mixed-24.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-mixed-24.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-mixed-28.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-mixed-28.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-mixed-32.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-mixed-32.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-nested.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/MaxMind-DB-test-nested.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/README.md: -------------------------------------------------------------------------------- 1 | The write-test-dbs script will create a small set of test databases with a 2 | variety of data and record sizes (24, 28, & 32 bit). 3 | 4 | These test databases are useful for testing code that reads MaxMind DB files. 5 | 6 | There is also a `maps-with-pointers.raw` file. This contains the raw output of 7 | the MaxMind::DB::Writer::Serializer module, when given a series of maps which 8 | share some keys and values. It is used to test that decoder code can handle 9 | pointers to map keys and values, as well as to the whole map. 10 | 11 | There are several ways to figure out what IP addresses are actually in the 12 | test databases. You can take a look at the 13 | [souce-data directory](https://github.com/maxmind/MaxMind-DB/tree/master/source-data) 14 | in this repository. This directory contains JSON files which are used to 15 | generate many (but not all) of the database files. 16 | 17 | You can also use the 18 | [mmdb-dump-database script](https://github.com/maxmind/MaxMind-DB-Reader-perl/blob/master/eg/mmdb-dump-database) 19 | in the 20 | [MaxMind-DB-Reader-perl repository](https://github.com/maxmind/MaxMind-DB-Reader-perl). 21 | 22 | Some databases are intentionally broken and cannot be dumped. You can look at 23 | the 24 | [script which generates these databases](https://github.com/maxmind/MaxMind-DB/blob/master/test-data/write-test-data.pl) 25 | to see what IP addresses they include, which will be necessary for those 26 | databases which cannot be dumped because they contain intentional errors. 27 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/maps-with-pointers.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/test-data/maps-with-pointers.raw -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/geoip2-golang/test-data/tidyall.ini: -------------------------------------------------------------------------------- 1 | [PerlTidy] 2 | select = **/*.{pl,pm,t} 3 | 4 | [JSON] 5 | select = **/*.json 6 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "test-data"] 2 | path = test-data 3 | url = git://github.com/maxmind/MaxMind-DB.git 4 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.4 5 | - 1.5 6 | - 1.6 7 | - tip 8 | 9 | before_install: 10 | - "if [[ $TRAVIS_GO_VERSION == 1.6 ]]; then go get -v github.com/golang/lint/golint; fi" 11 | 12 | install: 13 | - go get -v -t ./... 14 | 15 | script: 16 | - go test -race -cpu 1,4 -v 17 | - go test -race -v -tags appengine 18 | - "if [[ $TRAVIS_GO_VERSION == 1.6 ]]; then go vet ./...; fi" 19 | - "if [[ $TRAVIS_GO_VERSION == 1.6 ]]; then golint .; fi" 20 | 21 | sudo: false 22 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Gregory J. Oschwald 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 8 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 9 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 10 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 12 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 13 | PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/README.md: -------------------------------------------------------------------------------- 1 | # MaxMind DB Reader for Go # 2 | 3 | [![Build Status](https://travis-ci.org/oschwald/maxminddb-golang.png?branch=master)](https://travis-ci.org/oschwald/maxminddb-golang) 4 | [![Windows Build Status](https://ci.appveyor.com/api/projects/status/4j2f9oep8nnfrmov/branch/master?svg=true)](https://ci.appveyor.com/project/oschwald/maxminddb-golang/branch/master) 5 | [![GoDoc](https://godoc.org/github.com/oschwald/maxminddb-golang?status.png)](https://godoc.org/github.com/oschwald/maxminddb-golang) 6 | 7 | This is a Go reader for the MaxMind DB format. Although this can be used to 8 | read [GeoLite2](http://dev.maxmind.com/geoip/geoip2/geolite2/) and 9 | [GeoIP2](https://www.maxmind.com/en/geoip2-databases) databases, 10 | [geoip2](https://github.com/oschwald/geoip2-golang) provides a higher-level 11 | API for doing so. 12 | 13 | This is not an official MaxMind API. 14 | 15 | ## Installation ## 16 | 17 | ``` 18 | go get github.com/oschwald/maxminddb-golang 19 | ``` 20 | 21 | ## Usage ## 22 | 23 | [See GoDoc](http://godoc.org/github.com/oschwald/maxminddb-golang) for 24 | documentation and examples. 25 | 26 | ## Examples ## 27 | 28 | See [GoDoc](http://godoc.org/github.com/oschwald/maxminddb-golang) or 29 | `example_test.go` for examples. 30 | 31 | ## Contributing ## 32 | 33 | Contributions welcome! Please fork the repository and open a pull request 34 | with your changes. 35 | 36 | ## License ## 37 | 38 | This is free software, licensed under the ISC License. 39 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | 3 | os: Windows Server 2012 R2 4 | 5 | clone_folder: c:\gopath\src\github.com\oschwald\maxminddb-golang 6 | 7 | environment: 8 | GOPATH: c:\gopath 9 | 10 | install: 11 | - echo %PATH% 12 | - echo %GOPATH% 13 | - git submodule update --init --recursive 14 | - go version 15 | - go env 16 | - go get -v -t ./... 17 | 18 | build_script: 19 | - go test -v ./... 20 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/errors.go: -------------------------------------------------------------------------------- 1 | package maxminddb 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | // InvalidDatabaseError is returned when the database contains invalid data 9 | // and cannot be parsed. 10 | type InvalidDatabaseError struct { 11 | message string 12 | } 13 | 14 | func newInvalidDatabaseError(format string, args ...interface{}) InvalidDatabaseError { 15 | return InvalidDatabaseError{fmt.Sprintf(format, args...)} 16 | } 17 | 18 | func (e InvalidDatabaseError) Error() string { 19 | return e.message 20 | } 21 | 22 | // UnmarshalTypeError is returned when the value in the database cannot be 23 | // assigned to the specified data type. 24 | type UnmarshalTypeError struct { 25 | Value string // stringified copy of the database value that caused the error 26 | Type reflect.Type // type of the value that could not be assign to 27 | } 28 | 29 | func newUnmarshalTypeError(value interface{}, rType reflect.Type) UnmarshalTypeError { 30 | return UnmarshalTypeError{ 31 | Value: fmt.Sprintf("%v", value), 32 | Type: rType, 33 | } 34 | } 35 | 36 | func (e UnmarshalTypeError) Error() string { 37 | return fmt.Sprintf("maxminddb: cannot unmarshal %s into type %s", e.Value, e.Type.String()) 38 | } 39 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/key_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package maxminddb 4 | 5 | func (d *decoder) decodeStructKey(offset uint) (string, uint, error) { 6 | return d.decodeKeyString(offset) 7 | } 8 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/key_other.go: -------------------------------------------------------------------------------- 1 | // +build !appengine 2 | 3 | package maxminddb 4 | 5 | import ( 6 | "reflect" 7 | "unsafe" 8 | ) 9 | 10 | // decodeStructKey returns a string which points into the database. Don't keep 11 | // it around. 12 | func (d *decoder) decodeStructKey(offset uint) (string, uint, error) { 13 | typeNum, size, newOffset := d.decodeCtrlData(offset) 14 | switch typeNum { 15 | case _Pointer: 16 | pointer, ptrOffset := d.decodePointer(size, newOffset) 17 | s, _, err := d.decodeStructKey(pointer) 18 | return s, ptrOffset, err 19 | case _String: 20 | var s string 21 | val := (*reflect.StringHeader)(unsafe.Pointer(&s)) 22 | val.Data = uintptr(unsafe.Pointer(&d.buffer[newOffset])) 23 | val.Len = int(size) 24 | return s, newOffset + size, nil 25 | default: 26 | return "", 0, newInvalidDatabaseError("unexpected type when decoding struct key: %v", typeNum) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/mmap_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows,!appengine 2 | 3 | package maxminddb 4 | 5 | import ( 6 | "syscall" 7 | 8 | "golang.org/x/sys/unix" 9 | ) 10 | 11 | func mmap(fd int, length int) (data []byte, err error) { 12 | return unix.Mmap(fd, 0, length, syscall.PROT_READ, syscall.MAP_SHARED) 13 | } 14 | 15 | func munmap(b []byte) (err error) { 16 | return unix.Munmap(b) 17 | } 18 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/mmap_windows.go: -------------------------------------------------------------------------------- 1 | package maxminddb 2 | 3 | // Windows support largely borrowed from mmap-go. 4 | // 5 | // Copyright 2011 Evan Shaw. All rights reserved. 6 | // Use of this source code is governed by a BSD-style 7 | // license that can be found in the LICENSE file. 8 | 9 | import ( 10 | "errors" 11 | "os" 12 | "reflect" 13 | "sync" 14 | "unsafe" 15 | 16 | "golang.org/x/sys/windows" 17 | ) 18 | 19 | type memoryMap []byte 20 | 21 | // Windows 22 | var handleLock sync.Mutex 23 | var handleMap = map[uintptr]windows.Handle{} 24 | 25 | func mmap(fd int, length int) (data []byte, err error) { 26 | h, errno := windows.CreateFileMapping(windows.Handle(fd), nil, 27 | uint32(windows.PAGE_READONLY), 0, uint32(length), nil) 28 | if h == 0 { 29 | return nil, os.NewSyscallError("CreateFileMapping", errno) 30 | } 31 | 32 | addr, errno := windows.MapViewOfFile(h, uint32(windows.FILE_MAP_READ), 0, 33 | 0, uintptr(length)) 34 | if addr == 0 { 35 | return nil, os.NewSyscallError("MapViewOfFile", errno) 36 | } 37 | handleLock.Lock() 38 | handleMap[addr] = h 39 | handleLock.Unlock() 40 | 41 | m := memoryMap{} 42 | dh := m.header() 43 | dh.Data = addr 44 | dh.Len = length 45 | dh.Cap = dh.Len 46 | 47 | return m, nil 48 | } 49 | 50 | func (m *memoryMap) header() *reflect.SliceHeader { 51 | return (*reflect.SliceHeader)(unsafe.Pointer(m)) 52 | } 53 | 54 | func flush(addr, len uintptr) error { 55 | errno := windows.FlushViewOfFile(addr, len) 56 | return os.NewSyscallError("FlushViewOfFile", errno) 57 | } 58 | 59 | func munmap(b []byte) (err error) { 60 | m := memoryMap(b) 61 | dh := m.header() 62 | 63 | addr := dh.Data 64 | length := uintptr(dh.Len) 65 | 66 | flush(addr, length) 67 | err = windows.UnmapViewOfFile(addr) 68 | if err != nil { 69 | return err 70 | } 71 | 72 | handleLock.Lock() 73 | defer handleLock.Unlock() 74 | handle, ok := handleMap[addr] 75 | if !ok { 76 | // should be impossible; we would've errored above 77 | return errors.New("unknown base address") 78 | } 79 | delete(handleMap, addr) 80 | 81 | e := windows.CloseHandle(windows.Handle(handle)) 82 | return os.NewSyscallError("CloseHandle", e) 83 | } 84 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/reader_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package maxminddb 4 | 5 | import "io/ioutil" 6 | 7 | // Open takes a string path to a MaxMind DB file and returns a Reader 8 | // structure or an error. The database file is opened using a memory map, 9 | // except on Google App Engine where mmap is not supported; there the database 10 | // is loaded into memory. Use the Close method on the Reader object to return 11 | // the resources to the system. 12 | func Open(file string) (*Reader, error) { 13 | bytes, err := ioutil.ReadFile(file) 14 | if err != nil { 15 | return nil, err 16 | } 17 | 18 | return FromBytes(bytes) 19 | } 20 | 21 | // Close unmaps the database file from virtual memory and returns the 22 | // resources to the system. If called on a Reader opened using FromBytes 23 | // or Open on Google App Engine, this method does nothing. 24 | func (r *Reader) Close() error { 25 | return nil 26 | } 27 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/reader_other.go: -------------------------------------------------------------------------------- 1 | // +build !appengine 2 | 3 | package maxminddb 4 | 5 | import "os" 6 | 7 | // Open takes a string path to a MaxMind DB file and returns a Reader 8 | // structure or an error. The database file is opened using a memory map, 9 | // except on Google App Engine where mmap is not supported; there the database 10 | // is loaded into memory. Use the Close method on the Reader object to return 11 | // the resources to the system. 12 | func Open(file string) (*Reader, error) { 13 | mapFile, err := os.Open(file) 14 | if err != nil { 15 | return nil, err 16 | } 17 | defer func() { 18 | if rerr := mapFile.Close(); rerr != nil { 19 | err = rerr 20 | } 21 | }() 22 | 23 | stats, err := mapFile.Stat() 24 | if err != nil { 25 | return nil, err 26 | } 27 | 28 | fileSize := int(stats.Size()) 29 | mmap, err := mmap(int(mapFile.Fd()), fileSize) 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | reader, err := FromBytes(mmap) 35 | if err != nil { 36 | if err2 := munmap(mmap); err2 != nil { 37 | // failing to unmap the file is probably the more severe error 38 | return nil, err2 39 | } 40 | return nil, err 41 | } 42 | 43 | reader.hasMappedFile = true 44 | return reader, err 45 | } 46 | 47 | // Close unmaps the database file from virtual memory and returns the 48 | // resources to the system. If called on a Reader opened using FromBytes 49 | // or Open on Google App Engine, this method does nothing. 50 | func (r *Reader) Close() (err error) { 51 | if r.hasMappedFile { 52 | err = munmap(r.buffer) 53 | r.hasMappedFile = false 54 | } 55 | return err 56 | } 57 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/.gitattributes: -------------------------------------------------------------------------------- 1 | *.mmdb diff=mmdb 2 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/.gitconfig: -------------------------------------------------------------------------------- 1 | [diff "mmdb"] 2 | textconv = hexdump -v -C 3 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/.gitignore: -------------------------------------------------------------------------------- 1 | /_site 2 | .tidyall.d 3 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/.perltidyallrc: -------------------------------------------------------------------------------- 1 | --blank-lines-before-packages=0 2 | --iterations=2 3 | --no-outdent-long-comments 4 | -bar 5 | -boc 6 | -ci=4 7 | -i=4 8 | -l=78 9 | -nolq 10 | -se 11 | -wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=" 12 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/.tidyallrc: -------------------------------------------------------------------------------- 1 | [PerlTidy] 2 | select = **/*.{pl,pm,t,psgi} 3 | ignore = blib/**/* 4 | argv = --profile=$ROOT/.perltidyallrc 5 | 6 | [JSON] 7 | select = **/*.json 8 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/LICENSE: -------------------------------------------------------------------------------- 1 | This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 2 | Unported License. To view a copy of this license, visit 3 | http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative 4 | Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. 5 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/README.md: -------------------------------------------------------------------------------- 1 | MaxMind DB is a binary file format that stores data indexed by IP address 2 | subnets (IPv4 or IPv6). 3 | 4 | This repository contains the spec for that format. 5 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/perltidyrc: -------------------------------------------------------------------------------- 1 | --blank-lines-before-packages=0 2 | --iterations=2 3 | --no-outdent-long-comments 4 | -b 5 | -bar 6 | -boc 7 | -ci=4 8 | -i=4 9 | -l=78 10 | -nolq 11 | -se 12 | -wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=" 13 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/source-data/GeoIP2-Anonymous-IP-Test.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "::1.2.0.0/112" : { 4 | "is_anonymous" : true, 5 | "is_anonymous_vpn" : true 6 | } 7 | }, 8 | { 9 | "::71.160.223.0/120" : { 10 | "is_anonymous" : true, 11 | "is_hosting_provider" : true 12 | } 13 | }, 14 | { 15 | "::186.30.236.0/120" : { 16 | "is_anonymous" : true, 17 | "is_public_proxy" : true 18 | } 19 | }, 20 | { 21 | "::65.0.0.0/109" : { 22 | "is_anonymous" : true, 23 | "is_tor_exit_node" : true 24 | } 25 | }, 26 | { 27 | "abcd:1000::/112" : { 28 | "is_anonymous" : true, 29 | "is_public_proxy" : true 30 | } 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/source-data/GeoIP2-Connection-Type-Test.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "::1.0.0.0/120" : { 4 | "connection_type" : "Dialup" 5 | } 6 | }, 7 | { 8 | "::1.0.1.0/120" : { 9 | "connection_type" : "Cable/DSL" 10 | } 11 | }, 12 | { 13 | "::1.0.2.0/119" : { 14 | "connection_type" : "Dialup" 15 | } 16 | }, 17 | { 18 | "::1.0.4.0/118" : { 19 | "connection_type" : "Dialup" 20 | } 21 | }, 22 | { 23 | "::1.0.8.0/117" : { 24 | "connection_type" : "Dialup" 25 | } 26 | }, 27 | { 28 | "::1.0.16.0/116" : { 29 | "connection_type" : "Dialup" 30 | } 31 | }, 32 | { 33 | "::1.0.32.0/115" : { 34 | "connection_type" : "Dialup" 35 | } 36 | }, 37 | { 38 | "::1.0.64.0/114" : { 39 | "connection_type" : "Dialup" 40 | } 41 | }, 42 | { 43 | "::1.0.128.0/113" : { 44 | "connection_type" : "Dialup" 45 | } 46 | }, 47 | { 48 | "::80.214.0.0/116" : { 49 | "connection_type" : "Cellular" 50 | } 51 | }, 52 | { 53 | "::96.1.0.0/112" : { 54 | "connection_type" : "Cable/DSL" 55 | } 56 | }, 57 | { 58 | "::96.10.0.0/111" : { 59 | "connection_type" : "Cable/DSL" 60 | } 61 | }, 62 | { 63 | "::96.69.0.0/112" : { 64 | "connection_type" : "Cable/DSL" 65 | } 66 | }, 67 | { 68 | "::96.94.0.0/111" : { 69 | "connection_type" : "Cable/DSL" 70 | } 71 | }, 72 | { 73 | "::108.96.0.0/107" : { 74 | "connection_type" : "Cellular" 75 | } 76 | }, 77 | { 78 | "::175.16.199.0/120" : { 79 | "connection_type" : "Dialup" 80 | } 81 | }, 82 | { 83 | "::187.156.138.0/120" : { 84 | "connection_type" : "Cable/DSL" 85 | } 86 | }, 87 | { 88 | "::201.243.200.0/120" : { 89 | "connection_type" : "Corporate" 90 | } 91 | }, 92 | { 93 | "::207.179.48.0/116" : { 94 | "connection_type" : "Cellular" 95 | } 96 | }, 97 | { 98 | "2003::/24" : { 99 | "connection_type" : "Cable/DSL" 100 | } 101 | } 102 | ] 103 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/source-data/README: -------------------------------------------------------------------------------- 1 | All of these but the City and Enterprise files are JSON dumps of the databases 2 | created by the GeoIP2 build integration tests 3 | (TestFor::MM::Integration::GeoIP2::Build). 4 | 5 | Additional data was added to match our legacy test databases. 6 | 7 | The City file is of unknown origin. 8 | 9 | The Enterprise file is a single example IP address, modified slightly to 10 | include all fields. 11 | 12 | The Precision files is the normal GeoIP2 files with an additional marker 13 | (128.101.101.101) to differentiate the two. 14 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-Anonymous-IP-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-Anonymous-IP-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-City-Test-Broken-Double-Format.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-City-Test-Broken-Double-Format.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-City-Test-Invalid-Node-Count.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-City-Test-Invalid-Node-Count.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-City-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-City-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-Connection-Type-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-Connection-Type-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-Country-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-Country-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-Domain-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-Domain-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-Enterprise-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-Enterprise-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-ISP-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-ISP-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-Precision-City-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-Precision-City-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-Precision-ISP-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/GeoIP2-Precision-ISP-Test.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-string-value-entries.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-string-value-entries.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-broken-pointers-24.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-broken-pointers-24.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-broken-search-tree-24.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-broken-search-tree-24.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-decoder.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-decoder.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-ipv4-24.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-ipv4-24.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-ipv4-28.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-ipv4-28.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-ipv4-32.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-ipv4-32.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-ipv6-24.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-ipv6-24.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-ipv6-28.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-ipv6-28.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-ipv6-32.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-ipv6-32.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-metadata-pointers.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-metadata-pointers.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-mixed-24.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-mixed-24.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-mixed-28.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-mixed-28.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-mixed-32.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-mixed-32.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-nested.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/MaxMind-DB-test-nested.mmdb -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/README.md: -------------------------------------------------------------------------------- 1 | The write-test-dbs script will create a small set of test databases with a 2 | variety of data and record sizes (24, 28, & 32 bit). 3 | 4 | These test databases are useful for testing code that reads MaxMind DB files. 5 | 6 | There is also a `maps-with-pointers.raw` file. This contains the raw output of 7 | the MaxMind::DB::Writer::Serializer module, when given a series of maps which 8 | share some keys and values. It is used to test that decoder code can handle 9 | pointers to map keys and values, as well as to the whole map. 10 | 11 | There are several ways to figure out what IP addresses are actually in the 12 | test databases. You can take a look at the 13 | [souce-data directory](https://github.com/maxmind/MaxMind-DB/tree/master/source-data) 14 | in this repository. This directory contains JSON files which are used to 15 | generate many (but not all) of the database files. 16 | 17 | You can also use the 18 | [mmdb-dump-database script](https://github.com/maxmind/MaxMind-DB-Reader-perl/blob/master/eg/mmdb-dump-database) 19 | in the 20 | [MaxMind-DB-Reader-perl repository](https://github.com/maxmind/MaxMind-DB-Reader-perl). 21 | 22 | Some databases are intentionally broken and cannot be dumped. You can look at 23 | the 24 | [script which generates these databases](https://github.com/maxmind/MaxMind-DB/blob/master/test-data/write-test-data.pl) 25 | to see what IP addresses they include, which will be necessary for those 26 | databases which cannot be dumped because they contain intentional errors. 27 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/maps-with-pointers.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcjones/ct-sql/a1a22e4a3ef6b5ffba9293106a957383a43c28f7/Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/test-data/maps-with-pointers.raw -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/test-data/tidyall.ini: -------------------------------------------------------------------------------- 1 | [PerlTidy] 2 | select = **/*.{pl,pm,t} 3 | 4 | [JSON] 5 | select = **/*.json 6 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/traverse_test.go: -------------------------------------------------------------------------------- 1 | package maxminddb 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestNetworks(t *testing.T) { 9 | for _, recordSize := range []uint{24, 28, 32} { 10 | for _, ipVersion := range []uint{4, 6} { 11 | fileName := fmt.Sprintf("test-data/test-data/MaxMind-DB-test-ipv%d-%d.mmdb", ipVersion, recordSize) 12 | reader, err := Open(fileName) 13 | if err != nil { 14 | t.Fatalf("unexpected error while opening database: %v", err) 15 | } 16 | defer reader.Close() 17 | 18 | n := reader.Networks() 19 | for n.Next() { 20 | record := struct { 21 | IP string `maxminddb:"ip"` 22 | }{} 23 | network, err := n.Network(&record) 24 | if err != nil { 25 | t.Fatal(err) 26 | } 27 | 28 | if record.IP != network.IP.String() { 29 | t.Fatalf("expected %s got %s", record.IP, network.IP.String()) 30 | } 31 | } 32 | if n.Err() != nil { 33 | t.Fatal(n.Err()) 34 | } 35 | } 36 | } 37 | } 38 | 39 | func TestNetworksWithInvalidSearchTree(t *testing.T) { 40 | reader, err := Open("test-data/test-data/MaxMind-DB-test-broken-search-tree-24.mmdb") 41 | if err != nil { 42 | t.Fatalf("unexpected error while opening database: %v", err) 43 | } 44 | defer reader.Close() 45 | 46 | n := reader.Networks() 47 | for n.Next() { 48 | var record interface{} 49 | _, err := n.Network(&record) 50 | if err != nil { 51 | t.Fatal(err) 52 | } 53 | } 54 | if n.Err() == nil { 55 | t.Fatal("no error received when traversing an broken search tree") 56 | } else if n.Err().Error() != "invalid search tree at 128.128.128.128/32" { 57 | t.Error(n.Err()) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/oschwald/maxminddb-golang/verifier_test.go: -------------------------------------------------------------------------------- 1 | package maxminddb 2 | 3 | import "testing" 4 | 5 | func TestVerifyOnGoodDatabases(t *testing.T) { 6 | databases := []string{ 7 | "test-data/test-data/GeoIP2-Anonymous-IP-Test.mmdb", 8 | "test-data/test-data/GeoIP2-City-Test.mmdb", 9 | "test-data/test-data/GeoIP2-Connection-Type-Test.mmdb", 10 | "test-data/test-data/GeoIP2-Country-Test.mmdb", 11 | "test-data/test-data/GeoIP2-Domain-Test.mmdb", 12 | "test-data/test-data/GeoIP2-ISP-Test.mmdb", 13 | "test-data/test-data/GeoIP2-Precision-City-Test.mmdb", 14 | "test-data/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb", 15 | "test-data/test-data/MaxMind-DB-string-value-entries.mmdb", 16 | "test-data/test-data/MaxMind-DB-test-decoder.mmdb", 17 | "test-data/test-data/MaxMind-DB-test-ipv4-24.mmdb", 18 | "test-data/test-data/MaxMind-DB-test-ipv4-28.mmdb", 19 | "test-data/test-data/MaxMind-DB-test-ipv4-32.mmdb", 20 | "test-data/test-data/MaxMind-DB-test-ipv6-24.mmdb", 21 | "test-data/test-data/MaxMind-DB-test-ipv6-28.mmdb", 22 | "test-data/test-data/MaxMind-DB-test-ipv6-32.mmdb", 23 | "test-data/test-data/MaxMind-DB-test-mixed-24.mmdb", 24 | "test-data/test-data/MaxMind-DB-test-mixed-28.mmdb", 25 | "test-data/test-data/MaxMind-DB-test-mixed-32.mmdb", 26 | "test-data/test-data/MaxMind-DB-test-nested.mmdb", 27 | } 28 | 29 | for _, database := range databases { 30 | reader, err := Open(database) 31 | if err != nil { 32 | t.Error(err) 33 | } 34 | if err = reader.Verify(); err != nil { 35 | t.Errorf("Received error (%v) when verifying %v", err, database) 36 | } 37 | } 38 | } 39 | 40 | func TestVerifyOnBrokenDatabases(t *testing.T) { 41 | databases := []string{ 42 | "test-data/test-data/GeoIP2-City-Test-Broken-Double-Format.mmdb", 43 | "test-data/test-data/MaxMind-DB-test-broken-pointers-24.mmdb", 44 | "test-data/test-data/MaxMind-DB-test-broken-search-tree-24.mmdb", 45 | } 46 | 47 | for _, database := range databases { 48 | reader, err := Open(database) 49 | if err != nil { 50 | t.Error(err) 51 | } 52 | err = reader.Verify() 53 | if err == nil { 54 | t.Errorf( 55 | "Did not receive expected error when verifying %v", 56 | database, 57 | ) 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/vharitonsky/iniflags/.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/vharitonsky/iniflags/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 vharitonsky, valyala. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 1. Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 17 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/vharitonsky/iniflags/test_bom.ini: -------------------------------------------------------------------------------- 1 | bom=привет 2 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/vharitonsky/iniflags/test_config.ini: -------------------------------------------------------------------------------- 1 | # comment 2 | var0 = val0 ; comment 3 | 4 | [section] 5 | #import "test_config2.ini" # import another config 6 | var1 = "val#1\n\\\"\nx" # this is a test comment 7 | 8 | var3 = # empty value 9 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/vharitonsky/iniflags/test_config2.ini: -------------------------------------------------------------------------------- 1 | 2 | ; this file is imported from test_config.ini 3 | var2 = 1234 # comment 4 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/vharitonsky/iniflags/test_setconfigfile.ini: -------------------------------------------------------------------------------- 1 | x = foobar 2 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/ctxhttp_17_test.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 !plan9,go1.7 6 | 7 | package ctxhttp 8 | 9 | import ( 10 | "io" 11 | "net/http" 12 | "net/http/httptest" 13 | "testing" 14 | 15 | "context" 16 | ) 17 | 18 | func TestGo17Context(t *testing.T) { 19 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 20 | io.WriteString(w, "ok") 21 | })) 22 | ctx := context.Background() 23 | resp, err := Get(ctx, http.DefaultClient, ts.URL) 24 | if resp == nil || err != nil { 25 | t.Fatalf("error received from client: %v %v", err, resp) 26 | } 27 | resp.Body.Close() 28 | } 29 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/ctxhttp_pre17_test.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 !plan9,!go1.7 6 | 7 | package ctxhttp 8 | 9 | import ( 10 | "net" 11 | "net/http" 12 | "net/http/httptest" 13 | "sync" 14 | "testing" 15 | "time" 16 | 17 | "golang.org/x/net/context" 18 | ) 19 | 20 | // golang.org/issue/14065 21 | func TestClosesResponseBodyOnCancel(t *testing.T) { 22 | defer func() { testHookContextDoneBeforeHeaders = nop }() 23 | defer func() { testHookDoReturned = nop }() 24 | defer func() { testHookDidBodyClose = nop }() 25 | 26 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})) 27 | defer ts.Close() 28 | 29 | ctx, cancel := context.WithCancel(context.Background()) 30 | 31 | // closed when Do enters select case <-ctx.Done() 32 | enteredDonePath := make(chan struct{}) 33 | 34 | testHookContextDoneBeforeHeaders = func() { 35 | close(enteredDonePath) 36 | } 37 | 38 | testHookDoReturned = func() { 39 | // We now have the result (the Flush'd headers) at least, 40 | // so we can cancel the request. 41 | cancel() 42 | 43 | // But block the client.Do goroutine from sending 44 | // until Do enters into the <-ctx.Done() path, since 45 | // otherwise if both channels are readable, select 46 | // picks a random one. 47 | <-enteredDonePath 48 | } 49 | 50 | sawBodyClose := make(chan struct{}) 51 | testHookDidBodyClose = func() { close(sawBodyClose) } 52 | 53 | tr := &http.Transport{} 54 | defer tr.CloseIdleConnections() 55 | c := &http.Client{Transport: tr} 56 | req, _ := http.NewRequest("GET", ts.URL, nil) 57 | _, doErr := Do(ctx, c, req) 58 | 59 | select { 60 | case <-sawBodyClose: 61 | case <-time.After(5 * time.Second): 62 | t.Fatal("timeout waiting for body to close") 63 | } 64 | 65 | if doErr != ctx.Err() { 66 | t.Errorf("Do error = %v; want %v", doErr, ctx.Err()) 67 | } 68 | } 69 | 70 | type noteCloseConn struct { 71 | net.Conn 72 | onceClose sync.Once 73 | closefn func() 74 | } 75 | 76 | func (c *noteCloseConn) Close() error { 77 | c.onceClose.Do(c.closefn) 78 | return c.Conn.Close() 79 | } 80 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/context/withtimeout_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package context_test 6 | 7 | import ( 8 | "fmt" 9 | "time" 10 | 11 | "golang.org/x/net/context" 12 | ) 13 | 14 | func ExampleWithTimeout() { 15 | // Pass a context with a timeout to tell a blocking function that it 16 | // should abandon its work after the timeout elapses. 17 | ctx, _ := context.WithTimeout(context.Background(), 100*time.Millisecond) 18 | select { 19 | case <-time.After(200 * time.Millisecond): 20 | fmt.Println("overslept") 21 | case <-ctx.Done(): 22 | fmt.Println(ctx.Err()) // prints "context deadline exceeded" 23 | } 24 | // Output: 25 | // context deadline exceeded 26 | } 27 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | TEXT ·use(SB),NOSPLIT,$0 10 | RET 11 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-64 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/export_test.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 | var Itoa = itoa 10 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscall 15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 16 | 17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | syscall.Entersyscall() 19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 20 | syscall.Exitsyscall() 21 | return r, 0, syscall.Errno(errno) 22 | } 23 | 24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 25 | syscall.Entersyscall() 26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 27 | syscall.Exitsyscall() 28 | return r, 0, syscall.Errno(errno) 29 | } 30 | 31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 32 | syscall.Entersyscall() 33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 34 | syscall.Exitsyscall() 35 | return r, 0, syscall.Errno(errno) 36 | } 37 | 38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 40 | return r, 0, syscall.Errno(errno) 41 | } 42 | 43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/mkpost.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | // mkpost processes the output of cgo -godefs to 8 | // modify the generated types. It is used to clean up 9 | // the sys API in an architecture specific manner. 10 | // 11 | // mkpost is run after cgo -godefs by mkall.sh. 12 | package main 13 | 14 | import ( 15 | "fmt" 16 | "go/format" 17 | "io/ioutil" 18 | "log" 19 | "os" 20 | "regexp" 21 | ) 22 | 23 | func main() { 24 | b, err := ioutil.ReadAll(os.Stdin) 25 | if err != nil { 26 | log.Fatal(err) 27 | } 28 | s := string(b) 29 | 30 | goarch := os.Getenv("GOARCH") 31 | goos := os.Getenv("GOOS") 32 | if goarch == "s390x" && goos == "linux" { 33 | // Export the types of PtraceRegs fields. 34 | re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)") 35 | s = re.ReplaceAllString(s, "Ptrace$1") 36 | 37 | // Replace padding fields inserted by cgo with blank identifiers. 38 | re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*") 39 | s = re.ReplaceAllString(s, "_") 40 | 41 | // Replace other unwanted fields with blank identifiers. 42 | re = regexp.MustCompile("X_[A-Za-z0-9_]*") 43 | s = re.ReplaceAllString(s, "_") 44 | 45 | // Replace the control_regs union with a blank identifier for now. 46 | re = regexp.MustCompile("(Control_regs)\\s+\\[0\\]uint64") 47 | s = re.ReplaceAllString(s, "_ [0]uint64") 48 | } 49 | 50 | // gofmt 51 | b, err = format.Source([]byte(s)) 52 | if err != nil { 53 | log.Fatal(err) 54 | } 55 | 56 | // Append this command to the header to show where the new file 57 | // came from. 58 | re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)") 59 | b = re.ReplaceAll(b, []byte("$1 | go run mkpost.go")) 60 | 61 | fmt.Printf("%s", b) 62 | } 63 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_darwin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for Darwin from sys/syscall.h 7 | 8 | use strict; 9 | 10 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 11 | print STDERR "GOARCH or GOOS not defined in environment\n"; 12 | exit 1; 13 | } 14 | 15 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV); 16 | 17 | print <){ 29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){ 30 | my $name = $1; 31 | my $num = $2; 32 | $name =~ y/a-z/A-Z/; 33 | print " SYS_$name = $num;" 34 | } 35 | } 36 | 37 | print <){ 30 | if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){ 44 | next 45 | } 46 | 47 | print " $name = $num; // $proto\n"; 48 | 49 | # We keep Capsicum syscall numbers for FreeBSD 50 | # 9-STABLE here because we are not sure whether they 51 | # are mature and stable. 52 | if($num == 513){ 53 | print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n"; 54 | print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n"; 55 | print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n"; 56 | print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n"; 57 | } 58 | } 59 | } 60 | 61 | print < 999){ 29 | # ignore deprecated syscalls that are no longer implemented 30 | # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716 31 | return; 32 | } 33 | $name =~ y/a-z/A-Z/; 34 | print " SYS_$name = $num;\n"; 35 | } 36 | 37 | my $prev; 38 | open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc"; 39 | while(){ 40 | if(/^#define __NR_syscalls\s+/) { 41 | # ignore redefinitions of __NR_syscalls 42 | } 43 | elsif(/^#define __NR_(\w+)\s+([0-9]+)/){ 44 | $prev = $2; 45 | fmt($1, $2); 46 | } 47 | elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){ 48 | $prev = $2; 49 | fmt($1, $2); 50 | } 51 | elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){ 52 | fmt($1, $prev+$2) 53 | } 54 | } 55 | 56 | print <){ 31 | if($line =~ /^(.*)\\$/) { 32 | # Handle continuation 33 | $line = $1; 34 | $_ =~ s/^\s+//; 35 | $line .= $_; 36 | } else { 37 | # New line 38 | $line = $_; 39 | } 40 | next if $line =~ /\\$/; 41 | if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) { 42 | my $num = $1; 43 | my $proto = $6; 44 | my $compat = $8; 45 | my $name = "$7_$9"; 46 | 47 | $name = "$7_$11" if $11 ne ''; 48 | $name =~ y/a-z/A-Z/; 49 | 50 | if($compat eq '' || $compat eq '30' || $compat eq '50') { 51 | print " $name = $num; // $proto\n"; 52 | } 53 | } 54 | } 55 | 56 | print <){ 30 | if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $3; 33 | my $name = $4; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <= 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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_bsd_test.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 darwin dragonfly freebsd openbsd 6 | 7 | package unix_test 8 | 9 | import ( 10 | "runtime" 11 | "testing" 12 | 13 | "golang.org/x/sys/unix" 14 | ) 15 | 16 | const MNT_WAIT = 1 17 | 18 | func TestGetfsstat(t *testing.T) { 19 | n, err := unix.Getfsstat(nil, MNT_WAIT) 20 | if err != nil { 21 | t.Fatal(err) 22 | } 23 | 24 | data := make([]unix.Statfs_t, n) 25 | n, err = unix.Getfsstat(data, MNT_WAIT) 26 | if err != nil { 27 | t.Fatal(err) 28 | } 29 | 30 | empty := unix.Statfs_t{} 31 | for _, stat := range data { 32 | if stat == empty { 33 | t.Fatal("an empty Statfs_t struct was returned") 34 | } 35 | } 36 | } 37 | 38 | func TestSysctlRaw(t *testing.T) { 39 | if runtime.GOOS == "openbsd" { 40 | t.Skip("kern.proc.pid does not exist on OpenBSD") 41 | } 42 | 43 | _, err := unix.SysctlRaw("kern.proc.pid", unix.Getpid()) 44 | if err != nil { 45 | t.Fatal(err) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = int32(sec) 38 | tv.Usec = int32(usec) 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint32(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint32(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) 15 | 16 | func Getpagesize() int { return 4096 } 17 | 18 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 19 | 20 | func NsecToTimespec(nsec int64) (ts Timespec) { 21 | ts.Sec = nsec / 1e9 22 | ts.Nsec = nsec % 1e9 23 | return 24 | } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = sec 40 | tv.Usec = usec 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint64(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint64(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 76 | 77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 78 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 79 | const SYS___SYSCTL = SYS_SYSCTL 80 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func Getpagesize() int { return 4096 } 13 | 14 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 15 | 16 | func NsecToTimespec(nsec int64) (ts Timespec) { 17 | ts.Sec = int32(nsec / 1e9) 18 | ts.Nsec = int32(nsec % 1e9) 19 | return 20 | } 21 | 22 | func NsecToTimeval(nsec int64) (tv Timeval) { 23 | nsec += 999 // round up to microsecond 24 | tv.Usec = int32(nsec % 1e9 / 1e3) 25 | tv.Sec = int32(nsec / 1e9) 26 | return 27 | } 28 | 29 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 30 | func Gettimeofday(tv *Timeval) (err error) { 31 | // The tv passed to gettimeofday must be non-nil 32 | // but is otherwise unused. The answers come back 33 | // in the two registers. 34 | sec, usec, err := gettimeofday(tv) 35 | tv.Sec = int32(sec) 36 | tv.Usec = int32(usec) 37 | return err 38 | } 39 | 40 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 41 | k.Ident = uint32(fd) 42 | k.Filter = int16(mode) 43 | k.Flags = uint16(flags) 44 | } 45 | 46 | func (iov *Iovec) SetLen(length int) { 47 | iov.Len = uint32(length) 48 | } 49 | 50 | func (msghdr *Msghdr) SetControllen(length int) { 51 | msghdr.Controllen = uint32(length) 52 | } 53 | 54 | func (cmsg *Cmsghdr) SetLen(length int) { 55 | cmsg.Len = uint32(length) 56 | } 57 | 58 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 59 | var length = uint64(count) 60 | 61 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 62 | 63 | written = int(length) 64 | 65 | if e1 != 0 { 66 | err = e1 67 | } 68 | return 69 | } 70 | 71 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 72 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 16384 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = sec 38 | tv.Usec = usec 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint64(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint64(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = nsec / 1e9 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_test.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 freebsd 6 | 7 | package unix_test 8 | 9 | import ( 10 | "os" 11 | "testing" 12 | 13 | "golang.org/x/sys/unix" 14 | ) 15 | 16 | func TestSysctUint64(t *testing.T) { 17 | _, err := unix.SysctlUint64("vm.max_kernel_address") 18 | if err != nil { 19 | if os.Getenv("GO_BUILDER_NAME") == "freebsd-386-gce101" { 20 | t.Skipf("Ignoring known failing test (golang.org/issue/15186). Failed with: %v", err) 21 | } 22 | t.Fatal(err) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_test.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 darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix_test 8 | 9 | import ( 10 | "fmt" 11 | "testing" 12 | 13 | "golang.org/x/sys/unix" 14 | ) 15 | 16 | func testSetGetenv(t *testing.T, key, value string) { 17 | err := unix.Setenv(key, value) 18 | if err != nil { 19 | t.Fatalf("Setenv failed to set %q: %v", value, err) 20 | } 21 | newvalue, found := unix.Getenv(key) 22 | if !found { 23 | t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value) 24 | } 25 | if newvalue != value { 26 | t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value) 27 | } 28 | } 29 | 30 | func TestEnv(t *testing.T) { 31 | testSetGetenv(t, "TESTENV", "AVALUE") 32 | // make sure TESTENV gets set to "", not deleted 33 | testSetGetenv(t, "TESTENV", "") 34 | } 35 | 36 | func TestItoa(t *testing.T) { 37 | // Make most negative integer: 0x8000... 38 | i := 1 39 | for i<<1 != 0 { 40 | i <<= 1 41 | } 42 | if i >= 0 { 43 | t.Fatal("bad math") 44 | } 45 | s := unix.Itoa(i) 46 | f := fmt.Sprint(i) 47 | if s != f { 48 | t.Fatalf("itoa(%d) = %s, want %s", i, s, f) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This tool imports one CT log at a time into a MySQL database for ease of querying. 2 | 3 | It can be used with multiple CT logs by changing the `-log` flag. 4 | 5 | Quick Start: 6 | ``` 7 | # Acquire CT data 8 | go get github.com/jcjones/ct-sql/cmd/ct-sql 9 | 10 | # Configure ct-sql 11 | echo "dbConnect = mysql+tcp://root@localhost:3306/ctdb" > ./ct-sql.ini 12 | 13 | # Prepare the Database (using Goose migration took) 14 | go get bitbucket.org/liamstask/goose/cmd/goose 15 | 16 | pushd $GOPATH/src/github.com/jcjones/ct-sql 17 | cat db/dbconf.yml 18 | # Edit dbconf.yml as needed for user/pass 19 | goose up 20 | goose status 21 | popd 22 | 23 | # Scan a CT log 24 | ct-sql -config ./ct-sql.ini -log https://log.certly.io -limit 10000 25 | 26 | # Scan a Censys.io Export 27 | ct-sql -config ./ct-sql.ini -censysUrl https://url_to_censys/path/certificates.json 28 | 29 | # Resolve sites to determine their server locations 30 | go get github.com/jcjones/ct-sql/cmd/ct-sql-netscan 31 | ct-sql-netscan -config ./ct-sql.ini -limit 10 32 | ``` 33 | 34 | ## Vendored Packages 35 | We're using `[godep](https://github.com/tools/godep)` to handle vendored dependencies. 36 | ```godep save ./cmd/ct-sql/ ./cmd/ct-sql-netscan/ ./cmd/telemetry-update/ ./cmd/get-cert/``` 37 | -------------------------------------------------------------------------------- /cmd/get-cert/get-cert.go: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 | 5 | // Based on github.com/jmhodges/certificatetransparency/tools/lecsv 6 | 7 | package main 8 | 9 | import ( 10 | "flag" 11 | "fmt" 12 | "os" 13 | "strconv" 14 | 15 | "github.com/jcjones/ct-sql/utils" 16 | ) 17 | 18 | var ( 19 | config = utils.NewCTConfig() 20 | ) 21 | 22 | func main() { 23 | if config.CertPath == nil || len(*config.CertPath) == 0 { 24 | fmt.Fprintln(os.Stderr, "You must specify a Certificate Path") 25 | os.Exit(1) 26 | return 27 | } 28 | 29 | certFolderDB, err := utils.NewFolderDatabase(*config.CertPath, 0444, *config.CertsPerFolder) 30 | if err != nil { 31 | fmt.Fprintln(os.Stderr, fmt.Sprintf("unable to open Certificate Path: %s: %s", config.CertPath, err)) 32 | os.Exit(1) 33 | return 34 | } 35 | 36 | if flag.NArg() < 1 { 37 | fmt.Fprintln(os.Stderr, "Must specify the certificate ID to retrieve") 38 | os.Exit(1) 39 | return 40 | } 41 | 42 | id, err := strconv.ParseUint(flag.Arg(0), 10, 64) 43 | if err != nil { 44 | fmt.Fprintln(os.Stderr, fmt.Sprintf("unable to parse as integer: %s", err)) 45 | os.Exit(1) 46 | return 47 | } 48 | 49 | data, err := certFolderDB.Get(id) 50 | if err != nil { 51 | fmt.Fprintln(os.Stderr, fmt.Sprintf("unable to find CertID: %s", err)) 52 | os.Exit(1) 53 | return 54 | } 55 | 56 | _, err = os.Stdout.Write(data) 57 | if err != nil { 58 | fmt.Fprintln(os.Stderr, fmt.Sprintf("unable to write out CertID: %s", err)) 59 | os.Exit(1) 60 | return 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /db/dbconf.yml: -------------------------------------------------------------------------------- 1 | # what goose uses by default, even during migration creation 2 | development: 3 | driver: mysql 4 | open: root@tcp(localhost:3306)/ctdb?parseTime=true 5 | -------------------------------------------------------------------------------- /db/migrations/20160815094841_netscan-indicies.sql: -------------------------------------------------------------------------------- 1 | 2 | -- +goose Up 3 | -- SQL in section 'Up' is executed when this migration is applied 4 | 5 | ALTER TABLE `ctdb`.`resolvedname` 6 | ADD INDEX `timeIdx` (`time` ASC); 7 | ALTER TABLE `ctdb`.`resolvedname` 8 | ADD UNIQUE INDEX `name-time-ip-unique` (`nameID` ASC, `time` ASC, `ipaddr` ASC); 9 | 10 | -- +goose Down 11 | -- SQL section 'Down' is executed when this migration is rolled back 12 | 13 | ALTER TABLE `ctdb`.`resolvedname` 14 | DROP INDEX `timeIdx` ; 15 | 16 | ALTER TABLE `ctdb`.`resolvedname` 17 | DROP INDEX `name-time-ip-unique` ; 18 | -------------------------------------------------------------------------------- /db/migrations/20160817112844_certificate-indicies.sql: -------------------------------------------------------------------------------- 1 | 2 | -- +goose Up 3 | -- SQL in section 'Up' is executed when this migration is applied 4 | 5 | ALTER TABLE `ctdb`.`certificate` DROP INDEX `SerialIdx`; 6 | ALTER TABLE `ctdb`.`certificate` DROP INDEX `IssuerIdx`; 7 | 8 | -- +goose Down 9 | -- SQL section 'Down' is executed when this migration is rolled back 10 | 11 | ALTER TABLE `ctdb`.`certificate` ADD INDEX `SerialIdx` (`serial`); 12 | ALTER TABLE `ctdb`.`certificate` ADD INDEX `IssuerIdx` (`issuerID`); 13 | -------------------------------------------------------------------------------- /db/migrations/20160826153558_add_netscan_queue.sql: -------------------------------------------------------------------------------- 1 | 2 | -- +goose Up 3 | -- SQL in section 'Up' is executed when this migration is applied 4 | CREATE TABLE `netscanqueue` ( 5 | `nameID` bigint(20) unsigned DEFAULT NULL, 6 | `time` datetime DEFAULT NULL, 7 | PRIMARY KEY (`nameID`), 8 | CONSTRAINT `netscanqueue-nameID` FOREIGN KEY (`nameID`) REFERENCES `fqdn` (`nameID`) ON DELETE CASCADE 9 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 10 | 11 | INSERT INTO netscanqueue 12 | SELECT f.nameID, now() FROM fqdn AS f 13 | NATURAL LEFT JOIN resolvedname AS r 14 | WHERE r.time IS NULL; 15 | 16 | -- Recommended: 17 | -- GRANT DELETE ON ctdb.`netscanqueue` to 'ctsql'@'localhost'; 18 | 19 | -- +goose Down 20 | -- SQL section 'Down' is executed when this migration is rolled back 21 | 22 | DROP TABLE `netscanqueue`; -------------------------------------------------------------------------------- /db/migrations/20161014140240_add-firefox-pageload-telemetry.sql: -------------------------------------------------------------------------------- 1 | 2 | -- +goose Up 3 | -- SQL in section 'Up' is executed when this migration is applied 4 | 5 | CREATE TABLE IF NOT EXISTS `firefoxpageloadstls` ( 6 | `datestamp` date, 7 | `countTLS` int unsigned, 8 | `countPageloads` int unsigned, 9 | `timeAdded` datetime, 10 | PRIMARY KEY (`datestamp`) 11 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 12 | 13 | -- +goose Down 14 | -- SQL section 'Down' is executed when this migration is rolled back 15 | 16 | DROP TABLE `firefoxpageloadstls`; -------------------------------------------------------------------------------- /db/migrations/20161031093138_shard_new_old.sql: -------------------------------------------------------------------------------- 1 | 2 | -- +goose Up 3 | -- SQL in section 'Up' is executed when this migration is applied 4 | 5 | DROP VIEW IF EXISTS `unexpired_certificate`; 6 | 7 | CREATE TABLE `unexpired_certificate` ( 8 | `certID` bigint(20) unsigned NOT NULL, 9 | `issuerID` int(11) DEFAULT NULL, 10 | `notBefore` datetime DEFAULT NULL, 11 | `notAfter` datetime DEFAULT NULL, 12 | PRIMARY KEY (`certID`), 13 | KEY `notBeforeIdx` (`notBefore`) USING HASH, 14 | KEY `notAfterIdx` (`notAfter`) USING HASH, 15 | KEY `issuerIdx` (`issuerID`) USING HASH, 16 | CONSTRAINT `unexpired-certID` FOREIGN KEY (`certID`) REFERENCES `certificate` (`certID`) ON DELETE CASCADE 17 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 18 | 19 | INSERT INTO `unexpired_certificate` SELECT 20 | `certificate`.`certID` AS `certID`, 21 | `certificate`.`issuerID` AS `issuerID`, 22 | `certificate`.`notBefore` AS `notBefore`, 23 | `certificate`.`notAfter` AS `notAfter` 24 | FROM `certificate` WHERE (now() BETWEEN `certificate`.`notBefore` AND `certificate`.`notAfter`); 25 | 26 | ALTER TABLE `ctlog` 27 | ADD COLUMN `maxEntry` INT(11) NULL AFTER `url`, 28 | ADD COLUMN `lastEntryTime` DATETIME NULL AFTER `maxEntry`; 29 | 30 | UPDATE `ctlog` SET `maxEntry`=(SELECT MAX(`entryID`) FROM `ctlogentry` AS `in` WHERE `logID`=`in`.`logID`), `lastEntryTime`=now(); 31 | 32 | -- +goose Down 33 | -- SQL section 'Down' is executed when this migration is rolled back 34 | 35 | ALTER TABLE `ctlog` 36 | DROP COLUMN `lastEntryTime`, 37 | DROP COLUMN `maxEntry`; 38 | 39 | DROP TABLE IF EXISTS `unexpired_certificate`; 40 | 41 | CREATE VIEW `unexpired_certificate` AS 42 | select `certificate`.`certID` AS `certID`, 43 | `certificate`.`serial` AS `serial`, 44 | `certificate`.`issuerID` AS `issuerID`, 45 | `certificate`.`subject` AS `subject`, 46 | `certificate`.`notBefore` AS `notBefore`, 47 | `certificate`.`notAfter` AS `notAfter` 48 | FROM `certificate` WHERE (now() BETWEEN `certificate`.`notBefore` AND `certificate`.`notAfter`); 49 | -------------------------------------------------------------------------------- /db/migrations/20161031214332_use_dates_in_shard.sql: -------------------------------------------------------------------------------- 1 | 2 | -- +goose Up 3 | -- SQL in section 'Up' is executed when this migration is applied 4 | 5 | ALTER TABLE `unexpired_certificate` 6 | CHANGE COLUMN `notBefore` `notBefore` DATE NULL DEFAULT NULL, 7 | CHANGE COLUMN `notAfter` `notAfter` DATE NULL DEFAULT NULL; 8 | 9 | 10 | -- +goose Down 11 | -- SQL section 'Down' is executed when this migration is rolled back 12 | 13 | ALTER TABLE `unexpired_certificate` 14 | CHANGE COLUMN `notBefore` `notBefore` DATETIME NULL DEFAULT NULL , 15 | CHANGE COLUMN `notAfter` `notAfter` DATETIME NULL DEFAULT NULL ; 16 | -------------------------------------------------------------------------------- /db/migrations/20161103131125_remove_extra_indices.sql: -------------------------------------------------------------------------------- 1 | 2 | -- +goose Up 3 | -- SQL in section 'Up' is executed when this migration is applied 4 | 5 | ALTER TABLE `ctdb`.`registereddomain` DROP INDEX `LabelIdx`; 6 | 7 | -- +goose Down 8 | -- SQL section 'Down' is executed when this migration is rolled back 9 | 10 | ALTER TABLE `ctdb`.`registereddomain` ADD INDEX `LabelIdx` (`label`) USING HASH; 11 | -------------------------------------------------------------------------------- /db/migrations/20161103164403_add_foreign_keys.sql: -------------------------------------------------------------------------------- 1 | 2 | -- +goose Up 3 | -- SQL in section 'Up' is executed when this migration is applied 4 | 5 | ALTER TABLE `cert_fqdn` 6 | ADD CONSTRAINT `cert_fqdn-certID` FOREIGN KEY (`certID`) REFERENCES `certificate` (`certID`) ON DELETE CASCADE; 7 | 8 | ALTER TABLE `cert_fqdn` 9 | ADD CONSTRAINT `cert_fqdn-nameID` FOREIGN KEY (`nameID`) REFERENCES `fqdn` (`nameID`) ON DELETE CASCADE; 10 | 11 | ALTER TABLE `cert_registereddomain` 12 | ADD CONSTRAINT `cert_registereddomain-certID` FOREIGN KEY (`certID`) REFERENCES `certificate` (`certID`) ON DELETE CASCADE; 13 | 14 | ALTER TABLE `cert_registereddomain` 15 | ADD CONSTRAINT `cert_registereddomain-regdomID` FOREIGN KEY (`regdomID`) REFERENCES `registereddomain` (`regdomID`) ON DELETE CASCADE; 16 | 17 | 18 | -- +goose Down 19 | -- SQL section 'Down' is executed when this migration is rolled back 20 | 21 | ALTER TABLE `cert_fqdn` 22 | REMOVE CONSTRAINT `cert_fqdn-certID`; 23 | 24 | ALTER TABLE `cert_fqdn` 25 | REMOVE CONSTRAINT `cert_fqdn-nameID`; 26 | 27 | ALTER TABLE `cert_registereddomain` 28 | REMOVE CONSTRAINT `cert_registereddomain-certID`; 29 | 30 | ALTER TABLE `cert_registereddomain` 31 | REMOVE CONSTRAINT `cert_registereddomain-regdomID`; 32 | -------------------------------------------------------------------------------- /utils/conversions.go: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 | 5 | package utils 6 | 7 | import ( 8 | "time" 9 | ) 10 | 11 | func Uint64ToTimestamp(timestamp uint64) time.Time { 12 | return time.Unix(int64(timestamp/1000), int64(timestamp%1000)) 13 | } 14 | -------------------------------------------------------------------------------- /utils/folderdb.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | "path/filepath" 8 | ) 9 | 10 | type FolderDatabase struct { 11 | rootDir *os.File 12 | permissions os.FileMode 13 | folderSize uint64 14 | } 15 | 16 | func isDirectory(aPath string) bool { 17 | fileStat, err := os.Stat(aPath) 18 | if err != nil { 19 | return false 20 | } 21 | 22 | return fileStat.IsDir() 23 | } 24 | 25 | func NewFolderDatabase(aPath string, aPerms os.FileMode, aFolderSize uint64) (*FolderDatabase, error) { 26 | if !isDirectory(aPath) { 27 | return nil, fmt.Errorf("%s is not a directory. Aborting.", aPath) 28 | } 29 | 30 | fileObj, err := os.Open(aPath) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | db := &FolderDatabase{ 36 | rootDir: fileObj, 37 | permissions: aPerms, 38 | folderSize: aFolderSize, 39 | } 40 | 41 | return db, nil 42 | } 43 | 44 | func idToString(aID uint64) string { 45 | return fmt.Sprintf("%010x", aID) 46 | } 47 | 48 | func (db *FolderDatabase) getPathForID(aID uint64) (string, string) { 49 | subdirName := idToString(aID / db.folderSize) 50 | dirPath := filepath.Join(db.rootDir.Name(), subdirName) 51 | fileName := idToString(aID) 52 | filePath := filepath.Join(dirPath, fileName) 53 | return dirPath, filePath 54 | } 55 | 56 | func (db *FolderDatabase) Store(aID uint64, aData []byte) error { 57 | dirPath, filePath := db.getPathForID(aID) 58 | if !isDirectory(dirPath) { 59 | err := os.Mkdir(dirPath, os.ModeDir|0777) 60 | if err != nil { 61 | return err 62 | } 63 | } 64 | _, err := os.Stat(filePath) 65 | if err != nil && os.IsNotExist(err) { 66 | return ioutil.WriteFile(filePath, aData, db.permissions) 67 | } 68 | // Already exists, so skip 69 | return nil 70 | } 71 | 72 | func (db *FolderDatabase) Get(aID uint64) ([]byte, error) { 73 | _, fileName := db.getPathForID(aID) 74 | return ioutil.ReadFile(fileName) 75 | } 76 | --------------------------------------------------------------------------------