kgretzky/evilginx2 · error

invalid proxy type selected

Error message

invalid proxy type selected

What it means

setProxy validates the upstream proxy type against the allowlist {http, https, socks5, socks5h}. If the configured ptype is not in that list, configuration is rejected with this error before any proxy URL is built. It prevents constructing a malformed proxy URL scheme.

Source

Thrown at core/http_proxy.go:1914

}

func (p *HttpProxy) getSessionIdByIP(ip_addr string, hostname string) (string, bool) {
	p.ip_mtx.Lock()
	defer p.ip_mtx.Unlock()

	pl := p.getPhishletByPhishHost(hostname)
	if pl != nil {
		sid, ok := p.ip_sids[ip_addr+"-"+pl.Name]
		return sid, ok
	}
	return "", false
}

func (p *HttpProxy) setProxy(enabled bool, ptype string, address string, port int, username string, password string) error {
	if enabled {
		ptypes := []string{"http", "https", "socks5", "socks5h"}
		if !stringExists(ptype, ptypes) {
			return fmt.Errorf("invalid proxy type selected")
		}
		if len(address) == 0 {
			return fmt.Errorf("proxy address can't be empty")
		}
		if port == 0 {
			return fmt.Errorf("proxy port can't be 0")
		}

		u := url.URL{
			Scheme: ptype,
			Host:   address + ":" + strconv.Itoa(port),
		}

		if strings.HasPrefix(ptype, "http") {
			var dproxy *http_dialer.HttpTunnel
			if username != "" {
				dproxy = http_dialer.New(&u, http_dialer.WithProxyAuth(http_dialer.AuthBasic(username, password)))
			} else {

View on GitHub (pinned to 4c0988a1d9)

Solutions

  1. Set the proxy type to one of exactly: http, https, socks5, socks5h (all lowercase)
  2. If your upstream is SOCKS4, switch to a SOCKS5-capable proxy or use http
  3. Check for typos and case sensitivity in the type argument
  4. If a config file supplies the type, normalize it to lowercase before use

Example fix

// before
proxy socks4 127.0.0.1 9050
// after
proxy socks5 127.0.0.1 9050
Defensive patterns

Strategy: validation

Validate before calling

ptypes := []string{"http", "https", "socks5", "socks5h"}
if !stringExists(ptype, ptypes) {
    return fmt.Errorf("proxy type must be one of %v", ptypes)
}

Type guard

func validProxyType(t string) bool {
    switch t {
    case "http", "https", "socks5", "socks5h":
        return true
    }
    return false
}

Try / catch

if err := proxy.setProxy(true, ptype, addr, port, user, pass); err != nil {
    if strings.Contains(err.Error(), "invalid proxy type") {
        return fmt.Errorf("use http, https, socks5 or socks5h; got %q", ptype)
    }
}

Prevention

When it happens

Trigger: Calling setProxy(true, ptype, ...) (via the `proxy` console command) with a type string outside the allowlist — e.g. 'socks4', 'SOCKS5' (uppercase), 'ssl', or a typo like 'sock5'.

Common situations: Users configuring an upstream proxy with socks4 (unsupported), using uppercase type names, or mistyping 'socks5h' as 'socks5-h'/'sh'.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of kgretzky/evilginx2@4c0988a1d9 (2026-09-05). Data as JSON: /api/errors/1cbe3f1cc29f7009. Report an issue: GitHub.