|
|
@ -25,59 +25,27 @@ declarations. Update your hecking browser.
|
|
|
|
|
|
|
|
|
|
|
|
** Backend
|
|
|
|
** Backend
|
|
|
|
*** Prerequisites
|
|
|
|
*** Prerequisites
|
|
|
|
- .NET Core 3.1
|
|
|
|
- I use SBCL
|
|
|
|
- MariaDB / MySQL
|
|
|
|
*** Dependancies
|
|
|
|
|
|
|
|
- hunchentoot
|
|
|
|
*** .NET dependancies
|
|
|
|
- [[https://github.com/C-xC-c/hunchenhelpers][hunchenhelpers]], my hunchentoot helper library
|
|
|
|
- Nito.AsyncEX
|
|
|
|
- clsql
|
|
|
|
- Newtonsoft.Json
|
|
|
|
- jonathan, the JSON encoder/decoder
|
|
|
|
- MySql.Data
|
|
|
|
- cl-ppcre
|
|
|
|
- Microsoft.AspNetCore.Mvc.NewtonsoftJson
|
|
|
|
|
|
|
|
- Microsoft.AspNetCore.StaticFiles
|
|
|
|
|
|
|
|
- Microsoft.AspNetCore.Razor
|
|
|
|
|
|
|
|
- Microsoft.EntityFrameworkCore.SqlServer
|
|
|
|
|
|
|
|
- Microsoft.EntityFrameworkCore.Tools
|
|
|
|
|
|
|
|
- Magick.NET-Q8-AnyCPU
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*** Setup
|
|
|
|
*** Setup
|
|
|
|
1) [[https://dotnet.microsoft.com/download/dotnet-core][Install .NET Core]]
|
|
|
|
1. clone the project
|
|
|
|
2) Clone and build the BantFlags solution.
|
|
|
|
2. Symlink src/ to your ~/quicklisp/local-projects
|
|
|
|
3) Create the database using [[https://github.com/C-xC-c/BantFlags/blob/master/Environment/database.sql][database.sql]].
|
|
|
|
3. Move ~src/config.example.org~ to ~src/config.org~ and change it
|
|
|
|
- *Change the password*.
|
|
|
|
to whatever your settings are.
|
|
|
|
4) configure ~BantFlags/appsettings.example.json~ with your connection
|
|
|
|
4. Type the following into your repl:
|
|
|
|
string and webroot (where you'll serve the flags from *without a
|
|
|
|
#+BEGIN_SRC lisp
|
|
|
|
trailing slash*) and rename it to ~appsettings.json~
|
|
|
|
(ql:quickload :bantflags)
|
|
|
|
- [[./BantFlags/appsettings.example.json][example appsettings.json]]
|
|
|
|
(bantflags:main)
|
|
|
|
- ASP.NET Core applications look for a folder called ~wwwroot~ in
|
|
|
|
#+END_SRC
|
|
|
|
the same directory as the application for static files. However
|
|
|
|
You will almost certainly have several issues building clsql, the
|
|
|
|
you can choose to logically seperate these by providing a vaild
|
|
|
|
database connector used. I've [[https://plum.moe/words/bludgeoning-clsql-and-mariadb.html][written a blog post]] on some of the
|
|
|
|
directory to ~webroot~.
|
|
|
|
issues I've encountered personally, but there's no guarantee it'll
|
|
|
|
- That is to say, if the bantflags application is in
|
|
|
|
work. Piece of shit.
|
|
|
|
~/var/www/bantflags/BantFlags.dll~, the program will look for
|
|
|
|
|
|
|
|
the folder ~/var/www/bantflags/wwwroot/~ to host static content,
|
|
|
|
|
|
|
|
or whatever directory is provided to ~wwwroot~.
|
|
|
|
|
|
|
|
5) If you're hosting on your GNU/Linux distribution of choice, Create a
|
|
|
|
|
|
|
|
folder called ~keys~ in the same directory as the bantflags
|
|
|
|
|
|
|
|
executable.
|
|
|
|
|
|
|
|
- E.G. ~/var/www/bantflags/keys/~
|
|
|
|
|
|
|
|
- This is because ASP.NET Core uses some cryptic bullshit anti
|
|
|
|
|
|
|
|
forgery token when processing HTML forms, and it's unable to
|
|
|
|
|
|
|
|
persistantly store the decryption keys in memory on
|
|
|
|
|
|
|
|
GNU/Linux. This directory will store said keys when you or
|
|
|
|
|
|
|
|
users upload flags to /upload. The path uses
|
|
|
|
|
|
|
|
~AppDomain.CurrentDomain.BaseDirectory~ internally,
|
|
|
|
|
|
|
|
I.E. wherever the program is.
|
|
|
|
|
|
|
|
6) Add flags to the backend by uploading them to the flag console (/Upload).
|
|
|
|
|
|
|
|
- Flags must be 16x11 pixels and under 15kb. Their names must not
|
|
|
|
|
|
|
|
exceed 100 characters and cannot contain either "||" or ",".
|
|
|
|
|
|
|
|
7) Configure your webserver of choice to forward requests to kestral
|
|
|
|
|
|
|
|
- [[https://github.com/C-xC-c/BantFlags/blob/master/Environment/nginx.conf][Example nginx config.]]
|
|
|
|
|
|
|
|
8) Run with ~dotnet BantFlags.dll~ or create a service to run it as a
|
|
|
|
|
|
|
|
daemon.
|
|
|
|
|
|
|
|
- [[https://github.com/C-xC-c/BantFlags/blob/master/Environment/bantflags.service][Example systemd service.]]
|
|
|
|
|
|
|
|
9) ???
|
|
|
|
|
|
|
|
10) profit.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*** Database
|
|
|
|
*** Database
|
|
|
|
Tables look like this:
|
|
|
|
Tables look like this:
|
|
|
|
|
|
|
|
|
|
|
@ -97,10 +65,9 @@ Tables look like this:
|
|
|
|
where ~post_nr~ and ~flag~ in *postflags* are the id fields in their
|
|
|
|
where ~post_nr~ and ~flag~ in *postflags* are the id fields in their
|
|
|
|
respective tables.
|
|
|
|
respective tables.
|
|
|
|
*** API
|
|
|
|
*** API
|
|
|
|
The backend exposes three endpoints for the userscript to get and post
|
|
|
|
The backend exposes three endpoints for the userscript to get and
|
|
|
|
flags. Flags themselves are hosted from the ~flags/~ directory. This
|
|
|
|
post flags. Flags themselves are hosted from ~flags/~ which is
|
|
|
|
will be whatever value you gave to ~webroot~ (or
|
|
|
|
~www-root/flags/~ from ~config.lisp~ on the filesystem
|
|
|
|
~/path/to/bantflags/wwwroot/~ if no value is provided) + ~flags/~.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| route | purpse |
|
|
|
|
| route | purpse |
|
|
|
|
|------------+--------------------------------------------|
|
|
|
|
|------------+--------------------------------------------|
|
|
|
@ -108,10 +75,9 @@ will be whatever value you gave to ~webroot~ (or
|
|
|
|
| /api/post | Add flags to the database |
|
|
|
|
| /api/post | Add flags to the database |
|
|
|
|
| /api/flags | List the flags we support |
|
|
|
|
| /api/flags | List the flags we support |
|
|
|
|
| /flags/* | The flag images |
|
|
|
|
| /flags/* | The flag images |
|
|
|
|
|
|
|
|
** Notes
|
|
|
|
** Backwards Compatibility
|
|
|
|
You will get an error like =Recursive lock attempt #<SB-THREAD:MUTEX
|
|
|
|
The API is 1:1 compatable with all previous versions of
|
|
|
|
"global-message-log-lock" owner: #<SB-THREAD:THREAD
|
|
|
|
bantflags. Further improvements are achieved by encoding a ~version~
|
|
|
|
"hunchentoot-worker-127.0.0.1:54454" RUNNING {1001DED5E3}>>.= if you
|
|
|
|
variable when poking endpoints which allows for breaking changes in
|
|
|
|
try and log to a file that doesn't exist / you don't have permissions
|
|
|
|
the script and backend while guaranteeing data can be parsed on both
|
|
|
|
to read/write.
|
|
|
|
ends. See [[https://github.com/C-xC-c/BantFlags/tree/master/Docs/][Docs/{endpoint}]] for changes and compatibility.
|
|
|
|
|
|
|
|