Note that this is mostly for personal use, so there’s no user/authentication control other than that of SSH. Also, most if not all commands here are run as root.
I might get tired of saying this (it’s just copy paste, basically)… but you will need the same prerequisites as before (check my website and mail entries), with the extras:
(Optional, if you want a “front-end”) A CNAME for “git” and (optionally) “www.git”, or some other name for your sub-domains.
An SSL certificate, if you’re following the other entries, add a git.conf and run certbot --nginx to extend the certificate.
Those two lines above will need to be run each time you want to add a new repository to your server (yeah, kinda lame… although there are options to “automate” this, I like it this way).
After that you can already push/pull to your repository. I have my repositories (locally) set up so I can push to more than one remote at the same time (my server, GitHub, GitLab, etc.); to do so, check this gist.
This is optionally since it’s only for the web application.
Install the cgit and fcgiwrap packages:
diff --git a/live/blog/a/hoy_toco_desarrollo_personaje.html b/live/blog/a/hoy_toco_desarrollo_personaje.html
index 2b1f9d6..e67976a 100644
--- a/live/blog/a/hoy_toco_desarrollo_personaje.html
+++ b/live/blog/a/hoy_toco_desarrollo_personaje.html
@@ -3,27 +3,26 @@
"
prefix="og: https://ogp.me/ns#">
-
-
+
Hoy me tocó desarrollo de personaje -- Luevano's Blog
-
-
-
+
+
+
-
-
+
+
-
+
-
+
diff --git a/live/blog/a/mail_server_with_postfix.html b/live/blog/a/mail_server_with_postfix.html
index 6df0765..c8acc43 100644
--- a/live/blog/a/mail_server_with_postfix.html
+++ b/live/blog/a/mail_server_with_postfix.html
@@ -3,27 +3,26 @@
"
prefix="og: https://ogp.me/ns#">
-
-
+
Create a mail server with Postfix, Dovecot, SpamAssassin and OpenDKIM -- Luevano's Blog
-
-
-
+
+
+
-
-
+
+
-
+
-
+
@@ -78,14 +77,14 @@
The entry is going to be long because it’s a tedious process. This is also based on Luke Smith’s script, but adapted to Arch Linux (his script works on debian-based distributions). This entry is mostly so I can record all the notes required while I’m in the process of installing/configuring the mail server on a new VPS of mine; also I’m going to be writing a script that does everything in one go (for Arch Linux), that will be hosted here.
This configuration works for local users (users that appear in /etc/passwd), and does not use any type of SQL Database. And note that most if not all commands executed here are run with root privileges.
You will need a CNAME for “mail” and (optionally) “www.mail”, or whatever you want to call the sub-domains (although the RFC 2181 states that it NEEDS to be an A record, fuck the police).
An SSL certificate. You can use the SSL certificate obtained following my last post using certbot (just create a mail.conf and run certbot --nginx again).
Ports 25, 587 (SMTP), 465 (SMTPS), 143 (IMAP) and 993 (IMAPS) open on the firewall.
OpenDKIM is needed so services like G**gle (we don’t mention that name here [[[this is a meme]]]) don’t throw the mail to the trash. DKIM stands for “DomainKeys Identified Mail”.
We should have a working mail server by now. Before continuing check your journal logs (journalctl -xe --unit={unit}, where {unit} could be spamassassin.service for example) to see if there was any error whatsoever and try to debug it, it should be a typo somewhere (the logs are generally really descriptive) because all the settings and steps detailed here just (literally just finished doing everything on a new server as of the writing of this text) worked (((it just werks on my machine))).
Now, to actually use the mail service: first of all, you need a normal account (don’t use root) that belongs to the mail group (gpasswd -a user group to add a user user to group group) and that has a password.
Next, to actually login into a mail app/program/whateveryouwanttocallit, you will use the following settings, at least for thunderdbird(I tested in windows default mail app and you don’t need a lot of settings):
diff --git a/live/blog/a/new_blogging_system.html b/live/blog/a/new_blogging_system.html
index add7b56..066f288 100644
--- a/live/blog/a/new_blogging_system.html
+++ b/live/blog/a/new_blogging_system.html
@@ -3,27 +3,26 @@
"
prefix="og: https://ogp.me/ns#">
-
-
+
I'm using a new blogging system -- Luevano's Blog
-
-
-
+
+
+
-
-
+
+
-
+
-
+
diff --git a/live/blog/a/password_manager_authenticator_setup.html b/live/blog/a/password_manager_authenticator_setup.html
index 3c83a59..afd0e45 100644
--- a/live/blog/a/password_manager_authenticator_setup.html
+++ b/live/blog/a/password_manager_authenticator_setup.html
@@ -3,27 +3,26 @@
"
prefix="og: https://ogp.me/ns#">
-
-
+
My setup for a password manager and MFA authenticator -- Luevano's Blog
-
-
-
+
+
+
-
-
+
+
-
+
-
+
diff --git a/live/blog/a/rewrote_pyssg_again.html b/live/blog/a/rewrote_pyssg_again.html
index faff8bb..481cb45 100644
--- a/live/blog/a/rewrote_pyssg_again.html
+++ b/live/blog/a/rewrote_pyssg_again.html
@@ -3,27 +3,26 @@
"
prefix="og: https://ogp.me/ns#">
-
-
+
Rewrote pyssg again -- Luevano's Blog
-
-
-
+
+
+
-
-
+
+
-
+
-
+
diff --git a/live/blog/a/tenia_esto_descuidado.html b/live/blog/a/tenia_esto_descuidado.html
index bfe8f3f..76fa1ed 100644
--- a/live/blog/a/tenia_esto_descuidado.html
+++ b/live/blog/a/tenia_esto_descuidado.html
@@ -3,27 +3,26 @@
"
prefix="og: https://ogp.me/ns#">
-
-
+
Tenia este pex algo descuidado -- Luevano's Blog
-
-
-
+
+
+
-
-
+
+
-
+
-
+
diff --git a/live/blog/a/volviendo_a_usar_la_pagina.html b/live/blog/a/volviendo_a_usar_la_pagina.html
index 1911902..8380991 100644
--- a/live/blog/a/volviendo_a_usar_la_pagina.html
+++ b/live/blog/a/volviendo_a_usar_la_pagina.html
@@ -3,27 +3,26 @@
"
prefix="og: https://ogp.me/ns#">
-
-
+
Volviendo a usar la página -- Luevano's Blog
-
-
-
+
+
+
-
-
+
+
-
+
-
+
diff --git a/live/blog/a/vpn_server_with_openvpn.html b/live/blog/a/vpn_server_with_openvpn.html
index 205caec..de80c45 100644
--- a/live/blog/a/vpn_server_with_openvpn.html
+++ b/live/blog/a/vpn_server_with_openvpn.html
@@ -3,27 +3,26 @@
"
prefix="og: https://ogp.me/ns#">
-
-
+
Create a VPN server with OpenVPN (IPv4) -- Luevano's Blog
-
-
-
+
+
+
-
-
+
+
-
+
-
+
@@ -79,13 +78,13 @@
I’ve been wanting to do this entry, but had no time to do it since I also have to set up the VPN service as well to make sure what I’m writing makes sense, today is the day.
This will be installed and working alongside the other stuff I’ve wrote about on other posts (see the server tag). All commands here are executes as root unless specified otherwise. Also, this is intended only for IPv4 (it’s not that hard to include IPv6, but meh).
Working server with root access, and with Ufw as the firewall.
Depending on what port you want to run the VPN on, the default 1194, or as a fallback on 443 (click here for more). I will do mine on port 1194 but it’s just a matter of changing 2 lines of configuration and one Ufw rule.
PKI stands for Public Key Infrastructure and basically it’s required for certificates, private keys and more. This is supposed to work between two servers and one client: a server in charge of creating, signing and verifying the certificates, a server with the OpenVPN service running and the client making the request.
This is supposed to work something like: 1) a client wants to use the VPN service, so it creates a requests and sends it to the signing server, 2) this server checks the requests and signs the request, returning the certificates to both the VPN service and the client and 3) the client can now connect to the VPN service using the signed certificate which the OpenVPN server knows about. In a nutshell, I’m no expert.
… but, to be honest, all of this is a hassle and (in my case) I want something simple to use and manage. So I’m gonna do all on one server and then just give away the configuration file for the clients, effectively generating files that anyone can run and will work, meaning that you need to be careful who you give this files (it also comes with a revoking mechanism, so no worries).
You might notice that I didn’t specify how to actually connect to our server. For that we need to do a few more steps. We actually need a configuration file similar to the server.conf file that we created.
The real way of doing this would be to run similar steps as the ones with easy-rsa locally, send them to the server, sign them, and retrieve them. Nah, we’ll just create all configuration files on the server as I was mentioning earlier.
Also, the client configuration file has to match the server one (to some degree), to make this easier you can create a client-common file in /etc/openvpn/server with the following content:
diff --git a/live/blog/a/website_with_nginx.html b/live/blog/a/website_with_nginx.html
index bf5d581..386b95d 100644
--- a/live/blog/a/website_with_nginx.html
+++ b/live/blog/a/website_with_nginx.html
@@ -3,27 +3,26 @@
"
prefix="og: https://ogp.me/ns#">
-
-
+
Create a website with Nginx and Certbot -- Luevano's Blog
-
-
-
+
+
+
-
-
+
+
-
+
-
+
@@ -78,7 +77,7 @@
These are general notes on how to setup a Nginx web server plus Certbot for SSL certificates, initially learned from Luke’s video and after some use and research I added more stuff to the mix. And, actually at the time of writing this entry, I’m configuring the web server again on a new VPS instance, so this is going to be fresh.
As a side note, (((i use arch btw))) so everything here es aimed at an Arch Linux distro, and I’m doing everything on a VPS. Also note that most if not all commands here are executed with root privileges.
Nginx is a web (HTTP) server and reverse proxy server.
You have two options: nginx and nginx-mainline. I prefer nginx-mainline because it’s the “up to date” package even though nginx is labeled to be the “stable” version. Install the package and enable/start the service:
The only “bad” (bloated) thing about Certbot, is that it uses python, but for me it doesn’t matter too much. You may want to look up another alternative if you prefer. Install the packages certbot and certbot-nginx:
pacman -S certbot certbot-nginx
diff --git a/live/blog/a/xmpp_server_with_prosody.html b/live/blog/a/xmpp_server_with_prosody.html
index 7f7b168..20418ca 100644
--- a/live/blog/a/xmpp_server_with_prosody.html
+++ b/live/blog/a/xmpp_server_with_prosody.html
@@ -3,27 +3,26 @@
"
prefix="og: https://ogp.me/ns#">
-
-
+
Create an XMPP server with Prosody compatible with Conversations and Movim -- Luevano's Blog
-
-
-
+
+
+
-
-
+
+
-
+
-
+
@@ -79,7 +78,7 @@
Recently I set up an XMPP server (and a Matrix one, too) for my personal use and for friends if they want one; made one for EL ELE EME for example. So, here are the notes on how I set up the server that is compatible with the Conversations app and the Movim social network. You can see my addresses in contact and the XMPP compliance/score of the server.
As with my other entries, this is under a server running Arch Linux, with the Nginx web server and Certbot certificates. And all commands here are executed as root (unless specified otherwise)
Same as with my other entries (website, mail and git) plus:
A and (optionally) AAA DNS records for:
@@ -100,7 +99,7 @@
Email addresses for admin, abuse, contact, security, etc. Or use your own email for all of them, doesn’t really matter much as long as you define them in the configuration and are valid, I have aliases so those emails are forwarded to me.
Allow ports 5000, 5222, 5269, 5280 and 5281 for Prosody and, 3478 and 5349 for Turnserver which are the defaults for coturn.
That’s basically all the configuration that needs Prosody itself, but we still have to configure Nginx and Coturn before starting/enabling the prosody service.
Since this is not an ordinary configuration file I’m going to describe this too. Your prosody.conf file should have the following location blocks under the main server block (the one that listens to HTTPS):
# HTTPS server block
server {
@@ -542,7 +541,7 @@ server {
Coturn is the implementation of TURN and STUN server, which in general is for (at least in the XMPP world) voice support and external service discovery.
The source code can be found in my GitHub here, it also contains the exported versions for HTML5, Windows and Linux (be aware that the sound might be too high and I’m too lazy to make it configurable, it was the last thing I added), or you could also go to the itch.io page I setup where it’s playable in the browser:
Since this is just pixel art, the importing settings for textures needs to be adjusted so the sprites don’t look blurry. Go to Project -> Project settings… -> Import defaults and on the drop down select Texture, untick everything and make sure Compress/Mode is set to Lossless.
It’s also a good idea to setup some config variables project-wide. To do so, go to Project -> Project settings… -> General, select Application/config and add a new property (there is a text box at the top of the project settings window) for game scale: application/config/game_scale for the type use float and then click on add; configure the new property to 3.0; On the same window, also add application/config/version as a string, and make it 1.0.0 (or whatever number you want).
I only used 3 actions (keybindings): jump, restart and toggle_debug (optional). To add custom keybindings (so that the Input.something() API can be used), go to Project -> Project settings… -> Input Map and on the text box write “jump” and click add, then it will be added to the list and it’s just a matter of clicking the + sign to add a “Physical key”, press any key you want to be used to jump and click ok. Do the same for the rest of the actions.
Finally, rename the physics layers so we don’t lose track of which layer is which. Go to Project -> Layer Names -> 2d Physics and change the first 5 layer names to (in order): “player”, “ground”, “pipe”, “ceiling” and “score”.
For the assets I found out about a pack that contains just what I need: flappy-bird-assets by MegaCrash; I just did some minor modifications on the naming of the files. For the font I used Silver, and for the sound the resources from FlappyBird-N64 (which seems to be taken from 101soundboards.com which the orignal copyright holder is .Gears anyways).
Create the necessary directories to hold the respective assets and it’s just a matter of dragging and dropping, I used directories: res://entities/actors/player/sprites/, res://fonts/, res://levels/world/background/sprites/, res://levels/world/ground/sprites/, res://levels/world/pipe/sprites/, res://sfx/. For the player sprites, the “FileSystem” window looks like this (entities/actor directories are really not necessary):
Now it’s time to actually create the game, by creating the basic scenes that will make up the game. The hardest part and the most confusing is going to be the TileMaps, so that goes first.
I’m using a scene called “WorldTiles” with a Node2D node as root called the same. With 2 different TileMap nodes as children named “GroundTileMap” and “PipeTileMap” (these are their own scene); yes 2 different TileMaps because we need 2 different physics colliders (In Godot 4.0 you can have a single TileMap with different physics colliders in it). Each node has its own script. It should look something like this:
Now it’s just a matter of repeating the same for the pipes (“PipeTileMap”), only difference is that when selecting the tiles you need to select 2 tiles, as the pipe is 2 tiles wide, or just set the Snap Options/Step to 32x16, for example, just keep the cell size to 16x16.
I added few default ground tiles to the scene, just for testing purposes but I left them there. These could be place programatically, but I was too lazy to change things. On the “WorldTiles” scene, while selecting the “GroundTileMap”, you can select the tiles you want to paint with, and left click in the grid to paint with the selected tile. Need to place tiles from (-8, 7) to (10, 7) as well as the tile below with the filler ground (the tile position/coordinates show at the bottom left, refer to the image below):
On a new scene called “Player” with a KinematicBody2D node named “Player” as the root of the scene, then for the children: AnimatedSprite as “Sprite”, CollisionShape2D as “Collision” (with a circle shape) and 3 AudioStreamPlayers for “JumpSound”, “DeadSound” and “HitSound”. Not sure if it’s a good practice to have the audio here, since I did that at the end, pretty lazy. Then, attach a script to the “Player” node and then it should look like this:
Finally, make sure the “Sprite” node has the AnimatedSprite/Animation is set to “bird_1” and that the “Collision” node is configured correctly for its size and position (I just have it as a radius of 7). As well as dropping the SFX files into the corresponding AudioStreamPlayer (into the AudioStreamPlayer/Stream property).
These are really simple scenes that don’t require much setup:
“CeilingDetector”: just an Area2D node with a CollisionShape2D in the form of a rectangle (CollisionShape2D/Shape/extents to (120, 10)), stretched horizontally so it fits the whole screen. CollisionObject2D/Collision/Layer set to bit 4 (ceiling) and CollisionObject2D/Collision/Mask set to bit 1 (player).
This is the actual “Game” scene that holds all the playable stuff, here we will drop in all the previous scenes; the root node is a Node2D and also has an attached script. Also need to add 2 additional AudioStreamPlayers for the “start” and “score” sounds, as well as a Sprite for the background (Sprite/Offset/Offset set to (0, 10)) and a Camera2D (Camera2D/Current set to true (checked)). It should look something like this:
We need some font “Resources” to style the Label fonts. Under the FileSystem window, right click on the fonts directory (create one if needed) and click on “New Resource…” and select DynamicFontData, save it in the “fonts” directory as “SilverDynamicFontData.tres” (“Silver” as it is the font I’m using) then double click the just created resource and set the DynamicFontData/Font Path to the actual “Silver.ttf” font (or whatever you want).
Then create a new resource and this time select DynamicFont, name it “SilverDynamicFont.tres”, then double click to edit and add the “SilverDynamicFontData.tres” to the DynamicFont/Font/Font Data property (and I personally toggled off the DynamicFont/Font/Antialiased property), now just set the DynamicFont/Settings/(Size, Outline Size, Outline Color) to 32, 1 and black, respectively (or any other values you want). It should look something like this:
This has a bunch of nested nodes, so I’ll try to be concise here. The root node is a CanvasLayer named “UI” with its own script attached, and for the children:
“MarginContainer”: MarginContainer with Control/Margin/(Left, Top) set to 10 and Control/Margin/(Right, Bottom) set to -10.
This is the final scene where we connect the Game and the UI. It’s made of a Node2D with it’s own script attached and an instance of “Game” and “UI” as it’s children.
This is a good time to set the default scene when we run the game by going to Project -> Project settings… -> General and in Application/Run set the Main Scene to the “Main.tscn” scene.
I’m going to keep this scripting part to the most basic code blocks, as it’s too much code, for a complete view you can head to the source code.
As of now, the game itself doesn’t do anything if we hit play. The first thing to do so we have something going on is to do the minimal player scripting.
The most basic code needed so the bird goes up and down is to just detect “jump” key presses and add a negative jump velocity so it goes up (y coordinate is reversed in godot…), we also check the velocity sign of the y coordinate to decide if the animation is playing or not.
Finally need to add the actual checks for when the player dies (like collision with ground or pipe) as well as a function that listens to a signal for when the player goes to the ceiling.
The code is pretty simple, we just need a way of detecting if we ran out of ground and send a signal, as well as sending as signal when we start detecting ground/pipes behind us (to remove it) because the world is being generated as we move. The most basic functions needed are:
We need to keep track of 3 “flags”: ground_was_colliding, ground_now_colliding and pipe_now_colliding (and their respective signals), which are going to be used to do the checks inside _physics_process. For example for checking for new ground: ground_now_colliding = _now_colliding(old_ground, ground_now_colliding, "ground_started_colliding").
This script is what handles the “GroundTileMap” as well as the “PipeTileMap” and just basically functions as a “Signal bus” connecting a bunch of signals from the “WorldDetector” with the TileMaps and just tracking how many pipes have been placed:
export(int, 2, 20, 2) var PIPE_SEP: int = 6
var tiles_since_last_pipe: int = PIPE_SEP - 1
@@ -376,7 +375,7 @@ func _on_WorldDetector_ground_started_colliding() -> void:
func _on_WorldDetector_pipe_started_colliding() -> void:
emit_signal("remove_pipe")
This is the node that actually places the ground tiles upong receiving a signal. In general, what you want is to keep track of the newest tile that you need to place (empty spot) as well as the last tile that is in the tilemap (technically the first one if you count from left to right). I was experimenting with enums so I used them to define the possible Ground tiles:
Where you might notice that the _initial_new_tile_x is 11, instead of 10, refer to Default ground tiles where we placed tiles from -8 to 10, so the next empty one is 11. These _place_new_ground and _remove_first_ground functions are called upon receiving the signal.
This is really similar to the “GroundTileMap” code, instead of defining an enum for the ground tiles, we define it for the pipe patterns (because each pipe is composed of multiple pipe tiles). If your pipe tile set looks like this (notice the index):
These functions are called when receiving the signal to place/remove pipes.
Before proceeding, we require a way to save/load data (for the high scores). We’re going to use the ConfigFile node that uses a custom version of the “ini” file format. Need to define where to save the data:
The game script it’s also like a “Signal bus” in the sense that it connects all its childs’ signals together, and also has the job of starting/stopping the _process and _physics_process methods from the childs as needed. First, we need to define the signals and and references to all child nodes:
signal game_started
signal game_over
@@ -586,7 +585,7 @@ func _on_ScoreDetector_body_entered(body: Node2D) -> void:
score_sound.play()
When the player dies, we set all processing to false, except for the player itself (so it can drop all the way to the ground). Also, when receiving a “scoring” signal, we manage the current score, as well as saving the new high score when applicable, note that we need to read the high_score at the beginning by calling SavedData.get_high_score(). This signal we emit will be received by the UI so it updates accordingly.
First thing is to get a reference to all the child Labels, an initial reference to the high score as well as the version defined in the project settings:
At this point the game should be fully playable (if any detail missing feel free to look into the source code linked at the beginning). Only thing missing is an icon for the game; I did one pretty quicly with the assets I had.
If you followed the directory structure I used, then only thing needed is to transform the icon to a native Windows ico format (if exporting to Windows, else ignore this part). For this you need ImageMagick or some other program that can transform png (or whatever file format you used for the icon) to ico. I used [Chocolatey][https://chocolatey.org/] to install imagemagick, then to convert the icon itself used: magick convert icon.png -define icon:auto-resize=256,128,64,48,32,16 icon.ico as detailed in Godot‘s Changing application icon for Windows.
You need to download the templates for exporting as detailed in Godot‘s Exporting projects. Basically you go to Editor -> Manage Export Templates… and download the latest one specific to your Godot version by clicking on “Download and Install”.
If exporting for Windows then you also need to download rcedit from here. Just place it wherever you want (I put it next to the Godot executable).
Then go to Project -> Export… and the Window should be empty, add a new template by clicking on “Add…” at the top and then select the template you want. I used HTML5, Windows Desktop and Linux/X11. Really the only thing you need to set is the “Export Path” for each template, which is te location of where the executable will be written to, and in the case of the Windows Desktop template you could also setup stuff like “Company Name”, “Product Name”, “File/Product Version”, etc..
Again, similar to the FlappyBird clone I developed, I’m using the directory structure I wrote about on Godot project structure with slight modifications to test things out. Also using similar Project settings as those from the FlappyBird clone like the pixel art texture imports, keybindings, layers, etc..
I’ve also setup GifMaker, with slight modifications as the AssetLib doesn’t install it correctly and contains unnecessry stuff: moved necessary files to the res://addons directory, deleted test scenes and files in general, and copied the license to the res://docs directory. Setting this up was a bit annoying because the tutorial it’s bad (with all due respect). I might do a separate entry just to explain how to set it up, because I couldn’t find it anywhere other than by inspecting some of the code/scenes.I ended up not leaving this enabled in the game as it lagged the game out, but it’s an option I’ll end up researching more.
This time I’m also going to be using an Event bus singleton (which I’m going to just call Event) as managing signals was pretty annoying on my last project; as well as a Global singleton for essential stuff so I don’t have to do as many cross references between nodes/scenes.
This is the most challenging part in my opinion as making all the body parts follow the head in a user defined path it’s kinda hard. I tried with like 4-5 options and the one I’m detailing here is the only one that worked as I wanted for me. This time the directory structure I’m using is the following:
The most basic thing is to move the head, this is what we have control of. Create a scene called Head.tscn and setup the basic KinematicBody2D with it’s own Sprite and CollisionShape2D (I used a small circle for the tip of the head), and set the Collision Layer/Mask accordingly, for now just layer = bit 1. And all we need to do, is keep moving the snake forwards and be able to rotate left or right. Created a new script called head.gd attached to the root (KinematicBody2D) and added:
extends KinematicBody2D
@@ -136,7 +135,7 @@ func _rotate_to(direction: int) -> void:
Snake - Basic movement (left and right controls)
-
To move other snake parts by following the snake head the only solution I found was to use the Path2D and PathFollow2D nodes. Path2D basically just handles the curve/path that PathFollow2D will use to move its child node; and I say “child node” in singular… as PathFollow2D can only handle one damn child, all the other ones will have weird transformations and/or rotations. So, the next thing to do is to setup a way to compute (and draw so we can validate) the snake’s path/curve.
Added the signal snake_path_new_point(coordinates) to the Event singleton and then add the following to head.gd:
var _time_elapsed: float = 0.0
@@ -173,7 +172,7 @@ func _on_Head_snake_path_new_point(coordinates: Vector2) -> void:
Snake - Basic movement with path
-
At this point the only thing to do is to add the corresponding next body parts and tail of the snake. To do so, we need a PathFollow2D to use the live-generating Path2D, the only caveat is that we need one of these per body part/tail (this took me hours to figure out, thanks documentation).
Create a new scene called Body.tscn with a PathFollow2D as its root and an Area2D as its child, then just add the necessary Sprite and CollisionShap2D for the Area2D, I’m using layer = bit 2 for its collision. Create a new script called generic_segment.gd with the following code:
And this can be attached to the Body‘s root node (PathFollow2D), no extra setup needed. Repeat the same steps for creating the Tail.tscn scene and when attaching the generic_segment.gd script just configure the Type parameter to tail in the GUI (by selecting the node with the script attached and editing in the Inspector).
Now it’s just a matter of handling when to add new body parts in the snake.gd script. For now I’ve only setup for adding body parts to fulfill the initial length of the snake (this doesn’t include the head or tail). The extra code needed is the following:
export(PackedScene) var BODY_SEGMENT_NP: PackedScene
export(PackedScene) var TAIL_SEGMENT_NP: PackedScene
@@ -269,13 +268,13 @@ func _add_segment_to_queue() -> void:
_snake.propagate_call("set_process_input", [on_off])
After a while of testing and developing, I noticed that sometimes the head “detaches” from the body when a lot of rotations happen (moving the snake left or right), because of how imprecise the Curve2D is. To do this I just send a signal (snake_rotated) whenever the snake rotates and make a small correction (in generic_segment.gd):
For now I just decided to setup a simple system to see everything works fine. The idea is to make some kind of generic food node/scene and a “food manager” to spawn them, for now in totally random locations. For this I added the following signals: food_placing_new_food(type), food_placed_new_food(type) and food_eaten(type).
First thing is creating the Food.tscn which is just an Area2D with its necessary children with an attached script called food.gd. The script is really simple:
class_name Food # needed to access Type enum outside of the script, this registers this script as a node
@@ -323,7 +322,7 @@ func _on_body_entered(body: Node) -> void:
Snake - Food basic interaction
-
It just happend that I saw a video to create random maps by using a method called random walks, this video was made by NAD LABS: Nuclear Throne Like Map Generation In Godot. It’s a pretty simple but powerful script, he provided the source code from which I based my random walker, just tweaked a few things and added others. Some of the maps than can be generated with this method (already aded some random sprites):
Where get_cells_around is just a function that gets the safe cells around the origin. And this get_valid_map_coords just returns used cells minus the safe cells, to place food. get_centered_world_position is so we can center the food in the tiles.
Some signals I used for the world gen: world_gen_walker_started(id), world_gen_walker_finished(id), world_gen_walker_died(id) and world_gen_spawn_walker_unit(location).
The last food algorithm doesn’t check anything related to the world, and thus the food could spawn in the walls and outside the map.
First thing is I generalized the food into a single script and added basic food and special food which inherit from base food. The most important stuff for the base food is to be able to set all necessary properties at first:
Other than that, there are some differences between placing normal and special food (specially the signal they send, and if an extra “special points” property is set). Some of the signals that I used that might be important: food_placing_new_food(type), food_placed_new_food(type, location) and food_eaten(type, location).
I got the idea of saving the current stats (points, max body segments, etc.) in a separate Stats class for easier load/save data. This option I went with didn’t work as I would liked it to work, as it was a pain in the ass to setup and each time a new property is added you have to manually setup the load/save helper functions… so not the best option. This option I used was json but saving a Node directly could work better or using resources (saving tres files).
It uses json as the file format, but I might end up changing this in the future to something else more reliable and easier to use (Stats class related issues).
For this I created a scoring mechanisms and just called it ScoreManager (score_manager.gd) which just basically listens to food_eaten signal and adds points accordingly to the current Stats object loaded. The main function is:
Then this sends a signal display_stats to activate UI elements that shows the progression.
Naturally, the saved Stats are loaded whenever needed. For example, for the Snake, we load the stats and setup any value needed from there (like a flag to know if any ability is enabled), and since we’re saving the new Stats at the end, then on restart we load the updated one.
I redesigned the snake code (the head, actually) to use the state machine pattern by following this guide which is definitely a great guide, straight to the point and easy to implement.
Other than what is shown in the guide, I implemented some important functions in the state_machine.gd script itself, to be used by each of the states as needed:
Where the important parts happen in the enter and exit functions. We need to change the Global.SNAKE_SPEED with the Global.SNAKE_DASH_SPEED on startand start the timer for how long should the dash last. And on the exit we reset the Global.SNAKE_SPEED back to normal. There is probably a better way of updating the Global.SNAKE_SPEED but this works just fine.
For the other ones is the same. Only difference with the jump_state.gd is that the collision from head to body is disabled, and no rotation is allowed (by not calling the rotate_on_input function).
I actually didn’t finish this game (as how I visualized it), but I got it in a playable state which is good. My big learning during this jam is the time management that it requires to plan and design a game. I lost a lot of time trying to implement some mechanics because I was facing many issues, because of my lack of practice (which was expected) as well as trying to blog and create the necessary sprites myself. Next time I should just get an asset pack and do something with it, as well as keeping the scope of my game shorter.
Again, similar to the FlappyBird clone I developed, I’m using the directory structure I wrote about on Godot project structure with slight modifications to test things out. Also using similar Project settings as those from the FlappyBird clone like the pixel art texture imports, keybindings, layers, etc..
I’ve also setup GifMaker, with slight modifications as the AssetLib doesn’t install it correctly and contains unnecessry stuff: moved necessary files to the res://addons directory, deleted test scenes and files in general, and copied the license to the res://docs directory. Setting this up was a bit annoying because the tutorial it’s bad (with all due respect). I might do a separate entry just to explain how to set it up, because I couldn’t find it anywhere other than by inspecting some of the code/scenes.I ended up not leaving this enabled in the game as it lagged the game out, but it’s an option I’ll end up researching more.
This time I’m also going to be using an Event bus singleton (which I’m going to just call Event) as managing signals was pretty annoying on my last project; as well as a Global singleton for essential stuff so I don’t have to do as many cross references between nodes/scenes.
This is the most challenging part in my opinion as making all the body parts follow the head in a user defined path it’s kinda hard. I tried with like 4-5 options and the one I’m detailing here is the only one that worked as I wanted for me. This time the directory structure I’m using is the following:
The most basic thing is to move the head, this is what we have control of. Create a scene called Head.tscn and setup the basic KinematicBody2D with it’s own Sprite and CollisionShape2D (I used a small circle for the tip of the head), and set the Collision Layer/Mask accordingly, for now just layer = bit 1. And all we need to do, is keep moving the snake forwards and be able to rotate left or right. Created a new script called head.gd attached to the root (KinematicBody2D) and added:
extends KinematicBody2D
@@ -106,7 +106,7 @@ func _rotate_to(direction: int) -> void:
Snake - Basic movement (left and right controls)
-
To move other snake parts by following the snake head the only solution I found was to use the Path2D and PathFollow2D nodes. Path2D basically just handles the curve/path that PathFollow2D will use to move its child node; and I say “child node” in singular… as PathFollow2D can only handle one damn child, all the other ones will have weird transformations and/or rotations. So, the next thing to do is to setup a way to compute (and draw so we can validate) the snake’s path/curve.
Added the signal snake_path_new_point(coordinates) to the Event singleton and then add the following to head.gd:
var _time_elapsed: float = 0.0
@@ -143,7 +143,7 @@ func _on_Head_snake_path_new_point(coordinates: Vector2) -> void:
Snake - Basic movement with path
-
At this point the only thing to do is to add the corresponding next body parts and tail of the snake. To do so, we need a PathFollow2D to use the live-generating Path2D, the only caveat is that we need one of these per body part/tail (this took me hours to figure out, thanks documentation).
Create a new scene called Body.tscn with a PathFollow2D as its root and an Area2D as its child, then just add the necessary Sprite and CollisionShap2D for the Area2D, I’m using layer = bit 2 for its collision. Create a new script called generic_segment.gd with the following code:
And this can be attached to the Body‘s root node (PathFollow2D), no extra setup needed. Repeat the same steps for creating the Tail.tscn scene and when attaching the generic_segment.gd script just configure the Type parameter to tail in the GUI (by selecting the node with the script attached and editing in the Inspector).
Now it’s just a matter of handling when to add new body parts in the snake.gd script. For now I’ve only setup for adding body parts to fulfill the initial length of the snake (this doesn’t include the head or tail). The extra code needed is the following:
export(PackedScene) var BODY_SEGMENT_NP: PackedScene
export(PackedScene) var TAIL_SEGMENT_NP: PackedScene
@@ -239,13 +239,13 @@ func _add_segment_to_queue() -> void:
_snake.propagate_call("set_process_input", [on_off])
After a while of testing and developing, I noticed that sometimes the head “detaches” from the body when a lot of rotations happen (moving the snake left or right), because of how imprecise the Curve2D is. To do this I just send a signal (snake_rotated) whenever the snake rotates and make a small correction (in generic_segment.gd):
For now I just decided to setup a simple system to see everything works fine. The idea is to make some kind of generic food node/scene and a “food manager” to spawn them, for now in totally random locations. For this I added the following signals: food_placing_new_food(type), food_placed_new_food(type) and food_eaten(type).
First thing is creating the Food.tscn which is just an Area2D with its necessary children with an attached script called food.gd. The script is really simple:
class_name Food # needed to access Type enum outside of the script, this registers this script as a node
@@ -293,7 +293,7 @@ func _on_body_entered(body: Node) -> void:
Snake - Food basic interaction
-
It just happend that I saw a video to create random maps by using a method called random walks, this video was made by NAD LABS: Nuclear Throne Like Map Generation In Godot. It’s a pretty simple but powerful script, he provided the source code from which I based my random walker, just tweaked a few things and added others. Some of the maps than can be generated with this method (already aded some random sprites):
Where get_cells_around is just a function that gets the safe cells around the origin. And this get_valid_map_coords just returns used cells minus the safe cells, to place food. get_centered_world_position is so we can center the food in the tiles.
Some signals I used for the world gen: world_gen_walker_started(id), world_gen_walker_finished(id), world_gen_walker_died(id) and world_gen_spawn_walker_unit(location).
The last food algorithm doesn’t check anything related to the world, and thus the food could spawn in the walls and outside the map.
First thing is I generalized the food into a single script and added basic food and special food which inherit from base food. The most important stuff for the base food is to be able to set all necessary properties at first:
Other than that, there are some differences between placing normal and special food (specially the signal they send, and if an extra “special points” property is set). Some of the signals that I used that might be important: food_placing_new_food(type), food_placed_new_food(type, location) and food_eaten(type, location).
I got the idea of saving the current stats (points, max body segments, etc.) in a separate Stats class for easier load/save data. This option I went with didn’t work as I would liked it to work, as it was a pain in the ass to setup and each time a new property is added you have to manually setup the load/save helper functions… so not the best option. This option I used was json but saving a Node directly could work better or using resources (saving tres files).
It uses json as the file format, but I might end up changing this in the future to something else more reliable and easier to use (Stats class related issues).
For this I created a scoring mechanisms and just called it ScoreManager (score_manager.gd) which just basically listens to food_eaten signal and adds points accordingly to the current Stats object loaded. The main function is:
Then this sends a signal display_stats to activate UI elements that shows the progression.
Naturally, the saved Stats are loaded whenever needed. For example, for the Snake, we load the stats and setup any value needed from there (like a flag to know if any ability is enabled), and since we’re saving the new Stats at the end, then on restart we load the updated one.
I redesigned the snake code (the head, actually) to use the state machine pattern by following this guide which is definitely a great guide, straight to the point and easy to implement.
Other than what is shown in the guide, I implemented some important functions in the state_machine.gd script itself, to be used by each of the states as needed:
Where the important parts happen in the enter and exit functions. We need to change the Global.SNAKE_SPEED with the Global.SNAKE_DASH_SPEED on startand start the timer for how long should the dash last. And on the exit we reset the Global.SNAKE_SPEED back to normal. There is probably a better way of updating the Global.SNAKE_SPEED but this works just fine.
For the other ones is the same. Only difference with the jump_state.gd is that the collision from head to body is disabled, and no rotation is allowed (by not calling the rotate_on_input function).
I actually didn’t finish this game (as how I visualized it), but I got it in a playable state which is good. My big learning during this jam is the time management that it requires to plan and design a game. I lost a lot of time trying to implement some mechanics because I was facing many issues, because of my lack of practice (which was expected) as well as trying to blog and create the necessary sprites myself. Next time I should just get an asset pack and do something with it, as well as keeping the scope of my game shorter.
The source code can be found in my GitHub here, it also contains the exported versions for HTML5, Windows and Linux (be aware that the sound might be too high and I’m too lazy to make it configurable, it was the last thing I added), or you could also go to the itch.io page I setup where it’s playable in the browser:
Since this is just pixel art, the importing settings for textures needs to be adjusted so the sprites don’t look blurry. Go to Project -> Project settings… -> Import defaults and on the drop down select Texture, untick everything and make sure Compress/Mode is set to Lossless.
It’s also a good idea to setup some config variables project-wide. To do so, go to Project -> Project settings… -> General, select Application/config and add a new property (there is a text box at the top of the project settings window) for game scale: application/config/game_scale for the type use float and then click on add; configure the new property to 3.0; On the same window, also add application/config/version as a string, and make it 1.0.0 (or whatever number you want).
I only used 3 actions (keybindings): jump, restart and toggle_debug (optional). To add custom keybindings (so that the Input.something() API can be used), go to Project -> Project settings… -> Input Map and on the text box write “jump” and click add, then it will be added to the list and it’s just a matter of clicking the + sign to add a “Physical key”, press any key you want to be used to jump and click ok. Do the same for the rest of the actions.
Finally, rename the physics layers so we don’t lose track of which layer is which. Go to Project -> Layer Names -> 2d Physics and change the first 5 layer names to (in order): “player”, “ground”, “pipe”, “ceiling” and “score”.
For the assets I found out about a pack that contains just what I need: flappy-bird-assets by MegaCrash; I just did some minor modifications on the naming of the files. For the font I used Silver, and for the sound the resources from FlappyBird-N64 (which seems to be taken from 101soundboards.com which the orignal copyright holder is .Gears anyways).
Create the necessary directories to hold the respective assets and it’s just a matter of dragging and dropping, I used directories: res://entities/actors/player/sprites/, res://fonts/, res://levels/world/background/sprites/, res://levels/world/ground/sprites/, res://levels/world/pipe/sprites/, res://sfx/. For the player sprites, the “FileSystem” window looks like this (entities/actor directories are really not necessary):
Now it’s time to actually create the game, by creating the basic scenes that will make up the game. The hardest part and the most confusing is going to be the TileMaps, so that goes first.
I’m using a scene called “WorldTiles” with a Node2D node as root called the same. With 2 different TileMap nodes as children named “GroundTileMap” and “PipeTileMap” (these are their own scene); yes 2 different TileMaps because we need 2 different physics colliders (In Godot 4.0 you can have a single TileMap with different physics colliders in it). Each node has its own script. It should look something like this:
Now it’s just a matter of repeating the same for the pipes (“PipeTileMap”), only difference is that when selecting the tiles you need to select 2 tiles, as the pipe is 2 tiles wide, or just set the Snap Options/Step to 32x16, for example, just keep the cell size to 16x16.
I added few default ground tiles to the scene, just for testing purposes but I left them there. These could be place programatically, but I was too lazy to change things. On the “WorldTiles” scene, while selecting the “GroundTileMap”, you can select the tiles you want to paint with, and left click in the grid to paint with the selected tile. Need to place tiles from (-8, 7) to (10, 7) as well as the tile below with the filler ground (the tile position/coordinates show at the bottom left, refer to the image below):
On a new scene called “Player” with a KinematicBody2D node named “Player” as the root of the scene, then for the children: AnimatedSprite as “Sprite”, CollisionShape2D as “Collision” (with a circle shape) and 3 AudioStreamPlayers for “JumpSound”, “DeadSound” and “HitSound”. Not sure if it’s a good practice to have the audio here, since I did that at the end, pretty lazy. Then, attach a script to the “Player” node and then it should look like this:
Finally, make sure the “Sprite” node has the AnimatedSprite/Animation is set to “bird_1” and that the “Collision” node is configured correctly for its size and position (I just have it as a radius of 7). As well as dropping the SFX files into the corresponding AudioStreamPlayer (into the AudioStreamPlayer/Stream property).
These are really simple scenes that don’t require much setup:
“CeilingDetector”: just an Area2D node with a CollisionShape2D in the form of a rectangle (CollisionShape2D/Shape/extents to (120, 10)), stretched horizontally so it fits the whole screen. CollisionObject2D/Collision/Layer set to bit 4 (ceiling) and CollisionObject2D/Collision/Mask set to bit 1 (player).
This is the actual “Game” scene that holds all the playable stuff, here we will drop in all the previous scenes; the root node is a Node2D and also has an attached script. Also need to add 2 additional AudioStreamPlayers for the “start” and “score” sounds, as well as a Sprite for the background (Sprite/Offset/Offset set to (0, 10)) and a Camera2D (Camera2D/Current set to true (checked)). It should look something like this:
We need some font “Resources” to style the Label fonts. Under the FileSystem window, right click on the fonts directory (create one if needed) and click on “New Resource…” and select DynamicFontData, save it in the “fonts” directory as “SilverDynamicFontData.tres” (“Silver” as it is the font I’m using) then double click the just created resource and set the DynamicFontData/Font Path to the actual “Silver.ttf” font (or whatever you want).
Then create a new resource and this time select DynamicFont, name it “SilverDynamicFont.tres”, then double click to edit and add the “SilverDynamicFontData.tres” to the DynamicFont/Font/Font Data property (and I personally toggled off the DynamicFont/Font/Antialiased property), now just set the DynamicFont/Settings/(Size, Outline Size, Outline Color) to 32, 1 and black, respectively (or any other values you want). It should look something like this:
This has a bunch of nested nodes, so I’ll try to be concise here. The root node is a CanvasLayer named “UI” with its own script attached, and for the children:
“MarginContainer”: MarginContainer with Control/Margin/(Left, Top) set to 10 and Control/Margin/(Right, Bottom) set to -10.
This is the final scene where we connect the Game and the UI. It’s made of a Node2D with it’s own script attached and an instance of “Game” and “UI” as it’s children.
This is a good time to set the default scene when we run the game by going to Project -> Project settings… -> General and in Application/Run set the Main Scene to the “Main.tscn” scene.
I’m going to keep this scripting part to the most basic code blocks, as it’s too much code, for a complete view you can head to the source code.
As of now, the game itself doesn’t do anything if we hit play. The first thing to do so we have something going on is to do the minimal player scripting.
The most basic code needed so the bird goes up and down is to just detect “jump” key presses and add a negative jump velocity so it goes up (y coordinate is reversed in godot…), we also check the velocity sign of the y coordinate to decide if the animation is playing or not.
Finally need to add the actual checks for when the player dies (like collision with ground or pipe) as well as a function that listens to a signal for when the player goes to the ceiling.
The code is pretty simple, we just need a way of detecting if we ran out of ground and send a signal, as well as sending as signal when we start detecting ground/pipes behind us (to remove it) because the world is being generated as we move. The most basic functions needed are:
We need to keep track of 3 “flags”: ground_was_colliding, ground_now_colliding and pipe_now_colliding (and their respective signals), which are going to be used to do the checks inside _physics_process. For example for checking for new ground: ground_now_colliding = _now_colliding(old_ground, ground_now_colliding, "ground_started_colliding").
This script is what handles the “GroundTileMap” as well as the “PipeTileMap” and just basically functions as a “Signal bus” connecting a bunch of signals from the “WorldDetector” with the TileMaps and just tracking how many pipes have been placed:
export(int, 2, 20, 2) var PIPE_SEP: int = 6
var tiles_since_last_pipe: int = PIPE_SEP - 1
@@ -950,7 +950,7 @@ func _on_WorldDetector_ground_started_colliding() -> void:
func _on_WorldDetector_pipe_started_colliding() -> void:
emit_signal("remove_pipe")
This is the node that actually places the ground tiles upong receiving a signal. In general, what you want is to keep track of the newest tile that you need to place (empty spot) as well as the last tile that is in the tilemap (technically the first one if you count from left to right). I was experimenting with enums so I used them to define the possible Ground tiles:
Where you might notice that the _initial_new_tile_x is 11, instead of 10, refer to Default ground tiles where we placed tiles from -8 to 10, so the next empty one is 11. These _place_new_ground and _remove_first_ground functions are called upon receiving the signal.
This is really similar to the “GroundTileMap” code, instead of defining an enum for the ground tiles, we define it for the pipe patterns (because each pipe is composed of multiple pipe tiles). If your pipe tile set looks like this (notice the index):
These functions are called when receiving the signal to place/remove pipes.
Before proceeding, we require a way to save/load data (for the high scores). We’re going to use the ConfigFile node that uses a custom version of the “ini” file format. Need to define where to save the data:
The game script it’s also like a “Signal bus” in the sense that it connects all its childs’ signals together, and also has the job of starting/stopping the _process and _physics_process methods from the childs as needed. First, we need to define the signals and and references to all child nodes:
signal game_started
signal game_over
@@ -1160,7 +1160,7 @@ func _on_ScoreDetector_body_entered(body: Node2D) -> void:
score_sound.play()
When the player dies, we set all processing to false, except for the player itself (so it can drop all the way to the ground). Also, when receiving a “scoring” signal, we manage the current score, as well as saving the new high score when applicable, note that we need to read the high_score at the beginning by calling SavedData.get_high_score(). This signal we emit will be received by the UI so it updates accordingly.
First thing is to get a reference to all the child Labels, an initial reference to the high score as well as the version defined in the project settings:
At this point the game should be fully playable (if any detail missing feel free to look into the source code linked at the beginning). Only thing missing is an icon for the game; I did one pretty quicly with the assets I had.
If you followed the directory structure I used, then only thing needed is to transform the icon to a native Windows ico format (if exporting to Windows, else ignore this part). For this you need ImageMagick or some other program that can transform png (or whatever file format you used for the icon) to ico. I used [Chocolatey][https://chocolatey.org/] to install imagemagick, then to convert the icon itself used: magick convert icon.png -define icon:auto-resize=256,128,64,48,32,16 icon.ico as detailed in Godot‘s Changing application icon for Windows.
You need to download the templates for exporting as detailed in Godot‘s Exporting projects. Basically you go to Editor -> Manage Export Templates… and download the latest one specific to your Godot version by clicking on “Download and Install”.
If exporting for Windows then you also need to download rcedit from here. Just place it wherever you want (I put it next to the Godot executable).
Then go to Project -> Export… and the Window should be empty, add a new template by clicking on “Add…” at the top and then select the template you want. I used HTML5, Windows Desktop and Linux/X11. Really the only thing you need to set is the “Export Path” for each template, which is te location of where the executable will be written to, and in the case of the Windows Desktop template you could also setup stuff like “Company Name”, “Product Name”, “File/Product Version”, etc..
@@ -1446,13 +1446,13 @@ func _ready() -> void:
I’ve been wanting to do this entry, but had no time to do it since I also have to set up the VPN service as well to make sure what I’m writing makes sense, today is the day.
This will be installed and working alongside the other stuff I’ve wrote about on other posts (see the server tag). All commands here are executes as root unless specified otherwise. Also, this is intended only for IPv4 (it’s not that hard to include IPv6, but meh).
Working server with root access, and with Ufw as the firewall.
Depending on what port you want to run the VPN on, the default 1194, or as a fallback on 443 (click here for more). I will do mine on port 1194 but it’s just a matter of changing 2 lines of configuration and one Ufw rule.
PKI stands for Public Key Infrastructure and basically it’s required for certificates, private keys and more. This is supposed to work between two servers and one client: a server in charge of creating, signing and verifying the certificates, a server with the OpenVPN service running and the client making the request.
This is supposed to work something like: 1) a client wants to use the VPN service, so it creates a requests and sends it to the signing server, 2) this server checks the requests and signs the request, returning the certificates to both the VPN service and the client and 3) the client can now connect to the VPN service using the signed certificate which the OpenVPN server knows about. In a nutshell, I’m no expert.
… but, to be honest, all of this is a hassle and (in my case) I want something simple to use and manage. So I’m gonna do all on one server and then just give away the configuration file for the clients, effectively generating files that anyone can run and will work, meaning that you need to be careful who you give this files (it also comes with a revoking mechanism, so no worries).
You might notice that I didn’t specify how to actually connect to our server. For that we need to do a few more steps. We actually need a configuration file similar to the server.conf file that we created.
The real way of doing this would be to run similar steps as the ones with easy-rsa locally, send them to the server, sign them, and retrieve them. Nah, we’ll just create all configuration files on the server as I was mentioning earlier.
Also, the client configuration file has to match the server one (to some degree), to make this easier you can create a client-common file in /etc/openvpn/server with the following content:
@@ -1769,7 +1769,7 @@ cd $CPWD
Recently I set up an XMPP server (and a Matrix one, too) for my personal use and for friends if they want one; made one for EL ELE EME for example. So, here are the notes on how I set up the server that is compatible with the Conversations app and the Movim social network. You can see my addresses in contact and the XMPP compliance/score of the server.
As with my other entries, this is under a server running Arch Linux, with the Nginx web server and Certbot certificates. And all commands here are executed as root (unless specified otherwise)
Same as with my other entries (website, mail and git) plus:
A and (optionally) AAA DNS records for:
@@ -1790,7 +1790,7 @@ cd $CPWD
Email addresses for admin, abuse, contact, security, etc. Or use your own email for all of them, doesn’t really matter much as long as you define them in the configuration and are valid, I have aliases so those emails are forwarded to me.
Allow ports 5000, 5222, 5269, 5280 and 5281 for Prosody and, 3478 and 5349 for Turnserver which are the defaults for coturn.
That’s basically all the configuration that needs Prosody itself, but we still have to configure Nginx and Coturn before starting/enabling the prosody service.
Since this is not an ordinary configuration file I’m going to describe this too. Your prosody.conf file should have the following location blocks under the main server block (the one that listens to HTTPS):
# HTTPS server block
server {
@@ -2232,7 +2232,7 @@ server {
Coturn is the implementation of TURN and STUN server, which in general is for (at least in the XMPP world) voice support and external service discovery.
At this point you should have a working XMPP server, start/enable the prosody service now:
systemctl start prosody.service
systemctl enable prosody.service
@@ -2320,13 +2320,13 @@ systemctl enable prosody.service
How to create a git server using cgit on a server running Nginx. This is a follow up on post about creating a website with Nginx and Certbot.My git server is all I need to setup to actually kill my other server (I’ve been moving from servers on these last 2-3 blog entries), that’s why I’m already doing this entry. I’m basically following git’s guide on setting up a server plus some specific stuff for (btw i use) Arch Linux (Arch Linux Wiki: Git server and Step by step guide on setting up git server in arch linux (pushable)).
Note that this is mostly for personal use, so there’s no user/authentication control other than that of SSH. Also, most if not all commands here are run as root.
I might get tired of saying this (it’s just copy paste, basically)… but you will need the same prerequisites as before (check my website and mail entries), with the extras:
(Optional, if you want a “front-end”) A CNAME for “git” and (optionally) “www.git”, or some other name for your sub-domains.
An SSL certificate, if you’re following the other entries, add a git.conf and run certbot --nginx to extend the certificate.
Those two lines above will need to be run each time you want to add a new repository to your server (yeah, kinda lame… although there are options to “automate” this, I like it this way).
After that you can already push/pull to your repository. I have my repositories (locally) set up so I can push to more than one remote at the same time (my server, GitHub, GitLab, etc.); to do so, check this gist.
This is optionally since it’s only for the web application.
Install the cgit and fcgiwrap packages:
@@ -2449,14 +2449,14 @@ exec highlight --force --inline-css -f -I -O xhtml -S "$EXTENSION" 2&g
How to create mail server using Postfix, Dovecot, SpamAssassin and OpenDKIM. This is a follow up on post about creating a website with Nginx and Certbot.The entry is going to be long because it’s a tedious process. This is also based on Luke Smith’s script, but adapted to Arch Linux (his script works on debian-based distributions). This entry is mostly so I can record all the notes required while I’m in the process of installing/configuring the mail server on a new VPS of mine; also I’m going to be writing a script that does everything in one go (for Arch Linux), that will be hosted here.
This configuration works for local users (users that appear in /etc/passwd), and does not use any type of SQL Database. And note that most if not all commands executed here are run with root privileges.
You will need a CNAME for “mail” and (optionally) “www.mail”, or whatever you want to call the sub-domains (although the RFC 2181 states that it NEEDS to be an A record, fuck the police).
An SSL certificate. You can use the SSL certificate obtained following my last post using certbot (just create a mail.conf and run certbot --nginx again).
Ports 25, 587 (SMTP), 465 (SMTPS), 143 (IMAP) and 993 (IMAPS) open on the firewall.
OpenDKIM is needed so services like G**gle (we don’t mention that name here [[[this is a meme]]]) don’t throw the mail to the trash. DKIM stands for “DomainKeys Identified Mail”.
We should have a working mail server by now. Before continuing check your journal logs (journalctl -xe --unit={unit}, where {unit} could be spamassassin.service for example) to see if there was any error whatsoever and try to debug it, it should be a typo somewhere (the logs are generally really descriptive) because all the settings and steps detailed here just (literally just finished doing everything on a new server as of the writing of this text) worked (((it just werks on my machine))).
Now, to actually use the mail service: first of all, you need a normal account (don’t use root) that belongs to the mail group (gpasswd -a user group to add a user user to group group) and that has a password.
Next, to actually login into a mail app/program/whateveryouwanttocallit, you will use the following settings, at least for thunderdbird(I tested in windows default mail app and you don’t need a lot of settings):
@@ -2815,7 +2815,7 @@ systemctl enable spamassassin.service
How to create website that runs on Nginx and uses Certbot for SSL certificates. This is a base for future blog posts about similar topics.These are general notes on how to setup a Nginx web server plus Certbot for SSL certificates, initially learned from Luke’s video and after some use and research I added more stuff to the mix. And, actually at the time of writing this entry, I’m configuring the web server again on a new VPS instance, so this is going to be fresh.
As a side note, (((i use arch btw))) so everything here es aimed at an Arch Linux distro, and I’m doing everything on a VPS. Also note that most if not all commands here are executed with root privileges.
Nginx is a web (HTTP) server and reverse proxy server.
You have two options: nginx and nginx-mainline. I prefer nginx-mainline because it’s the “up to date” package even though nginx is labeled to be the “stable” version. Install the package and enable/start the service:
The only “bad” (bloated) thing about Certbot, is that it uses python, but for me it doesn’t matter too much. You may want to look up another alternative if you prefer. Install the packages certbot and certbot-nginx:
I don’t really do much on the internet nor do I provide any type of service, but still, if for some reason you want to donate, you can do it via my PayPal, either by its link or using my email david@luevano.xyz.
I wanted to add more fiat options but I don’t have access to them down here. So, instead you could use some of my referral links or donate crypto.
An indirect way of supporting me would be to use affiliate links (of stuff I actually use):
Vultr: Reliable server hosting, I host luevano.xyz here. You get $100 USD in credit for a month and if you continue using the service I get $25 after you spend $25 yourself.
Currently recreating the site with the updated pyssg, things might be broken.
My name is David Luévano and this is my little piece of internet. I’m into alot of stuff, but mostly technology, drawing sometimes and… of course, gaming.
I have some sites setup here, such as a working blog where I post about whatever, an art gallery, and other stuff (check the nav bar).
Also, yes, yes it is supposed to look like this. This isn’t supposed to be a bloated mOdErN website; I use plain HTML and CSS and sometimes a bit of JS (meaning that I use no rEaCt nor bOoTsTrAp).