academic / gURL

gURL is a cURL implementation with Go
MIT License
15 stars 3 forks source link

Proxy method #2

Open hmert opened 3 years ago

hmert commented 3 years ago
-x, --proxy [protocol://]host[:port] Use this proxy
     --proxy-anyauth Pick any proxy authentication method
     --proxy-basic   Use Basic authentication on the proxy
     --proxy-cacert <file> CA certificate to verify peer against for proxy
     --proxy-capath <dir> CA directory to verify peer against for proxy
     --proxy-cert <cert[:passwd]> Set client certificate for proxy
     --proxy-cert-type <type> Client certificate type for HTTPS proxy
     --proxy-ciphers <list> SSL ciphers to use for proxy
     --proxy-crlfile <file> Set a CRL list for proxy
     --proxy-digest  Use Digest authentication on the proxy
     --proxy-header <header/@file> Pass custom header(s) to proxy
     --proxy-insecure Do HTTPS proxy connections without verifying the proxy
     --proxy-key <key> Private key for HTTPS proxy
     --proxy-key-type <type> Private key file type for proxy
     --proxy-negotiate Use HTTP Negotiate (SPNEGO) authentication on the proxy
     --proxy-ntlm    Use NTLM authentication on the proxy
     --proxy-pass <phrase> Pass phrase for the private key for HTTPS proxy
     --proxy-pinnedpubkey <hashes> FILE/HASHES public key to verify proxy with
     --proxy-service-name <name> SPNEGO proxy service name
     --proxy-ssl-allow-beast Allow security flaw for interop for HTTPS proxy
     --proxy-tls13-ciphers <ciphersuite list> TLS 1.3 proxy cipher suites
     --proxy-tlsauthtype <type> TLS authentication type for HTTPS proxy
     --proxy-tlspassword <string> TLS password for HTTPS proxy
     --proxy-tlsuser <name> TLS username for HTTPS proxy
     --proxy-tlsv1   Use TLSv1 for HTTPS proxy
 -U, --proxy-user <user:password> Proxy user and password
     --proxy1.0 <host[:port]> Use HTTP/1.0 proxy on given port
 -p, --proxytunnel   Operate through an HTTP proxy tunnel (using CONNECT)
gozeloglu commented 3 years ago

Hi @hmert. I have an idea for implementing proxy commands to more clear. I wanted to get approval from you. proxy.go file is starting to be more complicated and messy for future commands. I was writing code for --proxy-digest flag and I had to modify proxyUserCmd by adding a new parameter. But, adding a new parameter affects to proxy_test.go file and proxyUserCredentials, err := proxyUserCmd(proxyUser) line. I think this problem will grow and be a problem. Maybe, refactoring will be necessary for each flag. That's why I think we can define a struct as follows:

type GurlProxy struct {
    proxyURL  string
    proxyUser string
    username  string
    password  string
    basic     bool
    digest    bool
    ntlm      bool
    negotiate bool
}

This struct may grow in the future, but I think, in this way, we suffer less pain. I am going to store necessary information as a struct and I'll convert functions to methods like func (g *GurlProxy) proxyCmd() (string, error). What do you think about that?