Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
)
go_binary(
name = "cmd",
embed = [":go_default_library"],
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = ["main.go"],
data = ["anti-fraud.toml"],
importpath = "go-common/app/service/openplatform/anti-fraud/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/openplatform/anti-fraud/conf:go_default_library",
"//app/service/openplatform/anti-fraud/server/http:go_default_library",
"//library/log:go_default_library",
"//library/net/trace:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,151 @@
# This is a TOML document. Boom.
version = "1.0.0"
user = "nobody"
dir = "./"
debug = false
[log]
dir = "/tmp/log/anti-fraud"
[db]
[db.antiFraud]
addr = "172.16.33.203:3306"
dsn = "root:123456@tcp(172.16.33.203:3306)/tickets?timeout=5s&readTimeout=30s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 5
queryTimeout = "1s"
execTimeout = "1s"
tranTimeout = "2s"
[db.antiFraud.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[db.payShield]
addr = "127.0.0.1:3306"
dsn = "root:123456@tcp(127.0.0.1:3306)/shield?timeout=5s&readTimeout=30s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 5
queryTimeout = "1s"
execTimeout = "1s"
tranTimeout = "2s"
[db.payShield.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[db.payShield1]
addr = "172.22.33.156:3306"
dsn = "pay:QaJvNP7FGxDjpMI3tcVXUusZ80w6gmbk@tcp(172.22.33.156:3306)/shield?timeout=5s&readTimeout=30s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 5
queryTimeout = "1s"
execTimeout = "1s"
tranTimeout = "2s"
[db.payShield1.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[redis]
name = "antifraud"
proto = "tcp"
addr = "172.16.33.203:9379"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "24h"
verifyCdTimes = "2h"
[httpClient]
[httpClient.read]
key = "7c7ac0db1aa05587"
secret = "9a6d62d93290c5f771ad381e9ca23f26"
dial = "1s"
timeout = "4s"
keepAlive = "60s"
timer = 1000
[httpClient.read.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[httpClient.write]
key = "7c7ac0db1aa05587"
secret = "9a6d62d93290c5f771ad381e9ca23f26"
dial = "1s"
timeout = "3s"
keepAlive = "60s"
timer = 1000
[httpClient.write.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[geetest]
#极验每小时拉起的总数 to do
count = 20
[limit]
Name = "ticket"
SaleTimeOut = 86400
#mid下单时间限制 to do
MIDCreateTimeOut = 3600
#mid最大下单次数 to do
MIDCreateMax = 10
#ip下单时间限制 to do
IPCreateTimeOut = 3600
#ip最大下单次数 to do
IPCreateMax = 20
#ip白名单
IPWhiteList = ["222.73.196.18"]
#ip修改时间间隔
IPChangeInterval = 2
[rule]
[rule.10001]
Name = "ticket"
SaleTimeOut = 86400
#mid下单时间限制 to do
MIDCreateTimeOut = 3600
#mid最大下单次数 to do
MIDCreateMax = 10
#ip下单时间限制 to do
IPCreateTimeOut = 3600
#ip最大下单次数 to do
IPCreateMax = 20
#ip白名单
IPWhiteList = ["222.73.196.18"]
#ip修改时间间隔
IPChangeInterval = 100
[rule.10002]
Name = "mall"
SaleTimeOut = 86400
#mid下单时间限制 to do
MIDCreateTimeOut = 3600
#mid最大下单次数 to do
MIDCreateMax = 10
#ip下单时间限制 to do
IPCreateTimeOut = 3600
#ip最大下单次数 to do
IPCreateMax = 20
#ip白名单
IPWhiteList = ["222.73.196.18"]
#ip修改时间间隔
IPChangeInterval = 2
[url]
shield = "http://10.23.144.107:8080/payplatform/shield/askasync"
[base]
shieldListTime = 8886400

View File

@@ -0,0 +1,47 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"go-common/app/service/openplatform/anti-fraud/conf"
"go-common/app/service/openplatform/anti-fraud/server/http"
"go-common/library/log"
"go-common/library/net/trace"
)
func main() {
flag.Parse()
if err := conf.Init(); err != nil {
panic(err)
}
log.Init(conf.Conf.Log)
defer log.Close()
trace.Init(nil)
defer trace.Close()
log.Info("anti_fraud start")
// http init
http.Init(conf.Conf)
// signal handler
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("anti-fraud get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGSTOP, syscall.SIGINT:
log.Info("anti-fraud exit")
return
case syscall.SIGHUP:
// TODO reload
default:
return
}
}
}