From dfc6fc417fb98e4d81250077032efa34f053fb4c Mon Sep 17 00:00:00 2001 From: Julien <120588494+julien4215@users.noreply.github.com> Date: Thu, 2 Jan 2025 20:18:00 +0100 Subject: [PATCH] Use http scheme when host url is a private ip address --- lib/src/network/http.dart | 4 +++- lib/src/network/socket.dart | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/src/network/http.dart b/lib/src/network/http.dart index fb0c115f04..54a87ffc47 100644 --- a/lib/src/network/http.dart +++ b/lib/src/network/http.dart @@ -38,7 +38,9 @@ const _maxCacheSize = 2 * 1024 * 1024; /// Creates a Uri pointing to lichess server with the given unencoded path and query parameters. Uri lichessUri(String unencodedPath, [Map? queryParameters]) => - kLichessHost.startsWith('localhost') + kLichessHost.startsWith('localhost') || + kLichessHost.startsWith('10.') || + kLichessHost.startsWith(RegExp('192.168.')) ? Uri.http(kLichessHost, unencodedPath, queryParameters) : Uri.https(kLichessHost, unencodedPath, queryParameters); diff --git a/lib/src/network/socket.dart b/lib/src/network/socket.dart index 93aacb93b2..556251db00 100644 --- a/lib/src/network/socket.dart +++ b/lib/src/network/socket.dart @@ -48,7 +48,9 @@ final socketGlobalStream = _globalStreamController.stream; /// Creates a WebSocket URI for the lichess server. Uri lichessWSUri(String unencodedPath, [Map? queryParameters]) => - kLichessWSHost.startsWith('localhost') + kLichessWSHost.startsWith('localhost') || + kLichessWSHost.startsWith('10.') || + kLichessWSHost.startsWith('192.168') ? Uri( scheme: 'ws', host: kLichessWSHost.split(':')[0],