SSH endpoint
This commit is contained in:
@@ -7,6 +7,7 @@ DragonCoreSSH V40 é um painel/servidor em Go para SSH com HTTP Injection, paine
|
||||
### Recursos principais
|
||||
|
||||
- SSH com HTTP Injection
|
||||
- Endpoint SSH raw interno sempre ativo em `127.0.0.1:2222` para proxies e túneis locais
|
||||
- Painel web administrativo
|
||||
- Banco de dados PostgreSQL
|
||||
- Integração com Xray-core/V2Ray
|
||||
@@ -148,6 +149,7 @@ O instalador monta `/opt/sshpanel/logs` como tmpfs de 15 MiB quando possível, p
|
||||
```text
|
||||
80 SSH com HTTP Injection
|
||||
8080 SSH extra com HTTP Injection
|
||||
2222 SSH raw interno em 127.0.0.1 (não público)
|
||||
53/udp DNS público para DNSTT, redirecionado para 5300/udp
|
||||
5300/udp DNSTT interno
|
||||
9090 Painel web + API pública /check
|
||||
@@ -167,6 +169,27 @@ sudo ufw allow 10086/tcp
|
||||
sudo ufw allow 10087/tcp
|
||||
```
|
||||
|
||||
### Endpoint SSH interno para proxies locais
|
||||
|
||||
O processo do DragonCore mantém um listener SSH raw separado em `127.0.0.1:2222`. Ele usa as mesmas contas, autenticação, cotas, limites de conexão e banda do SSH público, mas não executa a limpeza de cabeçalhos HTTP. O listener inicia junto com o serviço `sshpanel`, continua aberto durante reinícios automáticos dos listeners públicos e pode ser configurado em **Configurações → Rede/SSH → Internal Raw SSH**.
|
||||
|
||||
Um proxy/túnel executado no mesmo servidor pode usar diretamente:
|
||||
|
||||
```text
|
||||
Host: 127.0.0.1
|
||||
Porta: 2222
|
||||
Tipo: SSH raw
|
||||
Usuário/senha: uma conta SSH do painel
|
||||
```
|
||||
|
||||
Por exemplo, para criar um SOCKS local com o cliente OpenSSH:
|
||||
|
||||
```bash
|
||||
ssh -N -D 127.0.0.1:1080 -p 2222 usuario@127.0.0.1
|
||||
```
|
||||
|
||||
Não abra a porta `2222` no firewall: o servidor aceita para `local_ssh_listen` somente IPs loopback numéricos (`127.0.0.0/8` ou `::1`) e volta ao padrão seguro se receber um endereço público, wildcard ou inválido. Em contêineres, `127.0.0.1` aponta para o próprio contêiner; use rede host ou outra integração local apropriada para alcançar o listener do host.
|
||||
|
||||
|
||||
### DNSTT na porta DNS 53
|
||||
|
||||
@@ -551,6 +574,7 @@ DragonCoreSSH V40 is a Go-based SSH HTTP Injection server with a web panel, Post
|
||||
### Main features
|
||||
|
||||
- SSH with HTTP Injection
|
||||
- Always-on internal raw SSH endpoint at `127.0.0.1:2222` for local proxies and tunnels
|
||||
- Administrative web panel
|
||||
- PostgreSQL database
|
||||
- Xray-core/V2Ray integration
|
||||
@@ -689,6 +713,7 @@ Admin token
|
||||
```text
|
||||
80 SSH with HTTP Injection
|
||||
8080 Extra SSH with HTTP Injection
|
||||
2222 Internal raw SSH on 127.0.0.1 (not public)
|
||||
53/udp Public DNS for DNSTT, redirected to 5300/udp
|
||||
5300/udp Internal DNSTT listener
|
||||
9090 Web panel + public /check API
|
||||
@@ -708,6 +733,27 @@ sudo ufw allow 10086/tcp
|
||||
sudo ufw allow 10087/tcp
|
||||
```
|
||||
|
||||
### Internal SSH endpoint for local proxies
|
||||
|
||||
The DragonCore process keeps a separate raw SSH listener on `127.0.0.1:2222`. It uses the same accounts, authentication, quotas, connection caps, and bandwidth limits as public SSH, but does not perform HTTP-header cleanup. The listener starts with the `sshpanel` service, remains bound while public listeners are automatically restarted, and can be configured under **Settings → Network/SSH → Internal Raw SSH**.
|
||||
|
||||
A proxy or tunnel running on the same server can point directly to:
|
||||
|
||||
```text
|
||||
Host: 127.0.0.1
|
||||
Port: 2222
|
||||
Type: raw SSH
|
||||
Username/password: a panel SSH account
|
||||
```
|
||||
|
||||
For example, to create a local SOCKS proxy with the OpenSSH client:
|
||||
|
||||
```bash
|
||||
ssh -N -D 127.0.0.1:1080 -p 2222 username@127.0.0.1
|
||||
```
|
||||
|
||||
Do not open port `2222` in the firewall. `local_ssh_listen` accepts only numeric loopback IPs (`127.0.0.0/8` or `::1`) and falls back to the safe default when given a public, wildcard, or invalid address. Inside a container, `127.0.0.1` means that container itself; use host networking or another suitable local integration to reach the host listener.
|
||||
|
||||
|
||||
### DNSTT on DNS port 53
|
||||
|
||||
@@ -1325,6 +1371,7 @@ Replaces a certificate's `fullchain.pem` + `privkey.pem`. The panel's **Configur
|
||||
Reads/writes the panel's `config.json` and hot-applies changes.
|
||||
- **GET**: returns the raw config file JSON.
|
||||
- **POST**: body is the full config JSON (≤ 512 KiB). Validated (`listen` required), the file-based `users` array is preserved, ports normalized, then written to disk and applied live.
|
||||
- `local_ssh_listen` defaults to `127.0.0.1:2222`, is always enabled, and is restricted to a numeric loopback address. Its live status is returned as `services.local_ssh`.
|
||||
- `200`: reload report `{ "applied": bool, "warnings": string[], "services": { "<name>": ServiceReloadStatus } }`.
|
||||
- Errors: `400 invalid JSON: ...` / `listen address required`; `500 config path not set` / read/write errors.
|
||||
|
||||
|
||||
@@ -409,6 +409,7 @@ async function loadManagedServerConfig(id) {
|
||||
const c = await res.json();
|
||||
|
||||
document.getElementById("managedCfgListen").value = c.listen || "";
|
||||
document.getElementById("managedCfgLocalSSHListen").value = c.local_ssh_listen || "127.0.0.1:2222";
|
||||
document.getElementById("managedCfgExtraListen").value = (c.extra_listen || []).join("\n");
|
||||
document.getElementById("managedCfgProxyAutoRestart").value = c.proxy_auto_restart_interval || "";
|
||||
document.getElementById("managedCfgProxyRestartGrace").value = c.proxy_auto_restart_grace || "";
|
||||
@@ -478,6 +479,7 @@ function managedConfigFromForm() {
|
||||
const dnsttDomains = readDnsttDomains("managedCfgDnsttDomains");
|
||||
return {
|
||||
listen: document.getElementById("managedCfgListen").value.trim(),
|
||||
local_ssh_listen: document.getElementById("managedCfgLocalSSHListen").value.trim() || "127.0.0.1:2222",
|
||||
extra_listen: extraLines,
|
||||
proxy_auto_restart_interval: document.getElementById("managedCfgProxyAutoRestart").value.trim(),
|
||||
proxy_auto_restart_grace: document.getElementById("managedCfgProxyRestartGrace").value.trim(),
|
||||
|
||||
@@ -100,6 +100,7 @@ async function loadServerConfig() {
|
||||
|
||||
// Network
|
||||
document.getElementById("cfgListen").value = c.listen || "";
|
||||
document.getElementById("cfgLocalSSHListen").value = c.local_ssh_listen || "127.0.0.1:2222";
|
||||
document.getElementById("cfgExtraListen").value = (c.extra_listen || []).join("\n");
|
||||
document.getElementById("cfgProxyAutoRestart").value = c.proxy_auto_restart_interval || "";
|
||||
document.getElementById("cfgProxyRestartGrace").value = c.proxy_auto_restart_grace || "";
|
||||
@@ -185,6 +186,7 @@ async function saveServerConfig() {
|
||||
|
||||
const cfg = {
|
||||
listen: document.getElementById("cfgListen").value.trim(),
|
||||
local_ssh_listen: document.getElementById("cfgLocalSSHListen").value.trim() || "127.0.0.1:2222",
|
||||
extra_listen: extraLines,
|
||||
proxy_auto_restart_interval: document.getElementById("cfgProxyAutoRestart").value.trim(),
|
||||
proxy_auto_restart_grace: document.getElementById("cfgProxyRestartGrace").value.trim(),
|
||||
|
||||
+12
-2
@@ -821,6 +821,11 @@
|
||||
<label>Main Listen (SSH / HTTP)</label>
|
||||
<input type="text" id="managedCfgListen" placeholder="0.0.0.0:80"/>
|
||||
</div>
|
||||
<div class="field" style="margin-top:8px;">
|
||||
<label>Internal Raw SSH <span class="hint">(loopback only)</span></label>
|
||||
<input type="text" id="managedCfgLocalSSHListen" placeholder="127.0.0.1:2222"/>
|
||||
<div class="hint" style="margin-top:4px;">Always-on endpoint for local proxy/tunnel services. Numeric 127.0.0.0/8 or ::1 addresses only.</div>
|
||||
</div>
|
||||
<div class="field" style="margin-top:8px;">
|
||||
<label>Extra Listen Addresses <span class="hint">(one per line, e.g. 0.0.0.0:8080)</span></label>
|
||||
<textarea id="managedCfgExtraListen" rows="4" style="width:100%;box-sizing:border-box;background:var(--input-bg);border:1px solid var(--border);border-radius:8px;color:inherit;padding:10px;resize:vertical;"></textarea>
|
||||
@@ -1254,6 +1259,11 @@
|
||||
<label>Main Listen (SSH / HTTP)</label>
|
||||
<input type="text" id="cfgListen" placeholder="0.0.0.0:80"/>
|
||||
</div>
|
||||
<div class="field" style="grid-column:1/-1">
|
||||
<label>Internal Raw SSH <span class="hint">(loopback only)</span></label>
|
||||
<input type="text" id="cfgLocalSSHListen" placeholder="127.0.0.1:2222"/>
|
||||
<div class="hint" style="margin-top:4px;">Always-on endpoint for local proxy/tunnel services. Numeric 127.0.0.0/8 or ::1 addresses only.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field" style="margin-top:6px">
|
||||
<label>Extra Listen Addresses <span class="hint">(one per line, e.g. 0.0.0.0:8080)</span></label>
|
||||
@@ -1607,9 +1617,9 @@
|
||||
<script defer src="assets/js/03-ssh-users.js?v=20260720sshfilters1"></script>
|
||||
<script defer src="assets/js/04-xray.js?v=20260720sshfilters1"></script>
|
||||
<script defer src="assets/js/05-resellers.js?v=20260714pamfix1"></script>
|
||||
<script defer src="assets/js/06-servers.js?v=20260714pamfix1"></script>
|
||||
<script defer src="assets/js/06-servers.js?v=20260910localssh1"></script>
|
||||
<script defer src="assets/js/07-stats-logs.js?v=20260714pamfix1"></script>
|
||||
<script defer src="assets/js/08-server-config.js?v=20260805certupdate1"></script>
|
||||
<script defer src="assets/js/08-server-config.js?v=20260910localssh1"></script>
|
||||
<script defer src="assets/js/09-xray-wizard.js?v=20260724xrayinboundsr4"></script>
|
||||
<script defer src="assets/js/11-update-status.js?v=20260714pamfix1"></script>
|
||||
<script defer src="assets/js/12-bot.js?v=20260714pamfix1"></script>
|
||||
|
||||
+50
-6
@@ -4,15 +4,17 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultMainListen = "0.0.0.0:80"
|
||||
defaultExtraListen = "0.0.0.0:8080"
|
||||
defaultDNSTTListen = "0.0.0.0:5300"
|
||||
defaultUDPGWListen = "0.0.0.0:7400"
|
||||
defaultMainListen = "0.0.0.0:80"
|
||||
defaultExtraListen = "0.0.0.0:8080"
|
||||
defaultLocalSSHListen = "127.0.0.1:2222"
|
||||
defaultDNSTTListen = "0.0.0.0:5300"
|
||||
defaultUDPGWListen = "0.0.0.0:7400"
|
||||
)
|
||||
|
||||
func normalizeRuntimePorts(cfg *Config) []string {
|
||||
@@ -62,8 +64,22 @@ func normalizeRuntimePorts(cfg *Config) []string {
|
||||
}
|
||||
cfg.ExtraListen = extra
|
||||
|
||||
// DragonCore no longer uses an internal local SSH listener.
|
||||
cfg.LocalSSHListen = ""
|
||||
oldLocalSSHListen := strings.TrimSpace(cfg.LocalSSHListen)
|
||||
normalizedLocalSSHListen, localSSHErr := normalizeLocalSSHListen(oldLocalSSHListen)
|
||||
cfg.LocalSSHListen = normalizedLocalSSHListen
|
||||
if localSSHErr != nil {
|
||||
warn("internal SSH listener %q is invalid (%v); using safe default %s", oldLocalSSHListen, localSSHErr, cfg.LocalSSHListen)
|
||||
}
|
||||
if err := tcpAddrAvailableForPool(cfg.LocalSSHListen, localPool); err != nil {
|
||||
old := cfg.LocalSSHListen
|
||||
cfg.LocalSSHListen = defaultLocalSSHListen
|
||||
if old != defaultLocalSSHListen {
|
||||
warn("internal SSH listener %s is unavailable (%v); using default %s", old, err, cfg.LocalSSHListen)
|
||||
}
|
||||
if err2 := tcpAddrAvailableForPool(cfg.LocalSSHListen, localPool); err2 != nil {
|
||||
warn("default internal SSH listener %s is unavailable: %v", cfg.LocalSSHListen, err2)
|
||||
}
|
||||
}
|
||||
|
||||
cfg.ProxyAutoRestartInterval = strings.TrimSpace(cfg.ProxyAutoRestartInterval)
|
||||
if cfg.ProxyAutoRestartInterval != "" && cfg.ProxyAutoRestartInterval != "0" && cfg.ProxyAutoRestartInterval != "0s" && !strings.EqualFold(cfg.ProxyAutoRestartInterval, "off") && !strings.EqualFold(cfg.ProxyAutoRestartInterval, "disabled") {
|
||||
@@ -245,6 +261,34 @@ func normalizeRuntimePorts(cfg *Config) []string {
|
||||
return warnings
|
||||
}
|
||||
|
||||
// normalizeLocalSSHListen guarantees that the raw integration endpoint can
|
||||
// only bind to this machine. Hostnames and wildcard/non-loopback addresses are
|
||||
// deliberately rejected: a changed hosts file must not turn an internal SSH
|
||||
// port into a remotely reachable service.
|
||||
func normalizeLocalSSHListen(addr string) (string, error) {
|
||||
addr = strings.TrimSpace(addr)
|
||||
if addr == "" {
|
||||
return defaultLocalSSHListen, nil
|
||||
}
|
||||
|
||||
host, portText, err := net.SplitHostPort(addr)
|
||||
if err != nil {
|
||||
return defaultLocalSSHListen, fmt.Errorf("expected loopback host:port: %w", err)
|
||||
}
|
||||
ip := net.ParseIP(host)
|
||||
if ip == nil || !ip.IsLoopback() {
|
||||
return defaultLocalSSHListen, fmt.Errorf("host must be a numeric loopback IP")
|
||||
}
|
||||
port, err := strconv.Atoi(portText)
|
||||
if err != nil || port < 1 || port > 65535 {
|
||||
return defaultLocalSSHListen, fmt.Errorf("port must be between 1 and 65535")
|
||||
}
|
||||
if ipv4 := ip.To4(); ipv4 != nil {
|
||||
ip = ipv4
|
||||
}
|
||||
return net.JoinHostPort(ip.String(), strconv.Itoa(port)), nil
|
||||
}
|
||||
|
||||
func tcpAddrAvailableForPool(addr string, pool *listenerPool) error {
|
||||
if addr == "" {
|
||||
return nil
|
||||
|
||||
@@ -2,6 +2,40 @@ package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNormalizeLocalSSHListen(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
want string
|
||||
wantErr bool
|
||||
}{
|
||||
{name: "empty uses safe default", input: "", want: defaultLocalSSHListen},
|
||||
{name: "whitespace uses safe default", input: " ", want: defaultLocalSSHListen},
|
||||
{name: "IPv4 loopback", input: "127.0.0.1:2200", want: "127.0.0.1:2200"},
|
||||
{name: "other IPv4 loopback", input: "127.10.20.30:2222", want: "127.10.20.30:2222"},
|
||||
{name: "IPv6 loopback", input: "[::1]:2222", want: "[::1]:2222"},
|
||||
{name: "wildcard IPv4 rejected", input: "0.0.0.0:2222", want: defaultLocalSSHListen, wantErr: true},
|
||||
{name: "wildcard IPv6 rejected", input: "[::]:2222", want: defaultLocalSSHListen, wantErr: true},
|
||||
{name: "public address rejected", input: "192.0.2.10:2222", want: defaultLocalSSHListen, wantErr: true},
|
||||
{name: "hostname rejected", input: "localhost:2222", want: defaultLocalSSHListen, wantErr: true},
|
||||
{name: "missing port rejected", input: "127.0.0.1", want: defaultLocalSSHListen, wantErr: true},
|
||||
{name: "zero port rejected", input: "127.0.0.1:0", want: defaultLocalSSHListen, wantErr: true},
|
||||
{name: "large port rejected", input: "127.0.0.1:65536", want: defaultLocalSSHListen, wantErr: true},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := normalizeLocalSSHListen(tt.input)
|
||||
if got != tt.want {
|
||||
t.Fatalf("normalizeLocalSSHListen(%q) address = %q, want %q", tt.input, got, tt.want)
|
||||
}
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Fatalf("normalizeLocalSSHListen(%q) error = %v, wantErr %v", tt.input, err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeDNSTTListenDefault(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
+17
-3
@@ -261,6 +261,7 @@ func (p *tlsListenerPool) HasAll(forwarders []TLSForwarderConfig) bool {
|
||||
|
||||
var (
|
||||
publicPool *listenerPool // HTTP+SSH: listen + extra_listen
|
||||
localPool *listenerPool // raw SSH: loopback-only local_ssh_listen
|
||||
tlsPool *tlsListenerPool // TLS forwarders
|
||||
)
|
||||
|
||||
@@ -376,6 +377,22 @@ func applyFullConfigReload(newCfg *Config) ConfigReloadReport {
|
||||
setAdminHandler(http.FileServer(http.Dir(newCfg.AdminDir)))
|
||||
}
|
||||
|
||||
// Internal raw SSH listener. Keep it separate from the public listener
|
||||
// pool so proxy auto-restarts never take the local integration endpoint
|
||||
// offline. normalizeRuntimePorts guarantees one loopback address here.
|
||||
localAddrs := []string{newCfg.LocalSSHListen}
|
||||
for _, e := range localPool.Sync(localAddrs) {
|
||||
report.warnf("internal SSH listener error: %v", e)
|
||||
}
|
||||
report.Services["local_ssh"] = ServiceReloadStatus{
|
||||
Enabled: true,
|
||||
Running: localPool.HasAll(localAddrs),
|
||||
Listen: newCfg.LocalSSHListen,
|
||||
}
|
||||
if !report.Services["local_ssh"].Running {
|
||||
report.Services["local_ssh"] = ServiceReloadStatus{Enabled: true, Running: false, Listen: newCfg.LocalSSHListen, Error: "internal SSH listener could not be opened"}
|
||||
}
|
||||
|
||||
// Public SSH listeners (main listen + extra_listen)
|
||||
publicAddrs := append([]string{newCfg.Listen}, newCfg.ExtraListen...)
|
||||
for _, e := range publicPool.Sync(publicAddrs) {
|
||||
@@ -390,9 +407,6 @@ func applyFullConfigReload(newCfg *Config) ConfigReloadReport {
|
||||
report.Services["ssh"] = ServiceReloadStatus{Enabled: true, Running: false, Listen: joinAddrs(publicAddrs), Error: "one or more SSH listeners could not be opened"}
|
||||
}
|
||||
|
||||
// Legacy local_ssh_listen is intentionally ignored. DragonCore handles DNSTT in-process.
|
||||
newCfg.LocalSSHListen = ""
|
||||
|
||||
// TLS forwarders
|
||||
for _, e := range tlsPool.Sync(newCfg.TLSForwarders) {
|
||||
report.warnf("TLS listener error: %v", e)
|
||||
|
||||
@@ -530,6 +530,7 @@ cat > "$INSTALL_DIR/config.json" <<EOF
|
||||
{
|
||||
"listen": "0.0.0.0:80",
|
||||
"extra_listen": ["0.0.0.0:8080"],
|
||||
"local_ssh_listen": "127.0.0.1:2222",
|
||||
"host_key_file": "${INSTALL_DIR}/ssh_host_rsa_key",
|
||||
"quiet": false,
|
||||
"admin_dir": "${INSTALL_DIR}/admin",
|
||||
@@ -694,6 +695,7 @@ echo -e "${GREEN}═════════════════════
|
||||
echo ""
|
||||
echo -e " Server IP : ${YELLOW}${SERVER_IP}${NC}"
|
||||
echo -e " SSH ports : 80, 8080 (HTTP-injected SSH)"
|
||||
echo -e " Internal SSH : 127.0.0.1:2222 (raw SSH for local proxies)"
|
||||
echo -e " VLESS port : 10086"
|
||||
echo -e " VLESS UUID : ${YELLOW}${UUID}${NC}"
|
||||
echo -e " DNSTT DNS : UDP 53 redirects to local UDP 5300"
|
||||
|
||||
@@ -87,8 +87,10 @@ type Config struct {
|
||||
// "[::]:80", "[2001:db8::20]:8080". Empty slice means no
|
||||
// additional listeners.
|
||||
ExtraListen []string `json:"extra_listen"`
|
||||
// Legacy compatibility only. DragonCore no longer starts a local raw SSH listener.
|
||||
LocalSSHListen string `json:"local_ssh_listen,omitempty"`
|
||||
// LocalSSHListen is the raw SSH endpoint used by local proxy/tunnel daemons.
|
||||
// It is always enabled, defaults to 127.0.0.1:2222, and is restricted to a
|
||||
// numeric loopback address so it cannot accidentally become a public port.
|
||||
LocalSSHListen string `json:"local_ssh_listen"`
|
||||
HostKeyFile string `json:"host_key_file"`
|
||||
Quiet bool `json:"quiet"`
|
||||
|
||||
@@ -1288,7 +1290,7 @@ func loadConfig(path string) (*Config, map[string]*UserState, error) {
|
||||
}
|
||||
|
||||
if cfg.Listen == "" {
|
||||
cfg.Listen = ":2222"
|
||||
cfg.Listen = defaultMainListen
|
||||
}
|
||||
if cfg.HostKeyFile == "" {
|
||||
cfg.HostKeyFile = "ssh_host_rsa_key"
|
||||
@@ -2867,8 +2869,8 @@ func serveHTTP80(ln net.Listener) {
|
||||
|
||||
// serveRawSSH accepts connections on ln and passes each directly into
|
||||
// handleConn. Unlike serveHTTP80 it does not perform HTTP cleanup
|
||||
// and starts the SSH handshake immediately. This is used for
|
||||
// local-only listeners that other daemons (e.g. DNSTT) dial into.
|
||||
// and starts the SSH handshake immediately. This is used by local proxy and
|
||||
// tunnel daemons that need a stable SSH upstream.
|
||||
func serveRawSSH(ln net.Listener) {
|
||||
for {
|
||||
c, err := ln.Accept()
|
||||
@@ -3473,12 +3475,20 @@ func main() {
|
||||
|
||||
// Initialise listener pools (used for initial startup and hot-reload alike).
|
||||
publicPool = newListenerPool(serveHTTP80)
|
||||
localPool = newListenerPool(serveRawSSH)
|
||||
tlsPool = newTLSListenerPool()
|
||||
|
||||
for _, msg := range normalizeRuntimePorts(cfg) {
|
||||
log.Printf("startup config fallback: %s", msg)
|
||||
}
|
||||
|
||||
// Keep a plain, loopback-only SSH endpoint available to local proxy and
|
||||
// tunnel daemons. It has its own listener pool, so cycling the public proxy
|
||||
// ports does not close this socket.
|
||||
for _, e := range localPool.Sync([]string{cfg.LocalSSHListen}) {
|
||||
log.Printf("failed to start internal SSH listener: %v", e)
|
||||
}
|
||||
|
||||
// Start the integrated DNSTT and UDPGW if configured. Startup errors are logged
|
||||
// but do not crash the panel; the admin UI exposes the logs and service status.
|
||||
if err := startDNSTT(cfg.DNSTT, sshConfig); err != nil {
|
||||
|
||||
@@ -387,7 +387,7 @@ patch_configs() {
|
||||
|
||||
if [[ -f "$cfg" ]]; then
|
||||
python3 - "$cfg" <<'PYEOF'
|
||||
import json, sys
|
||||
import ipaddress, json, sys
|
||||
path = sys.argv[1]
|
||||
try:
|
||||
with open(path) as f:
|
||||
@@ -399,8 +399,23 @@ changed = False
|
||||
if 'banner_file' not in d:
|
||||
d['banner_file'] = '/opt/sshpanel/banner.txt'
|
||||
changed = True
|
||||
if 'local_ssh_listen' in d:
|
||||
d.pop('local_ssh_listen', None)
|
||||
local_ssh = str(d.get('local_ssh_listen') or '').strip()
|
||||
local_ssh_valid = False
|
||||
try:
|
||||
if local_ssh.startswith('['):
|
||||
end = local_ssh.index(']')
|
||||
host = local_ssh[1:end]
|
||||
if local_ssh[end + 1:end + 2] != ':':
|
||||
raise ValueError('missing port')
|
||||
port = int(local_ssh[end + 2:])
|
||||
else:
|
||||
host, port_text = local_ssh.rsplit(':', 1)
|
||||
port = int(port_text)
|
||||
local_ssh_valid = ipaddress.ip_address(host).is_loopback and 1 <= port <= 65535
|
||||
except (ValueError, IndexError):
|
||||
pass
|
||||
if not local_ssh_valid:
|
||||
d['local_ssh_listen'] = '127.0.0.1:2222'
|
||||
changed = True
|
||||
x = d.get('xray')
|
||||
if isinstance(x, dict):
|
||||
|
||||
Reference in New Issue
Block a user