X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fraop.c;h=fe57735329f95d6a9f672d4054a56a383b29312f;hb=5a746b97186cd50b3c787824ea2290dc88d84ed0;hp=0eaace1bbc2c2fde1d2ef2fbeae6c6a78b3fdd27;hpb=e4169f77f892fefc66a97439d295d3e09ef3e2f0;p=deb_shairplay.git diff --git a/src/lib/raop.c b/src/lib/raop.c index 0eaace1..fe57735 100644 --- a/src/lib/raop.c +++ b/src/lib/raop.c @@ -36,7 +36,7 @@ #define MAX_PASSWORD_LEN 64 /* MD5 as hex fits here */ -#define MAX_NONCE_LEN 33 +#define MAX_NONCE_LEN 32 struct raop_s { /* Callbacks for audio */ @@ -143,9 +143,10 @@ conn_request(void *ptr, http_request_t *request, http_response_t **response) authorization = http_request_get_header(request, "Authorization"); if (authorization) { + logger_log(&conn->raop->logger, LOGGER_DEBUG, "Our nonce: %s\n", conn->nonce); logger_log(&conn->raop->logger, LOGGER_DEBUG, "Authorization: %s\n", authorization); } - if (!digest_is_valid("AppleTV", raop->password, conn->nonce, method, authorization)) { + if (!digest_is_valid("AppleTV", raop->password, conn->nonce, method, http_request_get_url(request), authorization)) { char *authstr; int authstrlen; @@ -174,7 +175,7 @@ conn_request(void *ptr, http_request_t *request, http_response_t **response) http_response_add_header(res, "Apple-Jack-Status", "connected; type=analog"); challenge = http_request_get_header(request, "Apple-Challenge"); - if (challenge) { + if (!require_auth && challenge) { char signature[MAX_SIGNATURE_LEN]; memset(signature, 0, sizeof(signature)); @@ -288,10 +289,11 @@ conn_request(void *ptr, http_request_t *request, http_response_t **response) memcpy(datastr, data, datalen); if (!strncmp(datastr, "volume: ", 8)) { float vol = 0.0; - sscanf(data+8, "%f", &vol); + sscanf(datastr+8, "%f", &vol); raop_rtp_set_volume(conn->raop_rtp, vol); } } + free(datastr); } else if (!strcmp(method, "FLUSH")) { const char *rtpinfo; int next_seq = -1; @@ -427,6 +429,14 @@ raop_destroy(raop_t *raop) } } +int +raop_is_running(raop_t *raop) +{ + assert(raop); + + return httpd_is_running(raop->httpd); +} + int raop_start(raop_t *raop, unsigned short *port, const char *hwaddr, int hwaddrlen, const char *password) { @@ -439,18 +449,21 @@ raop_start(raop_t *raop, unsigned short *port, const char *hwaddr, int hwaddrlen return -1; } - /* Validate password */ - if (strlen(password) > MAX_PASSWORD_LEN) { - return -1; + memset(raop->password, 0, sizeof(raop->password)); + if (password) { + /* Validate password */ + if (strlen(password) > MAX_PASSWORD_LEN) { + return -1; + } + + /* Copy password to the raop structure */ + strncpy(raop->password, password, MAX_PASSWORD_LEN); } /* Copy hwaddr to the raop structure */ memcpy(raop->hwaddr, hwaddr, hwaddrlen); raop->hwaddrlen = hwaddrlen; - /* Copy password to the raop structure */ - strncpy(raop->password, password, MAX_PASSWORD_LEN); - return httpd_start(raop->httpd, port); }