Commit adeefc6b75
Verified · cmc
Layout: unified · split
internal/push/apns.go +10 −1
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | "encoding/json" | 7 | "encoding/json" |
| 8 | "fmt" | 8 | "fmt" |
| 9 | "io" | 9 | "io" |
| 10 | "log/slog" | ||
| 10 | "net/http" | 11 | "net/http" |
| 11 | "os" | 12 | "os" |
| 12 | "strconv" | 13 | "strconv" |
| @@ -65,8 +66,16 @@ func NewClient(cfg config.Push) (*Client, error) { | |||
| 65 | // speaks plain HTTP/1.1 rather than negotiating TLS, so the same override | 66 | // speaks plain HTTP/1.1 rather than negotiating TLS, so the same override |
| 66 | // has to drop the scheme too, or every request fails with "server gave | 67 | // has to drop the scheme too, or every request fails with "server gave |
| 67 | // HTTP response to HTTPS client" instead of reaching the fake at all. | 68 | // HTTP response to HTTPS client" instead of reaching the fake at all. |
| 69 | // | ||
| 70 | // The drop is logged rather than silent. config.Push's own doc comment | ||
| 71 | // promises a misconfigured [push] fails loudly at startup rather than | ||
| 72 | // filling a queue nobody is watching; a stray GITBAY_APNS_HOST on a real | ||
| 73 | // instance would otherwise send the provider JWT over cleartext with no | ||
| 74 | // sign anything had changed, where the pre-override behaviour at least | ||
| 75 | // failed loudly by attempting TLS against a host that cannot answer it. | ||
| 68 | func apnsScheme() string { | 76 | func apnsScheme() string { |
| 69 | if os.Getenv("GITBAY_APNS_HOST") != "" { | 77 | if h := os.Getenv("GITBAY_APNS_HOST"); h != "" { |
| 78 | slog.Warn("push: GITBAY_APNS_HOST is set, sending to it over plain HTTP instead of APNs", "host", h) | ||
| 70 | return "http" | 79 | return "http" |
| 71 | } | 80 | } |
| 72 | return "https" | 81 | return "https" |