|
| 1 | +# get-windows-proxy |
| 2 | + |
| 3 | +> Node.js module that finds a user's system proxy settings from their Windows registry settings. |
| 4 | +
|
| 5 | +[![NPM][npm-icon] ][npm-url] |
| 6 | + |
| 7 | +[![Build status][ci-image] ][ci-url] |
| 8 | +[![semantic-release][semantic-image] ][semantic-url] |
| 9 | + |
| 10 | +## Install |
| 11 | + |
| 12 | +Requires [Node](https://nodejs.org/en/) version 6 or above. |
| 13 | + |
| 14 | +```sh |
| 15 | +npm install --save get-windows-proxy |
| 16 | +``` |
| 17 | + |
| 18 | +## Usage |
| 19 | + |
| 20 | +```js |
| 21 | +const getWindowsProxy = require('get-windows-proxy') |
| 22 | + |
| 23 | +const proxy = getWindowsProxy() |
| 24 | + |
| 25 | +if (typeof proxy !== undefined) { |
| 26 | + console.log('HTTP Proxy: ', proxy.httpProxy) |
| 27 | + console.log('Proxy exclusions: ', proxy.noProxy) |
| 28 | + |
| 29 | + // Sample output: |
| 30 | + // HTTP Proxy: http://192.168.122.1:1337 |
| 31 | + // Proxy exclusions: corporate-intranet.com,other-stuff.local,localhost,127.0.0.0/8,::1 |
| 32 | +} |
| 33 | +``` |
| 34 | + |
| 35 | +## How does it work? |
| 36 | + |
| 37 | +Windows generally stores proxy settings in the registry under |
| 38 | +`HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings`. |
| 39 | +This module uses [registry-js][registry-js] to read those values out. Then, if |
| 40 | +`ProxyEnable` is set to `1`, we know that the proxy is enabled. From there, we |
| 41 | +read the proxy server from `ProxyServer` and the proxy bypass list from |
| 42 | +`ProxyOverride`. Finally, these values are converted to values compatible with |
| 43 | +the `HTTP_PROXY` and `NO_PROXY` environment variables that most applications are |
| 44 | +compatible with, and returned to the user. |
| 45 | + |
| 46 | +### Small print |
| 47 | + |
| 48 | +Author: [Cypress.io](https://www.cypress.io) © 2019 |
| 49 | + |
| 50 | +License: MIT - do anything with the code, but don't blame me if it does not work. |
| 51 | + |
| 52 | +Support: if you find any problems with this module, email / tweet / |
| 53 | +[open issue](https://github.com/cypress-io/get-windows-proxy/issues) on Github |
| 54 | + |
| 55 | +## MIT License |
| 56 | + |
| 57 | +Copyright (c) 2019 Cypress.io |
| 58 | + |
| 59 | +Permission is hereby granted, free of charge, to any person |
| 60 | +obtaining a copy of this software and associated documentation |
| 61 | +files (the "Software"), to deal in the Software without |
| 62 | +restriction, including without limitation the rights to use, |
| 63 | +copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 64 | +copies of the Software, and to permit persons to whom the |
| 65 | +Software is furnished to do so, subject to the following |
| 66 | +conditions: |
| 67 | + |
| 68 | +The above copyright notice and this permission notice shall be |
| 69 | +included in all copies or substantial portions of the Software. |
| 70 | + |
| 71 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 72 | +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
| 73 | +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 74 | +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 75 | +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 76 | +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 77 | +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 78 | +OTHER DEALINGS IN THE SOFTWARE. |
| 79 | + |
| 80 | +[npm-icon]: https://nodei.co/npm/get-windows-proxy.svg?downloads=true |
| 81 | +[npm-url]: https://npmjs.org/package/get-windows-proxy |
| 82 | +[ci-image]: https://travis-ci.org/cypress-io/get-windows-proxy.svg?branch=master |
| 83 | +[ci-url]: https://travis-ci.org/cypress-io/get-windows-proxy |
| 84 | +[semantic-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg |
| 85 | +[semantic-url]: https://github.com/semantic-release/semantic-release |
| 86 | +[registry-js]: https://github.com/desktop/registry-js/ |
0 commit comments