try to make deluged to use VPN

General support for problems installing or using Deluge
Post Reply
tuxin

try to make deluged to use VPN

Post by tuxin »

Hello,
I know that this subject has been treated many times, but after three days searching a solution, i come to you, hoping find a way to solve it.

First, i am running on ubuntu server 12.04.
I installed deluge as a daemon (deluged) and the web-ui. All of this is working fine.

I am now trying to use deluged through a VPN connection. When i set the "listen_interface" field of the core.conf file with the value returned by ifconfig, deluge says something like "cannot assign the requested address".

So the question is, i am right when i set this field ??
when ifconfig returned something like :

ppp0 Link encap:Point-to-Point Protocol
inet addr:mynetaddress P-t-P:the_network_address_of_the_vpn Mask:255.255.255.255
....

in the core.conf file, i set:
"listen_interface"="the_network_address_of_the_vpn"

thanks by advance :)
tuxin
Milliways

Re: try to make deluged to use VPN

Post by Milliways »

This is the script i use to keep Deluge to only listen on the current vpn ip, just save as vpnchk.sh and do sh vpnchk.sh as the user who runs deluge:

Code: Select all

#!/bin/sh
# Name of the vpn connection
pppname="vpnname"

# Number of the ppp connection, usualy ppp0 or tun0
pppnum="tun0"

# Directory where the configurationfiles are stored
configdir="/home/username/.config/deluge/"
 
# You shouldn't need to edit below
while true
do
 
 if ps ax | nmcli  con show --active id $pppname  | grep -v grep | grep $pppname > /dev/null
 then
    echo "vpn ok" > /dev/null
 else
    nmcli --nocheck con up id $pppname
    echo "VPN is not running! Restarting it"
 fi
 pppip=$(LANG= /sbin/ifconfig $pppnum | grep inet | awk '{ print $2 }' | cut -d: -f2) > /dev/null
 
 if [ -n "$pppip" ]; then
   ppphostnamefile="$configdir/ppphost.cfg"
   ppphost=`cat $ppphostnamefile`
   if [ "$pppip" != "$ppphost" ]; then
     delugepid=$(LANG= ps -ef | grep -v grep | grep deluge | awk '{ print $2 }')
     if [ -n "$delugepid" ]; then
       kill $delugepid
     fi
 
    cd $configdir
        sedcmd="sed -e s/\"listen_interface.*\"/\"listen_interface\":\"$pppip\"/"
     cat core.conf | $sedcmd > core2.conf
     rm -rf core.conf
     mv core2.conf core.conf
     echo -n $pppip > ppphost.cfg
     screen -dmS deluge deluge-gtk
   fi
 fi
 
 sleep 30
done
Post Reply