Skip to content

Webhooks Do Not Use Proxy Settings #8092

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

Closed
2 of 7 tasks
cdoantsys opened this issue Sep 4, 2019 · 4 comments · Fixed by #8116
Closed
2 of 7 tasks

Webhooks Do Not Use Proxy Settings #8092

cdoantsys opened this issue Sep 4, 2019 · 4 comments · Fixed by #8116
Labels
type/enhancement An improvement of existing functionality
Milestone

Comments

@cdoantsys
Copy link

  • Gitea version (or commit ref): 1.9.2
  • Git version: 2.23.0
  • Operating system: linux/amd64
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

In my environment Gitea does not have direct internet access, a proxy is required. I have been able to successfully mirror repositories and use the proxy to download other items. However, I am not able to post webhooks via Microsoft Teams. After further investigations it appears that the http client that is created in the InitDeliverHooks function in webhook.go does utilize any proxy settings.

Proposed Resolution

Current Implimentation

// InitDeliverHooks starts the hooks delivery thread
func InitDeliverHooks() {
	timeout := time.Duration(setting.Webhook.DeliverTimeout) * time.Second

	webhookHTTPClient = &http.Client{
		Transport: &http.Transport{
			TLSClientConfig: &tls.Config{InsecureSkipVerify: setting.Webhook.SkipTLSVerify},
			Dial: func(netw, addr string) (net.Conn, error) {
				conn, err := net.DialTimeout(netw, addr, timeout)
				if err != nil {
					return nil, err
				}

				return conn, conn.SetDeadline(time.Now().Add(timeout))

			},
		},
	}

	go DeliverHooks()
}

Proposed Implementation

// InitDeliverHooks starts the hooks delivery thread
func InitDeliverHooks() {
	timeout := time.Duration(setting.Webhook.DeliverTimeout) * time.Second

	webhookHTTPClient = &http.Client{
		Transport: &http.Transport{
			TLSClientConfig: &tls.Config{InsecureSkipVerify: setting.Webhook.SkipTLSVerify},
			Proxy: http.ProxyFromEnvironment,
			Dial: func(netw, addr string) (net.Conn, error) {
				conn, err := net.DialTimeout(netw, addr, timeout)
				if err != nil {
					return nil, err
				}

				return conn, conn.SetDeadline(time.Now().Add(timeout))

			},
		},
	}

	go DeliverHooks()
}

I have implemented this in my environment and it is currently working.

@lunny lunny added the type/enhancement An improvement of existing functionality label Sep 5, 2019
@lunny
Copy link
Member

lunny commented Sep 5, 2019

@cdoantsys could you send a PR?

@wpmp
Copy link

wpmp commented Oct 8, 2019

Will this issue also be resolved in 1.9.4 or 1.10.0 only?

@lunny
Copy link
Member

lunny commented Oct 9, 2019

It will be on 1.10.0 only

@wpmp
Copy link

wpmp commented Oct 9, 2019

Too bad, thanks.
Hope 1.10.0 will come out soon :)

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants