Skip to content

Commit

Permalink
removed unused function, add listen_socket to CI package tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc committed Feb 28, 2024
1 parent 4ef5384 commit 0fe3ec1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
14 changes: 7 additions & 7 deletions pkg/apiclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,24 +175,24 @@ func RegisterClient(config *Config, client *http.Client) (*ApiClient, error) {

func createTransport(url *url.URL) (*http.Transport, *url.URL) {
urlString := url.String()

// TCP transport
if !strings.HasPrefix(urlString, "/") {
return nil, url
}

ToUnixSocketUrl(url)
// Unix transport
url.Path = "/"
url.Host = "unix"
url.Scheme = "http"

return &http.Transport{
DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
return net.Dial("unix", strings.TrimSuffix(urlString, "/"))
},
}, url
}

func ToUnixSocketUrl(url *url.URL) {
url.Path = "/"
url.Host = "unix"
url.Scheme = "http"
}

type Response struct {
Response *http.Response
//add our pagination stuff
Expand Down
9 changes: 0 additions & 9 deletions pkg/apiserver/middlewares/v1/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/rand"
"errors"
"fmt"
"net"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -178,14 +177,6 @@ func (j *JWT) authPlain(c *gin.Context) (*authInput, error) {
return &ret, nil
}

func isUnixSocket(c *gin.Context) bool {
if localAddr, ok := c.Request.Context().Value(http.LocalAddrContextKey).(net.Addr); ok {
return strings.HasPrefix(localAddr.Network(), "unix")
}

return false
}

func (j *JWT) Authenticator(c *gin.Context) (interface{}, error) {
var (
err error
Expand Down
1 change: 1 addition & 0 deletions test/lib/config/config-global
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ config_prepare() {
# remove trailing slash from CONFIG_DIR
# since it's assumed to be missing during the tests
yq e -i '
.api.server.listen_socket="/run/crowdsec.sock" |
.config_paths.config_dir |= sub("/$", "")
' "${CONFIG_DIR}/config.yaml"
}
Expand Down

0 comments on commit 0fe3ec1

Please sign in to comment.