unoconv / unoserver

MIT License
495 stars 69 forks source link

Unoserver PV6 Interface Support #104

Closed ReeceJones closed 1 month ago

ReeceJones commented 4 months ago

I have a project that is networked in a way that requires IPV6 and does not support IPV4. Currently, the unoserver command only supports IPV4 network interfaces, because the SimpleXMLRPCServer class assumes an IPV4 networking stack.

I would greatly appreciate if this project natively supported IPV6 and would be happy to take on the implementation of IPV6 support.

I suggest a new implementation of SimpleXMLRPCServer which resolves address information in the constructor and sets the socket settings accordingly to support both IPV4 and IPV6 address families. For example:

import socket
import xmlrpc.server

class XMLRPCServer(xmlrpc.server.SimpleXMLRPCServer):
    def __init__(self, addr: tuple[str, int], requestHandler: xmlrpc.server.SimpleXMLRPCRequestHandler = ..., logRequests: bool = True, allow_none: bool = False, encoding: str | None = None, bind_and_activate: bool = True, use_builtin_types: bool = False) -> None:
        addr_info = socket.getaddrinfo(addr[0], addr[1], proto=socket.IPPROTO_TCP)

        if len(addr_info) == 0:
            raise Exception('Failed to resolve address')

        self.address_family = addr_info[0][0]
        self.socket_type = addr_info[0][1]
        super().__init__(addr_info[0][4], requestHandler, logRequests, allow_none, encoding, bind_and_activate, use_builtin_types)

with XMLRPCServer(('::', 8000)) as server:
    print('Server is running...')
regebro commented 4 months ago

A merge request with IPV6 support would be greatly appreciated.

ReeceJones commented 4 months ago

Cool beans! I created a PR to add IPV6 support in #105.

regebro commented 1 month ago

Merged