-
Notifications
You must be signed in to change notification settings - Fork 22
Fix node remote address #50
base: master
Are you sure you want to change the base?
Conversation
Connection/Connection.php
Outdated
@@ -650,7 +656,14 @@ public function isRemoteAddressConsidered() | |||
*/ | |||
public function getRemoteAddress() | |||
{ | |||
return $this->_remoteAddress; | |||
$stream = $this->getStream(); | |||
$streamId = (int) $stream; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure this is unique? Maybe spl_object_hash
would be a better alternative?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stream is a php resource, and the integer attributed to a php resource is unique within the same process execution. (even through a fork)
Connection/Connection.php
Outdated
* | ||
* @var string | ||
*/ | ||
protected $_remoteAddress = null; | ||
protected $_remotesAddress = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we store this information in a node instead? Open question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's something possible, maybe much appropriate, I need to test if this may have issues related to a pool of nodes.
ping? |
Thanks for the reminder, I will check soon for implement into the node. |
@Hywan I've made change in order to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure stream_socket_get_name
is strictly equivalent to the $address
argument of stream_socket_recvfrom
?
Connection/Connection.php
Outdated
@@ -355,7 +347,8 @@ public function quietAndMute() | |||
*/ | |||
public function disconnect() | |||
{ | |||
$this->_disconnect = $this->close(); | |||
$this->close(); | |||
$this->_disconnect = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
close()
return void and _disconnect
expect to be a boolean
Connection/Connection.php
Outdated
return null; | ||
} | ||
|
||
return $this->_node->getPeerName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why introducing a new vocabulary word (peer vs. remote)? No troll, real question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because the original method behind are stream_socket_get_name
and the second argument is called want_peer
in php doc
@Hywan address on |
I've a concern regarding the implementation of new method |
Options regarding possible BC break.
@hoaproject/hoackers thought? |
There is already an abstract node class: I don't like having |
Vote for Break it 👍 |
@Hywan Ping status?, I have another PR that will concerne same piece of code. |
Now that |
48bc77a
to
e86facc
Compare
This PR fix the bug related to the remote address of a connection.