V2RayConfigBuilder class

Composes Xray configurations without changing the existing V2RayURL API.

This builder keeps arbitrary Xray sections intact (including observatory, policy, DNS, and future core options) so it can also edit hand-written JSON. The first outbound is the default when no routing rule chooses another one.

Constructors

V2RayConfigBuilder.empty({int socksPort = 1080, String listen = '127.0.0.1'})
Start with a local SOCKS inbound and no outbound servers.
factory
V2RayConfigBuilder.fromJson(String config)
Preserve all existing sections in a full Xray JSON configuration.
factory
V2RayConfigBuilder.fromUrl(V2RayURL url)
Begin with the legacy share-link parser's full configuration.
factory
V2RayConfigBuilder.fromUrls(Iterable<V2RayURL> urls, {List<String>? tags})
Compose several share links while retaining the first link's local inbound, DNS defaults and direct/blackhole outbounds.
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
outboundTags → Set<String>
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addBalancer({required String tag, required List<String> selector, String strategy = 'roundRobin', Map<String, dynamic>? strategySettings}) → V2RayConfigBuilder
Register an Xray balancer. selector contains outbound tag prefixes.
addOutbound(Map<String, dynamic> outbound, {String? tag}) → V2RayConfigBuilder
Append an Xray outbound (VLESS, VMess, direct, blackhole, etc.).
addOutboundFromUrl(V2RayURL url, {required String tag}) → V2RayConfigBuilder
Parse a share link and add its generated outbound under a unique tag.
addRoutingRule(Map<String, dynamic> rule) → V2RayConfigBuilder
Add a raw routing rule, for advanced matching options.
build() → Map<String, dynamic>
Return an independent copy so callers cannot mutate the builder.
buildJson({int indent = 2}) → String
getFullConfiguration({int indent = 2}) → String
Alias for the legacy parser naming convention.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
replaceOutbound(String tag, Map<String, dynamic> outbound) → V2RayConfigBuilder
Edit a named outbound while preserving the other outbounds.
route({List<String>? domains, List<String>? ips, List<String>? inboundTags, String? outboundTag, String? balancerTag}) → V2RayConfigBuilder
Route matching domains or IP ranges to an outbound or balancer.
setDnsServers(List servers) → V2RayConfigBuilder
Replace DNS servers (IP strings, DoH URLs or full server objects).
setSection(String key, Object? value) → V2RayConfigBuilder
Set any top-level Xray section without dropping unknown fields.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited