askrobots / network-computer-flutter
Public
One Flutter client for network-computer: drive a remote Linux/Mac desktop from Android, iPhone, iPad, or desktop over WebRTC.
Dan Quellhorst
No colour (compare) in ⋯: the desk's picture in grey on this device
c74471a
1 month, 3 weeks ago
History
pin_check.dart · 1.3 KB · 31 lines
| 1 | // ignore_for_file: avoid_print |
| 2 | // Exercises the client's TLS pinning against a live secure-mode rendezvous. |
| 3 | // dart run tool/pin_check.dart <https-url> <password> <fingerprint> |
| 4 | import 'dart:io'; |
| 5 | import 'package:network_computer/signaling.dart'; |
| 6 | |
| 7 | Future<String> attempt(String label, Endpoint ep) async { |
| 8 | try { |
| 9 | final c = SignalingClient(ep); |
| 10 | await c.authenticate(); |
| 11 | final hosts = await c.fetchHosts(); |
| 12 | await c.connect(); // WebSocket over the same pinned client |
| 13 | c.close(); |
| 14 | return '$label: OK (mode=${c.mode}, hosts=$hosts, websocket connected)'; |
| 15 | } catch (e) { |
| 16 | return '$label: refused -> $e'; |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | Future<void> main(List<String> a) async { |
| 21 | final base = Uri.parse(a[0]); |
| 22 | final pw = a[1], fp = a[2]; |
| 23 | final wrong = '00${fp.substring(2)}'; |
| 24 | final colons = [for (var i = 0; i < fp.length; i += 2) fp.substring(i, i + 2)].join(':').toUpperCase(); |
| 25 | print(await attempt('correct pin ', Endpoint(base, 'nc', pw, fingerprint: fp))); |
| 26 | print(await attempt('pin as AB:CD:.. ', Endpoint(base, 'nc', pw, fingerprint: 'SHA256 $colons'))); |
| 27 | print(await attempt('wrong pin ', Endpoint(base, 'nc', pw, fingerprint: wrong))); |
| 28 | print(await attempt('no pin ', Endpoint(base, 'nc', pw))); |
| 29 | print(await attempt('bad password ', Endpoint(base, 'nc', 'nope', fingerprint: fp))); |
| 30 | exit(0); |
| 31 | } |