config: cleanup LISTEN_INTERFACE and LISTEN_PORT

parent c78bb9f2
......@@ -108,8 +108,8 @@ docker-compose build
All has default values.
```
LISTEN_INTERFACE
LISTEN_ADDR
BEIRAN_LISTEN_INTERFACE
BEIRAN_LISTEN_ADDRESS
BEIRAN_HOSTNAME
BEIRAN_SOCKET_FILE
```
......
......@@ -293,6 +293,18 @@ class Config(metaclass=ConfigMeta):
"""
return self.get_config('beiran.hostname', 'HOSTNAME')
@property
def listen_interface(self):
"""
Beiran daemon's interface. The default value is ``None``
config.toml: section ``beiran``, key ``listen_interface``
Environment variable: ``BEIRAN_LISTEN_INTERFACE``
"""
return self.get_config('beiran.listen_interface', 'LISTEN_INTERFACE')
@property
def known_nodes(self):
"""
......
......@@ -56,8 +56,7 @@ def local_node_uuid() -> UUID:
if LOCAL_NODE_UUID_CACHED:
return LOCAL_NODE_UUID_CACHED
config_folder = config.config_dir
uuid_conf_path = "/".join([config_folder, 'uuid.conf'])
uuid_conf_path = "/".join([config.config_dir, 'uuid.conf'])
try:
uuid_file = open(uuid_conf_path)
uuid_hex = uuid_file.read()
......@@ -119,7 +118,7 @@ def get_listen_interface() -> str:
"""
Seek for listen interface in order described below and return it.
First try LISTEN_INTERFACE env var.
First try BEIRAN_LISTEN_INTERFACE env var.
Second try to find the interface of ip address specified by config.listen_address.
Third, if config.listen_address is not set return default gateway's interface
......@@ -128,8 +127,8 @@ def get_listen_interface() -> str:
"""
if 'LISTEN_INTERFACE' in os.environ:
return os.environ['LISTEN_INTERFACE']
if config.listen_interface:
return config.listen_interface
if config.listen_address:
for interface in netifaces.interfaces():
......@@ -146,7 +145,7 @@ def get_listen_interface() -> str:
def get_advertise_address() -> str:
"""
First try environment variable `ADVERTISE_ADDR`. If it is not set,
First try environment variable `BEIRAN_LISTEN_ADDRESS`. If it is not set,
return the listen address unless it is `0.0.0.0`.
Lastly return default gateway's ip address
......@@ -159,10 +158,6 @@ def get_advertise_address() -> str:
string: ip address of advertise address
"""
if 'ADVERTISE_ADDR' in os.environ:
return os.environ['ADVERTISE_ADDR']
listen_address = get_listen_address()
if listen_address != '0.0.0.0':
......
......@@ -70,7 +70,7 @@ export BEIRAN_SOCKET_FILE=${BEIRAN_RUN_DIR}/beirand.sock
export BEIRAN_PORT=${BEIRAN_PORT:-8888}
export BEIRAN_URL=http://localhost:${BEIRAN_PORT}
export BEIRAN_DB_FILE=${DIR}/beiran.db
export LISTEN_ADDR=0.0.0.0
export BEIRAN_LISTEN_ADDRESS=0.0.0.0
export BEIRAN_CONFIG_DIR=${DIR}
function ps1_context {
......
......@@ -11,7 +11,7 @@ services:
environment:
- BEIRAN_DISCOVERY_METHOD=dns
- BEIRAN_DISCOVERY_DNS_CONFIG='discovery_service_address=beiran_dns'
- BEIRAN_LISTEN_ADDR=0.0.0.0
- BEIRAN_LISTEN_ADDRESS=0.0.0.0
- BEIRAN_LOG_LEVEL=INFO
networks:
......
......@@ -24,7 +24,7 @@ services:
environment:
- BEIRAN_DISCOVERY_METHOD=zeroconf
- BEIRAN_PLUGINS=discovery.zeroconf,package.docker
- BEIRAN_LISTEN_ADDR=0.0.0.0
- BEIRAN_LISTEN_ADDRESS=0.0.0.0
pod2:
......@@ -51,7 +51,7 @@ services:
environment:
- BEIRAN_DISCOVERY_METHOD=zeroconf
- BEIRAN_PLUGINS=discovery.zeroconf,package.docker
- BEIRAN_LISTEN_ADDR=0.0.0.0
- BEIRAN_LISTEN_ADDRESS=0.0.0.0
pod3:
......@@ -78,7 +78,7 @@ services:
environment:
- BEIRAN_DISCOVERY_METHOD=zeroconf
- BEIRAN_PLUGINS=discovery.zeroconf,package.docker
- BEIRAN_LISTEN_ADDR=0.0.0.0
- BEIRAN_LISTEN_ADDRESS=0.0.0.0
pod4:
image: gcr.io/google_containers/pause:0.8.0
......@@ -104,7 +104,7 @@ services:
environment:
- BEIRAN_DISCOVERY_METHOD=zeroconf
- BEIRAN_PLUGINS=discovery.zeroconf,package.docker
- BEIRAN_LISTEN_ADDR=0.0.0.0
- BEIRAN_LISTEN_ADDRESS=0.0.0.0
networks:
test:
......@@ -23,7 +23,7 @@ services:
environment:
- BEIRAN_DISCOVERY_METHOD=zeroconf
- BEIRAN_PLUGINS=discovery.zeroconf,package.docker
- BEIRAN_LISTEN_ADDR=0.0.0.0
- BEIRAN_LISTEN_ADDRESS=0.0.0.0
pod2:
......@@ -49,7 +49,7 @@ services:
environment:
- BEIRAN_DISCOVERY_METHOD=zeroconf
- BEIRAN_PLUGINS=discovery.zeroconf,package.docker
- BEIRAN_LISTEN_ADDR=0.0.0.0
- BEIRAN_LISTEN_ADDRESS=0.0.0.0
pod3:
......@@ -75,7 +75,7 @@ services:
environment:
- BEIRAN_DISCOVERY_METHOD=zeroconf
- BEIRAN_PLUGINS=discovery.zeroconf,package.docker
- BEIRAN_LISTEN_ADDR=0.0.0.0
- BEIRAN_LISTEN_ADDRESS=0.0.0.0
pod4:
image: gcr.io/google_containers/pause:0.8.0
......@@ -100,7 +100,7 @@ services:
environment:
- BEIRAN_DISCOVERY_METHOD=zeroconf
- BEIRAN_PLUGINS=discovery.zeroconf,package.docker
- BEIRAN_LISTEN_ADDR=0.0.0.0
- BEIRAN_LISTEN_ADDRESS=0.0.0.0
networks:
test:
......@@ -9,7 +9,7 @@ services:
- .:/src
environment:
- BEIRAN_DISCOVERY_METHOD=zeroconf
- BEIRAN_LISTEN_ADDR=0.0.0.0
- BEIRAN_LISTEN_ADDRESS=0.0.0.0
- BEIRAN_LISTEN_PORT=8889
- BEIRAN_LOG_LEVEL=INFO
......@@ -21,7 +21,7 @@ services:
- .:/src
environment:
- BEIRAN_DISCOVERY_METHOD=zeroconf
- BEIRAN_LISTEN_ADDR=0.0.0.0
- BEIRAN_LISTEN_ADDRESS=0.0.0.0
- BEIRAN_LOG_LEVEL=INFO
- BEIRAN_LISTEN_PORT=8890
......@@ -33,6 +33,6 @@ services:
- .:/src
environment:
- BEIRAN_DISCOVERY_METHOD=zeroconf
- BEIRAN_LISTEN_ADDR=0.0.0.0
- BEIRAN_LISTEN_ADDRESS=0.0.0.0
- BEIRAN_LOG_LEVEL=INFO
- BEIRAN_LISTEN_PORT=8891
......@@ -15,6 +15,6 @@ services:
network_mode: host
environment:
- BEIRAN_DISCOVERY_METHOD=zeroconf
- BEIRAN_LISTEN_ADDR=0.0.0.0
- BEIRAN_LISTEN_ADDRESS=0.0.0.0
- BEIRAN_DISCOVERY_DNS_CONFIG='discovery_service_address=beirand'
- BEIRAN_LOG_LEVEL=INFO
......@@ -13,7 +13,7 @@ services:
# network_mode: host
environment:
- BEIRAN_DISCOVERY_METHOD=zeroconf
- BEIRAN_LISTEN_ADDR=0.0.0.0
- BEIRAN_LISTEN_ADDRESS=0.0.0.0
- BEIRAN_LISTEN_PORT=8892
- BEIRAN_LOG_LEVEL=INFO
# - BEIRAN_HOSTNAME=b1
......@@ -35,7 +35,7 @@ services:
# network_mode: host
environment:
- BEIRAN_DISCOVERY_METHOD=zeroconf
- BEIRAN_LISTEN_ADDR=0.0.0.0
- BEIRAN_LISTEN_ADDRESS=0.0.0.0
- BEIRAN_LISTEN_PORT=8891
- BEIRAN_LOG_LEVEL=INFO
# - BEIRAN_HOSTNAME=b2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment