Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UsePort #31

Merged
merged 14 commits into from
Sep 3, 2022
2 changes: 1 addition & 1 deletion .github/workflows/dockerpublish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish to Docker Registry Manual
name: Manual Publish to Docker Registry
on:
workflow_dispatch:

Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/xTeVe_publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: xTeVe manual publish
name: xTeVe release manual
on:
workflow_dispatch:

Expand Down Expand Up @@ -45,4 +45,3 @@ jobs:
binary_name: xteve
build_flags: -v
ldflags: -X "main.appVersion=${{ steps.xteve_version.outputs.prop }}" -X "main.buildTime=${{ env.BUILD_TIME }}" -X main.gitCommit=${{ github.sha }} -X main.gitRef=${{ github.ref }}

2 changes: 1 addition & 1 deletion .github/workflows/xTeVe_release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: xTeVe release manual
name: xTeVe Release
on:
workflow_dispatch:
release:
Expand Down
4 changes: 4 additions & 0 deletions html/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@
"title": "Host Name Override",
"description": "Hostname xTeVe will use to form M3U and XMLTV files. This will override Host IP if set"
},
"usePort": {
"title": "Use Port in M3U File",
"description": "Use xTeVe port in M3U URL. Disable (most likely) for reverse proxies"
},
"tlsMode": {
"title": "TLS (HTTPS) mode",
"description": "Changes web server protocol to HTTPS.<br>For details, see <a href='https://github.com/SenexCrenshaw/xTeVe#tls-mode' target='_blank'>https://github.com/SenexCrenshaw/xTeVe#tls-mode</a>"
Expand Down
2 changes: 1 addition & 1 deletion src/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func Init() (err error) {
}

// Set Domain Names
setGlobalDomain(fmt.Sprintf("%s:%s", Settings.HostIP, Settings.Port))
setGlobalDomain()

System.URLBase = fmt.Sprintf("%s://%s:%s", System.ServerProtocol.WEB, Settings.HostIP, Settings.Port)

Expand Down
1 change: 1 addition & 0 deletions src/struct-system.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ type SettingsStruct struct {
Filter map[int64]interface{} `json:"filter"`
HostIP string `json:"hostIP"` // IP chosen in web client. Used to form m3u and xml files.
HostName string `json:"hostName"` // Hostname chosen in web client. Used to form m3u and xml files.
UsePort bool `json:"usePort"`
Key string `json:"key,omitempty"`
Language string `json:"language"`
LogEntriesRAM int `json:"log.entries.ram"`
Expand Down
1 change: 1 addition & 0 deletions src/struct-webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type RequestStruct struct {
FilesUpdate *bool `json:"files.update,omitempty"`
HostIP *string `json:"hostIP,omitempty"` // IP chosen in web client. Used to form m3u and xml files.
HostName *string `json:"hostName"` // Hostname chosen in web client. Used to form m3u and xml files.
UsePort *bool `json:"usePort"`
TempPath *string `json:"temp.path,omitempty"`
TLSMode *bool `json:"tlsMode,omitempty"`
Tuner *int `json:"tuner,omitempty"`
Expand Down
20 changes: 19 additions & 1 deletion src/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func loadSettings() (settings SettingsStruct, err error) {
defaults["git.branch"] = System.Branch
defaults["hostIP"] = "" // Will be set in resolveHostIP()
defaults["hostName"] = ""
defaults["usePort"] = true
defaults["language"] = "en"
defaults["log.entries.ram"] = 500
defaults["m3u8.adaptive.bandwidth.mbps"] = 10
Expand Down Expand Up @@ -235,7 +236,24 @@ func saveSettings(settings SettingsStruct) (err error) {
}

// Enable access via the Domain
func setGlobalDomain(domain string) {
func getGlobalDomain() (domain string) {
if Settings.HostName != "" {
domain = Settings.HostName
} else {
domain = Settings.HostIP
}
if Settings.UsePort {
domain = fmt.Sprintf("%s:%s", domain, Settings.Port)
}
return domain
}

func setGlobalDomain() {
setGlobalDomainWithDomain(getGlobalDomain())
}

// Enable access via the Domain
func setGlobalDomainWithDomain(domain string) {

System.Domain = domain

Expand Down
8 changes: 4 additions & 4 deletions src/webUI.go

Large diffs are not rendered by default.

42 changes: 17 additions & 25 deletions src/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@ func Index(w http.ResponseWriter, r *http.Request) {
var path = r.URL.Path
var debug string

if Settings.HostName != "" {
setGlobalDomain(Settings.HostName + ":" + Settings.Port)
} else {
setGlobalDomain(Settings.HostIP + ":" + Settings.Port)
}
setGlobalDomain()

debug = fmt.Sprintf("Web Server Request:Path: %s", path)
showDebug(debug, 2)
Expand Down Expand Up @@ -270,11 +266,7 @@ func xTeVe(w http.ResponseWriter, r *http.Request) {
var path = strings.TrimPrefix(r.URL.Path, "/")
var groups = []string{}

if Settings.HostName != "" {
setGlobalDomain(Settings.HostName + ":" + Settings.Port)
} else {
setGlobalDomain(Settings.HostIP + ":" + Settings.Port)
}
setGlobalDomain()

// XMLTV File
if strings.Contains(path, "xmltv/") {
Expand Down Expand Up @@ -412,11 +404,7 @@ func WS(w http.ResponseWriter, r *http.Request) {
}
defer conn.Close()

if Settings.HostName != "" {
setGlobalDomain(Settings.HostName + ":" + Settings.Port)
} else {
setGlobalDomain(Settings.HostIP + ":" + Settings.Port)
}
setGlobalDomain()

for {

Expand Down Expand Up @@ -494,6 +482,7 @@ func WS(w http.ResponseWriter, r *http.Request) {
var previousLogosCountry = Settings.LogosCountry
var previousHostIP = Settings.HostIP
var previousHostName = Settings.HostName
var previousUsePort = Settings.UsePort
var previousStoreBufferInRAM = Settings.StoreBufferInRAM
var previousClearXMLTVCache = Settings.ClearXMLTVCache

Expand Down Expand Up @@ -550,6 +539,16 @@ func WS(w http.ResponseWriter, r *http.Request) {
restartWebserver <- true
}

if Settings.UsePort != previousUsePort {
Settings.HostIP = previousHostName
//showInfo("Web server:" + fmt.Sprintf("Changing host name to %s", Settings.UsePort))

reinitialize()

// response.OpenLink = System.URLBase + "/web/"
// restartWebserver <- true
}

if Settings.StoreBufferInRAM != previousStoreBufferInRAM {
initBufferVFS(Settings.StoreBufferInRAM)
}
Expand Down Expand Up @@ -847,11 +846,7 @@ func Web(w http.ResponseWriter, r *http.Request) {

var language LanguageUI

if Settings.HostName != "" {
setGlobalDomain(Settings.HostName + ":" + Settings.Port)
} else {
setGlobalDomain(Settings.HostIP + ":" + Settings.Port)
}
setGlobalDomain()

if System.Dev {

Expand Down Expand Up @@ -1082,11 +1077,8 @@ func API(w http.ResponseWriter, r *http.Request) {
}
*/

if Settings.HostName != "" {
setGlobalDomain(Settings.HostName + ":" + Settings.Port)
} else {
setGlobalDomain(Settings.HostIP + ":" + Settings.Port)
}
setGlobalDomain()

var request APIRequestStruct
var response APIResponseStruct

Expand Down
12 changes: 9 additions & 3 deletions src/xepg.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func createXEPGMapping() {

// Create / update XEPG Database
func createXEPGDatabase() (err error) {

var firstFreeNumber float64 = Settings.MappingFirstChannel
var allChannelNumbers = make([]float64, 0)
Data.Cache.Streams.Active = make([]string, 0)
Data.XEPG.Channels = make(map[string]interface{})
Expand Down Expand Up @@ -268,7 +268,6 @@ func createXEPGDatabase() (err error) {

sort.Float64s(allChannelNumbers)

var firstFreeNumber float64 = Settings.MappingFirstChannel
if startingChannel != nil {
var startingChannel, _ = strconv.ParseFloat(startingChannel[0], 64)
if startingChannel > 0 {
Expand Down Expand Up @@ -328,8 +327,15 @@ func createXEPGDatabase() (err error) {
xepgChannelsValuesMap[channelHash] = channel
}

start := time.Now()
count := 0
total := len(Data.Streams.Active)
for _, dsa := range Data.Streams.Active {

count += 1
if count%1000 == 0 {
fmt.Printf("Processed %v/%v streams in %v\n", count, total, time.Since(start))
start = time.Now()
}
var channelExists = false // Decides whether a Channel should be added to the Database
var channelHasUUID = false // Checks whether the Channel (Stream) has Unique IDs
var currentXEPGID string // Current Database ID (XEPG) Used to update the Channel in the Database with the Stream of the M3U
Expand Down
2 changes: 1 addition & 1 deletion ts/base_ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ menuItems.push(new MainMenuItem("logout", "{{.mainMenu.item.logout}}", "logout.p

// Settings categories
var settingsCategory = new Array()
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.general}}", "tlsMode,xteveAutoUpdate,hostIP,hostName,tuner,epgSource,enableTapiosinnTVLogos,logosCountry,disallowURLDuplicates,clearXMLTVCache,api"))
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.general}}", "tlsMode,xteveAutoUpdate,hostIP,hostName,usePort,tuner,epgSource,enableTapiosinnTVLogos,logosCountry,disallowURLDuplicates,clearXMLTVCache,api"))
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.mapping}}", "defaultMissingEPG,enableMappedChannels"))
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.files}}", "update,files.update,temp.path,cache.images,xepg.replace.missing.images"))
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.streaming}}", "buffer,udpxy,buffer.size.kb,storeBufferInRAM,buffer.timeout,user.agent,ffmpeg.path,ffmpeg.options,vlc.path,vlc.options"))
Expand Down
4 changes: 2 additions & 2 deletions ts/menu_ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,12 @@ class Cell {
case "IMG":
element = document.createElement(this.childType);
element.setAttribute("alt", this.value);

element.setAttribute("channelID", this.id)

element.onerror = function (this: HTMLImageElement) {
showWarning(this.alt + " has a bad logo URL")
var channelNameID = this.attributes["channelID"].value;

document.getElementById(channelNameID).style.color = "red";
this.src = getDefaultLogo()
};
Expand Down Expand Up @@ -2309,7 +2310,6 @@ function donePopupData(dataType: string, idsStr: string) {
let element = (document.getElementById(id).childNodes[3].firstChild as HTMLElement)
if (!ImageExist(input["tvg-logo"])) {
element.style.color = "red";
showWarning(element.innerText + " has a bad logo URL")
input["tvg-logo"] = getDefaultLogo()
} else {
element.style.color = "white";
Expand Down
19 changes: 19 additions & 0 deletions ts/settings_ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,21 @@ class SettingsCategory {
setting.appendChild(tdLeft);
setting.appendChild(tdRight);
break;

case "usePort":
var tdLeft = document.createElement("TD")
tdLeft.innerHTML = "{{.settings.usePort.title}}" + ":"

var tdRight = document.createElement("TD")
var input = content.createCheckbox(settingsKey)
input.checked = data
input.setAttribute("onchange", "javascript: this.className = 'changed'")
tdRight.appendChild(input)

setting.appendChild(tdLeft)
setting.appendChild(tdRight)
break

case "tuner":
var tdLeft = document.createElement("TD")
tdLeft.innerHTML = "{{.settings.tuner.title}}" + ":"
Expand Down Expand Up @@ -655,6 +670,10 @@ class SettingsCategory {
text = "{{.settings.hostName.description}}"
break;

case "usePort":
text = "{{.settings.usePort.description}}"
break;

case "tuner":
text = "{{.settings.tuner.description}}"
break
Expand Down