Skip to content

Commit

Permalink
Use http scheme when host url is a private ip address
Browse files Browse the repository at this point in the history
  • Loading branch information
julien4215 committed Jan 2, 2025
1 parent fe0ca90 commit dfc6fc4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/src/network/http.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, dynamic>? 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);

Expand Down
4 changes: 3 additions & 1 deletion lib/src/network/socket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ final socketGlobalStream = _globalStreamController.stream;

/// Creates a WebSocket URI for the lichess server.
Uri lichessWSUri(String unencodedPath, [Map<String, String>? queryParameters]) =>
kLichessWSHost.startsWith('localhost')
kLichessWSHost.startsWith('localhost') ||
kLichessWSHost.startsWith('10.') ||
kLichessWSHost.startsWith('192.168')
? Uri(
scheme: 'ws',
host: kLichessWSHost.split(':')[0],
Expand Down

0 comments on commit dfc6fc4

Please sign in to comment.