SocksURL constructor

SocksURL({
  1. required String url,
})

Implementation

SocksURL({required super.url}) {
  if (!url.startsWith('socks://')) {
    throw ArgumentError('url is invalid');
  }
  final temp = Uri.tryParse(url);
  if (temp == null) {
    throw ArgumentError('url is invalid');
  }
  uri = temp;
  if (uri.userInfo.isNotEmpty) {
    final String userpass = utf8.decode(base64Decode(uri.userInfo));
    username = userpass.split(':')[0];
    password = userpass.substring(username!.length + 1);
  } else {
    username = null;
    password = null;
  }
}