Skip to content

mihai209/Connector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CPanel Connector (Go)

English

connector-go is the runtime daemon used by CPanel for Docker lifecycle, console I/O, files, schedules, metrics, and SFTP.

Requirements

  • Go 1.22+
  • Docker engine + Docker CLI
  • Linux host
  • Optional host tools for archive extraction:
    • unzip
    • tar
    • gzip / gunzip
    • bzip2
    • xz

Build

cd /home/mihai/Desktop/cpanel/connector-go
go mod tidy
go build -o cpanel-connector-go ./

Run

CONNECTOR_CONFIG=/etc/cpanel-connector/config.json \
VOLUMES_PATH=/var/lib/cpanel/volumes \
./cpanel-connector-go

What It Handles

  • Connector authentication over WebSocket
  • Panic-safe WS handler dispatch (runtime recover + stack log)
  • Docker create/start/stop/restart/kill/delete
  • Live console stream + command execution (stdin)
  • Console command throttling per server (anti-flood)
  • File ops:
    • list/read/write
    • create folder
    • rename/delete/chmod
    • download
    • unarchive in background (extract_archive)
  • Per-server schedule actions
  • Runtime metrics + heartbeat
  • Runtime health endpoint: GET /healthz
  • Runtime readiness endpoint: GET /readyz (503 when WS to panel is down)
  • SFTP service with panel-backed auth

Minimal config.json

{
  "panel": {
    "url": "https://panel.example.com",
    "allowedUrls": ["https://panel.example.com"]
  },
  "api": {
    "allowedOrigins": ["https://panel.example.com"]
  },
  "connector": {
    "id": 1,
    "token": "REPLACE_WITH_CONNECTOR_TOKEN",
    "name": "node-1"
  },
  "sftp": {
    "host": "0.0.0.0",
    "port": 8312,
    "directory": "/var/lib/cpanel/volumes",
    "hostKeyPath": "/etc/cpanel-connector/sftp_host_rsa.key"
  },
  "transfers": {
    "downloadLimit": 0,
    "allowedDownloadHosts": [
      "github.com",
      "raw.githubusercontent.com",
      "codeload.github.com",
      "objects.githubusercontent.com",
      "mohistmc.github.io",
      "api.modrinth.com",
      "cdn.modrinth.com",
      "modrinth.com"
    ]
  },
  "docker": {
    "network": {
      "name": "cpanel_nw",
      "network_mode": "cpanel_nw",
      "driver": "bridge",
      "interface": "172.18.0.1",
      "dns": [],
      "enable_icc": true,
      "network_mtu": 1500
    }
  }
}

docker.network.dns is optional:

  • [] (or omitted): inherit Docker daemon/host DNS (recommended default)
  • explicit values: force those resolvers in runtime/install containers
  • "auto" / "host" / "inherit": alias for inherit mode

transfers.allowedDownloadHosts is an SSRF safety allowlist for remote file downloads. Only exact hosts from this list are allowed (http/https only).

Update Mode

./cpanel-connector-go --update

Checks: https://github.com/mihai209/Connector/releases

systemd Example

/etc/systemd/system/cpanel-connector-go.service

[Unit]
Description=CPanel Connector (Go)
After=network-online.target docker.service
Wants=network-online.target

[Service]
Type=simple
WorkingDirectory=/etc/cpanel-connector
Environment=CONNECTOR_CONFIG=/etc/cpanel-connector/config.json
Environment=VOLUMES_PATH=/var/lib/cpanel/volumes
ExecStart=/etc/cpanel-connector/cpanel-connector-go
Restart=always
RestartSec=3
User=root

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now cpanel-connector-go
sudo systemctl status cpanel-connector-go

Notes

  • Panel controls if SFTP is enabled/disabled.
  • SFTP username format is per server (username.random5).
  • SFTP password is the panel account password.
  • Connector fails fast if auth token is invalid.

Romana

connector-go este daemon-ul runtime folosit de CPanel pentru Docker lifecycle, consola, fisiere, schedule-uri, metrici si SFTP.

Cerinte

  • Go 1.22+
  • Docker engine + Docker CLI
  • Host Linux
  • Optional, utilitare host pentru extract arhive:
    • unzip
    • tar
    • gzip / gunzip
    • bzip2
    • xz

Build

cd /home/mihai/Desktop/cpanel/connector-go
go mod tidy
go build -o cpanel-connector-go ./

Rulare

CONNECTOR_CONFIG=/etc/cpanel-connector/config.json \
VOLUMES_PATH=/var/lib/cpanel/volumes \
./cpanel-connector-go

Ce Gestioneaza

  • Autentificarea connector-ului pe WebSocket
  • Docker create/start/stop/restart/kill/delete
  • Stream live de consola + executie comenzi (stdin)
  • Operatii fisiere:
    • list/read/write
    • create folder
    • rename/delete/chmod
    • download
    • unarchive in background (extract_archive)
  • Actiuni schedule per server
  • Metrici runtime + heartbeat
  • Serviciu SFTP cu autentificare validata de panel

config.json Minim

Foloseste exemplul din sectiunea English de mai sus.

Mod Update

./cpanel-connector-go --update

Verifica release-urile din: https://github.com/mihai209/Connector/releases

Exemplu systemd

Foloseste serviciul din sectiunea English de mai sus.

Note

  • Panel-ul controleaza daca SFTP este activ sau nu.
  • Username-ul SFTP este per server (username.random5).
  • Parola SFTP este parola contului din panel.
  • Connector-ul da fail fast daca token-ul de autentificare devine invalid.

About

A free open-source daemon for CPanel

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages