Giter Site home page Giter Site logo

Comments (5)

chobie avatar chobie commented on June 16, 2024

The following is a document for CAPI, but it internally uses remoteAddress.
https://github.com/paullouisageneau/libdatachannel/blob/master/DOC.md#rtcgetremoteaddress

Retrieves the current remote address, i.e. the network address of the currently selected remote candidate. The address will have the format "IP_ADDRESS:PORT", where IP_ADDRESS may be either IPv4 or IPv6. The call may fail if the state is not RTC_CONNECTED, and the address might change after connection.

I think it would be good to search for ':' from the end and then split (like std::string::rfind).

It doesn't seem like there was a single API that returns the hostname or port number.
If necessary, wouldn't it be better to consider adding one?

from libdatachannel.

reischen80 avatar reischen80 commented on June 16, 2024

Following C++ WebSocket Class use the same implementation as CAPI
optional<string> remoteAddress() const;

I'd just like to know, why the result string have a strange form of "::ffff:105.11.31.26:9204", expected to be "105.11.31.26:9204". The last one will be easily to split and interpret.
It is a bug inside?

from libdatachannel.

chobie avatar chobie commented on June 16, 2024

The format ::ffff:x.x.x.x is used to maintain compatibility between IPv6 and IPv4, as far as I remember. For more details, I suggest referring to RFC 4291.

from libdatachannel.

reischen80 avatar reischen80 commented on June 16, 2024

Got it! Thanks!

from libdatachannel.

paullouisageneau avatar paullouisageneau commented on June 16, 2024

FYI this format is called IPv4-mapped IPv6 address. It can currently be returned by WebSocket::remoteAddress() if you listen on IPv6+IPv4 and the remote client connects over IPv4.

from libdatachannel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.