Adding argument to set custom anti-collision ID (#146)

This commit is contained in:
Matthew Huie
2023-04-11 05:29:38 -04:00
committed by GitHub
parent 8cb5ea3c5f
commit f9a83d52b3
3 changed files with 7 additions and 0 deletions

View File

@@ -84,6 +84,7 @@ var rootCmd = &cobra.Command{
HTTPS: viper.GetBool("https"), HTTPS: viper.GetBool("https"),
M3UFileName: viper.GetString("m3u-file-name"), M3UFileName: viper.GetString("m3u-file-name"),
CustomEndpoint: viper.GetString("custom-endpoint"), CustomEndpoint: viper.GetString("custom-endpoint"),
CustomId: viper.GetString("custom-id"),
XtreamGenerateApiGet: viper.GetBool("xtream-api-get"), XtreamGenerateApiGet: viper.GetBool("xtream-api-get"),
} }
@@ -121,6 +122,7 @@ func init() {
rootCmd.Flags().StringP("m3u-url", "u", "", `Iptv m3u file or url e.g: "http://example.com/iptv.m3u"`) rootCmd.Flags().StringP("m3u-url", "u", "", `Iptv m3u file or url e.g: "http://example.com/iptv.m3u"`)
rootCmd.Flags().StringP("m3u-file-name", "", "iptv.m3u", `Name of the new proxified m3u file e.g "http://poxy.com/iptv.m3u"`) rootCmd.Flags().StringP("m3u-file-name", "", "iptv.m3u", `Name of the new proxified m3u file e.g "http://poxy.com/iptv.m3u"`)
rootCmd.Flags().StringP("custom-endpoint", "", "", `Custom endpoint "http://poxy.com/<custom-endpoint>/iptv.m3u"`) rootCmd.Flags().StringP("custom-endpoint", "", "", `Custom endpoint "http://poxy.com/<custom-endpoint>/iptv.m3u"`)
rootCmd.Flags().StringP("custom-id", "", "", `Custom anti-collison ID for each track "http://proxy.com/<custom-id>/..."`)
rootCmd.Flags().Int("port", 8080, "Iptv-proxy listening port") rootCmd.Flags().Int("port", 8080, "Iptv-proxy listening port")
rootCmd.Flags().Int("advertised-port", 0, "Port to expose the IPTV file and xtream (by default, it's taking value from port) useful to put behind a reverse proxy") rootCmd.Flags().Int("advertised-port", 0, "Port to expose the IPTV file and xtream (by default, it's taking value from port) useful to put behind a reverse proxy")
rootCmd.Flags().String("hostname", "", "Hostname or IP to expose the IPTVs endpoints") rootCmd.Flags().String("hostname", "", "Hostname or IP to expose the IPTVs endpoints")

View File

@@ -51,6 +51,7 @@ type ProxyConfig struct {
M3UCacheExpiration int M3UCacheExpiration int
M3UFileName string M3UFileName string
CustomEndpoint string CustomEndpoint string
CustomId string
RemoteURL *url.URL RemoteURL *url.URL
AdvertisedPort int AdvertisedPort int
HTTPS bool HTTPS bool

View File

@@ -64,6 +64,10 @@ func NewServer(config *config.ProxyConfig) (*Config, error) {
} }
} }
if trimmedCustomId := strings.Trim(config.CustomId, "/"); trimmedCustomId != "" {
endpointAntiColision = trimmedCustomId
}
return &Config{ return &Config{
config, config,
&p, &p,