Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

refactor(remote-access): extract WireGuard-tunnels backend into extension

Juan Denise6bf4915b4fa
diff --git a/backend/app/__init__.py b/backend/app/__init__.py
index 68748fe8..3ab34746 100644
--- a/backend/app/__init__.py
+++ b/backend/app/__init__.py
@@ -117,7 +117,6 @@ def create_app(config_name=None):
# Register blueprints - Core
from app.api.apps import apps_bp
from app.api.domains import domains_bp
- from app.api.tunnels import tunnels_bp
from app.api.private_urls import private_urls_bp
app.register_blueprint(apps_bp, url_prefix='/api/v1/apps')
# "Services" is the user-facing term for Applications (§1 unification).
@@ -429,8 +428,11 @@ def create_app(config_name=None):
# plan 47) — its blueprint loads from builtin-extensions/ when installed, not
# from core. The CloudProvider/CloudServer models stay core (G2).
- # Register blueprints - Remote Access (WireGuard tunnels; imported above)
- app.register_blueprint(tunnels_bp, url_prefix='/api/v1/tunnels')
+ # Remote Access (WireGuard tunnels) is an opt-in builtin extension
+ # (serverkit-remote-access, plan 47) — its blueprint loads from
+ # builtin-extensions/ when installed, not from core. The Tunnel/ExposedService
+ # models stay core (G2); the agent gateway reaches its reconcile helper via
+ # get_installed_extension_attr only when the extension is present.
# Register blueprints - Performance
from app.api.performance import performance_bp
diff --git a/backend/app/agent_gateway.py b/backend/app/agent_gateway.py
index 1426d006..e15ff0a9 100644
--- a/backend/app/agent_gateway.py
+++ b/backend/app/agent_gateway.py
@@ -303,8 +303,14 @@ class AgentNamespace(Namespace):
try:
caps = (data or {}).get('capabilities') or {}
if caps.get('wireguard'):
- from app.services.tunnel_broker_service import TunnelBrokerService
- TunnelBrokerService.schedule_reconcile(agent.server_id)
+ # TunnelBrokerService now lives in the serverkit-remote-access
+ # extension (plan 47); reach it only when installed, no-op otherwise.
+ from app.services.plugin_service import get_installed_extension_attr
+ TunnelBrokerService = get_installed_extension_attr(
+ 'serverkit-remote-access', 'tunnel_broker_service',
+ 'TunnelBrokerService')
+ if TunnelBrokerService is not None:
+ TunnelBrokerService.schedule_reconcile(agent.server_id)
except Exception:
logger.debug("tunnel reconcile scheduling skipped", exc_info=True)
diff --git a/backend/app/services/plugin_service.py b/backend/app/services/plugin_service.py
index f75d681c..ed9394dc 100644
--- a/backend/app/services/plugin_service.py
+++ b/backend/app/services/plugin_service.py
@@ -1650,6 +1650,22 @@ def finalize_setup_flagships():
_set_flagship_uninstalled(slug, True)
+def get_installed_extension_attr(slug, module, attr, default=None):
+ """Return ``attr`` from an installed extension's backend module, else default.
+
+ A core seam that calls into a feature which now lives in an extracted
+ extension (plan 47) uses this so it no-ops cleanly when the extension isn't
+ installed. Resolves ``app.plugins.<slug>.<module>`` (the dashed package the
+ plugin loader wires up on install); any import/lookup failure yields
+ ``default``."""
+ try:
+ import importlib
+ mod = importlib.import_module(f'app.plugins.{slug}.{module}')
+ return getattr(mod, attr, default)
+ except Exception:
+ return default
+
+
def install_builtin_extension(slug, user_id=None):
"""Install a builtin extension by its slug (folder lookup)."""
if not os.path.isdir(BUILTIN_EXTENSIONS_DIR):
diff --git a/backend/tests/test_remote_access_extraction.py b/backend/tests/test_remote_access_extraction.py
new file mode 100644
index 00000000..2590792a
--- /dev/null
+++ b/backend/tests/test_remote_access_extraction.py
@@ -0,0 +1,236 @@
+"""Prove the Remote Access (WireGuard tunnels) extraction (plan 47 Phase 2).
+
+The tunnels blueprint + broker/publish/netutil services move out of core into
+serverkit-remote-access; the Tunnel/ExposedService models stay core (G2). This
+also re-homes the former test_tunnel_netutil.py (pure subnet/port helpers) and
+test_tunnel_reconcile.py (panel-authoritative reconcile) against the extension.
+"""
+import importlib
+import sys
+from types import SimpleNamespace
+
+import pytest
+
+from app import db
+from app.models.server import Server
+from app.models.tunnel import Tunnel
+from app.models.exposed_service import ExposedService
+from app.models.plugin import InstalledPlugin
+from app.services import agent_registry as ar_mod
+from app.services import plugin_service
+
+SLUG = 'serverkit-remote-access'
+_PKG = f'app.plugins.{SLUG}'
+
+
+# ── extraction shape ─────────────────────────────────────────────────────────
+
+def test_core_has_no_tunnel_routes(app):
+ rules = [r.rule for r in app.url_map.iter_rules()]
+ assert [r for r in rules if r.startswith('/api/v1/tunnels')] == []
+
+
+def test_core_import_of_tunnel_services_gone():
+ for mod in ('tunnel_broker_service', 'tunnel_publish_service', 'tunnel_netutil'):
+ with pytest.raises(ModuleNotFoundError):
+ importlib.import_module(f'app.services.{mod}')
+
+
+def test_remote_access_in_converted_builtin_slugs():
+ from app.services.extension_migration import CONVERTED_BUILTIN_SLUGS
+ assert SLUG in CONVERTED_BUILTIN_SLUGS
+
+
+def test_tunnel_models_stay_core():
+ from app.models.tunnel import Tunnel # noqa: F401
+ from app.models.exposed_service import ExposedService # noqa: F401
+
+
+def install_dirs(tmp_path, monkeypatch):
+ backend = tmp_path / 'plugins_backend'
+ frontend = tmp_path / 'plugins_frontend'
+ backend.mkdir()
+ frontend.mkdir()
+ monkeypatch.setattr(plugin_service, 'BACKEND_PLUGINS_DIR', str(backend))
+ monkeypatch.setattr(plugin_service, 'FRONTEND_PLUGINS_DIR', str(frontend))
+
+ added = str(backend)
+ app_pkg_plugins = importlib.import_module('app.plugins')
+ if added not in app_pkg_plugins.__path__:
+ app_pkg_plugins.__path__.append(added)
+
+ yield {'backend': backend, 'frontend': frontend}
+
+ if added in app_pkg_plugins.__path__:
+ app_pkg_plugins.__path__.remove(added)
+ for name in list(sys.modules):
+ if name == _PKG or name.startswith(_PKG + '.'):
+ del sys.modules[name]
+
+
+def ext(app, install_dirs):
+ plugin_service.install_builtin_extension(SLUG)
+ tn = importlib.import_module(f'{_PKG}.tunnel_netutil')
+ broker = importlib.import_module(f'{_PKG}.tunnel_broker_service')
+ return SimpleNamespace(tn=tn, TunnelBrokerService=broker.TunnelBrokerService)
+
+
+def test_install_registers_tunnel_routes(app, client, auth_headers, install_dirs):
+ plugin = plugin_service.install_builtin_extension(SLUG)
+ assert plugin.status == InstalledPlugin.STATUS_ACTIVE
+ assert plugin.has_backend is True
+ assert plugin.url_prefix == '/api/v1/tunnels'
+ rules = [r.rule for r in app.url_map.iter_rules()]
+ assert any(r.startswith('/api/v1/tunnels') for r in rules)
+
+
+# ── re-homed: tunnel_netutil pure helpers ────────────────────────────────────
+
+def test_pick_subnet_first_free(ext):
+ cidr, edge, priv = ext.tn.pick_subnet([])
+ assert (cidr, edge, priv) == ('10.88.0.0/24', '10.88.0.1', '10.88.0.2')
+
+
+def test_pick_subnet_skips_used(ext):
+ cidr, edge, priv = ext.tn.pick_subnet(['10.88.0.0/24', '10.88.1.0/24'])
+ assert (cidr, edge, priv) == ('10.88.2.0/24', '10.88.2.1', '10.88.2.2')
+
+
+def test_pick_subnet_exhausted(ext):
+ used = ['10.88.%d.0/24' % i for i in range(256)]
+ with pytest.raises(RuntimeError):
+ ext.tn.pick_subnet(used)
+
+
+def test_interface_name_is_stable_and_kernel_valid(ext):
+ name = ext.tn.interface_name_for('3fa9c2b1-dead-beef-0000-111122223333')
+ assert name == 'skwg3fa9c2b1'
+ assert len(name) <= 15
+ assert name.replace('skwg', '').isalnum()
+
+
+def test_derive_status(ext):
+ now = 1_000_000
+ assert ext.tn.derive_status(now - 10, now) == 'up'
+ assert ext.tn.derive_status(now - 10_000, now) == 'degraded'
+ assert ext.tn.derive_status(0, now) == 'pending'
+ assert ext.tn.derive_status(now, now, interface_up=False) == 'down'
+
+
+def test_validate_endpoint_host(ext):
+ assert ext.tn.validate_endpoint_host('203.0.113.5') is True
+ assert ext.tn.validate_endpoint_host('10.0.0.5') is True
+ assert ext.tn.validate_endpoint_host('127.0.0.1') is False
+ assert ext.tn.validate_endpoint_host('0.0.0.0') is False
+ assert ext.tn.validate_endpoint_host('') is False
+ assert ext.tn.validate_endpoint_host('not-an-ip') is False
+
+
+def test_pick_listen_port(ext):
+ assert ext.tn.pick_listen_port([]) == 51820
+ assert ext.tn.pick_listen_port([51820]) == 51821
+ assert ext.tn.pick_listen_port([51820, 51821, 51823]) == 51822
+
+
+def test_pick_listen_port_exhausted(ext):
+ used = list(range(ext.tn.DEFAULT_LISTEN_PORT,
+ ext.tn.DEFAULT_LISTEN_PORT + ext.tn.LISTEN_PORT_RANGE))
+ with pytest.raises(RuntimeError):
+ ext.tn.pick_listen_port(used)
+
+
+def test_diagnose_reachability(ext):
+ assert ext.tn.diagnose_reachability(0, None, False)['state'] == 'interface_down'
+ assert ext.tn.diagnose_reachability(1_700_000_000, 999, True)['state'] == 'ok'
+ assert ext.tn.diagnose_reachability(0, 5, True)['state'] == 'connecting'
+ d = ext.tn.diagnose_reachability(0, 600, True)
+ assert d['state'] == 'no_handshake'
+ assert 'blocked' in d['hint'].lower()
+
+
+# ── re-homed: panel-authoritative reconcile ──────────────────────────────────
+
+def _server(name, ip=None):
+ s = Server(name=name, ip_address=ip, status='online')
+ db.session.add(s)
+ db.session.commit()
+ return s
+
+
+def _record_send(monkeypatch):
+ calls = []
+
+ def fake_send(server_id, action, params=None, user_id=None, timeout=30.0):
+ calls.append({'server_id': server_id, 'action': action, 'params': params or {}})
+ return {'success': True, 'data': {}}
+
+ monkeypatch.setattr(ar_mod.agent_registry, 'send_command', fake_send)
+ return calls
+
+
+def _tunnel(edge, priv, iface, third):
+ t = Tunnel(
+ edge_server_id=edge.id, private_server_id=priv.id,
+ interface_name=iface, subnet='10.88.%d.0/24' % third,
+ edge_wg_ip='10.88.%d.1' % third, private_wg_ip='10.88.%d.2' % third,
+ listen_port=51820, edge_pubkey='EDGEPUB', private_pubkey='PRIVPUB',
+ status='up',
+ )
+ db.session.add(t)
+ db.session.commit()
+ return t
+
+
+def test_reconcile_private_side(ext, monkeypatch):
+ calls = _record_send(monkeypatch)
+ edge = _server('edge', ip='203.0.113.9')
+ priv = _server('home')
+ t = _tunnel(edge, priv, 'skwgrec01', 7)
+ db.session.add(ExposedService(tunnel_id=t.id, hostname='jelly.example.com',
+ port=8096, status='published'))
+ db.session.commit()
+
+ res = ext.TunnelBrokerService.reconcile_server(priv.id)
+ assert res and res[0]['ok']
+ actions = [c['action'] for c in calls]
+ assert 'wireguard:interface:up' in actions
+ assert 'wireguard:peer:set' in actions
+ assert 'wireguard:forward' in actions
+ peer = next(c['params'] for c in calls if c['action'] == 'wireguard:peer:set')
+ assert peer['public_key'] == 'EDGEPUB'
+ assert peer['endpoint'] == '203.0.113.9:51820'
+ assert peer['persistent_keepalive'] == 25
+ fwd = next(c['params'] for c in calls if c['action'] == 'wireguard:forward')
+ assert fwd['listen_port'] == 8096 and fwd['target_port'] == 8096
+ assert fwd['listen_ip'] == '10.88.7.2'
+
+
+def test_reconcile_edge_side(ext, monkeypatch):
+ calls = _record_send(monkeypatch)
+ edge = _server('edge2', ip='198.51.100.4')
+ priv = _server('home2')
+ _tunnel(edge, priv, 'skwgrec02', 8)
+
+ ext.TunnelBrokerService.reconcile_server(edge.id)
+ actions = [c['action'] for c in calls]
+ assert 'wireguard:interface:up' in actions
+ assert 'wireguard:peer:set' in actions
+ assert 'firewall:allow_port' in actions
+ peer = next(c['params'] for c in calls if c['action'] == 'wireguard:peer:set')
+ assert peer['public_key'] == 'PRIVPUB'
+ assert 'endpoint' not in peer
+
+
+def test_reconcile_skips_errored_tunnels(ext, monkeypatch):
+ calls = _record_send(monkeypatch)
+ edge = _server('edge3', ip='192.0.2.7')
+ priv = _server('home3')
+ t = _tunnel(edge, priv, 'skwgrec03', 9)
+ t.status = 'error'
+ db.session.commit()
+
+ res = ext.TunnelBrokerService.reconcile_server(priv.id)
+ assert res == []
+ assert calls == []
diff --git a/backend/tests/test_tunnel_netutil.py b/backend/tests/test_tunnel_netutil.py
deleted file mode 100644
index f0ada3b4..00000000
--- a/backend/tests/test_tunnel_netutil.py
+++ /dev/null
@@ -1,79 +0,0 @@
-"""Unit tests for the tunnel broker's pure helpers (roadmap #7 / #11).
-
-These import only app.services.tunnel_netutil (stdlib-only) so they prove
-the subnet allocator, interface-name derivation and health classification
-without needing a DB or connected agents.
-"""
-
-from app.services import tunnel_netutil as tn
-
-
-def test_pick_subnet_first_free():
- cidr, edge, priv = tn.pick_subnet([])
- assert cidr == '10.88.0.0/24'
- assert edge == '10.88.0.1'
- assert priv == '10.88.0.2'
-
-
-def test_pick_subnet_skips_used():
- cidr, edge, priv = tn.pick_subnet(['10.88.0.0/24', '10.88.1.0/24'])
- assert cidr == '10.88.2.0/24'
- assert edge == '10.88.2.1'
- assert priv == '10.88.2.2'
-
-
-def test_pick_subnet_exhausted():
- used = ['10.88.%d.0/24' % i for i in range(256)]
- try:
- tn.pick_subnet(used)
- assert False, "expected RuntimeError on exhausted pool"
- except RuntimeError:
- pass
-
-
-def test_interface_name_is_stable_and_kernel_valid():
- name = tn.interface_name_for('3fa9c2b1-dead-beef-0000-111122223333')
- assert name == 'skwg3fa9c2b1'
- assert len(name) <= 15
- assert name.replace('skwg', '').isalnum()
-
-
-def test_derive_status():
- now = 1_000_000
- assert tn.derive_status(now - 10, now) == 'up'
- assert tn.derive_status(now - 10_000, now) == 'degraded'
- assert tn.derive_status(0, now) == 'pending'
- assert tn.derive_status(now, now, interface_up=False) == 'down'
-
-
-def test_validate_endpoint_host():
- assert tn.validate_endpoint_host('203.0.113.5') is True
- assert tn.validate_endpoint_host('10.0.0.5') is True # private edge OK
- assert tn.validate_endpoint_host('127.0.0.1') is False # loopback
- assert tn.validate_endpoint_host('0.0.0.0') is False # unspecified
- assert tn.validate_endpoint_host('') is False
- assert tn.validate_endpoint_host('not-an-ip') is False
-
-
-def test_pick_listen_port():
- assert tn.pick_listen_port([]) == 51820
- assert tn.pick_listen_port([51820]) == 51821
- assert tn.pick_listen_port([51820, 51821, 51823]) == 51822 # fills the gap
-
-
-def test_pick_listen_port_exhausted():
- used = list(range(tn.DEFAULT_LISTEN_PORT, tn.DEFAULT_LISTEN_PORT + tn.LISTEN_PORT_RANGE))
- try:
- tn.pick_listen_port(used)
- assert False, "expected RuntimeError on exhausted port pool"
- except RuntimeError:
- pass
-
-
-def test_diagnose_reachability():
- assert tn.diagnose_reachability(0, None, False)['state'] == 'interface_down'
- assert tn.diagnose_reachability(1_700_000_000, 999, True)['state'] == 'ok'
- assert tn.diagnose_reachability(0, 5, True)['state'] == 'connecting'
- d = tn.diagnose_reachability(0, 600, True)
- assert d['state'] == 'no_handshake'
- assert 'blocked' in d['hint'].lower()
diff --git a/backend/tests/test_tunnel_reconcile.py b/backend/tests/test_tunnel_reconcile.py
deleted file mode 100644
index 977d0336..00000000
--- a/backend/tests/test_tunnel_reconcile.py
+++ /dev/null
@@ -1,101 +0,0 @@
-"""Phase 3 #19: panel-authoritative tunnel reconcile.
-
-Proves reconcile_server re-issues the right agent commands for each side
-of a tunnel, by monkeypatching agent_registry.send_command to record calls
-(no live agent needed).
-"""
-
-from app import db
-from app.models.server import Server
-from app.models.tunnel import Tunnel
-from app.models.exposed_service import ExposedService
-from app.services import agent_registry as ar_mod
-from app.services.tunnel_broker_service import TunnelBrokerService
-
-
-def _server(name, ip=None):
- s = Server(name=name, ip_address=ip, status='online')
- db.session.add(s)
- db.session.commit()
- return s
-
-
-def _record_send(monkeypatch):
- calls = []
-
- def fake_send(server_id, action, params=None, user_id=None, timeout=30.0):
- calls.append({'server_id': server_id, 'action': action, 'params': params or {}})
- return {'success': True, 'data': {}}
-
- monkeypatch.setattr(ar_mod.agent_registry, 'send_command', fake_send)
- return calls
-
-
-def _tunnel(edge, priv, iface, third):
- t = Tunnel(
- edge_server_id=edge.id, private_server_id=priv.id,
- interface_name=iface, subnet='10.88.%d.0/24' % third,
- edge_wg_ip='10.88.%d.1' % third, private_wg_ip='10.88.%d.2' % third,
- listen_port=51820, edge_pubkey='EDGEPUB', private_pubkey='PRIVPUB',
- status='up',
- )
- db.session.add(t)
- db.session.commit()
- return t
-
-
-def test_reconcile_private_side(app, monkeypatch):
- calls = _record_send(monkeypatch)
- edge = _server('edge', ip='203.0.113.9')
- priv = _server('home')
- t = _tunnel(edge, priv, 'skwgrec01', 7)
- db.session.add(ExposedService(tunnel_id=t.id, hostname='jelly.example.com', port=8096, status='published'))
- db.session.commit()
-
- res = TunnelBrokerService.reconcile_server(priv.id)
- assert res and res[0]['ok']
-
- actions = [c['action'] for c in calls]
- assert 'wireguard:interface:up' in actions
- assert 'wireguard:peer:set' in actions
- assert 'wireguard:forward' in actions
-
- peer = next(c['params'] for c in calls if c['action'] == 'wireguard:peer:set')
- assert peer['public_key'] == 'EDGEPUB' # private peers with the edge
- assert peer['endpoint'] == '203.0.113.9:51820' # dials the edge endpoint
- assert peer['persistent_keepalive'] == 25
-
- fwd = next(c['params'] for c in calls if c['action'] == 'wireguard:forward')
- assert fwd['listen_port'] == 8096 and fwd['target_port'] == 8096
- assert fwd['listen_ip'] == '10.88.7.2'
-
-
-def test_reconcile_edge_side(app, monkeypatch):
- calls = _record_send(monkeypatch)
- edge = _server('edge2', ip='198.51.100.4')
- priv = _server('home2')
- _tunnel(edge, priv, 'skwgrec02', 8)
-
- TunnelBrokerService.reconcile_server(edge.id)
-
- actions = [c['action'] for c in calls]
- assert 'wireguard:interface:up' in actions
- assert 'wireguard:peer:set' in actions
- assert 'firewall:allow_port' in actions # edge re-opens its UDP port
-
- peer = next(c['params'] for c in calls if c['action'] == 'wireguard:peer:set')
- assert peer['public_key'] == 'PRIVPUB' # edge peers with the private host
- assert 'endpoint' not in peer # edge has no endpoint for the private peer
-
-
-def test_reconcile_skips_errored_tunnels(app, monkeypatch):
- calls = _record_send(monkeypatch)
- edge = _server('edge3', ip='192.0.2.7')
- priv = _server('home3')
- t = _tunnel(edge, priv, 'skwgrec03', 9)
- t.status = 'error'
- db.session.commit()
-
- res = TunnelBrokerService.reconcile_server(priv.id)
- assert res == []
- assert calls == []
diff --git a/builtin-extensions/serverkit-remote-access/backend/__init__.py b/builtin-extensions/serverkit-remote-access/backend/__init__.py
new file mode 100644
index 00000000..f766423c
--- /dev/null
+++ b/builtin-extensions/serverkit-remote-access/backend/__init__.py
@@ -0,0 +1,13 @@
+"""ServerKit Remote Access extension backend package (WireGuard tunnels).
+
+Extracted from core (plan 47): the tunnels blueprint + broker/publish/netutil
+services ship here so a fresh panel that never exposes a NAT'd service loads none
+of it. Mounted under ``/api/v1/tunnels`` via the manifest's ``url_prefix``. The
+Tunnel / ExposedService models stay in core (G2); this package imports them.
+Core's agent gateway reaches TunnelBrokerService.schedule_reconcile through
+``plugin_service.get_installed_extension_attr`` only when the extension is
+installed. Upgrades re-acquire it automatically (``CONVERTED_BUILTIN_SLUGS``).
+"""
+from .tunnels import tunnels_bp
+
+__all__ = ['tunnels_bp']
diff --git a/backend/app/services/tunnel_broker_service.py b/builtin-extensions/serverkit-remote-access/backend/tunnel_broker_service.py
similarity index 99%
rename from backend/app/services/tunnel_broker_service.py
rename to builtin-extensions/serverkit-remote-access/backend/tunnel_broker_service.py
index 410d5689..627b53fb 100644
--- a/backend/app/services/tunnel_broker_service.py
+++ b/builtin-extensions/serverkit-remote-access/backend/tunnel_broker_service.py
@@ -14,7 +14,7 @@ from app import db
from app.models.server import Server
from app.models.tunnel import Tunnel
from app.services.agent_registry import agent_registry
-from app.services import tunnel_netutil
+from . import tunnel_netutil
logger = logging.getLogger(__name__)
diff --git a/backend/app/services/tunnel_netutil.py b/builtin-extensions/serverkit-remote-access/backend/tunnel_netutil.py
similarity index 100%
rename from backend/app/services/tunnel_netutil.py
rename to builtin-extensions/serverkit-remote-access/backend/tunnel_netutil.py
diff --git a/backend/app/services/tunnel_publish_service.py b/builtin-extensions/serverkit-remote-access/backend/tunnel_publish_service.py
similarity index 100%
rename from backend/app/services/tunnel_publish_service.py
rename to builtin-extensions/serverkit-remote-access/backend/tunnel_publish_service.py
diff --git a/backend/app/api/tunnels.py b/builtin-extensions/serverkit-remote-access/backend/tunnels.py
similarity index 95%
rename from backend/app/api/tunnels.py
rename to builtin-extensions/serverkit-remote-access/backend/tunnels.py
index 7b58c7c0..15953692 100644
--- a/backend/app/api/tunnels.py
+++ b/builtin-extensions/serverkit-remote-access/backend/tunnels.py
@@ -9,8 +9,8 @@ from flask import Blueprint, request, jsonify
from flask_jwt_extended import jwt_required, get_jwt_identity
from app.models.tunnel import Tunnel
-from app.services.tunnel_broker_service import TunnelBrokerService, TunnelBrokerError
-from app.services.tunnel_publish_service import TunnelPublishService, TunnelPublishError
+from .tunnel_broker_service import TunnelBrokerService, TunnelBrokerError
+from .tunnel_publish_service import TunnelPublishService, TunnelPublishError
from app.middleware.rbac import developer_required
tunnels_bp = Blueprint('tunnels', __name__)
diff --git a/builtin-extensions/serverkit-remote-access/plugin.json b/builtin-extensions/serverkit-remote-access/plugin.json
index d382c6e2..01e1c90a 100644
--- a/builtin-extensions/serverkit-remote-access/plugin.json
+++ b/builtin-extensions/serverkit-remote-access/plugin.json
@@ -8,6 +8,8 @@
"category": "integration",
"homepage": "https://github.com/jhd3197/ServerKit",
"permissions": ["network"],
+ "entry_point": "tunnels:tunnels_bp",
+ "url_prefix": "/api/v1/tunnels",
"icon": "<rect x=\"16\" y=\"16\" width=\"6\" height=\"6\" rx=\"1\"/><rect x=\"2\" y=\"16\" width=\"6\" height=\"6\" rx=\"1\"/><rect x=\"9\" y=\"2\" width=\"6\" height=\"6\" rx=\"1\"/><path d=\"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3\"/><path d=\"M12 12V8\"/>",
"contributions": {
"tabs": [