forked from justhyped/gocaptcha
/
models.go
241 lines (181 loc) · 5.22 KB
/
models.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
package gocaptcha
func (p *RecaptchaV2Payload) SetDefaultValues() {
if p.InitialWaitTime == 0 {
p.InitialWaitTime = 10
}
if p.PollInterval == 0 {
p.PollInterval = 5
}
if p.MaxRetries == 0 {
p.MaxRetries = 15
}
}
func (p *RecaptchaV3Payload) SetDefaultValues() {
if p.InitialWaitTime == 0 {
p.InitialWaitTime = 10
}
if p.PollInterval == 0 {
p.PollInterval = 5
}
if p.MaxRetries == 0 {
p.MaxRetries = 15
}
if p.MinScore != 0.3 && p.MinScore != 0.6 && p.MinScore != 0.9 {
p.MinScore = 0.3
}
}
func (p *HCaptchaPayload) SetDefaultValues() {
if p.InitialWaitTime == 0 {
p.InitialWaitTime = 10
}
if p.PollInterval == 0 {
p.PollInterval = 5
}
if p.MaxRetries == 0 {
p.MaxRetries = 15
}
}
func (p *ImageCaptchaPayload) SetDefaultValues() {
if p.InitialWaitTime == 0 {
p.InitialWaitTime = 5
}
if p.PollInterval == 0 {
p.PollInterval = 3
}
if p.MaxRetries == 0 {
p.MaxRetries = 15
}
}
func (p *ImageCaptchaPayload) CreateImageCaptchaResponse() *CaptchaResponse {
return &CaptchaResponse{
Service: p.ServiceName,
ServiceApiKey: p.ServiceApiKey,
Endpoint: p.CustomServiceUrl,
}
}
func (p *RecaptchaV2Payload) CreateRecaptchaResponse() *CaptchaResponse {
return &CaptchaResponse{
Service: p.ServiceName,
ServiceApiKey: p.ServiceApiKey,
Endpoint: p.CustomServiceUrl,
}
}
func (p *HCaptchaPayload) CreateHCaptchaResponse() *CaptchaResponse {
return &CaptchaResponse{
Service: p.ServiceName,
ServiceApiKey: p.ServiceApiKey,
Endpoint: p.CustomServiceUrl,
}
}
func (p *RecaptchaV3Payload) CreateRecaptchaResponse() *CaptchaResponse {
return &CaptchaResponse{
Service: p.ServiceName,
ServiceApiKey: p.ServiceApiKey,
Endpoint: p.CustomServiceUrl,
}
}
type RecaptchaV2Payload struct {
// This is the endpoint that has Recaptcha Protection
EndpointUrl string
// This is the Recaptcha Key
// Can be found on the Endpoint URL page
EndpointKey string
// The API key for your captcha service
ServiceApiKey string
// The name of the captcha service
// Can be AntiCaptcha, 2Captcha or CapMonster Cloud
ServiceName string
// Enable if endpoint has invisible Recaptcha V2
IsInvisibleCaptcha bool
// Set this in case you're using a custom solver like CapMonster (not cloud)
CustomServiceUrl string
// The time to wait before starting to poll result
InitialWaitTime int
// The time to wait between polling results
PollInterval int
// Max amount of poll attempts
MaxRetries int
// Enable if endpoint has enterprise Recaptcha V2
IsEnterpriseCaptcha bool
}
type RecaptchaV3Payload struct {
// This is the endpoint that has Recaptcha Protection
EndpointUrl string
// This is the Recaptcha Key
// Can be found on the Endpoint URL page
EndpointKey string
// The API key for your captcha service
ServiceApiKey string
// The name of the captcha service
// Can be AntiCaptcha, 2Captcha or CapMonster Cloud
ServiceName string
// The action name of the recaptcha, you can find it in source code of site
Action string
// Set this in case you're using a custom solver like CapMonster (not cloud)
CustomServiceUrl string
// Set to true if it's V3 Enterprise
IsEnterprise bool
// Defaults to 0.3, accepted values are 0.3, 0.6, 0.9
MinScore float32
// The time to wait before starting to poll result
InitialWaitTime int
// The time to wait between polling results
PollInterval int
// Max amount of poll attempts
MaxRetries int
}
type ImageCaptchaPayload struct {
// This is the base64 that represents the image captcha
Base64String string
// The API key for your captcha service
ServiceApiKey string
// The name of the captcha service
// Can be AntiCaptcha, 2Captcha or CapMonster Cloud
ServiceName string
// Set this in case you're using a custom solver like CapMonster (not cloud)
CustomServiceUrl string
// Set to true if captcha is case sensitive
CaseSensitive bool
// Set this if the human solver needs additional information
// about how to solve the captcha
InstructionsForSolver string
// The time to wait before starting to poll result
InitialWaitTime int
// The time to wait between polling results
PollInterval int
// Max amount of poll attempts
MaxRetries int
}
type HCaptchaPayload struct {
// This is the endpoint that has Recaptcha Protection
EndpointUrl string
// This is the HCaptcha Key
// Can be found on the Endpoint URL page
EndpointKey string
// The API key for your captcha service
ServiceApiKey string
// The name of the captcha service
// Can be AntiCaptcha, 2Captcha or CapMonster Cloud
ServiceName string
// Set this in case you're using a custom solver like CapMonster (not cloud)
CustomServiceUrl string
// The time to wait before starting to poll result
InitialWaitTime int
// The time to wait between polling results
PollInterval int
// Max amount of poll attempts
MaxRetries int
}
type CaptchaResponse struct {
// The task ID of the solved captcha
TaskId string
// The answer of the solved captcha
Solution string
// The service used for solving the captcha
// this is used when reporting a good/bad captcha
Service string
// The service endpoint, it's copied from CustomServiceUrl
Endpoint string
// The API key for the service that's used for solving
ServiceApiKey string
}