Browse Source

Merge pull request #7566 from SomberNight/202111_rpcsock_unix_default

daemon: change `rpcsock` default to "unix" where available
patch-4
ghost43 3 years ago
committed by GitHub
parent
commit
3e486b029c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      electrum/daemon.py

10
electrum/daemon.py

@ -33,6 +33,7 @@ from typing import Dict, Optional, Tuple, Iterable, Callable, Union, Sequence, M
from base64 import b64decode, b64encode
from collections import defaultdict
import json
import socket
import aiohttp
from aiohttp import web, client_exceptions
@ -64,7 +65,12 @@ class DaemonNotRunning(Exception):
def get_rpcsock_defaultpath(config: SimpleConfig):
return os.path.join(config.path, 'daemon_rpc_socket')
def get_rpcsock_default_type(osname):
def get_rpcsock_default_type():
# Use unix domain sockets when available,
# with the extra paranoia that in case windows "implements" them,
# we want to test it before making it the default there.
if hasattr(socket, 'AF_UNIX') and sys.platform != 'win32':
return 'unix'
return 'tcp'
def get_lockfile(config: SimpleConfig):
@ -245,7 +251,7 @@ class CommandsServer(AuthenticatedServer):
self.fd = fd
self.config = daemon.config
sockettype = self.config.get('rpcsock', 'auto')
self.socktype = sockettype if sockettype != 'auto' else get_rpcsock_default_type(os.name)
self.socktype = sockettype if sockettype != 'auto' else get_rpcsock_default_type()
self.sockpath = self.config.get('rpcsockpath', get_rpcsock_defaultpath(self.config))
self.host = self.config.get('rpchost', '127.0.0.1')
self.port = self.config.get('rpcport', 0)

Loading…
Cancel
Save