From b37b367f835ae9c4e7bbe779287d87f416de2f30 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Thu, 25 Mar 2021 09:25:00 +0100 Subject: [PATCH] Use GRE tunnel for multiples IPs --- omr-admin.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/omr-admin.py b/omr-admin.py index dbbca9d..802136e 100755 --- a/omr-admin.py +++ b/omr-admin.py @@ -45,7 +45,7 @@ from fastapi.openapi.docs import get_swagger_ui_html from fastapi.openapi.models import OAuthFlows as OAuthFlowsModel from fastapi.openapi.utils import get_openapi from fastapi.openapi.models import SecurityBase as SecurityBaseModel -from fastapi.responses import StreamingResponse +from fastapi.responses import StreamingResponse, FileResponse from pydantic import BaseModel, ValidationError # pylint: disable=E0611 from starlette.status import HTTP_403_FORBIDDEN from starlette.responses import RedirectResponse, Response, JSONResponse @@ -404,6 +404,7 @@ def add_gre_tunnels(): if not '# OMR GRE for public IP ' + str(addr) + ' for user ' + str(user) in line: n.write(line) n.write('SNAT(' + str(addr) + ') ' + str(network) + ' ' + str(iface) + ' # OMR GRE for public IP ' + str(addr) + ' for user ' + str(user) + "\n") + n.write('SNAT(' + str(list(network)[1]) + ') - ' + gre_intf + ' # OMR GRE for public IP ' + str(addr) + ' for user ' + str(user) + "\n") os.close(fd) move(tmpfile, '/etc/shorewall/snat') #fd, tmpfile = mkstemp() @@ -642,8 +643,8 @@ def shorewall_add_port(user, port, proto, name, fwtype='ACCEPT', source_dip='', if fwtype == 'ACCEPT': n.write('ACCEPT ' + net + ' $FW ' + proto + ' ' + port + ' - ' + source_dip + ' # OMR ' + user.username + ' open ' + name + ' port ' + proto + comment + "\n") elif fwtype == 'DNAT' and vpn != 'default': - #n.write('DNAT ' + net + ' vpn:' + vpn + ' ' + proto + ' ' + port + ' - ' + source_dip + ' # OMR ' + user.username + ' redirect ' + name + ' port ' + proto + comment + "\n") - n.write('DNAT ' + net + ' vpn:$OMR_ADDR' + ' ' + proto + ' ' + port + ' - ' + source_dip + ' # OMR ' + user.username + ' redirect ' + name + ' port ' + proto + comment + "\n") + n.write('DNAT ' + net + ' vpn:' + vpn + ' ' + proto + ' ' + port + ' - ' + source_dip + ' # OMR ' + user.username + ' redirect ' + name + ' port ' + proto + comment + "\n") + #n.write('DNAT ' + net + ' vpn:$OMR_ADDR' + ' ' + proto + ' ' + port + ' - ' + source_dip + ' # OMR ' + user.username + ' redirect ' + name + ' port ' + proto + comment + "\n") elif fwtype == 'DNAT' and userid == 0: n.write('DNAT ' + net + ' vpn:$OMR_ADDR ' + proto + ' ' + port + ' - ' + source_dip + ' # OMR ' + user.username + ' redirect ' + name + ' port ' + proto + comment + "\n") elif fwtype == 'DNAT' and userid != 0: