Skip to content

Commit 2b1c8c7

Browse files
authored
Update the gocaptcha configuration (#4)
1 parent 67e4241 commit 2b1c8c7

File tree

15 files changed

+62
-45
lines changed

15 files changed

+62
-45
lines changed

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
# Variables
44
BINARY_NAME=go-captcha-service
5-
VERSION?=1.0.1
5+
VERSION?=1.0.3
66
BUILD_DIR=build
7+
COMPRESSED_DIR=build/compressed
78
PLATFORMS=darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 linux/arm/v7 windows/amd64
89
DOCKER_IMAGE?=wenlng/go-captcha-service
910
GO=go
@@ -70,6 +71,15 @@ build-multi: proto
7071
CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch $(GO) build $(GOFLAGS) -o $$output ./cmd/go-captcha-service || exit 1; \
7172
done
7273

74+
.PHONY: build-compress
75+
build-compress:
76+
@mkdir -p $(COMPRESSED_DIR)
77+
@for file in $(BUILD_DIR)/*; do \
78+
if [ -f "$$file" ] && [[ $$(basename "$$file") != .* ]]; then \
79+
zip -j $(COMPRESSED_DIR)/$$(basename "$$file").zip "$$file"; \
80+
fi; \
81+
done
82+
7383
# Packaging Binaries
7484
.PHONY: package
7585
package: build-multi

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ The service uses two configuration files: `config.json` for service runtime para
753753
"version": "0.0.1",
754754
"language": "chinese",
755755
"master": {
756-
"image_size": { "width": 300, "height": 200 },
756+
"image_size": { "width": 300, "height": 220 },
757757
"range_length": { "min": 6, "max": 7 },
758758
"range_angles": [
759759
{ "min": 20, "max": 35 },
@@ -804,7 +804,7 @@ The service uses two configuration files: `config.json` for service runtime para
804804
"click-shape-default": {
805805
"version": "0.0.1",
806806
"master": {
807-
"image_size": { "width": 300, "height": 200 },
807+
"image_size": { "width": 300, "height": 220 },
808808
"range_length": { "min": 6, "max": 7 },
809809
"range_angles": [
810810
{ "min": 20, "max": 35 },
@@ -840,7 +840,7 @@ The service uses two configuration files: `config.json` for service runtime para
840840
"slide-default": {
841841
"version": "0.0.1",
842842
"master": {
843-
"image_size": { "width": 300, "height": 200 },
843+
"image_size": { "width": 300, "height": 220 },
844844
"image_alpha": 1
845845
},
846846
"thumb": {
@@ -858,7 +858,7 @@ The service uses two configuration files: `config.json` for service runtime para
858858
"drag-default": {
859859
"version": "0.0.1",
860860
"master": {
861-
"image_size": { "width": 300, "height": 200 },
861+
"image_size": { "width": 300, "height": 220 },
862862
"image_alpha": 1
863863
},
864864
"thumb": {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/sony/gobreaker v0.5.0
1313
github.com/stretchr/testify v1.9.0
1414
github.com/wenlng/go-captcha-assets v1.0.6
15-
github.com/wenlng/go-captcha/v2 v2.0.3
15+
github.com/wenlng/go-captcha/v2 v2.0.4
1616
github.com/wenlng/go-service-link v0.0.2
1717
go.etcd.io/etcd/client/v3 v3.5.21
1818
go.etcd.io/etcd/server/v3 v3.5.21

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,8 @@ github.com/wenlng/go-captcha-assets v1.0.6 h1:PSTTReE7QXsYdBnE/oZB91BllCZSvBKb4u
475475
github.com/wenlng/go-captcha-assets v1.0.6/go.mod h1:zinRACsdYcL/S6pHgI9Iv7FKTU41d00+43pNX+b9+MM=
476476
github.com/wenlng/go-captcha/v2 v2.0.3 h1:QTZ39/gVDisPSgvL9O2X2HbTuj5P/z8QsdGB/aayg9c=
477477
github.com/wenlng/go-captcha/v2 v2.0.3/go.mod h1:5hac1em3uXoyC5ipZ0xFv9umNM/waQvYAQdr0cx/h34=
478+
github.com/wenlng/go-captcha/v2 v2.0.4 h1:5cSUF36ZyA03qeDMjKmeXGpbYJMXEexZIYK3Vga3ME0=
479+
github.com/wenlng/go-captcha/v2 v2.0.4/go.mod h1:5hac1em3uXoyC5ipZ0xFv9umNM/waQvYAQdr0cx/h34=
478480
github.com/wenlng/go-service-link v0.0.2 h1:5nB/W1UD5EkH+JEtVA71tzBZX/FXZRyXHg8Ovo4Oggs=
479481
github.com/wenlng/go-service-link v0.0.2/go.mod h1:1d4570TMBbMPv/w0pwgjT7Ev6Ajxv2/u0UVL1mIh6Y0=
480482
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=

gocaptcha.dev.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"master": {
6464
"image_size": {
6565
"width": 300,
66-
"height": 200
66+
"height": 220
6767
},
6868
"range_length": {
6969
"min": 6,
@@ -158,7 +158,7 @@
158158
"master": {
159159
"image_size": {
160160
"width": 300,
161-
"height": 200
161+
"height": 220
162162
},
163163
"range_length": {
164164
"min": 6,
@@ -253,7 +253,7 @@
253253
"master": {
254254
"image_size": {
255255
"width": 300,
256-
"height": 200
256+
"height": 220
257257
},
258258
"range_length": {
259259
"min": 6,
@@ -348,7 +348,7 @@
348348
"master": {
349349
"image_size": {
350350
"width": 300,
351-
"height": 200
351+
"height": 220
352352
},
353353
"range_length": {
354354
"min": 6,
@@ -442,7 +442,7 @@
442442
"click-shape-default": {
443443
"version": "0.0.1",
444444
"master": {
445-
"image_size": { "width": 300, "height": 200 },
445+
"image_size": { "width": 300, "height": 220 },
446446
"range_length": { "min": 6, "max": 7 },
447447
"range_angles": [
448448
{ "min": 20, "max": 35 },
@@ -478,7 +478,7 @@
478478
"slide-default": {
479479
"version": "0.0.1",
480480
"master": {
481-
"image_size": { "width": 300, "height": 200 },
481+
"image_size": { "width": 300, "height": 220 },
482482
"image_alpha": 1
483483
},
484484
"thumb": {
@@ -496,7 +496,7 @@
496496
"drag-default": {
497497
"version": "0.0.1",
498498
"master": {
499-
"image_size": { "width": 300, "height": 200 },
499+
"image_size": { "width": 300, "height": 220 },
500500
"image_alpha": 1
501501
},
502502
"thumb": {

gocaptcha.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"master": {
4545
"image_size": {
4646
"width": 300,
47-
"height": 200
47+
"height": 220
4848
},
4949
"range_length": {
5050
"min": 6,
@@ -139,7 +139,7 @@
139139
"master": {
140140
"image_size": {
141141
"width": 300,
142-
"height": 200
142+
"height": 220
143143
},
144144
"range_length": {
145145
"min": 6,
@@ -234,7 +234,7 @@
234234
"master": {
235235
"image_size": {
236236
"width": 300,
237-
"height": 200
237+
"height": 220
238238
},
239239
"range_length": {
240240
"min": 6,
@@ -329,7 +329,7 @@
329329
"master": {
330330
"image_size": {
331331
"width": 300,
332-
"height": 200
332+
"height": 220
333333
},
334334
"range_length": {
335335
"min": 6,
@@ -423,7 +423,7 @@
423423
"click-shape-default": {
424424
"version": "0.0.1",
425425
"master": {
426-
"image_size": { "width": 300, "height": 200 },
426+
"image_size": { "width": 300, "height": 220 },
427427
"range_length": { "min": 6, "max": 7 },
428428
"range_angles": [
429429
{ "min": 20, "max": 35 },
@@ -459,7 +459,7 @@
459459
"slide-default": {
460460
"version": "0.0.1",
461461
"master": {
462-
"image_size": { "width": 300, "height": 200 },
462+
"image_size": { "width": 300, "height": 220 },
463463
"image_alpha": 1
464464
},
465465
"thumb": {
@@ -477,7 +477,7 @@
477477
"drag-default": {
478478
"version": "0.0.1",
479479
"master": {
480-
"image_size": { "width": 300, "height": 200 },
480+
"image_size": { "width": 300, "height": 220 },
481481
"image_alpha": 1
482482
},
483483
"thumb": {

gocaptcha.tpl.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"master": {
6464
"image_size": {
6565
"width": 300,
66-
"height": 200
66+
"height": 220
6767
},
6868
"range_length": {
6969
"min": 6,
@@ -158,7 +158,7 @@
158158
"master": {
159159
"image_size": {
160160
"width": 300,
161-
"height": 200
161+
"height": 220
162162
},
163163
"range_length": {
164164
"min": 6,
@@ -253,7 +253,7 @@
253253
"master": {
254254
"image_size": {
255255
"width": 300,
256-
"height": 200
256+
"height": 220
257257
},
258258
"range_length": {
259259
"min": 6,
@@ -348,7 +348,7 @@
348348
"master": {
349349
"image_size": {
350350
"width": 300,
351-
"height": 200
351+
"height": 220
352352
},
353353
"range_length": {
354354
"min": 6,
@@ -442,7 +442,7 @@
442442
"click-shape-default": {
443443
"version": "0.0.1",
444444
"master": {
445-
"image_size": { "width": 300, "height": 200 },
445+
"image_size": { "width": 300, "height": 220 },
446446
"range_length": { "min": 6, "max": 7 },
447447
"range_angles": [
448448
{ "min": 20, "max": 35 },
@@ -478,7 +478,7 @@
478478
"slide-default": {
479479
"version": "0.0.1",
480480
"master": {
481-
"image_size": { "width": 300, "height": 200 },
481+
"image_size": { "width": 300, "height": 220 },
482482
"image_alpha": 1
483483
},
484484
"thumb": {
@@ -496,7 +496,7 @@
496496
"drag-default": {
497497
"version": "0.0.1",
498498
"master": {
499-
"image_size": { "width": 300, "height": 200 },
499+
"image_size": { "width": 300, "height": 220 },
500500
"image_alpha": 1
501501
},
502502
"thumb": {

internal/app/app.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,12 @@ func (a *App) startHTTPServer(svcCtx *common.SvcContext, cfg *config.Config) err
388388
var middlewares = make([]middleware.HTTPMiddleware, 0)
389389

390390
// Enable cross-domain resource
391-
if cfg.EnableCors {
392-
middlewares = append(middlewares, nil, middleware.CORSMiddleware(a.logger))
393-
}
391+
//if cfg.EnableCors {
392+
// middlewares = append(middlewares, nil, middleware.CORSMiddleware(a.dynamicCfg, a.logger))
393+
//}
394394

395395
middlewares = append(middlewares,
396+
middleware.CORSMiddleware(a.dynamicCfg, a.logger),
396397
middleware.APIKeyMiddleware(a.dynamicCfg, a.logger),
397398
middleware.LoggingMiddleware(a.logger),
398399
middleware.RateLimitMiddleware(a.limiter, a.logger),

internal/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ func MergeWithFlags(config Config, flags map[string]interface{}) Config {
533533
config.LogLevel = v
534534
}
535535

536-
if v, ok := flags["enable-cors"].(bool); ok && !config.EnableCors {
536+
if v, ok := flags["enable-cors"].(bool); ok {
537537
config.EnableCors = v
538538
}
539539
return config

internal/logic/click.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,9 @@ func (cl *ClickCaptLogic) CheckData(ctx context.Context, key string, dots string
159159
dot := dct[i]
160160
j := i * 2
161161
k := i*2 + 1
162-
sx, _ := strconv.ParseInt(src[j], 10, 64)
163-
sy, _ := strconv.ParseInt(src[k], 10, 64)
164-
165-
ret = click.CheckPoint(sx, sy, int64(dot.X), int64(dot.Y), int64(dot.Width), int64(dot.Height), 0)
162+
sx, _ := strconv.Atoi(src[j])
163+
sy, _ := strconv.Atoi(src[k])
164+
ret = click.Validate(sx, sy, dot.X, dot.Y, dot.Width, dot.Height, 0)
166165
if !ret {
167166
break
168167
}

0 commit comments

Comments
 (0)