buildTrojanConfig static method
Build a minimal Trojan JSON config string.
Implementation
static String buildTrojanConfig({
required String address,
required int port,
required String password,
String? serverName,
bool allowInsecure = false,
}) {
return jsonEncode({
'log': {'loglevel': 'warning'},
'inbounds': [
{
'port': 10808,
'protocol': 'socks',
'settings': {'auth': 'noauth'},
},
],
'outbounds': [
{
'protocol': 'trojan',
'settings': {
'servers': [
{
'address': address,
'port': port,
'password': password,
},
],
},
'streamSettings': {
'network': 'tcp',
'security': 'tls',
'tlsSettings': {
'serverName': serverName ?? address,
'allowInsecure': allowInsecure,
},
},
},
],
});
}