149675cd86
Fixed mutexes. Now program doesn't fall under high load.
...
Seems like an old expiry comparing didn't work as left thousands of expired captchas in a map, so it was replaced by a forgotten by me time.Since() function.
2022-06-27 02:48:55 +04:00
a3faf8b9c9
Made use of a new style name feature and implemented a dark style, and now by default light version is being rendered.
2022-06-27 01:30:28 +04:00
504a8d137f
A simple refactor of generateImage() rearranging method calls in for loops.
2022-06-27 01:25:28 +04:00
ffbc79ce4b
In README.md added style query parameter for image endpoint and its description.
2022-06-27 01:21:16 +04:00
96c13ec6b2
Added support for different styles for CAPTCHA.
2022-06-27 01:20:36 +04:00
0957102169
Removed reduntant cast to captcha.ID.
2022-06-27 01:13:25 +04:00
c92d02f4e4
Let instance actually use GetExpiry() method.
2022-06-27 01:10:52 +04:00
8f6ea671c6
Made use of mutex in a goroutine that cleans expired captchas.
2022-06-27 01:05:44 +04:00
b0d5f9d9d0
Embed sync.Mutex in CaptchaDB struct in order to directly call its methods.
2022-06-27 01:03:28 +04:00
b65f3be236
ID generating moved off to a separate function NewID().
2022-06-27 01:02:24 +04:00
6307433ea0
Removed instantiating of Answer field in NewDwellingCaptcha().
2022-06-27 00:44:42 +04:00
9ed5ad42e2
generateAnswer() function made into a private. And now being called by GetAnswer() method in Captcha.
2022-06-27 00:44:11 +04:00
10167c4e17
Added comments for ICaptcha interface.
2022-06-27 00:43:12 +04:00
28ceae169b
ID type moved to db.go file where it belongs.
2022-06-27 00:26:03 +04:00
508d44a512
In db.go GetExpireInterval() renamed to GetExpiry().
2022-06-26 23:59:19 +04:00
9e7f3a2728
When I moved implementation to pkg directory an error appeared that DwellingCaptcha doesn't implement generateImage() method. And these methods was copied here to resolve this problem. But, actual fix was implementing an empty generateImage() method for base Captcha struct.
2022-06-26 23:57:16 +04:00
8053952122
Captcha implementation was moved off to pkg directory to be able to be used as an external library.
2022-06-26 23:53:52 +04:00
a2f4ce30f5
Removed unneded dependency on github.com/pkg/errors.
2022-06-26 23:24:10 +04:00
96e8cf0c97
Methods Solve, GetAnswer, IsSolved, and Expiry could be implemented once for a base Captcha struct. But GetImage and generateImage methods should be implemented by all structs that compose with base Captcha struct.
2022-06-26 22:02:38 +04:00
9658bbd755
In db.go method GetExpiry() placed next to SetExpiry() method.
2022-06-26 21:28:22 +04:00
66d443183f
In README.md a little formatting change to highlight HTTP codes.
2022-06-26 21:03:11 +04:00
63e832c217
In README.md section Usage was added.
2022-06-26 21:01:47 +04:00
70195a666e
In ICaptcha inteface GenerateImage() method was modified into private.
2022-06-26 21:01:27 +04:00
1abd0da118
In Makefile -expire flag fixed to a new -expiry.
2022-06-26 21:00:34 +04:00
a23c80ae88
GenerateImage() method was changed to be private.
2022-06-26 21:00:06 +04:00
3ebfcb2c95
In handlers.go GetExpireInterval() changed to GetExpiry().
2022-06-26 20:54:15 +04:00
3251b68629
In instance.go GetExpireInterval() changed to GetExpiry(). And changed name of corresponding field of CaptchaDB to ExpireIn.
2022-06-26 20:53:48 +04:00
bb4b3bd1ba
Method Expire() changed to Expiry().
2022-06-26 20:52:29 +04:00
f7d55b9c44
In dwelling_captcha.go. Renamed ExpireDate() to ExpiryDate(). In NewDwellingCaptcha() argument expiration changed to expiry.
2022-06-26 20:51:04 +04:00
1dd070abd4
Refactor of db.go to change expiration and expire to expiry. ExpireInterval field renamed to ExpireIn.
2022-06-26 20:49:43 +04:00
2e3d41a628
Changed Expire() method in ICaptcha to Expiry().
...
ExpireDate() changed to ExpiryDate() and its argument expiration changed to expiry.
2022-06-26 20:47:25 +04:00
d04870ae40
-expire flag changed to a new -expiry in systemd unit.
2022-06-26 20:44:38 +04:00
74b8c2d96a
Refactor of main.go to correct terms.
2022-06-26 20:43:18 +04:00
be4050d1f5
Removed excessive variable n, and multiplying by time.Second.
2022-06-26 20:36:36 +04:00
0c1972461e
run-test target renamed to just run in Makefile.
2022-06-26 16:49:42 +04:00
3db89cde4f
Removed clean target from Makefile.
2022-06-26 16:49:23 +04:00
4121ba9ad3
A more sane variable names in Makefile.
2022-06-26 16:46:26 +04:00
4bff49fe2f
Added mention of 500 HTTP error code for image endpoint.
2022-06-26 15:47:15 +04:00
e30c3663d4
Removed passing of expiration time to HTTP handlers.
2022-06-26 15:46:49 +04:00
7a7c3107d8
Added GetExpireInterval() wrapper for CaptchaDB instance.
2022-06-26 15:46:23 +04:00
4af8d67299
Expiration time now being get from CaptchaDB.
2022-06-26 15:45:42 +04:00
c5d159531c
Added GetExpireInterval() method to DB.
2022-06-26 15:44:41 +04:00
f0ced332e8
This validity check is reduntant.
2022-06-26 14:55:05 +04:00
1130568e39
Actually, this check is reduntant, move defering to network type check.
2022-06-26 14:54:11 +04:00
e9dc53e542
Defer unix-socket remove only if a unix-socket actually being used.
2022-06-26 14:50:39 +04:00
3685907891
Fixed a typo in path to unix-socket.
2022-06-26 14:45:21 +04:00
21b2f24986
Initial commit with a fully working program, lel.
2022-06-24 23:09:46 +04:00