mirror of
https://github.com/minio/minio.git
synced 2025-01-23 12:43:16 -05:00
fix: webhook notify endpoint with standard ports (#18016)
This commit is contained in:
parent
dc48cd841a
commit
419e5baf16
@ -104,6 +104,8 @@ type WebhookTarget struct {
|
||||
loggerOnce logger.LogOnce
|
||||
cancel context.CancelFunc
|
||||
cancelCh <-chan struct{}
|
||||
|
||||
addr string // full address ip/dns with a port number, e.g. x.x.x.x:8080
|
||||
}
|
||||
|
||||
// ID - returns target ID.
|
||||
@ -130,7 +132,7 @@ func (target *WebhookTarget) Store() event.TargetStore {
|
||||
}
|
||||
|
||||
func (target *WebhookTarget) isActive() (bool, error) {
|
||||
conn, err := net.DialTimeout("tcp", target.args.Endpoint.Host, 5*time.Second)
|
||||
conn, err := net.DialTimeout("tcp", target.addr, 5*time.Second)
|
||||
if err != nil {
|
||||
if xnet.IsNetworkOrHostDown(err, false) {
|
||||
return false, store.ErrNotConnected
|
||||
@ -291,6 +293,19 @@ func NewWebhookTarget(ctx context.Context, id string, args WebhookArgs, loggerOn
|
||||
cancelCh: ctx.Done(),
|
||||
}
|
||||
|
||||
// Calculate the webhook addr with the port number format
|
||||
target.addr = args.Endpoint.Host
|
||||
if _, _, err := net.SplitHostPort(args.Endpoint.Host); err != nil && strings.Contains(err.Error(), "missing port in address") {
|
||||
switch strings.ToLower(args.Endpoint.Scheme) {
|
||||
case "http":
|
||||
target.addr += ":80"
|
||||
case "https":
|
||||
target.addr += ":443"
|
||||
default:
|
||||
return nil, errors.New("unsupported scheme")
|
||||
}
|
||||
}
|
||||
|
||||
if target.store != nil {
|
||||
store.StreamItems(target.store, target, target.cancelCh, target.loggerOnce)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user