Veröffentlichte Quellen
Quellen als ZIP herunterladen
CH-J SM Mobile
Durchsuchen Sie Verzeichnisse und Dateien einer bestimmten Anwendungsausgabe.
CH-J / SM Mobile
134 Dateien
sm-mobile-20261016T050549Z-3678f2a05fa9
Hinzugefügt: · Erstellt:
1
import 'dart:convert';2
import 'dart:io';3
import 'dart:math';4
import '../core/failure.dart';6
enum AuthMethod { password, privateKey }8
String newId() => List.generate(9
16,10
(_) => Random.secure().nextInt(256),11
).map((e) => e.toRadixString(16).padLeft(2, '0')).join();13
String normalizeHost(String input) {14
var host = input.trim();15
if (host.startsWith('[') && host.endsWith(']')) {16
host = host.substring(1, host.length - 1);17
if (InternetAddress.tryParse(host)?.type != InternetAddressType.IPv6) {18
throw const Failure('invalidProfile');19
}20
}21
final ip = InternetAddress.tryParse(host);22
final dns = RegExp(23
r'^(?=.{1,253}$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$',24
);25
if (ip == null && !dns.hasMatch(host)) throw const Failure('invalidProfile');26
return host;27
}29
class ServerProfile {30
final String id, name, host, username;31
final int port;32
final AuthMethod auth;33
ServerProfile({34
String? id,35
required String name,36
required String host,37
required String username,38
this.port = 22,39
this.auth = AuthMethod.password,40
}) : id = id ?? newId(),41
name = name.trim(),42
host = normalizeHost(host),43
username = username.trim() {44
if (this.name.isEmpty ||45
this.name.length > 100 ||46
this.username.isEmpty ||47
this.username.length > 128 ||48
RegExp(r'[\x00-\x1f\x7f]').hasMatch(this.name + this.username) ||49
port < 1 ||50
port > 65535) {51
throw const Failure('invalidProfile');52
}53
}54
String get endpoint {55
final ip = InternetAddress.tryParse(host);56
final canonical = ip == null57
? host.toLowerCase()58
: InternetAddress.fromRawAddress(ip.rawAddress).address;59
return ip?.type == InternetAddressType.IPv660
? '[$canonical]:$port'61
: '$canonical:$port';62
}64
String get identity => jsonEncode([endpoint, username]);65
Map<String, dynamic> portable() => {66
'name': name,67
'host': host,68
'username': username,69
'port': port,70
};71
Map<String, dynamic> toJson() => {...portable(), 'id': id, 'auth': auth.name};72
factory ServerProfile.fromJson(73
Map<String, dynamic> json, {74
bool portable = false,75
}) {76
if (json['name'] is! String ||77
json['host'] is! String ||78
json['username'] is! String ||79
(json.containsKey('port') && json['port'] is! int)) {80
throw const Failure('invalidProfile');81
}82
return ServerProfile(83
id: portable ? null : json['id'] as String?,84
name: json['name'],85
host: json['host'],86
username: json['username'],87
port: json['port'] ?? 22,88
auth: !portable && json['auth'] == 'privateKey'89
? AuthMethod.privateKey90
: AuthMethod.password,91
);92
}93
}SHA-256
b113b315481958d2c705a4f91b25d61761555eff0369ee3fd2698cf9069b33e9CH-J Proprietary Software License 1.14 · Die Quellen werden unter der CH-J Proprietary Software License 1.14 bereitgestellt. Ihre Verfügbarkeit ändert die Lizenzbedingungen nicht und gewährt keine zusätzlichen Rechte.
SHA-256 des Archivs
c486a807e4828998b9c57ab0f2e760f7980b31965fe118e89d3e1a5a2b65be65