mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-26 23:25:56 -05:00
Enable new mDNS backend
This commit is contained in:
parent
97cb82faf7
commit
97faadf6dd
@ -23,6 +23,7 @@ mt_daapd_SOURCES = main.c daapd.h rend.h webserver.c \
|
||||
webserver.h configfile.c configfile.h err.c err.h \
|
||||
mp3-scanner.h mp3-scanner.c \
|
||||
filescanner_ffmpeg.c \
|
||||
mdns_avahi.c mdns_avahi.h \
|
||||
db-generic.c db-generic.h ff-plugins.c ff-plugins.h \
|
||||
rxml.c rxml.h redblack.c redblack.h \
|
||||
scan-xml.c scan-wma.c scan-url.c \
|
||||
|
@ -57,7 +57,6 @@
|
||||
#include "os.h"
|
||||
#include "xml-rpc.h"
|
||||
#include "upnp.h"
|
||||
#include "rend.h"
|
||||
|
||||
|
||||
/*
|
||||
@ -667,8 +666,6 @@ void config_emit_literal(WS_CONNINFO *pwsc, void *value, char *arg) {
|
||||
* \param arg any args passwd with the meta command. Also unused
|
||||
*/
|
||||
void config_emit_service_status(WS_CONNINFO *pwsc, void *value, char *arg) {
|
||||
int mdns_running;
|
||||
char *html;
|
||||
char buf[256];
|
||||
int r_days, r_hours, r_mins, r_secs;
|
||||
int scanning;
|
||||
@ -677,23 +674,6 @@ void config_emit_service_status(WS_CONNINFO *pwsc, void *value, char *arg) {
|
||||
ws_writefd(pwsc,"<table><tr><th align=\"left\">Service</th>");
|
||||
ws_writefd(pwsc,"<th align=\"left\">Status</th><th align=\"left\">Control</th></tr>\n");
|
||||
|
||||
ws_writefd(pwsc,"<tr><td>Rendezvous</td>");
|
||||
|
||||
if(config.use_mdns) {
|
||||
mdns_running=!rend_running();
|
||||
|
||||
if(mdns_running) {
|
||||
html="<a href=\"config-update.html?action=stopmdns\">Stop MDNS Server</a>";
|
||||
} else {
|
||||
html="<a href=\"config-update.html?action=startmdns\">Start MDNS Server</a>";
|
||||
}
|
||||
|
||||
ws_writefd(pwsc,"<td>%s</td><td>%s</td></tr>\n",mdns_running ? "Running":"Stopped",
|
||||
html);
|
||||
} else {
|
||||
ws_writefd(pwsc,"<td>Not configured</td><td> </td></tr>\n");
|
||||
}
|
||||
|
||||
ws_writefd(pwsc,"<tr><td>DAAP Server</td><td>%s</td>",config.stop ? "Stopping":"Running");
|
||||
if(config.stop) {
|
||||
ws_writefd(pwsc,"<td>Wait...</td></tr>\n");
|
||||
|
99
src/main.c
99
src/main.c
@ -87,9 +87,10 @@
|
||||
#include "plugin.h"
|
||||
#include "util.h"
|
||||
#include "upnp.h"
|
||||
#include "rend.h"
|
||||
#include "io.h"
|
||||
|
||||
#include "mdns_avahi.h"
|
||||
|
||||
#ifdef HAVE_GETOPT_H
|
||||
# include "getopt.h"
|
||||
#endif
|
||||
@ -185,7 +186,6 @@ void usage(char *program) {
|
||||
printf(" -a Set cwd to app dir before starting\n");
|
||||
printf(" -d <number> Debug level (0-9)\n");
|
||||
printf(" -D <mod,mod..> Debug modules\n");
|
||||
printf(" -m Disable mDNS\n");
|
||||
printf(" -c <file> Use configfile specified\n");
|
||||
printf(" -P <file> Write the PID to specified file\n");
|
||||
printf(" -f Run in foreground\n");
|
||||
@ -363,7 +363,7 @@ int main(int argc, char *argv[]) {
|
||||
int convert_conf=0;
|
||||
char *db_type,*db_parms,*web_root,*runas, *tmp;
|
||||
char **mp3_dir_array;
|
||||
char *servername, *iface;
|
||||
char *servername;
|
||||
char *ffid = NULL;
|
||||
int appdir = 0;
|
||||
char *perr=NULL;
|
||||
@ -372,6 +372,7 @@ int main(int argc, char *argv[]) {
|
||||
char *plugindir;
|
||||
struct event *main_timer;
|
||||
struct timeval tv;
|
||||
int ret;
|
||||
|
||||
int err;
|
||||
char *apppath;
|
||||
@ -379,7 +380,6 @@ int main(int argc, char *argv[]) {
|
||||
int debuglevel=0;
|
||||
int plugins_loaded = 0;
|
||||
|
||||
config.use_mdns=1;
|
||||
err_setlevel(2);
|
||||
|
||||
config.foreground=0;
|
||||
@ -414,10 +414,6 @@ int main(int argc, char *argv[]) {
|
||||
configfile=optarg;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
config.use_mdns=0;
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
os_set_pidfile(optarg);
|
||||
break;
|
||||
@ -560,17 +556,18 @@ int main(int argc, char *argv[]) {
|
||||
os_deinit();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if(config.use_mdns) {
|
||||
DPRINTF(E_LOG,L_MAIN,"Starting rendezvous daemon\n");
|
||||
if(rend_init(runas)) {
|
||||
DPRINTF(E_FATAL,L_MAIN|L_REND,"Error in rend_init: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
free(runas);
|
||||
|
||||
DPRINTF(E_LOG, L_MAIN, "mDNS init\n");
|
||||
ret = mdns_init();
|
||||
if (ret != 0)
|
||||
{
|
||||
DPRINTF(E_FATAL, L_MAIN | L_REND, "mDNS init failed\n");
|
||||
|
||||
os_deinit();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#ifdef UPNP
|
||||
upnp_init();
|
||||
#endif
|
||||
@ -582,9 +579,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
if(err) {
|
||||
DPRINTF(E_LOG,L_MAIN|L_DB,"Error opening db: %s\n",perr);
|
||||
if(config.use_mdns) {
|
||||
rend_stop();
|
||||
}
|
||||
|
||||
mdns_deinit();
|
||||
os_deinit();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -648,42 +644,39 @@ int main(int argc, char *argv[]) {
|
||||
ws_registerhandler(config.server, "/",main_handler,main_auth,
|
||||
0,1);
|
||||
|
||||
if(config.use_mdns) { /* register services */
|
||||
servername = conf_get_servername();
|
||||
/* Register mDNS services */
|
||||
servername = conf_get_servername();
|
||||
|
||||
memset(txtrecord,0,sizeof(txtrecord));
|
||||
txt_add(txtrecord,"txtvers=1");
|
||||
txt_add(txtrecord,"Database ID=%0X",util_djb_hash_str(servername));
|
||||
txt_add(txtrecord,"Machine ID=%0X",util_djb_hash_str(servername));
|
||||
txt_add(txtrecord,"Machine Name=%s",servername);
|
||||
txt_add(txtrecord,"mtd-version=" VERSION);
|
||||
txt_add(txtrecord,"iTSh Version=131073"); /* iTunes 6.0.4 */
|
||||
txt_add(txtrecord,"Version=196610"); /* iTunes 6.0.4 */
|
||||
tmp = conf_alloc_string("general","password",NULL);
|
||||
if(tmp && (strlen(tmp)==0)) tmp=NULL;
|
||||
memset(txtrecord,0,sizeof(txtrecord));
|
||||
txt_add(txtrecord,"txtvers=1");
|
||||
txt_add(txtrecord,"Database ID=%0X",util_djb_hash_str(servername));
|
||||
txt_add(txtrecord,"Machine ID=%0X",util_djb_hash_str(servername));
|
||||
txt_add(txtrecord,"Machine Name=%s",servername);
|
||||
txt_add(txtrecord,"mtd-version=" VERSION);
|
||||
txt_add(txtrecord,"iTSh Version=131073"); /* iTunes 6.0.4 */
|
||||
txt_add(txtrecord,"Version=196610"); /* iTunes 6.0.4 */
|
||||
tmp = conf_alloc_string("general","password",NULL);
|
||||
if(tmp && (strlen(tmp)==0)) tmp=NULL;
|
||||
|
||||
txt_add(txtrecord,"Password=%s",tmp ? "true" : "false");
|
||||
if(tmp) free(tmp);
|
||||
txt_add(txtrecord,"Password=%s",tmp ? "true" : "false");
|
||||
if(tmp) free(tmp);
|
||||
|
||||
srand((unsigned int)time(NULL));
|
||||
srand((unsigned int)time(NULL));
|
||||
|
||||
if(ffid) {
|
||||
txt_add(txtrecord,"ffid=%s",ffid);
|
||||
} else {
|
||||
txt_add(txtrecord,"ffid=%08x",rand());
|
||||
}
|
||||
|
||||
DPRINTF(E_LOG,L_MAIN|L_REND,"Registering rendezvous names\n");
|
||||
iface = conf_alloc_string("general","interface","");
|
||||
|
||||
rend_register(servername,"_http._tcp",ws_config.port,iface,txtrecord);
|
||||
|
||||
plugin_rend_register(servername,ws_config.port,iface,txtrecord);
|
||||
|
||||
free(servername);
|
||||
free(iface);
|
||||
if(ffid) {
|
||||
txt_add(txtrecord,"ffid=%s",ffid);
|
||||
} else {
|
||||
txt_add(txtrecord,"ffid=%08x",rand());
|
||||
}
|
||||
|
||||
DPRINTF(E_LOG,L_MAIN|L_REND,"Registering rendezvous names\n");
|
||||
/* Register main service */
|
||||
mdns_register(servername, "_http._tcp", ws_config.port, txtrecord);
|
||||
/* Register plugin services */
|
||||
plugin_rend_register(servername, ws_config.port, txtrecord);
|
||||
|
||||
free(servername);
|
||||
|
||||
end_time=(int) time(NULL);
|
||||
|
||||
err=db_get_song_count(&perr,&song_count);
|
||||
@ -710,10 +703,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
DPRINTF(E_LOG,L_MAIN,"Stopping gracefully\n");
|
||||
|
||||
if(config.use_mdns) {
|
||||
DPRINTF(E_LOG,L_MAIN|L_REND,"Stopping rendezvous daemon\n");
|
||||
rend_stop();
|
||||
}
|
||||
DPRINTF(E_LOG, L_MAIN | L_REND, "mDNS deinit\n");
|
||||
mdns_deinit();
|
||||
|
||||
#ifdef UPNP
|
||||
upnp_deinit();
|
||||
|
@ -57,13 +57,14 @@
|
||||
#include "io.h"
|
||||
#include "os.h"
|
||||
#include "plugin.h"
|
||||
#include "rend.h"
|
||||
#include "smart-parser.h"
|
||||
#include "xml-rpc.h"
|
||||
#include "webserver.h"
|
||||
#include "ff-plugins.h"
|
||||
#include "io.h"
|
||||
|
||||
#include "mdns_avahi.h"
|
||||
|
||||
typedef struct tag_pluginentry {
|
||||
void *phandle;
|
||||
PLUGIN_INFO *pinfo;
|
||||
@ -338,7 +339,7 @@ void plugin_url_handle(WS_CONNINFO *pwsc) {
|
||||
* walk through the plugins and register whatever rendezvous
|
||||
* names the clients want
|
||||
*/
|
||||
int plugin_rend_register(char *name, int port, char *iface, char *txt) {
|
||||
int plugin_rend_register(char *name, int port, char *txt) {
|
||||
PLUGIN_ENTRY *ppi;
|
||||
PLUGIN_REND_INFO *pri;
|
||||
char *supplied_txt;
|
||||
@ -355,7 +356,7 @@ int plugin_rend_register(char *name, int port, char *iface, char *txt) {
|
||||
supplied_txt = txt;
|
||||
|
||||
DPRINTF(E_DBG,L_PLUG,"Registering %s\n",pri->type);
|
||||
rend_register(name,pri->type,port,iface,supplied_txt);
|
||||
mdns_register(name, pri->type, port, supplied_txt);
|
||||
pri++;
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ extern int plugin_deinit(void);
|
||||
extern int plugin_url_candispatch(WS_CONNINFO *pwsc);
|
||||
extern void plugin_url_handle(WS_CONNINFO *pwsc);
|
||||
extern int plugin_auth_handle(WS_CONNINFO *pwsc, char *username, char *pw);
|
||||
extern int plugin_rend_register(char *name, int port, char *iface, char *txt);
|
||||
extern int plugin_rend_register(char *name, int port, char *txt);
|
||||
extern void plugin_event_dispatch(int event_id, int intval, void *vp, int len);
|
||||
|
||||
extern void *plugin_enum(void *);
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "mp3-scanner.h"
|
||||
#include "os.h"
|
||||
#include "plugin.h"
|
||||
#include "rend.h"
|
||||
#include "webserver.h"
|
||||
#include "xml-rpc.h"
|
||||
|
||||
@ -520,18 +519,6 @@ void xml_get_stats(WS_CONNINFO *pwsc) {
|
||||
|
||||
xml_push(pxml,"service_status");
|
||||
|
||||
xml_push(pxml,"service");
|
||||
|
||||
xml_output(pxml,"name","Rendezvous");
|
||||
|
||||
if(config.use_mdns) {
|
||||
xml_output(pxml,"status",rend_running() ? "Running" : "Stopped"); /* ??? */
|
||||
} else {
|
||||
xml_output(pxml,"status","Disabled");
|
||||
}
|
||||
|
||||
xml_pop(pxml); /* service */
|
||||
|
||||
xml_push(pxml,"service");
|
||||
xml_output(pxml,"name","DAAP Server");
|
||||
xml_output(pxml,"status",config.stop ? "Stopping" : "Running");
|
||||
|
Loading…
Reference in New Issue
Block a user