Created
November 18, 2013 21:17
-
-
Save couteau/7535462 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 6963b3a6beef2fdfdb1f234fa926005fbcaae55b Mon Sep 17 00:00:00 2001 | |
From: Stuart C Naifeh <scnaifeh@ruby.naifeh.org> | |
Date: Mon, 18 Nov 2013 16:11:43 -0500 | |
Subject: [PATCH] Add support for dynamic config of encryption and metadata | |
handling based on device mDNS TXT record | |
--- | |
src/player.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- | |
src/raop.c | 20 ++++---------------- | |
src/raop.h | 2 ++ | |
3 files changed, 53 insertions(+), 19 deletions(-) | |
diff --git a/src/player.c b/src/player.c | |
index de2e20e..ae9b164 100644 | |
--- a/src/player.c | |
+++ b/src/player.c | |
@@ -3596,6 +3596,8 @@ raop_device_cb(const char *name, const char *type, const char *domain, const cha | |
char *at_name; | |
char *password; | |
uint64_t id; | |
+ char encrypt; | |
+ char wants_metadata; | |
char has_password; | |
enum raop_devtype devtype; | |
int ret; | |
@@ -3704,8 +3706,6 @@ raop_device_cb(const char *name, const char *type, const char *domain, const cha | |
DPRINTF(E_LOG, L_PLAYER, "No password given in config for AirTunes device %s\n", name); | |
} | |
- devtype = RAOP_DEV_APEX_80211N; | |
- | |
p = keyval_get(txt, "am"); | |
if (!p) | |
{ | |
@@ -3726,10 +3726,52 @@ raop_device_cb(const char *name, const char *type, const char *domain, const cha | |
if (strncmp(p, "AppleTV", strlen("AppleTV")) == 0) | |
devtype = RAOP_DEV_APPLETV; | |
- else if (strncmp(p, "AirPort4", strlen("AirPort4")) != 0) | |
+ else if (strncmp(p, "AirPort4", strlen("AirPort4")) == 0) | |
+ devtype = RAOP_DEV_APEX_80211N; | |
+ else | |
devtype = OTHER; | |
no_am: | |
+ p = keyval_get(txt, "ek"); | |
+ if (!p) | |
+ { | |
+ DPRINTF(E_LOG, L_PLAYER, "AirTunes %s: no ek field in TXT record!\n", name); | |
+ encrypt = 0; | |
+ | |
+ goto no_ek; | |
+ } | |
+ | |
+ if (*p == '\0') | |
+ { | |
+ DPRINTF(E_LOG, L_PLAYER, "AirTunes %s: ek has no value\n", name); | |
+ encrypt = 0; | |
+ | |
+ goto no_ek; | |
+ } | |
+ | |
+ encrypt = (*p == '1') ? 1: 0; | |
+ | |
+ no_ek: | |
+ p = keyval_get(txt, "md"); | |
+ if (!p) | |
+ { | |
+ DPRINTF(E_LOG, L_PLAYER, "AirTunes %s: no md field in TXT record!\n", name); | |
+ wants_metadata = 0; | |
+ | |
+ goto no_md; | |
+ } | |
+ | |
+ if (*p == '\0') | |
+ { | |
+ DPRINTF(E_LOG, L_PLAYER, "AirTunes %s: md has no value\n", name); | |
+ wants_metadata = 0; | |
+ | |
+ goto no_md; | |
+ } | |
+ | |
+ wants_metadata = 1; | |
+ | |
+ no_md: | |
DPRINTF(E_DBG, L_PLAYER, "AirTunes device %s: password: %s, type %s\n", name, (password) ? "yes" : "no", raop_devtype[devtype]); | |
rd->advertised = 1; | |
@@ -3749,6 +3791,8 @@ raop_device_cb(const char *name, const char *type, const char *domain, const cha | |
rd->devtype = devtype; | |
+ rd->encrypt = encrypt; | |
+ rd->wants_metadata = wants_metadata; | |
rd->has_password = has_password; | |
rd->password = password; | |
diff --git a/src/raop.c b/src/raop.c | |
index f9e293b..5aab889 100644 | |
--- a/src/raop.c | |
+++ b/src/raop.c | |
@@ -1847,32 +1847,20 @@ raop_session_make(struct raop_device *rd, int family, raop_status_cb cb) | |
rs->status_cb = cb; | |
rs->server_fd = -1; | |
+ rs->encrypt = rd->encrypt; | |
+ rs->wants_metadata = rd->wants_metadata; | |
rs->password = rd->password; | |
switch (rd->devtype) | |
{ | |
case RAOP_DEV_APEX_80211G: | |
- rs->encrypt = 1; | |
- rs->auth_quirk_itunes = 1; | |
- rs->wants_metadata = 0; | |
- break; | |
+ rs->auth_quirk_itunes = 1; | |
+ break; | |
case RAOP_DEV_APEX_80211N: | |
- rs->encrypt = 1; | |
- rs->auth_quirk_itunes = 0; | |
- rs->wants_metadata = 0; | |
- break; | |
- | |
case RAOP_DEV_APPLETV: | |
- rs->encrypt = 0; | |
- rs->auth_quirk_itunes = 0; | |
- rs->wants_metadata = 1; | |
- break; | |
- | |
case OTHER: | |
- rs->encrypt = 0; | |
rs->auth_quirk_itunes = 0; | |
- rs->wants_metadata = 0; | |
break; | |
} | |
diff --git a/src/raop.h b/src/raop.h | |
index a920668..b3dca7b 100644 | |
--- a/src/raop.h | |
+++ b/src/raop.h | |
@@ -40,6 +40,8 @@ struct raop_device | |
unsigned selected:1; | |
unsigned advertised:1; | |
+ unsigned encrypt:1; | |
+ unsigned wants_metadata:1; | |
unsigned has_password:1; | |
const char *password; | |
-- | |
1.8.3.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment