From 0933476ff61089bd5d846ebc48c4c9160302e802 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Fri, 13 Dec 2024 12:02:44 +0700 Subject: 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. --- client.go | 5 +++++ go.mod | 2 +- go.sum | 4 ++-- 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= -- cgit v1.3