Skip to content

Commit

Permalink
Merge pull request #268 from SputNikPlop/ipv4
Browse files Browse the repository at this point in the history
fix: force ipv4 connection
  • Loading branch information
Xemdo authored Sep 13, 2023
2 parents 98ddbfb + 1e7b72e commit 48df769
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/events/trigger/forward_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ package trigger

import (
"bytes"
"context"
"crypto/hmac"
"crypto/sha256"
"fmt"
"net"
"net/http"
"time"

Expand Down Expand Up @@ -78,6 +80,13 @@ func ForwardEvent(p ForwardParamters) (*http.Response, error) {
}
}

// Twitch only supports IPv4 currently, so we will force this TCP connection to only use IPv4
var dialer net.Dialer
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.DialContext = func (ctx context.Context, network, addr string) (net.Conn, error) {
return dialer.DialContext(ctx, "tcp4", addr)
}

if p.Secret != "" {
getSignatureHeader(req, p.ID, p.Secret, p.Transport, p.Timestamp, p.JSON)
}
Expand All @@ -87,6 +96,7 @@ func ForwardEvent(p ForwardParamters) (*http.Response, error) {
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
Transport: transport,
}
resp, err := client.Do(req)
if err != nil {
Expand Down

0 comments on commit 48df769

Please sign in to comment.