some minor improvements \\ enough work for today

This commit is contained in:
2024-02-14 00:02:35 +01:00
parent 512ef3b357
commit 9ca119e4df
14 changed files with 233 additions and 119 deletions

17
app.go
View File

@@ -105,15 +105,20 @@ func displayCinfo() {
fmt.Println("| |")
fmt.Println("| *** DNS *** |")
fmt.Println("| |")
fmt.Println("| hijack_ip = ", config.HijackIP, " |")
fmt.Println("| hijack_app = ", config.HijackApp, " |")
fmt.Println("| hijack_img = ", config.HijackImg, " |")
fmt.Println("| forward_ip = ", config.ForwardIP, " |") // any big ip address and my design tabs too far :( haha
fmt.Println("| hijack_ip = ", config.HijackIP, " |")
fmt.Println("| hijack_app = ", config.HijackApp, " |")
fmt.Println("| hijack_img = ", config.HijackImg, " |")
fmt.Println("| forward_ip = ", config.ForwardIP, " |") // any big ip address and my design tabs too far :( haha
fmt.Println("| forward_port = ", config.ForwardPort, " |")
fmt.Println("| |")
fmt.Println("| *** WEB *** |")
fmt.Println("| |")
fmt.Println("| https_port = ", config.HttpsPort, " |")
fmt.Println("| https_port = ", config.HttpPort, " |")
fmt.Println("| https_port = ", config.HttpsPort, " |")
fmt.Println("| https_port = ", config.HttpPort, " |")
fmt.Println("| |")
fmt.Println("| *** CERTGEN *** |")
fmt.Println("| |")
fmt.Println("| common_name = ", config.CertName, " |")
fmt.Println("| |")
fmt.Println("=========================================")
fmt.Println("| go to brain.seppjm.com/# |")

View File

@@ -1,81 +0,0 @@
// /\_/|
// { ' ' } JellyCAT
// \____\
//----------------------------DOMView--------------------------------------------
var JCATAboutXML = '<?xml version="1.0" encoding="UTF-8"?>\n' +
'<atv>\n' +
' <head>\n' +
' </head>\n' +
' <body>\n' +
' <scrollingText id="com.jellycat.jcatabout" initialSelection="1">\n' +
' <title>JellyCAT About</title>\n' +
' <text><![CDATA[\n' +
'// /\\_/ |\n' +
'// { \' \' } JellyCAT\n' +
'// \\____\\\n' +
'\n' +
'ENGLISH | ABOUT\n' +
' \n' +
'JellyCAT $atvcsettings.version\n' +
' \n' +
'Thank you for using JellyCAT! A (hacky) Jellyfin client for Apple TV 2 & 3.\n' +
' \n' +
'== soon more ==\n' +
' \n' +
'\n\n\n' +
'-=JellyCAT Server (JCHOST) Information=-\n' +
'\n\n' +
'JellyCAT Server Host (fallback):\n' +
'http://jcathost.dns\n' +
'\n' +
'ATVCSETTINGS pick-up location:\n' +
'http://jcathost.dns/atvcsettings\n' +
'\n' +
'ATVCSETTINGS Hello:\n' +
'$atvcsettings.hello\n' +
'\n' +
'ATVCSETTINGS System Information:\n' +
'$atvcsettings.system\n' +
'\n' +
'JellyCat Version:\n' +
'$atvcsettings.version\n' +
'\n' +
'Hijacked Host App domain\n' +
'$atvcsettings.sighost\n' +
'\n' +
'JellyCAT Server Host IP\n' +
'$atvcsettings.hostip\n' +
'\n' +
'-=Jellyfin Client settings=-\n' +
' ]]></text>\n' +
' <buttons>\n' +
' <actionButton onSelect="DomViewManager.unloadView(\'JcatAboutView\');" id="close">\n' +
' <title>Close</title>\n' +
' </actionButton>\n' +
' </buttons>\n' +
' </scrollingText>\n' +
' </body>\n' +
'</atv>';
JCATAboutXML = JCATAboutXML
.replace(/\$atvcsettings\.hello/g, atv.jcathost.HelloMessage)
.replace(/\$atvcsettings\.system/g, atv.jcathost.System)
.replace(/\$atvcsettings\.version/g, atv.jcathost.Version)
.replace(/\$atvcsettings\.sighost/g, atv.jcathost.SigHost)
.replace(/\$atvcsettings\.hostip/g, atv.jcathost.HostIP);
function generateJCATAboutXML() {
var doc = atv.parseXML( JCATAboutXML );
console.log( "Creating the view --> " );
DomViewManager.createView( "JcatAboutView" );
console.log( "Loading the view --> " );
DomViewManager.loadView( "JcatAboutView", doc );
console.log( "View is loaded" );
}

View File

@@ -7,6 +7,7 @@
var JCATHOSTInfoXML = '<?xml version="1.0" encoding="UTF-8"?>\n' +
'<atv>\n' +
' <head>\n' +
' <script src="http://jcathost.dns/js/settingloader.js"/>\n' +
' </head>\n' +
' <body>\n' +
' <scrollingText id="com.jellycat.jcathostinfo" initialSelection="1">\n' +
@@ -42,7 +43,7 @@ var JCATHOSTInfoXML = '<?xml version="1.0" encoding="UTF-8"?>\n' +
'$atvcsettings.hostip\n' +
']]></text>\n' +
' <buttons>\n' +
' <actionButton onSelect="generateJCATAboutXML();" id="about">\n' +
' <actionButton onSelect="loadAbout();" id="about">\n' +
' <title>About</title>\n' +
' </actionButton>\n' +
' <actionButton onSelect="DomViewManager.unloadView(\'JcathostInfoView\');" id="close">\n' +
@@ -71,4 +72,6 @@ function generateJCATHOSTInfoXML() {
DomViewManager.loadView( "JcathostInfoView", doc );
console.log( "View is loaded" );
}
}
// I will keep this DomView generator for reference, however I like my new way of templating better

