Back to previous page

Purpose

This page explain how to change the way how proxydriver generates the configuration name.
When proxydriver recieves a connection event, it generates the configuration name; then, proxydriver will try to load the corresponding configuration profile.
If you are not using the classic way to use proxydriver – connects to several wifi networks with different proxy settings – this article may interrest you.

Why? If you can generate differently the configuration name, then you will be able to assign differently profiles when a connection is established, even if connection name is identical (same wifi network, ethernet connection, etc.)

How profile name is generated

For each unique name, a configuration file is generated.

The first try is done with nmcli. If nmcli is not available, then script switch to iwgetid. If nmcli is not available and iwgetid does not provide any network name, the configuration name "default" is used.

if type -P nmcli &>/dev/null
then
	# retrieve connection/vpn name
	networkID=`nmcli -t -f name,devices,vpn con status | \
		awk -F':' "BEGIN { device=\"$1\"; event=\"$2\" } \
			event == \"up\" && \\$2 == device && \\$3 == \"no\" { print \\$1 } \
			event == \"vpn-up\" && \\$3 == \"yes\" { print \"vpn_\" \\$1 }"`
else
	# try ESSID if nmcli is not installed
	logger -p user.notice -t $log_tag "nmcli not detected, will use essid"
		networkID=`iwgetid --scheme`
	[ $? -ne 0 ] && networkID='default'
fi

After this, the configuration name is cleaned (special characters are removed) and profile is loaded or generatedif it does not exists already.

# strip out anything hostile to the file system
networkID=`echo "$networkID" | tr -c '[:alnum:]-' '_' | sed 's/.$/\n/'`

The configuration profiles are stored in directory /etc/proxydriver.d

How modify the script

You need to have root access and edit the proxydriver script which is located here:
/etc/NetworkManager/dispatcher.d/99proxydriver.sh

Using the editor nano with the command line bellow is the simpliest way:

$ sudo nano /etc/NetworkManager/dispatcher.d/99proxydriver.sh

At the line 60, before the strip out command, you can insert command with in order to alter the networkID value which contains the profile name.

Some examples

If you are connecting to several fixed IP wired networks, these lines can help you generting a different file for each differents IP configuration:

# not wlan, use IPv4 address of network to identify
if ! iwconfig "$1" &>/dev/null
then
	networkID=`ip addr show "$1" | awk '$1 == "inet" {print $2;exit}'`
fi

If you are connecting to several wired networks with a dynamic IP but with different IP ranges, using the broadcast address of network you are connecting to is probably more insteresing:

# not wlan, use IPv4 broadcast address of network to identify
if ! iwconfig "$1" &>/dev/null
then
	networkID=`ip addr show "$1" | awk '$1 == "inet" {print $4;exit}'`
fi

Can I use the UUID value?

Unfortunately, this value is volatile and can change even if you are connecting to same network.
It seems to remains identical for wireless networks contrary to wired networks, for which it changes every new session.

contact/mail protection