mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-07-07 18:11:35 +02:00
new rules, new spawn logic, small fixes, default and narrow corridor debugged
This commit is contained in:
README.md
marl_factory_grid
__init__.py
reload_agent.pyalgorithms
configs
environment
modules
batteries
clean_up
destinations
doors
items
machines
maintenance
zones
utils
studies
transform_wg_to_json_no_priv.py
43
transform_wg_to_json_no_priv.py
Normal file
43
transform_wg_to_json_no_priv.py
Normal file
@ -0,0 +1,43 @@
|
||||
import configparser
|
||||
import json
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
|
||||
conf_path = Path('wg0')
|
||||
wg0_conf = configparser.ConfigParser()
|
||||
wg0_conf.read(conf_path/'wg0.conf')
|
||||
interface = wg0_conf['Interface']
|
||||
# Iterate all pears
|
||||
for client_name in wg0_conf.sections():
|
||||
if client_name == 'Interface':
|
||||
continue
|
||||
# Delete any old conf.json for the current peer
|
||||
(conf_path / f'{client_name}.json').unlink(missing_ok=True)
|
||||
|
||||
|
||||
peer = wg0_conf[client_name]
|
||||
|
||||
date_time = datetime.now().strftime('%Y-%m-%dT%H:%M:%S.%f000Z')
|
||||
|
||||
jdict = dict(
|
||||
id=client_name,
|
||||
private_key=peer['PublicKey'],
|
||||
public_key=peer['PublicKey'],
|
||||
# preshared_key=wg0_conf[client_name_wg0]['PresharedKey'],
|
||||
name=client_name,
|
||||
email=f"sysadmin@mobile.ifi.lmu.de",
|
||||
allocated_ips=[interface['Address'].replace('/24', '')],
|
||||
allowed_ips=['10.4.0.0/24', '10.153.199.0/24'],
|
||||
extra_allowed_ips=[],
|
||||
use_server_dns=True,
|
||||
enabled=True,
|
||||
created_at=date_time,
|
||||
updated_at=date_time
|
||||
)
|
||||
|
||||
with (conf_path / f'{client_name}.json').open('w+') as f:
|
||||
json.dump(jdict, f, indent='\t', separators=(',', ': '))
|
||||
print(client_name, ' written...')
|
Reference in New Issue
Block a user