Package init

This commit is contained in:
overweight 2019-09-30 10:57:39 -04:00
commit ec31002289
7 changed files with 479 additions and 0 deletions

BIN
0.4.15.tar.gz Normal file

Binary file not shown.

View File

@ -0,0 +1,177 @@
From 6f6d2dd74e6a1bd0e356e9290d733672afcf8f70 Mon Sep 17 00:00:00 2001
From: David Woodhouse <David.Woodhouse@intel.com>
Date: Wed, 8 Dec 2010 12:13:43 +0000
Subject: [PATCH] =?UTF-8?q?Add=20config=20module=20for=20querying=20PacRun?=
=?UTF-8?q?ner=20d=C3=A6mon?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
libproxy/cmake/modules.cmk | 2 +
libproxy/cmake/modules/config_pacrunner.cmk | 3 +
libproxy/modules/config_pacrunner.cpp | 122 ++++++++++++++++++++++++++++
3 files changed, 127 insertions(+)
create mode 100644 libproxy/cmake/modules/config_pacrunner.cmk
create mode 100644 libproxy/modules/config_pacrunner.cpp
diff --git a/libproxy/cmake/modules.cmk b/libproxy/cmake/modules.cmk
index 68ff898..2593d29 100644
--- a/libproxy/cmake/modules.cmk
+++ b/libproxy/cmake/modules.cmk
@@ -8,6 +8,7 @@ endif()
# Do module determination
include(cmake/pxmodule.cmk)
include(cmake/pkgconfig.cmk)
+include(cmake/modules/config_pacrunner.cmk)
include(cmake/modules/config_envvar.cmk)
include(cmake/modules/config_sysconfig.cmk)
include(cmake/modules/config_gnome.cmk)
@@ -28,6 +29,7 @@ endif()
## Module definition
#
message("MODULES TO BUILD:")
+px_module(config_pacrunner "${DBUS_FOUND}" 0 ${DBUS_LIBRARIES})
px_module(config_envvar "${ENVVAR_FOUND}" 1)
px_module(config_sysconfig "${SYSCONFIG_FOUND}" 1)
px_module(config_gnome "${GNOME2_FOUND}" 0)
diff --git a/libproxy/cmake/modules/config_pacrunner.cmk b/libproxy/cmake/modules/config_pacrunner.cmk
new file mode 100644
index 0000000..11dde89
--- /dev/null
+++ b/libproxy/cmake/modules/config_pacrunner.cmk
@@ -0,0 +1,3 @@
+if (NOT WIN32 AND NOT APPLE)
+ px_check_modules(DBUS dbus-1)
+endif()
diff --git a/libproxy/modules/config_pacrunner.cpp b/libproxy/modules/config_pacrunner.cpp
new file mode 100644
index 0000000..b4cf723
--- /dev/null
+++ b/libproxy/modules/config_pacrunner.cpp
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * libproxy - A library for proxy configuration
+ * Copyright (C) 2010 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ ******************************************************************************/
+
+#include "../extension_config.hpp"
+using namespace libproxy;
+
+#include <string.h>
+#include <dbus/dbus.h>
+
+class pacrunner_config_extension : public config_extension {
+public:
+ pacrunner_config_extension() {
+ this->conn = NULL;
+ }
+
+ ~pacrunner_config_extension() {
+ if (this->conn) dbus_connection_close(this->conn);
+ }
+
+ class scoped_dbus_message {
+ public:
+ scoped_dbus_message(DBusMessage *msg) {
+ this->msg = msg;
+ }
+
+ ~scoped_dbus_message() {
+ if (this->msg)
+ dbus_message_unref(msg);
+ }
+
+ private:
+ DBusMessage *msg;
+ };
+
+ vector<url> get_config(const url &dest) throw (runtime_error) {
+ // Make sure we have a valid connection with a proper match
+ DBusConnection *conn = this->conn;
+ vector<url> response;
+
+ if (!conn || !dbus_connection_get_is_connected(conn))
+ {
+ // If the connection was disconnected,
+ // close it an clear the queue
+ if (conn)
+ {
+ dbus_connection_close(conn);
+ dbus_connection_read_write(conn, 0);
+ for (DBusMessage *msg=NULL ; (msg = dbus_connection_pop_message(conn)) ; dbus_message_unref(msg)) {};
+ }
+
+ // Create a new connections
+ conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, NULL);
+ this->conn = conn;
+ if (!conn)
+ throw runtime_error("Unable to set up DBus connection");
+
+ // If connection was successful, set it up
+ dbus_connection_set_exit_on_disconnect(conn, false);
+ }
+
+ DBusMessage *msg, *reply;
+
+ msg = dbus_message_new_method_call("org.pacrunner",
+ "/org/pacrunner/client",
+ "org.pacrunner.Client",
+ "FindProxyForURL");
+ if (!msg)
+ throw runtime_error("Unable to create PacRunner DBus call");
+
+ string dest_str = dest.to_string();
+ string dest_host = dest.get_host();
+ const char *dest_cstr = dest_str.c_str();
+ const char *dest_host_cstr = dest_host.c_str();
+
+ dbus_message_append_args(msg, DBUS_TYPE_STRING, &dest_cstr,
+ DBUS_TYPE_STRING, &dest_host_cstr,
+ DBUS_TYPE_INVALID);
+
+ reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, NULL);
+
+ dbus_message_unref(msg);
+
+ if (!reply)
+ throw runtime_error("Failed to get DBus response from PacRunner");
+
+ scoped_dbus_message smsg(reply);
+ char *str = NULL;
+ dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID);
+
+ if (!str || !strlen(str) || !::strcmp(str, "DIRECT"))
+ response.push_back(url("direct://"));
+ else if (!strncmp(str, "PROXY ", 6))
+ response.push_back(url("http://" + string(str + 6)));
+ else if (!strncmp(str, "SOCKS ", 6))
+ response.push_back(url("socks://" + string(str + 6)));
+ else {
+ throw runtime_error("Unrecognised proxy response from PacRunner: " + string(str));
+ }
+ return response;
+ }
+
+private:
+ DBusConnection *conn;
+};
+
+MM_MODULE_INIT_EZ(pacrunner_config_extension, true, NULL, NULL);
--
1.8.2.1

