diff --git a/CHANGELOG.md b/CHANGELOG.md
index eed9453..8e2d1dd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
# Changelog
+## v1.0.4
+
+- Dodano ograniczanie dostępu do przekierowanych portów według adresów źródłowych IPv4.
+- Dodano edycję przekierowań i wybór adresu klienta z listy.
+
## v1.0.3
- Ograniczono odświeżanie panelu w ukrytych kartach i liczbę odczytów bazy danych.
diff --git a/README.md b/README.md
index db47dc3..7f0802a 100644
--- a/README.md
+++ b/README.md
@@ -26,6 +26,8 @@ Podczas tworzenia lub edycji sieci wybierz sposób nasłuchiwania i interfejs al
W **Ustawienia → Użytkownicy → Uprawnienia** administrator wybiera sieci dostępne dla użytkownika i dozwolone w nich działania. W **Serwer → Grupy publicznych adresów IPv4** można dodatkowo współdzielić adresy między sieciami.
+Przy dodawaniu lub edycji przekierowania portu można wybrać klienta z listy i ograniczyć dostęp do wskazanych adresów źródłowych IPv4. Kilka adresów należy oddzielić przecinkami; bez ograniczenia port jest dostępny ze wszystkich adresów.
+
## Aktualizacja
Pobierz pakiet `.bin` z wydania WGTools-Extended i wgraj go w ustawieniach panelu. Przed aktualizacją program tworzy kopię zapasową i kopię umożliwiającą przywrócenie poprzedniej wersji.
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 6b0acac..6613b9c 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -1 +1 @@
-Improves panel performance and reduces unnecessary background refreshes.
+Adds source IP restrictions, editing for port forwarding, and a client selector.
diff --git a/VERSION b/VERSION
index 21e8796..ee90284 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.3
+1.0.4
diff --git a/app/core/helper.py b/app/core/helper.py
index f5f651d..e07ebc8 100644
--- a/app/core/helper.py
+++ b/app/core/helper.py
@@ -45,6 +45,7 @@ ALLOWED_ACTIONS = {
"extended_ip_groups_set",
"extended_forward_get",
"extended_forward_add",
+ "extended_forward_update",
"extended_forward_delete",
"route_create",
"route_update",
@@ -87,7 +88,7 @@ def run_helper(action: str, payload: dict[str, Any] | None = None, *, interface:
# helper enough time to finish its transactional rollback/commit path
# instead of killing it mid-update.
timeout = 120
- elif action in {"raw_config_apply", "server_settings_apply", "extended_snat_apply", "extended_listen_apply", "extended_forward_add", "extended_forward_delete", "route_create", "route_update", "route_delete", "access_rule_create", "access_rule_update", "access_rule_delete"}:
+ elif action in {"raw_config_apply", "server_settings_apply", "extended_snat_apply", "extended_listen_apply", "extended_forward_add", "extended_forward_update", "extended_forward_delete", "route_create", "route_update", "route_delete", "access_rule_create", "access_rule_update", "access_rule_delete"}:
timeout = 90
elif action == "migration_backup_create":
timeout = 45
diff --git a/app/main.py b/app/main.py
index f360eac..8cd44cd 100644
--- a/app/main.py
+++ b/app/main.py
@@ -476,6 +476,12 @@ class ExtendedForwardRequest(BaseModel):
target_ip: str = Field(max_length=15)
target_port: int = Field(ge=1, le=65535)
protocol: str = Field(max_length=4)
+ restrict_sources: bool = False
+ allowed_sources: list[str] = Field(default_factory=list, max_length=32)
+
+
+class ExtendedForwardUpdateRequest(ExtendedForwardRequest):
+ id: str = Field(pattern=r"^[0-9a-f]{16}$")
class ExtendedForwardDeleteRequest(BaseModel):
@@ -685,7 +691,7 @@ async def require_authentication(request: Request, call_next):
access = get_user_access(int(current["id"]), initialize=False)
request.state.access = access
if access["role"] != "admin":
- allowed = {"/", "/clients", "/api/interfaces", "/api/snapshot", "/api/metrics/history", "/api/app-settings", "/api/auth/logout", "/api/clients/create", "/api/clients/update", "/api/clients/credentials/rotate", "/api/clients/config", "/api/clients/config/download", "/api/clients/qr", "/api/extended/forwardings", "/api/extended/forwardings/delete"}
+ allowed = {"/", "/clients", "/api/interfaces", "/api/snapshot", "/api/metrics/history", "/api/app-settings", "/api/auth/logout", "/api/clients/create", "/api/clients/update", "/api/clients/credentials/rotate", "/api/clients/config", "/api/clients/config/download", "/api/clients/qr", "/api/extended/forwardings", "/api/extended/forwardings/update", "/api/extended/forwardings/delete"}
if path not in allowed or (path == "/api/app-settings" and request.method != "GET"):
return JSONResponse(status_code=403, content={"ok": False, "error": "Brak uprawnień"})
if path.startswith("/api/clients/") or path.startswith("/api/extended/forwardings") or path == "/api/snapshot":
@@ -1769,6 +1775,16 @@ def api_extended_forward_add(payload: ExtendedForwardRequest, request: Request):
return JSONResponse(status_code=400, content={"ok": False, "error": str(exc)})
+@app.post("/api/extended/forwardings/update")
+def api_extended_forward_update(payload: ExtendedForwardUpdateRequest, request: Request):
+ try:
+ result = run_helper("extended_forward_update", payload.model_dump(), interface=request_interface(request))
+ audit_action(request, "network.forward_updated", object=request_interface(request), result="saved", details=payload.model_dump())
+ return result
+ except HelperError as exc:
+ return JSONResponse(status_code=400, content={"ok": False, "error": str(exc)})
+
+
@app.post("/api/extended/forwardings/delete")
def api_extended_forward_delete(payload: ExtendedForwardDeleteRequest, request: Request):
try:
diff --git a/app/static/js/app.js b/app/static/js/app.js
index 053a39d..f4fdc8c 100644
--- a/app/static/js/app.js
+++ b/app/static/js/app.js
@@ -1093,9 +1093,13 @@
loadGroups();
}
if(page==='clients' && $('extended-forward-form')){
- const loadForwards=async()=>{const r=await fetch(appUrl('/api/extended/forwardings'));const d=await r.json();if(!r.ok)throw new Error(d.error);$('extended-forward-public').innerHTML=(d.addresses||[]).map(ip=>``).join('');$('extended-forward-list').innerHTML=(d.forwards||[]).map(f=>`
${esc(f.public_ip)}:${Number(f.public_port)} / ${esc(f.protocol)} → ${esc(f.target_ip)}:${Number(f.target_port)}
`).join('')||'Brak przekierowań.
';};
- $('extended-forward-form').addEventListener('submit',async e=>{e.preventDefault();try{const r=await fetch(appUrl('/api/extended/forwardings'),{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({public_ip:$('extended-forward-public').value,public_port:Number($('extended-forward-public-port').value),target_ip:$('extended-forward-target').value.trim(),target_port:Number($('extended-forward-target-port').value),protocol:$('extended-forward-protocol').value})});const d=await r.json();if(!r.ok)throw new Error(d.error);await loadForwards();operationStatus('extended-forward-status','Dodano przekierowanie.','success');}catch(err){operationStatus('extended-forward-status',err.message,'error');}});
- $('extended-forward-list').addEventListener('click',async e=>{const b=e.target.closest('[data-ext-forward-delete]');if(!b||!confirm('Usunąć przekierowanie?'))return;try{const r=await fetch(appUrl('/api/extended/forwardings/delete'),{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({id:b.dataset.extForwardDelete})});const d=await r.json();if(!r.ok)throw new Error(d.error);await loadForwards();}catch(err){operationStatus('extended-forward-status',err.message,'error');}});
+ let forwards=[], editing='';
+ const reset=()=>{editing='';$('extended-forward-form').reset();$('extended-forward-restrict').checked=false;syncSources();$('extended-forward-submit').textContent='Dodaj przekierowanie';$('extended-forward-cancel').hidden=true;};
+ const syncSources=()=>{const enabled=$('extended-forward-restrict').checked;$('extended-forward-sources-wrap').hidden=!enabled;$('extended-forward-sources').required=enabled;};
+ const loadForwards=async()=>{const r=await fetch(appUrl('/api/extended/forwardings'));const d=await r.json();if(!r.ok)throw new Error(d.error);forwards=d.forwards||[];const current=$('extended-forward-public').value;$('extended-forward-public').innerHTML=(d.addresses||[]).map(ip=>``).join('');if((d.addresses||[]).includes(current))$('extended-forward-public').value=current;$('extended-forward-list').innerHTML=forwards.map(f=>`${esc(f.public_ip)}:${Number(f.public_port)} / ${esc(f.protocol)} → ${esc(f.target_ip)}:${Number(f.target_port)}${f.allowed_sources?.length?'Dozwolone adresy: '+esc(f.allowed_sources.join(', ')):'Dostęp ze wszystkich adresów'}
`).join('')||'Brak przekierowań.
';};
+ $('extended-forward-restrict').addEventListener('change',syncSources);$('extended-forward-cancel').addEventListener('click',reset);
+ $('extended-forward-form').addEventListener('submit',async e=>{e.preventDefault();const restricted=$('extended-forward-restrict').checked;const payload={public_ip:$('extended-forward-public').value,public_port:Number($('extended-forward-public-port').value),target_ip:$('extended-forward-target').value,target_port:Number($('extended-forward-target-port').value),protocol:$('extended-forward-protocol').value,restrict_sources:restricted,allowed_sources:restricted?$('extended-forward-sources').value.split(',').map(x=>x.trim()).filter(Boolean):[]};if(editing)payload.id=editing;const button=$('extended-forward-submit');button.disabled=true;try{const r=await fetch(appUrl(editing?'/api/extended/forwardings/update':'/api/extended/forwardings'),{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(payload)});const d=await r.json();if(!r.ok)throw new Error(d.error);reset();await loadForwards();operationStatus('extended-forward-status','Zapisano przekierowanie.','success');}catch(err){operationStatus('extended-forward-status',err.message,'error');}finally{button.disabled=false;}});
+ $('extended-forward-list').addEventListener('click',async e=>{const edit=e.target.closest('[data-ext-forward-edit]'),del=e.target.closest('[data-ext-forward-delete]');if(edit){const f=forwards.find(x=>x.id===edit.dataset.extForwardEdit);if(!f)return;editing=f.id;$('extended-forward-public').value=f.public_ip;$('extended-forward-public-port').value=f.public_port;$('extended-forward-target').value=f.target_ip;$('extended-forward-target-port').value=f.target_port;$('extended-forward-protocol').value=f.protocol;$('extended-forward-restrict').checked=Boolean(f.allowed_sources?.length);$('extended-forward-sources').value=(f.allowed_sources||[]).join(', ');syncSources();$('extended-forward-submit').textContent='Zapisz zmiany';$('extended-forward-cancel').hidden=false;operationStatus('extended-forward-status','Edytujesz przekierowanie.','working');$('extended-forward-form').scrollIntoView({behavior:'smooth',block:'center'});return;}if(!del||!confirm('Usunąć przekierowanie?'))return;try{const r=await fetch(appUrl('/api/extended/forwardings/delete'),{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({id:del.dataset.extForwardDelete})});const d=await r.json();if(!r.ok)throw new Error(d.error);if(editing===del.dataset.extForwardDelete)reset();await loadForwards();}catch(err){operationStatus('extended-forward-status',err.message,'error');}});
loadForwards().catch(err=>operationStatus('extended-forward-status',err.message,'error'));
}
if(page==='server' && $('extended-listen-form')){
@@ -1154,6 +1158,8 @@
}
function renderClients(d){
const peers=d.peers||[]; const body=$('client-body'); const add=$('add-client-button'); const manage=$('manage-groups-button');
+ const targets=$('extended-forward-target');if(targets){const selected=targets.value;const valid=peers.map(p=>({ip:String(p.vpn_address||'').split('/')[0],name:p.name||'Klient'})).filter(p=>/^\d{1,3}(?:\.\d{1,3}){3}$/.test(p.ip));targets.innerHTML=''+valid.map(p=>``).join('');if(valid.some(p=>p.ip===selected))targets.value=selected;}
+
if(add)add.disabled=!d.wireguard?.config_exists; if(manage)manage.disabled=!d.wireguard?.config_exists; syncClientQuickSearchClear();
if(!peers.length){body.innerHTML=`| ${esc(t('clients.no_peers','No peers found'))} |
`;return;}
const visible=peers.map((p,index)=>({p,index})).filter(item=>clientMatchesQuickSearch(item.p));
diff --git a/app/templates/clients.html b/app/templates/clients.html
index bd8da70..6a11ae2 100644
--- a/app/templates/clients.html
+++ b/app/templates/clients.html
@@ -17,11 +17,14 @@
-
+
-
+
+
+
+
diff --git a/scripts/wgtools-helper b/scripts/wgtools-helper
index 92e8428..22c318a 100644
--- a/scripts/wgtools-helper
+++ b/scripts/wgtools-helper
@@ -31,6 +31,7 @@ ALLOWED_ACTIONS.update({"extended_snat_get", "extended_snat_apply"})
ALLOWED_ACTIONS.add("extended_host_ips")
ALLOWED_ACTIONS.update({"extended_listen_get", "extended_listen_apply"})
ALLOWED_ACTIONS.update({"extended_ip_groups_get", "extended_ip_groups_set", "extended_forward_get", "extended_forward_add", "extended_forward_delete"})
+ALLOWED_ACTIONS.add("extended_forward_update")
ALLOWED_ACTIONS.update({"update_file_schedule", "update_file_apply"})
ALLOWED_IFACE_RE = re.compile(r"^[A-Za-z0-9_.-]{1,15}$")
INTERNAL_INTERFACE_PREFIXES = ("wgrly", "wgnode")
@@ -4449,6 +4450,10 @@ def _extended_forwards(iface: str) -> list[dict[str, Any]]:
raise ValueError()
if row["protocol"] not in {"tcp", "udp", "both"} or not ALLOWED_IFACE_RE.fullmatch(row["device"]) or row["device"].startswith('-'):
raise ValueError()
+ sources = row.get("allowed_sources", [])
+ if not isinstance(sources, list) or len(sources) > 32:
+ raise ValueError()
+ row["allowed_sources"] = sorted({str(ipaddress.IPv4Address(value)) for value in sources})
except (KeyError, ValueError, TypeError) as exc:
raise ValueError(f"Nieprawidłowy wpis przekierowania w {iface}") from exc
result.append(row)
@@ -4500,6 +4505,9 @@ def extended_forward_get(iface: str) -> dict[str, Any]:
def _extended_write_forwards(iface: str, rows: list[dict[str, Any]]) -> dict[str, Any]:
+ complexity = sum((len(row.get('allowed_sources', [])) or 1) * (2 if row['protocol'] == 'both' else 1) for row in rows)
+ if complexity > 100:
+ raise ValueError("Zbyt wiele adresów źródłowych w przekierowaniach tej sieci")
prefix, section, suffix = _interface_section_parts(read_config_text(iface))
marker = f"wgext-forward-{iface}"
section = [line for line in section if not (line.strip().startswith("# WGEXT-FORWARD ") or (re.match(r"\s*Post(?:Up|Down)\s*=", line, re.I) and f"--comment {marker}-" in line))]
@@ -4510,9 +4518,19 @@ def _extended_write_forwards(iface: str, rows: list[dict[str, Any]]) -> dict[str
for proto in (["tcp", "udp"] if row["protocol"] == "both" else [row["protocol"]]):
tag = f"{marker}-{row['id']}-{proto}"
nat = f"-i {row['device']} -d {row['public_ip']} -p {proto} --dport {row['public_port']} -m comment --comment {tag}-nat -j DNAT --to-destination {row['target_ip']}:{row['target_port']}"
- forward = f"-i {row['device']} -o {iface} -d {row['target_ip']} -p {proto} --dport {row['target_port']} -m comment --comment {tag}-in -j ACCEPT"
+ forward_match = f"-i {row['device']} -o {iface} -d {row['target_ip']} -p {proto} --dport {row['target_port']} -m conntrack --ctorigdst {row['public_ip']} --ctorigdstport {row['public_port']}"
reply = f"-i {iface} -o {row['device']} -s {row['target_ip']} -p {proto} --sport {row['target_port']} -m conntrack --ctstate ESTABLISHED,RELATED -m comment --comment {tag}-out -j ACCEPT"
- for table, chain, rule in [(' -t nat', 'PREROUTING', nat), ('', 'FORWARD', forward), ('', 'FORWARD', reply)]:
+ rules = [(' -t nat', 'PREROUTING', nat), ('', 'FORWARD', reply)]
+ sources = row.get('allowed_sources', [])
+ if sources:
+ # Match the original public tuple even for connections created
+ # before an edit changed the destination client.
+ deny_match = f"-i {row['device']} -o {iface} -p {proto} -m conntrack --ctorigdst {row['public_ip']} --ctorigdstport {row['public_port']}"
+ rules.append(('', 'FORWARD', f"{deny_match} -m comment --comment {tag}-deny -j DROP"))
+ for index, source in enumerate(sources or ['']):
+ source_match = f" -s {source}" if source else ''
+ rules.append(('', 'FORWARD', f"{forward_match}{source_match} -m comment --comment {tag}-in{index} -j ACCEPT"))
+ for table, chain, rule in rules:
up.append(f"iptables -w{table} -I {chain} 1 {rule}")
down.append(f"iptables -w{table} -D {chain} {rule} 2>/dev/null || true")
if up:
@@ -4521,7 +4539,7 @@ def _extended_write_forwards(iface: str, rows: list[dict[str, Any]]) -> dict[str
return raw_config_apply(iface, {"content": "\n".join([*prefix, *section, *suffix]).rstrip() + "\n"})
-def extended_forward_add(iface: str, payload: dict[str, Any]) -> dict[str, Any]:
+def extended_forward_add(iface: str, payload: dict[str, Any], *, update_id: str = '') -> dict[str, Any]:
require_valid_iface(iface)
try:
public_ip = str(ipaddress.IPv4Address(payload.get("public_ip")))
@@ -4530,6 +4548,15 @@ def extended_forward_add(iface: str, payload: dict[str, Any]) -> dict[str, Any]:
except (ValueError, TypeError) as exc:
raise ValueError("Nieprawidłowy adres lub port") from exc
protocol = str(payload.get("protocol") or "")
+ sources = payload.get('allowed_sources') or []
+ if not isinstance(sources, list) or len(sources) > 32:
+ raise ValueError("Można podać maksymalnie 32 adresy źródłowe")
+ try:
+ sources = sorted({str(ipaddress.IPv4Address(value)) for value in sources})
+ except (ValueError, TypeError) as exc:
+ raise ValueError("Podaj poprawne adresy źródłowe IPv4") from exc
+ if bool(payload.get('restrict_sources')) != bool(sources):
+ raise ValueError("Podaj co najmniej jeden adres IPv4 albo wyłącz ograniczenie")
if protocol not in {"tcp", "udp", "both"} or not (1 <= public_port <= 65535 and 1 <= target_port <= 65535):
raise ValueError("Nieprawidłowy protokół lub port")
if public_ip not in _extended_allowed(_extended_groups(), iface):
@@ -4549,14 +4576,18 @@ def extended_forward_add(iface: str, payload: dict[str, Any]) -> dict[str, Any]:
if "udp" in protocols and (other_cfg.get("interface") or {}).get("listen_port") == public_port:
raise ValueError("Ten port UDP jest używany przez WireGuard")
for row in _extended_forwards(other):
+ if other == iface and row['id'] == update_id:
+ continue
existing = {"tcp", "udp"} if row["protocol"] == "both" else {row["protocol"]}
if row["public_ip"] == public_ip and row["public_port"] == public_port and protocols & existing:
raise ValueError("Ten adres, port i protokół są już używane przez inne przekierowanie")
rows = _extended_forwards(iface)
- if len(rows) >= 20:
+ if update_id and not any(row['id'] == update_id for row in rows):
+ raise ValueError("Nie znaleziono przekierowania")
+ if not update_id and len(rows) >= 20:
raise ValueError("Osiągnięto limit przekierowań w tej sieci")
- row = {"id": secrets.token_hex(8), "public_ip": public_ip, "public_port": public_port, "target_ip": target_ip, "target_port": target_port, "protocol": protocol, "device": device}
- result = _extended_write_forwards(iface, [*rows, row])
+ row = {"id": update_id or secrets.token_hex(8), "public_ip": public_ip, "public_port": public_port, "target_ip": target_ip, "target_port": target_port, "protocol": protocol, "device": device, "allowed_sources": sources}
+ result = _extended_write_forwards(iface, [*(item for item in rows if item['id'] != update_id), row])
return {**result, "forward": row}
@@ -6734,6 +6765,12 @@ def main() -> int:
elif action == "extended_forward_add":
payload = read_json_stdin()
result = locked_call(lambda: extended_forward_add(iface, payload))
+ elif action == "extended_forward_update":
+ payload = read_json_stdin()
+ identifier = str(payload.get('id') or '')
+ if not re.fullmatch(r'[0-9a-f]{16}', identifier):
+ raise ValueError("Nieprawidłowy identyfikator przekierowania")
+ result = locked_call(lambda: extended_forward_add(iface, payload, update_id=identifier))
elif action == "extended_forward_delete":
payload = read_json_stdin()
result = locked_call(lambda: extended_forward_delete(iface, payload))
diff --git a/tests/test_access_http.py b/tests/test_access_http.py
index d03ebb7..ba2693f 100644
--- a/tests/test_access_http.py
+++ b/tests/test_access_http.py
@@ -51,6 +51,7 @@ def test_user_is_restricted_to_assigned_interface(tmp_path):
assert c.post('/api/clients/create', json={'name':'bad','type':'site_to_site','remote_networks':['10.1.0.0/16']}).status_code == 403
set_user_access(user['id'], 'user', ['wg1'], {'wg1':['add']})
assert c.post('/api/extended/forwardings', json={'public_ip':'192.0.2.1','public_port':1234,'target_ip':'10.0.0.2','target_port':1234,'protocol':'tcp'}).status_code == 403
+ assert c.post('/api/extended/forwardings/update', json={'id':'0123456789abcdef','public_ip':'192.0.2.1','public_port':1234,'target_ip':'10.0.0.2','target_port':1234,'protocol':'tcp'}).status_code == 403
assert c.post('/api/clients/update', json={'name':'peer','public_key':'x'*44}).status_code == 403
c.post('/api/auth/logout')
assert c.post('/api/auth/login', json={'username':'admin','password':'password123'}).status_code == 200
diff --git a/tests/test_extended_forward.py b/tests/test_extended_forward.py
index 5751274..aadf5ea 100644
--- a/tests/test_extended_forward.py
+++ b/tests/test_extended_forward.py
@@ -55,6 +55,33 @@ def test_rejects_foreign_target_and_wireguard_port(network):
m['extended_forward_add']('wg1', {**forward,'target_ip':'10.0.1.2','public_port':51822,'protocol':'udp'})
+def test_forward_restricts_sources_and_can_be_edited(network):
+ m, configs = network
+ m['extended_ip_groups_set']({'name':'shared','addresses':['192.0.2.10'],'interfaces':['wg1']})
+ payload = {'public_ip':'192.0.2.10','public_port':25565,'target_ip':'10.0.1.2','target_port':25565,'protocol':'both',
+ 'restrict_sources': True, 'allowed_sources':['89.144.32.110','89.144.32.172']}
+ row = m['extended_forward_add']('wg1', payload)['forward']
+ config = configs['wg1']
+ assert '--ctorigdst 192.0.2.10 --ctorigdstport 25565' in config
+ assert '-s 89.144.32.110' in config and '-s 89.144.32.172' in config
+ post_up = next(line for line in config.splitlines() if line.startswith('PostUp ='))
+ assert post_up.index('-tcp-deny -j DROP') < post_up.index('-tcp-in0 -j ACCEPT')
+ assert post_up.index('-udp-deny -j DROP') < post_up.index('-udp-in0 -j ACCEPT')
+ updated = m['extended_forward_add']('wg1', {**payload, 'restrict_sources':False, 'allowed_sources':[]}, update_id=row['id'])['forward']
+ assert updated['id'] == row['id']
+ assert len(m['extended_forward_get']('wg1')['forwards']) == 1
+ assert '-tcp-deny -j DROP' not in configs['wg1']
+
+
+def test_forward_rejects_invalid_and_empty_source_lists(network):
+ m, _ = network
+ m['extended_ip_groups_set']({'name':'shared','addresses':['192.0.2.10'],'interfaces':['wg1']})
+ payload = {'public_ip':'192.0.2.10','public_port':1234,'target_ip':'10.0.1.2','target_port':1234,'protocol':'tcp','restrict_sources': True}
+ for sources in ([], ['192.0.2.1/24'], ['1.2.3.4;id']):
+ with pytest.raises(ValueError):
+ m['extended_forward_add']('wg1', {**payload, 'allowed_sources': sources})
+
+
def test_wireguard_dump_accepts_disabled_keepalive(network, monkeypatch):
m, _ = network
gl = m['wg_dump'].__globals__
diff --git a/tests/test_help_localization.py b/tests/test_help_localization.py
index c07388e..8daa438 100644
--- a/tests/test_help_localization.py
+++ b/tests/test_help_localization.py
@@ -36,7 +36,7 @@ class HelpTranslationTests(unittest.TestCase):
def test_unknown_language_defaults_to_english(self):
self.assertEqual(get_help_sections('non-existent-language'), HELP['en'])
def test_version(self):
- self.assertEqual((ROOT/'VERSION').read_text().strip(),'1.0.3')
+ self.assertEqual((ROOT/'VERSION').read_text().strip(),'1.0.4')
if __name__ == '__main__':
unittest.main()
diff --git a/tests/test_release_0404.py b/tests/test_release_0404.py
index 4e94757..269d0e9 100644
--- a/tests/test_release_0404.py
+++ b/tests/test_release_0404.py
@@ -15,7 +15,7 @@ LANGS = ('en', 'ru', 'de', 'fr', 'it', 'es', 'pl')
class CandidateTests(unittest.TestCase):
def test_versions_and_locale_fallback_contract(self):
- self.assertEqual((ROOT / 'VERSION').read_text().strip(), '1.0.3')
+ self.assertEqual((ROOT / 'VERSION').read_text().strip(), '1.0.4')
en = json.loads((ROOT/'app/locales/en.json').read_text())
self.assertGreaterEqual(len(en), 1098)
for lang in LANGS: