public function setProxy($proxy)
  {
    $args = array('set_proxy');
    if ($proxy !== false)
    {
      if (preg_match('~^(http|socks5)://(?:([^:@/]*?):([^:@/]*?)@)?([^:@/]+):(\d+)$~', $proxy, $components))
      {
        array_push($args, $components[4], intval($components[5], 10), $components[1]);
        if (strlen($components[2]) || strlen($components[3]))
        {
          array_push($args, urldecode($components[2]), urldecode($components[3]));
        }
      }
      else
      {
        throw new \UnexpectedValueException('Invalid proxy url ' . $proxy);
      }
    }
    return call_user_func_array(array($this, 'command'), $args);
  }