-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathbeacon_server
executable file
·62 lines (57 loc) · 2.69 KB
/
beacon_server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/python3
# Copyright 2014 ETH Zurich
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Stdlib
import argparse
import logging
import os
# SCION
from beacon_server.core import CoreBeaconServer
from beacon_server.local import LocalBeaconServer
from lib.app.sciond import get_default_sciond_path
from lib.defines import TOPO_FILE
from lib.log import init_logging, log_exception
from lib.main import main_wrapper
from lib.topology import Topology
from lib.util import handle_signals, trace
def beacon_default():
handle_signals()
parser = argparse.ArgumentParser()
parser.add_argument('--log_dir', default="logs/", help='Log dir (Default: logs/)')
parser.add_argument('--spki_cache_dir', default="gen-cache/",
help='Cache dir for SCION TRCs and cert chains (Default: gen-cache/)')
parser.add_argument('--prom', type=str, help='Address to export prometheus metrics on')
parser.add_argument('--sciond_path', type=str, help='Sciond socket path '
'(Default: %s)' % get_default_sciond_path())
parser.add_argument('--filter_isd_loops', default=False, action='store_true',
help='Filter ISD loops in Core Beacon Server (Default: False)')
parser.add_argument('server_id', help='Server identifier')
parser.add_argument('conf_dir', nargs='?', default='.',
help='Configuration directory (Default: ./)')
args = parser.parse_args()
init_logging(os.path.join(args.log_dir, args.server_id))
# Load the topology to check if this is a core AD or not
topo = Topology.from_file(os.path.join(args.conf_dir, TOPO_FILE))
if topo.is_core_as:
inst = CoreBeaconServer(args.server_id, args.conf_dir, prom_export=args.prom,
sciond_path=args.sciond_path,
spki_cache_dir=args.spki_cache_dir, filter_isd_loops=args.filter_isd_loops)
else:
inst = LocalBeaconServer(args.server_id, args.conf_dir,
prom_export=args.prom,
sciond_path=args.sciond_path,
spki_cache_dir=args.spki_cache_dir)
logging.info("Started %s", args.server_id)
inst.run()
main_wrapper(beacon_default)