View File

@@ -946,5 +946,65 @@ var DomViewManager = ( function() {
// ------ End DOM View Manager --------
// ***************************************************
// Extra's
// PlexConnect ATV UTILS
// https://github.com/iBaa/PlexConnect/blob/master/assets/js/utils.js
// Some
// atv.Document extensions
if( atv.Document ) {
atv.Document.prototype.getElementById = function(id) {
var elements = this.evaluateXPath("//*[@id='" + id + "']", this);
if ( elements && elements.length > 0 ) {
return elements[0];
}
return undefined;
}
}
// atv.Element extensions
if( atv.Element ) {
atv.Element.prototype.getElementsByTagName = function(tagName) {
return this.ownerDocument.evaluateXPath("descendant::" + tagName, this);
}
atv.Element.prototype.getElementByTagName = function(tagName) {
var elements = this.getElementsByTagName(tagName);
if ( elements && elements.length > 0 ) {
return elements[0];
}
return undefined;
}
}
// string extension: format()
// see http://stackoverflow.com/a/4673436
if (!String.prototype.format) {
String.prototype.format = function() {
var args = arguments;
return this.replace(/{(\d+)}/g, function(match, number) {
return typeof args[number] != 'undefined' ? args[number] : match;
});
};
}
// Always love a good hack haha!
/*
* xml updater Major Hack :)
*/
function updateContextXML()
{
xmlstr = '<atv><body><optionList id="fakeUpdater" autoSelectSingleItem="true"> \
<items><oneLineMenuItem id="0" onSelect="atv.unloadPage()"><label></label> \
</oneLineMenuItem></items></optionList></body></atv>';
xmlDoc = atv.parseXML(xmlstr);
atv.loadXML(xmlDoc);
}
console.log('Reached EOF!');

View File

@@ -27,9 +27,10 @@ function setServerAddress() {
function(value) {
// Save server address to localStorage
atv.localStorage['jellyfin_server_address'] = value;
fetchDataAndRender();
},
function() {
fetchDataAndRender();
},
atv.localStorage['jellyfin_server_address'] || ""
);
@@ -44,9 +45,10 @@ function setUsername() {
function(value) {
// Save username to localStorage
atv.localStorage['jellyfin_username'] = value;
fetchDataAndRender();
},
function() {
fetchDataAndRender();
},
atv.localStorage['jellyfin_username'] || ""
);
@@ -61,10 +63,30 @@ function setPassword() {
function(value) {
// Save password to localStorage
atv.localStorage['jellyfin_password'] = value;
fetchDataAndRender();
},
function() {
fetchDataAndRender();
},
atv.localStorage['jellyfin_password'] || ""
);
}
// Let's try finding and changing the values
function fetchDataAndRender() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var xmlstr = xhttp.responseText;
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);
var xmlDoc = atv.parseXML(modifiedXml);
atv.loadAndSwapXML(xmlDoc);
}
};
xhttp.open("GET", 'https://' + atv.jcathost.SigHost + '/xml/server-settings.xml', true);
xhttp.send();
}

42
app/js/settingloader.js Normal file
View File

@@ -0,0 +1,42 @@
// /\_/|
// { ' ' } JellyCAT
// \____\
function loadServerSettings(){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var xmlstr = xhttp.responseText;
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);
var xmlDoc = atv.parseXML(modifiedXml);
atv.loadXML(xmlDoc);
}
};
xhttp.open("GET", 'https://' + atv.jcathost.SigHost + '/xml/server-settings.xml', true);
xhttp.send();
}
function loadAbout(){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var xmlstr = xhttp.responseText;
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(/\$atvcsettings\.hello/g, atv.jcathost.HelloMessage)
.replace(/\$atvcsettings\.system/g, atv.jcathost.System)
.replace(/\$atvcsettings\.version/g, atv.jcathost.Version)
.replace(/\$atvcsettings\.sighost/g, atv.jcathost.SigHost)
.replace(/\$atvcsettings\.hostip/g, atv.jcathost.HostIP);
var xmlDoc = atv.parseXML(modifiedXml);
atv.loadXML(xmlDoc);
}
};
xhttp.open("GET", 'https://' + atv.jcathost.SigHost + '/xml/about.xml', true);
xhttp.send();
}

54
app/xml/about.xml Normal file
View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<atv>
<head>
</head>
<body>
<scrollingText id="com.jellycat.jcatabout" initialSelection="1">
<title>JellyCAT About</title>
<text><![CDATA[
// /\_/ |
// { ' ' } JellyCAT
// \____\
ENGLISH | ABOUT
JellyCAT $atvcsettings.version
Thank you for using JellyCAT! A (hacky) Jellyfin client for Apple TV 2 & 3.
== soon more ==
-=JellyCAT Server (JCHOST) Information=-
JellyCAT Server Host (fallback):
http://jcathost.dns
ATVCSETTINGS pick-up location:
http://jcathost.dns/atvcsettings
ATVCSETTINGS Hello:
$atvcsettings.hello
ATVCSETTINGS System Information:
$atvcsettings.system
JellyCat Version:
$atvcsettings.version
Hijacked Host App domain
$atvcsettings.sighost
JellyCAT Server Host IP
$atvcsettings.hostip
-=Jellyfin Client settings=-
]]></text>
<buttons>
<actionButton onSelect="atv.unloadPage();" id="close">
<title>Close</title>
</actionButton>
</buttons>
</scrollingText>
</body>
</atv>

View File

@@ -3,7 +3,6 @@
<head>
<script src="http://jcathost.dns/js/jcm.js"/>
<script src="http://jcathost.dns/js/jcathostinfo.js"/>
<script src="http://jcathost.dns/js/about.js"/>
</head>
<body>
<optionDialog id="com.jellycat.devtools">
@@ -16,7 +15,7 @@
<description>These options are intended for testing your development environment only. It is crucial to refrain from utilizing these test functions on server hosts that are not under your management, as doing so may inadvertently expose sensitive data to the server's administrator.</description>
<menu>
<initialSelection>
<row>5</row>
<row>7</row>
</initialSelection>
<sections>
<menuSection>
@@ -36,7 +35,13 @@
<oneLineMenuItem id="list_4" accessibilityLabel="Option 5" onSelect="console.log('loading jcathostinfo-page'); generateJCATHOSTInfoXML();">
<label>JCATHOST Information</label>
</oneLineMenuItem>
<oneLineMenuItem id="list_5" accessibilityLabel="Option 6" onSelect="console.log('Unloading page'); atv.unloadPage();">
<oneLineMenuItem id="list_5" accessibilityLabel="Option 6" onSelect="console.log('UDID: ' + atv.device.udid);">
<label>Print device UDID (log)</label>
</oneLineMenuItem>
<oneLineMenuItem id="list_6" accessibilityLabel="Option 7" onSelect="console.log('UDID: ' + atv.device.displayName);">
<label>Print device DisplayName (log)</label>
</oneLineMenuItem>
<oneLineMenuItem id="list_7" accessibilityLabel="Option 8" onSelect="console.log('Unloading page'); atv.unloadPage();">
<label>Unload Page (go back)</label>
</oneLineMenuItem>
</items>

View File

@@ -25,18 +25,18 @@
<items>
<oneLineMenuItem accessibilityLabel="List item 0" id="list_0" onSelect="setServerAddress();">
<label>Server Address</label>
<rightLabel>(not set)</rightLabel>
<rightLabel>$server_address</rightLabel>
</oneLineMenuItem>
<oneLineMenuItem accessibilityLabel="List item 1" id="list_1" onSelect="setUsername();">
<label>Server Username</label>
<rightLabel>(not set)</rightLabel>
<rightLabel>$username</rightLabel>
</oneLineMenuItem>
<oneLineMenuItem accessibilityLabel="List item 2" id="list_2" onSelect="setPassword();">
<label>Server Password</label>
<rightLabel>(always hidden)</rightLabel>
</oneLineMenuItem>
<oneLineMenuItem accessibilityLabel="List item 3" id="list_3" onSelect="">
<label>Test connection</label>
<oneLineMenuItem accessibilityLabel="List item 3" id="list_3" onSelect="testJellyfinConnection();">
<label>Test Connection</label>
</oneLineMenuItem>
<oneLineMenuItem accessibilityLabel="List item 4" id="list_4" onSelect="console.log('Logging out and clearing storage'); atv.localStorage.clear(); atv.sessionStorage.clear(); atv.exitApp();">
<label>Remove saved data</label>

View File

@@ -3,6 +3,7 @@
<head>
<script src="http://jcathost.dns/js/jcm.js"/>
<script src="http://jcathost.dns/js/about.js"/>
<script src="http://jcathost.dns/js/settingloader.js"/>
</head>
<body>
<listWithPreview id="com.jellycat.settings">
@@ -25,7 +26,7 @@
</horizontalDivider>
</header>
<items>
<twoLineMenuItem id="list_center_1" accessibilityLabel="Menu Item 1" onSelect="atvutils.loadURL('https://' + atv.jcathost.SigHost + '/xml/server-settings.xml');">
<twoLineMenuItem id="list_center_1" accessibilityLabel="Menu Item 1" onSelect="loadServerSettings();">
<label>Jellyfin Server Settings</label>
<label2>Set Jellyfin Server and User</label2>
<image>http://jcathost.dns/assets/img/jfserver.png</image>
@@ -48,7 +49,7 @@
<oneLineMenuItem id="list_center_1" accessibilityLabel="tools" onSelect="atvutils.loadURL('https://' + atv.jcathost.SigHost + '/xml/dvt/devtools.xml');">
<label>Tools</label>
</oneLineMenuItem>
<oneLineMenuItem id="list_center_1" accessibilityLabel="about" onSelect="generateJCATAboutXML();">
<oneLineMenuItem id="list_center_1" accessibilityLabel="about" onSelect="loadAbout()">
<label>About</label>
</oneLineMenuItem>
<oneLineMenuItem id="list_center_1" accessibilityLabel="about" onSelect="atvutils.loadURL('https://' + atv.jcathost.SigHost + '/xml/help.xml');">

View File

@@ -11,13 +11,14 @@ import (
)
type Config struct {
HijackIP string `toml:"hijack_ip"`
HijackApp string `toml:"hijack_app"`
HijackImg string `toml:"hijack_img"`
ForwardIP string `toml:"forward_ip"`
HttpsPort string `toml:"https_port"`
HttpPort string `toml:"http_port"`
CertName string `toml:"common_name"`
HijackIP string `toml:"hijack_ip"`
HijackApp string `toml:"hijack_app"`
HijackImg string `toml:"hijack_img"`
ForwardIP string `toml:"forward_ip"`
ForwardPort string `toml:"forward_port"`
HttpsPort string `toml:"https_port"`
HttpPort string `toml:"http_port"`
CertName string `toml:"common_name"`
}
var config Config

View File

@@ -67,7 +67,7 @@ func addHijackedAnswer(m *dns.Msg, name string) {
func forwardRequest(m *dns.Msg, r *dns.Msg) {
resolver := &dns.Client{}
resp, _, err := resolver.Exchange(r, net.JoinHostPort(config.ForwardIP, "53"))
resp, _, err := resolver.Exchange(r, net.JoinHostPort(config.ForwardIP, config.ForwardPort))
if err == nil {
m.Answer = append(m.Answer, resp.Answer...)
}

View File

@@ -26,7 +26,7 @@ func main() {
// Default information store
JellyCAT = JcatDefaults{
Version: "0.1.2revB",
Version: "0.1.2revC",
Name: "JellyCAT Serving stHack",
HostName: config.CertName,
HostIP: config.HijackIP,

View File

@@ -6,15 +6,17 @@
# DNS Settings
# hijack_ip = the ip address that the dns server sends out as the A record, make this your JellyCAT Host
# hijack_app = the main domain we want to use to hijack, we use this domain to intercept DNS
# hijack_img = the domain we intercept for the imaging (branding) of the app we want to hijack (this function is currently removed)
# forward_ip = the ip address of an dns server we want to forward uninteresting DNS requests to
# hijack_ip = the ip address that the dns server sends out as the A record, make this your JellyCAT Host
# hijack_app = the main domain we want to use to hijack, we use this domain to intercept DNS
# hijack_img = the domain we intercept for the imaging (branding) of the app we want to hijack (this function is currently removed)
# forward_ip = the ip address of an dns server we want to forward uninteresting DNS requests to
# forward_port = the port of an dns server we want to forward uninteresting DNS requests to
hijack_ip = "192.168.11.23"
hijack_app = "atv.qello.com."
hijack_img = "notused.com."
forward_ip = "1.1.1.1"
hijack_ip = "192.168.11.23"
hijack_app = "atv.qello.com."
hijack_img = "notused.com."
forward_ip = "1.1.1.1"
forward_port = "53"
# WEBServer Settings
@@ -22,7 +24,7 @@ forward_ip = "1.1.1.1"
# http_port = the port you want to open for the http webserver (edit for use with reverse proxy)
https_port = ":443"
http_port = ":80"
http_port = ":80"
# CERTGEN Settings