populateTlsSettings method

void populateTlsSettings({
  1. required String? streamSecurity,
  2. required bool allowInsecure,
  3. required String? sni,
  4. required String? fingerprint,
  5. required String? alpns,
  6. required String? publicKey,
  7. required String? shortId,
  8. required String? spiderX,
})

Implementation

void populateTlsSettings({
  required String? streamSecurity,
  required bool allowInsecure,
  required String? sni,
  required String? fingerprint,
  required String? alpns,
  required String? publicKey,
  required String? shortId,
  required String? spiderX,
}) {
  streamSetting['security'] = streamSecurity;
  Map<String, dynamic> tlsSetting = {
    "allowInsecure": allowInsecure,
    "serverName": sni,
    "alpn": alpns == '' ? null : alpns?.split(','),
    "minVersion": null,
    "maxVersion": null,
    "preferServerCipherSuites": null,
    "cipherSuites": null,
    "fingerprint": fingerprint,
    "certificates": null,
    "disableSystemRoot": null,
    "enableSessionResumption": null,
    "show": false,
    "publicKey": publicKey,
    "shortId": shortId,
    "spiderX": spiderX,
  };
  if (streamSecurity == 'tls') {
    streamSetting['realitySettings'] = null;
    streamSetting['tlsSettings'] = tlsSetting;
  } else if (streamSecurity == 'reality') {
    streamSetting['tlsSettings'] = null;
    streamSetting['realitySettings'] = tlsSetting;
  }
}