diff --git a/app/js/jellyfin-setup.js b/app/js/jellyfin-setup.js
index c50175d..0095ad1 100644
--- a/app/js/jellyfin-setup.js
+++ b/app/js/jellyfin-setup.js
@@ -23,7 +23,7 @@ function setServerAddress() {
showTextEntryPage(
"emailAddress",
"Set Jellyfin Server Address",
- "Enter the address of the Jellyfin server:",
+ "Enter the address of the Jellyfin server: \n\nExample: \nhttps://demo.jellyfin.org/stable \nhttp://192.168.11.11:8096",
function(value) {
// Save server address to localStorage
atv.localStorage['jellyfin_server_address'] = value;
@@ -32,7 +32,7 @@ function setServerAddress() {
function() {
fetchDataAndRender();
},
- atv.localStorage['jellyfin_server_address'] || ""
+ atv.localStorage['jellyfin_server_address'] || "http://"
);
}
@@ -40,8 +40,8 @@ function setServerAddress() {
function setUsername() {
showTextEntryPage(
"emailAddress",
- "Set Username",
- "Enter your username:",
+ "Set Jellyfin Username",
+ "Enter your Jellyfin username:",
function(value) {
// Save username to localStorage
atv.localStorage['jellyfin_username'] = value;
@@ -58,8 +58,8 @@ function setUsername() {
function setPassword() {
showTextEntryPage(
"password",
- "Set Password",
- "Enter your password:",
+ "Set Jellyfin Password",
+ "Enter your Jellyfin password:",
function(value) {
// Save password to localStorage
atv.localStorage['jellyfin_password'] = value;
@@ -74,7 +74,6 @@ function setPassword() {
}
// Let's try finding and changing the values
-
function fetchDataAndRender() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
@@ -90,3 +89,108 @@ function fetchDataAndRender() {
xhttp.open("GET", 'https://' + atv.jcathost.SigHost + '/xml/server-settings.xml', true);
xhttp.send();
}
+
+function getJellyfinInfo() {
+ var xhttp = new XMLHttpRequest();
+ var serverAddress = atv.localStorage['jellyfin_server_address'];
+
+ if (!serverAddress) {
+ showServerErrorScreen();
+ return;
+ }
+
+ if (!serverAddress || !/(http|https):\/\//.test(serverAddress)) {
+ showServerErrorScreen();
+ return;
+ }
+
+ xhttp.onreadystatechange = function() {
+ if (this.readyState == 4) {
+ if (this.status == 200) {
+ var response = JSON.parse(this.responseText);
+ if (response && response.ProductName === "Jellyfin Server") {
+ displayJellyfinInfo(response);
+ } else {
+ showServerErrorScreen();
+ }
+ } else {
+ showServerErrorScreen();
+ }
+ }
+ };
+
+ xhttp.open("GET", serverAddress + "/system/info/public", true);
+ xhttp.send();
+}
+
+function displayJellyfinInfo(info) {
+ var serverName = info.ServerName;
+ var version = info.Version;
+ var productName = info.ProductName;
+ var operatingSystem = info.OperatingSystem;
+ var id = info.Id;
+ var serverAddress = atv.localStorage['jellyfin_server_address'];
+
+ var xmlstr = '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' Jellyfin Server Response:' +
+ ' ' +
+ ' ' +
+ ' JellyCAT has successfully established a connection with the Jellyfin Server and received the following response:\n\n' + productName + ' (' + serverAddress + ')' +
+ '\n\nServer Name: ' + serverName + '\nVersion: ' + version +'\nOS: ' + operatingSystem + '\nid: ' + id +'\n\nTo begin viewing content, simply click on "Login" to log in to this server and receive your authentication key!' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ xmlDoc = atv.parseXML(xmlstr);
+ atv.loadXML(xmlDoc);
+
+ console.log("Valid Jellyfin server: " + serverName + " " + version)
+}
+
+function showServerErrorScreen(){
+ var xmlstr = '' +
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ xmlDoc = atv.parseXML(xmlstr);
+ atv.loadXML(xmlDoc);
+
+ console.log("Jellyfin Server Connection Issue")
+}
+
+function authenticateJellyfin(){
+ console.log("yapppa!")
+}
\ No newline at end of file
diff --git a/app/js/settingloader.js b/app/js/settingloader.js
index d6d96c4..6a35964 100644
--- a/app/js/settingloader.js
+++ b/app/js/settingloader.js
@@ -26,8 +26,8 @@ function loadAbout(){
var serverAddress = atv.localStorage['jellyfin_server_address'];
var username = atv.localStorage['jellyfin_username'];
var modifiedXml = xmlstr
- .replace(/\$server_address/g, serverAddress)
- .replace(/\$username/g, username)
+ .replace(/\$jellyfin.server_address/g, serverAddress)
+ .replace(/\$jellyfin.username/g, username)
.replace(/\$atvcsettings\.hello/g, atv.jcathost.HelloMessage)
.replace(/\$atvcsettings\.system/g, atv.jcathost.System)
.replace(/\$atvcsettings\.version/g, atv.jcathost.Version)
diff --git a/app/xml/about.xml b/app/xml/about.xml
index d42547e..e381f53 100644
--- a/app/xml/about.xml
+++ b/app/xml/about.xml
@@ -43,6 +43,12 @@ JellyCAT Server Host IP
$atvcsettings.hostip
-=Jellyfin Client settings=-
+
+Jellyfin Server
+$jellyfin.server_address
+
+Jellyfin User
+$jellyfin.username
]]>
diff --git a/app/xml/server-settings.xml b/app/xml/server-settings.xml
index ae6d806..ff49e11 100644
--- a/app/xml/server-settings.xml
+++ b/app/xml/server-settings.xml
@@ -35,7 +35,7 @@
(always hidden)
-
+
diff --git a/configLoader.go b/configLoader.go
index 4404c6e..8771653 100644
--- a/configLoader.go
+++ b/configLoader.go
@@ -11,6 +11,8 @@ import (
)
type Config struct {
+ DnsServEN bool `toml:"dns_server_en"`
+ WebServEN bool `toml:"web_server_en"`
HijackIP string `toml:"hijack_ip"`
HijackApp string `toml:"hijack_app"`
HijackImg string `toml:"hijack_img"`
@@ -18,6 +20,7 @@ type Config struct {
ForwardPort string `toml:"forward_port"`
HttpsPort string `toml:"https_port"`
HttpPort string `toml:"http_port"`
+ JfRevURL string `toml:"jellyfin_url"`
CertName string `toml:"common_name"`
}
diff --git a/dnsResolver.go b/dnsResolver.go
index 9603c2b..b5604e3 100644
--- a/dnsResolver.go
+++ b/dnsResolver.go
@@ -49,7 +49,7 @@ func handleDNSRequest(w dns.ResponseWriter, r *dns.Msg) {
}
func shouldHijack(name string, qtype uint16) bool {
- return (name == config.HijackApp || name == config.HijackImg || name == "jcathost.dns.") && (qtype == dns.TypeA || qtype == dns.TypeAAAA)
+ return (name == config.HijackApp || name == config.HijackImg || name == "jcathost.dns." || name == "jellyfin.dns.") && (qtype == dns.TypeA || qtype == dns.TypeAAAA)
}
func handleHijackedRequest(name string) {
diff --git a/main.go b/main.go
index 475b930..648a6b3 100644
--- a/main.go
+++ b/main.go
@@ -26,7 +26,7 @@ func main() {
// Default information store
JellyCAT = JcatDefaults{
- Version: "0.1.2revC",
+ Version: "0.1.3revA",
Name: "JellyCAT Serving stHack",
HostName: config.CertName,
HostIP: config.HijackIP,
@@ -37,13 +37,21 @@ func main() {
fmt.Println(" JellyCAT", JellyCAT.Version)
fmt.Println()
- // DNS Server & Resolver function for hijacking and forwarding DNS requests
- fmt.Println("SYS-LOG: Attempting to start DNS Server...")
- dnsResolver()
+ if config.DnsServEN {
+ // DNS Server & Resolver function for hijacking and forwarding DNS requests
+ fmt.Println("SYS-LOG: Attempting to start DNS Server...")
+ dnsResolver()
+ } else {
+ fmt.Println("SYS-LOG: DNS Server disabled ")
+ }
- // Webserver for serving x and app to the ATV
- fmt.Println("SYS-LOG: Attempting to start WEB Server...")
- webServer()
+ if config.WebServEN {
+ // Webserver for serving x and app to the ATV
+ fmt.Println("SYS-LOG: Attempting to start WEB Server...")
+ webServer()
+ } else {
+ fmt.Println("SYS-LOG: WEB Server disabled ")
+ }
// App main for any other server-sided logic
fmt.Println("SYS-LOG: Attempting to start JellyCAT-Main...")
diff --git a/settings.cfg b/settings.cfg
index 439103e..ecf9084 100644
--- a/settings.cfg
+++ b/settings.cfg
@@ -4,6 +4,14 @@
# Edit your custom settings here
+# JellyCAT Settings
+
+# dns_server_en = Enable DNS Server (true) | Disable DNS Server (False)
+# Enable WEBServer = Enable WEB Server (true) | Disable WEB Server (False)
+
+dns_server_en = true
+web_server_en = true
+
# DNS Settings
# hijack_ip = the ip address that the dns server sends out as the A record, make this your JellyCAT Host
@@ -20,11 +28,13 @@ forward_port = "53"
# WEBServer Settings
-# https_port = the port you want to open for the https webserver with the self signed certificate
-# http_port = the port you want to open for the http webserver (edit for use with reverse proxy)
+# https_port = the port you want to open for the https webserver with the self signed certificate
+# http_port = the port you want to open for the http webserver (edit for use with reverse proxy)
+# jellyfin_url = JellyCAT has a simple reverse proxy built in for setting a secure jellyfin server behind http://jellyfin.dns
-https_port = ":443"
-http_port = ":80"
+https_port = ":443"
+http_port = ":80"
+jellyfin_url = "https://demo.jellyfin.org/stable"
# CERTGEN Settings
diff --git a/webServer.go b/webServer.go
index 5821966..d02af1f 100644
--- a/webServer.go
+++ b/webServer.go
@@ -9,6 +9,8 @@ import (
"fmt"
"io"
"net/http"
+ "net/http/httputil"
+ "net/url"
)
type ATVCSettings struct {
@@ -38,7 +40,25 @@ func webServer() {
func startHTTPSServer(certFile, keyFile string) {
fileServer := http.FileServer(http.Dir("app"))
- http.Handle("/", logHandler(fileServer))
+
+ targetURL, _ := url.Parse(config.JfRevURL)
+
+ reverseProxy := httputil.NewSingleHostReverseProxy(targetURL)
+
+ // Define a handler function that checks the request's host and path
+ http.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ // Check if the request's host is jellyfin.dns and reverse proxies it
+ if r.Host == "jellyfin.dns" {
+ // Pass the request to the reverse proxy
+ fmt.Print("\033[A\r")
+ fmt.Printf("WEB.SERVER-LOG: ReverseProxy: [%s] %s %s%s to %s \n", r.RemoteAddr, r.Method, r.Host, r.URL, targetURL)
+ resetCommand()
+ reverseProxy.ServeHTTP(w, r)
+ } else {
+ // Otherwise, pass the request to the file server
+ logHandler(fileServer).ServeHTTP(w, r)
+ }
+ }))
http.HandleFunc("/certificate.cer", func(w http.ResponseWriter, r *http.Request) {
logRequest(r)
@@ -125,7 +145,7 @@ func logHandler(next http.Handler) http.Handler {
func logRequest(r *http.Request) {
fmt.Print("\033[A\r")
- fmt.Printf("WEB.SERVER-LOG: [%s] %s %s \n", r.RemoteAddr, r.Method, r.URL)
+ fmt.Printf("WEB.SERVER-LOG: [%s] %s %s%s \n", r.RemoteAddr, r.Method, r.Host, r.URL)
resetCommand()
}