These are chat archives for Nithmr/ProxyHelper

1st
Jun 2016
Utkarsh Raj
@clearnote01
Jun 01 2016 08:05
Umm... Yeah... almost
Got kind of distracted by some other things..... But rn the python part of the script is complete and what remains is linking the bash and the python script
Akarshit Wal
@Akarshit
Jun 01 2016 08:37
@clearnote01 Cool. So the application has been converted to python. Now parallalization needs to be implemented. Right?
Nope, I have implemented parallel pinging and it's working !
master branch is the new update ProxyHelper
alternate branch is the old one
*updated
Akarshit Wal
@Akarshit
Jun 01 2016 09:47
OK cool will test this and let you know.
Utkarsh Raj
@clearnote01
Jun 01 2016 10:16
nice
Akarshit Wal
@Akarshit
Jun 01 2016 10:18
Till then have a look at #5 its really necessary
Utkarsh Raj
@clearnote01
Jun 01 2016 10:20
Yeah, looking rn
Also for testing, try running just the python3 script
for the parallel pinging and other stuffs
Akarshit Wal
@Akarshit
Jun 01 2016 10:23
Ok will do.
Akarshit Wal
@Akarshit
Jun 01 2016 15:04
We can add this right now and then see on how many systems it works.
Utkarsh Raj
@clearnote01
Jun 01 2016 15:04
Putting a script in /etc/network/if-up.d folder makes it run whenever connected to network
but...
i can't seem to do it for my script, even though it works fine for a demo
Akarshit Wal
@Akarshit
Jun 01 2016 15:05
Though I feel there might be a better way to do this in python. Establishing some listeners and then executing the script accordingly
Utkarsh Raj
@clearnote01
Jun 01 2016 15:06
I am aware of that technique... can you elaborate?
it should work on most debian based system by given answer but I somehow can't... can you try implementing it that way?
Maybe it's Kubuntu's fault :P
Akarshit Wal
@Akarshit
Jun 01 2016 15:07
I don't know exactly, I just hope that python should be having a library to detect connections. Using that we can run our script.
OK I will try this on ubuntu.
Utkarsh Raj
@clearnote01
Jun 01 2016 15:08
I don't know... .shouldn't this means that it will always running in background?
A callback method like the answer seems kinda superior
Akarshit Wal
@Akarshit
Jun 01 2016 15:09
Yes, it will always run in background. The answer seems better to me too. But it is quite platform dependent. Do you think doing it the python way will make it platform independent?
Utkarsh Raj
@clearnote01
Jun 01 2016 15:10
No
I don't think it will work for windows anyway...
setting system proxy in windows seems a really hi-fi job
requiring some System API calls in C
which I don
Akarshit Wal
@Akarshit
Jun 01 2016 15:11
OK, lets first make this for linux then.
Utkarsh Raj
@clearnote01
Jun 01 2016 15:11
't think I can write
Yeah
Akarshit Wal
@Akarshit
Jun 01 2016 15:11
BTW do you know a windows developer?
Utkarsh Raj
@clearnote01
Jun 01 2016 15:11
Nope
Still... for windows a superior option
would be using PAC files
Utkarsh Raj
@clearnote01
Jun 01 2016 15:33
Well.... I am trying to debug the script and it turns out
that all its part are running except the python portion
automatically when connected to wifi
Akarshit Wal
@Akarshit
Jun 01 2016 15:45
I asked @akshendra to try the script.
Waiting for his response.
Utkarsh Raj
@clearnote01
Jun 01 2016 15:54
Okay... thanks
I am able to schedule the python script according to connection
but it does not work inside the bash script
So...
Even if I can't get it to work inside, I will
just port every part of bash script to python
Akarshit Wal
@Akarshit
Jun 01 2016 15:56
Ya that would be a good idea.
Utkarsh Raj
@clearnote01
Jun 01 2016 15:56
I mean that's it plan B for me
Akshendra Pratap Singh
@akshendra
Jun 01 2016 15:56
Should I try the script on the github repo?
Utkarsh Raj
@clearnote01
Jun 01 2016 15:56
Yeah
the master branch
Akshendra Pratap Singh
@akshendra
Jun 01 2016 15:56
Okay
Akarshit Wal
@Akarshit
Jun 01 2016 15:56
Try to automate the running of the script using the SO answer
try from here... i forgot this is not merged into main
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:00
What does it supposed to do?
Utkarsh Raj
@clearnote01
Jun 01 2016 16:00
umm... the repo ? or the answer?
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:00
The repo
Utkarsh Raj
@clearnote01
Jun 01 2016 16:01
Try the python3 script first
it will ping many proxies and DN in parallel and return the fastest proxy
the bash script is a wrapper for the python script
and uses the resulting proxy to set in '/etc/environment' and '/etc/apt/apt.conf'
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:04
I got this
(MainThread) Threads created 11
(Thread-1 ) Created thread
(Thread-1 ) Class name original
(Thread-2 ) Created thread
(Thread-3 ) Created thread
(Thread-2 ) Class name original
(Thread-4 ) Created thread
(Thread-4 ) Class name original
(Thread-3 ) Class name original
(Thread-5 ) Created thread
(Thread-5 ) Class name original
(Thread-6 ) Created thread
(Thread-6 ) Class name original
(Thread-7 ) Created thread
(Thread-7 ) Class name original
(Thread-8 ) Created thread
(Thread-8 ) Class name original
(Thread-9 ) Created thread
(Thread-9 ) Class name original
(Thread-10) Created thread
(Thread-10) Class name original
(Thread-11) Created thread
(Thread-11) Class name original
Output is 36.225
(Thread-2 ) Handling task {'bing.com': 36.225}
Output is 14.146
(Thread-11) Handling task {'reddit.com': 37.584, 'bing.com': 36.225}
Output is 37.584
(Thread-1 ) Handling task {'reddit.com': 37.584, 'bing.com': 36.225, 'google.com': 37.584}
Output is 274.683
(Thread-3 ) Handling task {'reddit.com': 37.584, 'wikipedia.com': 274.683, 'bing.com': 36.225, 'google.com': 37.584}
Output is inf
(Thread-4 ) Handling task {'172.16.24.2': inf, 'reddit.com': 37.584, 'wikipedia.com': 274.683, 'bing.com': 36.225, 'google.com': 37.584}
Output is inf
(Thread-8 ) Handling task {'wikipedia.com': 274.683, 'google.com': 37.584, '172.16.12.3': inf, 'reddit.com': 37.584, '172.16.24.2': inf, 'bing.com': 36.225}
Output is inf
(Thread-6 ) Handling task {'wikipedia.com': 274.683, 'google.com': 37.584, '172.16.12.3': inf, 'reddit.com': 37.584, '172.16.24.2': inf, 'bing.com': 36.225, '172.16.24.4': inf}
Output is inf
(Thread-5 ) Handling task {'172.16.24.3': inf, 'wikipedia.com': 274.683, 'google.com': 37.584, '172.16.12.3': inf, 'reddit.com': 37.584, '172.16.24.2': inf, 'bing.com': 36.225, '172.16.24.4': inf}
Output is inf
(Thread-9 ) Handling task {'172.16.24.3': inf, 'wikipedia.com': 274.683, 'google.com': 37.584, '172.16.20.2': inf, '172.16.12.3': inf, 'reddit.com': 37.584, '172.16.24.2': inf, 'bing.com': 36.225, '172.16.24.4': inf}
Output is inf
(Thread-7 ) Handling task {'172.16.24.3': inf, '172.16.12.2': inf, 'wikipedia.com': 274.683, 'google.com': 37.584, '172.16.20.2': inf, '172.16.12.3': inf, 'reddit.com': 37.584, '172.16.24.2': inf, 'bing.com': 36.225, '172.16.24.4': inf}
ping: unknown host None
Output is inf
(Thread-10) Handling task {'172.16.24.3': inf, '172.16.12.2': inf, 'wikipedia.com': 274.683, 'google.com': 37.584, '172.16.20.2': inf, '172.16.12.3': inf, 'None': inf, 'reddit.com': 37.584, '172.16.24.2': inf, 'bing.com': 36.225, '172.16.24.4': inf}
(MainThread) Time taken for resolution = 6.480717420578003
Proxy : bing.com
Utkarsh Raj
@clearnote01
Jun 01 2016 16:04
Yeah... it is correct
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:04
It got the same thing, when I ran the bash script
Utkarsh Raj
@clearnote01
Jun 01 2016 16:05
yeah... since we are not in proxy in our current n/w
I used Domain Name for pinging
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:05
Cool
Utkarsh Raj
@clearnote01
Jun 01 2016 16:05
in ideal case we will replace all the proxies with college proxies
Now the issue is that it should run automatically
when network interface is turned on
something like the 1st answer here
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:07
I tried that and it seems to be not working for me
Utkarsh Raj
@clearnote01
Jun 01 2016 16:07
Yeah... ik
i debugged it
and it seems that while the bash script is
running. the python inside is not :/
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:08
Can you see the error log or something?
Utkarsh Raj
@clearnote01
Jun 01 2016 16:08
is there an error log?
i have no idea where it is stored
for n/w if
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:10
You can add that some logging in your shell script
Maybe check syslog, not sure though
Utkarsh Raj
@clearnote01
Jun 01 2016 16:11
Sorry I don't know about that... can you try it and tell?
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:12
Also have you tried giving absolute path of the python script inside of the bash script
Utkarsh Raj
@clearnote01
Jun 01 2016 16:12
Yeah.. I am currently trying that
wow... i don't believe... i made such a stupid mistake
thanks... I think it is working now!!1
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:16
Awesome
Utkarsh Raj
@clearnote01
Jun 01 2016 16:16
well... actually i am not sure if it's completely working or not
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:16
How did you make the script run on network connection? I tried the first solution in the StackOverflow answer and it's not working
Utkarsh Raj
@clearnote01
Jun 01 2016 16:16
but yeah... the path was def a problem
umm... i just added into the folder
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:17
the path is always a problem
Utkarsh Raj
@clearnote01
Jun 01 2016 16:17
/etc/network/if-up.d
renamed it start with z
since files are exec in lexic order
chmod +x
yeah, that's that :)
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:18
Yeah I did all these
Akarshit Wal
@Akarshit
Jun 01 2016 16:18
Cool!
Utkarsh Raj
@clearnote01
Jun 01 2016 16:18
well... it's not working for me completely... but I think it will
in a moment or two
:/
And it is
finally
it is working!!
Thanks everyone
Akarshit Wal
@Akarshit
Jun 01 2016 16:20
OK, so what are you working on next
Utkarsh Raj
@clearnote01
Jun 01 2016 16:20
I don't know
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:20
@clearnote01 Great job
Utkarsh Raj
@clearnote01
Jun 01 2016 16:21
isn't it finished now?
:)
Akarshit Wal
@Akarshit
Jun 01 2016 16:22
Nops. We have a lot to do.
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:22
You can make an install script to
Utkarsh Raj
@clearnote01
Jun 01 2016 16:22
Yeah... in bash?
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:23
Yes in bash, it would be nothing more than copying files and making it executable
Utkarsh Raj
@clearnote01
Jun 01 2016 16:24
Yea... it's really nothing more than that
some chmod and mv
Akarshit Wal
@Akarshit
Jun 01 2016 16:24
Yes that is a great idea.
Before that make a PR when you think the code is in a stable state.
Utkarsh Raj
@clearnote01
Jun 01 2016 16:27
yepp... doing it rn
honestly, this application looks really useful :)
no trouble with proxy ever again !
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:29
You can also take a look at the script generated by oduso.com, they ask for sudo permission through their script
Utkarsh Raj
@clearnote01
Jun 01 2016 16:31
i don't understand...
is this for the bash script?
?_?
Akshendra Pratap Singh
@akshendra
Jun 01 2016 16:31
Yes the script ask for the password, so if someone runs without sudo, it will ask for the permission itself
Just an enhancement, not really necessary
Utkarsh Raj
@clearnote01
Jun 01 2016 16:32
ah.. okay
Akarshit Wal
@Akarshit
Jun 01 2016 16:33
We will be needing that script as we will have to setup up many things for future options.
Akarshit Wal
@Akarshit
Jun 01 2016 16:40
I have a idea!
What if we take the automation 1 step further. Instead of pinging all the proxies on the connected network. What if we ping all the proxies on all the available network.
For example the network list is as follows
  1. Netgear ( full signal)
  2. DLink (medium signal)
  3. PhD Lab (low signal)
    The signal strength could be easily derived (bcoz it is shown in the GUI).
    So the script will first connect to Netgear and try the best proxy there. If Netgear doesn't have any proxy working it will automatically connect to DLink and will ping all proxies there and so on.
    The process will stop when a working proxy has been found on a connection.
