getSession method

ProxySession? getSession({
  1. required Proxy proxy,
  2. required String domain,
})

Gets a session for a proxy and domain

Implementation

ProxySession? getSession({required Proxy proxy, required String domain}) {
  // Clean up old sessions
  _cleanupSessions();

  // Check if we have a session for this proxy and domain
  final proxyKey = '${proxy.host}:${proxy.port}';
  final domainSessions = _sessionsByDomain[domain];
  if (domainSessions != null) {
    final session = domainSessions[proxyKey];
    if (session != null && session.isActive) {
      return session;
    }
  }

  return null;
}