diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-11-13 15:57:53 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-11-13 15:57:53 (GMT) |
commit | afec6e2f8bd472da1d9170bdaf102b5a572bcd2a (patch) | |
tree | 843aa6434a0379a53638eccd20f9ea7a8bff85f3 /src | |
parent | 2b3fb554e90793670a6ec384c22c89f005142c55 (diff) | |
download | uscxml-afec6e2f8bd472da1d9170bdaf102b5a572bcd2a.zip uscxml-afec6e2f8bd472da1d9170bdaf102b5a572bcd2a.tar.gz uscxml-afec6e2f8bd472da1d9170bdaf102b5a572bcd2a.tar.bz2 |
Support for Proxies via USCXML_PROXY environment variable, check CURL_PROXY syntax for examples
Diffstat (limited to 'src')
-rw-r--r-- | src/uscxml/URL.cpp | 75 | ||||
-rw-r--r-- | src/uscxml/transform/ChartToPromela.cpp | 15 |
2 files changed, 90 insertions, 0 deletions
diff --git a/src/uscxml/URL.cpp b/src/uscxml/URL.cpp index 9ba015c..06fd934 100644 --- a/src/uscxml/URL.cpp +++ b/src/uscxml/URL.cpp @@ -539,6 +539,81 @@ std::ostream & operator<<(std::ostream & stream, const URL& url) { URLFetcher::URLFetcher() { _isStarted = false; _multiHandle = curl_multi_init(); + + // read proxy information from environment +// CURLOPT_PROXY; +// CURLOPT_PROXY_TRANSFER_MODE; +// CURLOPT_PROXYAUTH; +// CURLOPT_PROXYHEADER; +// CURLOPT_PROXYPASSWORD; +// CURLOPT_PROXYPORT; +// CURLOPT_PROXYTYPE; +// CURLOPT_PROXYUSERNAME; +// CURLOPT_PROXYUSERPWD; + + bool unsupported = false; + CURLcode curlError; + + char* envProxy = getenv("USCXML_PROXY"); // e.g. 'socks5://bob:marley@localhost:12345' + + // exposed just in case + char* envProxyTransferMode = getenv("USCXML_PROXY_TRANSFER_MODE"); + char* envProxyAuth = getenv("USCXML_PROXYAUTH"); + char* envProxyHeader = getenv("USCXML_PROXYHEADER"); // unsupported below + char* envProxyPassword = getenv("USCXML_PROXYPASSWORD"); + char* envProxyPort = getenv("USCXML_PROXYPORT"); + char* envProxyType = getenv("USCXML_PROXYTYPE"); // unsupported below + char* envProxyUsername = getenv("USCXML_PROXYUSERNAME"); + char* envProxyUserPwd = getenv("USCXML_PROXYUSERPWD"); + + /* Name of proxy to use. */ + if (envProxy) + (curlError = curl_easy_setopt(_multiHandle, CURLOPT_PROXY, envProxy)) == CURLE_OK || + LOG(ERROR) << "Cannot set curl proxy: " << curl_easy_strerror(curlError); + + /* set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy */ + if (envProxyTransferMode) + (curlError = curl_easy_setopt(_multiHandle, CURLOPT_PROXY_TRANSFER_MODE, envProxyTransferMode)) == CURLE_OK || + LOG(ERROR) << "Cannot set curl proxy transfer mode: " << curl_easy_strerror(curlError); + + /* Set this to a bitmask value to enable the particular authentications + methods you like. Use this in combination with CURLOPT_PROXYUSERPWD. + Note that setting multiple bits may cause extra network round-trips. */ + if (envProxyAuth) + (curlError = curl_easy_setopt(_multiHandle, CURLOPT_PROXYAUTH, envProxyAuth)) == CURLE_OK || + LOG(ERROR) << "Cannot set curl proxy authentication: " << curl_easy_strerror(curlError); + + /* This points to a linked list of headers used for proxy requests only, + struct curl_slist kind */ + if (envProxyHeader && unsupported) + (curlError = curl_easy_setopt(_multiHandle, CURLOPT_PROXYHEADER, envProxyHeader)) == CURLE_OK || + LOG(ERROR) << "Cannot set curl proxy header: " << curl_easy_strerror(curlError); + + /* "name" and "pwd" to use with Proxy when fetching. */ + if (envProxyUsername) + (curlError = curl_easy_setopt(_multiHandle, CURLOPT_PROXYUSERNAME, envProxyUsername)) == CURLE_OK || + LOG(ERROR) << "Cannot set curl proxy username: " << curl_easy_strerror(curlError); + if (envProxyPassword) + (curlError = curl_easy_setopt(_multiHandle, CURLOPT_PROXYPASSWORD, envProxyPassword)) == CURLE_OK || + LOG(ERROR) << "Cannot set curl proxy password: " << curl_easy_strerror(curlError); + + /* Port of the proxy, can be set in the proxy string as well with: + "[host]:[port]" */ + if (envProxyPort) + (curlError = curl_easy_setopt(_multiHandle, CURLOPT_PROXYPORT, envProxyPort)) == CURLE_OK || + LOG(ERROR) << "Cannot set curl proxy port: " << curl_easy_strerror(curlError); + + /* indicates type of proxy. accepted values are CURLPROXY_HTTP (default), + CURLPROXY_SOCKS4, CURLPROXY_SOCKS4A and CURLPROXY_SOCKS5. */ + if (envProxyType && unsupported) + (curlError = curl_easy_setopt(_multiHandle, CURLOPT_PROXYTYPE, envProxyType)) == CURLE_OK || + LOG(ERROR) << "Cannot set curl proxy type: " << curl_easy_strerror(curlError); + + /* "user:password" to use with proxy. */ + if (envProxyUserPwd) + (curlError = curl_easy_setopt(_multiHandle, CURLOPT_PROXYUSERPWD, envProxyUserPwd)) == CURLE_OK || + LOG(ERROR) << "Cannot set curl proxy user password: " << curl_easy_strerror(curlError); + start(); } diff --git a/src/uscxml/transform/ChartToPromela.cpp b/src/uscxml/transform/ChartToPromela.cpp index ea83784..9b6674d 100644 --- a/src/uscxml/transform/ChartToPromela.cpp +++ b/src/uscxml/transform/ChartToPromela.cpp @@ -2267,6 +2267,21 @@ void ChartToPromela::initNodes() { _analyzer.addCode(*codeIter); } + // add all namelist entries to the _event structure + { + NodeSet<std::string> withNamelist; + withNamelist.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "send", _scxml, true)); + withNamelist.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true)); + for (int i = 0; i < withNamelist.size(); i++) { + if (HAS_ATTR_CAST(withNamelist[i], "namelist")) { + std::string namelist = ATTR_CAST(withNamelist[i], "namelist"); + std::list<std::string> names = tokenizeIdRefs(namelist); + for (std::list<std::string>::iterator nameIter = names.begin(); nameIter != names.end(); nameIter++) { + _analyzer.addCode("_event.data." + *nameIter + " = 0;"); // introduce for _event_t typedef + } + } + } + } } std::string ChartToPromela::sanitizeCode(const std::string& code) { |