[cli/core] Add option to disable HTTPS for downloads

The EGS client does not use HTTPS for downloads in order to facilitate
the use of tools such as LanCache that use DNS based CDN redirection.

Legendary should be usable in such an environment as well,
but HTTPS will remain on by default.

See: https://lancache.net/news/2019/06/15/steamcache-is-rebranding-to-lancachenet/
This commit is contained in:
derrod 2021-08-09 11:31:03 +02:00
parent 1760c34703
commit d86039dd9b
2 changed files with 12 additions and 3 deletions

View file

@ -622,7 +622,8 @@ class LegendaryCLI:
repair_use_latest=args.repair_and_update,
disable_delta=args.disable_delta,
override_delta_manifest=args.override_delta_manifest,
preferred_cdn=args.preferred_cdn)
preferred_cdn=args.preferred_cdn,
disable_https=args.disable_https)
# game is either up to date or hasn't changed, so we have nothing to do
if not analysis.dl_size:
@ -1205,7 +1206,9 @@ def main():
install_parser.add_argument('--reset-sdl', dest='reset_sdl', action='store_true',
help='Reset selective downloading choices (requires repair to download new components)')
install_parser.add_argument('--preferred-cdn', dest='preferred_cdn', action='store', metavar='<hostname>',
help='Set the hostname of the preferred CDN to use when available.')
help='Set the hostname of the preferred CDN to use when available')
install_parser.add_argument('--no-https', dest='disable_https', action='store_true',
help='Download games via plaintext HTTP (like EGS), e.g. for use with a lan cache')
uninstall_parser.add_argument('--keep-files', dest='keep_files', action='store_true',
help='Keep files but remove game from Legendary database')

View file

@ -704,7 +704,8 @@ class LegendaryCore:
dl_optimizations: bool = False, dl_timeout: int = 10,
repair: bool = False, repair_use_latest: bool = False,
disable_delta: bool = False, override_delta_manifest: str = '',
egl_guid: str = '', preferred_cdn: str = None) -> (DLManager, AnalysisResult, ManifestMeta):
egl_guid: str = '', preferred_cdn: str = None,
disable_https: bool = False) -> (DLManager, AnalysisResult, ManifestMeta):
# load old manifest
old_manifest = None
@ -820,6 +821,11 @@ class LegendaryCore:
else:
self.log.warning(f'Preferred CDN "{preferred_cdn}" unavailable, using default selection.')
# The EGS client uses plaintext HTTP by default for the purposes of enabling simple DNS based
# CDN redirection to a (local) cache. In Legendary this will be a config option.
if disable_https or self.lgd.config.getboolean('Legendary', 'disable_https', fallback=False):
base_url = base_url.replace('https://', 'http://')
self.log.debug(f'Using base URL: {base_url}')
scheme, cdn_host = base_url.split('/')[0:3:2]
self.log.info(f'Selected CDN: {cdn_host} ({scheme.strip(":")})')