mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-17 14:00:01 +02:00
Fix internal requests when gitea listens to unix socket or only external IP (#2234)
* Fix internal requests when gitea listens to unix socket or only external IP * When Gitea is set to listen using FastCGI use AppURL for LocalURL
This commit is contained in:
parent
a4ca54425f
commit
fa8d40faca
4 changed files with 34 additions and 12 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/modules/httplib"
|
||||
|
@ -34,15 +35,27 @@ func decodeJSONError(resp *http.Response) *Response {
|
|||
return &res
|
||||
}
|
||||
|
||||
func newInternalRequest(url, method string) *httplib.Request {
|
||||
req := newRequest(url, method).SetTLSClientConfig(&tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
if setting.Protocol == setting.UnixSocket {
|
||||
req.SetTransport(&http.Transport{
|
||||
Dial: func(_, _ string) (net.Conn, error) {
|
||||
return net.Dial("unix", setting.HTTPAddr)
|
||||
},
|
||||
})
|
||||
}
|
||||
return req
|
||||
}
|
||||
|
||||
// UpdatePublicKeyUpdated update publick key updates
|
||||
func UpdatePublicKeyUpdated(keyID int64) error {
|
||||
// Ask for running deliver hook and test pull request tasks.
|
||||
reqURL := setting.LocalURL + fmt.Sprintf("api/internal/ssh/%d/update", keyID)
|
||||
log.GitLogger.Trace("UpdatePublicKeyUpdated: %s", reqURL)
|
||||
|
||||
resp, err := newRequest(reqURL, "POST").SetTLSClientConfig(&tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
}).Response()
|
||||
resp, err := newInternalRequest(reqURL, "POST").Response()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue