diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index adf9e67..b6e9be7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -94,9 +94,9 @@ jobs: Get-Content pubspec.yaml | Select-String -Pattern 'version:\s(.+)\+' | % {Set-Item -Path Env:QECK_VERSION -Value "$($_.matches.groups[1])"} & 'C:/Program Files (x86)/Inno Setup 6/ISCC.exe' /DMyAppVersion=$Env:QECK_VERSION QeckSetup.iss # flutter pub run msix:create - - name: Copy portable start script - run: | - cp scripts/start.bat build/windows/runner/Release/ + #- name: Copy portable start script + # run: | + # cp scripts/start.bat build/windows/runner/Release/ - name: Archive uses: actions/upload-artifact@v3 with: @@ -190,9 +190,9 @@ jobs: run: | ls mv ./*.AppImage linwood-qeck-linux.AppImage - - name: Copy portable start script - run: | - cp scripts/start.sh build/linux/x64/release/bundle + #- name: Copy portable start script + # run: | + # cp scripts/start.sh build/linux/x64/release/bundle - name: Archive uses: actions/upload-artifact@v3 with: diff --git a/app/.gitignore b/app/.gitignore index fcee56a..1fe5f00 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -34,8 +34,5 @@ .pub/ /build/ -# Web related -lib/generated_plugin_registrant.dart - # Exceptions to above rules. -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages \ No newline at end of file +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages diff --git a/app/lib/l10n/app_en.arb b/app/lib/l10n/app_en.arb index d321ba2..cf4a99d 100644 --- a/app/lib/l10n/app_en.arb +++ b/app/lib/l10n/app_en.arb @@ -37,5 +37,7 @@ "count": "Count", "putCards": "Put cards", "changeVisibility": "Change visibility", - "change": "Change" + "change": "Change", + "secure": "Secure", + "port": "Port" } diff --git a/app/lib/pages/home/connect.dart b/app/lib/pages/home/connect.dart index a0bad99..821452a 100644 --- a/app/lib/pages/home/connect.dart +++ b/app/lib/pages/home/connect.dart @@ -9,6 +9,8 @@ class ConnectGameDialog extends StatelessWidget { @override Widget build(BuildContext context) { var currentAddress = ''; + var port = kDefaultPort; + bool secure = false; return AlertDialog( title: Text(AppLocalizations.of(context).create), scrollable: true, @@ -17,6 +19,11 @@ class ConnectGameDialog extends StatelessWidget { child: Column( mainAxisSize: MainAxisSize.min, children: [ + CheckboxListTile( + title: Text(AppLocalizations.of(context).secure), + value: secure, + onChanged: (value) => secure = value ?? secure, + ), TextFormField( decoration: InputDecoration( labelText: AppLocalizations.of(context).address, @@ -26,6 +33,16 @@ class ConnectGameDialog extends StatelessWidget { initialValue: currentAddress, onChanged: (value) => currentAddress = value, ), + const SizedBox(height: 16), + TextFormField( + decoration: InputDecoration( + labelText: AppLocalizations.of(context).port, + filled: true, + icon: const PhosphorIcon(PhosphorIconsLight.textT), + ), + initialValue: port.toString(), + onChanged: (value) => port = int.tryParse(value) ?? port, + ), ], ), ), @@ -36,9 +53,10 @@ class ConnectGameDialog extends StatelessWidget { ), ElevatedButton( onPressed: () => Navigator.of(context).pop(Uri( - scheme: 'ws', + scheme: secure ? 'wss' : 'ws', host: currentAddress, - port: kDefaultPort, + port: port, + path: '/connect', )), child: Text(AppLocalizations.of(context).create), ), diff --git a/tools/local_server.dart b/tools/local_server.dart new file mode 100644 index 0000000..71a9277 --- /dev/null +++ b/tools/local_server.dart @@ -0,0 +1,39 @@ +import 'dart:io'; + +import 'package:shelf/shelf.dart'; +import 'package:shelf/shelf_io.dart' as io; +import 'package:shelf_static/shelf_static.dart'; +import 'package:shelf_web_socket/shelf_web_socket.dart'; +import 'package:web_socket_channel/web_socket_channel.dart'; + +void main() { + final staticHandler = + createStaticHandler('app/build/web', defaultDocument: 'index.html'); + + final socketHandler = webSocketHandler((WebSocketChannel webSocket) async { + final proxied = await WebSocket.connect('ws://localhost:10357'); + webSocket.stream.listen((message) { + proxied.add(message); + }, onDone: () { + proxied.close(); + }); + proxied.listen((message) { + webSocket.sink.add(message); + }, onDone: () { + webSocket.sink.close(); + }); + }); + + // Serve /connect requests with the web socket handler. + // Serve other requests with the static file handler. + handler(Request request) { + print(request.url.path); + if (request.url.path == 'connect') { + return socketHandler(request); + } else { + return staticHandler(request); + } + } + + io.serve(handler, 'localhost', 80); +} diff --git a/tools/pubspec.lock b/tools/pubspec.lock index e8ed66b..767e152 100644 --- a/tools/pubspec.lock +++ b/tools/pubspec.lock @@ -9,6 +9,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.4.1" + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" clock: dependency: transitive description: @@ -25,6 +33,38 @@ packages: url: "https://pub.dev" source: hosted version: "1.17.1" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" + http: + dependency: transitive + description: + name: http + sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" + url: "https://pub.dev" + source: hosted + version: "0.13.6" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" intl: dependency: "direct main" description: @@ -49,6 +89,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.1" + mime: + dependency: transitive + description: + name: mime + sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e + url: "https://pub.dev" + source: hosted + version: "1.0.4" path: dependency: transitive description: @@ -57,6 +105,38 @@ packages: url: "https://pub.dev" source: hosted version: "1.8.3" + shelf: + dependency: "direct main" + description: + name: shelf + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 + url: "https://pub.dev" + source: hosted + version: "1.4.1" + shelf_proxy: + dependency: "direct main" + description: + name: shelf_proxy + sha256: cf9883f9ec7fe9d3fb076724d627dd5d9a3c8d07cde7ef5c3f51813d1d732abe + url: "https://pub.dev" + source: hosted + version: "1.0.3" + shelf_static: + dependency: "direct main" + description: + name: shelf_static + sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e + url: "https://pub.dev" + source: hosted + version: "1.1.2" + shelf_web_socket: + dependency: "direct main" + description: + name: shelf_web_socket + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" + url: "https://pub.dev" + source: hosted + version: "1.0.4" source_span: dependency: transitive description: @@ -65,6 +145,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.10.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" + source: hosted + version: "1.11.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" + source: hosted + version: "2.1.1" string_scanner: dependency: transitive description: @@ -81,6 +177,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.1" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + web_socket_channel: + dependency: "direct main" + description: + name: web_socket_channel + sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b + url: "https://pub.dev" + source: hosted + version: "2.4.0" yaml: dependency: "direct main" description: diff --git a/tools/pubspec.yaml b/tools/pubspec.yaml index 2b6a80b..ed5b099 100644 --- a/tools/pubspec.yaml +++ b/tools/pubspec.yaml @@ -5,4 +5,9 @@ dependencies: args: ^2.4.1 intl: ^0.18.1 lints: ^2.0.1 + shelf: ^1.4.1 + shelf_proxy: ^1.0.3 + shelf_static: ^1.1.2 + shelf_web_socket: ^1.0.4 + web_socket_channel: ^2.4.0 yaml: ^3.1.2