View File

@ -0,0 +1,41 @@
diff -up libproxy-0.4.11/libproxy/extension_pacrunner.cpp.crash libproxy-0.4.11/libproxy/extension_pacrunner.cpp
--- libproxy-0.4.11/libproxy/extension_pacrunner.cpp.crash 2010-07-29 08:14:59.000000000 -0400
+++ libproxy-0.4.11/libproxy/extension_pacrunner.cpp 2013-11-11 15:23:56.987266457 -0500
@@ -22,20 +22,10 @@ using namespace libproxy;
pacrunner::pacrunner(string, const url&) {}
-pacrunner_extension::pacrunner_extension() {
- this->pr = NULL;
-}
+pacrunner_extension::pacrunner_extension() {}
-pacrunner_extension::~pacrunner_extension() {
- if (this->pr) delete this->pr;
-}
+pacrunner_extension::~pacrunner_extension() {}
pacrunner* pacrunner_extension::get(string pac, const url& pacurl) throw (bad_alloc) {
- if (this->pr) {
- if (this->last == pac)
- return this->pr;
- delete this->pr;
- }
-
- return this->pr = this->create(pac, pacurl);
+ return this->create(pac, pacurl);
}
diff -up libproxy-0.4.11/libproxy/proxy.cpp.crash libproxy-0.4.11/libproxy/proxy.cpp
--- libproxy-0.4.11/libproxy/proxy.cpp.crash 2013-11-11 15:25:27.309271353 -0500
+++ libproxy-0.4.11/libproxy/proxy.cpp 2013-11-11 15:25:31.569271584 -0500
@@ -416,7 +416,9 @@ void proxy_factory::run_pac(url &realurl
/* Run the PAC, but only try one PACRunner */
if (debug) cerr << "Using pacrunner: " << typeid(*pacrunners[0]).name() << endl;
- string pacresp = pacrunners[0]->get(this->pac, this->pacurl->to_string())->run(realurl);
+ pacrunner* runner = pacrunners[0]->get(this->pac, this->pacurl->to_string());
+ string pacresp = runner->run(realurl);
+ delete runner;
if (debug) cerr << "Pacrunner returned: " << pacresp << endl;
format_pac_response(pacresp, response);
}

