go-get-proxied

command module
v0.0.0-...-ea033ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0

README

go-get-proxied - Cross platform proxy configurations

Build Status Go Report Card

Go code (golang) package which facilitates the retrieval of system proxy configurations.

Installation
  • Install this package using go get github.com/bdwyertech/go-get-proxied
  • Or, simply import go get github.com/bdwyertech/go-get-proxied, and use dep ensure to include it in your package
Usage:
package main
import (
    "fmt"
    "github.com/bdwyertech/go-get-proxied/proxy"
)
func main() {
    p := proxy.NewProvider("").Get("https", "https://rapid7.com")
    if p != nil {
        fmt.Printf("Found proxy: %s\n", p)
    }
}
Command Line Usage:
> ./go-get-proxied -h
Usage of ./go-get-proxied:
  -c string
    	Optional. Path to configuration file.
  -j	Optional. If a proxy is found, write it as JSON instead of a URL.
  -l	Optional. If set, a list of proxy will be returned.
  -p string
    	Optional. The proxy protocol you wish to lookup. Default: https (default "https")
  -t string
    	Optional. Target URL which the proxy will be used for. Default: *
  -v	Optional. If set, log content will be sent to stderr.
> netsh winhttp set proxy testProxy:8999

Current WinHTTP proxy settings:

    Proxy Server(s) :  testProxy:8999
    Bypass List     :  (none)
> ./go-get-proxied
//testProxy:8999
> ./go-get-proxied -j
{
   "host": "testProxy",
   "password": null,
   "port": 8999,
   "protocol": "",
   "src": "WinHTTP:WinHttpDefault",
   "username": null
}
> echo '{"https":"http://testProxy:8999"}' > proxy.config
> ./go-get-proxied -c proxy.config
http://testProxy:8999
> ./go-get-proxied -c proxy.config -j
{
   "host": "testProxy",
   "password": null,
   "port": 8999,
   "protocol": "http",
   "src": "ConfigurationFile",
   "username": null
}
Configuration:

The priority of retrieval is the following.

  • Windows:
    • Configuration File
    • Environment Variable: HTTPS_PROXY, HTTP_PROXY, FTP_PROXY, or ALL_PROXY. NO_PROXY is respected.
    • Internet Options: Automatically detect settings (WPAD)
    • Internet Options: Use automatic configuration script (PAC)
    • Internet Options: Manual proxy server
    • WINHTTP: (netsh winhttp)
  • Linux:
    • Configuration File
    • Environment Variable: HTTPS_PROXY, HTTP_PROXY, FTP_PROXY, or ALL_PROXY. NO_PROXY is respected.
  • MacOS:
    • Configuration File
    • Environment Variable: HTTPS_PROXY, HTTP_PROXY, FTP_PROXY, or ALL_PROXY. NO_PROXY is respected.
    • Network Settings: scutil

Documentation

Overview

Copyright 2018, Rapid7, Inc. License: BSD-3-clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

Directories

Path Synopsis
Package proxy allows you to retrieve a system configured proxy for a given protocol and target URL.
Package proxy allows you to retrieve a system configured proxy for a given protocol and target URL.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL