├── api └── .gitkeep ├── conf ├── .gitkeep ├── mariadb │ └── collation.cnf ├── redis │ └── redis.conf ├── db.example.json ├── cloud.example.yml └── nginx │ ├── api.safeu.a2os.club │ ├── nginx.dev.conf │ ├── nginx.prod.conf │ └── testapi.safeu.a2os.club ├── vendor ├── github.com │ ├── gin-gonic │ │ └── gin │ │ │ ├── wercker.yml │ │ │ ├── codecov.yml │ │ │ ├── doc.go │ │ │ ├── context_appengine.go │ │ │ ├── response_writer_1.7.go │ │ │ ├── json │ │ │ ├── json.go │ │ │ └── jsoniter.go │ │ │ ├── coverage.sh │ │ │ ├── test_helpers.go │ │ │ ├── binding │ │ │ ├── query.go │ │ │ ├── xml.go │ │ │ ├── msgpack.go │ │ │ ├── protobuf.go │ │ │ ├── json.go │ │ │ ├── form.go │ │ │ └── default_validator.go │ │ │ ├── response_writer_1.8.go │ │ │ ├── render │ │ │ ├── data.go │ │ │ ├── xml.go │ │ │ ├── yaml.go │ │ │ ├── redirect.go │ │ │ ├── msgpack.go │ │ │ ├── text.go │ │ │ ├── reader.go │ │ │ ├── render.go │ │ │ └── html.go │ │ │ ├── CONTRIBUTING.md │ │ │ ├── deprecated.go │ │ │ ├── LICENSE │ │ │ ├── fs.go │ │ │ ├── Makefile │ │ │ └── mode.go │ ├── ugorji │ │ └── go │ │ │ ├── codec │ │ │ ├── go.mod │ │ │ ├── goversion_vendor_gte_go17.go │ │ │ ├── goversion_vendor_lt_go15.go │ │ │ ├── goversion_unexportedembeddedptr_gte_go110.go │ │ │ ├── goversion_unexportedembeddedptr_lt_go110.go │ │ │ ├── goversion_vendor_eq_go15.go │ │ │ ├── goversion_vendor_eq_go16.go │ │ │ ├── codecgen.go │ │ │ ├── goversion_makemap_lt_go19.go │ │ │ ├── goversion_arrayof_gte_go15.go │ │ │ ├── goversion_makemap_gte_go19.go │ │ │ ├── goversion_arrayof_lt_go15.go │ │ │ ├── goversion_unsupported_lt_go14.go │ │ │ ├── gen-enc-chan.go.tmpl │ │ │ └── fast-path.not.go │ │ │ └── LICENSE │ ├── gorilla │ │ ├── securecookie │ │ │ ├── go.mod │ │ │ ├── fuzz.go │ │ │ ├── AUTHORS │ │ │ └── LICENSE │ │ ├── sessions │ │ │ ├── go.mod │ │ │ ├── cookie.go │ │ │ ├── cookie_go111.go │ │ │ ├── options.go │ │ │ ├── options_go111.go │ │ │ ├── LICENSE │ │ │ ├── AUTHORS │ │ │ └── lex.go │ │ └── context │ │ │ ├── README.md │ │ │ └── LICENSE │ ├── mattn │ │ ├── go-isatty │ │ │ ├── doc.go │ │ │ ├── isatty_others.go │ │ │ ├── isatty_solaris.go │ │ │ ├── isatty_linux.go │ │ │ ├── isatty_bsd.go │ │ │ ├── isatty_linux_ppc64x.go │ │ │ ├── LICENSE │ │ │ └── README.md │ │ └── go-colorable │ │ │ ├── colorable_appengine.go │ │ │ ├── colorable_others.go │ │ │ ├── LICENSE │ │ │ ├── noncolorable.go │ │ │ └── README.md │ ├── go-redis │ │ └── redis │ │ │ ├── doc.go │ │ │ ├── internal │ │ │ ├── util │ │ │ │ ├── safe.go │ │ │ │ ├── unsafe.go │ │ │ │ └── strconv.go │ │ │ ├── log.go │ │ │ ├── util.go │ │ │ ├── internal.go │ │ │ ├── pool │ │ │ │ ├── pool_single.go │ │ │ │ ├── pool_sticky.go │ │ │ │ └── conn.go │ │ │ ├── error.go │ │ │ ├── once.go │ │ │ └── consistenthash │ │ │ │ └── consistenthash.go │ │ │ ├── cluster_commands.go │ │ │ ├── Makefile │ │ │ ├── CHANGELOG.md │ │ │ ├── LICENSE │ │ │ ├── script.go │ │ │ └── iterator.go │ ├── jinzhu │ │ ├── gorm │ │ │ ├── dialects │ │ │ │ └── mysql │ │ │ │ │ └── mysql.go │ │ │ ├── test_all.sh │ │ │ ├── model.go │ │ │ ├── interface.go │ │ │ ├── docker-compose.yml │ │ │ ├── callback_row_query.go │ │ │ ├── License │ │ │ ├── field.go │ │ │ ├── README.md │ │ │ ├── callback_delete.go │ │ │ └── errors.go │ │ └── inflection │ │ │ ├── wercker.yml │ │ │ ├── LICENSE │ │ │ └── README.md │ ├── pilu │ │ ├── fresh │ │ │ ├── runner │ │ │ │ ├── limit_windows.go │ │ │ │ ├── limit_unix.go │ │ │ │ ├── runner.go │ │ │ │ ├── build.go │ │ │ │ ├── logger.go │ │ │ │ ├── watcher.go │ │ │ │ └── utils.go │ │ │ ├── runner.conf.sample │ │ │ ├── LICENSE │ │ │ └── main.go │ │ └── config │ │ │ ├── README.md │ │ │ ├── LICENSE │ │ │ ├── doc.go │ │ │ └── config.go │ ├── utrack │ │ └── gin-csrf │ │ │ ├── go.mod │ │ │ ├── LICENSE │ │ │ └── README.md │ ├── howeyc │ │ └── fsnotify │ │ │ ├── CONTRIBUTING.md │ │ │ ├── fsnotify_open_darwin.go │ │ │ ├── fsnotify_open_bsd.go │ │ │ ├── AUTHORS │ │ │ └── LICENSE │ ├── json-iterator │ │ └── go │ │ │ ├── test.sh │ │ │ ├── build.sh │ │ │ ├── Gopkg.lock │ │ │ ├── Gopkg.toml │ │ │ ├── fuzzy_mode_convert_table.md │ │ │ ├── jsoniter.go │ │ │ ├── pool.go │ │ │ ├── LICENSE │ │ │ ├── any_nil.go │ │ │ ├── any_int64.go │ │ │ ├── any_int32.go │ │ │ ├── any_uint64.go │ │ │ ├── iter_array.go │ │ │ ├── any_uint32.go │ │ │ ├── any_float.go │ │ │ ├── any_invalid.go │ │ │ ├── reflect_dynamic.go │ │ │ └── reflect_json_raw_message.go │ ├── gin-contrib │ │ ├── sse │ │ │ ├── writer.go │ │ │ ├── LICENSE │ │ │ └── README.md │ │ ├── cors │ │ │ ├── go.mod │ │ │ └── LICENSE │ │ └── sessions │ │ │ ├── LICENSE │ │ │ ├── cookie │ │ │ └── cookie.go │ │ │ └── go.mod │ ├── go-sql-driver │ │ └── mysql │ │ │ ├── appengine.go │ │ │ ├── result.go │ │ │ ├── transaction.go │ │ │ ├── CONTRIBUTING.md │ │ │ ├── utils_go18.go │ │ │ └── utils_go17.go │ ├── aliyun │ │ └── aliyun-oss-go-sdk │ │ │ └── oss │ │ │ ├── transport_1_6.go │ │ │ ├── transport_1_7.go │ │ │ └── model.go │ ├── satori │ │ └── go.uuid │ │ │ └── LICENSE │ └── golang │ │ └── protobuf │ │ └── LICENSE └── gopkg.in │ ├── yaml.v2 │ ├── go.mod │ ├── NOTICE │ ├── writerc.go │ └── LICENSE.libyaml │ └── go-playground │ └── validator.v8 │ ├── logo.png │ └── LICENSE ├── scripts ├── run-dev-docker-containers.sh ├── run-production-docker-containers.sh ├── gofmt.sh ├── build-docker-images.sh ├── search-prod-logs.sh ├── remove-database-files.sh ├── getcert.sh ├── install-docker-family-on-ubuntu-1804.sh ├── upgrade-safeu-containers.sh ├── prod-docker-compose.sh ├── staging-docker-compose.sh └── dev-docker-compose.sh ├── common ├── maintenance.go ├── log.go └── aliyunOSS.go ├── runner.conf ├── .github ├── ISSUE_TEMPLATE │ ├── ---------.md │ └── bug-report--en-.md └── workflows │ └── go.yml ├── .gitignore ├── item ├── models.go └── info.go ├── go.mod ├── ERRORS.md └── deployments └── dev-safeu └── docker-compose.yml /api/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /conf/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/wercker.yml: -------------------------------------------------------------------------------- 1 | box: wercker/default -------------------------------------------------------------------------------- /vendor/github.com/ugorji/go/codec/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/ugorji/go/codec 2 | 3 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/securecookie/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gorilla/securecookie 2 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/doc.go: -------------------------------------------------------------------------------- 1 | // Package isatty implements interface to isatty 2 | package isatty 3 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package redis implements a Redis client. 3 | */ 4 | package redis 5 | -------------------------------------------------------------------------------- /vendor/github.com/jinzhu/gorm/dialects/mysql/mysql.go: -------------------------------------------------------------------------------- 1 | package mysql 2 | 3 | import _ "github.com/go-sql-driver/mysql" 4 | -------------------------------------------------------------------------------- /vendor/github.com/pilu/fresh/runner/limit_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package runner 4 | 5 | func initLimit() { 6 | } 7 | -------------------------------------------------------------------------------- /scripts/run-dev-docker-containers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sudo docker run --rm -it -e TZ=Asia/Shanghai -p 8080:8080 safeu-backend-dev 4 | -------------------------------------------------------------------------------- /scripts/run-production-docker-containers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sudo docker run --rm -it -e TZ=Asia/Shanghai -p 8080:8080 safeu-backend 4 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/go.mod: -------------------------------------------------------------------------------- 1 | module "gopkg.in/yaml.v2" 2 | 3 | require ( 4 | "gopkg.in/check.v1" v0.0.0-20161208181325-20d25e280405 5 | ) 6 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | notify: 3 | gitter: 4 | default: 5 | url: https://webhooks.gitter.im/e/d90dcdeeab2f1e357165 6 | -------------------------------------------------------------------------------- /vendor/gopkg.in/go-playground/validator.v8/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NUAA-Open-Source/safeu-backend/master/vendor/gopkg.in/go-playground/validator.v8/logo.png -------------------------------------------------------------------------------- /vendor/github.com/gorilla/sessions/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gorilla/sessions 2 | 3 | require ( 4 | github.com/gorilla/context v1.1.1 5 | github.com/gorilla/securecookie v1.1.1 6 | ) 7 | -------------------------------------------------------------------------------- /vendor/github.com/jinzhu/gorm/test_all.sh: -------------------------------------------------------------------------------- 1 | dialects=("postgres" "mysql" "mssql" "sqlite") 2 | 3 | for dialect in "${dialects[@]}" ; do 4 | DEBUG=false GORM_DIALECT=${dialect} go test 5 | done 6 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package gin implements a HTTP web framework called gin. 3 | 4 | See https://gin-gonic.github.io/gin/ for more information about gin. 5 | */ 6 | package gin // import "github.com/gin-gonic/gin" 7 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/internal/util/safe.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package util 4 | 5 | func BytesToString(b []byte) string { 6 | return string(b) 7 | } 8 | 9 | func StringToBytes(s string) []byte { 10 | return []byte(s) 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/utrack/gin-csrf/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/utrack/gin-csrf 2 | 3 | require ( 4 | github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9 5 | github.com/gin-contrib/sessions v0.0.0-20190101140330-dc5246754963 6 | github.com/gin-gonic/gin v1.3.0 7 | ) 8 | -------------------------------------------------------------------------------- /vendor/github.com/howeyc/fsnotify/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Moving Notice 4 | 5 | There is a fork being actively developed with a new API in preparation for the Go Standard Library: 6 | [github.com/go-fsnotify/fsnotify](https://github.com/go-fsnotify/fsnotify) 7 | 8 | -------------------------------------------------------------------------------- /vendor/github.com/ugorji/go/codec/goversion_vendor_gte_go17.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build go1.7 5 | 6 | package codec 7 | 8 | const genCheckVendor = true 9 | -------------------------------------------------------------------------------- /vendor/github.com/ugorji/go/codec/goversion_vendor_lt_go15.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build !go1.5 5 | 6 | package codec 7 | 8 | var genCheckVendor = false 9 | -------------------------------------------------------------------------------- /scripts/gofmt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | gofmt=$(govendor fmt +l) 4 | echo ${gofmt} 5 | 6 | if [[ ${#gofmt} != 0 ]]; then 7 | echo "There is unformatted code, you should use `go fmt ./\.\.\.` to format it." 8 | exit 1 9 | else 10 | echo "Codes are formatted." 11 | exit 0 12 | fi 13 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/internal/log.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | ) 7 | 8 | var Logger *log.Logger 9 | 10 | func Logf(s string, args ...interface{}) { 11 | if Logger == nil { 12 | return 13 | } 14 | Logger.Output(2, fmt.Sprintf(s, args...)) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_gte_go110.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build go1.10 5 | 6 | package codec 7 | 8 | const allowSetUnexportedEmbeddedPtr = false 9 | -------------------------------------------------------------------------------- /vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_lt_go110.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build !go1.10 5 | 6 | package codec 7 | 8 | const allowSetUnexportedEmbeddedPtr = true 9 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/context_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | // Copyright 2017 Manu Martinez-Almeida. All rights reserved. 4 | // Use of this source code is governed by a MIT style 5 | // license that can be found in the LICENSE file. 6 | 7 | package gin 8 | 9 | func init() { 10 | defaultAppEngine = true 11 | } 12 | -------------------------------------------------------------------------------- /scripts/build-docker-images.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Build safeu-backend-dev docker image for development 4 | sudo docker build -t safeu-backend-dev:latest -f ../build/package/safeu-backend-dev/Dockerfile .. 5 | 6 | # Build safeu-backend docker image for production 7 | sudo docker build -t safeu-backend:latest -f ../build/package/safeu-backend/Dockerfile .. 8 | -------------------------------------------------------------------------------- /vendor/github.com/howeyc/fsnotify/fsnotify_open_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 darwin 6 | 7 | package fsnotify 8 | 9 | import "syscall" 10 | 11 | const open_FLAGS = syscall.O_EVTONLY 12 | -------------------------------------------------------------------------------- /vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go15.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build go1.5,!go1.6 5 | 6 | package codec 7 | 8 | import "os" 9 | 10 | var genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") == "1" 11 | -------------------------------------------------------------------------------- /vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go16.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build go1.6,!go1.7 5 | 6 | package codec 7 | 8 | import "os" 9 | 10 | var genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") != "0" 11 | -------------------------------------------------------------------------------- /conf/mariadb/collation.cnf: -------------------------------------------------------------------------------- 1 | [client] 2 | default-character-set=utf8mb4 3 | 4 | [mysql] 5 | default-character-set=utf8mb4 6 | 7 | [mysqld] 8 | character-set-server = utf8mb4 9 | character-set-client-handshake = utf8mb4 10 | 11 | init-connect='SET NAMES utf8mb4 12 | init-connect='SET collation_connection = utf8mb4_bin' 13 | 14 | collation-server = utf8mb4_bin 15 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/response_writer_1.7.go: -------------------------------------------------------------------------------- 1 | // +build !go1.8 2 | 3 | // Copyright 2018 Gin Core Team. All rights reserved. 4 | // Use of this source code is governed by a MIT style 5 | // license that can be found in the LICENSE file. 6 | 7 | package gin 8 | 9 | // ResponseWriter ... 10 | type ResponseWriter interface { 11 | responseWriterBase 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/json-iterator/go/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | echo "" > coverage.txt 5 | 6 | for d in $(go list ./... | grep -v vendor); do 7 | go test -coverprofile=profile.out -coverpkg=github.com/json-iterator/go $d 8 | if [ -f profile.out ]; then 9 | cat profile.out >> coverage.txt 10 | rm profile.out 11 | fi 12 | done 13 | -------------------------------------------------------------------------------- /vendor/github.com/ugorji/go/codec/codecgen.go: -------------------------------------------------------------------------------- 1 | // +build codecgen generated 2 | 3 | package codec 4 | 5 | // this file is here, to set the codecgen variable to true 6 | // when the build tag codecgen is set. 7 | // 8 | // this allows us do specific things e.g. skip missing fields tests, 9 | // when running in codecgen mode. 10 | 11 | func init() { 12 | codecgen = true 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/howeyc/fsnotify/fsnotify_open_bsd.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 freebsd openbsd netbsd dragonfly 6 | 7 | package fsnotify 8 | 9 | import "syscall" 10 | 11 | const open_FLAGS = syscall.O_NONBLOCK | syscall.O_RDONLY 12 | -------------------------------------------------------------------------------- /conf/redis/redis.conf: -------------------------------------------------------------------------------- 1 | notify-keyspace-events "Ex" 2 | # requirepass "safeu" 3 | save 60 100 4 | save 900 1 5 | save 300 10 6 | stop-writes-on-bgsave-error no 7 | rdbcompression yes 8 | dbfilename dump.rdb 9 | 10 | appendonly no 11 | appendfsync everysec 12 | no-appendfsync-on-rewrite no 13 | auto-aof-rewrite-percentage 100 14 | auto-aof-rewrite-min-size 64mb 15 | 16 | dir /data 17 | -------------------------------------------------------------------------------- /vendor/github.com/ugorji/go/codec/goversion_makemap_lt_go19.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build !go1.9 5 | 6 | package codec 7 | 8 | import "reflect" 9 | 10 | func makeMapReflect(t reflect.Type, size int) reflect.Value { 11 | return reflect.MakeMap(t) 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/pilu/fresh/runner/limit_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package runner 4 | 5 | import ( 6 | "syscall" 7 | "fmt" 8 | ) 9 | 10 | func initLimit() { 11 | var rLimit syscall.Rlimit 12 | rLimit.Max = 10000 13 | rLimit.Cur = 10000 14 | err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit) 15 | if err != nil { 16 | fmt.Println("Error Setting Rlimit ", err) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/json/json.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Bo-Yi Wu. 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 | // +build !jsoniter 6 | 7 | package json 8 | 9 | import "encoding/json" 10 | 11 | var ( 12 | Marshal = json.Marshal 13 | MarshalIndent = json.MarshalIndent 14 | NewDecoder = json.NewDecoder 15 | ) 16 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/coverage.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | echo "mode: count" > coverage.out 6 | 7 | for d in $(go list ./... | grep -E 'gin$|binding$|render$' | grep -v 'examples'); do 8 | go test -v -covermode=count -coverprofile=profile.out $d 9 | if [ -f profile.out ]; then 10 | cat profile.out | grep -v "mode:" >> coverage.out 11 | rm profile.out 12 | fi 13 | done 14 | -------------------------------------------------------------------------------- /vendor/github.com/jinzhu/gorm/model.go: -------------------------------------------------------------------------------- 1 | package gorm 2 | 3 | import "time" 4 | 5 | // Model base model definition, including fields `ID`, `CreatedAt`, `UpdatedAt`, `DeletedAt`, which could be embedded in your models 6 | // type User struct { 7 | // gorm.Model 8 | // } 9 | type Model struct { 10 | ID uint `gorm:"primary_key"` 11 | CreatedAt time.Time 12 | UpdatedAt time.Time 13 | DeletedAt *time.Time `sql:"index"` 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/ugorji/go/codec/goversion_arrayof_gte_go15.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build go1.5 5 | 6 | package codec 7 | 8 | import "reflect" 9 | 10 | const reflectArrayOfSupported = true 11 | 12 | func reflectArrayOf(count int, elem reflect.Type) reflect.Type { 13 | return reflect.ArrayOf(count, elem) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/json-iterator/go/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | set -x 4 | 5 | if [ ! -d /tmp/build-golang/src/github.com/json-iterator ]; then 6 | mkdir -p /tmp/build-golang/src/github.com/json-iterator 7 | ln -s $PWD /tmp/build-golang/src/github.com/json-iterator/go 8 | fi 9 | export GOPATH=/tmp/build-golang 10 | go get -u github.com/golang/dep/cmd/dep 11 | cd /tmp/build-golang/src/github.com/json-iterator/go 12 | exec $GOPATH/bin/dep ensure -update 13 | -------------------------------------------------------------------------------- /conf/db.example.json: -------------------------------------------------------------------------------- 1 | { 2 | "Master": { 3 | "User": "your_db_username", 4 | "Pass": "your_db_password", 5 | "Host": "your_db_ip_address", 6 | "Port": "your_db_port", 7 | "Database": "safeu", 8 | "MaxIdleConns": 30, 9 | "MaxOpenConns": 100, 10 | "ConnMaxLifetime":3600, 11 | "Debug": false 12 | }, 13 | "Redis": { 14 | "Host": "your_redis_ip_address", 15 | "Port": "your_redis_port", 16 | "Pass": "your_redis_password" 17 | } 18 | } -------------------------------------------------------------------------------- /vendor/github.com/ugorji/go/codec/goversion_makemap_gte_go19.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build go1.9 5 | 6 | package codec 7 | 8 | import "reflect" 9 | 10 | func makeMapReflect(t reflect.Type, size int) reflect.Value { 11 | if size < 0 { 12 | return reflect.MakeMapWithSize(t, 4) 13 | } 14 | return reflect.MakeMapWithSize(t, size) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/ugorji/go/codec/goversion_arrayof_lt_go15.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build !go1.5 5 | 6 | package codec 7 | 8 | import "reflect" 9 | 10 | const reflectArrayOfSupported = false 11 | 12 | func reflectArrayOf(count int, elem reflect.Type) reflect.Type { 13 | panic("codec: reflect.ArrayOf unsupported in this go version") 14 | } 15 | -------------------------------------------------------------------------------- /common/maintenance.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "log" 5 | "net/http" 6 | 7 | "github.com/gin-gonic/gin" 8 | ) 9 | 10 | func MaintenanceHandling() gin.HandlerFunc { 11 | return func(c *gin.Context) { 12 | if MAINTENANCE { 13 | c.JSON(http.StatusServiceUnavailable, gin.H{ 14 | "err_code": 10008, 15 | "message": Errors[10008], 16 | }) 17 | log.Println(c.ClientIP(), "Maintenance mode is open") 18 | c.Abort() 19 | } 20 | 21 | c.Next() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /common/log.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "log" 5 | "os" 6 | ) 7 | 8 | var ( 9 | logFile *os.File 10 | err error 11 | ) 12 | 13 | func InitLogger() { 14 | 15 | os.Mkdir("log", os.ModePerm|os.ModeDir) 16 | logFile, err = os.OpenFile("log/safeu.log", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644) 17 | if err != nil { 18 | log.Fatal(err) 19 | } 20 | if !DEBUG { 21 | log.SetOutput(logFile) 22 | } 23 | } 24 | 25 | func GetLogFile() *os.File { 26 | return logFile 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/pilu/fresh/runner.conf.sample: -------------------------------------------------------------------------------- 1 | root: . 2 | tmp_path: ./tmp 3 | build_name: runner-build 4 | build_log: runner-build-errors.log 5 | valid_ext: .go, .tpl, .tmpl, .html 6 | no_rebuild_ext: .tpl, .tmpl, .html 7 | ignored: assets, tmp 8 | build_delay: 600 9 | colors: 1 10 | log_color_main: cyan 11 | log_color_build: yellow 12 | log_color_runner: green 13 | log_color_watcher: magenta 14 | log_color_app: 15 | -------------------------------------------------------------------------------- /vendor/github.com/jinzhu/inflection/wercker.yml: -------------------------------------------------------------------------------- 1 | box: golang 2 | 3 | build: 4 | steps: 5 | - setup-go-workspace 6 | 7 | # Gets the dependencies 8 | - script: 9 | name: go get 10 | code: | 11 | go get 12 | 13 | # Build the project 14 | - script: 15 | name: go build 16 | code: | 17 | go build ./... 18 | 19 | # Test the project 20 | - script: 21 | name: go test 22 | code: | 23 | go test ./... 24 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/json/jsoniter.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Bo-Yi Wu. 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 | // +build jsoniter 6 | 7 | package json 8 | 9 | import "github.com/json-iterator/go" 10 | 11 | var ( 12 | json = jsoniter.ConfigCompatibleWithStandardLibrary 13 | Marshal = json.Marshal 14 | MarshalIndent = json.MarshalIndent 15 | NewDecoder = json.NewDecoder 16 | ) 17 | -------------------------------------------------------------------------------- /runner.conf: -------------------------------------------------------------------------------- 1 | root: . 2 | tmp_path: ./tmp 3 | build_name: runner-build 4 | build_log: runner-build-errors.log 5 | valid_ext: .go, .tpl, .tmpl, .html 6 | no_rebuild_ext: .tpl, .tmpl, .html 7 | ignored: assets, tmp, vendor, db-data, data, data-dev, log, api, build, deployments 8 | build_delay: 600 9 | colors: 1 10 | log_color_main: cyan 11 | log_color_build: yellow 12 | log_color_runner: green 13 | log_color_watcher: magenta 14 | log_color_app: -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/internal/util/unsafe.go: -------------------------------------------------------------------------------- 1 | // +build !appengine 2 | 3 | package util 4 | 5 | import ( 6 | "unsafe" 7 | ) 8 | 9 | // BytesToString converts byte slice to string. 10 | func BytesToString(b []byte) string { 11 | return *(*string)(unsafe.Pointer(&b)) 12 | } 13 | 14 | // StringToBytes converts string to byte slice. 15 | func StringToBytes(s string) []byte { 16 | return *(*[]byte)(unsafe.Pointer( 17 | &struct { 18 | string 19 | Cap int 20 | }{s, len(s)}, 21 | )) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/cluster_commands.go: -------------------------------------------------------------------------------- 1 | package redis 2 | 3 | import "sync/atomic" 4 | 5 | func (c *ClusterClient) DBSize() *IntCmd { 6 | cmd := NewIntCmd("dbsize") 7 | var size int64 8 | err := c.ForEachMaster(func(master *Client) error { 9 | n, err := master.DBSize().Result() 10 | if err != nil { 11 | return err 12 | } 13 | atomic.AddInt64(&size, n) 14 | return nil 15 | }) 16 | if err != nil { 17 | cmd.setErr(err) 18 | return cmd 19 | } 20 | cmd.val = size 21 | return cmd 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/sessions/cookie.go: -------------------------------------------------------------------------------- 1 | // +build !go1.11 2 | 3 | package sessions 4 | 5 | import "net/http" 6 | 7 | // newCookieFromOptions returns an http.Cookie with the options set. 8 | func newCookieFromOptions(name, value string, options *Options) *http.Cookie { 9 | return &http.Cookie{ 10 | Name: name, 11 | Value: value, 12 | Path: options.Path, 13 | Domain: options.Domain, 14 | MaxAge: options.MaxAge, 15 | Secure: options.Secure, 16 | HttpOnly: options.HttpOnly, 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/test_helpers.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Manu Martinez-Almeida. 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 gin 6 | 7 | import "net/http" 8 | 9 | // CreateTestContext returns a fresh engine and context for testing purposes 10 | func CreateTestContext(w http.ResponseWriter) (c *Context, r *Engine) { 11 | r = New() 12 | c = r.allocateContext() 13 | c.reset() 14 | c.writermem.reset(w) 15 | return 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_others.go: -------------------------------------------------------------------------------- 1 | // +build appengine js 2 | 3 | package isatty 4 | 5 | // IsTerminal returns true if the file descriptor is terminal which 6 | // is always false on js and appengine classic which is a sandboxed PaaS. 7 | func IsTerminal(fd uintptr) bool { 8 | return false 9 | } 10 | 11 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 12 | // terminal. This is also always false on this environment. 13 | func IsCygwinTerminal(fd uintptr) bool { 14 | return false 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/gin-contrib/sse/writer.go: -------------------------------------------------------------------------------- 1 | package sse 2 | 3 | import "io" 4 | 5 | type stringWriter interface { 6 | io.Writer 7 | WriteString(string) (int, error) 8 | } 9 | 10 | type stringWrapper struct { 11 | io.Writer 12 | } 13 | 14 | func (w stringWrapper) WriteString(str string) (int, error) { 15 | return w.Writer.Write([]byte(str)) 16 | } 17 | 18 | func checkWriter(writer io.Writer) stringWriter { 19 | if w, ok := writer.(stringWriter); ok { 20 | return w 21 | } else { 22 | return stringWrapper{writer} 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/securecookie/fuzz.go: -------------------------------------------------------------------------------- 1 | // +build gofuzz 2 | 3 | package securecookie 4 | 5 | var hashKey = []byte("very-secret12345") 6 | var blockKey = []byte("a-lot-secret1234") 7 | var s = New(hashKey, blockKey) 8 | 9 | type Cookie struct { 10 | B bool 11 | I int 12 | S string 13 | } 14 | 15 | func Fuzz(data []byte) int { 16 | datas := string(data) 17 | var c Cookie 18 | if err := s.Decode("fuzz", datas, &c); err != nil { 19 | return 0 20 | } 21 | if _, err := s.Encode("fuzz", c); err != nil { 22 | panic(err) 23 | } 24 | return 1 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/sessions/cookie_go111.go: -------------------------------------------------------------------------------- 1 | // +build go1.11 2 | 3 | package sessions 4 | 5 | import "net/http" 6 | 7 | // newCookieFromOptions returns an http.Cookie with the options set. 8 | func newCookieFromOptions(name, value string, options *Options) *http.Cookie { 9 | return &http.Cookie{ 10 | Name: name, 11 | Value: value, 12 | Path: options.Path, 13 | Domain: options.Domain, 14 | MaxAge: options.MaxAge, 15 | Secure: options.Secure, 16 | HttpOnly: options.HttpOnly, 17 | SameSite: options.SameSite, 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/sessions/options.go: -------------------------------------------------------------------------------- 1 | // +build !go1.11 2 | 3 | package sessions 4 | 5 | // Options stores configuration for a session or session store. 6 | // 7 | // Fields are a subset of http.Cookie fields. 8 | type Options struct { 9 | Path string 10 | Domain string 11 | // MaxAge=0 means no Max-Age attribute specified and the cookie will be 12 | // deleted after the browser session ends. 13 | // MaxAge<0 means delete cookie immediately. 14 | // MaxAge>0 means Max-Age attribute present and given in seconds. 15 | MaxAge int 16 | Secure bool 17 | HttpOnly bool 18 | } 19 | -------------------------------------------------------------------------------- /scripts/search-prod-logs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Author: TripleZ 3 | 4 | echo -e " 5 | This script is for searching the safeu-backend application log with 6 | your specific keyword. 7 | 8 | Usage: 9 | ./search-prod-logs.sh [OPTIONS] Search logs 10 | 11 | Example: 12 | ./search-prod-logs.sh --tail 1000 Show the last 1000 lines of log 13 | " 14 | 15 | echo -e "\n Input your query keyword: \c" 16 | read kw 17 | echo "" 18 | 19 | sudo docker-compose -f ../deployments/prod-safeu/docker-compose.yml logs -t "$@" | grep "$kw" | more 20 | 21 | echo -e "\n Bye~" -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/query.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Manu Martinez-Almeida. 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 binding 6 | 7 | import "net/http" 8 | 9 | type queryBinding struct{} 10 | 11 | func (queryBinding) Name() string { 12 | return "query" 13 | } 14 | 15 | func (queryBinding) Bind(req *http.Request, obj interface{}) error { 16 | values := req.URL.Query() 17 | if err := mapForm(obj, values); err != nil { 18 | return err 19 | } 20 | return validate(obj) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/internal/util.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import "github.com/go-redis/redis/internal/util" 4 | 5 | func ToLower(s string) string { 6 | if isLower(s) { 7 | return s 8 | } 9 | 10 | b := make([]byte, len(s)) 11 | for i := range b { 12 | c := s[i] 13 | if c >= 'A' && c <= 'Z' { 14 | c += 'a' - 'A' 15 | } 16 | b[i] = c 17 | } 18 | return util.BytesToString(b) 19 | } 20 | 21 | func isLower(s string) bool { 22 | for i := 0; i < len(s); i++ { 23 | c := s[i] 24 | if c >= 'A' && c <= 'Z' { 25 | return false 26 | } 27 | } 28 | return true 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/internal/util/strconv.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import "strconv" 4 | 5 | func Atoi(b []byte) (int, error) { 6 | return strconv.Atoi(BytesToString(b)) 7 | } 8 | 9 | func ParseInt(b []byte, base int, bitSize int) (int64, error) { 10 | return strconv.ParseInt(BytesToString(b), base, bitSize) 11 | } 12 | 13 | func ParseUint(b []byte, base int, bitSize int) (uint64, error) { 14 | return strconv.ParseUint(BytesToString(b), base, bitSize) 15 | } 16 | 17 | func ParseFloat(b []byte, bitSize int) (float64, error) { 18 | return strconv.ParseFloat(BytesToString(b), bitSize) 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/appengine.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2013 The Go-MySQL-Driver Authors. All rights reserved. 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 7 | // You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | // +build appengine 10 | 11 | package mysql 12 | 13 | import ( 14 | "google.golang.org/appengine/cloudsql" 15 | ) 16 | 17 | func init() { 18 | RegisterDial("cloudsql", cloudsql.Dial) 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/jinzhu/gorm/interface.go: -------------------------------------------------------------------------------- 1 | package gorm 2 | 3 | import "database/sql" 4 | 5 | // SQLCommon is the minimal database connection functionality gorm requires. Implemented by *sql.DB. 6 | type SQLCommon interface { 7 | Exec(query string, args ...interface{}) (sql.Result, error) 8 | Prepare(query string) (*sql.Stmt, error) 9 | Query(query string, args ...interface{}) (*sql.Rows, error) 10 | QueryRow(query string, args ...interface{}) *sql.Row 11 | } 12 | 13 | type sqlDb interface { 14 | Begin() (*sql.Tx, error) 15 | } 16 | 17 | type sqlTx interface { 18 | Commit() error 19 | Rollback() error 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/ugorji/go/codec/goversion_unsupported_lt_go14.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build !go1.4 5 | 6 | package codec 7 | 8 | // This codec package will only work for go1.4 and above. 9 | // This is for the following reasons: 10 | // - go 1.4 was released in 2014 11 | // - go runtime is written fully in go 12 | // - interface only holds pointers 13 | // - reflect.Value is stabilized as 3 words 14 | 15 | func init() { 16 | panic("codec: go 1.3 and below are not supported") 17 | } 18 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2011-2016 Canonical Ltd. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/response_writer_1.8.go: -------------------------------------------------------------------------------- 1 | // +build go1.8 2 | 3 | // Copyright 2018 Gin Core Team. All rights reserved. 4 | // Use of this source code is governed by a MIT style 5 | // license that can be found in the LICENSE file. 6 | 7 | package gin 8 | 9 | import ( 10 | "net/http" 11 | ) 12 | 13 | // ResponseWriter ... 14 | type ResponseWriter interface { 15 | responseWriterBase 16 | // get the http.Pusher for server push 17 | Pusher() http.Pusher 18 | } 19 | 20 | func (w *responseWriter) Pusher() (pusher http.Pusher) { 21 | if pusher, ok := w.ResponseWriter.(http.Pusher); ok { 22 | return pusher 23 | } 24 | return nil 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/internal/internal.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "math/rand" 5 | "time" 6 | ) 7 | 8 | // Retry backoff with jitter sleep to prevent overloaded conditions during intervals 9 | // https://www.awsarchitectureblog.com/2015/03/backoff.html 10 | func RetryBackoff(retry int, minBackoff, maxBackoff time.Duration) time.Duration { 11 | if retry < 0 { 12 | retry = 0 13 | } 14 | 15 | backoff := minBackoff << uint(retry) 16 | if backoff > maxBackoff || backoff < minBackoff { 17 | backoff = maxBackoff 18 | } 19 | 20 | if backoff == 0 { 21 | return 0 22 | } 23 | return time.Duration(rand.Int63n(int64(backoff))) 24 | } 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/---------.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 问题报告 (简中) 3 | about: 新建问题报告 issue,让 SafeU 变得更好! 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **问题描述** 11 | 使用清晰的语言描述你所遇到的问题。 12 | 13 | **重现步骤** 14 | 通过以下步骤可以快速重现该问题: 15 | 1. 在 SafeU 上传新文件。 16 | 2. 点击 xxx 设置,将 yyy 设为 zzz 17 | 3. 发现问题 18 | 19 | 20 | **期望结果** 21 | 使用简要的语言描述你的期望结果。 22 | 23 | **截屏** 24 | 最好有截屏来帮助你描述该问题。 25 | 26 | **计算机信息 (请填写以下信息):** 27 | - 操作系统: [e.g. iOS] 28 | - 浏览器 [e.g. chrome, safari] 29 | 30 | **移动设备信息 (please complete the following information):** 31 | - 设备型号: [e.g. iPhone11] 32 | - 操作系统: [e.g. iOS8.1] 33 | - 浏览器 [e.g. chrome, safari] 34 | 35 | **附加信息** 36 | 关于该问题的更多信息。 37 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/data.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. 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 render 6 | 7 | import "net/http" 8 | 9 | type Data struct { 10 | ContentType string 11 | Data []byte 12 | } 13 | 14 | // Render (Data) writes data with custom ContentType. 15 | func (r Data) Render(w http.ResponseWriter) (err error) { 16 | r.WriteContentType(w) 17 | _, err = w.Write(r.Data) 18 | return 19 | } 20 | 21 | func (r Data) WriteContentType(w http.ResponseWriter) { 22 | writeContentType(w, []string{r.ContentType}) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/xml.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. 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 render 6 | 7 | import ( 8 | "encoding/xml" 9 | "net/http" 10 | ) 11 | 12 | type XML struct { 13 | Data interface{} 14 | } 15 | 16 | var xmlContentType = []string{"application/xml; charset=utf-8"} 17 | 18 | func (r XML) Render(w http.ResponseWriter) error { 19 | r.WriteContentType(w) 20 | return xml.NewEncoder(w).Encode(r.Data) 21 | } 22 | 23 | func (r XML) WriteContentType(w http.ResponseWriter) { 24 | writeContentType(w, xmlContentType) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/sessions/options_go111.go: -------------------------------------------------------------------------------- 1 | // +build go1.11 2 | 3 | package sessions 4 | 5 | import "net/http" 6 | 7 | // Options stores configuration for a session or session store. 8 | // 9 | // Fields are a subset of http.Cookie fields. 10 | type Options struct { 11 | Path string 12 | Domain string 13 | // MaxAge=0 means no Max-Age attribute specified and the cookie will be 14 | // deleted after the browser session ends. 15 | // MaxAge<0 means delete cookie immediately. 16 | // MaxAge>0 means Max-Age attribute present and given in seconds. 17 | MaxAge int 18 | Secure bool 19 | HttpOnly bool 20 | // Defaults to http.SameSiteDefaultMode 21 | SameSite http.SameSite 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/Makefile: -------------------------------------------------------------------------------- 1 | all: testdeps 2 | go test ./... 3 | go test ./... -short -race 4 | env GOOS=linux GOARCH=386 go test ./... 5 | go vet 6 | go get github.com/gordonklaus/ineffassign 7 | ineffassign . 8 | 9 | testdeps: testdata/redis/src/redis-server 10 | 11 | bench: testdeps 12 | go test ./... -test.run=NONE -test.bench=. -test.benchmem 13 | 14 | .PHONY: all test testdeps bench 15 | 16 | testdata/redis: 17 | mkdir -p $@ 18 | wget -qO- https://github.com/antirez/redis/archive/5.0.tar.gz | tar xvz --strip-components=1 -C $@ 19 | 20 | testdata/redis/src/redis-server: testdata/redis 21 | sed -i.bak 's/libjemalloc.a/libjemalloc.a -lrt/g' $ Note: gorilla/context, having been born well before `context.Context` existed, does not play well 8 | > with the shallow copying of the request that [`http.Request.WithContext`](https://golang.org/pkg/net/http/#Request.WithContext) (added to net/http Go 1.7 onwards) performs. You should either use *just* gorilla/context, or moving forward, the new `http.Request.Context()`. 9 | 10 | Read the full documentation here: https://www.gorillatoolkit.org/pkg/context 11 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "golang.org/x/sys/unix" 8 | ) 9 | 10 | // IsTerminal returns true if the given file descriptor is a terminal. 11 | // see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c 12 | func IsTerminal(fd uintptr) bool { 13 | var termio unix.Termio 14 | err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio) 15 | return err == nil 16 | } 17 | 18 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 19 | // terminal. This is also always false on this environment. 20 | func IsCygwinTerminal(fd uintptr) bool { 21 | return false 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/pilu/fresh/runner/runner.go: -------------------------------------------------------------------------------- 1 | package runner 2 | 3 | import ( 4 | "io" 5 | "os/exec" 6 | ) 7 | 8 | func run() bool { 9 | runnerLog("Running...") 10 | 11 | cmd := exec.Command(buildPath()) 12 | 13 | stderr, err := cmd.StderrPipe() 14 | if err != nil { 15 | fatal(err) 16 | } 17 | 18 | stdout, err := cmd.StdoutPipe() 19 | if err != nil { 20 | fatal(err) 21 | } 22 | 23 | err = cmd.Start() 24 | if err != nil { 25 | fatal(err) 26 | } 27 | 28 | go io.Copy(appLogWriter{}, stderr) 29 | go io.Copy(appLogWriter{}, stdout) 30 | 31 | go func() { 32 | <-stopChannel 33 | pid := cmd.Process.Pid 34 | runnerLog("Killing PID %d", pid) 35 | cmd.Process.Kill() 36 | }() 37 | 38 | return true 39 | } 40 | -------------------------------------------------------------------------------- /scripts/remove-database-files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo -e "\n Are you sure to remove all the database files? (y/n, default: n): \c" 4 | read isSure 5 | 6 | if [ "$isSure" == "y" ] || [ "$isSure" == "Y" ] 7 | then 8 | echo -e "\n Removing the development database data..." 9 | sudo rm -rf ../data-dev 10 | 11 | echo -e "\n Are you SURE to remove the production database data??? 12 | ALL DATA WILL BE LOST!!!\n (y/n, default: n): \c" 13 | read isProdSure 14 | if [ "$isProdSure" == "y" ] || [ "$isProdSure" == "Y" ] 15 | then 16 | echo -e "\n Removing the production database data..." 17 | sudo rm -rf ../data 18 | fi 19 | else 20 | echo -e "\n Be careful!" 21 | fi 22 | 23 | echo -e "\n Bye~\n" 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore log files 2 | log/ 3 | 4 | # Ignore docker database volume 5 | db-data/ 6 | data/ 7 | data-dev/ 8 | 9 | # Ignore binary file and only file 10 | safeu-backend 11 | !safeu-backend/ 12 | 13 | # Ignore config file 14 | conf/db.json 15 | conf/cloud.yml 16 | 17 | # Ignore GoLand config files 18 | .idea/ 19 | 20 | # Ignore VS Code config files 21 | .vscode/ 22 | 23 | # Ignore fresh tmp files 24 | tmp/ 25 | 26 | # Ignore vendor package files 27 | 28 | # Binaries for programs and plugins 29 | *.exe 30 | *.exe~ 31 | *.dll 32 | *.so 33 | *.dylib 34 | 35 | # Test binary, built with `go test -c` 36 | *.test 37 | 38 | # Output of the go coverage tool, specifically when used with LiteIDE 39 | *.out 40 | 41 | safeu-backend\.iml 42 | -------------------------------------------------------------------------------- /vendor/github.com/pilu/fresh/runner/build.go: -------------------------------------------------------------------------------- 1 | package runner 2 | 3 | import ( 4 | "io" 5 | "io/ioutil" 6 | "os" 7 | "os/exec" 8 | ) 9 | 10 | func build() (string, bool) { 11 | buildLog("Building...") 12 | 13 | cmd := exec.Command("go", "build", "-o", buildPath(), root()) 14 | 15 | stderr, err := cmd.StderrPipe() 16 | if err != nil { 17 | fatal(err) 18 | } 19 | 20 | stdout, err := cmd.StdoutPipe() 21 | if err != nil { 22 | fatal(err) 23 | } 24 | 25 | err = cmd.Start() 26 | if err != nil { 27 | fatal(err) 28 | } 29 | 30 | io.Copy(os.Stdout, stdout) 31 | errBuf, _ := ioutil.ReadAll(stderr) 32 | 33 | err = cmd.Wait() 34 | if err != nil { 35 | return string(errBuf), false 36 | } 37 | 38 | return "", true 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | // +build !appengine,!ppc64,!ppc64le 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TCGETS 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | 20 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 21 | // terminal. This is also always false on this environment. 22 | func IsCygwinTerminal(fd uintptr) bool { 23 | return false 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | 20 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 21 | // terminal. This is also always false on this environment. 22 | func IsCygwinTerminal(fd uintptr) bool { 23 | return false 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_linux_ppc64x.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | // +build ppc64 ppc64le 3 | 4 | package isatty 5 | 6 | import ( 7 | "unsafe" 8 | 9 | syscall "golang.org/x/sys/unix" 10 | ) 11 | 12 | const ioctlReadTermios = syscall.TCGETS 13 | 14 | // IsTerminal return true if the file descriptor is terminal. 15 | func IsTerminal(fd uintptr) bool { 16 | var termios syscall.Termios 17 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 18 | return err == 0 19 | } 20 | 21 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 22 | // terminal. This is also always false on this environment. 23 | func IsCygwinTerminal(fd uintptr) bool { 24 | return false 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/yaml.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. 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 render 6 | 7 | import ( 8 | "net/http" 9 | 10 | "gopkg.in/yaml.v2" 11 | ) 12 | 13 | type YAML struct { 14 | Data interface{} 15 | } 16 | 17 | var yamlContentType = []string{"application/x-yaml; charset=utf-8"} 18 | 19 | func (r YAML) Render(w http.ResponseWriter) error { 20 | r.WriteContentType(w) 21 | 22 | bytes, err := yaml.Marshal(r.Data) 23 | if err != nil { 24 | return err 25 | } 26 | 27 | w.Write(bytes) 28 | return nil 29 | } 30 | 31 | func (r YAML) WriteContentType(w http.ResponseWriter) { 32 | writeContentType(w, yamlContentType) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/jinzhu/gorm/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | mysql: 5 | image: 'mysql:latest' 6 | ports: 7 | - 9910:3306 8 | environment: 9 | - MYSQL_DATABASE=gorm 10 | - MYSQL_USER=gorm 11 | - MYSQL_PASSWORD=gorm 12 | - MYSQL_RANDOM_ROOT_PASSWORD="yes" 13 | postgres: 14 | image: 'postgres:latest' 15 | ports: 16 | - 9920:5432 17 | environment: 18 | - POSTGRES_USER=gorm 19 | - POSTGRES_DB=gorm 20 | - POSTGRES_PASSWORD=gorm 21 | mssql: 22 | image: 'mcmoe/mssqldocker:latest' 23 | ports: 24 | - 9930:1433 25 | environment: 26 | - ACCEPT_EULA=Y 27 | - SA_PASSWORD=LoremIpsum86 28 | - MSSQL_DB=gorm 29 | - MSSQL_USER=gorm 30 | - MSSQL_PASSWORD=LoremIpsum86 31 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package colorable 4 | 5 | import ( 6 | "io" 7 | "os" 8 | 9 | _ "github.com/mattn/go-isatty" 10 | ) 11 | 12 | // NewColorable return new instance of Writer which handle escape sequence. 13 | func NewColorable(file *os.File) io.Writer { 14 | if file == nil { 15 | panic("nil passed instead of *os.File to NewColorable()") 16 | } 17 | 18 | return file 19 | } 20 | 21 | // NewColorableStdout return new instance of Writer which handle escape sequence for stdout. 22 | func NewColorableStdout() io.Writer { 23 | return os.Stdout 24 | } 25 | 26 | // NewColorableStderr return new instance of Writer which handle escape sequence for stderr. 27 | func NewColorableStderr() io.Writer { 28 | return os.Stderr 29 | } 30 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/writerc.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | // Set the writer error and return false. 4 | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { 5 | emitter.error = yaml_WRITER_ERROR 6 | emitter.problem = problem 7 | return false 8 | } 9 | 10 | // Flush the output buffer. 11 | func yaml_emitter_flush(emitter *yaml_emitter_t) bool { 12 | if emitter.write_handler == nil { 13 | panic("write handler not set") 14 | } 15 | 16 | // Check if the buffer is empty. 17 | if emitter.buffer_pos == 0 { 18 | return true 19 | } 20 | 21 | if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { 22 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 23 | } 24 | emitter.buffer_pos = 0 25 | return true 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/ugorji/go/codec/gen-enc-chan.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.Label}}: 2 | switch timeout{{.Sfx}} := z.EncBasicHandle().ChanRecvTimeout; { 3 | case timeout{{.Sfx}} == 0: // only consume available 4 | for { 5 | select { 6 | case b{{.Sfx}} := <-{{.Chan}}: 7 | {{ .Slice }} = append({{.Slice}}, b{{.Sfx}}) 8 | default: 9 | break {{.Label}} 10 | } 11 | } 12 | case timeout{{.Sfx}} > 0: // consume until timeout 13 | tt{{.Sfx}} := time.NewTimer(timeout{{.Sfx}}) 14 | for { 15 | select { 16 | case b{{.Sfx}} := <-{{.Chan}}: 17 | {{.Slice}} = append({{.Slice}}, b{{.Sfx}}) 18 | case <-tt{{.Sfx}}.C: 19 | // close(tt.C) 20 | break {{.Label}} 21 | } 22 | } 23 | default: // consume until close 24 | for b{{.Sfx}} := range {{.Chan}} { 25 | {{.Slice}} = append({{.Slice}}, b{{.Sfx}}) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !appengine 3 | 4 | package colorable 5 | 6 | import ( 7 | "io" 8 | "os" 9 | 10 | _ "github.com/mattn/go-isatty" 11 | ) 12 | 13 | // NewColorable return new instance of Writer which handle escape sequence. 14 | func NewColorable(file *os.File) io.Writer { 15 | if file == nil { 16 | panic("nil passed instead of *os.File to NewColorable()") 17 | } 18 | 19 | return file 20 | } 21 | 22 | // NewColorableStdout return new instance of Writer which handle escape sequence for stdout. 23 | func NewColorableStdout() io.Writer { 24 | return os.Stdout 25 | } 26 | 27 | // NewColorableStderr return new instance of Writer which handle escape sequence for stderr. 28 | func NewColorableStderr() io.Writer { 29 | return os.Stderr 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/transport_1_6.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7 2 | 3 | package oss 4 | 5 | import ( 6 | "net" 7 | "net/http" 8 | ) 9 | 10 | func newTransport(conn *Conn, config *Config) *http.Transport { 11 | httpTimeOut := conn.config.HTTPTimeout 12 | httpMaxConns := conn.config.HTTPMaxConns 13 | // New Transport 14 | transport := &http.Transport{ 15 | Dial: func(netw, addr string) (net.Conn, error) { 16 | conn, err := net.DialTimeout(netw, addr, httpTimeOut.ConnectTimeout) 17 | if err != nil { 18 | return nil, err 19 | } 20 | return newTimeoutConn(conn, httpTimeOut.ReadWriteTimeout, httpTimeOut.LongTimeout), nil 21 | }, 22 | MaxIdleConnsPerHost: httpMaxConns.MaxIdleConnsPerHost, 23 | ResponseHeaderTimeout: httpTimeOut.HeaderTimeout, 24 | } 25 | return transport 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/deprecated.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. 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 gin 6 | 7 | import ( 8 | "log" 9 | 10 | "github.com/gin-gonic/gin/binding" 11 | ) 12 | 13 | // BindWith binds the passed struct pointer using the specified binding engine. 14 | // See the binding package. 15 | func (c *Context) BindWith(obj interface{}, b binding.Binding) error { 16 | log.Println(`BindWith(\"interface{}, binding.Binding\") error is going to 17 | be deprecated, please check issue #662 and either use MustBindWith() if you 18 | want HTTP 400 to be automatically returned if any error occur, or use 19 | ShouldBindWith() if you need to manage the error.`) 20 | return c.MustBindWith(obj, b) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/securecookie/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of gorilla/securecookie authors for copyright purposes. 2 | # Please keep the list sorted. 3 | 4 | 0x434D53 5 | Abdülhamit Yilmaz 6 | Annonomus-Penguin 7 | Craig Peterson 8 | Cyril David 9 | Dmitry Chestnykh 10 | Dominik Honnef 11 | Google LLC (https://opensource.google.com/) 12 | John Downey 13 | Kamil Kisiel 14 | Keunwoo Lee 15 | Mahmud Ridwan 16 | Matt Silverlock 17 | rodrigo moraes 18 | s7v7nislands 19 | Wesley Bitter 20 | -------------------------------------------------------------------------------- /vendor/github.com/json-iterator/go/Gopkg.toml: -------------------------------------------------------------------------------- 1 | # Gopkg.toml example 2 | # 3 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 4 | # for detailed Gopkg.toml documentation. 5 | # 6 | # required = ["github.com/user/thing/cmd/thing"] 7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 8 | # 9 | # [[constraint]] 10 | # name = "github.com/user/project" 11 | # version = "1.0.0" 12 | # 13 | # [[constraint]] 14 | # name = "github.com/user/project2" 15 | # branch = "dev" 16 | # source = "github.com/myfork/project2" 17 | # 18 | # [[override]] 19 | # name = "github.com/x/y" 20 | # version = "2.4.0" 21 | 22 | ignored = ["github.com/davecgh/go-spew*","github.com/google/gofuzz*","github.com/stretchr/testify*"] 23 | 24 | [[constraint]] 25 | name = "github.com/modern-go/reflect2" 26 | version = "1.0.1" 27 | -------------------------------------------------------------------------------- /conf/cloud.example.yml: -------------------------------------------------------------------------------- 1 | --- 2 | aliyun: 3 | - accountid: account1 4 | accesskey: account1ak 5 | accesskeysecret: account1as 6 | endpoint: 7 | - endpointid: account1endpoint1 8 | base: account1endpoint1base 9 | bucket: 10 | - bucketid: account1endpoint1basebucket1 11 | name: 999 12 | - bucketid: account1endpoint1basebucket2 13 | name: 998 14 | - endpointid: account1endpoint2 15 | base: account1endpoint2base 16 | - accountid: account2 17 | accesskey: account2ak 18 | accesskeysecret: account2as 19 | endpoint: 20 | - endpointid: account2endpoint1 21 | base: account2endpoint1base 22 | 23 | server: 24 | - serverid: 0 25 | servercallback: "your_server_callback_url_address" 26 | 27 | faas: 28 | - name: zip 29 | endpoint: "your_cloud_zip_function_url_address" 30 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/xml.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. 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 binding 6 | 7 | import ( 8 | "bytes" 9 | "encoding/xml" 10 | "io" 11 | "net/http" 12 | ) 13 | 14 | type xmlBinding struct{} 15 | 16 | func (xmlBinding) Name() string { 17 | return "xml" 18 | } 19 | 20 | func (xmlBinding) Bind(req *http.Request, obj interface{}) error { 21 | return decodeXML(req.Body, obj) 22 | } 23 | 24 | func (xmlBinding) BindBody(body []byte, obj interface{}) error { 25 | return decodeXML(bytes.NewReader(body), obj) 26 | } 27 | func decodeXML(r io.Reader, obj interface{}) error { 28 | decoder := xml.NewDecoder(r) 29 | if err := decoder.Decode(obj); err != nil { 30 | return err 31 | } 32 | return validate(obj) 33 | } 34 | -------------------------------------------------------------------------------- /item/models.go: -------------------------------------------------------------------------------- 1 | package item 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/jinzhu/gorm" 7 | ) 8 | 9 | type Item struct { 10 | gorm.Model 11 | Status int `gorm:"not null"` 12 | Name string `gorm:"index"` 13 | OriginalName string `gorm:"not null"` 14 | Host string 15 | ReCode string `gorm:"index"` 16 | Password string 17 | DownCount int `gorm:"default:-100"` 18 | Type string 19 | IsPublic bool `gorm:"default:true"` 20 | ArchiveType int `gorm:"default:0"` 21 | Protocol string 22 | Bucket string 23 | Endpoint string 24 | Path string 25 | ExpiredAt time.Time `gorm:"NOT NULL"` 26 | } 27 | 28 | type Token struct { 29 | gorm.Model 30 | Token string `gorm:"NOT NULL;INDEX"` 31 | RetrieveCode string `gorm:"NOT NULL"` 32 | Valid bool 33 | ExpiredAt time.Time `gorm:"NOT NULL"` 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/redirect.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. 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 render 6 | 7 | import ( 8 | "fmt" 9 | "net/http" 10 | ) 11 | 12 | type Redirect struct { 13 | Code int 14 | Request *http.Request 15 | Location string 16 | } 17 | 18 | func (r Redirect) Render(w http.ResponseWriter) error { 19 | // todo(thinkerou): go1.6 not support StatusPermanentRedirect(308) 20 | // when we upgrade go version we can use http.StatusPermanentRedirect 21 | if (r.Code < 300 || r.Code > 308) && r.Code != 201 { 22 | panic(fmt.Sprintf("Cannot redirect with status code %d", r.Code)) 23 | } 24 | http.Redirect(w, r.Request, r.Location, r.Code) 25 | return nil 26 | } 27 | 28 | func (r Redirect) WriteContentType(http.ResponseWriter) {} 29 | -------------------------------------------------------------------------------- /vendor/github.com/jinzhu/gorm/callback_row_query.go: -------------------------------------------------------------------------------- 1 | package gorm 2 | 3 | import "database/sql" 4 | 5 | // Define callbacks for row query 6 | func init() { 7 | DefaultCallback.RowQuery().Register("gorm:row_query", rowQueryCallback) 8 | } 9 | 10 | type RowQueryResult struct { 11 | Row *sql.Row 12 | } 13 | 14 | type RowsQueryResult struct { 15 | Rows *sql.Rows 16 | Error error 17 | } 18 | 19 | // queryCallback used to query data from database 20 | func rowQueryCallback(scope *Scope) { 21 | if result, ok := scope.InstanceGet("row_query_result"); ok { 22 | scope.prepareQuerySQL() 23 | 24 | if rowResult, ok := result.(*RowQueryResult); ok { 25 | rowResult.Row = scope.SQLDB().QueryRow(scope.SQL, scope.SQLVars...) 26 | } else if rowsResult, ok := result.(*RowsQueryResult); ok { 27 | rowsResult.Rows, rowsResult.Error = scope.SQLDB().Query(scope.SQL, scope.SQLVars...) 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/transaction.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2012 The Go-MySQL-Driver Authors. All rights reserved. 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 7 | // You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | package mysql 10 | 11 | type mysqlTx struct { 12 | mc *mysqlConn 13 | } 14 | 15 | func (tx *mysqlTx) Commit() (err error) { 16 | if tx.mc == nil || tx.mc.closed.IsSet() { 17 | return ErrInvalidConn 18 | } 19 | err = tx.mc.exec("COMMIT") 20 | tx.mc = nil 21 | return 22 | } 23 | 24 | func (tx *mysqlTx) Rollback() (err error) { 25 | if tx.mc == nil || tx.mc.closed.IsSet() { 26 | return ErrInvalidConn 27 | } 28 | err = tx.mc.exec("ROLLBACK") 29 | tx.mc = nil 30 | return 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/msgpack.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Manu Martinez-Almeida. 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 render 6 | 7 | import ( 8 | "net/http" 9 | 10 | "github.com/ugorji/go/codec" 11 | ) 12 | 13 | type MsgPack struct { 14 | Data interface{} 15 | } 16 | 17 | var msgpackContentType = []string{"application/msgpack; charset=utf-8"} 18 | 19 | func (r MsgPack) WriteContentType(w http.ResponseWriter) { 20 | writeContentType(w, msgpackContentType) 21 | } 22 | 23 | func (r MsgPack) Render(w http.ResponseWriter) error { 24 | return WriteMsgPack(w, r.Data) 25 | } 26 | 27 | func WriteMsgPack(w http.ResponseWriter, obj interface{}) error { 28 | writeContentType(w, msgpackContentType) 29 | var h codec.Handle = new(codec.MsgpackHandle) 30 | return codec.NewEncoder(w, h).Encode(obj) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/transport_1_7.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | package oss 4 | 5 | import ( 6 | "net" 7 | "net/http" 8 | ) 9 | 10 | func newTransport(conn *Conn, config *Config) *http.Transport { 11 | httpTimeOut := conn.config.HTTPTimeout 12 | httpMaxConns := conn.config.HTTPMaxConns 13 | // New Transport 14 | transport := &http.Transport{ 15 | Dial: func(netw, addr string) (net.Conn, error) { 16 | conn, err := net.DialTimeout(netw, addr, httpTimeOut.ConnectTimeout) 17 | if err != nil { 18 | return nil, err 19 | } 20 | return newTimeoutConn(conn, httpTimeOut.ReadWriteTimeout, httpTimeOut.LongTimeout), nil 21 | }, 22 | MaxIdleConns: httpMaxConns.MaxIdleConns, 23 | MaxIdleConnsPerHost: httpMaxConns.MaxIdleConnsPerHost, 24 | IdleConnTimeout: httpTimeOut.IdleConnTimeout, 25 | ResponseHeaderTimeout: httpTimeOut.HeaderTimeout, 26 | } 27 | return transport 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/text.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. 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 render 6 | 7 | import ( 8 | "fmt" 9 | "io" 10 | "net/http" 11 | ) 12 | 13 | type String struct { 14 | Format string 15 | Data []interface{} 16 | } 17 | 18 | var plainContentType = []string{"text/plain; charset=utf-8"} 19 | 20 | func (r String) Render(w http.ResponseWriter) error { 21 | WriteString(w, r.Format, r.Data) 22 | return nil 23 | } 24 | 25 | func (r String) WriteContentType(w http.ResponseWriter) { 26 | writeContentType(w, plainContentType) 27 | } 28 | 29 | func WriteString(w http.ResponseWriter, format string, data []interface{}) { 30 | writeContentType(w, plainContentType) 31 | if len(data) > 0 { 32 | fmt.Fprintf(w, format, data...) 33 | } else { 34 | io.WriteString(w, format) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/msgpack.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Manu Martinez-Almeida. 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 binding 6 | 7 | import ( 8 | "bytes" 9 | "io" 10 | "net/http" 11 | 12 | "github.com/ugorji/go/codec" 13 | ) 14 | 15 | type msgpackBinding struct{} 16 | 17 | func (msgpackBinding) Name() string { 18 | return "msgpack" 19 | } 20 | 21 | func (msgpackBinding) Bind(req *http.Request, obj interface{}) error { 22 | return decodeMsgPack(req.Body, obj) 23 | } 24 | 25 | func (msgpackBinding) BindBody(body []byte, obj interface{}) error { 26 | return decodeMsgPack(bytes.NewReader(body), obj) 27 | } 28 | 29 | func decodeMsgPack(r io.Reader, obj interface{}) error { 30 | cdc := new(codec.MsgpackHandle) 31 | if err := codec.NewDecoder(r, cdc).Decode(&obj); err != nil { 32 | return err 33 | } 34 | return validate(obj) 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/json-iterator/go/fuzzy_mode_convert_table.md: -------------------------------------------------------------------------------- 1 | | json type \ dest type | bool | int | uint | float |string| 2 | | --- | --- | --- | --- |--|--| 3 | | number | positive => true
negative => true
zero => false| 23.2 => 23
-32.1 => -32| 12.1 => 12
-12.1 => 0|as normal|same as origin| 4 | | string | empty string => false
string "0" => false
other strings => true | "123.32" => 123
"-123.4" => -123
"123.23xxxw" => 123
"abcde12" => 0
"-32.1" => -32| 13.2 => 13
-1.1 => 0 |12.1 => 12.1
-12.3 => -12.3
12.4xxa => 12.4
+1.1e2 =>110 |same as origin| 5 | | bool | true => true
false => false| true => 1
false => 0 | true => 1
false => 0 |true => 1
false => 0|true => "true"
false => "false"| 6 | | object | true | 0 | 0 |0|originnal json| 7 | | array | empty array => false
nonempty array => true| [] => 0
[1,2] => 1 | [] => 0
[1,2] => 1 |[] => 0
[1,2] => 1|original json| -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/reader.go: -------------------------------------------------------------------------------- 1 | package render 2 | 3 | import ( 4 | "io" 5 | "net/http" 6 | "strconv" 7 | ) 8 | 9 | type Reader struct { 10 | ContentType string 11 | ContentLength int64 12 | Reader io.Reader 13 | Headers map[string]string 14 | } 15 | 16 | // Render (Reader) writes data with custom ContentType and headers. 17 | func (r Reader) Render(w http.ResponseWriter) (err error) { 18 | r.WriteContentType(w) 19 | r.Headers["Content-Length"] = strconv.FormatInt(r.ContentLength, 10) 20 | r.writeHeaders(w, r.Headers) 21 | _, err = io.Copy(w, r.Reader) 22 | return 23 | } 24 | 25 | func (r Reader) WriteContentType(w http.ResponseWriter) { 26 | writeContentType(w, []string{r.ContentType}) 27 | } 28 | 29 | func (r Reader) writeHeaders(w http.ResponseWriter, headers map[string]string) { 30 | header := w.Header() 31 | for k, v := range headers { 32 | if val := header[k]; len(val) == 0 { 33 | header[k] = []string{v} 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/json-iterator/go/jsoniter.go: -------------------------------------------------------------------------------- 1 | // Package jsoniter implements encoding and decoding of JSON as defined in 2 | // RFC 4627 and provides interfaces with identical syntax of standard lib encoding/json. 3 | // Converting from encoding/json to jsoniter is no more than replacing the package with jsoniter 4 | // and variable type declarations (if any). 5 | // jsoniter interfaces gives 100% compatibility with code using standard lib. 6 | // 7 | // "JSON and Go" 8 | // (https://golang.org/doc/articles/json_and_go.html) 9 | // gives a description of how Marshal/Unmarshal operate 10 | // between arbitrary or predefined json objects and bytes, 11 | // and it applies to jsoniter.Marshal/Unmarshal as well. 12 | // 13 | // Besides, jsoniter.Iterator provides a different set of interfaces 14 | // iterating given bytes/string/reader 15 | // and yielding parsed elements one by one. 16 | // This set of interfaces reads input as required and gives 17 | // better performance. 18 | package jsoniter 19 | -------------------------------------------------------------------------------- /common/aliyunOSS.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-oss-go-sdk/oss" 7 | ) 8 | 9 | var ossClient *oss.Client 10 | 11 | func InitAliyunOSSClient() *oss.Client { 12 | 13 | var ( 14 | ossEndpoint string 15 | accessKeyID string 16 | accessKeySecret string 17 | ) 18 | 19 | // 从云配置中获取相关配置 20 | for _, account := range CloudConfig.AliyunConfig.Accounts { 21 | accessKeyID = account.AccessKey 22 | accessKeySecret = account.AccessKeySecret 23 | for _, endpoint := range account.EndPoint { 24 | ossEndpoint = endpoint.Base 25 | } 26 | } 27 | 28 | // FIXME: 每个用户的每个地区都需要初始化一个 client 实例,若有多地域使用 map 来映射存储 29 | client, err := oss.New( 30 | ossEndpoint, 31 | accessKeyID, 32 | accessKeySecret) 33 | 34 | if err != nil { 35 | log.Fatalln("Cannot init Aliyun OSS Client: ", err) 36 | } 37 | 38 | ossClient = client 39 | 40 | return ossClient 41 | } 42 | 43 | func GetAliyunOSSClient() *oss.Client { 44 | return ossClient 45 | } 46 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report--en-.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report (EN) 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/protobuf.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. 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 binding 6 | 7 | import ( 8 | "io/ioutil" 9 | "net/http" 10 | 11 | "github.com/golang/protobuf/proto" 12 | ) 13 | 14 | type protobufBinding struct{} 15 | 16 | func (protobufBinding) Name() string { 17 | return "protobuf" 18 | } 19 | 20 | func (b protobufBinding) Bind(req *http.Request, obj interface{}) error { 21 | buf, err := ioutil.ReadAll(req.Body) 22 | if err != nil { 23 | return err 24 | } 25 | return b.BindBody(buf, obj) 26 | } 27 | 28 | func (protobufBinding) BindBody(body []byte, obj interface{}) error { 29 | if err := proto.Unmarshal(body, obj.(proto.Message)); err != nil { 30 | return err 31 | } 32 | // Here it's same to return validate(obj), but util now we cann't add 33 | // `binding:""` to the struct which automatically generate by gen-proto 34 | return nil 35 | // return validate(obj) 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/howeyc/fsnotify/AUTHORS: -------------------------------------------------------------------------------- 1 | # Names should be added to this file as 2 | # Name or Organization 3 | # The email address is not required for organizations. 4 | 5 | # You can update this list using the following command: 6 | # 7 | # $ git shortlog -se | awk '{print $2 " " $3 " " $4}' 8 | 9 | # Please keep the list sorted. 10 | 11 | Adrien Bustany 12 | Caleb Spare 13 | Case Nelson 14 | Chris Howey 15 | Christoffer Buchholz 16 | Dave Cheney 17 | Francisco Souza 18 | John C Barstow 19 | Kelvin Fo 20 | Nathan Youngman 21 | Paul Hammond 22 | Pursuit92 23 | Rob Figueiredo 24 | Travis Cline 25 | Tudor Golubenco 26 | bronze1man 27 | debrando 28 | henrikedwards 29 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/render.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. 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 render 6 | 7 | import "net/http" 8 | 9 | type Render interface { 10 | Render(http.ResponseWriter) error 11 | WriteContentType(w http.ResponseWriter) 12 | } 13 | 14 | var ( 15 | _ Render = JSON{} 16 | _ Render = IndentedJSON{} 17 | _ Render = SecureJSON{} 18 | _ Render = JsonpJSON{} 19 | _ Render = XML{} 20 | _ Render = String{} 21 | _ Render = Redirect{} 22 | _ Render = Data{} 23 | _ Render = HTML{} 24 | _ HTMLRender = HTMLDebug{} 25 | _ HTMLRender = HTMLProduction{} 26 | _ Render = YAML{} 27 | _ Render = MsgPack{} 28 | _ Render = Reader{} 29 | _ Render = AsciiJSON{} 30 | ) 31 | 32 | func writeContentType(w http.ResponseWriter, value []string) { 33 | header := w.Header() 34 | if val := header["Content-Type"]; len(val) == 0 { 35 | header["Content-Type"] = value 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /item/info.go: -------------------------------------------------------------------------------- 1 | package item 2 | 3 | import ( 4 | "net/http" 5 | 6 | "a2os/safeu-backend/common" 7 | 8 | "github.com/gin-gonic/gin" 9 | ) 10 | 11 | type getItemInfoBody struct { 12 | UserToken string `json:"user_token"` 13 | } 14 | 15 | // GetItemInfo 获取文件信息 16 | func GetItemInfo(c *gin.Context) { 17 | retrieveCode := c.Param("retrieveCode") 18 | var getItemInfoBody getItemInfoBody 19 | if common.FuncHandler(c, c.BindJSON(&getItemInfoBody), nil, http.StatusBadRequest, 20301) { 20 | return 21 | } 22 | tokenRedisClient := common.GetUserTokenRedisClient() 23 | if common.FuncHandler(c, KeyISExistInRedis(getItemInfoBody.UserToken, tokenRedisClient), true, http.StatusUnauthorized, 20201) { 24 | return 25 | } 26 | db := common.GetDB() 27 | var item Item 28 | if common.FuncHandler(c, db.Where("re_code = ?", retrieveCode).First(&item).RecordNotFound(), false, http.StatusUnauthorized, 20306) { 29 | return 30 | } 31 | c.JSON(http.StatusOK, gin.H{ 32 | "down_count": item.DownCount, 33 | "expired_at": item.ExpiredAt, 34 | "is_public": item.IsPublic, 35 | }) 36 | return 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/gin-contrib/cors/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gin-contrib/cors 2 | 3 | require ( 4 | github.com/davecgh/go-spew v1.1.1 // indirect 5 | github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7 // indirect 6 | github.com/gin-gonic/gin v1.3.0 7 | github.com/golang/protobuf v1.2.0 // indirect 8 | github.com/json-iterator/go v1.1.5 // indirect 9 | github.com/mattn/go-isatty v0.0.4 // indirect 10 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 11 | github.com/modern-go/reflect2 v1.0.1 // indirect 12 | github.com/pmezard/go-difflib v1.0.0 // indirect 13 | github.com/stretchr/testify v1.2.2 14 | github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 // indirect 15 | golang.org/x/net v0.0.0-20181220203305-927f97764cc3 // indirect 16 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect 17 | golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb // indirect 18 | gopkg.in/go-playground/assert.v1 v1.2.1 // indirect 19 | gopkg.in/go-playground/validator.v8 v8.18.2 // indirect 20 | gopkg.in/yaml.v2 v2.2.2 // indirect 21 | ) 22 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/internal/pool/pool_single.go: -------------------------------------------------------------------------------- 1 | package pool 2 | 3 | type SingleConnPool struct { 4 | cn *Conn 5 | } 6 | 7 | var _ Pooler = (*SingleConnPool)(nil) 8 | 9 | func NewSingleConnPool(cn *Conn) *SingleConnPool { 10 | return &SingleConnPool{ 11 | cn: cn, 12 | } 13 | } 14 | 15 | func (p *SingleConnPool) NewConn() (*Conn, error) { 16 | panic("not implemented") 17 | } 18 | 19 | func (p *SingleConnPool) CloseConn(*Conn) error { 20 | panic("not implemented") 21 | } 22 | 23 | func (p *SingleConnPool) Get() (*Conn, error) { 24 | return p.cn, nil 25 | } 26 | 27 | func (p *SingleConnPool) Put(cn *Conn) { 28 | if p.cn != cn { 29 | panic("p.cn != cn") 30 | } 31 | } 32 | 33 | func (p *SingleConnPool) Remove(cn *Conn) { 34 | if p.cn != cn { 35 | panic("p.cn != cn") 36 | } 37 | } 38 | 39 | func (p *SingleConnPool) Len() int { 40 | return 1 41 | } 42 | 43 | func (p *SingleConnPool) IdleLen() int { 44 | return 0 45 | } 46 | 47 | func (p *SingleConnPool) Stats() *Stats { 48 | return nil 49 | } 50 | 51 | func (p *SingleConnPool) Close() error { 52 | return nil 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/pilu/fresh/runner/logger.go: -------------------------------------------------------------------------------- 1 | package runner 2 | 3 | import ( 4 | "fmt" 5 | logPkg "log" 6 | "time" 7 | 8 | "github.com/mattn/go-colorable" 9 | ) 10 | 11 | type logFunc func(string, ...interface{}) 12 | 13 | var logger = logPkg.New(colorable.NewColorableStderr(), "", 0) 14 | 15 | func newLogFunc(prefix string) func(string, ...interface{}) { 16 | color, clear := "", "" 17 | if settings["colors"] == "1" { 18 | color = fmt.Sprintf("\033[%sm", logColor(prefix)) 19 | clear = fmt.Sprintf("\033[%sm", colors["reset"]) 20 | } 21 | prefix = fmt.Sprintf("%-11s", prefix) 22 | 23 | return func(format string, v ...interface{}) { 24 | now := time.Now() 25 | timeString := fmt.Sprintf("%d:%d:%02d", now.Hour(), now.Minute(), now.Second()) 26 | format = fmt.Sprintf("%s%s %s |%s %s", color, timeString, prefix, clear, format) 27 | logger.Printf(format, v...) 28 | } 29 | } 30 | 31 | func fatal(err error) { 32 | logger.Fatal(err) 33 | } 34 | 35 | type appLogWriter struct{} 36 | 37 | func (a appLogWriter) Write(p []byte) (n int, err error) { 38 | appLog(string(p)) 39 | 40 | return len(p), nil 41 | } 42 | -------------------------------------------------------------------------------- /conf/nginx/api.safeu.a2os.club: -------------------------------------------------------------------------------- 1 | # HTTP server 2 | server { 3 | listen 80 default_server; 4 | listen [::]:80 default_server; 5 | server_name api.safeu.a2os.club; 6 | # server_name _; 7 | # location / { 8 | # proxy_pass http://app_servers; 9 | # proxy_redirect default; 10 | # } 11 | return 301 https://$host$request_uri; 12 | } 13 | # HTTPS server 14 | server { 15 | # SSL configuration 16 | listen 443 ssl default_server; 17 | listen [::]:443 ssl default_server; 18 | 19 | server_name api.safeu.a2os.club; 20 | ssl on; 21 | ssl_certificate /opt/nginx/api.safeu.a2os.club/fullchain.pem; 22 | ssl_certificate_key /opt/nginx/api.safeu.a2os.club/privkey.pem; 23 | 24 | location / { 25 | # First attempt to serve request as file, then 26 | # as directory, then fall back to displaying a 404. 27 | #try_files $uri $uri/ =404; 28 | proxy_pass http://app_servers; 29 | proxy_redirect default; 30 | } 31 | } -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Yasuhiro MATSUMOTO 2 | 3 | MIT License (Expat) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /vendor/github.com/json-iterator/go/pool.go: -------------------------------------------------------------------------------- 1 | package jsoniter 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | // IteratorPool a thread safe pool of iterators with same configuration 8 | type IteratorPool interface { 9 | BorrowIterator(data []byte) *Iterator 10 | ReturnIterator(iter *Iterator) 11 | } 12 | 13 | // StreamPool a thread safe pool of streams with same configuration 14 | type StreamPool interface { 15 | BorrowStream(writer io.Writer) *Stream 16 | ReturnStream(stream *Stream) 17 | } 18 | 19 | func (cfg *frozenConfig) BorrowStream(writer io.Writer) *Stream { 20 | stream := cfg.streamPool.Get().(*Stream) 21 | stream.Reset(writer) 22 | return stream 23 | } 24 | 25 | func (cfg *frozenConfig) ReturnStream(stream *Stream) { 26 | stream.out = nil 27 | stream.Error = nil 28 | stream.Attachment = nil 29 | cfg.streamPool.Put(stream) 30 | } 31 | 32 | func (cfg *frozenConfig) BorrowIterator(data []byte) *Iterator { 33 | iter := cfg.iteratorPool.Get().(*Iterator) 34 | iter.ResetBytes(data) 35 | return iter 36 | } 37 | 38 | func (cfg *frozenConfig) ReturnIterator(iter *Iterator) { 39 | iter.Error = nil 40 | iter.Attachment = nil 41 | cfg.iteratorPool.Put(iter) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/gin-contrib/cors/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Gin-Gonic 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/gin-contrib/sessions/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Gin-Gonic 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/json-iterator/go/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 json-iterator 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/satori/go.uuid/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013-2018 by Maxim Bublis 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/utrack/gin-csrf/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Nikita Koptelov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/jinzhu/inflection/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 - Jinzhu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/getcert.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # Author: Jinjin Feng, Zhenzhen Zhao 3 | # Date: 2019-04-14 4 | 5 | if [ "$1" == "-h" ] || [ "$1" == "--help" ] 6 | then 7 | echo -e " Usage: 8 | ./getcert.sh [DOMAIN] Generate domain HTTPS certification 9 | ./getcert.sh -h|--help Get this help message 10 | " 11 | elif [ "$1" != "" ] 12 | then 13 | domain=$1 14 | read -s -p "Authorization password: " password 15 | echo 16 | 17 | mkdir ~/.secrets/ 18 | mkdir ~/.secrets/certbot/ 19 | chmod 700 ~/.secrets/ 20 | 21 | header="authorization: Basic " 22 | auth="a2os:"$password 23 | auth=$(echo -n $auth | base64) 24 | header+="$auth" 25 | 26 | curl -o ~/.secrets/certbot/cloudflare.ini https://api.vvzero.com/certbot/cloudflare.ini -H "$header" 27 | chmod 400 ~/.secrets/certbot/cloudflare.ini 28 | 29 | # just for Ubuntu/Debian 30 | apt update 31 | apt install python-pip -y 32 | pip install certbot-dns-cloudflare 33 | 34 | certbot certonly --dns-cloudflare --dns-cloudflare-credentials ~/.secrets/certbot/cloudflare.ini -d $domain 35 | else 36 | echo "Cannot get the domain value, please use \"-h\" or \"--help\" to get help." 37 | fi 38 | -------------------------------------------------------------------------------- /vendor/github.com/gin-contrib/sse/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Manuel Martínez-Almeida 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Manuel Martínez-Almeida 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yasuhiro Matsumoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/gopkg.in/go-playground/validator.v8/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Dean Karn 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/jinzhu/gorm/License: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013-NOW Jinzhu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/pilu/config/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Andrea Franz (http://gravityblast.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/pilu/fresh/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Andrea Franz (http://gravityblast.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/ugorji/go/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2012-2015 Ugorji Nwoke. 4 | All rights reserved. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | ## Reporting Issues 4 | 5 | Before creating a new Issue, please check first if a similar Issue [already exists](https://github.com/go-sql-driver/mysql/issues?state=open) or was [recently closed](https://github.com/go-sql-driver/mysql/issues?direction=desc&page=1&sort=updated&state=closed). 6 | 7 | ## Contributing Code 8 | 9 | By contributing to this project, you share your code under the Mozilla Public License 2, as specified in the LICENSE file. 10 | Don't forget to add yourself to the AUTHORS file. 11 | 12 | ### Code Review 13 | 14 | Everyone is invited to review and comment on pull requests. 15 | If it looks fine to you, comment with "LGTM" (Looks good to me). 16 | 17 | If changes are required, notice the reviewers with "PTAL" (Please take another look) after committing the fixes. 18 | 19 | Before merging the Pull Request, at least one [team member](https://github.com/go-sql-driver?tab=members) must have commented with "LGTM". 20 | 21 | ## Development Ideas 22 | 23 | If you are looking for ideas for code contributions, please check our [Development Ideas](https://github.com/go-sql-driver/mysql/wiki/Development-Ideas) Wiki page. 24 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/noncolorable.go: -------------------------------------------------------------------------------- 1 | package colorable 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | ) 7 | 8 | // NonColorable hold writer but remove escape sequence. 9 | type NonColorable struct { 10 | out io.Writer 11 | } 12 | 13 | // NewNonColorable return new instance of Writer which remove escape sequence from Writer. 14 | func NewNonColorable(w io.Writer) io.Writer { 15 | return &NonColorable{out: w} 16 | } 17 | 18 | // Write write data on console 19 | func (w *NonColorable) Write(data []byte) (n int, err error) { 20 | er := bytes.NewReader(data) 21 | var bw [1]byte 22 | loop: 23 | for { 24 | c1, err := er.ReadByte() 25 | if err != nil { 26 | break loop 27 | } 28 | if c1 != 0x1b { 29 | bw[0] = c1 30 | w.out.Write(bw[:]) 31 | continue 32 | } 33 | c2, err := er.ReadByte() 34 | if err != nil { 35 | break loop 36 | } 37 | if c2 != 0x5b { 38 | continue 39 | } 40 | 41 | var buf bytes.Buffer 42 | for { 43 | c, err := er.ReadByte() 44 | if err != nil { 45 | break loop 46 | } 47 | if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' { 48 | break 49 | } 50 | buf.Write([]byte(string(c))) 51 | } 52 | } 53 | 54 | return len(data), nil 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/pilu/fresh/runner/watcher.go: -------------------------------------------------------------------------------- 1 | package runner 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | "strings" 7 | 8 | "github.com/howeyc/fsnotify" 9 | ) 10 | 11 | func watchFolder(path string) { 12 | watcher, err := fsnotify.NewWatcher() 13 | if err != nil { 14 | fatal(err) 15 | } 16 | 17 | go func() { 18 | for { 19 | select { 20 | case ev := <-watcher.Event: 21 | if isWatchedFile(ev.Name) { 22 | watcherLog("sending event %s", ev) 23 | startChannel <- ev.String() 24 | } 25 | case err := <-watcher.Error: 26 | watcherLog("error: %s", err) 27 | } 28 | } 29 | }() 30 | 31 | watcherLog("Watching %s", path) 32 | err = watcher.Watch(path) 33 | 34 | if err != nil { 35 | fatal(err) 36 | } 37 | } 38 | 39 | func watch() { 40 | root := root() 41 | filepath.Walk(root, func(path string, info os.FileInfo, err error) error { 42 | if info.IsDir() && !isTmpDir(path) { 43 | if len(path) > 1 && strings.HasPrefix(filepath.Base(path), ".") { 44 | return filepath.SkipDir 45 | } 46 | 47 | if isIgnoredFolder(path) { 48 | watcherLog("Ignoring %s", path) 49 | return filepath.SkipDir 50 | } 51 | 52 | watchFolder(path) 53 | } 54 | 55 | return err 56 | }) 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | - Cluster and Ring pipelines process commands for each node in its own goroutine. 6 | 7 | ## 6.14 8 | 9 | - Added Options.MinIdleConns. 10 | - Added Options.MaxConnAge. 11 | - PoolStats.FreeConns is renamed to PoolStats.IdleConns. 12 | - Add Client.Do to simplify creating custom commands. 13 | - Add Cmd.String, Cmd.Int, Cmd.Int64, Cmd.Uint64, Cmd.Float64, and Cmd.Bool helpers. 14 | - Lower memory usage. 15 | 16 | ## v6.13 17 | 18 | - Ring got new options called `HashReplicas` and `Hash`. It is recommended to set `HashReplicas = 1000` for better keys distribution between shards. 19 | - Cluster client was optimized to use much less memory when reloading cluster state. 20 | - PubSub.ReceiveMessage is re-worked to not use ReceiveTimeout so it does not lose data when timeout occurres. In most cases it is recommended to use PubSub.Channel instead. 21 | - Dialer.KeepAlive is set to 5 minutes by default. 22 | 23 | ## v6.12 24 | 25 | - ClusterClient got new option called `ClusterSlots` which allows to build cluster of normal Redis Servers that don't have cluster mode enabled. See https://godoc.org/github.com/go-redis/redis#example-NewClusterClient--ManualSetup 26 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module a2os/safeu-backend 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190125095113-2b29687e15f2 7 | github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9 8 | github.com/gin-contrib/cors v0.0.0-20190101123304-5e7acb10687f 9 | github.com/gin-contrib/sessions v0.0.0-20190226023029-1532893d996f 10 | github.com/gin-gonic/gin v1.3.0 11 | github.com/go-redis/redis v6.15.2+incompatible 12 | github.com/go-sql-driver/mysql v0.0.0-20180530100258-7413002f368f 13 | github.com/golang/protobuf v1.2.0 14 | github.com/gorilla/context v1.1.1 15 | github.com/gorilla/securecookie v1.1.1 16 | github.com/gorilla/sessions v1.1.3 17 | github.com/howeyc/fsnotify v0.0.0-20151003194602-f0c08ee9c607 18 | github.com/jinzhu/gorm v0.0.0-20190102133208-9f1a7f535111 19 | github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a 20 | github.com/mattn/go-colorable v0.1.0 21 | github.com/pilu/config v0.0.0-20131214182432-3eb99e6c0b9a 22 | github.com/pilu/fresh v0.0.0-20170301142741-9c0092493eff 23 | github.com/satori/go.uuid v0.0.0-20181028125025-b2ce2384e17b 24 | github.com/utrack/gin-csrf v0.0.0-20190213160413-1689c46c9740 25 | gopkg.in/go-playground/validator.v8 v8.18.2 26 | gopkg.in/yaml.v2 v2.2.2 27 | ) 28 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/json.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. 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 binding 6 | 7 | import ( 8 | "bytes" 9 | "io" 10 | "net/http" 11 | 12 | "github.com/gin-gonic/gin/json" 13 | ) 14 | 15 | // EnableDecoderUseNumber is used to call the UseNumber method on the JSON 16 | // Decoder instance. UseNumber causes the Decoder to unmarshal a number into an 17 | // interface{} as a Number instead of as a float64. 18 | var EnableDecoderUseNumber = false 19 | 20 | type jsonBinding struct{} 21 | 22 | func (jsonBinding) Name() string { 23 | return "json" 24 | } 25 | 26 | func (jsonBinding) Bind(req *http.Request, obj interface{}) error { 27 | return decodeJSON(req.Body, obj) 28 | } 29 | 30 | func (jsonBinding) BindBody(body []byte, obj interface{}) error { 31 | return decodeJSON(bytes.NewReader(body), obj) 32 | } 33 | 34 | func decodeJSON(r io.Reader, obj interface{}) error { 35 | decoder := json.NewDecoder(r) 36 | if EnableDecoderUseNumber { 37 | decoder.UseNumber() 38 | } 39 | if err := decoder.Decode(obj); err != nil { 40 | return err 41 | } 42 | return validate(obj) 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/json-iterator/go/any_nil.go: -------------------------------------------------------------------------------- 1 | package jsoniter 2 | 3 | type nilAny struct { 4 | baseAny 5 | } 6 | 7 | func (any *nilAny) LastError() error { 8 | return nil 9 | } 10 | 11 | func (any *nilAny) ValueType() ValueType { 12 | return NilValue 13 | } 14 | 15 | func (any *nilAny) MustBeValid() Any { 16 | return any 17 | } 18 | 19 | func (any *nilAny) ToBool() bool { 20 | return false 21 | } 22 | 23 | func (any *nilAny) ToInt() int { 24 | return 0 25 | } 26 | 27 | func (any *nilAny) ToInt32() int32 { 28 | return 0 29 | } 30 | 31 | func (any *nilAny) ToInt64() int64 { 32 | return 0 33 | } 34 | 35 | func (any *nilAny) ToUint() uint { 36 | return 0 37 | } 38 | 39 | func (any *nilAny) ToUint32() uint32 { 40 | return 0 41 | } 42 | 43 | func (any *nilAny) ToUint64() uint64 { 44 | return 0 45 | } 46 | 47 | func (any *nilAny) ToFloat32() float32 { 48 | return 0 49 | } 50 | 51 | func (any *nilAny) ToFloat64() float64 { 52 | return 0 53 | } 54 | 55 | func (any *nilAny) ToString() string { 56 | return "" 57 | } 58 | 59 | func (any *nilAny) WriteTo(stream *Stream) { 60 | stream.WriteNil() 61 | } 62 | 63 | func (any *nilAny) Parse() *Iterator { 64 | return nil 65 | } 66 | 67 | func (any *nilAny) GetInterface() interface{} { 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/gin-contrib/sessions/cookie/cookie.go: -------------------------------------------------------------------------------- 1 | package cookie 2 | 3 | import ( 4 | "github.com/gin-contrib/sessions" 5 | gsessions "github.com/gorilla/sessions" 6 | ) 7 | 8 | type Store interface { 9 | sessions.Store 10 | } 11 | 12 | // Keys are defined in pairs to allow key rotation, but the common case is to set a single 13 | // authentication key and optionally an encryption key. 14 | // 15 | // The first key in a pair is used for authentication and the second for encryption. The 16 | // encryption key can be set to nil or omitted in the last pair, but the authentication key 17 | // is required in all pairs. 18 | // 19 | // It is recommended to use an authentication key with 32 or 64 bytes. The encryption key, 20 | // if set, must be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256 modes. 21 | func NewStore(keyPairs ...[]byte) Store { 22 | return &store{gsessions.NewCookieStore(keyPairs...)} 23 | } 24 | 25 | type store struct { 26 | *gsessions.CookieStore 27 | } 28 | 29 | func (c *store) Options(options sessions.Options) { 30 | c.CookieStore.Options = &gsessions.Options{ 31 | Path: options.Path, 32 | Domain: options.Domain, 33 | MaxAge: options.MaxAge, 34 | Secure: options.Secure, 35 | HttpOnly: options.HttpOnly, 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/README.md: -------------------------------------------------------------------------------- 1 | # go-isatty 2 | 3 | [![Godoc Reference](https://godoc.org/github.com/mattn/go-isatty?status.svg)](http://godoc.org/github.com/mattn/go-isatty) 4 | [![Build Status](https://travis-ci.org/mattn/go-isatty.svg?branch=master)](https://travis-ci.org/mattn/go-isatty) 5 | [![Coverage Status](https://coveralls.io/repos/github/mattn/go-isatty/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-isatty?branch=master) 6 | [![Go Report Card](https://goreportcard.com/badge/mattn/go-isatty)](https://goreportcard.com/report/mattn/go-isatty) 7 | 8 | isatty for golang 9 | 10 | ## Usage 11 | 12 | ```go 13 | package main 14 | 15 | import ( 16 | "fmt" 17 | "github.com/mattn/go-isatty" 18 | "os" 19 | ) 20 | 21 | func main() { 22 | if isatty.IsTerminal(os.Stdout.Fd()) { 23 | fmt.Println("Is Terminal") 24 | } else if isatty.IsCygwinTerminal(os.Stdout.Fd()) { 25 | fmt.Println("Is Cygwin/MSYS2 Terminal") 26 | } else { 27 | fmt.Println("Is Not Terminal") 28 | } 29 | } 30 | ``` 31 | 32 | ## Installation 33 | 34 | ``` 35 | $ go get github.com/mattn/go-isatty 36 | ``` 37 | 38 | ## License 39 | 40 | MIT 41 | 42 | ## Author 43 | 44 | Yasuhiro Matsumoto (a.k.a mattn) 45 | 46 | ## Thanks 47 | 48 | * k-takata: base idea for IsCygwinTerminal 49 | 50 | https://github.com/k-takata/go-iscygpty 51 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/fs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Manu Martinez-Almeida. 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 gin 6 | 7 | import ( 8 | "net/http" 9 | "os" 10 | ) 11 | 12 | type onlyfilesFS struct { 13 | fs http.FileSystem 14 | } 15 | 16 | type neuteredReaddirFile struct { 17 | http.File 18 | } 19 | 20 | // Dir returns a http.Filesystem that can be used by http.FileServer(). It is used internally 21 | // in router.Static(). 22 | // if listDirectory == true, then it works the same as http.Dir() otherwise it returns 23 | // a filesystem that prevents http.FileServer() to list the directory files. 24 | func Dir(root string, listDirectory bool) http.FileSystem { 25 | fs := http.Dir(root) 26 | if listDirectory { 27 | return fs 28 | } 29 | return &onlyfilesFS{fs} 30 | } 31 | 32 | // Open conforms to http.Filesystem. 33 | func (fs onlyfilesFS) Open(name string) (http.File, error) { 34 | f, err := fs.fs.Open(name) 35 | if err != nil { 36 | return nil, err 37 | } 38 | return neuteredReaddirFile{f}, nil 39 | } 40 | 41 | // Readdir overrides the http.File default implementation. 42 | func (f neuteredReaddirFile) Readdir(count int) ([]os.FileInfo, error) { 43 | // this disables directory listing 44 | return nil, nil 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/pilu/fresh/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | Fresh is a command line tool that builds and (re)starts your web application everytime you save a go or template file. 3 | 4 | If the web framework you are using supports the Fresh runner, it will show build errors on your browser. 5 | 6 | It currently works with Traffic (https://github.com/pilu/traffic), Martini (https://github.com/codegangsta/martini) and gocraft/web (https://github.com/gocraft/web). 7 | 8 | Fresh will watch for file events, and every time you create/modifiy/delete a file it will build and restart the application. 9 | If `go build` returns an error, it will logs it in the tmp folder. 10 | 11 | Traffic (https://github.com/pilu/traffic) already has a middleware that shows the content of that file if it is present. This middleware is automatically added if you run a Traffic web app in dev mode with Fresh. 12 | */ 13 | package main 14 | 15 | import ( 16 | "flag" 17 | "fmt" 18 | "github.com/pilu/fresh/runner" 19 | "os" 20 | ) 21 | 22 | func main() { 23 | configPath := flag.String("c", "", "config file path") 24 | flag.Parse() 25 | 26 | if *configPath != "" { 27 | if _, err := os.Stat(*configPath); err != nil { 28 | fmt.Printf("Can't find config file `%s`\n", *configPath) 29 | os.Exit(1) 30 | } else { 31 | os.Setenv("RUNNER_CONFIG_PATH", *configPath) 32 | } 33 | } 34 | 35 | runner.Start() 36 | } 37 | -------------------------------------------------------------------------------- /scripts/install-docker-family-on-ubuntu-1804.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # remove older versions 4 | sudo apt-get remove docker docker-engine docker.io containerd runc -y 5 | 6 | # Install docker via USTC mirror 7 | # sudo apt-get update -y 8 | # sudo apt-get install -y \ 9 | # apt-transport-https \ 10 | # ca-certificates \ 11 | # curl \ 12 | # gnupg-agent \ 13 | # software-properties-common 14 | 15 | # curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -y - 16 | 17 | # sudo add-apt-repository -y \ 18 | # "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \ 19 | # $(lsb_release -cs) \ 20 | # stable" 21 | 22 | # sudo apt-get update -y 23 | # sudo apt-get install docker-ce docker-ce-cli containerd.io -y 24 | 25 | # Install docker via DaoCloud mirror 26 | curl -sSL https://get.daocloud.io/docker | sh 27 | 28 | if [ ! -f "/etc/docker/daemon.json" ]; then 29 | echo "{ 30 | \"registry-mirrors\": [\"https://docker.mirrors.ustc.edu.cn/\"] 31 | } 32 | " >> /etc/docker/daemon.json 33 | fi 34 | 35 | sudo systemctl restart docker 36 | 37 | # Install docker compose via DaoCloud 38 | curl -L https://get.daocloud.io/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose 39 | chmod +x /usr/local/bin/docker-compose 40 | 41 | echo "" 42 | echo "Installed docker & docker-compose successfully~" 43 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 The github.com/go-redis/redis Authors. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/LICENSE.libyaml: -------------------------------------------------------------------------------- 1 | The following files were ported to Go from C files of libyaml, and thus 2 | are still covered by their original copyright and license: 3 | 4 | apic.go 5 | emitterc.go 6 | parserc.go 7 | readerc.go 8 | scannerc.go 9 | writerc.go 10 | yamlh.go 11 | yamlprivateh.go 12 | 13 | Copyright (c) 2006 Kirill Simonov 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | this software and associated documentation files (the "Software"), to deal in 17 | the Software without restriction, including without limitation the rights to 18 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | of the Software, and to permit persons to whom the Software is furnished to do 20 | so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in all 23 | copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 | SOFTWARE. 32 | -------------------------------------------------------------------------------- /vendor/github.com/utrack/gin-csrf/README.md: -------------------------------------------------------------------------------- 1 | # gin-csrf [![Build Status](https://travis-ci.org/utrack/gin-csrf.svg?branch=master)](https://travis-ci.org/utrack/gin-csrf) 2 | 3 | CSRF protection middleware for [Gin]. This middleware has to be used with [gin-contrib/sessions](https://github.com/gin-contrib/sessions). 4 | 5 | Original credit to [tommy351](https://github.com/tommy351/gin-csrf), this fork makes it work with gin-gonic contrib sessions. 6 | 7 | ## Installation 8 | 9 | ``` bash 10 | $ go get github.com/utrack/gin-csrf 11 | ``` 12 | 13 | ## Usage 14 | 15 | ``` go 16 | import ( 17 | "errors" 18 | 19 | "github.com/gin-gonic/gin" 20 | "github.com/gin-contrib/sessions" 21 | "github.com/utrack/gin-csrf" 22 | ) 23 | 24 | func main(){ 25 | r := gin.Default() 26 | store := sessions.NewCookieStore([]byte("secret")) 27 | r.Use(sessions.Sessions("mysession", store)) 28 | r.Use(csrf.Middleware(csrf.Options{ 29 | Secret: "secret123", 30 | ErrorFunc: func(c *gin.Context){ 31 | c.String(400, "CSRF token mismatch") 32 | c.Abort() 33 | }, 34 | })) 35 | 36 | r.GET("/protected", func(c *gin.Context){ 37 | c.String(200, csrf.GetToken(c)) 38 | }) 39 | 40 | r.POST("/protected", func(c *gin.Context){ 41 | c.String(200, "CSRF token is valid") 42 | }) 43 | } 44 | ``` 45 | 46 | [Gin]: http://gin-gonic.github.io/gin/ 47 | [gin-sessions]: https://github.com/utrack/gin-sessions 48 | -------------------------------------------------------------------------------- /vendor/github.com/json-iterator/go/any_int64.go: -------------------------------------------------------------------------------- 1 | package jsoniter 2 | 3 | import ( 4 | "strconv" 5 | ) 6 | 7 | type int64Any struct { 8 | baseAny 9 | val int64 10 | } 11 | 12 | func (any *int64Any) LastError() error { 13 | return nil 14 | } 15 | 16 | func (any *int64Any) ValueType() ValueType { 17 | return NumberValue 18 | } 19 | 20 | func (any *int64Any) MustBeValid() Any { 21 | return any 22 | } 23 | 24 | func (any *int64Any) ToBool() bool { 25 | return any.val != 0 26 | } 27 | 28 | func (any *int64Any) ToInt() int { 29 | return int(any.val) 30 | } 31 | 32 | func (any *int64Any) ToInt32() int32 { 33 | return int32(any.val) 34 | } 35 | 36 | func (any *int64Any) ToInt64() int64 { 37 | return any.val 38 | } 39 | 40 | func (any *int64Any) ToUint() uint { 41 | return uint(any.val) 42 | } 43 | 44 | func (any *int64Any) ToUint32() uint32 { 45 | return uint32(any.val) 46 | } 47 | 48 | func (any *int64Any) ToUint64() uint64 { 49 | return uint64(any.val) 50 | } 51 | 52 | func (any *int64Any) ToFloat32() float32 { 53 | return float32(any.val) 54 | } 55 | 56 | func (any *int64Any) ToFloat64() float64 { 57 | return float64(any.val) 58 | } 59 | 60 | func (any *int64Any) ToString() string { 61 | return strconv.FormatInt(any.val, 10) 62 | } 63 | 64 | func (any *int64Any) WriteTo(stream *Stream) { 65 | stream.WriteInt64(any.val) 66 | } 67 | 68 | func (any *int64Any) Parse() *Iterator { 69 | return nil 70 | } 71 | 72 | func (any *int64Any) GetInterface() interface{} { 73 | return any.val 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/json-iterator/go/any_int32.go: -------------------------------------------------------------------------------- 1 | package jsoniter 2 | 3 | import ( 4 | "strconv" 5 | ) 6 | 7 | type int32Any struct { 8 | baseAny 9 | val int32 10 | } 11 | 12 | func (any *int32Any) LastError() error { 13 | return nil 14 | } 15 | 16 | func (any *int32Any) ValueType() ValueType { 17 | return NumberValue 18 | } 19 | 20 | func (any *int32Any) MustBeValid() Any { 21 | return any 22 | } 23 | 24 | func (any *int32Any) ToBool() bool { 25 | return any.val != 0 26 | } 27 | 28 | func (any *int32Any) ToInt() int { 29 | return int(any.val) 30 | } 31 | 32 | func (any *int32Any) ToInt32() int32 { 33 | return any.val 34 | } 35 | 36 | func (any *int32Any) ToInt64() int64 { 37 | return int64(any.val) 38 | } 39 | 40 | func (any *int32Any) ToUint() uint { 41 | return uint(any.val) 42 | } 43 | 44 | func (any *int32Any) ToUint32() uint32 { 45 | return uint32(any.val) 46 | } 47 | 48 | func (any *int32Any) ToUint64() uint64 { 49 | return uint64(any.val) 50 | } 51 | 52 | func (any *int32Any) ToFloat32() float32 { 53 | return float32(any.val) 54 | } 55 | 56 | func (any *int32Any) ToFloat64() float64 { 57 | return float64(any.val) 58 | } 59 | 60 | func (any *int32Any) ToString() string { 61 | return strconv.FormatInt(int64(any.val), 10) 62 | } 63 | 64 | func (any *int32Any) WriteTo(stream *Stream) { 65 | stream.WriteInt32(any.val) 66 | } 67 | 68 | func (any *int32Any) Parse() *Iterator { 69 | return nil 70 | } 71 | 72 | func (any *int32Any) GetInterface() interface{} { 73 | return any.val 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/json-iterator/go/any_uint64.go: -------------------------------------------------------------------------------- 1 | package jsoniter 2 | 3 | import ( 4 | "strconv" 5 | ) 6 | 7 | type uint64Any struct { 8 | baseAny 9 | val uint64 10 | } 11 | 12 | func (any *uint64Any) LastError() error { 13 | return nil 14 | } 15 | 16 | func (any *uint64Any) ValueType() ValueType { 17 | return NumberValue 18 | } 19 | 20 | func (any *uint64Any) MustBeValid() Any { 21 | return any 22 | } 23 | 24 | func (any *uint64Any) ToBool() bool { 25 | return any.val != 0 26 | } 27 | 28 | func (any *uint64Any) ToInt() int { 29 | return int(any.val) 30 | } 31 | 32 | func (any *uint64Any) ToInt32() int32 { 33 | return int32(any.val) 34 | } 35 | 36 | func (any *uint64Any) ToInt64() int64 { 37 | return int64(any.val) 38 | } 39 | 40 | func (any *uint64Any) ToUint() uint { 41 | return uint(any.val) 42 | } 43 | 44 | func (any *uint64Any) ToUint32() uint32 { 45 | return uint32(any.val) 46 | } 47 | 48 | func (any *uint64Any) ToUint64() uint64 { 49 | return any.val 50 | } 51 | 52 | func (any *uint64Any) ToFloat32() float32 { 53 | return float32(any.val) 54 | } 55 | 56 | func (any *uint64Any) ToFloat64() float64 { 57 | return float64(any.val) 58 | } 59 | 60 | func (any *uint64Any) ToString() string { 61 | return strconv.FormatUint(any.val, 10) 62 | } 63 | 64 | func (any *uint64Any) WriteTo(stream *Stream) { 65 | stream.WriteUint64(any.val) 66 | } 67 | 68 | func (any *uint64Any) Parse() *Iterator { 69 | return nil 70 | } 71 | 72 | func (any *uint64Any) GetInterface() interface{} { 73 | return any.val 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/json-iterator/go/iter_array.go: -------------------------------------------------------------------------------- 1 | package jsoniter 2 | 3 | // ReadArray read array element, tells if the array has more element to read. 4 | func (iter *Iterator) ReadArray() (ret bool) { 5 | c := iter.nextToken() 6 | switch c { 7 | case 'n': 8 | iter.skipThreeBytes('u', 'l', 'l') 9 | return false // null 10 | case '[': 11 | c = iter.nextToken() 12 | if c != ']' { 13 | iter.unreadByte() 14 | return true 15 | } 16 | return false 17 | case ']': 18 | return false 19 | case ',': 20 | return true 21 | default: 22 | iter.ReportError("ReadArray", "expect [ or , or ] or n, but found "+string([]byte{c})) 23 | return 24 | } 25 | } 26 | 27 | // ReadArrayCB read array with callback 28 | func (iter *Iterator) ReadArrayCB(callback func(*Iterator) bool) (ret bool) { 29 | c := iter.nextToken() 30 | if c == '[' { 31 | c = iter.nextToken() 32 | if c != ']' { 33 | iter.unreadByte() 34 | if !callback(iter) { 35 | return false 36 | } 37 | c = iter.nextToken() 38 | for c == ',' { 39 | if !callback(iter) { 40 | return false 41 | } 42 | c = iter.nextToken() 43 | } 44 | if c != ']' { 45 | iter.ReportError("ReadArrayCB", "expect ] in the end, but found "+string([]byte{c})) 46 | return false 47 | } 48 | return true 49 | } 50 | return true 51 | } 52 | if c == 'n' { 53 | iter.skipThreeBytes('u', 'l', 'l') 54 | return true // null 55 | } 56 | iter.ReportError("ReadArrayCB", "expect [ or n, but found "+string([]byte{c})) 57 | return false 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/json-iterator/go/any_uint32.go: -------------------------------------------------------------------------------- 1 | package jsoniter 2 | 3 | import ( 4 | "strconv" 5 | ) 6 | 7 | type uint32Any struct { 8 | baseAny 9 | val uint32 10 | } 11 | 12 | func (any *uint32Any) LastError() error { 13 | return nil 14 | } 15 | 16 | func (any *uint32Any) ValueType() ValueType { 17 | return NumberValue 18 | } 19 | 20 | func (any *uint32Any) MustBeValid() Any { 21 | return any 22 | } 23 | 24 | func (any *uint32Any) ToBool() bool { 25 | return any.val != 0 26 | } 27 | 28 | func (any *uint32Any) ToInt() int { 29 | return int(any.val) 30 | } 31 | 32 | func (any *uint32Any) ToInt32() int32 { 33 | return int32(any.val) 34 | } 35 | 36 | func (any *uint32Any) ToInt64() int64 { 37 | return int64(any.val) 38 | } 39 | 40 | func (any *uint32Any) ToUint() uint { 41 | return uint(any.val) 42 | } 43 | 44 | func (any *uint32Any) ToUint32() uint32 { 45 | return any.val 46 | } 47 | 48 | func (any *uint32Any) ToUint64() uint64 { 49 | return uint64(any.val) 50 | } 51 | 52 | func (any *uint32Any) ToFloat32() float32 { 53 | return float32(any.val) 54 | } 55 | 56 | func (any *uint32Any) ToFloat64() float64 { 57 | return float64(any.val) 58 | } 59 | 60 | func (any *uint32Any) ToString() string { 61 | return strconv.FormatInt(int64(any.val), 10) 62 | } 63 | 64 | func (any *uint32Any) WriteTo(stream *Stream) { 65 | stream.WriteUint32(any.val) 66 | } 67 | 68 | func (any *uint32Any) Parse() *Iterator { 69 | return nil 70 | } 71 | 72 | func (any *uint32Any) GetInterface() interface{} { 73 | return any.val 74 | } 75 | -------------------------------------------------------------------------------- /conf/nginx/nginx.dev.conf: -------------------------------------------------------------------------------- 1 | # user www-data; 2 | worker_processes auto; 3 | pid /run/nginx.pid; 4 | include /etc/nginx/modules-enabled/*.conf; 5 | 6 | events { 7 | worker_connections 768; 8 | # multi_accept on; 9 | } 10 | 11 | http { 12 | 13 | # SafeU backend server LB settings 14 | upstream app_servers { 15 | least_conn; 16 | server web:8080 max_fails=10 fail_timeout=10s; 17 | } 18 | 19 | ## 20 | # Basic Settings 21 | ## 22 | 23 | sendfile on; 24 | tcp_nopush on; 25 | tcp_nodelay on; 26 | keepalive_timeout 65; 27 | types_hash_max_size 2048; 28 | # server_tokens off; 29 | 30 | # server_names_hash_bucket_size 64; 31 | # server_name_in_redirect off; 32 | 33 | include /etc/nginx/mime.types; 34 | default_type application/octet-stream; 35 | 36 | ## 37 | # SSL Settings 38 | ## 39 | 40 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE 41 | ssl_prefer_server_ciphers on; 42 | 43 | ## 44 | # Logging Settings 45 | ## 46 | 47 | access_log /var/log/nginx/access.log; 48 | error_log /var/log/nginx/error.log; 49 | 50 | ## 51 | # Gzip Settings 52 | ## 53 | 54 | gzip on; 55 | 56 | # gzip_vary on; 57 | # gzip_proxied any; 58 | # gzip_comp_level 6; 59 | # gzip_buffers 16 8k; 60 | # gzip_http_version 1.1; 61 | # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; 62 | 63 | ## 64 | # Virtual Host Configs 65 | ## 66 | 67 | # include /etc/nginx/conf.d/*.conf; 68 | include /etc/nginx/sites-enabled/*; 69 | 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/form.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. 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 binding 6 | 7 | import "net/http" 8 | 9 | const defaultMemory = 32 * 1024 * 1024 10 | 11 | type formBinding struct{} 12 | type formPostBinding struct{} 13 | type formMultipartBinding struct{} 14 | 15 | func (formBinding) Name() string { 16 | return "form" 17 | } 18 | 19 | func (formBinding) Bind(req *http.Request, obj interface{}) error { 20 | if err := req.ParseForm(); err != nil { 21 | return err 22 | } 23 | req.ParseMultipartForm(defaultMemory) 24 | if err := mapForm(obj, req.Form); err != nil { 25 | return err 26 | } 27 | return validate(obj) 28 | } 29 | 30 | func (formPostBinding) Name() string { 31 | return "form-urlencoded" 32 | } 33 | 34 | func (formPostBinding) Bind(req *http.Request, obj interface{}) error { 35 | if err := req.ParseForm(); err != nil { 36 | return err 37 | } 38 | if err := mapForm(obj, req.PostForm); err != nil { 39 | return err 40 | } 41 | return validate(obj) 42 | } 43 | 44 | func (formMultipartBinding) Name() string { 45 | return "multipart/form-data" 46 | } 47 | 48 | func (formMultipartBinding) Bind(req *http.Request, obj interface{}) error { 49 | if err := req.ParseMultipartForm(defaultMemory); err != nil { 50 | return err 51 | } 52 | if err := mapForm(obj, req.MultipartForm.Value); err != nil { 53 | return err 54 | } 55 | return validate(obj) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/utils_go18.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2017 The Go-MySQL-Driver Authors. All rights reserved. 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 7 | // You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | // +build go1.8 10 | 11 | package mysql 12 | 13 | import ( 14 | "crypto/tls" 15 | "database/sql" 16 | "database/sql/driver" 17 | "errors" 18 | "fmt" 19 | ) 20 | 21 | func cloneTLSConfig(c *tls.Config) *tls.Config { 22 | return c.Clone() 23 | } 24 | 25 | func namedValueToValue(named []driver.NamedValue) ([]driver.Value, error) { 26 | dargs := make([]driver.Value, len(named)) 27 | for n, param := range named { 28 | if len(param.Name) > 0 { 29 | // TODO: support the use of Named Parameters #561 30 | return nil, errors.New("mysql: driver does not support the use of Named Parameters") 31 | } 32 | dargs[n] = param.Value 33 | } 34 | return dargs, nil 35 | } 36 | 37 | func mapIsolationLevel(level driver.IsolationLevel) (string, error) { 38 | switch sql.IsolationLevel(level) { 39 | case sql.LevelRepeatableRead: 40 | return "REPEATABLE READ", nil 41 | case sql.LevelReadCommitted: 42 | return "READ COMMITTED", nil 43 | case sql.LevelReadUncommitted: 44 | return "READ UNCOMMITTED", nil 45 | case sql.LevelSerializable: 46 | return "SERIALIZABLE", nil 47 | default: 48 | return "", fmt.Errorf("mysql: unsupported isolation level: %v", level) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /conf/nginx/nginx.prod.conf: -------------------------------------------------------------------------------- 1 | user www-data; 2 | worker_processes auto; 3 | pid /run/nginx.pid; 4 | include /etc/nginx/modules-enabled/*.conf; 5 | 6 | events { 7 | worker_connections 4096; 8 | # multi_accept on; 9 | } 10 | 11 | http { 12 | 13 | # SafeU backend server LB settings 14 | upstream app_servers { 15 | least_conn; 16 | server web1:8080 max_fails=3 fail_timeout=10s; 17 | server web2:8080 max_fails=3 fail_timeout=10s; 18 | } 19 | 20 | 21 | ## 22 | # Basic Settings 23 | ## 24 | 25 | sendfile on; 26 | tcp_nopush on; 27 | tcp_nodelay on; 28 | keepalive_timeout 65; 29 | types_hash_max_size 2048; 30 | # server_tokens off; 31 | 32 | # server_names_hash_bucket_size 64; 33 | # server_name_in_redirect off; 34 | 35 | include /etc/nginx/mime.types; 36 | default_type application/octet-stream; 37 | 38 | ## 39 | # SSL Settings 40 | ## 41 | 42 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE 43 | ssl_prefer_server_ciphers on; 44 | 45 | ## 46 | # Logging Settings 47 | ## 48 | 49 | access_log /var/log/nginx/access.log; 50 | error_log /var/log/nginx/error.log; 51 | 52 | ## 53 | # Gzip Settings 54 | ## 55 | 56 | gzip on; 57 | 58 | # gzip_vary on; 59 | # gzip_proxied any; 60 | # gzip_comp_level 6; 61 | # gzip_buffers 16 8k; 62 | # gzip_http_version 1.1; 63 | # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; 64 | 65 | ## 66 | # Virtual Host Configs 67 | ## 68 | 69 | # include /etc/nginx/conf.d/*.conf; 70 | include /etc/nginx/sites-enabled/*; 71 | 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/default_validator.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Manu Martinez-Almeida. 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 binding 6 | 7 | import ( 8 | "reflect" 9 | "sync" 10 | 11 | "gopkg.in/go-playground/validator.v8" 12 | ) 13 | 14 | type defaultValidator struct { 15 | once sync.Once 16 | validate *validator.Validate 17 | } 18 | 19 | var _ StructValidator = &defaultValidator{} 20 | 21 | // ValidateStruct receives any kind of type, but only performed struct or pointer to struct type. 22 | func (v *defaultValidator) ValidateStruct(obj interface{}) error { 23 | value := reflect.ValueOf(obj) 24 | valueType := value.Kind() 25 | if valueType == reflect.Ptr { 26 | valueType = value.Elem().Kind() 27 | } 28 | if valueType == reflect.Struct { 29 | v.lazyinit() 30 | if err := v.validate.Struct(obj); err != nil { 31 | return err 32 | } 33 | } 34 | return nil 35 | } 36 | 37 | // Engine returns the underlying validator engine which powers the default 38 | // Validator instance. This is useful if you want to register custom validations 39 | // or struct level validations. See validator GoDoc for more info - 40 | // https://godoc.org/gopkg.in/go-playground/validator.v8 41 | func (v *defaultValidator) Engine() interface{} { 42 | v.lazyinit() 43 | return v.validate 44 | } 45 | 46 | func (v *defaultValidator) lazyinit() { 47 | v.once.Do(func() { 48 | config := &validator.Config{TagName: "binding"} 49 | v.validate = validator.New(config) 50 | }) 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2010 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/README.md: -------------------------------------------------------------------------------- 1 | # go-colorable 2 | 3 | [![Godoc Reference](https://godoc.org/github.com/mattn/go-colorable?status.svg)](http://godoc.org/github.com/mattn/go-colorable) 4 | [![Build Status](https://travis-ci.org/mattn/go-colorable.svg?branch=master)](https://travis-ci.org/mattn/go-colorable) 5 | [![Coverage Status](https://coveralls.io/repos/github/mattn/go-colorable/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-colorable?branch=master) 6 | [![Go Report Card](https://goreportcard.com/badge/mattn/go-colorable)](https://goreportcard.com/report/mattn/go-colorable) 7 | 8 | Colorable writer for windows. 9 | 10 | For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But I don't want.) 11 | This package is possible to handle escape sequence for ansi color on windows. 12 | 13 | ## Too Bad! 14 | 15 | ![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/bad.png) 16 | 17 | 18 | ## So Good! 19 | 20 | ![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/good.png) 21 | 22 | ## Usage 23 | 24 | ```go 25 | logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true}) 26 | logrus.SetOutput(colorable.NewColorableStdout()) 27 | 28 | logrus.Info("succeeded") 29 | logrus.Warn("not correct") 30 | logrus.Error("something error") 31 | logrus.Fatal("panic") 32 | ``` 33 | 34 | You can compile above code on non-windows OSs. 35 | 36 | ## Installation 37 | 38 | ``` 39 | $ go get github.com/mattn/go-colorable 40 | ``` 41 | 42 | # License 43 | 44 | MIT 45 | 46 | # Author 47 | 48 | Yasuhiro Matsumoto (a.k.a mattn) 49 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/securecookie/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2018 The Gorilla Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/sessions/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2018 The Gorilla Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /scripts/upgrade-safeu-containers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Author: TripleZ 3 | # Date: 2019-04-30 4 | 5 | helpMsg() { 6 | echo -e " Usage: 7 | ./upgrade-safeu-containers.sh [ENV] [BRANCH NAME] 8 | ./upgrade-safeu-containers.sh -h|--help 9 | 10 | Environments: 11 | dev Development environment 12 | staging Staging deployment environment 13 | prod Production deployment environment 14 | 15 | Branchs: 16 | master Stable version 17 | dev Development version 18 | [custom] Custom Git branch 19 | " 20 | } 21 | 22 | if [ "$2" != "" ] 23 | then 24 | # update code 25 | git stash # stash the current modification 26 | # git pull # default pull to update branches 27 | git fetch origin $2 28 | git checkout $2 29 | else 30 | echo -e "\n [ERROR] Unrecognized branch name!\n" 31 | helpMsg 32 | exit 1 33 | fi 34 | 35 | if [ "$1" == "prod" ] 36 | then 37 | sudo ./prod-docker-compose.sh build 38 | sudo ./prod-docker-compose.sh down 39 | sudo ./prod-docker-compose.sh up 40 | 41 | elif [ "$1" == "staging" ] 42 | then 43 | sudo ./staging-docker-compose.sh build 44 | sudo ./staging-docker-compose.sh down 45 | sudo ./staging-docker-compose.sh up 46 | 47 | elif [ "$1" == "dev" ] 48 | then 49 | sudo ./dev-docker-compose.sh build 50 | sudo ./dev-docker-compose.sh down 51 | sudo ./dev-docker-compose.sh up 52 | 53 | elif [ "$1" == "-h" ] || [ "$1" == "--help" ] 54 | then 55 | helpMsg 56 | else 57 | echo -e " [ERROR] Unrecognized environment name!\n" 58 | helpMsg 59 | exit 1 60 | fi 61 | -------------------------------------------------------------------------------- /vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/model.go: -------------------------------------------------------------------------------- 1 | package oss 2 | 3 | import ( 4 | "hash" 5 | "io" 6 | "net/http" 7 | ) 8 | 9 | // Response defines HTTP response from OSS 10 | type Response struct { 11 | StatusCode int 12 | Headers http.Header 13 | Body io.ReadCloser 14 | ClientCRC uint64 15 | ServerCRC uint64 16 | } 17 | 18 | func (r *Response) Read(p []byte) (n int, err error) { 19 | return r.Body.Read(p) 20 | } 21 | 22 | func (r *Response) Close() error { 23 | return r.Body.Close() 24 | } 25 | 26 | // PutObjectRequest is the request of DoPutObject 27 | type PutObjectRequest struct { 28 | ObjectKey string 29 | Reader io.Reader 30 | } 31 | 32 | // GetObjectRequest is the request of DoGetObject 33 | type GetObjectRequest struct { 34 | ObjectKey string 35 | } 36 | 37 | // GetObjectResult is the result of DoGetObject 38 | type GetObjectResult struct { 39 | Response *Response 40 | ClientCRC hash.Hash64 41 | ServerCRC uint64 42 | } 43 | 44 | // AppendObjectRequest is the requtest of DoAppendObject 45 | type AppendObjectRequest struct { 46 | ObjectKey string 47 | Reader io.Reader 48 | Position int64 49 | } 50 | 51 | // AppendObjectResult is the result of DoAppendObject 52 | type AppendObjectResult struct { 53 | NextPosition int64 54 | CRC uint64 55 | } 56 | 57 | // UploadPartRequest is the request of DoUploadPart 58 | type UploadPartRequest struct { 59 | InitResult *InitiateMultipartUploadResult 60 | Reader io.Reader 61 | PartSize int64 62 | PartNumber int 63 | } 64 | 65 | // UploadPartResult is the result of DoUploadPart 66 | type UploadPartResult struct { 67 | Part UploadPart 68 | } 69 | -------------------------------------------------------------------------------- /vendor/github.com/json-iterator/go/any_float.go: -------------------------------------------------------------------------------- 1 | package jsoniter 2 | 3 | import ( 4 | "strconv" 5 | ) 6 | 7 | type floatAny struct { 8 | baseAny 9 | val float64 10 | } 11 | 12 | func (any *floatAny) Parse() *Iterator { 13 | return nil 14 | } 15 | 16 | func (any *floatAny) ValueType() ValueType { 17 | return NumberValue 18 | } 19 | 20 | func (any *floatAny) MustBeValid() Any { 21 | return any 22 | } 23 | 24 | func (any *floatAny) LastError() error { 25 | return nil 26 | } 27 | 28 | func (any *floatAny) ToBool() bool { 29 | return any.ToFloat64() != 0 30 | } 31 | 32 | func (any *floatAny) ToInt() int { 33 | return int(any.val) 34 | } 35 | 36 | func (any *floatAny) ToInt32() int32 { 37 | return int32(any.val) 38 | } 39 | 40 | func (any *floatAny) ToInt64() int64 { 41 | return int64(any.val) 42 | } 43 | 44 | func (any *floatAny) ToUint() uint { 45 | if any.val > 0 { 46 | return uint(any.val) 47 | } 48 | return 0 49 | } 50 | 51 | func (any *floatAny) ToUint32() uint32 { 52 | if any.val > 0 { 53 | return uint32(any.val) 54 | } 55 | return 0 56 | } 57 | 58 | func (any *floatAny) ToUint64() uint64 { 59 | if any.val > 0 { 60 | return uint64(any.val) 61 | } 62 | return 0 63 | } 64 | 65 | func (any *floatAny) ToFloat32() float32 { 66 | return float32(any.val) 67 | } 68 | 69 | func (any *floatAny) ToFloat64() float64 { 70 | return any.val 71 | } 72 | 73 | func (any *floatAny) ToString() string { 74 | return strconv.FormatFloat(any.val, 'E', -1, 64) 75 | } 76 | 77 | func (any *floatAny) WriteTo(stream *Stream) { 78 | stream.WriteFloat64(any.val) 79 | } 80 | 81 | func (any *floatAny) GetInterface() interface{} { 82 | return any.val 83 | } 84 | -------------------------------------------------------------------------------- /vendor/github.com/howeyc/fsnotify/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 The Go Authors. All rights reserved. 2 | Copyright (c) 2012 fsnotify Authors. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/utils_go17.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2017 The Go-MySQL-Driver Authors. All rights reserved. 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 7 | // You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | // +build go1.7 10 | // +build !go1.8 11 | 12 | package mysql 13 | 14 | import "crypto/tls" 15 | 16 | func cloneTLSConfig(c *tls.Config) *tls.Config { 17 | return &tls.Config{ 18 | Rand: c.Rand, 19 | Time: c.Time, 20 | Certificates: c.Certificates, 21 | NameToCertificate: c.NameToCertificate, 22 | GetCertificate: c.GetCertificate, 23 | RootCAs: c.RootCAs, 24 | NextProtos: c.NextProtos, 25 | ServerName: c.ServerName, 26 | ClientAuth: c.ClientAuth, 27 | ClientCAs: c.ClientCAs, 28 | InsecureSkipVerify: c.InsecureSkipVerify, 29 | CipherSuites: c.CipherSuites, 30 | PreferServerCipherSuites: c.PreferServerCipherSuites, 31 | SessionTicketsDisabled: c.SessionTicketsDisabled, 32 | SessionTicketKey: c.SessionTicketKey, 33 | ClientSessionCache: c.ClientSessionCache, 34 | MinVersion: c.MinVersion, 35 | MaxVersion: c.MaxVersion, 36 | CurvePreferences: c.CurvePreferences, 37 | DynamicRecordSizingDisabled: c.DynamicRecordSizingDisabled, 38 | Renegotiation: c.Renegotiation, 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/Makefile: -------------------------------------------------------------------------------- 1 | GOFMT ?= gofmt "-s" 2 | PACKAGES ?= $(shell go list ./... | grep -v /vendor/) 3 | VETPACKAGES ?= $(shell go list ./... | grep -v /vendor/ | grep -v /examples/) 4 | GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*") 5 | 6 | all: install 7 | 8 | install: deps 9 | govendor sync 10 | 11 | .PHONY: test 12 | test: 13 | sh coverage.sh 14 | 15 | .PHONY: fmt 16 | fmt: 17 | $(GOFMT) -w $(GOFILES) 18 | 19 | .PHONY: fmt-check 20 | fmt-check: 21 | # get all go files and run go fmt on them 22 | @diff=$$($(GOFMT) -d $(GOFILES)); \ 23 | if [ -n "$$diff" ]; then \ 24 | echo "Please run 'make fmt' and commit the result:"; \ 25 | echo "$${diff}"; \ 26 | exit 1; \ 27 | fi; 28 | 29 | vet: 30 | go vet $(VETPACKAGES) 31 | 32 | deps: 33 | @hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ 34 | go get -u github.com/kardianos/govendor; \ 35 | fi 36 | @hash embedmd > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ 37 | go get -u github.com/campoy/embedmd; \ 38 | fi 39 | 40 | embedmd: 41 | embedmd -d *.md 42 | 43 | .PHONY: lint 44 | lint: 45 | @hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ 46 | go get -u github.com/golang/lint/golint; \ 47 | fi 48 | for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done; 49 | 50 | .PHONY: misspell-check 51 | misspell-check: 52 | @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ 53 | go get -u github.com/client9/misspell/cmd/misspell; \ 54 | fi 55 | misspell -error $(GOFILES) 56 | 57 | .PHONY: misspell 58 | misspell: 59 | @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ 60 | go get -u github.com/client9/misspell/cmd/misspell; \ 61 | fi 62 | misspell -w $(GOFILES) 63 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/script.go: -------------------------------------------------------------------------------- 1 | package redis 2 | 3 | import ( 4 | "crypto/sha1" 5 | "encoding/hex" 6 | "io" 7 | "strings" 8 | ) 9 | 10 | type scripter interface { 11 | Eval(script string, keys []string, args ...interface{}) *Cmd 12 | EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd 13 | ScriptExists(hashes ...string) *BoolSliceCmd 14 | ScriptLoad(script string) *StringCmd 15 | } 16 | 17 | var _ scripter = (*Client)(nil) 18 | var _ scripter = (*Ring)(nil) 19 | var _ scripter = (*ClusterClient)(nil) 20 | 21 | type Script struct { 22 | src, hash string 23 | } 24 | 25 | func NewScript(src string) *Script { 26 | h := sha1.New() 27 | io.WriteString(h, src) 28 | return &Script{ 29 | src: src, 30 | hash: hex.EncodeToString(h.Sum(nil)), 31 | } 32 | } 33 | 34 | func (s *Script) Hash() string { 35 | return s.hash 36 | } 37 | 38 | func (s *Script) Load(c scripter) *StringCmd { 39 | return c.ScriptLoad(s.src) 40 | } 41 | 42 | func (s *Script) Exists(c scripter) *BoolSliceCmd { 43 | return c.ScriptExists(s.hash) 44 | } 45 | 46 | func (s *Script) Eval(c scripter, keys []string, args ...interface{}) *Cmd { 47 | return c.Eval(s.src, keys, args...) 48 | } 49 | 50 | func (s *Script) EvalSha(c scripter, keys []string, args ...interface{}) *Cmd { 51 | return c.EvalSha(s.hash, keys, args...) 52 | } 53 | 54 | // Run optimistically uses EVALSHA to run the script. If script does not exist 55 | // it is retried using EVAL. 56 | func (s *Script) Run(c scripter, keys []string, args ...interface{}) *Cmd { 57 | r := s.EvalSha(c, keys, args...) 58 | if err := r.Err(); err != nil && strings.HasPrefix(err.Error(), "NOSCRIPT ") { 59 | return s.Eval(c, keys, args...) 60 | } 61 | return r 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/json-iterator/go/any_invalid.go: -------------------------------------------------------------------------------- 1 | package jsoniter 2 | 3 | import "fmt" 4 | 5 | type invalidAny struct { 6 | baseAny 7 | err error 8 | } 9 | 10 | func newInvalidAny(path []interface{}) *invalidAny { 11 | return &invalidAny{baseAny{}, fmt.Errorf("%v not found", path)} 12 | } 13 | 14 | func (any *invalidAny) LastError() error { 15 | return any.err 16 | } 17 | 18 | func (any *invalidAny) ValueType() ValueType { 19 | return InvalidValue 20 | } 21 | 22 | func (any *invalidAny) MustBeValid() Any { 23 | panic(any.err) 24 | } 25 | 26 | func (any *invalidAny) ToBool() bool { 27 | return false 28 | } 29 | 30 | func (any *invalidAny) ToInt() int { 31 | return 0 32 | } 33 | 34 | func (any *invalidAny) ToInt32() int32 { 35 | return 0 36 | } 37 | 38 | func (any *invalidAny) ToInt64() int64 { 39 | return 0 40 | } 41 | 42 | func (any *invalidAny) ToUint() uint { 43 | return 0 44 | } 45 | 46 | func (any *invalidAny) ToUint32() uint32 { 47 | return 0 48 | } 49 | 50 | func (any *invalidAny) ToUint64() uint64 { 51 | return 0 52 | } 53 | 54 | func (any *invalidAny) ToFloat32() float32 { 55 | return 0 56 | } 57 | 58 | func (any *invalidAny) ToFloat64() float64 { 59 | return 0 60 | } 61 | 62 | func (any *invalidAny) ToString() string { 63 | return "" 64 | } 65 | 66 | func (any *invalidAny) WriteTo(stream *Stream) { 67 | } 68 | 69 | func (any *invalidAny) Get(path ...interface{}) Any { 70 | if any.err == nil { 71 | return &invalidAny{baseAny{}, fmt.Errorf("get %v from invalid", path)} 72 | } 73 | return &invalidAny{baseAny{}, fmt.Errorf("%v, get %v from invalid", any.err, path)} 74 | } 75 | 76 | func (any *invalidAny) Parse() *Iterator { 77 | return nil 78 | } 79 | 80 | func (any *invalidAny) GetInterface() interface{} { 81 | return nil 82 | } 83 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/mode.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. 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 gin 6 | 7 | import ( 8 | "io" 9 | "os" 10 | 11 | "github.com/gin-gonic/gin/binding" 12 | ) 13 | 14 | const ENV_GIN_MODE = "GIN_MODE" 15 | 16 | const ( 17 | DebugMode = "debug" 18 | ReleaseMode = "release" 19 | TestMode = "test" 20 | ) 21 | const ( 22 | debugCode = iota 23 | releaseCode 24 | testCode 25 | ) 26 | 27 | // DefaultWriter is the default io.Writer used the Gin for debug output and 28 | // middleware output like Logger() or Recovery(). 29 | // Note that both Logger and Recovery provides custom ways to configure their 30 | // output io.Writer. 31 | // To support coloring in Windows use: 32 | // import "github.com/mattn/go-colorable" 33 | // gin.DefaultWriter = colorable.NewColorableStdout() 34 | var DefaultWriter io.Writer = os.Stdout 35 | var DefaultErrorWriter io.Writer = os.Stderr 36 | 37 | var ginMode = debugCode 38 | var modeName = DebugMode 39 | 40 | func init() { 41 | mode := os.Getenv(ENV_GIN_MODE) 42 | SetMode(mode) 43 | } 44 | 45 | func SetMode(value string) { 46 | switch value { 47 | case DebugMode, "": 48 | ginMode = debugCode 49 | case ReleaseMode: 50 | ginMode = releaseCode 51 | case TestMode: 52 | ginMode = testCode 53 | default: 54 | panic("gin mode unknown: " + value) 55 | } 56 | if value == "" { 57 | value = DebugMode 58 | } 59 | modeName = value 60 | } 61 | 62 | func DisableBindValidation() { 63 | binding.Validator = nil 64 | } 65 | 66 | func EnableJsonDecoderUseNumber() { 67 | binding.EnableDecoderUseNumber = true 68 | } 69 | 70 | func Mode() string { 71 | return modeName 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/iterator.go: -------------------------------------------------------------------------------- 1 | package redis 2 | 3 | import "sync" 4 | 5 | // ScanIterator is used to incrementally iterate over a collection of elements. 6 | // It's safe for concurrent use by multiple goroutines. 7 | type ScanIterator struct { 8 | mu sync.Mutex // protects Scanner and pos 9 | cmd *ScanCmd 10 | pos int 11 | } 12 | 13 | // Err returns the last iterator error, if any. 14 | func (it *ScanIterator) Err() error { 15 | it.mu.Lock() 16 | err := it.cmd.Err() 17 | it.mu.Unlock() 18 | return err 19 | } 20 | 21 | // Next advances the cursor and returns true if more values can be read. 22 | func (it *ScanIterator) Next() bool { 23 | it.mu.Lock() 24 | defer it.mu.Unlock() 25 | 26 | // Instantly return on errors. 27 | if it.cmd.Err() != nil { 28 | return false 29 | } 30 | 31 | // Advance cursor, check if we are still within range. 32 | if it.pos < len(it.cmd.page) { 33 | it.pos++ 34 | return true 35 | } 36 | 37 | for { 38 | // Return if there is no more data to fetch. 39 | if it.cmd.cursor == 0 { 40 | return false 41 | } 42 | 43 | // Fetch next page. 44 | if it.cmd._args[0] == "scan" { 45 | it.cmd._args[1] = it.cmd.cursor 46 | } else { 47 | it.cmd._args[2] = it.cmd.cursor 48 | } 49 | 50 | err := it.cmd.process(it.cmd) 51 | if err != nil { 52 | return false 53 | } 54 | 55 | it.pos = 1 56 | 57 | // Redis can occasionally return empty page. 58 | if len(it.cmd.page) > 0 { 59 | return true 60 | } 61 | } 62 | } 63 | 64 | // Val returns the key/field at the current cursor position. 65 | func (it *ScanIterator) Val() string { 66 | var v string 67 | it.mu.Lock() 68 | if it.cmd.Err() == nil && it.pos > 0 && it.pos <= len(it.cmd.page) { 69 | v = it.cmd.page[it.pos-1] 70 | } 71 | it.mu.Unlock() 72 | return v 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/sessions/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of gorilla/sessions authors for copyright purposes. 2 | # 3 | # Please keep the list sorted. 4 | 5 | Ahmadreza Zibaei 6 | Anton Lindström 7 | Brian Jones 8 | Collin Stedman 9 | Deniz Eren 10 | Dmitry Chestnykh 11 | Dustin Oprea 12 | Egon Elbre 13 | enumappstore 14 | Geofrey Ernest 15 | Google LLC (https://opensource.google.com/) 16 | Jerry Saravia 17 | Jonathan Gillham 18 | Justin Clift 19 | Justin Hellings 20 | Kamil Kisiel 21 | Keiji Yoshida 22 | kliron 23 | Kshitij Saraogi 24 | Lauris BH 25 | Lukas Rist 26 | Mark Dain 27 | Matt Ho 28 | Matt Silverlock 29 | Mattias Wadman 30 | Michael Schuett 31 | Michael Stapelberg 32 | Mirco Zeiss 33 | moraes 34 | nvcnvn 35 | pappz 36 | Pontus Leitzler 37 | QuaSoft 38 | rcadena 39 | rodrigo moraes 40 | Shawn Smith 41 | Taylor Hurt 42 | Tortuoise 43 | Vitor De Mario 44 | -------------------------------------------------------------------------------- /vendor/github.com/json-iterator/go/reflect_dynamic.go: -------------------------------------------------------------------------------- 1 | package jsoniter 2 | 3 | import ( 4 | "github.com/modern-go/reflect2" 5 | "reflect" 6 | "unsafe" 7 | ) 8 | 9 | type dynamicEncoder struct { 10 | valType reflect2.Type 11 | } 12 | 13 | func (encoder *dynamicEncoder) Encode(ptr unsafe.Pointer, stream *Stream) { 14 | obj := encoder.valType.UnsafeIndirect(ptr) 15 | stream.WriteVal(obj) 16 | } 17 | 18 | func (encoder *dynamicEncoder) IsEmpty(ptr unsafe.Pointer) bool { 19 | return encoder.valType.UnsafeIndirect(ptr) == nil 20 | } 21 | 22 | type efaceDecoder struct { 23 | } 24 | 25 | func (decoder *efaceDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) { 26 | pObj := (*interface{})(ptr) 27 | obj := *pObj 28 | if obj == nil { 29 | *pObj = iter.Read() 30 | return 31 | } 32 | typ := reflect2.TypeOf(obj) 33 | if typ.Kind() != reflect.Ptr { 34 | *pObj = iter.Read() 35 | return 36 | } 37 | ptrType := typ.(*reflect2.UnsafePtrType) 38 | ptrElemType := ptrType.Elem() 39 | if iter.WhatIsNext() == NilValue { 40 | if ptrElemType.Kind() != reflect.Ptr { 41 | iter.skipFourBytes('n', 'u', 'l', 'l') 42 | *pObj = nil 43 | return 44 | } 45 | } 46 | if reflect2.IsNil(obj) { 47 | obj := ptrElemType.New() 48 | iter.ReadVal(obj) 49 | *pObj = obj 50 | return 51 | } 52 | iter.ReadVal(obj) 53 | } 54 | 55 | type ifaceDecoder struct { 56 | valType *reflect2.UnsafeIFaceType 57 | } 58 | 59 | func (decoder *ifaceDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) { 60 | if iter.ReadNil() { 61 | decoder.valType.UnsafeSet(ptr, decoder.valType.UnsafeNew()) 62 | return 63 | } 64 | obj := decoder.valType.UnsafeIndirect(ptr) 65 | if reflect2.IsNil(obj) { 66 | iter.ReportError("decode non empty interface", "can not unmarshal into nil") 67 | return 68 | } 69 | iter.ReadVal(obj) 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/pilu/config/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package config parses files with format similar to INI files. 3 | Comments starts with '#' or ';'. 4 | Each line define a key and a value, both strings. Between them you can use =, : or just spaces. 5 | 6 | foo: bar 7 | foo = bar 8 | foo bar 9 | 10 | In the above example the key is 'key' and the value is 'value with spaces'. 11 | You can also specify sections: 12 | 13 | [section_1] 14 | foo 1 15 | 16 | [section_2] 17 | foo 2 18 | 19 | All top level options are grouped in a main section. The main section name is passed to the ParseFile function. 20 | 21 | sections, err := config.ParseFile("test.conf", mainSectionName) 22 | 23 | ParseFile returns a map where keys are section names, and values are options. 24 | Options are simple map with string for both keys and values. 25 | 26 | Example file: 27 | 28 | # comment 1 29 | # comment 2 30 | 31 | url http://example.com 32 | 33 | [development] 34 | db.host localhost 35 | db.username foo-dev 36 | db.password bar-dev 37 | 38 | [production] 39 | db.host example.com 40 | db.username foo-production 41 | db.password bar-production 42 | 43 | Usage example: 44 | 45 | package main 46 | 47 | import ( 48 | "fmt" 49 | "github.com/pilu/config" 50 | ) 51 | 52 | func main() { 53 | mainSectionName := "main" 54 | // Top level options are grouped in a section called "main" 55 | sections, err := config.ParseFile("test.conf", mainSectionName) 56 | if err != nil { 57 | panic(err) 58 | } 59 | 60 | for section, options := range sections { 61 | fmt.Printf("'%s': \n", section) 62 | for key, value := range options { 63 | fmt.Printf(" '%s' = '%s' \n", key, value) 64 | } 65 | } 66 | 67 | } 68 | */ 69 | package config 70 | -------------------------------------------------------------------------------- /vendor/github.com/gin-contrib/sessions/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gin-contrib/sessions 2 | 3 | require ( 4 | github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff 5 | github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737 6 | github.com/bradleypeabody/gorilla-sessions-memcache v0.0.0-20181103040241-659414f458e1 7 | github.com/davecgh/go-spew v1.1.1 // indirect 8 | github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7 // indirect 9 | github.com/gin-gonic/gin v1.3.0 10 | github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 11 | github.com/golang/protobuf v1.2.0 // indirect 12 | github.com/gomodule/redigo v2.0.0+incompatible 13 | github.com/gorilla/context v1.1.1 14 | github.com/gorilla/sessions v1.1.3 15 | github.com/json-iterator/go v1.1.5 // indirect 16 | github.com/kidstuff/mongostore v0.0.0-20181113001930-e650cd85ee4b 17 | github.com/kr/pretty v0.1.0 // indirect 18 | github.com/mattn/go-isatty v0.0.4 // indirect 19 | github.com/memcachier/mc v2.0.1+incompatible 20 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 21 | github.com/modern-go/reflect2 v1.0.1 // indirect 22 | github.com/pmezard/go-difflib v1.0.0 // indirect 23 | github.com/quasoft/memstore v0.0.0-20180925164028-84a050167438 24 | github.com/stretchr/testify v1.2.2 // indirect 25 | github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 // indirect 26 | golang.org/x/net v0.0.0-20181220203305-927f97764cc3 // indirect 27 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect 28 | golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb // indirect 29 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect 30 | gopkg.in/go-playground/assert.v1 v1.2.1 // indirect 31 | gopkg.in/go-playground/validator.v8 v8.18.2 // indirect 32 | gopkg.in/yaml.v2 v2.2.2 // indirect 33 | ) 34 | -------------------------------------------------------------------------------- /ERRORS.md: -------------------------------------------------------------------------------- 1 | # Error Code Documentation 2 | 3 | ## System Errors 4 | 5 | 1xxxx 为系统级错误。 6 | 7 | | Error Code | Error Message (en) | Error Message (zh) | 8 | | :----: | :----: | :----: | 9 | | 10001 | System error | 系统错误 | 10 | | 10002 | Service unavailable | 服务暂停 | 11 | | 10003 | Parameter error | 参数错误 | 12 | | 10004 | Parameter value invalid | 参数非法 | 13 | | 10005 | Missing required parameter | 缺少参数 | 14 | | 10006 | Resource unavailable | 资源不存在 | 15 | | 10007 | CSRF token mismatch | CSRF 认证失败 | 16 | | 10008 | This service is undergoing maintenance | 服务处于维护模式,无法提供服务 | 17 | 18 | ## Application Errors 19 | 20 | 2xxxx 为应用级错误。 21 | 22 | ### General Errors 23 | 24 | | Error Code | Error Message (en) | Error Message (zh) | 25 | | :----: | :----: | :----: | 26 | | 20000 | General error | 通用应用错误(以返回错误信息为准) | 27 | 28 | ### Upload Errors 29 | 30 | 201xx 为上传相关错误。 31 | 32 | ### Update Errors 33 | 34 | 202xx 为更新相关错误。 35 | 36 | | Error Code | Error Message (en) | Error Message (zh) | 37 | | :----: | :----: | :----: | 38 | | 20201 | Can't find user token | 无法找到 Token | 39 | 40 | ### Download Errors 41 | 42 | 203xx 为下载相关错误。 43 | 44 | | Error Code | Error Message (en) | Error Message (zh) | 45 | | :----: | :----: | :----: | 46 | | 20301 | Missing token in header | 请求头缺少 Token | 47 | | 20302 | Token used | Token 已被使用 | 48 | | 20303 | Token expired | Token 已过期 | 49 | | 20304 | Token revoked | Token 不合法 | 50 | | 20305 | Can't get the download link | 无法获取下载链接 | 51 | | 20306 | The retrieve code mismatch auth | 提取码无法对应auth | 52 | | 20307 | The retrieve code repeat | 提取码重复 | 53 | ### Delete Errors 54 | 55 | 204xx 为删除相关错误。 56 | 57 | ### Validate Errors 58 | 59 | 205xx 为认证相关错误。 60 | 61 | | Error Code | Error Message (en) | Error Message (zh) | 62 | | :----: | :----: | :----: | 63 | | 20501 | Password incorrect | 密码错误 | 64 | | 20502 | Password required | 需要密码 | 65 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/internal/error.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "io" 5 | "net" 6 | "strings" 7 | 8 | "github.com/go-redis/redis/internal/proto" 9 | ) 10 | 11 | func IsRetryableError(err error, retryTimeout bool) bool { 12 | if err == nil { 13 | return false 14 | } 15 | if err == io.EOF { 16 | return true 17 | } 18 | if netErr, ok := err.(net.Error); ok { 19 | if netErr.Timeout() { 20 | return retryTimeout 21 | } 22 | return true 23 | } 24 | s := err.Error() 25 | if s == "ERR max number of clients reached" { 26 | return true 27 | } 28 | if strings.HasPrefix(s, "LOADING ") { 29 | return true 30 | } 31 | if strings.HasPrefix(s, "READONLY ") { 32 | return true 33 | } 34 | if strings.HasPrefix(s, "CLUSTERDOWN ") { 35 | return true 36 | } 37 | return false 38 | } 39 | 40 | func IsRedisError(err error) bool { 41 | _, ok := err.(proto.RedisError) 42 | return ok 43 | } 44 | 45 | func IsBadConn(err error, allowTimeout bool) bool { 46 | if err == nil { 47 | return false 48 | } 49 | if IsRedisError(err) { 50 | return strings.HasPrefix(err.Error(), "READONLY ") 51 | } 52 | if allowTimeout { 53 | if netErr, ok := err.(net.Error); ok && netErr.Timeout() { 54 | return false 55 | } 56 | } 57 | return true 58 | } 59 | 60 | func IsMovedError(err error) (moved bool, ask bool, addr string) { 61 | if !IsRedisError(err) { 62 | return 63 | } 64 | 65 | s := err.Error() 66 | if strings.HasPrefix(s, "MOVED ") { 67 | moved = true 68 | } else if strings.HasPrefix(s, "ASK ") { 69 | ask = true 70 | } else { 71 | return 72 | } 73 | 74 | ind := strings.LastIndex(s, " ") 75 | if ind == -1 { 76 | return false, false, "" 77 | } 78 | addr = s[ind+1:] 79 | return 80 | } 81 | 82 | func IsLoadingError(err error) bool { 83 | return strings.HasPrefix(err.Error(), "LOADING ") 84 | } 85 | -------------------------------------------------------------------------------- /vendor/github.com/jinzhu/gorm/field.go: -------------------------------------------------------------------------------- 1 | package gorm 2 | 3 | import ( 4 | "database/sql" 5 | "database/sql/driver" 6 | "errors" 7 | "fmt" 8 | "reflect" 9 | ) 10 | 11 | // Field model field definition 12 | type Field struct { 13 | *StructField 14 | IsBlank bool 15 | Field reflect.Value 16 | } 17 | 18 | // Set set a value to the field 19 | func (field *Field) Set(value interface{}) (err error) { 20 | if !field.Field.IsValid() { 21 | return errors.New("field value not valid") 22 | } 23 | 24 | if !field.Field.CanAddr() { 25 | return ErrUnaddressable 26 | } 27 | 28 | reflectValue, ok := value.(reflect.Value) 29 | if !ok { 30 | reflectValue = reflect.ValueOf(value) 31 | } 32 | 33 | fieldValue := field.Field 34 | if reflectValue.IsValid() { 35 | if reflectValue.Type().ConvertibleTo(fieldValue.Type()) { 36 | fieldValue.Set(reflectValue.Convert(fieldValue.Type())) 37 | } else { 38 | if fieldValue.Kind() == reflect.Ptr { 39 | if fieldValue.IsNil() { 40 | fieldValue.Set(reflect.New(field.Struct.Type.Elem())) 41 | } 42 | fieldValue = fieldValue.Elem() 43 | } 44 | 45 | if reflectValue.Type().ConvertibleTo(fieldValue.Type()) { 46 | fieldValue.Set(reflectValue.Convert(fieldValue.Type())) 47 | } else if scanner, ok := fieldValue.Addr().Interface().(sql.Scanner); ok { 48 | v := reflectValue.Interface() 49 | if valuer, ok := v.(driver.Valuer); ok { 50 | if v, err = valuer.Value(); err == nil { 51 | err = scanner.Scan(v) 52 | } 53 | } else { 54 | err = scanner.Scan(v) 55 | } 56 | } else { 57 | err = fmt.Errorf("could not convert argument of field %s from %s to %s", field.Name, reflectValue.Type(), fieldValue.Type()) 58 | } 59 | } 60 | } else { 61 | field.Field.Set(reflect.Zero(field.Field.Type())) 62 | } 63 | 64 | field.IsBlank = isBlank(field.Field) 65 | return err 66 | } 67 | -------------------------------------------------------------------------------- /vendor/github.com/ugorji/go/codec/fast-path.not.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build notfastpath 5 | 6 | package codec 7 | 8 | import "reflect" 9 | 10 | const fastpathEnabled = false 11 | 12 | // The generated fast-path code is very large, and adds a few seconds to the build time. 13 | // This causes test execution, execution of small tools which use codec, etc 14 | // to take a long time. 15 | // 16 | // To mitigate, we now support the notfastpath tag. 17 | // This tag disables fastpath during build, allowing for faster build, test execution, 18 | // short-program runs, etc. 19 | 20 | func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { return false } 21 | func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { return false } 22 | func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { return false } 23 | func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { return false } 24 | func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool { return false } 25 | 26 | type fastpathT struct{} 27 | type fastpathE struct { 28 | rtid uintptr 29 | rt reflect.Type 30 | encfn func(*Encoder, *codecFnInfo, reflect.Value) 31 | decfn func(*Decoder, *codecFnInfo, reflect.Value) 32 | } 33 | type fastpathA [0]fastpathE 34 | 35 | func (x fastpathA) index(rtid uintptr) int { return -1 } 36 | 37 | func (_ fastpathT) DecSliceUint8V(v []uint8, canChange bool, d *Decoder) (_ []uint8, changed bool) { 38 | fn := d.h.fn(uint8SliceTyp, true, true) 39 | d.kSlice(&fn.i, reflect.ValueOf(&v).Elem()) 40 | return v, true 41 | } 42 | 43 | var fastpathAV fastpathA 44 | var fastpathTV fastpathT 45 | 46 | // ---- 47 | type TestMammoth2Wrapper struct{} // to allow testMammoth work in notfastpath mode 48 | -------------------------------------------------------------------------------- /vendor/github.com/json-iterator/go/reflect_json_raw_message.go: -------------------------------------------------------------------------------- 1 | package jsoniter 2 | 3 | import ( 4 | "encoding/json" 5 | "github.com/modern-go/reflect2" 6 | "unsafe" 7 | ) 8 | 9 | var jsonRawMessageType = reflect2.TypeOfPtr((*json.RawMessage)(nil)).Elem() 10 | var jsoniterRawMessageType = reflect2.TypeOfPtr((*RawMessage)(nil)).Elem() 11 | 12 | func createEncoderOfJsonRawMessage(ctx *ctx, typ reflect2.Type) ValEncoder { 13 | if typ == jsonRawMessageType { 14 | return &jsonRawMessageCodec{} 15 | } 16 | if typ == jsoniterRawMessageType { 17 | return &jsoniterRawMessageCodec{} 18 | } 19 | return nil 20 | } 21 | 22 | func createDecoderOfJsonRawMessage(ctx *ctx, typ reflect2.Type) ValDecoder { 23 | if typ == jsonRawMessageType { 24 | return &jsonRawMessageCodec{} 25 | } 26 | if typ == jsoniterRawMessageType { 27 | return &jsoniterRawMessageCodec{} 28 | } 29 | return nil 30 | } 31 | 32 | type jsonRawMessageCodec struct { 33 | } 34 | 35 | func (codec *jsonRawMessageCodec) Decode(ptr unsafe.Pointer, iter *Iterator) { 36 | *((*json.RawMessage)(ptr)) = json.RawMessage(iter.SkipAndReturnBytes()) 37 | } 38 | 39 | func (codec *jsonRawMessageCodec) Encode(ptr unsafe.Pointer, stream *Stream) { 40 | stream.WriteRaw(string(*((*json.RawMessage)(ptr)))) 41 | } 42 | 43 | func (codec *jsonRawMessageCodec) IsEmpty(ptr unsafe.Pointer) bool { 44 | return len(*((*json.RawMessage)(ptr))) == 0 45 | } 46 | 47 | type jsoniterRawMessageCodec struct { 48 | } 49 | 50 | func (codec *jsoniterRawMessageCodec) Decode(ptr unsafe.Pointer, iter *Iterator) { 51 | *((*RawMessage)(ptr)) = RawMessage(iter.SkipAndReturnBytes()) 52 | } 53 | 54 | func (codec *jsoniterRawMessageCodec) Encode(ptr unsafe.Pointer, stream *Stream) { 55 | stream.WriteRaw(string(*((*RawMessage)(ptr)))) 56 | } 57 | 58 | func (codec *jsoniterRawMessageCodec) IsEmpty(ptr unsafe.Pointer) bool { 59 | return len(*((*RawMessage)(ptr))) == 0 60 | } 61 | -------------------------------------------------------------------------------- /scripts/prod-docker-compose.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Author: TripleZ 3 | # Date: 2019-03-11 4 | 5 | echo -e "\n Build, up, down, restart, pull, check logs for SafeU production docker clusters.\n" 6 | 7 | if [ "$1" == "up" ] 8 | then 9 | mkdir -p ../data 10 | sudo docker-compose -f ../deployments/prod-safeu/docker-compose.yml up -d 11 | 12 | elif [ "$1" == "down" ] 13 | then 14 | sudo docker-compose -f ../deployments/prod-safeu/docker-compose.yml down 15 | 16 | elif [ "$1" == "build" ] 17 | then 18 | sudo docker-compose -f ../deployments/prod-safeu/docker-compose.yml build --force-rm 19 | 20 | elif [ "$1" == "restart" ] 21 | then 22 | sudo docker-compose -f ../deployments/prod-safeu/docker-compose.yml restart -t 10 23 | 24 | elif [ "$1" == "pull" ] 25 | then 26 | sudo docker-compose -f ../deployments/prod-safeu/docker-compose.yml pull 27 | 28 | elif [ "$1" == "logs" ] 29 | then 30 | echo -e " Follow log output? (y/n, default: n): \c" 31 | read isF 32 | echo "" 33 | if [ "$isF" == "y" ] || [ "$isF" == "Y" ] 34 | then 35 | sudo docker-compose -f ../deployments/prod-safeu/docker-compose.yml logs -f 36 | else 37 | sudo docker-compose -f ../deployments/prod-safeu/docker-compose.yml logs 38 | fi 39 | 40 | elif [ "$1" == "help" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ] 41 | then 42 | echo -e " Usage: 43 | ./prod-docker-compose.sh [COMMAND] 44 | ./prod-docker-compose.sh -h|--help 45 | 46 | Commands: 47 | build Build SafeU prod container images 48 | down Down SafeU prod containers 49 | help Show this help message 50 | logs View output from prod containers 51 | pull Pull SafeU prod container images 52 | restart Restart SafeU prod containers 53 | up Up SafeU prod containers 54 | " 55 | 56 | else 57 | echo -e " Cannot match the command \"$1\", please type \"help\" command for help." 58 | fi 59 | -------------------------------------------------------------------------------- /vendor/github.com/pilu/config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "os" 5 | "io" 6 | "bufio" 7 | "strings" 8 | "regexp" 9 | ) 10 | 11 | type Options map[string]string 12 | 13 | type Sections map[string]Options 14 | 15 | var commentSplitRegexp = regexp.MustCompile(`[#;]`) 16 | 17 | var keyValueSplitRegexp = regexp.MustCompile(`(\s*(:|=)\s*)|\s+`) 18 | 19 | func cleanLine(line string) string { 20 | chunks := commentSplitRegexp.Split(line, 2) 21 | return strings.TrimSpace(chunks[0]) 22 | } 23 | 24 | func parse(reader *bufio.Reader, mainSectionName string) (Sections, error) { 25 | sections := make(Sections) 26 | section := mainSectionName 27 | options := make(Options) 28 | 29 | for { 30 | line, err := reader.ReadString('\n') 31 | if err != nil && err == io.EOF { 32 | break 33 | } else if err != nil { 34 | return sections, err 35 | } 36 | 37 | line = cleanLine(line) 38 | 39 | if len(line) == 0 { 40 | continue 41 | } 42 | 43 | if line[0] == '[' && line[len(line) - 1] == ']' { 44 | sections[section] = options 45 | section = line[1:(len(line) - 1)] 46 | options = sections[section] // check if section already exists 47 | if options == nil { 48 | options = make(Options) 49 | } 50 | } else { 51 | values := keyValueSplitRegexp.Split(line, 2) 52 | key := values[0] 53 | value := "" 54 | if len(values) == 2 { 55 | value = values[1] 56 | } 57 | 58 | options[key] = value 59 | } 60 | } 61 | 62 | sections[section] = options 63 | 64 | return sections, nil 65 | } 66 | 67 | func ParseFile(path string, mainSectionName string) (Sections, error) { 68 | file, err := os.Open(path) 69 | if err != nil { 70 | return make(Sections), err 71 | } 72 | 73 | defer file.Close() 74 | 75 | reader := bufio.NewReader(file) 76 | 77 | return parse(reader, mainSectionName) 78 | } 79 | -------------------------------------------------------------------------------- /vendor/github.com/jinzhu/inflection/README.md: -------------------------------------------------------------------------------- 1 | # Inflection 2 | 3 | Inflection pluralizes and singularizes English nouns 4 | 5 | [![wercker status](https://app.wercker.com/status/f8c7432b097d1f4ce636879670be0930/s/master "wercker status")](https://app.wercker.com/project/byKey/f8c7432b097d1f4ce636879670be0930) 6 | 7 | ## Basic Usage 8 | 9 | ```go 10 | inflection.Plural("person") => "people" 11 | inflection.Plural("Person") => "People" 12 | inflection.Plural("PERSON") => "PEOPLE" 13 | inflection.Plural("bus") => "buses" 14 | inflection.Plural("BUS") => "BUSES" 15 | inflection.Plural("Bus") => "Buses" 16 | 17 | inflection.Singular("people") => "person" 18 | inflection.Singular("People") => "Person" 19 | inflection.Singular("PEOPLE") => "PERSON" 20 | inflection.Singular("buses") => "bus" 21 | inflection.Singular("BUSES") => "BUS" 22 | inflection.Singular("Buses") => "Bus" 23 | 24 | inflection.Plural("FancyPerson") => "FancyPeople" 25 | inflection.Singular("FancyPeople") => "FancyPerson" 26 | ``` 27 | 28 | ## Register Rules 29 | 30 | Standard rules are from Rails's ActiveSupport (https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflections.rb) 31 | 32 | If you want to register more rules, follow: 33 | 34 | ``` 35 | inflection.AddUncountable("fish") 36 | inflection.AddIrregular("person", "people") 37 | inflection.AddPlural("(bu)s$", "${1}ses") # "bus" => "buses" / "BUS" => "BUSES" / "Bus" => "Buses" 38 | inflection.AddSingular("(bus)(es)?$", "${1}") # "buses" => "bus" / "Buses" => "Bus" / "BUSES" => "BUS" 39 | ``` 40 | 41 | ## Contributing 42 | 43 | You can help to make the project better, check out [http://gorm.io/contribute.html](http://gorm.io/contribute.html) for things you can do. 44 | 45 | ## Author 46 | 47 | **jinzhu** 48 | 49 | * 50 | * 51 | * 52 | 53 | ## License 54 | 55 | Released under the [MIT License](http://www.opensource.org/licenses/MIT). 56 | -------------------------------------------------------------------------------- /conf/nginx/testapi.safeu.a2os.club: -------------------------------------------------------------------------------- 1 | # HTTP server 2 | server { 3 | listen 80 default_server; 4 | listen [::]:80 default_server; 5 | server_name _; 6 | # server_name testapi.safeu.a2os.club; 7 | # Test without redirection 8 | # return 301 https://$host$request_uri; 9 | 10 | location / { 11 | proxy_pass http://app_servers; 12 | proxy_redirect default; 13 | } 14 | } 15 | # HTTPS server 16 | # server { 17 | # #listen 80 default_server; 18 | # #listen [::]:80 default_server; 19 | 20 | # # SSL configuration 21 | # # 22 | # listen 443 ssl default_server; 23 | # listen [::]:443 ssl default_server; 24 | # # 25 | # # Note: You should disable gzip for SSL traffic. 26 | # # See: https://bugs.debian.org/773332 27 | # # 28 | # # Read up on ssl_ciphers to ensure a secure configuration. 29 | # # See: https://bugs.debian.org/765782 30 | # # 31 | # # Self signed certs generated by the ssl-cert package 32 | # # Don't use them in a production server! 33 | # # 34 | # # include snippets/snakeoil.conf; 35 | 36 | # # root /var/www/html; 37 | 38 | # # Add index.php to the list if you are using PHP 39 | # # index index.html index.htm index.nginx-debian.html; 40 | 41 | # server_name testapi.safeu.a2os.club; 42 | # ssl on; 43 | # ssl_certificate /opt/nginx/testapi.safeu.a2os.club/fullchain.pem; 44 | # ssl_certificate_key /opt/nginx/testapi.safeu.a2os.club/privkey.pem; 45 | 46 | # location / { 47 | # # First attempt to serve request as file, then 48 | # # as directory, then fall back to displaying a 404. 49 | # #try_files $uri $uri/ =404; 50 | # proxy_pass http://app_servers; 51 | # proxy_redirect default; 52 | # } 53 | # } -------------------------------------------------------------------------------- /scripts/staging-docker-compose.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Author: TripleZ 3 | # Date: 2019-04-30 4 | 5 | echo -e "\n Build, up, down, restart, pull, check logs for SafeU staging docker clusters.\n" 6 | 7 | if [ "$1" == "up" ] 8 | then 9 | mkdir -p ../data 10 | sudo docker-compose -f ../deployments/staging-safeu/docker-compose.yml up -d 11 | 12 | elif [ "$1" == "down" ] 13 | then 14 | sudo docker-compose -f ../deployments/staging-safeu/docker-compose.yml down 15 | 16 | elif [ "$1" == "build" ] 17 | then 18 | sudo docker-compose -f ../deployments/staging-safeu/docker-compose.yml build --force-rm 19 | 20 | elif [ "$1" == "restart" ] 21 | then 22 | sudo docker-compose -f ../deployments/staging-safeu/docker-compose.yml restart -t 10 23 | 24 | elif [ "$1" == "pull" ] 25 | then 26 | sudo docker-compose -f ../deployments/staging-safeu/docker-compose.yml pull 27 | 28 | elif [ "$1" == "logs" ] 29 | then 30 | echo -e " Follow log output? (y/n, default: n): \c" 31 | read isF 32 | echo "" 33 | if [ "$isF" == "y" ] || [ "$isF" == "Y" ] 34 | then 35 | sudo docker-compose -f ../deployments/staging-safeu/docker-compose.yml logs -f 36 | else 37 | sudo docker-compose -f ../deployments/staging-safeu/docker-compose.yml logs 38 | fi 39 | 40 | elif [ "$1" == "help" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ] 41 | then 42 | echo -e " Usage: 43 | ./staging-docker-compose.sh [COMMAND] 44 | ./staging-docker-compose.sh -h|--help 45 | 46 | Commands: 47 | build Build SafeU staging container images 48 | down Down SafeU staging containers 49 | help Show this help message 50 | logs View output from staging containers 51 | pull Pull SafeU staging container images 52 | restart Restart SafeU staging containers 53 | up Up SafeU staging containers 54 | " 55 | 56 | else 57 | echo -e " Cannot match the command \"$1\", please type \"help\" command for help." 58 | fi 59 | -------------------------------------------------------------------------------- /deployments/dev-safeu/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | # nginx: 4 | # image: nginx 5 | # volumes: 6 | # - ../../conf/nginx/nginx.dev.conf:/etc/nginx/nginx.conf 7 | # - ../../conf/nginx/testapi.safeu.a2os.club:/etc/nginx/sites-enabled/testapi.safeu.a2os.club 8 | # - /etc/letsencrypt/live/testapi.safeu.a2os.club:/opt/nginx/testapi.safeu.a2os.club/ 9 | # environment:res 10 | # - TZ=Asia/Shanghai 11 | # ports: 12 | # - "80:80" 13 | # networks: 14 | # - webnet 15 | # depends_on: 16 | # - web 17 | # restart: on-failure 18 | safeu: 19 | build: 20 | context: ../.. 21 | dockerfile: ././build/package/safeu-backend-dev/Dockerfile-compose 22 | volumes: 23 | - ../../log/web:/go/src/a2os/safeu-backend/log/ 24 | # - ../..:/go/src/a2os/safeu-backend/ 25 | environment: 26 | - TZ=Asia/Shanghai 27 | ports: 28 | - "9000:8080" 29 | networks: 30 | - safeu-app-net 31 | # depends_on: 32 | # - db 33 | # - safeu-redis 34 | restart: always 35 | 36 | # db: 37 | # environment: 38 | # - TZ=Asia/Shanghai 39 | # - MYSQL_ROOT_PASSWORD=safeu 40 | # - MYSQL_DATABASE=safeu 41 | ## image: mysql:5.7.23 42 | # image: mariadb:10.3 43 | # volumes: 44 | # - ../../data-dev/mariadb:/var/lib/mysql 45 | # - ../../conf/mariadb:/etc/mysql/conf.d 46 | ## ports: 47 | ## - "3306:3306" 48 | # networks: 49 | # - safeu-app-net 50 | # restart: on-failure 51 | 52 | # safeu-redis: 53 | # image: redis:5.0.3-alpine 54 | # environment: 55 | # - TZ=Asia/Shanghai 56 | # volumes: 57 | # - ../../conf/redis/redis.conf:/usr/local/etc/redis/redis.conf 58 | # - ../../data-dev/redis:/data # for redis persistent storage 59 | # entrypoint: redis-server /usr/local/etc/redis/redis.conf 60 | # ports: 61 | # - "6379:6379" 62 | # networks: 63 | # - safeu-app-net 64 | # restart: on-failure 65 | 66 | networks: 67 | safeu-app-net: 68 | -------------------------------------------------------------------------------- /vendor/github.com/gin-contrib/sse/README.md: -------------------------------------------------------------------------------- 1 | # Server-Sent Events 2 | 3 | [![GoDoc](https://godoc.org/github.com/gin-contrib/sse?status.svg)](https://godoc.org/github.com/gin-contrib/sse) 4 | [![Build Status](https://travis-ci.org/gin-contrib/sse.svg)](https://travis-ci.org/gin-contrib/sse) 5 | [![codecov](https://codecov.io/gh/gin-contrib/sse/branch/master/graph/badge.svg)](https://codecov.io/gh/gin-contrib/sse) 6 | [![Go Report Card](https://goreportcard.com/badge/github.com/gin-contrib/sse)](https://goreportcard.com/report/github.com/gin-contrib/sse) 7 | 8 | Server-sent events (SSE) is a technology where a browser receives automatic updates from a server via HTTP connection. The Server-Sent Events EventSource API is [standardized as part of HTML5[1] by the W3C](http://www.w3.org/TR/2009/WD-eventsource-20091029/). 9 | 10 | - [Read this great SSE introduction by the HTML5Rocks guys](http://www.html5rocks.com/en/tutorials/eventsource/basics/) 11 | - [Browser support](http://caniuse.com/#feat=eventsource) 12 | 13 | ## Sample code 14 | 15 | ```go 16 | import "github.com/gin-contrib/sse" 17 | 18 | func httpHandler(w http.ResponseWriter, req *http.Request) { 19 | // data can be a primitive like a string, an integer or a float 20 | sse.Encode(w, sse.Event{ 21 | Event: "message", 22 | Data: "some data\nmore data", 23 | }) 24 | 25 | // also a complex type, like a map, a struct or a slice 26 | sse.Encode(w, sse.Event{ 27 | Id: "124", 28 | Event: "message", 29 | Data: map[string]interface{}{ 30 | "user": "manu", 31 | "date": time.Now().Unix(), 32 | "content": "hi!", 33 | }, 34 | }) 35 | } 36 | ``` 37 | ``` 38 | event: message 39 | data: some data\\nmore data 40 | 41 | id: 124 42 | event: message 43 | data: {"content":"hi!","date":1431540810,"user":"manu"} 44 | 45 | ``` 46 | 47 | ## Content-Type 48 | 49 | ```go 50 | fmt.Println(sse.ContentType) 51 | ``` 52 | ``` 53 | text/event-stream 54 | ``` 55 | 56 | ## Decoding support 57 | 58 | There is a client-side implementation of SSE coming soon. 59 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/internal/once.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 The Camlistore Authors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package internal 18 | 19 | import ( 20 | "sync" 21 | "sync/atomic" 22 | ) 23 | 24 | // A Once will perform a successful action exactly once. 25 | // 26 | // Unlike a sync.Once, this Once's func returns an error 27 | // and is re-armed on failure. 28 | type Once struct { 29 | m sync.Mutex 30 | done uint32 31 | } 32 | 33 | // Do calls the function f if and only if Do has not been invoked 34 | // without error for this instance of Once. In other words, given 35 | // var once Once 36 | // if once.Do(f) is called multiple times, only the first call will 37 | // invoke f, even if f has a different value in each invocation unless 38 | // f returns an error. A new instance of Once is required for each 39 | // function to execute. 40 | // 41 | // Do is intended for initialization that must be run exactly once. Since f 42 | // is niladic, it may be necessary to use a function literal to capture the 43 | // arguments to a function to be invoked by Do: 44 | // err := config.once.Do(func() error { return config.init(filename) }) 45 | func (o *Once) Do(f func() error) error { 46 | if atomic.LoadUint32(&o.done) == 1 { 47 | return nil 48 | } 49 | // Slow-path. 50 | o.m.Lock() 51 | defer o.m.Unlock() 52 | var err error 53 | if o.done == 0 { 54 | err = f() 55 | if err == nil { 56 | atomic.StoreUint32(&o.done, 1) 57 | } 58 | } 59 | return err 60 | } 61 | -------------------------------------------------------------------------------- /vendor/github.com/pilu/fresh/runner/utils.go: -------------------------------------------------------------------------------- 1 | package runner 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | "strings" 7 | ) 8 | 9 | func initFolders() { 10 | runnerLog("InitFolders") 11 | path := tmpPath() 12 | runnerLog("mkdir %s", path) 13 | err := os.Mkdir(path, 0755) 14 | if err != nil { 15 | runnerLog(err.Error()) 16 | } 17 | } 18 | 19 | func isTmpDir(path string) bool { 20 | absolutePath, _ := filepath.Abs(path) 21 | absoluteTmpPath, _ := filepath.Abs(tmpPath()) 22 | 23 | return absolutePath == absoluteTmpPath 24 | } 25 | 26 | func isIgnoredFolder(path string) bool { 27 | paths := strings.Split(path, "/") 28 | if len(paths) <= 0 { 29 | return false 30 | } 31 | 32 | for _, e := range strings.Split(settings["ignored"], ",") { 33 | if strings.TrimSpace(e) == paths[0] { 34 | return true 35 | } 36 | } 37 | return false 38 | } 39 | 40 | func isWatchedFile(path string) bool { 41 | absolutePath, _ := filepath.Abs(path) 42 | absoluteTmpPath, _ := filepath.Abs(tmpPath()) 43 | 44 | if strings.HasPrefix(absolutePath, absoluteTmpPath) { 45 | return false 46 | } 47 | 48 | ext := filepath.Ext(path) 49 | 50 | for _, e := range strings.Split(settings["valid_ext"], ",") { 51 | if strings.TrimSpace(e) == ext { 52 | return true 53 | } 54 | } 55 | 56 | return false 57 | } 58 | 59 | func shouldRebuild(eventName string) bool { 60 | for _, e := range strings.Split(settings["no_rebuild_ext"], ",") { 61 | e = strings.TrimSpace(e) 62 | fileName := strings.Replace(strings.Split(eventName, ":")[0], `"`, "", -1) 63 | if strings.HasSuffix(fileName, e) { 64 | return false 65 | } 66 | } 67 | 68 | return true 69 | } 70 | 71 | func createBuildErrorsLog(message string) bool { 72 | file, err := os.Create(buildErrorsFilePath()) 73 | if err != nil { 74 | return false 75 | } 76 | 77 | _, err = file.WriteString(message) 78 | if err != nil { 79 | return false 80 | } 81 | 82 | return true 83 | } 84 | 85 | func removeBuildErrorsLog() error { 86 | err := os.Remove(buildErrorsFilePath()) 87 | 88 | return err 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/jinzhu/gorm/README.md: -------------------------------------------------------------------------------- 1 | # GORM 2 | 3 | The fantastic ORM library for Golang, aims to be developer friendly. 4 | 5 | [![go report card](https://goreportcard.com/badge/github.com/jinzhu/gorm "go report card")](https://goreportcard.com/report/github.com/jinzhu/gorm) 6 | [![wercker status](https://app.wercker.com/status/8596cace912c9947dd9c8542ecc8cb8b/s/master "wercker status")](https://app.wercker.com/project/byKey/8596cace912c9947dd9c8542ecc8cb8b) 7 | [![Join the chat at https://gitter.im/jinzhu/gorm](https://img.shields.io/gitter/room/jinzhu/gorm.svg)](https://gitter.im/jinzhu/gorm?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 8 | [![Open Collective Backer](https://opencollective.com/gorm/tiers/backer/badge.svg?label=backer&color=brightgreen "Open Collective Backer")](https://opencollective.com/gorm) 9 | [![Open Collective Sponsor](https://opencollective.com/gorm/tiers/sponsor/badge.svg?label=sponsor&color=brightgreen "Open Collective Sponsor")](https://opencollective.com/gorm) 10 | [![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT) 11 | [![GoDoc](https://godoc.org/github.com/jinzhu/gorm?status.svg)](https://godoc.org/github.com/jinzhu/gorm) 12 | 13 | ## Overview 14 | 15 | * Full-Featured ORM (almost) 16 | * Associations (Has One, Has Many, Belongs To, Many To Many, Polymorphism) 17 | * Hooks (Before/After Create/Save/Update/Delete/Find) 18 | * Preloading (eager loading) 19 | * Transactions 20 | * Composite Primary Key 21 | * SQL Builder 22 | * Auto Migrations 23 | * Logger 24 | * Extendable, write Plugins based on GORM callbacks 25 | * Every feature comes with tests 26 | * Developer Friendly 27 | 28 | ## Getting Started 29 | 30 | * GORM Guides [http://gorm.io](http://gorm.io) 31 | 32 | ## Contributing 33 | 34 | [You can help to deliver a better GORM, check out things you can do](http://gorm.io/contribute.html) 35 | 36 | ## License 37 | 38 | © Jinzhu, 2013~time.Now 39 | 40 | Released under the [MIT License](https://github.com/jinzhu/gorm/blob/master/License) 41 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/sessions/lex.go: -------------------------------------------------------------------------------- 1 | // This file contains code adapted from the Go standard library 2 | // https://github.com/golang/go/blob/39ad0fd0789872f9469167be7fe9578625ff246e/src/net/http/lex.go 3 | 4 | package sessions 5 | 6 | import "strings" 7 | 8 | var isTokenTable = [127]bool{ 9 | '!': true, 10 | '#': true, 11 | '$': true, 12 | '%': true, 13 | '&': true, 14 | '\'': true, 15 | '*': true, 16 | '+': true, 17 | '-': true, 18 | '.': true, 19 | '0': true, 20 | '1': true, 21 | '2': true, 22 | '3': true, 23 | '4': true, 24 | '5': true, 25 | '6': true, 26 | '7': true, 27 | '8': true, 28 | '9': true, 29 | 'A': true, 30 | 'B': true, 31 | 'C': true, 32 | 'D': true, 33 | 'E': true, 34 | 'F': true, 35 | 'G': true, 36 | 'H': true, 37 | 'I': true, 38 | 'J': true, 39 | 'K': true, 40 | 'L': true, 41 | 'M': true, 42 | 'N': true, 43 | 'O': true, 44 | 'P': true, 45 | 'Q': true, 46 | 'R': true, 47 | 'S': true, 48 | 'T': true, 49 | 'U': true, 50 | 'W': true, 51 | 'V': true, 52 | 'X': true, 53 | 'Y': true, 54 | 'Z': true, 55 | '^': true, 56 | '_': true, 57 | '`': true, 58 | 'a': true, 59 | 'b': true, 60 | 'c': true, 61 | 'd': true, 62 | 'e': true, 63 | 'f': true, 64 | 'g': true, 65 | 'h': true, 66 | 'i': true, 67 | 'j': true, 68 | 'k': true, 69 | 'l': true, 70 | 'm': true, 71 | 'n': true, 72 | 'o': true, 73 | 'p': true, 74 | 'q': true, 75 | 'r': true, 76 | 's': true, 77 | 't': true, 78 | 'u': true, 79 | 'v': true, 80 | 'w': true, 81 | 'x': true, 82 | 'y': true, 83 | 'z': true, 84 | '|': true, 85 | '~': true, 86 | } 87 | 88 | func isToken(r rune) bool { 89 | i := int(r) 90 | return i < len(isTokenTable) && isTokenTable[i] 91 | } 92 | 93 | func isNotToken(r rune) bool { 94 | return !isToken(r) 95 | } 96 | 97 | func isCookieNameValid(raw string) bool { 98 | if raw == "" { 99 | return false 100 | } 101 | return strings.IndexFunc(raw, isNotToken) < 0 102 | } 103 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/html.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. 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 render 6 | 7 | import ( 8 | "html/template" 9 | "net/http" 10 | ) 11 | 12 | type Delims struct { 13 | Left string 14 | Right string 15 | } 16 | 17 | type HTMLRender interface { 18 | Instance(string, interface{}) Render 19 | } 20 | 21 | type HTMLProduction struct { 22 | Template *template.Template 23 | Delims Delims 24 | } 25 | 26 | type HTMLDebug struct { 27 | Files []string 28 | Glob string 29 | Delims Delims 30 | FuncMap template.FuncMap 31 | } 32 | 33 | type HTML struct { 34 | Template *template.Template 35 | Name string 36 | Data interface{} 37 | } 38 | 39 | var htmlContentType = []string{"text/html; charset=utf-8"} 40 | 41 | func (r HTMLProduction) Instance(name string, data interface{}) Render { 42 | return HTML{ 43 | Template: r.Template, 44 | Name: name, 45 | Data: data, 46 | } 47 | } 48 | 49 | func (r HTMLDebug) Instance(name string, data interface{}) Render { 50 | return HTML{ 51 | Template: r.loadTemplate(), 52 | Name: name, 53 | Data: data, 54 | } 55 | } 56 | func (r HTMLDebug) loadTemplate() *template.Template { 57 | if r.FuncMap == nil { 58 | r.FuncMap = template.FuncMap{} 59 | } 60 | if len(r.Files) > 0 { 61 | return template.Must(template.New("").Delims(r.Delims.Left, r.Delims.Right).Funcs(r.FuncMap).ParseFiles(r.Files...)) 62 | } 63 | if r.Glob != "" { 64 | return template.Must(template.New("").Delims(r.Delims.Left, r.Delims.Right).Funcs(r.FuncMap).ParseGlob(r.Glob)) 65 | } 66 | panic("the HTML debug render was created without files or glob pattern") 67 | } 68 | 69 | func (r HTML) Render(w http.ResponseWriter) error { 70 | r.WriteContentType(w) 71 | 72 | if r.Name == "" { 73 | return r.Template.Execute(w, r.Data) 74 | } 75 | return r.Template.ExecuteTemplate(w, r.Name, r.Data) 76 | } 77 | 78 | func (r HTML) WriteContentType(w http.ResponseWriter) { 79 | writeContentType(w, htmlContentType) 80 | } 81 | -------------------------------------------------------------------------------- /scripts/dev-docker-compose.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Author: TripleZ 3 | # Date: 2019-03-11 4 | 5 | echo -e "\n Build, up, down, restart, pull, check logs for SafeU development docker clusters.\n" 6 | 7 | if [ "$1" == "up" ] 8 | then 9 | mkdir -p ../data-dev 10 | echo -e " Running dockers on daemon mode? (y/n, default: n): \c" 11 | read isD 12 | 13 | if [ "$isD" = "y" ]||[ "$isD" = "Y" ] 14 | then 15 | sudo docker-compose -f ../deployments/dev-safeu/docker-compose.yml up -d 16 | else 17 | sudo docker-compose -f ../deployments/dev-safeu/docker-compose.yml up 18 | fi 19 | elif [ "$1" == "down" ] 20 | then 21 | sudo docker-compose -f ../deployments/dev-safeu/docker-compose.yml down 22 | elif [ "$1" == "build" ] 23 | then 24 | sudo docker-compose -f ../deployments/dev-safeu/docker-compose.yml build --force-rm 25 | elif [ "$1" == "pull" ] 26 | then 27 | sudo docker-compose -f ../deployments/dev-safeu/docker-compose.yml pull 28 | elif [ "$1" == "restart" ] 29 | then 30 | sudo docker-compose -f ../deployments/dev-safeu/docker-compose.yml restart -t 10 31 | elif [ "$1" == "logs" ] 32 | then 33 | echo -e " Follow log output? (y/n, default: n): \c" 34 | read isF 35 | echo "" 36 | if [ "$isF" == "y" ] || [ "$isF" == "Y" ] 37 | then 38 | sudo docker-compose -f ../deployments/dev-safeu/docker-compose.yml logs -f 39 | else 40 | sudo docker-compose -f ../deployments/dev-safeu/docker-compose.yml logs 41 | fi 42 | elif [ "$1" == "help" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ] 43 | then 44 | echo -e " Usage: 45 | ./dev-docker-compose.sh [COMMAND] 46 | ./dev-docker-compose.sh -h|--help 47 | 48 | Commands: 49 | build Build SafeU dev container images 50 | down Down SafeU dev containers 51 | help Show this help message 52 | logs View output from dev containers 53 | pull Pull SafeU dev container images 54 | restart Restart SafeU dev containers 55 | up Up SafeU dev containers 56 | " 57 | else 58 | echo -e " Cannot match the command \"$1\", please type \"help\" command for help." 59 | fi 60 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/internal/pool/pool_sticky.go: -------------------------------------------------------------------------------- 1 | package pool 2 | 3 | import "sync" 4 | 5 | type StickyConnPool struct { 6 | pool *ConnPool 7 | reusable bool 8 | 9 | cn *Conn 10 | closed bool 11 | mu sync.Mutex 12 | } 13 | 14 | var _ Pooler = (*StickyConnPool)(nil) 15 | 16 | func NewStickyConnPool(pool *ConnPool, reusable bool) *StickyConnPool { 17 | return &StickyConnPool{ 18 | pool: pool, 19 | reusable: reusable, 20 | } 21 | } 22 | 23 | func (p *StickyConnPool) NewConn() (*Conn, error) { 24 | panic("not implemented") 25 | } 26 | 27 | func (p *StickyConnPool) CloseConn(*Conn) error { 28 | panic("not implemented") 29 | } 30 | 31 | func (p *StickyConnPool) Get() (*Conn, error) { 32 | p.mu.Lock() 33 | defer p.mu.Unlock() 34 | 35 | if p.closed { 36 | return nil, ErrClosed 37 | } 38 | if p.cn != nil { 39 | return p.cn, nil 40 | } 41 | 42 | cn, err := p.pool.Get() 43 | if err != nil { 44 | return nil, err 45 | } 46 | 47 | p.cn = cn 48 | return cn, nil 49 | } 50 | 51 | func (p *StickyConnPool) putUpstream() { 52 | p.pool.Put(p.cn) 53 | p.cn = nil 54 | } 55 | 56 | func (p *StickyConnPool) Put(cn *Conn) {} 57 | 58 | func (p *StickyConnPool) removeUpstream() { 59 | p.pool.Remove(p.cn) 60 | p.cn = nil 61 | } 62 | 63 | func (p *StickyConnPool) Remove(cn *Conn) { 64 | p.removeUpstream() 65 | } 66 | 67 | func (p *StickyConnPool) Len() int { 68 | p.mu.Lock() 69 | defer p.mu.Unlock() 70 | 71 | if p.cn == nil { 72 | return 0 73 | } 74 | return 1 75 | } 76 | 77 | func (p *StickyConnPool) IdleLen() int { 78 | p.mu.Lock() 79 | defer p.mu.Unlock() 80 | 81 | if p.cn == nil { 82 | return 1 83 | } 84 | return 0 85 | } 86 | 87 | func (p *StickyConnPool) Stats() *Stats { 88 | return nil 89 | } 90 | 91 | func (p *StickyConnPool) Close() error { 92 | p.mu.Lock() 93 | defer p.mu.Unlock() 94 | 95 | if p.closed { 96 | return ErrClosed 97 | } 98 | p.closed = true 99 | 100 | if p.cn != nil { 101 | if p.reusable { 102 | p.putUpstream() 103 | } else { 104 | p.removeUpstream() 105 | } 106 | } 107 | 108 | return nil 109 | } 110 | -------------------------------------------------------------------------------- /vendor/github.com/jinzhu/gorm/callback_delete.go: -------------------------------------------------------------------------------- 1 | package gorm 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | ) 7 | 8 | // Define callbacks for deleting 9 | func init() { 10 | DefaultCallback.Delete().Register("gorm:begin_transaction", beginTransactionCallback) 11 | DefaultCallback.Delete().Register("gorm:before_delete", beforeDeleteCallback) 12 | DefaultCallback.Delete().Register("gorm:delete", deleteCallback) 13 | DefaultCallback.Delete().Register("gorm:after_delete", afterDeleteCallback) 14 | DefaultCallback.Delete().Register("gorm:commit_or_rollback_transaction", commitOrRollbackTransactionCallback) 15 | } 16 | 17 | // beforeDeleteCallback will invoke `BeforeDelete` method before deleting 18 | func beforeDeleteCallback(scope *Scope) { 19 | if scope.DB().HasBlockGlobalUpdate() && !scope.hasConditions() { 20 | scope.Err(errors.New("Missing WHERE clause while deleting")) 21 | return 22 | } 23 | if !scope.HasError() { 24 | scope.CallMethod("BeforeDelete") 25 | } 26 | } 27 | 28 | // deleteCallback used to delete data from database or set deleted_at to current time (when using with soft delete) 29 | func deleteCallback(scope *Scope) { 30 | if !scope.HasError() { 31 | var extraOption string 32 | if str, ok := scope.Get("gorm:delete_option"); ok { 33 | extraOption = fmt.Sprint(str) 34 | } 35 | 36 | deletedAtField, hasDeletedAtField := scope.FieldByName("DeletedAt") 37 | 38 | if !scope.Search.Unscoped && hasDeletedAtField { 39 | scope.Raw(fmt.Sprintf( 40 | "UPDATE %v SET %v=%v%v%v", 41 | scope.QuotedTableName(), 42 | scope.Quote(deletedAtField.DBName), 43 | scope.AddToVars(NowFunc()), 44 | addExtraSpaceIfExist(scope.CombinedConditionSql()), 45 | addExtraSpaceIfExist(extraOption), 46 | )).Exec() 47 | } else { 48 | scope.Raw(fmt.Sprintf( 49 | "DELETE FROM %v%v%v", 50 | scope.QuotedTableName(), 51 | addExtraSpaceIfExist(scope.CombinedConditionSql()), 52 | addExtraSpaceIfExist(extraOption), 53 | )).Exec() 54 | } 55 | } 56 | } 57 | 58 | // afterDeleteCallback will invoke `AfterDelete` method after deleting 59 | func afterDeleteCallback(scope *Scope) { 60 | if !scope.HasError() { 61 | scope.CallMethod("AfterDelete") 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/internal/consistenthash/consistenthash.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Google Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package consistenthash provides an implementation of a ring hash. 18 | package consistenthash 19 | 20 | import ( 21 | "hash/crc32" 22 | "sort" 23 | "strconv" 24 | ) 25 | 26 | type Hash func(data []byte) uint32 27 | 28 | type Map struct { 29 | hash Hash 30 | replicas int 31 | keys []int // Sorted 32 | hashMap map[int]string 33 | } 34 | 35 | func New(replicas int, fn Hash) *Map { 36 | m := &Map{ 37 | replicas: replicas, 38 | hash: fn, 39 | hashMap: make(map[int]string), 40 | } 41 | if m.hash == nil { 42 | m.hash = crc32.ChecksumIEEE 43 | } 44 | return m 45 | } 46 | 47 | // Returns true if there are no items available. 48 | func (m *Map) IsEmpty() bool { 49 | return len(m.keys) == 0 50 | } 51 | 52 | // Adds some keys to the hash. 53 | func (m *Map) Add(keys ...string) { 54 | for _, key := range keys { 55 | for i := 0; i < m.replicas; i++ { 56 | hash := int(m.hash([]byte(strconv.Itoa(i) + key))) 57 | m.keys = append(m.keys, hash) 58 | m.hashMap[hash] = key 59 | } 60 | } 61 | sort.Ints(m.keys) 62 | } 63 | 64 | // Gets the closest item in the hash to the provided key. 65 | func (m *Map) Get(key string) string { 66 | if m.IsEmpty() { 67 | return "" 68 | } 69 | 70 | hash := int(m.hash([]byte(key))) 71 | 72 | // Binary search for appropriate replica. 73 | idx := sort.Search(len(m.keys), func(i int) bool { return m.keys[i] >= hash }) 74 | 75 | // Means we have cycled back to the first replica. 76 | if idx == len(m.keys) { 77 | idx = 0 78 | } 79 | 80 | return m.hashMap[m.keys[idx]] 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/go-redis/redis/internal/pool/conn.go: -------------------------------------------------------------------------------- 1 | package pool 2 | 3 | import ( 4 | "net" 5 | "sync/atomic" 6 | "time" 7 | 8 | "github.com/go-redis/redis/internal/proto" 9 | ) 10 | 11 | var noDeadline = time.Time{} 12 | 13 | type Conn struct { 14 | netConn net.Conn 15 | 16 | rd *proto.Reader 17 | rdLocked bool 18 | wr *proto.Writer 19 | 20 | InitedAt time.Time 21 | pooled bool 22 | usedAt atomic.Value 23 | } 24 | 25 | func NewConn(netConn net.Conn) *Conn { 26 | cn := &Conn{ 27 | netConn: netConn, 28 | } 29 | cn.rd = proto.NewReader(netConn) 30 | cn.wr = proto.NewWriter(netConn) 31 | cn.SetUsedAt(time.Now()) 32 | return cn 33 | } 34 | 35 | func (cn *Conn) UsedAt() time.Time { 36 | return cn.usedAt.Load().(time.Time) 37 | } 38 | 39 | func (cn *Conn) SetUsedAt(tm time.Time) { 40 | cn.usedAt.Store(tm) 41 | } 42 | 43 | func (cn *Conn) SetNetConn(netConn net.Conn) { 44 | cn.netConn = netConn 45 | cn.rd.Reset(netConn) 46 | cn.wr.Reset(netConn) 47 | } 48 | 49 | func (cn *Conn) setReadTimeout(timeout time.Duration) error { 50 | now := time.Now() 51 | cn.SetUsedAt(now) 52 | if timeout > 0 { 53 | return cn.netConn.SetReadDeadline(now.Add(timeout)) 54 | } 55 | return cn.netConn.SetReadDeadline(noDeadline) 56 | } 57 | 58 | func (cn *Conn) setWriteTimeout(timeout time.Duration) error { 59 | now := time.Now() 60 | cn.SetUsedAt(now) 61 | if timeout > 0 { 62 | return cn.netConn.SetWriteDeadline(now.Add(timeout)) 63 | } 64 | return cn.netConn.SetWriteDeadline(noDeadline) 65 | } 66 | 67 | func (cn *Conn) Write(b []byte) (int, error) { 68 | return cn.netConn.Write(b) 69 | } 70 | 71 | func (cn *Conn) RemoteAddr() net.Addr { 72 | return cn.netConn.RemoteAddr() 73 | } 74 | 75 | func (cn *Conn) WithReader(timeout time.Duration, fn func(rd *proto.Reader) error) error { 76 | _ = cn.setReadTimeout(timeout) 77 | return fn(cn.rd) 78 | } 79 | 80 | func (cn *Conn) WithWriter(timeout time.Duration, fn func(wr *proto.Writer) error) error { 81 | _ = cn.setWriteTimeout(timeout) 82 | 83 | firstErr := fn(cn.wr) 84 | err := cn.wr.Flush() 85 | if err != nil && firstErr == nil { 86 | firstErr = err 87 | } 88 | return firstErr 89 | } 90 | 91 | func (cn *Conn) Close() error { 92 | return cn.netConn.Close() 93 | } 94 | -------------------------------------------------------------------------------- /vendor/github.com/jinzhu/gorm/errors.go: -------------------------------------------------------------------------------- 1 | package gorm 2 | 3 | import ( 4 | "errors" 5 | "strings" 6 | ) 7 | 8 | var ( 9 | // ErrRecordNotFound returns a "record not found error". Occurs only when attempting to query the database with a struct; querying with a slice won't return this error 10 | ErrRecordNotFound = errors.New("record not found") 11 | // ErrInvalidSQL occurs when you attempt a query with invalid SQL 12 | ErrInvalidSQL = errors.New("invalid SQL") 13 | // ErrInvalidTransaction occurs when you are trying to `Commit` or `Rollback` 14 | ErrInvalidTransaction = errors.New("no valid transaction") 15 | // ErrCantStartTransaction can't start transaction when you are trying to start one with `Begin` 16 | ErrCantStartTransaction = errors.New("can't start transaction") 17 | // ErrUnaddressable unaddressable value 18 | ErrUnaddressable = errors.New("using unaddressable value") 19 | ) 20 | 21 | // Errors contains all happened errors 22 | type Errors []error 23 | 24 | // IsRecordNotFoundError returns true if error contains a RecordNotFound error 25 | func IsRecordNotFoundError(err error) bool { 26 | if errs, ok := err.(Errors); ok { 27 | for _, err := range errs { 28 | if err == ErrRecordNotFound { 29 | return true 30 | } 31 | } 32 | } 33 | return err == ErrRecordNotFound 34 | } 35 | 36 | // GetErrors gets all errors that have occurred and returns a slice of errors (Error type) 37 | func (errs Errors) GetErrors() []error { 38 | return errs 39 | } 40 | 41 | // Add adds an error to a given slice of errors 42 | func (errs Errors) Add(newErrors ...error) Errors { 43 | for _, err := range newErrors { 44 | if err == nil { 45 | continue 46 | } 47 | 48 | if errors, ok := err.(Errors); ok { 49 | errs = errs.Add(errors...) 50 | } else { 51 | ok = true 52 | for _, e := range errs { 53 | if err == e { 54 | ok = false 55 | } 56 | } 57 | if ok { 58 | errs = append(errs, err) 59 | } 60 | } 61 | } 62 | return errs 63 | } 64 | 65 | // Error takes a slice of all errors that have occurred and returns it as a formatted string 66 | func (errs Errors) Error() string { 67 | var errors = []string{} 68 | for _, e := range errs { 69 | errors = append(errors, e.Error()) 70 | } 71 | return strings.Join(errors, "; ") 72 | } 73 | --------------------------------------------------------------------------------