src/Proxy/SOCKS.php
protected function userpass(\Erebot\URIInterface $proxyURI)
    {
        $username = $proxyURI->asParsedURL(PHP_URL_USER);
        $password = $proxyURI->asParsedURL(PHP_URL_PASS);

        if ($username === null || $password === null) {
            throw new \Erebot\InvalidValueException(
                'No username or password supplied'
            );
        }

        $ulen = strlen($username);
        $plen = strlen($password);
        if ($ulen > 255) {
            throw new \Erebot\InvalidValueException(
                'Username too long (max. 255)'
            );
        }

        if ($plen > 255) {
            throw new \Erebot\InvalidValueException(
                'Password too long (max. 255)'
            );
        }

        $this->write(
            "\x01".pack(
                "Ca*Ca*",
                $ulen,
                $username,
                $plen,
                $password
            )
        );
        $line = $this->read(2);

        if ($line[0] != "\x01") {
            throw new \Erebot\InvalidValueException(
                'Bad subnegociation version'
            );
        }

        if ($line[1] != "\x00") {
            throw new \Erebot\InvalidValueException('Bad username or password');
        }
    }
protected function userpass(\Erebot\URIInterface $proxyURI)
    {
        $username = $proxyURI->asParsedURL(PHP_URL_USER);
        $password = $proxyURI->asParsedURL(PHP_URL_PASS);

        if ($username === null || $password === null) {
            throw new \Erebot\InvalidValueException(
                'No username or password supplied'
            );
        }

        $ulen = strlen($username);
        $plen = strlen($password);
        if ($ulen > 255) {
            throw new \Erebot\InvalidValueException(
                'Username too long (max. 255)'
            );
        }

        if ($plen > 255) {
            throw new \Erebot\InvalidValueException(
                'Password too long (max. 255)'
            );
        }

        $this->write(
            "\x01".pack(
                "Ca*Ca*",
                $ulen,
                $username,
                $plen,
                $password
            )
        );
        $line = $this->read(2);

        if ($line[0] != "\x01") {
            throw new \Erebot\InvalidValueException(
                'Bad subnegociation version'
            );
        }

        if ($line[1] != "\x00") {
            throw new \Erebot\InvalidValueException('Bad username or password');
        }
    }
protected function userpass ( \ Erebot \ URIInterface $ proxyURI ) { $ username = $ proxyURI -> asParsedURL ( PHP_URL_USER ) ; $ password = $ proxyURI -> asParsedURL ( PHP_URL_PASS ) ; if ( $ username === null || $ password === null ) { throw new \ Erebot \ InvalidValueException ( 'No username or password supplied' ) ; } $ ulen = strlen ( $ username ) ; $ plen = strlen ( $ password ) ; if ( $ ulen > 255 ) { throw new \ Erebot \ InvalidValueException ( 'Username too long (max. 255)' ) ; } if ( $ plen > 255 ) { throw new \ Erebot \ InvalidValueException ( 'Password too long (max. 255)' ) ; } $ this -> write ( "\x01" . pack ( "Ca*Ca*" , $ ulen , $ username , $ plen , $ password ) ) ; $ line = $ this -> read ( 2 ) ; if ( $ line [ 0 ] != "\x01" ) { throw new \ Erebot \ InvalidValueException ( 'Bad subnegociation version' ) ; } if ( $ line [ 1 ] != "\x00" ) { throw new \ Erebot \ InvalidValueException ( 'Bad username or password' ) ; } }
Does the authentication step.

\param Erebot::URIInterface $proxyURI
An object representing the URI of this SOCKS proxy server,
containing the credentials that will be sent during the
authentication step.
Does the authentication step .