SocksURL constructor

SocksURL({
  1. required String url,
})

Parses a lowercase socks:// URI, including legacy full-base64 authorities.

The server port defaults to 443 when no valid explicit port is available. Invalid URI or scheme throws ArgumentError. Native Core performs final configuration and server validation.

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;
  _address = uri.host;
  _port = uri.hasPort ? uri.port : null;
  if (uri.userInfo.isNotEmpty) {
    _parseUserPassword(_decodeUserInfo(uri.userInfo));
  } else {
    _parseLegacyFullBase64();
  }
}