parseEndpoint function
Implementation
IPEndpoint? parseEndpoint(Instance instance, String s) {
var e = endpointParser().parse(s.split(' '));
if (e.arguments.first == 'tcp') {
final host = e['host'] ?? instance.defaultHost;
return TcpEndpoint(
host: host,
port: int.parse(e['port']),
secure: false,
compress: e['compress'] ?? false,
timeout: e['timeout'] == 'infinite'
? -1
: e['timeout'] != null
? int.parse(e['timeout'])
: 0,
sourceAddress: e['sourceAddress'] ?? '',
addressList: host == '*' || host.isEmpty ? [InternetAddress.anyIPv4] : [],
);
} else if (e.arguments.first == 'udp') {
final host = e['host'] ?? instance.defaultHost;
return UdpEndpoint(
host: host,
port: int.parse(e['port']),
ttl: e['ttl'] ?? 1,
interface: e['interface'] ?? '',
connect: e['connect'] ?? false,
secure: false,
compress: e['compress'] ?? false,
addressList: host == '*' || host.isEmpty ? [InternetAddress.anyIPv4] : [],
);
}
}