TrojanURL constructor
TrojanURL({
- required String url,
Implementation
TrojanURL({required super.url}) {
if (!url.startsWith('trojan://')) {
throw ArgumentError('url is invalid');
}
final temp = Uri.tryParse(url);
if (temp == null) {
throw ArgumentError('url is invalid');
}
uri = temp;
if (uri.queryParameters.isNotEmpty) {
var sni = super.populateTransportSettings(
transport: uri.queryParameters['type'] ?? "tcp",
headerType: uri.queryParameters['headerType'],
host: uri.queryParameters["host"],
path: uri.queryParameters["path"],
seed: uri.queryParameters["seed"],
quicSecurity: uri.queryParameters["quicSecurity"],
key: uri.queryParameters["key"],
mode: uri.queryParameters["mode"],
serviceName: uri.queryParameters["serviceName"],
);
super.populateTlsSettings(
streamSecurity: uri.queryParameters['security'] ?? 'tls',
allowInsecure: allowInsecure,
sni: uri.queryParameters["sni"] ?? sni,
fingerprint:
streamSetting['tlsSettings']?['fingerprint'] ?? "randomized",
alpns: uri.queryParameters['alpn'],
publicKey: null,
shortId: null,
spiderX: null,
);
flow = uri.queryParameters["flow"] ?? "";
} else {
super.populateTlsSettings(
streamSecurity: 'tls',
allowInsecure: allowInsecure,
sni: '',
fingerprint:
streamSetting['tlsSettings']?['fingerprint'] ?? "randomized",
alpns: null,
publicKey: null,
shortId: null,
spiderX: null,
);
}
}