`srs_get_peer_ip` retrieves the client's address.
zxl8121 opened this issue · comments
Description'
Please ensure that the markdown structure is maintained.
Description'
Describe the problem you encountered.
The 'ip' inside 'on_play' is the local IP instead of the client player's IP.
Please ensure that the markdown structure is maintained.
Environment'
Please ensure that the markdown structure is maintained.
- SRS Version:
srs3.0
- Operating System:
centos7
'
Please ensure that the markdown structure is maintained.
Solution:
Change getsockname
to getpeername
.
Please ensure that the markdown structure is maintained.
TRANS_BY_GPT3
I also encountered the same problem. After using getpeername, it returns 0.0.0.0. How can I solve this? The system I am using is openSUSE.
TRANS_BY_GPT3
Originally it was getpeername, later changed to getsockname: link
I checked the manual and confirmed that getpeername should indeed be used.
int getpeername(int socket, struct sockaddr *restrict address, socklen_t *restrict address_len);
The getpeername() function returns the address of the peer connected to the specified socket.
int getsockname(int socket, struct sockaddr *restrict address, socklen_t *restrict address_len);
The getsockname() function returns the current address for the specified socket.
TRANS_BY_GPT3