View File

@ -0,0 +1,101 @@
From f594720280b2e40d81fa6e286a0ef8868687ef7e Mon Sep 17 00:00:00 2001
From: Pierre Lejeune <superheron@gmail.com>
Date: Sat, 30 Jun 2018 21:10:06 +0200
Subject: [PATCH] Build with mozjs-52
Fixes #71
---
libproxy/cmake/modules/pacrunner_mozjs.cmk | 2 +-
libproxy/modules/pacrunner_mozjs.cpp | 19 +++++++------------
2 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/libproxy/cmake/modules/pacrunner_mozjs.cmk b/libproxy/cmake/modules/pacrunner_mozjs.cmk
index c2ae3db..20857fb 100644
--- a/libproxy/cmake/modules/pacrunner_mozjs.cmk
+++ b/libproxy/cmake/modules/pacrunner_mozjs.cmk
@@ -9,7 +9,7 @@ if(WIN32)
elseif(NOT APPLE)
option(WITH_MOZJS "Search for MOZJS package" ON)
if (WITH_MOZJS)
- pkg_search_module(MOZJS mozjs-38)
+ pkg_search_module(MOZJS mozjs-52)
if(MOZJS_FOUND)
include_directories(${MOZJS_INCLUDE_DIRS})
link_directories(${MOZJS_LIBRARY_DIRS})
diff --git a/libproxy/modules/pacrunner_mozjs.cpp b/libproxy/modules/pacrunner_mozjs.cpp
index a70b2e9..ed07c69 100644
--- a/libproxy/modules/pacrunner_mozjs.cpp
+++ b/libproxy/modules/pacrunner_mozjs.cpp
@@ -35,6 +35,7 @@ using namespace libproxy;
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
#include <jsapi.h>
#pragma GCC diagnostic error "-Winvalid-offsetof"
+#include <js/Initialization.h>
#include <js/CallArgs.h>
#include "pacutils.h"
@@ -111,17 +112,14 @@ class mozjs_pacrunner : public pacrunner {
mozjs_pacrunner(string pac, const url& pacurl) throw (bad_alloc) : pacrunner(pac, pacurl) {
// Set defaults
- this->jsrun = nullptr;
this->jsctx = nullptr;
JS_Init();
- // Initialize Javascript runtime environment
- if (!(this->jsrun = JS_NewRuntime(1024 * 1024))) goto error;
- if (!(this->jsctx = JS_NewContext(this->jsrun, 1024 * 1024))) goto error;
+ // Initialize Javascript context
+ if (!(this->jsctx = JS_NewContext(1024 * 1024))) goto error;
{
JS::RootedValue rval(this->jsctx);
JS::CompartmentOptions compart_opts;
- compart_opts.setVersion(JSVERSION_LATEST);
this->jsglb = new JS::Heap<JSObject*>(JS_NewGlobalObject(
this->jsctx, &cls,
@@ -139,16 +137,15 @@ class mozjs_pacrunner : public pacrunner {
JS::CompileOptions options(this->jsctx);
options.setUTF8(true);
- JS::Evaluate(this->jsctx, global, options, JAVASCRIPT_ROUTINES,
- strlen(JAVASCRIPT_ROUTINES), &rval);
+ JS::Evaluate(this->jsctx, options, JAVASCRIPT_ROUTINES,
+ strlen(JAVASCRIPT_ROUTINES), JS::MutableHandleValue(&rval));
// Add PAC to the environment
- JS::Evaluate(this->jsctx, global, options, pac.c_str(), pac.length(), &rval);
+ JS::Evaluate(this->jsctx, options, pac.c_str(), pac.length(), JS::MutableHandleValue(&rval));
return;
}
error:
if (this->jsctx) JS_DestroyContext(this->jsctx);
- if (this->jsrun) JS_DestroyRuntime(this->jsrun);
throw bad_alloc();
}
@@ -156,7 +153,6 @@ class mozjs_pacrunner : public pacrunner {
if (this->jsac) delete this->jsac;
if (this->jsglb) delete this->jsglb;
if (this->jsctx) JS_DestroyContext(this->jsctx);
- if (this->jsrun) JS_DestroyRuntime(this->jsrun);
JS_ShutDown();
}
@@ -178,7 +174,7 @@ class mozjs_pacrunner : public pacrunner {
JS::RootedObject global(this->jsctx,this->jsglb->get());
bool result = JS_CallFunctionName(this->jsctx, global, "FindProxyForURL", args, &rval);
if (!result) return "";
-
+
char * tmpanswer = JS_EncodeString(this->jsctx, rval.toString());
string answer = string(tmpanswer);
JS_free(this->jsctx, tmpanswer);
@@ -188,7 +184,6 @@ class mozjs_pacrunner : public pacrunner {
}
private:
- JSRuntime *jsrun;
JSContext *jsctx;
JS::Heap<JSObject*> *jsglb;
JSAutoCompartment *jsac;

View File

@ -0,0 +1,26 @@
From 2d6da65598b90480b4a62c4633eda035ea51681f Mon Sep 17 00:00:00 2001
From: David King <amigadave@amigadave.com>
Date: Wed, 27 Jun 2018 06:36:00 +0100
Subject: [PATCH] python: support Python 3.7 and 3.8
Add 3.7 and 3.8 to the list of accepted Python 3 versions.
---
cmake/FindPython3Interp.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmake/FindPython3Interp.cmake b/cmake/FindPython3Interp.cmake
index c6cbe3d..8e5e409 100644
--- a/cmake/FindPython3Interp.cmake
+++ b/cmake/FindPython3Interp.cmake
@@ -39,7 +39,7 @@
unset(_Python3_NAMES)
-set(_Python3_VERSIONS 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
+set(_Python3_VERSIONS 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
if(Python3Interp_FIND_VERSION)
if(Python3Interp_FIND_VERSION_COUNT GREATER 1)
--
2.17.1

111
libproxy.spec Normal file
View File

@ -0,0 +1,111 @@
Name: libproxy
Version: 0.4.15
Release: 10
Summary: Libproxy is a library that provides automatic proxy configuration management
License: LGPLv2+
URL: https://libproxy.github.io/libproxy/
Source0: https://github.com/libproxy/%{name}/archive/%{version}.tar.gz
# Source1 comes from the Debian package.
Source1: proxy.1
# Patch0 and patch 1 come from fedora commuity
Patch0: 0001-Add-config-module-for-querying-PacRunner-d-mon.patch
Patch1: libproxy-0.4.11-crash.patch
# Patch 2 and 3 are backported from upstream commuity
Patch2: libproxy-0.4.15-python3738.patch
Patch3: libproxy-0.4.15-mozjs52.patch
BuildRequires: cmake >= 2.6.0 gcc-c++ libmodman-devel >= 2.0.1
BuildRequires: pkgconfig(gio-2.0) >= 2.26 pkgconfig(mozjs-52) pkgconfig(libnm) python2-devel python3-devel
BuildRequires: pkgconfig(dbus-1) pkgconfig(javascriptcoregtk-4.0) /usr/bin/kreadconfig5
Provides: %{name}-bin %{name}-gnome %{name}-kde %{name}-mozjs %{name}-networkmanager %{name}-pacrunner %{name}-webkitgtk4
Obsoletes: %{name}-bin %{name}-gnome %{name}-kde %{name}-mozjs %{name}-networkmanager %{name}-pacrunner %{name}-webkitgtk4
%description
libproxy offers the following features:
* extremely small core footprint (< 35K).
* no external dependencies within libproxy core.
(libproxy plugins may have dependencies).
* only 3 functions in the stable external API.
* dynamic adjustment to changing network topology.
* a standard way of dealing with proxy settings across all scenarios.
%package -n python2-%{name}
Summary: Binding for %{name} and python2
Requires: %{name} = %{version}-%{release}
BuildArch: noarch
%{?python_provide:%python_provide python2-%{name}}
%description -n python2-%{name}
The python2 binding for libproxy.
%package -n python3-%{name}
Summary: Binding for %{name} and python3
Requires: %{name} = %{version}-%{release}
BuildArch: noarch
%{?python_provide:%python_provide python3-%{name}}
%description -n python3-%{name}
The python3 binding for libproxy.
%package devel
Summary: Libproxy provides consistent proxy configuration to applications - Development Files
Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
This package contains libraries and header files for developing applications.
%package help
Summary: Documents for libproxy.
%description help
This package provides documents.
%prep
%autosetup -p1
%build
%{cmake} \
-DMODULE_INSTALL_DIR=%{_libdir}/%{name}/%{version}/modules \
-DWITH_PERL=OFF -DWITH_GNOME3=ON -DWITH_PYTHON2=ON -DPYTHON2_EXECUTABLE=%{__python2} \
-DWITH_PYTHON3=ON -DWITH_WEBKIT3=ON -DWITH_MOZJS=ON .
%make_build
%install
%make_install
mkdir -p %{buildroot}%{_libdir}/%{name}/%{version}/modules
install -Dpm 0644 %{SOURCE1} %{buildroot}/%{_mandir}/man1/proxy.1
%check
make test
%ldconfig_scriptlets
%files
%doc AUTHORS README COPYING
%{_libdir}/*.so.*
%{_bindir}/proxy
%{_libdir}/%{name}/%{version}/modules/*
%{_libexecdir}/pxgsettings
%files -n python2-%{name}
%{python2_sitelib}/%{name}.*
%files -n python3-%{name}
%{python3_sitelib}/__pycache__/*
%{python3_sitelib}/%{name}.*
%files devel
%{_includedir}/proxy.h
%{_libdir}/*.so
%{_libdir}/pkgconfig/libproxy-1.0.pc
%{_datadir}/cmake/Modules/Findlibproxy.cmake
%files help
%{_mandir}/man1/proxy.1*
%changelog
* Tue Sep 10 2019 liyongqiang<liyongqiang10@huawei.com> - 0.4.15-10
- Package init

23
proxy.1 Normal file
View File

@ -0,0 +1,23 @@
.TH PROXY "1" "September 2013" "libproxy" "User Commands"
.SH NAME
proxy \- Display the proxy server that should be used to reach a given a network resource
.SH SYNOPSIS
proxy
.SH DESCRIPTION
Display the proxy server that should be used to reach a given a network resource.
.PP
libproxy is a library that provides automatic proxy configuration management
using different backends.
.SH EXAMPLE
.B echo http://www.example.com/ | proxy
http://webcache:3128 direct://
.SH AUTHOR
This manual page was written by
.MT bigon@debian.org
Laurent Bigonville
.ME ,
for the Debian GNU/Linux system (but may be used by others).
.SH SEE ALSO
.UR http://code.google.com/p/libproxy/
libproxy
.UE .