Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
mycard
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
syntax_j
mycard
Commits
de17066c
Commit
de17066c
authored
Dec 27, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dns resolve
parent
3072acbf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
lib/ygocore/game.rb
lib/ygocore/game.rb
+15
-4
No files found.
lib/ygocore/game.rb
View file @
de17066c
...
...
@@ -32,9 +32,9 @@ class Ygocore < Game
matched
=
@username
.
match
Jabber
::
JID
::
PATTERN
if
matched
[
1
]
&&
matched
[
2
]
@username
=
matched
[
1
]
jid
=
Jabber
::
JID
::
new
@username
,
matched
[
2
],
matched
[
3
]
||
'mycard'
jid
=
Jabber
::
JID
::
new
matched
[
1
]
,
matched
[
2
],
matched
[
3
]
||
'mycard'
else
jid
=
Jabber
::
JID
::
new
@username
,
'my-card.in'
,
'mycard'
jid
=
Jabber
::
JID
::
new
@username
.
dup
,
'my-card.in'
,
'mycard'
end
@@im
=
Jabber
::
Client
.
new
(
jid
)
...
...
@@ -116,7 +116,10 @@ class Ygocore < Game
@@im
.
allow_tls
=
false
@@im
.
use_ssl
=
true
#由于XMPP4r在windows
if
@@im
.
jid
.
domain
==
'my-card.in'
@@im
.
connect
(
record
.
target
.
to_s
,
5223
)
else
#由于XMPP4r在windows下TLS有问题...
srv
=
[]
Resolv
::
DNS
.
open
{
|
dns
|
# If ruby version is too old and SRV is unknown, this will raise a NameError
...
...
@@ -124,12 +127,17 @@ class Ygocore < Game
Jabber
::
debuglog
(
"RESOLVING:
\n
_xmpp-client._tcp.
#{
@@im
.
jid
.
domain
}
(SRV)"
)
srv
=
dns
.
getresources
(
"_xmpp-client._tcp.
#{
@@im
.
jid
.
domain
}
"
,
Resolv
::
DNS
::
Resource
::
IN
::
SRV
)
}
if
srv
.
empty?
Game_Event
.
push
Game_Event
::
Error
.
new
(
'登录'
,
'解析服务器地址失败'
)
Thread
.
exit
end
# Sort SRV records: lowest priority first, highest weight first
srv
.
sort!
{
|
a
,
b
|
(
a
.
priority
!=
b
.
priority
)
?
(
a
.
priority
<=>
b
.
priority
)
:
(
b
.
weight
<=>
a
.
weight
)
}
srv
.
each
{
|
record
|
begin
@@im
.
connect
(
record
.
target
.
to_s
,
5223
)
@@im
.
connect
# Success
break
rescue
SocketError
,
Errno
::
ECONNREFUSED
...
...
@@ -137,6 +145,8 @@ class Ygocore < Game
end
}
end
begin
@@im
.
auth
(
@password
)
rescue
Jabber
::
ClientAuthenticationFailure
...
...
@@ -219,6 +229,7 @@ class Ygocore < Game
end
def
exit
@@im
.
close
rescue
nil
@recv
.
exit
if
@recv
@recv
=
nil
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment