diff --git a/.gitignore b/.gitignore index 771674c..a745ee7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -go/jilo-agent +jilo-agent diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b92962..e94d09a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file. --- +## Unreleased + +#### Links +- upstream: https://code.lindeas.com/lindeas/jilo-agent/compare/v0.1...HEAD +- codeberg: https://codeberg.org/lindeas/jilo-agent/compare/v0.1...HEAD +- github: https://github.com/lindeas/jilo-agent/compare/v0.1...HEAD +- gitlab: https://gitlab.com/lindeas/jilo-agent/-/compare/v0.1...HEAD + +### Added +- Removed PHP version +- Added support for HTTPS + +--- + ## 0.1 - 2024-10-02 #### Links diff --git a/README.md b/README.md index 778ea69..d99e3e0 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,7 @@ ## overview -Jilo Agent - a remote agent for Jilo Web - -Initial version is in PHP. - -The current version is in "go" folder and is in Go. +Jilo Agent - a remote agent for Jilo Web written in Go. ## license @@ -32,6 +28,8 @@ go build -o jilo-agent main.go The config file is "jilo-agent.json", in the same folder as the "jilo-agent" binary. +If you add the SSL config options, HTTPS will be used. + You can run the agent without a config file - then default vales are used. ## usage diff --git a/config.php b/config.php deleted file mode 100644 index eb958ff..0000000 --- a/config.php +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/go/build.sh b/doc/build.sh similarity index 97% rename from go/build.sh rename to doc/build.sh index d459111..7e18c14 100755 --- a/go/build.sh +++ b/doc/build.sh @@ -15,6 +15,6 @@ # - upx ### -CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o jilo-agent main.go +CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o jilo-agent ../main.go upx --best --lzma -o jilo-agent-upx jilo-agent mv jilo-agent-upx jilo-agent diff --git a/go/jilo-agent.conf b/doc/jilo-agent.conf similarity index 79% rename from go/jilo-agent.conf rename to doc/jilo-agent.conf index cf38812..48e7127 100644 --- a/go/jilo-agent.conf +++ b/doc/jilo-agent.conf @@ -8,6 +8,12 @@ agent_port: 8081 # secret for checking JWT (same as in Jilo Web agent config) secret_key: "mysecretkey" +# SSL certificate file (relative or full path) +ssl_cert: "jilo-agent.crt" + +# SSL key file (relative or full path) +ssl_key: "jilo-agent.key" + # the port we check for nginx nginx_port: 80 diff --git a/functions.php b/functions.php deleted file mode 100644 index edd447e..0000000 --- a/functions.php +++ /dev/null @@ -1,50 +0,0 @@ - 'Failed to decode the JSON reply from the service.']; - } - return $decodedData; -} - - -// get JVB data -function getJVBStatus() { - $status = trim(shell_exec('systemctl is-active jitsi-videobridge2')); - return ($status === 'active') ? 'running' : 'not running'; -} -function getJVBStats($command) { - $data = shell_exec($command); - $decodedData = json_decode($data, true); - if (json_last_error() !== JSON_ERROR_NONE) { - return ['error' => 'Failed to decode the JSON reply from the service.']; - } - return $decodedData; -} - -?> diff --git a/go/go.mod b/go.mod similarity index 100% rename from go/go.mod rename to go.mod diff --git a/go/go.sum b/go.sum similarity index 100% rename from go/go.sum rename to go.sum diff --git a/index.php b/index.php deleted file mode 100644 index bfd7f5b..0000000 --- a/index.php +++ /dev/null @@ -1,52 +0,0 @@ - getNginxStatus(), - 'nginx_connections' => getNginxConnections(), - ]; - echo json_encode($data, JSON_PRETTY_PRINT) . "\n"; - -// prosody status -} elseif ($request === '/prosody' || $request === "/$scriptname/prosody") { - $data = [ - 'prosody_status' => getProsodyStatus(), - ]; - echo json_encode($data, JSON_PRETTY_PRINT) . "\n"; - -// jicofo status -} elseif ($request === '/jicofo' || $request === "/$scriptname/jicofo") { - $jicofoStatsCommand = "curl -s $jicofoStatsURL"; - $jicofoStatsData = getJicofoStats($jicofoStatsCommand); - $data = [ - 'jicofo_status' => getJicofoStatus(), - 'jicofo_API_stats' => $jicofoStatsData, - ]; - echo json_encode($data, JSON_PRETTY_PRINT) . "\n"; - -// jvb status -} elseif ($request === '/jvb' || $request === "/$scriptname/jvb") { - $jvbStatsCommand = "curl -s $jvbStatsURL"; - $jvbStatsData = getJVBStats($jvbStatsCommand); - $data = [ - 'jvb_status' => getJVBStatus(), - 'jvb_API_stats' => $jvbStatsData, - ]; - echo json_encode($data, JSON_PRETTY_PRINT) . "\n"; - -// default response - error -} else { - echo json_encode(['error' => 'Endpoint not found']) . "\n"; -} - -?> diff --git a/go/main.go b/main.go similarity index 97% rename from go/main.go rename to main.go index 475c281..a5e864f 100644 --- a/go/main.go +++ b/main.go @@ -28,6 +28,8 @@ import ( // Config holds the structure of the configuration file type Config struct { AgentPort int `yaml:"agent_port"` + SSLcert string `yaml:"ssl_cert"` + SSLkey string `yaml:"ssl_key"` SecretKey string `yaml:"secret_key"` NginxPort int `yaml:"nginx_port"` ProsodyPort int `yaml:"prosody_port"` @@ -317,7 +319,8 @@ func main() { // start the http server agentPortStr := fmt.Sprintf(":%d", config.AgentPort) fmt.Printf("Starting Jilo agent on port %d.\n", config.AgentPort) - if err := http.ListenAndServe(agentPortStr, corsHandler); err != nil { +// if err := http.ListenAndServe(agentPortStr, corsHandler); err != nil { + if err := http.ListenAndServeTLS(agentPortStr, config.SSLcert, config.SSLkey, corsHandler); err != nil { log.Fatalf("Could not start the agent: %v\n", err) } }