forked from hanguofeng/gocaptcha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigtypes.go
74 lines (63 loc) · 1.54 KB
/
configtypes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright 2013 hanguofeng. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package gocaptcha
import (
"time"
)
//CaptchaConfig ,the captcha config
type CaptchaConfig struct {
LifeTime time.Duration
CaseSensitive bool
ChangeTextOnRefresh bool
}
//FilterConfigGroup
type FilterConfigGroup struct {
data map[string]string
}
func (this *FilterConfigGroup) Init() {
this.data = map[string]string{}
}
func (this *FilterConfigGroup) GetItem(key string) (string, bool) {
val, ok := this.data[key]
return val, ok
}
func (this *FilterConfigGroup) SetItem(key string, val string) {
this.data[key] = val
}
type FilterConfig struct {
Filters []string
data map[string]*FilterConfigGroup
}
func (this *FilterConfig) Init() {
this.Filters = []string{}
this.data = map[string]*FilterConfigGroup{}
}
func (this *FilterConfig) GetGroup(key string) (FilterConfigGroup, bool) {
val, ok := this.data[key]
if !ok {
val = new(FilterConfigGroup)
}
return *val, ok
}
func (this *FilterConfig) SetGroup(key string, group *FilterConfigGroup) {
this.data[key] = group
}
//ImageConfig ,the image config
type ImageConfig struct {
Width int
Height int
FontSize float64
FontFiles []string
fontManager *FontManager
}
const STORE_ENGINE_BUILDIN = "buildin"
const STORE_ENGINE_MEMCACHE = "memcache"
//StoreConfig ,the store engine config
type StoreConfig struct {
CaptchaConfig
Engine string
Servers []string
GcProbability int
GcDivisor int
}