Writing a Chatbot Powered by Google Gemini Part I

Google released the Gemini model recently, and it’s free to use. We can use it to create our own chatbot. We’ll start with the introduction to Telegram bots because they are also free and can handle text and image messages. Bots on other platforms should be similar. info There is a Golang library providing Telegram bots api wrappers. We don’t use it in this post because the api is very easy and self-explanatory....

published on February 9, 2024 · 6 min · 1121 words

Writing a Caddy Plugin Part II

Previous post discusses the basics of a Caddy plugin and shows an example of a bare-bone plugin. In this post we implement a Caddy module that listens to a TCP socket and replies Hello world to every connected client. Plugin Considerations Before we begin, we need to think about what our plugin can do and how its behavior can be customized by its user. Depending on the function, the full configuration may be complex, but we should provide a reasonable default to the user....

published on January 22, 2024 · last edited on February 3, 2024 · 4 min · 816 words

Writing a Caddy Plugin Part I

Caddy is a server best known for its auto HTTPS features. It manages TLS certificates automatically without any human intervention. It’s also quite extensible, there are some built-in namespaces that define how we can implement some interfaces to add new functionalities to Caddy. First, let’s see how Caddy works. Caddy Architecture Caddy has three parts: a commandline interface, a core and module system. Command Interface It is how Caddy interprets commandline arguments to run some common tasks such as printing help information and running a simple reverse proxy or a file server....

published on January 8, 2024 · last edited on February 1, 2024 · 2 min · 382 words

Setup Wireguard Between Two Servers

WireGuard is a modern VPN that utilizes state-of-art cryptography. It’s very easy to set up compared to other VPNs. In this post we are exploring how to set up secure networks between two servers over the internet. Preparation First, we will need the necessary components: wireguard-go and wg from wireguard-tools. wireguard-go is used to create the network interface that the system uses to create the tunnel between the servers. wg manages the configuration of the interfaces....

published on December 28, 2023 · 4 min · 655 words

Tracking Http Upload Progress Using Golang

I wrote a simple cli tool to upload files to my Cloudreve instance. It’s easy to figure out which api to call when uploading files. However, it will be helpful to know how the upload is going. Visualizing Speed When creating an upload request, golang allows us to use a io.Reader as the request body. The body will be responsible for displaying upload progress. info Although Cloudreve and its storage providers require Content-Length header to be set, thus requiring the total length to be known beforehand, this method is applicable even if the total is unknown....

published on December 10, 2023 · 3 min · 574 words