Skip to content

Commit

Permalink
chg: [D4Server] add server port in config
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrtia committed Mar 31, 2021
1 parent cbb90c0 commit 39d5933
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions server/configs/server.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use_default_save_directory = yes
save_directory = None

[D4_Server]
server_port=4443
# registration or shared-secret
server_mode = registration
default_hmac_key = private key to change
Expand Down
14 changes: 12 additions & 2 deletions server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import logging
import logging.handlers

import configparser

from twisted.internet import ssl, task, protocol, endpoints, defer
from twisted.python import log
from twisted.python.modules import getModule
Expand Down Expand Up @@ -45,8 +47,16 @@
redis_server_metadata = config_loader.get_redis_conn("Redis_METADATA", decode_responses=False)

# get server_mode
try:
D4server_port = config_loader.get_config_int("D4_Server", "server_port")
except configparser.NoOptionError:
D4server_port = 4443

server_mode = config_loader.get_config_str("D4_Server", "server_mode")
hmac_key = config_loader.get_config_str("D4_Server", "default_hmac_key")
try:
hmac_key = config_loader.get_config_str("D4_Server", "default_hmac_key")
except configparser.NoOptionError:
hmac_key = 'private key to change'

config_loader = None
### ###
Expand Down Expand Up @@ -555,7 +565,7 @@ def main(reactor):
certificate = ssl.PrivateCertificate.loadPEM(certData)
factory = protocol.Factory.forProtocol(D4_Server)
# use interface to support both IPv4 and IPv6
reactor.listenSSL(4443, factory, certificate.options(), interface='::')
reactor.listenSSL(D4server_port, factory, certificate.options(), interface='::')
return defer.Deferred()


Expand Down

0 comments on commit 39d5933

Please sign in to comment.