Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix Ruby SDK
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander Olofsson
Matrix Ruby SDK
Commits
93cbab5a
Verified
Commit
93cbab5a
authored
6 years ago
by
Alexander Olofsson
Browse files
Options
Downloads
Patches
Plain Diff
api: Fix variable collision in discovery
parent
3cbe79c0
No related branches found
No related tags found
No related merge requests found
Pipeline
#2553
failed
6 years ago
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/matrix_sdk/api.rb
+12
-14
12 additions, 14 deletions
lib/matrix_sdk/api.rb
with
12 additions
and
14 deletions
lib/matrix_sdk/api.rb
+
12
−
14
View file @
93cbab5a
...
...
@@ -72,13 +72,13 @@ module MatrixSdk
def
self
.
new_for_domain
(
domain
,
target: :client
,
ssl:
true
,
**
params
)
domain
,
port
=
domain
.
split
(
':'
)
uri
=
URI
(
"http
#{
ssl
?
's'
:
''
}
://
#{
domain
}
"
)
target
=
nil
target
_uri
=
nil
if
!
port
.
empty?
target
=
URI
(
"https://
#{
domain
}
:
#{
port
}
"
)
target
_uri
=
URI
(
"https://
#{
domain
}
:
#{
port
}
"
)
elsif
target
==
:server
# Attempt SRV record discovery
target
=
begin
target
_uri
=
begin
require
'resolv'
resolver
=
Resolv
::
DNS
.
new
resolver
.
getresource
(
"_matrix._tcp.
#{
domain
}
"
)
...
...
@@ -86,7 +86,7 @@ module MatrixSdk
nil
end
if
target
.
nil?
if
target
_uri
.
nil?
well_known
=
begin
data
=
Net
::
HTTP
.
get
(
"https://
#{
domain
}
/.well-known/matrix/server"
)
JSON
.
parse
(
data
)
...
...
@@ -94,13 +94,11 @@ module MatrixSdk
nil
end
if
well_known
&&
well_known
.
key?
(
'm.server'
)
target
=
well_known
[
'm.server'
]
end
target_uri
=
well_known
[
'm.server'
]
if
well_known
&&
well_known
.
key?
(
'm.server'
)
else
target
=
URI
(
"https://
#{
target
.
target
}
:
#{
target
.
port
}
"
)
target
_uri
=
URI
(
"https://
#{
target
_uri
.
target
}
:
#{
target
.
port
}
"
)
end
elsif
%i[client identity]
.
include?
target
elsif
%i[client identity]
.
include?
target
_uri
# Attempt .well-known discovery
well_known
=
begin
data
=
Net
::
HTTP
.
get
(
"https://
#{
domain
}
/.well-known/matrix/client"
)
...
...
@@ -115,18 +113,18 @@ module MatrixSdk
if
well_known
.
key?
(
key
)
&&
well_known
[
key
].
key?
(
'base_url'
)
uri
=
well_known
[
key
][
'base_url'
]
target
=
uri
target
_uri
=
uri
end
end
end
# Fall back to direct domain connection
target
||=
URI
(
"https://
#{
domain
}
:8448"
)
target
_uri
||=
URI
(
"https://
#{
domain
}
:8448"
)
new
(
"https://
#{
domain
}
"
,
new
(
uri
,
params
.
merge
(
address:
target
.
host
,
port:
target
.
port
address:
target
_uri
.
host
,
port:
target
_uri
.
port
))
end
...
...
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