-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand the IP Address reporting capabilities #27731
Conversation
Currently the IP_Address and the IP._get_local_addresses method only report the ip addresses of the adapters available on the device. The results do not give information on which adapter the ip address is associated with, nor the type of address, e.g. TYPE_IPV4 or TYPE_IPV6. This change adds a new method IP._get_local_addresses_full that reports more information about each ip address on the adapters. The method results an array of dictionary objects with the following information: 'adapter' name 'friendly' adapter name ip 'address' 'type' of address, e.g. TYPE_IPV4 or TYPE_IPV6. Additionally, the NetworkedMultiplayerENet has methods to return the address of a peer, but does not provide the address of peer 1. This chane also adds two ne methods to the NetworkedMultiplayerENet objects to retrieve the bound ip address of the host or client, e.g. the bind_ip. get_bind_address retrieves the bind address get_bind_port retrieves the bind port.
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.
Hi @thzero . First of all thank you for your interest in Godot Engine.
While the capability of extracting more detailed information for available network interfaces is a wanted capability (and it will be needed soon as we plan to support extracting multicast addresses for example), this PR has 2 main problems I can see.
- The change is implemented for Windows and Unixes, but it seems not to take into account UWP (Universal Windows Platform), which has a separate function for collecting those info and was not modified.
godot/drivers/unix/ip_unix.cpp
Lines 132 to 135 in 5fc8602
void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const { using namespace Windows::Networking; using namespace Windows::Networking::Connectivity; - More importantly, those informations should not be stored in
IP_Address
. Probably, a dedicated struct should be defined inIP
(e.g.struct InterfaceInfo
) that contains theIPAddress
, the adapter name, the friendly name (and in the future, adapter index, and list of multicast addreses).
A list of those struct should then be returned by a new virtualget_interfaces_info
inIP
(implemented for all platforms inIP_Unix
) and reused byget_local_addresses
(which can then be moved toIP
fromIP_Unix
) flattening that result to a list ofIP_Address
.
Furthermore, can you please remove the enet changes from this PR and create a new one for those changes only?
core/io/ip_address.cpp
Outdated
@@ -40,6 +40,9 @@ IP_Address::operator Variant() const { | |||
|
|||
IP_Address::operator String() const { | |||
|
|||
if (wildcard) | |||
return "wildcard"; |
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.
Use "*"
instead for compatibility.
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.
Will do.
@Faless so made changes to create a Interface_Info struct. Having issues with the UWP (not really wanting to install VS2015) so haven't had chance to compile let alone test it. |
@thzero few things:
PS: We it's ready I can test it with UWP (and fix it if something is wrong). I'll wait till the PR is ready, and CI checks pass. |
I'm also not sure why you chose to have a struct that way, with setters/getters and the like. |
Ok, refactored based on your recommendations. |
@thzero can you apply the following patch? (I known it's quite big, I'm trying to avoid duplicating code for interfaces and addresses):
|
Sounds good... might be a day or two with Easter and all upcoming |
Bump :) |
The commits will need to be squashed together too. |
Superseded by #29935. |
Currently the IP_Address and the IP._get_local_addresses method only
report the ip addresses of the adapters available on the device. The
results do not give information on which adapter the ip address is
associated with, nor the type of address, e.g. TYPE_IPV4 or TYPE_IPV6.
This change adds a new method IP._get_local_addresses_full that reports
more information about each ip address on the adapters. The method
results an array of dictionary objects with the following information:
'adapter' name
'friendly' adapter name
ip 'address'
'type' of address, e.g. TYPE_IPV4 or TYPE_IPV6.
Additionally, the NetworkedMultiplayerENet has methods to return the
address of a peer, but does not provide the address of peer 1.
This chane also adds two ne methods to the NetworkedMultiplayerENet
objects to retrieve the bound ip address of the host or client, e.g.
the bind_ip.
get_bind_address retrieves the bind address
get_bind_port retrieves the bind port.