* Add new options to (1) force a rescan at startup, (2) display help text, and (3) bind to a specified network interface.
This commit is contained in:
parent
efc2ab6b2b
commit
d1049476ef
79
minidlna.c
79
minidlna.c
@ -253,6 +253,15 @@ init(int argc, char * * argv)
|
|||||||
{
|
{
|
||||||
switch(ary_options[i].id)
|
switch(ary_options[i].id)
|
||||||
{
|
{
|
||||||
|
case UPNPIFNAME:
|
||||||
|
if(getifaddr(ary_options[i].value, ext_ip_addr, INET_ADDRSTRLEN) >= 0)
|
||||||
|
{
|
||||||
|
if( *ext_ip_addr && parselanaddr(&lan_addr[n_lan_addr], ext_ip_addr) == 0 )
|
||||||
|
n_lan_addr++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fprintf(stderr, "Interface %s not found, ignoring.\n", ary_options[i].value);
|
||||||
|
break;
|
||||||
case UPNPLISTENING_IP:
|
case UPNPLISTENING_IP:
|
||||||
if(n_lan_addr < MAX_LAN_ADDR)
|
if(n_lan_addr < MAX_LAN_ADDR)
|
||||||
{
|
{
|
||||||
@ -374,6 +383,11 @@ init(int argc, char * * argv)
|
|||||||
{
|
{
|
||||||
fprintf(stderr, "Unknown option: %s\n", argv[i]);
|
fprintf(stderr, "Unknown option: %s\n", argv[i]);
|
||||||
}
|
}
|
||||||
|
else if(strcmp(argv[i], "--help")==0)
|
||||||
|
{
|
||||||
|
runtime_vars.port = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
else switch(argv[i][1])
|
else switch(argv[i][1])
|
||||||
{
|
{
|
||||||
case 't':
|
case 't':
|
||||||
@ -449,9 +463,50 @@ init(int argc, char * * argv)
|
|||||||
else
|
else
|
||||||
fprintf(stderr, "Option -%c takes one argument.\n", argv[i][1]);
|
fprintf(stderr, "Option -%c takes one argument.\n", argv[i][1]);
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
if(i+1 < argc)
|
||||||
|
{
|
||||||
|
int address_already_there = 0;
|
||||||
|
int j;
|
||||||
|
i++;
|
||||||
|
if( getifaddr(argv[i], ext_ip_addr, INET_ADDRSTRLEN) < 0 )
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Network interface '%s' not found.\n",
|
||||||
|
argv[i]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
for(j=0; j<n_lan_addr; j++)
|
||||||
|
{
|
||||||
|
struct lan_addr_s tmpaddr;
|
||||||
|
parselanaddr(&tmpaddr, ext_ip_addr);
|
||||||
|
if(0 == strcmp(lan_addr[j].str, tmpaddr.str))
|
||||||
|
address_already_there = 1;
|
||||||
|
}
|
||||||
|
if(address_already_there)
|
||||||
|
break;
|
||||||
|
if(n_lan_addr < MAX_LAN_ADDR)
|
||||||
|
{
|
||||||
|
if(parselanaddr(&lan_addr[n_lan_addr], ext_ip_addr) == 0)
|
||||||
|
n_lan_addr++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Too many listening ips (max: %d), ignoring %s\n",
|
||||||
|
MAX_LAN_ADDR, argv[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fprintf(stderr, "Option -%c takes one argument.\n", argv[i][1]);
|
||||||
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
i++; /* discarding, the config file is already read */
|
i++; /* discarding, the config file is already read */
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
|
runtime_vars.port = 0; // triggers help display
|
||||||
|
break;
|
||||||
|
case 'R':
|
||||||
|
system("rm -rf " DB_PATH); // triggers a full rescan
|
||||||
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
printf("Version " MINIDLNA_VERSION "\n");
|
printf("Version " MINIDLNA_VERSION "\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -478,18 +533,20 @@ init(int argc, char * * argv)
|
|||||||
if( (n_lan_addr==0) || (runtime_vars.port<=0) )
|
if( (n_lan_addr==0) || (runtime_vars.port<=0) )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage:\n\t"
|
fprintf(stderr, "Usage:\n\t"
|
||||||
"%s [-f config_file]\n"
|
"%s [-d] [-f config_file]\n"
|
||||||
"\t\t[-a listening_ip] [-p port] [-d]\n"
|
"\t\t[-a listening_ip] [-p port]\n"
|
||||||
/*"[-l logfile] " not functionnal */
|
/*"[-l logfile] " not functionnal */
|
||||||
"\t\t[-s serial] [-m model_number] \n"
|
"\t\t[-s serial] [-m model_number] \n"
|
||||||
"\t\t[-t notify_interval] [-P pid_filename]\n"
|
"\t\t[-t notify_interval] [-P pid_filename]\n"
|
||||||
"\t\t[-w url]\n"
|
"\t\t[-w url] [-R] [-V] [-h]\n"
|
||||||
"\nNotes:\n\tNotify interval is in seconds. Default is 895 seconds.\n"
|
"\nNotes:\n\tNotify interval is in seconds. Default is 895 seconds.\n"
|
||||||
"\tDefault pid file is %s.\n"
|
"\tDefault pid file is %s.\n"
|
||||||
"\tWith -d minidlna will run in debug mode (not daemonize).\n"
|
"\tWith -d minidlna will run in debug mode (not daemonize).\n"
|
||||||
"\t-w sets the presentation url. Default is http address on port 80\n"
|
"\t-w sets the presentation url. Default is http address on port 80\n"
|
||||||
"\t-V print the version number\n"
|
"\t-h displays this text\n"
|
||||||
"", argv[0], pidfilename);
|
"\t-R forces a full rescan\n"
|
||||||
|
"\t-V print the version number\n",
|
||||||
|
argv[0], pidfilename);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
# port for HTTP (descriptions and SOAP) traffic
|
# port for HTTP (descriptions, SOAP, media transfer) traffic
|
||||||
port=8200
|
port=8200
|
||||||
|
|
||||||
|
# network interface to bind to (this is the only interface that will serve files)
|
||||||
|
#network_interface=eth0
|
||||||
|
|
||||||
# set this to the directory you want scanned.
|
# set this to the directory you want scanned.
|
||||||
# * if have multiple directories, you can have multiple media_dir= lines
|
# * if have multiple directories, you can have multiple media_dir= lines
|
||||||
# * if you want to restrict a media_dir to a specific content type, you
|
# * if you want to restrict a media_dir to a specific content type, you
|
||||||
|
@ -20,8 +20,7 @@ static const struct {
|
|||||||
enum upnpconfigoptions id;
|
enum upnpconfigoptions id;
|
||||||
const char * name;
|
const char * name;
|
||||||
} optionids[] = {
|
} optionids[] = {
|
||||||
{ UPNPEXT_IFNAME, "ext_ifname" },
|
{ UPNPIFNAME, "network_interface" },
|
||||||
{ UPNPEXT_IP, "ext_ip" },
|
|
||||||
{ UPNPLISTENING_IP, "listening_ip" },
|
{ UPNPLISTENING_IP, "listening_ip" },
|
||||||
{ UPNPPORT, "port" },
|
{ UPNPPORT, "port" },
|
||||||
{ UPNPPRESENTATIONURL, "presentation_url" },
|
{ UPNPPRESENTATIONURL, "presentation_url" },
|
||||||
|
@ -13,13 +13,12 @@
|
|||||||
/* enum of option available in the miniupnpd.conf */
|
/* enum of option available in the miniupnpd.conf */
|
||||||
enum upnpconfigoptions {
|
enum upnpconfigoptions {
|
||||||
UPNP_INVALID = 0,
|
UPNP_INVALID = 0,
|
||||||
UPNPEXT_IFNAME = 1, /* ext_ifname */
|
UPNPIFNAME = 1, /* ext_ifname */
|
||||||
UPNPEXT_IP, /* ext_ip */
|
|
||||||
UPNPLISTENING_IP, /* listening_ip */
|
UPNPLISTENING_IP, /* listening_ip */
|
||||||
UPNPPORT, /* "port" */
|
UPNPPORT, /* port */
|
||||||
UPNPPRESENTATIONURL, /* presentation_url */
|
UPNPPRESENTATIONURL, /* presentation_url */
|
||||||
UPNPNOTIFY_INTERVAL, /* notify_interval */
|
UPNPNOTIFY_INTERVAL, /* notify_interval */
|
||||||
UPNPSYSTEM_UPTIME, /* "system_uptime" */
|
UPNPSYSTEM_UPTIME, /* system_uptime */
|
||||||
UPNPUUID, /* uuid */
|
UPNPUUID, /* uuid */
|
||||||
UPNPSERIAL, /* serial */
|
UPNPSERIAL, /* serial */
|
||||||
UPNPMODEL_NUMBER, /* model_number */
|
UPNPMODEL_NUMBER, /* model_number */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user