toJson method

  1. @override
JsonMap toJson()
override

Implementation

@override
JsonMap toJson() {
  if (inbounds.isEmpty) {
    throw StateError('Xray config must contain at least one inbound');
  }
  if (outbounds.isEmpty) {
    throw StateError('Xray config must contain at least one outbound');
  }

  final json = <String, dynamic>{
    'log': log.toJson(),
    'inbounds': inbounds.map((inbound) => inbound.toJson()).toList(),
    'outbounds': outbounds.map((outbound) => outbound.toJson()).toList(),
    'routing': routing.toJson(),
  };
  return sanitizeXrayJson(json) as JsonMap;
}