Skip to content
Permalink
Browse files

samples: net: Modify mqtt_publisher to use set proxy

Modify mqtt_publisher sample to use mqtt_client_set_proxy().
Removed CONFIG_MQTT_LIB_SOCKS based setup.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
  • Loading branch information...
rveerama1 authored and jukkar committed Aug 1, 2019
1 parent 8e70bd6 commit fa7a5db12ed2b06f51002eeeb17a9c1dbd32957f
@@ -1 +1 @@
CONFIG_MQTT_LIB_SOCKS=y
CONFIG_SOCKS=y
@@ -25,7 +25,7 @@
#endif
#endif

#if defined(CONFIG_MQTT_LIB_SOCKS)
#if defined(CONFIG_SOCKS)
#define SOCKS5_PROXY_ADDR SERVER_ADDR
#define SOCKS5_PROXY_PORT 1080
#endif
@@ -26,8 +26,9 @@ static struct mqtt_client client_ctx;

/* MQTT Broker details. */
static struct sockaddr_storage broker;
#if defined(CONFIG_MQTT_LIB_SOCKS)
static struct sockaddr_storage socks5_proxy;

#if defined(CONFIG_SOCKS)
static struct sockaddr socks5_proxy;
#endif

static struct pollfd fds[1];
@@ -246,7 +247,7 @@ static void broker_init(void)
broker6->sin6_port = htons(SERVER_PORT);
inet_pton(AF_INET6, SERVER_ADDR, &broker6->sin6_addr);

#if defined(CONFIG_MQTT_LIB_SOCKS)
#if defined(CONFIG_SOCKS)
struct sockaddr_in6 *proxy6 = (struct sockaddr_in6 *)&socks5_proxy;

proxy6->sin6_family = AF_INET6;
@@ -259,8 +260,7 @@ static void broker_init(void)
broker4->sin_family = AF_INET;
broker4->sin_port = htons(SERVER_PORT);
inet_pton(AF_INET, SERVER_ADDR, &broker4->sin_addr);

#if defined(CONFIG_MQTT_LIB_SOCKS)
#if defined(CONFIG_SOCKS)
struct sockaddr_in *proxy4 = (struct sockaddr_in *)&socks5_proxy;

proxy4->sin_family = AF_INET;
@@ -307,13 +307,15 @@ static void client_init(struct mqtt_client *client)
tls_config->hostname = NULL;
#endif

#else
#if defined(CONFIG_MQTT_LIB_SOCKS)
client->transport.type = MQTT_TRANSPORT_SOCKS;
client->transport.socks5.proxy = &socks5_proxy;
#else
client->transport.type = MQTT_TRANSPORT_NON_SECURE;
#endif

#if defined(CONFIG_SOCKS)
mqtt_client_set_proxy(client, &socks5_proxy,
socks5_proxy.sa_family == AF_INET ?
sizeof(struct sockaddr_in) :
sizeof(struct sockaddr_in6));
#endif
}

0 comments on commit fa7a5db

Please sign in to comment.
You can’t perform that action at this time.