works enough for now
This commit is contained in:
commit
c04a9a752a
12 changed files with 178 additions and 0 deletions
27
compiler/parser.py
Normal file
27
compiler/parser.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import yaml
|
||||
from .models import GlobalConfig, Service
|
||||
|
||||
def load_services(path: str) -> list[Service]:
|
||||
raw = yaml.safe_load(open(path))["services"]
|
||||
|
||||
services = []
|
||||
for name, s in raw.items():
|
||||
ip, port = s["endpoint"].split(":")
|
||||
services.append(Service(
|
||||
name=name,
|
||||
internal_ip=ip,
|
||||
internal_port=int(port),
|
||||
public_port=int(s["public_port"]),
|
||||
protocol=s["protocol"],
|
||||
exposure=set(s.get("exposure", [])),
|
||||
))
|
||||
return(services)
|
||||
|
||||
def load_globals(path: str) -> GlobalConfig:
|
||||
g = yaml.safe_load(open(path))["wan"]
|
||||
return GlobalConfig(
|
||||
wan_interface=g["wan_interface"],
|
||||
public_ip=g["public_ip"],
|
||||
lan_interface=g["lan_interface"],
|
||||
internal_cidr=g["internal_cidr"],
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue