mirror of
https://github.com/beetbox/beets.git
synced 2025-12-25 01:53:31 +01:00
password half-implemented
--HG-- extra : convert_revision : svn%3A41726ec3-264d-0410-9c23-a9f1637257cc/trunk%40167
This commit is contained in:
parent
585141ce5b
commit
2e21cd93a5
2 changed files with 14 additions and 6 deletions
|
|
@ -44,6 +44,11 @@ ERROR_EXIST = 56
|
|||
VOLUME_MIN = 0
|
||||
VOLUME_MAX = 100
|
||||
|
||||
SAFE_COMMANDS = (
|
||||
# Commands that should be available when unauthenticated.
|
||||
'close', 'commands', 'notcommands', 'password', 'ping',
|
||||
)
|
||||
|
||||
|
||||
# Logger.
|
||||
log = logging.getLogger('bpd')
|
||||
|
|
@ -169,11 +174,12 @@ class BaseServer(object):
|
|||
This is a generic superclass and doesn't support many commands.
|
||||
"""
|
||||
|
||||
def __init__(self, host='', port=DEFAULT_PORT):
|
||||
def __init__(self, host='', port=DEFAULT_PORT, password=''):
|
||||
"""Create a new server bound to address `host` and listening
|
||||
on port `port`.
|
||||
on port `port`. If `password` is given, it is required to do
|
||||
anything significant on the server.
|
||||
"""
|
||||
self.host, self.port = host, port
|
||||
self.host, self.port, self.password = host, port, password
|
||||
|
||||
# Default server values.
|
||||
self.random = False
|
||||
|
|
@ -644,9 +650,9 @@ class Server(BaseServer):
|
|||
to store its library.
|
||||
"""
|
||||
|
||||
def __init__(self, library, host='', port=DEFAULT_PORT):
|
||||
def __init__(self, library, host='', port=DEFAULT_PORT, password=''):
|
||||
from beets.player.gstplayer import GstPlayer
|
||||
super(Server, self).__init__(host, port)
|
||||
super(Server, self).__init__(host, port, password)
|
||||
self.lib = library
|
||||
self.player = GstPlayer(self.play_finished)
|
||||
|
||||
|
|
|
|||
4
bts
4
bts
|
|
@ -11,6 +11,7 @@ CONFIG_DEFAULTS = {
|
|||
# bpd
|
||||
'host': '',
|
||||
'port': '6600',
|
||||
'password': '',
|
||||
}
|
||||
|
||||
CONFIG_FILE = os.path.expanduser('~/.beetsrc')
|
||||
|
|
@ -73,9 +74,10 @@ def bpd(lib, config, opts):
|
|||
host = host if host else config.get('bpd', 'host')
|
||||
port = int(opts.pop(0)) if opts else None
|
||||
port = port if port else config.getint('bpd', 'port')
|
||||
password = config.get('bpd', 'password')
|
||||
|
||||
from beets.player.bpd import Server
|
||||
Server(lib, host, port).run()
|
||||
Server(lib, host, port, password).run()
|
||||
|
||||
if __name__ == "__main__":
|
||||
# parse options
|
||||
|
|
|
|||
Loading…
Reference in a new issue