int mosquittopp::socks5_set(const char *host, int port, const char *username, const char *password) { #ifdef WITH_SOCKS return mosquitto_socks5_set(m_mosq, host, port, username, password); #else return MOSQ_ERR_NOT_SUPPORTED; #endif }
int client_opts_set(struct mosquitto *mosq, struct mosq_config *cfg) { int rc; if(cfg->will_topic && mosquitto_will_set(mosq, cfg->will_topic, cfg->will_payloadlen, cfg->will_payload, cfg->will_qos, cfg->will_retain)) { if(!cfg->quiet) fprintf(stderr, "Error: Problem setting will.\n"); mosquitto_lib_cleanup(); return 1; } if(cfg->username && mosquitto_username_pw_set(mosq, cfg->username, cfg->password)) { if(!cfg->quiet) fprintf(stderr, "Error: Problem setting username and password.\n"); mosquitto_lib_cleanup(); return 1; } #ifdef WITH_TLS if((cfg->cafile || cfg->capath) && mosquitto_tls_set(mosq, cfg->cafile, cfg->capath, cfg->certfile, cfg->keyfile, NULL)) { if(!cfg->quiet) fprintf(stderr, "Error: Problem setting TLS options.\n"); mosquitto_lib_cleanup(); return 1; } if(cfg->insecure && mosquitto_tls_insecure_set(mosq, true)) { if(!cfg->quiet) fprintf(stderr, "Error: Problem setting TLS insecure option.\n"); mosquitto_lib_cleanup(); return 1; } # ifdef WITH_TLS_PSK if(cfg->psk && mosquitto_tls_psk_set(mosq, cfg->psk, cfg->psk_identity, NULL)) { if(!cfg->quiet) fprintf(stderr, "Error: Problem setting TLS-PSK options.\n"); mosquitto_lib_cleanup(); return 1; } # endif if(cfg->tls_version && mosquitto_tls_opts_set(mosq, 1, cfg->tls_version, cfg->ciphers)) { if(!cfg->quiet) fprintf(stderr, "Error: Problem setting TLS options.\n"); mosquitto_lib_cleanup(); return 1; } #endif mosquitto_max_inflight_messages_set(mosq, cfg->max_inflight); #ifdef WITH_SOCKS if(cfg->socks5_host) { rc = mosquitto_socks5_set(mosq, cfg->socks5_host, cfg->socks5_port, cfg->socks5_username, cfg->socks5_password); if(rc) { mosquitto_lib_cleanup(); return rc; } } #endif mosquitto_opts_set(mosq, MOSQ_OPT_PROTOCOL_VERSION, &(cfg->protocol_version)); return MOSQ_ERR_SUCCESS; }
int mosquittopp::socks5_set(const char *host, int port, const char *username, const char *password) { return mosquitto_socks5_set(m_mosq, host, port, username, password); }