mindflayer / python-mocket

a socket mock framework - for all kinds of socket animals, web-clients included
BSD 3-Clause "New" or "Revised" License
280 stars 42 forks source link

Some options not implemented in MocketSocket #142

Closed fvigo closed 2 years ago

fvigo commented 3 years ago

Describe the bug When using mocked sockets in some conditions, certain socket properties are not properly implemented.

  1. In AF_INET6 scenarios (IPv6 connection), address can be a tuple of four elements (see https://docs.python.org/3/library/socket.html#socket-families ), but the current implementation only takes tuples with 2 arguments. For example socket.connect((host, port, 0, 0)) should not throw an error.
  2. The socket type argument of getaddrinfo() is called type ( https://docs.python.org/3/library/socket.html#socket.getaddrinfo ) and not socktype as implemented here: https://github.com/mindflayer/python-mocket/blob/bce7cde62177bb23008ff57c84faaca1294b645d/mocket/mocket.py#L458
mindflayer commented 3 years ago

There is no support for IPv6 at the moment, feel free to help. For this I will definitely need to fix the CI before merging to master, though, but still no answers from Travis...

fvigo commented 3 years ago

Have you considered trying GitHub actions?

mindflayer commented 3 years ago

Yes, that would be the alternative. Edit: DONE!

mindflayer commented 3 years ago

Hi @fvigo, were you thinking to propose a PR related to this issue? Otherwise I'll have a look at it in the near future.

fvigo commented 3 years ago

Hi @mindflayer , sorry for the delayed response. I found a solution that allowed me to continue without requiring a change to mocket.

For IPV6 support, I think should be considered an enhancement, but the issues described here might create problems with the socket API.

They should be both easy fixes: allow MocketSocket.connect() to support tuples of 4 elements, and rename socktype to type in getaddrinfo. However, I'd recommend for you to take a look at those as, especially the latter, might maybe break some compatibility.