21 namespace Erebot\Identd;
31 \Erebot\Interfaces\SendingConnection,
32 \Erebot\Interfaces\ReceivingConnection
60 throw new \Erebot\InvalidValueException(
'Not a valid socket');
64 $this->io = new \Erebot\LineIO(
75 public function connect()
79 public function disconnect($quitMessage = null)
81 $this->bot->removeConnection($this);
82 if ($this->socket !== null) {
83 stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR);
88 public function read()
90 return $this->io->read();
96 if (!$this->io->inReadQueue()) {
102 $this->io->push($line);
106 $this->bot->removeConnection($this);
125 if (!is_string($line)) {
129 $parts = array_map(
'trim', explode(
',', $line));
130 if (count($parts) != 2) {
134 $line = implode(
" , ", $parts);
135 if (!ctype_digit($parts[0]) || !ctype_digit($parts[1])) {
136 return $line .
" : ERROR : INVALID-PORT";
139 $cport = (int) $parts[0];
140 $sport = (int) $parts[1];
142 if ($sport <= 0 || $sport > 65535 || $cport <= 0 || $cport > 65535) {
143 return $line .
" : ERROR : INVALID-PORT";
146 foreach ($this->bot->getConnections() as $connection) {
147 if ($connection == $this) {
151 $socket = $connection->getSocket();
153 $rport = (int) substr(strrchr(stream_socket_get_name(
$socket,
true),
':'), 1);
154 if ($rport != $sport) {
158 $lport = (int) substr(strrchr(stream_socket_get_name(
$socket,
false),
':'), 1);
159 if ($lport != $cport) {
164 $config = $connection->getConfig(null);
165 $identity = $config->parseString(
166 '\\Erebot\\Module\\IrcConnector',
170 return $line .
" : USERID : UNIX : " . $identity;
171 }
catch (\Erebot\Exception $e) {
172 return $line .
" : ERROR : HIDDEN-USER ";
176 return $line .
" : ERROR : NO-USER";
179 public function isConnected()
184 public function getSocket()
189 public function write()
193 public function getBot()
198 public function getConfig($chan)
203 public function getIO()
const EOL_WIN
Windows line-ending.
$socket
The underlying socket, represented as a stream.
Provides core functionalities for Erebot.
process()
Processes commands queued in the input buffer.
A worker process for the Identification Protocol (RFC 1413).
$bot
A bot object implementing the Erebot::Interfaces::Core interface.
__construct(\Erebot\Interfaces\Core $bot, $socket)
$io
I/O manager for the socket.