DDNS polish

This commit is contained in:
Antoine Gersant 2024-10-09 16:45:50 -07:00
parent 8b31698cf4
commit 32e67dc095
5 changed files with 25 additions and 44 deletions

View file

@ -1,5 +1,11 @@
# Streaming From Other Devices
These instructions apply to users running Polaris on a home network. When deploying to cloud services or VPS, configurations requirements will differ.
## Port Forwarding
Configure port forwarding on your router to redirect port 80 traffic towards port 5050 towards the computer running Polaris. The exact way to do this depends on your router manufacturer and model.
## Dynamic DNS
You can access your Polaris installation from anywhere via your computer's public IP address, but there are two problems with that:
@ -8,34 +14,8 @@ You can access your Polaris installation from anywhere via your computer's publi
A solution to these problems is to set up Dynamic DNS, so that your installation can always be reached at a fixed URL.
The steps below will walk you through setting up YDNS and Polaris to give your installation a fixed URL. If you have another solution in mind, or prefer using another Dynamic DNS service, skip to the next section.
1. Register for a free account on https://ydns.io
2. On the YDNS website, access the "My Hosts" page and press the + sign for "Add Host"
3. Fill the host form as described below:
- Domain: ydns.eu
- Name: This part is up to you, whatever you enter will be in the URL you use to access Polaris
- Content: Leave the default. Take a note whether the value looks like a IPv4 address (format: xxx.xxx.xxx.xxx) or a IPv6 address (format: xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx)
- Type: Dynamic IP
4. If the content field looked like a IPv4 address: skip to step #6
5. If the content field looked like a IPv6 address:
- Click on your host name (eg. yourdomain.ydns.eu)
- You should now see a page which looks like this:
![YDNS Records](res/ydns_records.png?raw=true "YDNS Records")
- Click on the green "+" icon on the right
- Fill out the new form as described:
- Make sure the `Type` field is set to `A`
- Set content to 0.0.0.0
- You should now be back on the "records" page which was pictured above
- Click on the ID number on the left for the row that has its `Type` listed as `AAAA` (#28717 in the picture above).
- Click on the red trash can icon in the corner to delete this record
- Done!
6. In the Polaris web interface, access the `Dynamic DNS` tab of the settings screen:
- Update the hostname field to match what you set in step 5. (eg. http://yourdomain.ydns.eu)
- Update the username field to the email address you use when creating your YDNS account
- Update the password field with your YDNS API password. You can find this password on https://ydns.io: click on the "User" icon in the top right and then `Preferences > API`.
## Port Forwarding
Configure port forwarding on your router to redirect port 80 towards port 5050 on the computer where you run Polaris. The exact way to do this depends on your router manufacturer and model.
Don't forget to restart Polaris to apply your configuration changes, and access your music from other computers at http://yourdomain.ydns.eu
1. Reserve a URL with a dynamic DNS provider such as https://www.duckdns.org/, https://freemyip.com/ or https://ydns.io/.
2. The dynamic DNS provider gives you a unique Update URL that can be used to tell them where to send traffic. For example, `freemyip.com` gives you this URL immediately after claiming a subdomain. Other providers may show it in your profile page, etc.
3. Access your Polaris instance (http://localhost:5050 by default).
4. Go to the `Setting page` and into the `Dynamic DNS` section.
5. Set the Update URL to the one you obtained in step 2.

View file

@ -7,11 +7,11 @@ One of the following:
- Linux (any reasonably modern distribution should do)
### Windows
1. Download the [latest installer](https://github.com/agersant/polaris/releases/latest) (you want the .msi file)
2. Run the installer
3. That's it, you're done!
You can now start Polaris from the start menu or from your desktop, Polaris will also start automatically next time you restart your computer. You can tell when Polaris is running by its icon in the notification area (near the clock and volume controls).
3. Launch Polaris from the start menu
4. In your web browser, access http://localhost:5050
### Linux
@ -26,17 +26,10 @@ You can now start Polaris from the start menu or from your desktop, Polaris will
3. To install Polaris within your home directory, execute `make install-xdg`. This installation follows the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html). You can use `make preview-xdg` to see which directories the install process would use.
4. If you prefer a system-wide install, execute `make install` (without the `-xdg` suffix). If you use `sudo` to perform such a system install, you may need the `-E` option so that your sudo user find the Rust binaries: `sudo -E make install`. This installation follows the [GNU Standard Installation Directories](https://www.gnu.org/prep/standards/html_node/Directory-Variables.html). You can use `make preview` to see which directories the install process would use.
From here, you might want to adjust your system to run Polaris on login using Systemd, Cron or whichever method your distribution endorses.
If you want to uninstall Polaris, execute `make uninstall-xdg` from the extracted archive's directory (or `make uninstall` if you made a system-wide install). This will delete all the files and directories listed above **including your Polaris database**. If you customized the install process by specifying environment variables like `PREFIX`, make sure they are set to the same values when running the uninstall command.
If you want to uninstall Polaris, execute `make uninstall-xdg` from the extracted archive's directory (or `make uninstall` if you made a system-wide install). This will delete all the files and directories listed above (including your configuration, playlists, etc.). If you customized the install process by specifying environment variables like `PREFIX`, make sure they are set to the same values when running the uninstall command.
### In a docker container
To run polaris from a Docker container, please follow instructions from the [docker-polaris](https://github.com/ogarcia/docker-polaris) repository.
## Test Run
- Start Polaris using the shortcut on your desktop (Windows) or by running the Polaris executable
- In your Web browser, access http://localhost:5050
- You will see a welcome page that will guide you through the Polaris configuration

View file

@ -13,7 +13,7 @@ impl Manager {
Self { config_manager }
}
async fn update_ddns(&self) -> Result<(), Error> {
pub async fn update_ddns(&self) -> Result<(), Error> {
let url = self.config_manager.get_ddns_update_url().await;
let Some(url) = url else {
debug!("Skipping DDNS update because credentials are missing");

View file

@ -59,6 +59,12 @@ impl FromRef<App> for app::config::Manager {
}
}
impl FromRef<App> for app::ddns::Manager {
fn from_ref(app: &App) -> Self {
app.ddns_manager.clone()
}
}
impl FromRef<App> for app::peaks::Manager {
fn from_ref(app: &App) -> Self {
app.peaks_manager.clone()

View file

@ -13,7 +13,7 @@ use regex::Regex;
use tower_http::{compression::CompressionLayer, CompressionLevel};
use crate::{
app::{auth, config, index, peaks, playlist, scanner, thumbnail, App},
app::{auth, config, ddns, index, peaks, playlist, scanner, thumbnail, App},
server::{
dto, error::APIError, APIMajorVersion, API_ARRAY_SEPARATOR, API_MAJOR_VERSION,
API_MINOR_VERSION,
@ -121,6 +121,7 @@ async fn get_settings(
async fn put_settings(
_admin_rights: AdminRights,
State(config_manager): State<config::Manager>,
State(ddns_manager): State<ddns::Manager>,
Json(new_settings): Json<dto::NewSettings>,
) -> Result<(), APIError> {
if let Some(pattern) = new_settings.album_art_pattern {
@ -141,6 +142,7 @@ async fn put_settings(
return Err(APIError::InvalidDDNSURL);
};
config_manager.set_ddns_update_url(uri).await?;
ddns_manager.update_ddns().await?;
}
Ok(())