aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2024-12-13 12:02:44 +0700
committerShulhan <ms@kilabit.info>2025-01-02 03:14:16 +0700
commit0933476ff61089bd5d846ebc48c4c9160302e802 (patch)
tree2b72cb2fe43fabd58593ad70980f706298f5f54d
parent9a5e753864629aedcb5d91b66459e3773c7f835a (diff)
downloadkbbi-0933476ff61089bd5d846ebc48c4c9160302e802.tar.xz
client: fix connection being blocked by CloudFlare
I think the admin of kbbi set the HTTPS mode minimal to version 1.3, which cause Go (that use TLS v1.2 by default, but have 1.3 as maximum) being rejected during handshake.
-rw-r--r--client.go5
-rw-r--r--go.mod2
-rw-r--r--go.sum4
3 files changed, 8 insertions, 3 deletions
diff --git a/client.go b/client.go
index a54f179..091ea87 100644
--- a/client.go
+++ b/client.go
@@ -5,6 +5,7 @@ package kbbi
import (
"bytes"
+ "crypto/tls"
"encoding/gob"
"errors"
"fmt"
@@ -99,6 +100,10 @@ func NewClient() (cl *Client, err error) {
}
cl.httpc.Jar = jar
+ var transport *http.Transport = cl.httpc.Transport()
+
+ // This fix connection being blocked by CloudFlare.
+ transport.TLSClientConfig.MinVersion = tls.VersionTLS13
err = cl.loadCookies()
if err != nil {
diff --git a/go.mod b/go.mod
index 2280035..a25aff5 100644
--- a/go.mod
+++ b/go.mod
@@ -6,7 +6,7 @@ module git.sr.ht/~shulhan/kbbi
go 1.23.3
require (
- git.sr.ht/~shulhan/pakakeh.go v0.58.1
+ git.sr.ht/~shulhan/pakakeh.go v0.58.2-0.20241212161141-3361472cc3d4
golang.org/x/net v0.32.0
)
diff --git a/go.sum b/go.sum
index f5f58dc..7d4daac 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,5 @@
-git.sr.ht/~shulhan/pakakeh.go v0.58.1 h1:KBb/6rT/IjBOP1MqjI6uKVw/miTjTuwR27e8oWzz3es=
-git.sr.ht/~shulhan/pakakeh.go v0.58.1/go.mod h1:QOiVaVWOilYaB+OlQtQfZo9uSvSVSVP1r8s2zve6imY=
+git.sr.ht/~shulhan/pakakeh.go v0.58.2-0.20241212161141-3361472cc3d4 h1:GJuzSB1DntXGLZzhGhwMIuI66wsBIYXF5kfEvDh0qiQ=
+git.sr.ht/~shulhan/pakakeh.go v0.58.2-0.20241212161141-3361472cc3d4/go.mod h1:andCp7SiIOiomrITys+AuhviJn/o2ASLQNrQjTlRkS4=
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=