commands: Allow servers to be added using the full URL.
This commit is contained in:
parent
dc34a5bef9
commit
cc0ccd6dba
1 changed files with 16 additions and 5 deletions
|
@ -33,6 +33,11 @@ from .utf import utf8_decode
|
||||||
from .utils import key_from_value
|
from .utils import key_from_value
|
||||||
from .uploads import UploadsBuffer, Upload
|
from .uploads import UploadsBuffer, Upload
|
||||||
|
|
||||||
|
try:
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
except ImportError:
|
||||||
|
from urlparse import urlparse
|
||||||
|
|
||||||
|
|
||||||
class ParseError(Exception):
|
class ParseError(Exception):
|
||||||
pass
|
pass
|
||||||
|
@ -1400,7 +1405,7 @@ def matrix_command_help(args):
|
||||||
" delete: delete a server\n"
|
" delete: delete a server\n"
|
||||||
"server-name: server to reconnect (internal name)\n"
|
"server-name: server to reconnect (internal name)\n"
|
||||||
" hostname: name or IP address of server\n"
|
" hostname: name or IP address of server\n"
|
||||||
" port: port of server (default: 8448)\n"
|
" port: port of server (default: 443)\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Examples:"
|
"Examples:"
|
||||||
"\n /matrix server listfull"
|
"\n /matrix server listfull"
|
||||||
|
@ -1618,10 +1623,16 @@ def matrix_server_command_add(args):
|
||||||
SERVERS[server.name] = server
|
SERVERS[server.name] = server
|
||||||
|
|
||||||
if len(args) >= 2:
|
if len(args) >= 2:
|
||||||
try:
|
if args[1].startswith("http"):
|
||||||
host, port = args[1].split(":", 1)
|
homeserver= urlparse(args[1])
|
||||||
except ValueError:
|
|
||||||
host, port = args[1], None
|
host = homeserver.hostname
|
||||||
|
port = str(homeserver.port) if homeserver.port else None
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
host, port = args[1].split(":", 1)
|
||||||
|
except ValueError:
|
||||||
|
host, port = args[1], None
|
||||||
|
|
||||||
return_code = W.config_option_set(
|
return_code = W.config_option_set(
|
||||||
server.config._option_ptrs["address"], host, 1
|
server.config._option_ptrs["address"], host, 1
|
||||||
|
|
Loading…
Add table
Reference in a new issue