· 4 years ago · Apr 30, 2021, 01:06 PM
1///////
2UI config
3///////
4
5
6# -*- encoding: utf-8 -*-
7"""
8License: MIT
9Copyright (c) 2019 - present AppSeed.us
10"""
11
12import os
13from os import environ
14
15class Config(object):
16
17 basedir = os.path.abspath(os.path.dirname(__file__))
18
19 SECRET_KEY = 'key'
20
21 # This will connect to the FTS db
22 SQLALCHEMY_DATABASE_URI = 'sqlite:///' + '/root/FTSDataBase.db'
23
24 # certificates path
25 certpath = "/usr/local/lib/python3.8/dist-packages/FreeTAKServer/certs/"
26
27 # crt file path
28 crtfilepath = f"{certpath}pubserver.pem"
29
30 # key file path
31 keyfilepath = f"{certpath}pubserver.key.unencrypted"
32
33 # this IP will be used to connect with the FTS API
34 IP = '192.168.178.4'
35
36 # Port the UI uses to communicate with the API
37 PORT = '19023'
38
39 # the public IP your server is exposing
40 APPIP = '192.168.178.4'
41
42 # this port will be used to listen
43 APPPort = 5000
44
45 # the webSocket key used by the UI to communicate with FTS.
46 WEBSOCKETKEY = 'YourWebsocketKey'
47
48 # the API key used by the UI to comunicate with FTS. generate a new system user and then set it
49 APIKEY = 'Bearer token'
50
51 # For 'in memory' database, please use:
52 # SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'
53
54 SQLALCHEMY_TRACK_MODIFICATIONS = False
55
56 # THEME SUPPORT
57 # if set then url_for('static', filename='', theme='')
58 # will add the theme name to the static URL:
59 # /static/<DEFAULT_THEME>/filename
60 # DEFAULT_THEME = "themes/dark"
61 DEFAULT_THEME = None
62
63
64class ProductionConfig(Config):
65 DEBUG = False
66
67 # Security
68 SESSION_COOKIE_HTTPONLY = True
69 REMEMBER_COOKIE_HTTPONLY = True
70 REMEMBER_COOKIE_DURATION = 3600
71
72 # PostgreSQL database
73 SQLALCHEMY_DATABASE_URI = 'postgresql://{}:{}@{}:{}/{}'.format(
74 environ.get('APPSEED_DATABASE_USER', 'appseed'),
75 environ.get('APPSEED_DATABASE_PASSWORD', 'appseed'),
76 environ.get('APPSEED_DATABASE_HOST', 'db'),
77 environ.get('APPSEED_DATABASE_PORT', 5432),
78 environ.get('APPSEED_DATABASE_NAME', 'appseed')
79 )
80
81
82class DebugConfig(Config):
83 DEBUG = True
84
85
86config_dict = {
87 'Production': ProductionConfig,
88 'Debug': DebugConfig
89}
90
91
92
93
94
95///////
96server config
97///////
98
99
100import os
101
102currentPath = os.path.dirname(os.path.abspath(__file__))
103from pathlib import Path
104
105
106class MainConfig:
107 """
108 this is the main configuration file and is the only one which
109 should need to be changed
110 """
111 # this is the port to which clients will connect
112 CoTServicePort = int(os.environ.get('FTS_COT_PORT', 8087))
113
114 SSLCoTServicePort = int(os.environ.get('FTS_SSLCOT_PORT', 8089))
115
116 # this needs to be changed for private data packages to work
117 DataPackageServiceDefaultIP = str(os.environ.get('FTS_DP_ADDRESS', "192.168.178.4"))
118
119 # User Connection package IP needs to be set to the IP which is used when creating the connection in your tak device
120 UserConnectionIP = str(os.environ.get('FTS_USER_ADDRESS', "192.168.178.4"))
121
122 python_version = 'python3.8'
123
124 userpath = '/usr/local/lib/'
125
126 # api port
127 APIPort = os.environ.get('FTS_API_PORT', 19023)
128
129 # Federation port
130 FederationPort = os.environ.get('FTS_FED_PORT', 9000)
131
132 # api IP
133 APIIP = os.environ.get('FTS_API_ADDRESS', '192.168.178.4')
134
135 # allowed ip's to access CLI commands
136 AllowedCLIIPs = ['127.0.0.1']
137
138 # IP for CLI to access
139 CLIIP = '127.0.0.1'
140
141 # whether or not to save CoT's to the DB
142 SaveCoTToDB = bool(os.environ.get('FTS_COT_TO_DB', True))
143
144 # this should be set before startup
145
146 DBFilePath = str(os.environ.get('FTS_DATA_PATH', r'/root/') + "FTSDataBase.db")
147
148 # the version information of the server (recommended to leave as default)
149 version = 'FreeTAKServer-1.7.5 Public'
150
151 MainPath = str(os.environ.get('FTS_DATA_PATH',
152 Path(fr'{userpath}{python_version}/dist-packages/FreeTAKServer')))
153
154 ExCheckMainPath = str(Path(fr'{MainPath}/ExCheck'))
155
156 ExCheckFilePath = str(Path(fr'{MainPath}/ExCheck/template'))
157
158 ExCheckChecklistFilePath = str(Path(fr'{MainPath}/ExCheck/checklist'))
159
160 DataPackageFilePath = str(Path(fr'{MainPath}/FreeTAKServerDataPackageFolder'))
161
162 # format of API message header should be {Authentication: Bearer 'TOKEN'}
163 from uuid import uuid4
164 id = str(uuid4())
165
166 nodeID = os.environ.get('FTS_NODE_ID', f"FreeTAKServer-{id}")
167
168 # set to None if you don't want a message sent
169 ConnectionMessage = f'Welcome to FreeTAKServer {version}. The Parrot is not dead. It’s just resting'
170
171 certsPath = os.environ.get('FTS_CERTS_PATH', fr'{MainPath}/certs')
172
173 keyDir = str(Path(fr'{certsPath}/pubserver.key'))
174
175 pemDir = str(Path(fr'{certsPath}/pubserver.pem')) # or crt
176
177 unencryptedKey = str(Path(fr'{certsPath}/pubserver.key.unencrypted'))
178
179 p12Dir = str(Path(fr'{certsPath}/pubserver.p12'))
180
181 CA = str(Path(fr'{certsPath}/ca.pem'))
182 CAkey = str(Path(fr'{certsPath}/ca.key'))
183
184 federationCert = str(Path(fr'{certsPath}/pubserver.pem'))
185 federationKey = str(Path(fr'{certsPath}/pubserver.key'))
186 federationKeyPassword = str(os.environ.get('FTS_FED_PASSWORD','defaultpass'))
187
188 # location to backup client packages
189 clientPackages = str(Path(fr'{MainPath}/certs/ClientPackages'))
190
191 password = str(os.environ.get('FTS_PASSWORD', 'defaultpass'))
192
193 websocketkey = os.environ.get('FTS_WEBSOCKET_KEY', "YourWebsocketKey")
194
195
196
197
198
199
200