New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need quick proxy switch #742
Comments
If you are going to work on something like this, make sure it works for all of the downloaders, not just one. |
Can you give me a few sentences on where to get started implementing this? How you'd like to see it get done? I'm not familiar with the codebase, so don't know where to start. |
Ok, so at the HTTP level there are "downloaders". These are classes that interface with different APIs or external programs to actually download files from the internet. The primary downloader uses the Python urllib/urllib2 module, and it used for non-secure downloads on OS X and Linux, plus secure downloads on OS X: Sublime Text doesn't bundle the _ssl module on Linux, so there are two downloaders for secure connections on Linux, both which use external programs (curl and wget): On Windows, all downloads (secure and not) are passed through the WinINet API so that Sublime Text uses the system-wide proxy settings: Each downloader gets a settings dict passed to its constructor. Control of what settings are loaded from the settings file is performed in: If you are going to create a new command, it should be placed in a file in https://github.com/wbond/sublime_package_control/tree/master/package_control/commands and added to the init.py. Then you'll need to add the name of the command to the list of commands exposed to the command palette: https://github.com/wbond/sublime_package_control/blob/master/Default.sublime-commands. Good luck! |
@berniedurfee There is a better solution to define settings based on your current machine/platform. The rough idea is to modify settings in a plugin. This is still no optimal solution but AFAIS Sublime is too limited for a really good synchronization across different machines/platforms. So here is some pseudo code:
This should probably be but in a plugin which is loaded before Package Control, e.g. |
FWIW, the pseudo code won't do since Instead you have to use the json module (and possibly account for comments in the file that you'll have to skip; see this). |
Ah yes, but doing this in |
Syncing the same config between work system and personal system is great in theory, but the docs (https://packagecontrol.io/docs/syncing) won't work if you have to set an Rather than implementing a manual "quick proxy switch", perhaps it would be better to create a more general purpose plugin that can customize settings based on detected system information. This plugin could update the proxy and/or other settings based on machine name, wifi network name, IP address range, whether VPN is active, etc. I haven't ever written a Sublime plugin, but it seems like this would be doable and more versatile. Perhaps PlatformSettings might be a good place to start looking for ideas? |
What about something like this in {
"http_proxy": "proxy.example.com",
"https_proxy": "proxy.example.com",
"proxy_username": "",
"proxy_password": "",
"machines": [
// specific config for machine 1
"machine1-name": {
// eg: specify user info to use on this machine
"proxy_username": "proxyuser",
"proxy_password": "proxypassword",
},
// specific config for machine 2
"machine2-name": {
// eg: no proxy needed for this machine
"http_proxy": "",
"https_proxy": "",
}
]
} Or something like this (separate machine-specific config into its own file): file {
"http_proxy": "proxy.example.com",
"https_proxy": "proxy.example.com",
"proxy_username": "",
"proxy_password": "",
} file // specific config for machine 1
{
// eg: specify user info to use on this machine
"proxy_username": "proxyuser",
"proxy_password": "proxypassword",
} file // specific config for machine 2
{
// eg: no proxy needed for this machine
"http_proxy": "",
"https_proxy": "",
} With this kind of solution, you can override every setting you want for a particular machine. What do you think ? :) |
I like Sublime Package Control. At work I need to configure a proxy server. Anywhere else I don't. I use Sublime Package Control everywhere.
It would be nice to have a quick way to switch the proxy on and off.
A) Just a setting like 'use_proxy' which can be true or false. That would be okay.
B) Some way that would allow me to configure a keyboard shortcut. That would be great.
If I get time I'll try to do a pull request, unless someone beats me to it?
The text was updated successfully, but these errors were encountered: