Skip to content
New issue

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

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

Already on GitHub? # to your account

DEFAULT_FORWARDED_PORT_FILEPATH global variable has side effects #6

Open
3 tasks done
Steinhagen opened this issue Feb 21, 2025 · 2 comments
Open
3 tasks done

Comments

@Steinhagen
Copy link

We are happy to answer your questions about the code or discuss technical ideas.

The following commit introduces the DEFAULT_FORWARDED_PORT_FILEPATH global variable that has side effects (generates directories due to VPNExecutionEnvironment()). As a result, every time you import the core python module, the directories will be generated:
https://github.com/ProtonVPN/python-proton-vpn-api-core/commit/2bed80d42ef199ea1d8d90e13be843cae3e3850c#diff-a477ea526f47d9a15ba19e31f1e9a374bdf99f676be865d5b99563a665709cd3R26

Please complete the following checklist (by adding [x]):

  • I have searched open and closed issues for duplicates
  • This isn't a feature request
  • This is not a report about my app not working as expected

@calexandru2018
Copy link
Member

Hey @Steinhagen , from our tests that's not the case. We even checked with our QA and you can also check the code here: https://github.com/ProtonVPN/python-proton-core/blob/stable/proton/utils/environment.py#L64-L68

@Steinhagen
Copy link
Author

But it does (I've added the snippet below that creates the directories). Also, you can try to run the build using Nix in a sterile environment and you will see that the directories will be generated on just importing the module.

https://github.com/ProtonVPN/python-proton-vpn-api-core/commit/2bed80d42ef199ea1d8d90e13be843cae3e3850c#diff-a477ea526f47d9a15ba19e31f1e9a374bdf99f676be865d5b99563a665709cd3R26

snippet:

DEFAULT_FORWARDED_PORT_FILEPATH = os.path.join(
    VPNExecutionEnvironment().path_runtime, "forwarded_port"
)

Calling path_runtime will generate those directories:
https://github.com/ProtonVPN/python-proton-core/blob/stable/proton/utils/environment.py#L55C1-L58C34

snippet:

    @property
    def path_runtime(self):
        self.generate_dirs(self._path_runtime)
        return self._path_runtime

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants