Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): Allow users to set AP port #1420

Merged
merged 4 commits into from
Mar 30, 2024
Merged

Conversation

gilcu3
Copy link
Contributor

@gilcu3 gilcu3 commented Mar 21, 2024

Describe your changes

Added a config option ap-port to fix the port used to connect to spotify and pass it to librespot. Fixes issues with restrictive firewalls, after setting ap-port = 443 in config file.

Issue ticket number and link

Fixes #1404

Checklist before requesting a review

  • Documentation was updated (i.e. due to changes in keybindings, commands, etc.)
  • Changelog was updated with relevant user-facing changes (eg. not dependency updates,
    not performance improvements, etc.)

src/spotify.rs Outdated
Comment on lines 140 to 142
let ap_port = cfg.values().ap_port.unwrap_or(0);
if ap_port != 0 {
session_config.ap_port = Some(ap_port);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this intermediate 0 value? Could we also do it like this?

Suggested change
let ap_port = cfg.values().ap_port.unwrap_or(0);
if ap_port != 0 {
session_config.ap_port = Some(ap_port);
}
session_config.ap_port = cfg.values().ap_port;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not sure if that would behave in the correct way (no parameter is set) when the ap-port option is missing in the config file. If that's the case, please feel free to apply the change, I wont be able in a couple of days.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default librespot sets ap_port to None: https://github.com/librespot-org/librespot/blob/4d35c5ffe222c839d1532d8afac78fe4c37043b3/core/src/config.rs#L33

However, if we wanted to be absolutely sure we could also use an if let expression here.

@hrkfdn hrkfdn changed the title added support for ap-port conf feat(config): Allow users to set AP port Mar 30, 2024
@hrkfdn hrkfdn merged commit 9624c03 into hrkfdn:main Mar 30, 2024
5 checks passed
@gilcu3 gilcu3 deleted the ap-port-support branch March 30, 2024 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add support for --ap-port option
2 participants