Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
comms
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xx network
comms
Commits
103f84ce
Commit
103f84ce
authored
2 years ago
by
Jonah Husson
Browse files
Options
Downloads
Patches
Plain Diff
Use https for isonline
parent
11f1f406
No related branches found
No related tags found
2 merge requests
!61
Hotfix/fix is online
,
!39
Merge release into master
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
connect/webConn.go
+9
-3
9 additions, 3 deletions
connect/webConn.go
connect/webConn_test.go
+6
-0
6 additions, 0 deletions
connect/webConn_test.go
with
15 additions
and
3 deletions
connect/webConn.go
+
9
−
3
View file @
103f84ce
...
@@ -189,6 +189,12 @@ func (wc *webConn) isAlive() bool {
...
@@ -189,6 +189,12 @@ func (wc *webConn) isAlive() bool {
// IsOnline sends an empty http get request to verify the status of the server
// IsOnline sends an empty http get request to verify the status of the server
func
(
wc
*
webConn
)
IsOnline
()
(
time
.
Duration
,
bool
)
{
func
(
wc
*
webConn
)
IsOnline
()
(
time
.
Duration
,
bool
)
{
addr
:=
wc
.
h
.
GetAddress
()
addr
:=
wc
.
h
.
GetAddress
()
pingTimeout
:=
wc
.
h
.
params
.
PingTimeout
return
isOnlineHelper
(
addr
,
pingTimeout
)
}
func
isOnlineHelper
(
addr
string
,
pingTimeout
time
.
Duration
)
(
time
.
Duration
,
bool
)
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
tr
:=
&
http
.
Transport
{
tr
:=
&
http
.
Transport
{
TLSClientConfig
:
&
tls
.
Config
{
TLSClientConfig
:
&
tls
.
Config
{
...
@@ -197,9 +203,9 @@ func (wc *webConn) IsOnline() (time.Duration, bool) {
...
@@ -197,9 +203,9 @@ func (wc *webConn) IsOnline() (time.Duration, bool) {
}
}
client
:=
http
.
Client
{
client
:=
http
.
Client
{
Transport
:
tr
,
Transport
:
tr
,
Timeout
:
wc
.
h
.
params
.
P
ingTimeout
,
Timeout
:
p
ingTimeout
,
}
}
target
:=
"http://"
+
addr
target
:=
"http
s
://"
+
addr
req
,
err
:=
http
.
NewRequest
(
"GET"
,
target
,
nil
)
req
,
err
:=
http
.
NewRequest
(
"GET"
,
target
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
jww
.
WARN
.
Printf
(
"Failed to initiate request: %+v"
,
err
)
jww
.
WARN
.
Printf
(
"Failed to initiate request: %+v"
,
err
)
...
@@ -219,7 +225,7 @@ func (wc *webConn) IsOnline() (time.Duration, bool) {
...
@@ -219,7 +225,7 @@ func (wc *webConn) IsOnline() (time.Duration, bool) {
}
}
// IMPORTANT - enables better HTTP(S) discovery, because many browsers block CORS by default.
// IMPORTANT - enables better HTTP(S) discovery, because many browsers block CORS by default.
req
.
Header
.
Add
(
"js.fetch:mode"
,
"no-cors"
)
//
req.Header.Add("js.fetch:mode", "no-cors")
jww
.
TRACE
.
Printf
(
"(GO request): %+v"
,
req
)
jww
.
TRACE
.
Printf
(
"(GO request): %+v"
,
req
)
req
=
req
.
WithContext
(
httptrace
.
WithClientTrace
(
req
.
Context
(),
trace
))
req
=
req
.
WithContext
(
httptrace
.
WithClientTrace
(
req
.
Context
(),
trace
))
...
...
This diff is collapsed.
Click to expand it.
connect/webConn_test.go
+
6
−
0
View file @
103f84ce
...
@@ -142,3 +142,9 @@ func Test_checkErrorExceptions(t *testing.T) {
...
@@ -142,3 +142,9 @@ func Test_checkErrorExceptions(t *testing.T) {
}
}
}
}
}
}
//func Test_isOnline_actual(t *testing.T) {
// targetAddr := "a98c39d9f9a3b08ddc63d979f69e71c03e76e75353878e3d4b3c2e.xxnode.io:22840"
// _, ok := isOnlineHelper(targetAddr, time.Second*10)
// t.Fatal(ok)
//}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment