fix: small fixes
This commit is contained in:
1 parent
86cb0226ab
commit
171e14176a
28 files changed
+95
-91
No files matched your search
@@ -400,7 +400,7 @@ type UfwRule struct {
|
||||
ID int64
|
||||
Port int
|
||||
Proto string
|
||||
RuleID int64 // bound forward rule id, or 0 for shared/manual (e.g. tunnel 8446)
|
||||
RuleID int64 // bound forward rule id, or 0 for shared/manual (e.g. the tunnel port)
|
||||
}
|
||||
|
||||
func (db *DB) AddUfwRule(port int, proto string, ruleID int64) error {
|
||||
|
||||
@@ -14,8 +14,8 @@ import (
|
||||
// supports three transports:
|
||||
// - "http": tunneled over the HTTP long-poll channel (works anywhere nginx
|
||||
// reaches, highest latency);
|
||||
// - "tcp": direct TCP multiplexed over the 8446 tunnel (low latency);
|
||||
// - "udp": direct UDP over the 8446 channel.
|
||||
// - "tcp": direct TCP multiplexed over the tunnel port (low latency);
|
||||
// - "udp": direct UDP over the tunnel port.
|
||||
type forwardManager struct {
|
||||
hub *Hub
|
||||
tun *tunnelHub
|
||||
@@ -92,11 +92,11 @@ func (m *forwardManager) acceptTCP(rule ForwardRule, ln net.Listener) {
|
||||
}
|
||||
}
|
||||
|
||||
// bridgeDirect wires a connection to the agent's low-latency 8446 tunnel.
|
||||
// bridgeDirect wires a connection to the agent's low-latency direct tunnel.
|
||||
func (m *forwardManager) bridgeDirect(rule ForwardRule, conn net.Conn) {
|
||||
at := m.tun.get(rule.AgentID)
|
||||
if at == nil {
|
||||
// No direct tunnel (agent offline or 8446 unreachable).
|
||||
// No direct tunnel (agent offline or the tunnel port unreachable).
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ func writeJSON(w http.ResponseWriter, v any) {
|
||||
_ = json.NewEncoder(w).Encode(v)
|
||||
}
|
||||
|
||||
// POST /api/agent/enroll — exchange the shared enroll secret for a per-agent id+token.
|
||||
// POST /api/agent/enroll - exchange the shared enroll secret for a per-agent id+token.
|
||||
func (s *Server) handleEnroll(w http.ResponseWriter, r *http.Request) {
|
||||
secret := r.Header.Get("X-Enroll-Secret")
|
||||
if !constantTimeEqual(secret, s.db.EnrollSecret()) {
|
||||
@@ -36,7 +36,7 @@ func (s *Server) handleEnroll(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, proto.EnrollResponse{AgentID: id, Token: token})
|
||||
}
|
||||
|
||||
// GET /api/agent/poll — control channel. Held until a job is queued or timeout.
|
||||
// GET /api/agent/poll - control channel. Held until a job is queued or timeout.
|
||||
func (s *Server) handlePoll(w http.ResponseWriter, r *http.Request) {
|
||||
a := s.authenticateAgent(r)
|
||||
if a == nil {
|
||||
@@ -68,7 +68,7 @@ func (s *Server) setTunnelHeader(w http.ResponseWriter) {
|
||||
}
|
||||
}
|
||||
|
||||
// GET /api/agent/config — settings an agent picks up when it connects, without
|
||||
// GET /api/agent/config - settings an agent picks up when it connects, without
|
||||
// waiting out a poll hold.
|
||||
func (s *Server) handleAgentConfig(w http.ResponseWriter, r *http.Request) {
|
||||
if s.authenticateAgent(r) == nil {
|
||||
@@ -79,7 +79,7 @@ func (s *Server) handleAgentConfig(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// GET /api/agent/task/{id} — the agent fetches the task to run.
|
||||
// GET /api/agent/task/{id} - the agent fetches the task to run.
|
||||
func (s *Server) handleTaskFetch(w http.ResponseWriter, r *http.Request) {
|
||||
if s.authenticateAgent(r) == nil {
|
||||
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
||||
@@ -93,7 +93,7 @@ func (s *Server) handleTaskFetch(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, env)
|
||||
}
|
||||
|
||||
// POST /api/agent/task/{id}/result — the agent returns the task result.
|
||||
// POST /api/agent/task/{id}/result - the agent returns the task result.
|
||||
func (s *Server) handleTaskResult(w http.ResponseWriter, r *http.Request) {
|
||||
if s.authenticateAgent(r) == nil {
|
||||
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
||||
@@ -108,7 +108,7 @@ func (s *Server) handleTaskResult(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// GET /api/agent/term/{sid}/in — downstream (panel -> agent) long-poll.
|
||||
// GET /api/agent/term/{sid}/in - downstream (panel -> agent) long-poll.
|
||||
func (s *Server) handleTermIn(w http.ResponseWriter, r *http.Request) {
|
||||
if s.authenticateAgent(r) == nil {
|
||||
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
||||
@@ -127,7 +127,7 @@ func (s *Server) handleTermIn(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, proto.InBatch{Frames: frames})
|
||||
}
|
||||
|
||||
// POST /api/agent/term/{sid}/out — upstream (agent PTY -> panel).
|
||||
// POST /api/agent/term/{sid}/out - upstream (agent PTY -> panel).
|
||||
func (s *Server) handleTermOut(w http.ResponseWriter, r *http.Request) {
|
||||
if s.authenticateAgent(r) == nil {
|
||||
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
||||
|
||||
@@ -137,7 +137,7 @@ func seenText(online bool, lastSeen time.Time) string {
|
||||
return humanSince(lastSeen)
|
||||
}
|
||||
|
||||
// GET /api/panel/agents/presence — who is online, for the dashboard to keep
|
||||
// GET /api/panel/agents/presence - who is online, for the dashboard to keep
|
||||
// its status column live without reloading.
|
||||
func (s *Server) handlePresence(w http.ResponseWriter, r *http.Request) {
|
||||
agents, err := s.db.ListAgents()
|
||||
@@ -227,7 +227,7 @@ func (s *Server) agentUsers(agentID string) (*proto.SysUsersResult, error) {
|
||||
case res := <-ch:
|
||||
if !res.OK {
|
||||
// Agents older than 0.0.2 don't know this task.
|
||||
return nil, errors.New("клиент не поддерживает выбор пользователя — обновите его")
|
||||
return nil, errors.New("клиент не поддерживает выбор пользователя - обновите его")
|
||||
}
|
||||
var out proto.SysUsersResult
|
||||
if err := json.Unmarshal(res.Data, &out); err != nil {
|
||||
@@ -258,7 +258,7 @@ func (s *Server) handleAgentSetUser(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
name := strings.TrimSpace(r.FormValue("user"))
|
||||
if !s.online(a) {
|
||||
editUserRedirect(w, r, id, "uerr", "Машина офлайн — сменить пользователя нельзя.")
|
||||
editUserRedirect(w, r, id, "uerr", "Машина офлайн - сменить пользователя нельзя.")
|
||||
return
|
||||
}
|
||||
// Only accept a user the machine itself reports, so a typo (or an agent too
|
||||
@@ -299,7 +299,7 @@ func (s *Server) handleAgentAddUser(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
if !s.online(a) {
|
||||
editUserRedirect(w, r, id, "uerr", "Машина офлайн — создать пользователя нельзя.")
|
||||
editUserRedirect(w, r, id, "uerr", "Машина офлайн - создать пользователя нельзя.")
|
||||
return
|
||||
}
|
||||
name := strings.TrimSpace(r.FormValue("name"))
|
||||
@@ -402,7 +402,7 @@ func (s *Server) handleSettings(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
}
|
||||
|
||||
// POST /settings/tunnel — host and port agents use for the direct tunnel.
|
||||
// POST /settings/tunnel - host and port agents use for the direct tunnel.
|
||||
func (s *Server) handleSetTunnel(w http.ResponseWriter, r *http.Request) {
|
||||
if !checkCSRF(r) {
|
||||
http.Error(w, "bad csrf", http.StatusForbidden)
|
||||
|
||||
@@ -37,7 +37,7 @@ func (s *Server) handleFilesPage(w http.ResponseWriter, r *http.Request) {
|
||||
s.render(w, "files.html", map[string]any{"Agent": a, "EditLimit": proto.FSReadCap})
|
||||
}
|
||||
|
||||
// POST /api/panel/agents/{id}/fs/{op} — run a file-manager operation on the
|
||||
// POST /api/panel/agents/{id}/fs/{op} - run a file-manager operation on the
|
||||
// agent and return its result. The request body is the op's JSON args and is
|
||||
// forwarded verbatim to the agent.
|
||||
func (s *Server) handleFSOp(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -74,7 +74,7 @@ func (s *Server) handleFSOp(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
// GET /api/panel/agents/{id}/fs/download?path=... — stream a file as a download.
|
||||
// GET /api/panel/agents/{id}/fs/download?path=... - stream a file as a download.
|
||||
func (s *Server) handleFSDownload(w http.ResponseWriter, r *http.Request) {
|
||||
agentID := r.PathValue("id")
|
||||
p := r.URL.Query().Get("path")
|
||||
|
||||
@@ -103,12 +103,12 @@ func (s *Server) onlineAgent(w http.ResponseWriter, r *http.Request) (string, bo
|
||||
// the task.
|
||||
func oldAgentError(res proto.TaskResult) proto.TaskResult {
|
||||
if !res.OK && strings.Contains(res.Error, "неизвестная операция") {
|
||||
res.Error = "клиент не поддерживает эту функцию — обновите его (нужен 0.0.5+)"
|
||||
res.Error = "клиент не поддерживает эту функцию - обновите его (нужен 0.0.5+)"
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// GET /api/panel/agents/{id}/stat — CPU, RAM and disk of the machine right now.
|
||||
// GET /api/panel/agents/{id}/stat - CPU, RAM and disk of the machine right now.
|
||||
func (s *Server) handleAgentStat(w http.ResponseWriter, r *http.Request) {
|
||||
id, ok := s.onlineAgent(w, r)
|
||||
if !ok {
|
||||
@@ -128,7 +128,7 @@ func (s *Server) handleAgentStat(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, e.res)
|
||||
}
|
||||
|
||||
// POST /api/panel/agents/{id}/speed — have the agent measure its link to us.
|
||||
// POST /api/panel/agents/{id}/speed - have the agent measure its link to us.
|
||||
func (s *Server) handleAgentSpeed(w http.ResponseWriter, r *http.Request) {
|
||||
id, ok := s.onlineAgent(w, r)
|
||||
if !ok {
|
||||
@@ -150,7 +150,7 @@ var speedBlock = sync.OnceValue(func() []byte {
|
||||
return b
|
||||
})
|
||||
|
||||
// GET /api/agent/speed/down?bytes=N — stream N bytes (default: as much as fits
|
||||
// GET /api/agent/speed/down?bytes=N - stream N bytes (default: as much as fits
|
||||
// in the time window) for the agent to time. bytes=0 is the ping probe.
|
||||
func (s *Server) handleSpeedDown(w http.ResponseWriter, r *http.Request) {
|
||||
if s.authenticateAgent(r) == nil {
|
||||
@@ -182,7 +182,7 @@ func (s *Server) handleSpeedDown(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
// POST /api/agent/speed/up — swallow the agent's upload.
|
||||
// POST /api/agent/speed/up - swallow the agent's upload.
|
||||
func (s *Server) handleSpeedUp(w http.ResponseWriter, r *http.Request) {
|
||||
if s.authenticateAgent(r) == nil {
|
||||
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
// same transport the agent uses), so it works through any reverse proxy without
|
||||
// WebSocket upgrade support.
|
||||
|
||||
// POST /api/panel/term/{agentID}/open — create a terminal session.
|
||||
// POST /api/panel/term/{agentID}/open - create a terminal session.
|
||||
func (s *Server) handlePanelOpen(w http.ResponseWriter, r *http.Request) {
|
||||
agentID := r.PathValue("agentID")
|
||||
agent, err := s.db.GetAgent(agentID)
|
||||
@@ -28,7 +28,7 @@ func (s *Server) handlePanelOpen(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, map[string]string{"session_id": sess.ID})
|
||||
}
|
||||
|
||||
// GET /api/panel/term/{sid}/out — long-poll for PTY output.
|
||||
// GET /api/panel/term/{sid}/out - long-poll for PTY output.
|
||||
func (s *Server) handlePanelOut(w http.ResponseWriter, r *http.Request) {
|
||||
sess := s.hub.Session(r.PathValue("sid"))
|
||||
if sess == nil {
|
||||
@@ -51,7 +51,7 @@ type panelInMsg struct {
|
||||
Rows uint16 `json:"rows,omitempty"`
|
||||
}
|
||||
|
||||
// POST /api/panel/term/{sid}/in — send keystrokes/resize to the agent PTY.
|
||||
// POST /api/panel/term/{sid}/in - send keystrokes/resize to the agent PTY.
|
||||
func (s *Server) handlePanelIn(w http.ResponseWriter, r *http.Request) {
|
||||
sess := s.hub.Session(r.PathValue("sid"))
|
||||
if sess == nil {
|
||||
@@ -72,7 +72,7 @@ func (s *Server) handlePanelIn(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// POST /api/panel/term/{sid}/close — tear the session down.
|
||||
// POST /api/panel/term/{sid}/close - tear the session down.
|
||||
func (s *Server) handlePanelClose(w http.ResponseWriter, r *http.Request) {
|
||||
s.hub.CloseSession(r.PathValue("sid"))
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
|
||||
@@ -37,7 +37,7 @@ type taskEntry struct {
|
||||
}
|
||||
|
||||
// Session is one live byte stream between the panel and an agent (a PTY terminal
|
||||
// or a raw TCP forward — the hub treats both identically).
|
||||
// or a raw TCP forward - the hub treats both identically).
|
||||
type Session struct {
|
||||
ID string
|
||||
AgentID string
|
||||
|
||||
@@ -26,8 +26,8 @@ type Options struct {
|
||||
// nginx TLS); set false only for plain-HTTP local testing.
|
||||
SecureCookies bool
|
||||
// TunnelAddr is the listen address for the direct TCP+UDP forward tunnel
|
||||
// (default ":8446"). Empty disables direct forwarding. The port can be
|
||||
// overridden from the settings page.
|
||||
// Empty disables direct forwarding. The port can be overridden from the
|
||||
// settings page.
|
||||
TunnelAddr string
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,11 @@ import (
|
||||
"github.com/x-grk/longpolling-remote-access/internal/tunnel"
|
||||
)
|
||||
|
||||
// udpRelay carries UDP forwards over the direct 8446 UDP channel. The agent
|
||||
// udpRelay carries UDP forwards over the direct UDP channel. The agent
|
||||
// registers its UDP return address; end-user datagrams arriving on a rule's
|
||||
// host port are relayed to the agent and replies are sent back.
|
||||
//
|
||||
// Datagram framing on the 8446 control socket:
|
||||
// Datagram framing on the tunnel control socket:
|
||||
//
|
||||
// registration (agent->server): "R <agentID> <sig>"
|
||||
// data (both): 'D' | sid(4) | port(2) | payload
|
||||
|
||||
@@ -172,7 +172,7 @@ func (u *ufwManager) pruneShared() {
|
||||
|
||||
// allowForward opens the host ports a forward rule needs: its host port (bound
|
||||
// to the rule so it is revoked with it) plus the shared tunnel port for direct
|
||||
// tcp/udp modes (bound to 0 — shared across rules). A rule made "without ufw"
|
||||
// tcp/udp modes (bound to 0 - shared across rules). A rule made "without ufw"
|
||||
// opens nothing, so nothing is revoked with it either.
|
||||
func (u *ufwManager) allowForward(rule ForwardRule) {
|
||||
if !u.available() {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Машины — LPRA</title>
|
||||
<title>Машины - LPRA</title>
|
||||
<link rel="stylesheet" href="/static/app.css">
|
||||
</head>
|
||||
<body>
|
||||
@@ -49,7 +49,7 @@
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"/></svg>
|
||||
</a>
|
||||
<form method="post" action="/agents/{{.ID}}/delete" style="display:inline"
|
||||
onsubmit="return confirm('Удалить машину {{.Name}}? Сервис на ней продолжит работать, но перестанет быть виден. Чтобы снова подключиться — переустановите агента.')">
|
||||
onsubmit="return confirm('Удалить машину {{.Name}}? Сервис на ней продолжит работать, но перестанет быть виден. Чтобы снова подключиться - переустановите агента.')">
|
||||
<input type="hidden" name="csrf" value="{{$.CSRF}}">
|
||||
<button class="btn danger small icon" type="submit" title="Удалить">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>
|
||||
@@ -63,7 +63,7 @@
|
||||
</table>
|
||||
{{else}}
|
||||
<p class="muted">Пока нет подключённых машин. Добавьте первую в разделе
|
||||
<a href="/settings">Настройки</a> — там одна команда для установки.</p>
|
||||
<a href="/settings">Настройки</a> - там одна команда для установки.</p>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Изменить машину — LPRA</title>
|
||||
<title>Изменить машину - LPRA</title>
|
||||
<link rel="stylesheet" href="/static/app.css?v={{.ServerVersion}}-2">
|
||||
</head>
|
||||
<body>
|
||||
@@ -55,7 +55,7 @@
|
||||
<label style="color:var(--text); font-size:14px">
|
||||
<input type="checkbox" name="sudo" value="1"> Добавить в sudo
|
||||
</label>
|
||||
<p class="muted" style="font-size:13px">Без пароля вход по паролю (и sudo) для него работать не будет — только терминал из панели.</p>
|
||||
<p class="muted" style="font-size:13px">Без пароля вход по паролю (и sudo) для него работать не будет - только терминал из панели.</p>
|
||||
<button type="submit">Создать пользователя</button>
|
||||
</form>
|
||||
{{else}}
|
||||
@@ -64,7 +64,7 @@
|
||||
{{else if .UsersErr}}
|
||||
<p class="muted" style="font-size:13px">Список пользователей недоступен: {{.UsersErr}}.</p>
|
||||
{{else}}
|
||||
<p class="muted" style="font-size:13px">Машина офлайн — сменить пользователя можно, когда она на связи.</p>
|
||||
<p class="muted" style="font-size:13px">Машина офлайн - сменить пользователя можно, когда она на связи.</p>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
<div class="card">
|
||||
<h2>Удаление</h2>
|
||||
<p class="muted">Удаляет машину из панели. Сервис на самой машине продолжит работать,
|
||||
но перестанет быть виден; чтобы подключиться снова — переустановите агента.</p>
|
||||
но перестанет быть виден; чтобы подключиться снова - переустановите агента.</p>
|
||||
<form method="post" action="/agents/{{.Agent.ID}}/delete"
|
||||
onsubmit="return confirm('Удалить машину {{.Agent.Name}}?')">
|
||||
<input type="hidden" name="csrf" value="{{.CSRF}}">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Файлы · {{.Agent.Name}} — LPRA</title>
|
||||
<title>Файлы · {{.Agent.Name}} - LPRA</title>
|
||||
<link rel="stylesheet" href="/static/app.css">
|
||||
<style>
|
||||
.fm-bar { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-bottom:12px; }
|
||||
@@ -44,7 +44,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<header class="topbar">
|
||||
<div class="brand">LPRA · Файлы — {{.Agent.Name}} <span class="muted">({{.Agent.Hostname}})</span></div>
|
||||
<div class="brand">LPRA · Файлы - {{.Agent.Name}} <span class="muted">({{.Agent.Hostname}})</span></div>
|
||||
<nav>
|
||||
<a href="/">← Машины</a>
|
||||
<a href="/agents/{{.Agent.ID}}/terminal">Терминал</a>
|
||||
@@ -78,7 +78,7 @@
|
||||
<tbody id="list"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<p class="muted" id="hint" style="font-size:13px">Перетащите файлы сюда для загрузки. Клик по файлу — просмотр (правка, если < 2 КБ).</p>
|
||||
<p class="muted" id="hint" style="font-size:13px">Перетащите файлы сюда для загрузки. Клик по файлу - просмотр и правка.</p>
|
||||
</div>
|
||||
|
||||
<dialog id="viewer">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Порты · {{.Agent.Name}} — LPRA</title>
|
||||
<title>Порты · {{.Agent.Name}} - LPRA</title>
|
||||
<link rel="stylesheet" href="/static/app.css">
|
||||
<style>
|
||||
.frow { display:flex; align-items:flex-end; gap:14px; flex-wrap:wrap; }
|
||||
@@ -21,7 +21,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<header class="topbar">
|
||||
<div class="brand">LPRA · Порты — {{.Agent.Name}} <span class="muted">({{.Agent.Hostname}})</span></div>
|
||||
<div class="brand">LPRA · Порты - {{.Agent.Name}} <span class="muted">({{.Agent.Hostname}})</span></div>
|
||||
<nav>
|
||||
<a href="/">← Машины</a>
|
||||
<a href="/agents/{{.Agent.ID}}/terminal">Терминал</a>
|
||||
@@ -31,7 +31,7 @@
|
||||
<div class="wrap">
|
||||
<h1>Проброс портов</h1>
|
||||
<p class="muted">Порт сервиса на машине-клиенте становится доступен на порту хоста.
|
||||
Клиент за NAT — трафик идёт исходящим подключением агента.</p>
|
||||
Клиент за NAT - трафик идёт исходящим подключением агента.</p>
|
||||
{{if .Error}}<div class="err">{{.Error}}</div>{{end}}
|
||||
|
||||
<div class="card">
|
||||
@@ -101,9 +101,9 @@
|
||||
<div class="card">
|
||||
<h2>Режимы</h2>
|
||||
<ul class="muted" style="font-size:14px; line-height:1.7">
|
||||
<li><b>http</b> — туннель поверх HTTP long-poll (через адрес панели, порт {{.PanelPort}}). Работает везде, где доступна панель, но задержка выше.</li>
|
||||
<li><b>tcp</b> — прямой TCP-мультиплексор через порт <b>{{.TunnelPort}}</b> хоста. Минимальная задержка, keep-alive, TCP_NODELAY. Нужно открыть {{.TunnelPort}}/tcp на хосте.</li>
|
||||
<li><b>udp</b> — прямой UDP через порт <b>{{.TunnelPort}}</b> хоста. Нужно открыть {{.TunnelPort}}/udp.</li>
|
||||
<li><b>http</b> - туннель поверх HTTP long-poll (через адрес панели, порт {{.PanelPort}}). Работает везде, где доступна панель, но задержка выше.</li>
|
||||
<li><b>tcp</b> - прямой TCP-мультиплексор через порт <b>{{.TunnelPort}}</b> хоста. Минимальная задержка, keep-alive, TCP_NODELAY. Нужно открыть {{.TunnelPort}}/tcp на хосте.</li>
|
||||
<li><b>udp</b> - прямой UDP через порт <b>{{.TunnelPort}}</b> хоста. Нужно открыть {{.TunnelPort}}/udp.</li>
|
||||
</ul>
|
||||
<p class="muted" style="font-size:13px">Для tcp/udp агент держит исходящее соединение к <code>host:{{.TunnelPort}}</code>; несколько клиентов и портов мультиплексируются на нём.</p>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Вход — LPRA</title>
|
||||
<title>Вход - LPRA</title>
|
||||
<link rel="stylesheet" href="/static/app.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Настройки — LPRA</title>
|
||||
<title>Настройки - LPRA</title>
|
||||
<link rel="stylesheet" href="/static/app.css">
|
||||
</head>
|
||||
<body>
|
||||
@@ -56,7 +56,7 @@
|
||||
<p class="muted">Прямой туннель отключён при запуске сервера (пустой <code>-tunnel</code> / <code>LPRA_TUNNEL_ADDR</code>).</p>
|
||||
{{else}}
|
||||
<p class="muted">Адрес, к которому агенты подключаются для проброса в режимах tcp/udp. Агенты забирают его
|
||||
с панели сами — при подключении и при каждом опросе, так что смена применяется без переустановки.
|
||||
с панели сами - при подключении и при каждом опросе, так что смена применяется без переустановки.
|
||||
Хост можно оставить пустым (тогда берётся хост из адреса панели) или указать IP/другое имя.</p>
|
||||
<form method="post" action="/settings/tunnel" class="row">
|
||||
<input type="hidden" name="csrf" value="{{.CSRF}}">
|
||||
@@ -115,7 +115,7 @@
|
||||
<div class="card">
|
||||
<h2>Firewall (ufw)</h2>
|
||||
{{if not .UfwInstalled}}
|
||||
<p class="muted">ufw не установлен на хосте — интеграция недоступна.</p>
|
||||
<p class="muted">ufw не установлен на хосте - интеграция недоступна.</p>
|
||||
{{else if not .UfwRunnable}}
|
||||
<p class="muted">ufw установлен, но сервер не может им управлять (нужны права root).
|
||||
Запустите сервер под root или настройте sudo для ufw.</p>
|
||||
@@ -124,7 +124,7 @@
|
||||
Статус ufw: {{if .UfwActive}}<span style="color:var(--ok)">активен</span>{{else}}<span style="color:var(--danger)">выключен</span>{{end}}
|
||||
· Интеграция: {{if .UfwEnabled}}<span style="color:var(--ok)">включена</span>{{else}}<span class="muted">выключена</span>{{end}}
|
||||
</p>
|
||||
<p class="muted" style="font-size:13px">При создании правила проброса порт открывается в ufw автоматически (для tcp/udp — также порт туннеля{{if .TunnelPort}} {{.TunnelPort}}{{end}}); для http-проброса открывается tcp-порт хоста. Порты правил, слушающих только 127.0.0.1, не открываются.</p>
|
||||
<p class="muted" style="font-size:13px">При создании правила проброса порт открывается в ufw автоматически (для tcp/udp - также порт туннеля{{if .TunnelPort}} {{.TunnelPort}}{{end}}); для http-проброса открывается tcp-порт хоста. Порты правил, слушающих только 127.0.0.1, не открываются.</p>
|
||||
{{if .UfwError}}<div class="err">Последняя команда ufw завершилась ошибкой: <code>{{.UfwError}}</code></div>{{end}}
|
||||
<form method="post" action="/settings/ufw/toggle" style="display:inline">
|
||||
<input type="hidden" name="csrf" value="{{.CSRF}}">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Настройка — LPRA</title>
|
||||
<title>Настройка - LPRA</title>
|
||||
<link rel="stylesheet" href="/static/app.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Статус · {{.Agent.Name}} — LPRA</title>
|
||||
<title>Статус · {{.Agent.Name}} - LPRA</title>
|
||||
<link rel="stylesheet" href="/static/app.css">
|
||||
<style>
|
||||
.meters { display:grid; grid-template-columns:repeat(auto-fit, minmax(240px, 1fr)); gap:20px; margin-bottom:20px; }
|
||||
@@ -23,7 +23,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<header class="topbar">
|
||||
<div class="brand">LPRA · Статус — {{.Agent.Name}} <span class="muted">({{.Agent.Hostname}})</span></div>
|
||||
<div class="brand">LPRA · Статус - {{.Agent.Name}} <span class="muted">({{.Agent.Hostname}})</span></div>
|
||||
<nav>
|
||||
<a href="/">← Машины</a>
|
||||
<a href="/agents/{{.Agent.ID}}/terminal">Терминал</a>
|
||||
@@ -37,17 +37,17 @@
|
||||
|
||||
<div class="meters">
|
||||
<div class="card meter">
|
||||
<div class="head"><span class="name">Процессор</span><span class="val" id="cpu-val">—</span></div>
|
||||
<div class="head"><span class="name">Процессор</span><span class="val" id="cpu-val">-</span></div>
|
||||
<div class="bar"><i id="cpu-bar"></i></div>
|
||||
<div class="sub" id="cpu-sub"></div>
|
||||
</div>
|
||||
<div class="card meter">
|
||||
<div class="head"><span class="name">Оперативная память</span><span class="val" id="mem-val">—</span></div>
|
||||
<div class="head"><span class="name">Оперативная память</span><span class="val" id="mem-val">-</span></div>
|
||||
<div class="bar"><i id="mem-bar"></i></div>
|
||||
<div class="sub" id="mem-sub"></div>
|
||||
</div>
|
||||
<div class="card meter">
|
||||
<div class="head"><span class="name">Диск (/)</span><span class="val" id="disk-val">—</span></div>
|
||||
<div class="head"><span class="name">Диск (/)</span><span class="val" id="disk-val">-</span></div>
|
||||
<div class="bar"><i id="disk-bar"></i></div>
|
||||
<div class="sub" id="disk-sub"></div>
|
||||
</div>
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
<div class="card">
|
||||
<h2>Скорость соединения</h2>
|
||||
<p class="muted">Клиент замеряет свой канал до хоста панели — тот же, по которому идут терминал, файлы и http-проброс.
|
||||
<p class="muted">Клиент замеряет свой канал до хоста панели - тот же, по которому идут терминал, файлы и http-проброс.
|
||||
Замер занимает около 7 секунд и на это время нагружает канал.</p>
|
||||
<div class="row">
|
||||
<button id="speed-btn" type="button">Замерить скорость</button>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Терминал · {{.Agent.Name}} — LPRA</title>
|
||||
<title>Терминал · {{.Agent.Name}} - LPRA</title>
|
||||
<link rel="stylesheet" href="/static/app.css">
|
||||
<link rel="stylesheet" href="/static/xterm.css">
|
||||
<style>
|
||||
@@ -13,7 +13,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<header class="topbar">
|
||||
<div class="brand">LPRA · Терминал — {{.Agent.Name}} <span class="muted">({{.Agent.TerminalUser}}@{{.Agent.Hostname}})</span></div>
|
||||
<div class="brand">LPRA · Терминал - {{.Agent.Name}} <span class="muted">({{.Agent.TerminalUser}}@{{.Agent.Hostname}})</span></div>
|
||||
<nav>
|
||||
<a href="/">← Машины</a>
|
||||
<a href="/agents/{{.Agent.ID}}/files">Файлы</a>
|
||||
@@ -78,7 +78,7 @@
|
||||
setStatus('ошибка открытия (' + r.status + ')', 'st-err');
|
||||
term.write('\r\n\x1b[31m[не удалось открыть сессию: HTTP ' + r.status + ']\x1b[0m\r\n');
|
||||
if (body) term.write(body.slice(0, 300).replace(/\n/g, '\r\n') + '\r\n');
|
||||
if (r.status === 404) term.write('\x1b[33mМашина не найдена на сервере — возможно, устаревший бинарник сервера без маршрута /open.\x1b[0m\r\n');
|
||||
if (r.status === 404) term.write('\x1b[33mМашина не найдена на сервере - возможно, устаревший бинарник сервера без маршрута /open.\x1b[0m\r\n');
|
||||
return;
|
||||
}
|
||||
const j = await r.json();
|
||||
|
||||
Reference in new issue
Block a user