buildVlessConfig static method
Build a minimal VLESS-over-Reality JSON config string.
All string parameters are sanitised – they must not contain unescaped JSON special characters supplied by the server.
Implementation
static String buildVlessConfig({
required String address,
required int port,
required String uuid,
String flow = 'xtls-rprx-vision',
String network = 'tcp',
String security = 'reality',
String? serverName,
String? publicKey,
String? shortId,
}) {
final outbound = {
'protocol': 'vless',
'settings': {
'vnext': [
{
'address': address,
'port': port,
'users': [
{'id': uuid, 'flow': flow, 'encryption': 'none'},
],
},
],
},
'streamSettings': {
'network': network,
'security': security,
if (security == 'reality')
'realitySettings': {
'serverName': serverName ?? address,
'publicKey': publicKey ?? '',
'shortId': shortId ?? '',
},
if (security == 'tls')
'tlsSettings': {
'serverName': serverName ?? address,
'allowInsecure': false,
},
},
};
return jsonEncode({
'log': {'loglevel': 'warning'},
'inbounds': [
{
'port': 10808,
'protocol': 'socks',
'settings': {'auth': 'noauth'},
},
],
'outbounds': [outbound],
});
}