3 The registry server listens to broadcasts on UDP port 18812, answering to
4 discovery queries by clients and registering keepalives from all running
5 servers. In order for clients to use discovery, a registry service must
6 be running somewhere on their local network.
8 from plumbum import cli
9 from rpyc.utils.registry import REGISTRY_PORT, DEFAULT_PRUNING_TIMEOUT
10 from rpyc.utils.registry import UDPRegistryServer, TCPRegistryServer
11 from rpyc.lib import setup_logger
14 class RegistryServer(cli.Application):
15 mode = cli.SwitchAttr(["-m", "--mode"], cli.Set("UDP", "TCP"), default="UDP",
18 ipv6 = cli.Flag(["-6", "--ipv6"], help="use ipv6 instead of ipv4")
20 port = cli.SwitchAttr(["-p", "--port"], cli.Range(0, 65535), default=REGISTRY_PORT,
21 help="The UDP/TCP listener port")
23 logfile = cli.SwitchAttr(["--logfile"], str, default=None,
24 help="The log file to use; the default is stderr")
26 quiet = cli.SwitchAttr(["-q", "--quiet"], help="Quiet mode (only errors are logged)")
28 pruning_timeout = cli.SwitchAttr(["-t", "--timeout"], int,
29 default=DEFAULT_PRUNING_TIMEOUT, help="Set a custom pruning timeout (in seconds)")
32 if self.mode == "UDP":
33 server = UDPRegistryServer(host='::' if self.ipv6 else '0.0.0.0', port=self.port,
34 pruning_timeout=self.pruning_timeout)
35 elif self.mode == "TCP":
36 server = TCPRegistryServer(port=self.port, pruning_timeout=self.pruning_timeout)
37 setup_logger(self.quiet, self.logfile)
41 if __name__ == "__main__":