Utkarsh Raj
@clearnote01
Jun 01 2016 17:01
well... not very hard to implement
nmcli in ubuntu and ubuntu derived distros make it a pretty simple task
But I think they are better as separate components... cause actually they can work pretty well independently. The ping_proxy_set script runs automatically whenever any Wifi network is connected. So we can have this extra automation script to check all networks
I have no idea how it will be callbacked but there must be someway
Utkarsh Raj
@clearnote01
Jun 01 2016 17:15
On the same note, should checking the network signal strength suffice in some degree?
Akshendra Pratap Singh
@akshendra
Jun 01 2016 17:16
I don't think signal strenght matter, who knows what bandwidth the router is actually allocated
Utkarsh Raj
@clearnote01
Jun 01 2016 17:17
  • SSID MODE CHAN RATE SIGNAL BARS SECURITY
    TP-LINK93D2FE Infra 1 54 Mbit/s 59 ▂▄▆ WPA2
    TP-LINK658077 Infra 10 54 Mbit/s 40 ▂▄_ WPA2
    TP-LINK wifi Infra 1 54 Mbit/s 39 ▂▄ WPA1 WPA2
result of 'nmcli d wifi' at my place is something like this
and I thought if it could get us some general info
_<
Utkarsh Raj
@clearnote01
Jun 01 2016 17:28
I think that we should postpone this task for later... it seems a lot of work and while it certainly looks useful, out current application works pretty nice as well
I think we should expand into covering different tools like youtube-dl, pip, etc
which sometimes don't work with environment proxy, so we can set alias in bash with the currently set proxy
Also the ReadMe should be made more comprehensive, since much has changed since last time... there should be info about changing proxy settings to take it from system proxy, etc
Utkarsh Raj
@clearnote01
Jun 01 2016 17:34
I mean, I think we should focus on(for now) finalizing the application so anyone can quickly clone it & use it as everyday application