diff options
author | Alberto Garcia Illera <agarciaillera@gmail.com> | 2022-10-21 15:35:59 +1100 |
---|---|---|
committer | Alberto Garcia Illera <agarciaillera@gmail.com> | 2022-10-21 15:35:59 +1100 |
commit | 11e3867a8e819e71253d66f6dfb583cd1cdc870b (patch) | |
tree | 4432e86197a87a88491123e9e7966f1e9f80e8b7 | |
parent | d06a8657d6a29c0950707fa2f0429099190b0ad8 (diff) | |
download | libproxy-git-11e3867a8e819e71253d66f6dfb583cd1cdc870b.tar.gz |
init and destroy winsock on Windows
-rw-r--r-- | libproxy/modules/pacrunner_duktape.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libproxy/modules/pacrunner_duktape.cpp b/libproxy/modules/pacrunner_duktape.cpp index 12e3df6..2c44ae1 100644 --- a/libproxy/modules/pacrunner_duktape.cpp +++ b/libproxy/modules/pacrunner_duktape.cpp @@ -81,6 +81,11 @@ static duk_ret_t myIpAddress(duk_context *ctx) { class duktape_pacrunner : public pacrunner { public: duktape_pacrunner(string pac, const url& pacurl) : pacrunner(pac, pacurl) { +#ifdef _WIN32 + // On windows, we need to initialize the winsock dll first. + WSADATA WsaData; + WSAStartup(MAKEWORD(2, 0), &WsaData); +#endif this->ctx = duk_create_heap_default(); if (!this->ctx) goto error; duk_push_c_function(this->ctx, dnsResolve, 1); @@ -109,6 +114,9 @@ public: ~duktape_pacrunner() { duk_destroy_heap(this->ctx); +#ifdef _WIN32 + WSACleanup(); +#endif } string run(const url& url_) override { |