-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat: Support enabling proxy when adding nodes #11525
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -709,7 +709,7 @@ | |
| if len(req.ProxyUser) != 0 { | ||
| proxyURL.User = url.UserPassword(req.ProxyUser, req.ProxyPasswd) | ||
| } | ||
| transport = http.Transport{Proxy: http.ProxyURL(proxyURL)} | ||
| transport = http.Transport{Proxy: http.ProxyURL(proxyURL), TLSClientConfig: &tls.Config{InsecureSkipVerify: true}} | ||
Check failureCode scanning / SonarCloud Server hostnames should be verified during SSL/TLS connections High
Enable server hostname verification on this SSL/TLS connection. See more on SonarQube Cloud
|
||
| case "socks5": | ||
| var auth *proxy.Auth | ||
| if len(req.ProxyUser) == 0 { | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| package ssh | ||
|
|
||
| import ( | ||
| "bufio" | ||
| "crypto/tls" | ||
| "encoding/base64" | ||
| "fmt" | ||
| "net" | ||
| "strings" | ||
| "time" | ||
|
|
||
| "github.com/1Panel-dev/1Panel/core/global" | ||
| ) | ||
|
|
||
| type HTTPProxyDialer struct { | ||
| Type string | ||
| URL string | ||
| User string | ||
| Password string | ||
| } | ||
|
|
||
| func HTTPDial(dialer HTTPProxyDialer, network, addr string) (net.Conn, error) { | ||
| var conn net.Conn | ||
| var err error | ||
|
|
||
| global.LOG.Debugf("Dialing HTTP proxy %s for %s", dialer.URL, addr) | ||
| dialer.URL = strings.TrimPrefix(dialer.URL, dialer.Type+"://") | ||
| if dialer.Type == "https" { | ||
| conn, err = tls.DialWithDialer( | ||
| &net.Dialer{Timeout: 30 * time.Second}, | ||
| network, | ||
| dialer.URL, | ||
| &tls.Config{InsecureSkipVerify: true}, | ||
Check failureCode scanning / SonarCloud Server certificates should be verified during SSL/TLS connections High
Enable server certificate validation on this SSL/TLS connection. See more on SonarQube Cloud
Check failureCode scanning / SonarCloud Server hostnames should be verified during SSL/TLS connections High
Enable server hostname verification on this SSL/TLS connection. See more on SonarQube Cloud
|
||
| ) | ||
| } else { | ||
| conn, err = net.DialTimeout(network, dialer.URL, 30*time.Second) | ||
| } | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| conn.SetDeadline(time.Now().Add(30 * time.Second)) | ||
| connectReq := fmt.Sprintf("CONNECT %s HTTP/1.1\r\n", addr) | ||
| connectReq += fmt.Sprintf("Host: %s\r\n", addr) | ||
| connectReq += "User-Agent: Go-ssh-client/1.0\r\n" | ||
|
|
||
| if dialer.User != "" { | ||
| auth := base64.StdEncoding.EncodeToString( | ||
| []byte(dialer.User + ":" + dialer.Password), | ||
| ) | ||
| connectReq += fmt.Sprintf("Proxy-Authorization: Basic %s\r\n", auth) | ||
| } | ||
| connectReq += "Connection: keep-alive\r\n\r\n" | ||
| if _, err := conn.Write([]byte(connectReq)); err != nil { | ||
| conn.Close() | ||
| return nil, err | ||
| } | ||
| reader := bufio.NewReader(conn) | ||
| response, err := reader.ReadString('\n') | ||
| if err != nil { | ||
| conn.Close() | ||
| return nil, err | ||
| } | ||
| if !strings.HasPrefix(response, "HTTP/1.1 200") && | ||
| !strings.HasPrefix(response, "HTTP/1.0 200") { | ||
| conn.Close() | ||
| return nil, fmt.Errorf("proxy connection failed: %s", strings.TrimSpace(response)) | ||
| } | ||
| for { | ||
| line, err := reader.ReadString('\n') | ||
| if err != nil { | ||
| conn.Close() | ||
| return nil, err | ||
| } | ||
| if line == "\r\n" || line == "\n" { | ||
| break | ||
| } | ||
| } | ||
| conn.SetDeadline(time.Time{}) | ||
|
|
||
| return conn, nil | ||
| } | ||
Check failure
Code scanning / SonarCloud
Server certificates should be verified during SSL/TLS connections High