jadolg / outline-vpn-api

A Python API wrapper for Outline VPN https://getoutline.org/
MIT License
114 stars 30 forks source link

Platform with multiple servers control #19

Open balakhonoff opened 11 months ago

balakhonoff commented 11 months ago

Goal: create a convenient class to manage multiple VPN servers wrapped in the outline-vpn-api class, without worrying about servers that suddenly stop working and distributing users across servers. Additionally, there should be no need to administer databases (the service is completely stateless). After restarting the service, it should only gather up-to-date data on VPN servers, remove duplicate keys (keeping only the most recent one), and grant access to keys based on the username (only one key per user is available at all times).

Solution: Two files have been added, which do not affect the core functionality but add a new capability to manage an array of servers, increasing the reliability of the system that remains operational even if any of the servers fail.

  1. File outline_vpn/platform.py - the Platform class allows creating an instance that manages multiple servers. The servers should be provided as three lists: servers (server names - arbitrary), apis (API URLs from the outline server), certs (certificates from the outline server).

This file describes methods for updating data from servers, creating new keys (on an arbitrary or explicitly specified server), deleting keys (without explicitly searching for the server on which the key is currently located), and adding or increasing user limits.

  1. File outline_vpn/example_platform.py - an example of using the Platform class. In this file:

An example of the .env file looks as follows:

SERVER_1="server1" CERT_1="xxx" API_1="xxx"

SERVER_2="server2" CERT_2="xxx" API_2="xxx"

SERVER_3="server1" CERT_3="xxx" API_3="xxx"

sonarcloud[bot] commented 11 months ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

jadolg commented 11 months ago

Hi @balakhonoff :wave: Thanks for contributing. My thoughts about this right now are that even when it's very useful, I see it as a different project on top of the wrapper. The objective of this lib is to create a simple abstraction on top of the outline manager API and nothing else. This way we can have a real vanilla experience while building other projects with it. I'd love to see this become a new lib but I'd rather not merge it with the current project.