VlessURL constructor

VlessURL({
  1. required String url,
})

Implementation

VlessURL({required super.url}) {
  if (!url.startsWith('vless://')) {
    throw ArgumentError('url is invalid');
  }
  final temp = Uri.tryParse(url);
  if (temp == null) {
    throw ArgumentError('url is invalid');
  }
  uri = temp;
  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"] ?? "",
    allowInsecure: allowInsecure,
    sni: uri.queryParameters["sni"] ?? sni,
    fingerprint: uri.queryParameters["fp"] ??
        streamSetting['tlsSettings']?['fingerprint'],
    alpns: uri.queryParameters["alpn"],
    publicKey: uri.queryParameters["pbk"] ?? "",
    shortId: uri.queryParameters["sid"] ?? "",
    spiderX: uri.queryParameters["spx"] ?? "",
  );
}