force_exit = 1;
}
-char *gpass = NULL;
-
static int server_callback(struct mg_connection *c, enum mg_event ev) {
int result = MG_FALSE;
FILE *fp = NULL;
#endif
case MG_AUTH:
// no auth for websockets since mobile safari does not support it
- if ( (gpass == NULL) || (c->is_websocket) )
+ if ( (mpd.gpass == NULL) || (c->is_websocket) || ((mpd.local_port > 0) && (c->local_port == mpd.local_port)) )
return MG_TRUE;
else {
- if ( (fp = fopen(gpass, "r")) != NULL ) {
+ if ( (fp = fopen(mpd.gpass, "r")) != NULL ) {
result = mg_authorize_digest(c, fp);
fclose(fp);
}
mg_set_option(server, "auth_domain", "ympd");
mpd.port = 6600;
+ mpd.local_port = 0;
+ mpd.gpass = NULL;
strcpy(mpd.host, "127.0.0.1");
strcpy(dirble_api_token, "2e223c9909593b94fc6577361a");
{"digest", required_argument, 0, 'D'},
{"host", required_argument, 0, 'h'},
{"port", required_argument, 0, 'p'},
+ {"localport", required_argument, 0, 'l'},
{"webport", required_argument, 0, 'w'},
{"dirbletoken", required_argument, 0, 'd'},
{"user", required_argument, 0, 'u'},
{0, 0, 0, 0 }
};
- while((n = getopt_long(argc, argv, "D:h:p:w:u:d:v:m",
+ while((n = getopt_long(argc, argv, "D:h:p:l:w:u:d:v:m",
long_options, &option_index)) != -1) {
switch (n) {
case 'D':
- gpass = strdup(optarg);
+ mpd.gpass = strdup(optarg);
break;
case 'h':
strncpy(mpd.host, optarg, sizeof(mpd.host));
case 'p':
mpd.port = atoi(optarg);
break;
+ case 'l':
+ mpd.local_port = atoi(optarg);
+ break;
case 'w':
webport = strdup(optarg);
break;
" \t(realm ympd) [no authorization]\n"
" -h, --host <host>\t\tconnect to mpd at host [localhost]\n"
" -p, --port <port>\t\tconnect to mpd at port [6600]\n"
+ " -l, --localport <port>\t\tskip authorization for local port\n"
" -w, --webport [ip:]<port>\tlisten interface/port for webserver [8080]\n"
" -u, --user <username>\t\tdrop priviliges to user after socket bind\n"
" -d, --dirbletoken <apitoken>\tDirble API token\n"