Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
srvpro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
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
MyCard
srvpro
Commits
0d34825e
Commit
0d34825e
authored
Feb 19, 2018
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add support for remote windbot
parent
3a7e6938
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
17 deletions
+21
-17
data/default_config.json
data/default_config.json
+3
-1
ygopro-server.coffee
ygopro-server.coffee
+10
-9
ygopro-server.js
ygopro-server.js
+8
-7
No files found.
data/default_config.json
View file @
0d34825e
...
...
@@ -53,7 +53,9 @@
"enabled"
:
false
,
"botlist"
:
"./windbot/bots.json"
,
"spawn"
:
false
,
"port"
:
2399
"port"
:
2399
,
"server_ip"
:
"127.0.0.1"
,
"my_ip"
:
"127.0.0.1"
},
"mycard"
:
{
"enabled"
:
false
,
...
...
ygopro-server.coffee
View file @
0d34825e
...
...
@@ -627,7 +627,7 @@ class Room
add_windbot
:
(
botdata
)
->
@
windbot
=
botdata
request
url
:
"http://
127.0.0.1:
#{
settings
.
modules
.
windbot
.
port
}
/?name=
#{
encodeURIComponent
(
botdata
.
name
)
}
&deck=
#{
encodeURIComponent
(
botdata
.
deck
)
}
&host=127.0.0.1
&port=
#{
settings
.
port
}
&dialog=
#{
encodeURIComponent
(
botdata
.
dialog
)
}
&version=
#{
settings
.
version
}
&password=
#{
encodeURIComponent
(
@
name
)
}
"
url
:
"http://
#{
settings
.
modules
.
windbot
.
server_ip
}
:
#{
settings
.
modules
.
windbot
.
port
}
/?name=
#{
encodeURIComponent
(
botdata
.
name
)
}
&deck=
#{
encodeURIComponent
(
botdata
.
deck
)
}
&host=
#{
settings
.
modules
.
windbot
.
my_ip
}
&port=
#{
settings
.
port
}
&dialog=
#{
encodeURIComponent
(
botdata
.
dialog
)
}
&version=
#{
settings
.
version
}
&password=
#{
encodeURIComponent
(
@
name
)
}
"
,
(
error
,
response
,
body
)
=>
if
error
log
.
warn
'windbot add error'
,
error
,
this
.
name
...
...
@@ -692,8 +692,10 @@ class Room
# 网络连接
net
.
createServer
(
client
)
->
client
.
ip
=
client
.
remoteAddress
client
.
is_local
=
client
.
ip
.
includes
(
'127.0.0.1'
)
or
client
.
ip
.
includes
(
settings
.
modules
.
windbot
.
server_ip
)
connect_count
=
ROOM_connected_ip
[
client
.
ip
]
or
0
if
!
settings
.
modules
.
test_mode
.
no_connect_count_limit
and
client
.
ip
!=
'::ffff:127.0.0.1'
if
!
settings
.
modules
.
test_mode
.
no_connect_count_limit
and
!
client
.
is_local
connect_count
++
ROOM_connected_ip
[
client
.
ip
]
=
connect_count
#log.info "connect", client.ip, ROOM_connected_ip[client.ip]
...
...
@@ -783,7 +785,7 @@ net.createServer (client) ->
return
return
return
# 需要重构
# 客户端到服务端(ctos)协议分析
...
...
@@ -945,7 +947,7 @@ ygopro.ctos_follow 'PLAYER_INFO', true, (buffer, info, client, server)->
buffer
=
struct
.
buffer
client
.
name
=
name
if
not
settings
.
modules
.
i18n
.
auto_pick
or
client
.
i
p
==
"::ffff:127.0.0.1"
if
not
settings
.
modules
.
i18n
.
auto_pick
or
client
.
i
s_local
client
.
lang
=
settings
.
modules
.
i18n
.
default
else
geo
=
geoip
.
lookup
(
client
.
ip
)
...
...
@@ -1242,7 +1244,7 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
ygopro
.
stoc_send_chat
(
client
,
settings
.
modules
.
welcome
,
ygopro
.
constants
.
COLORS
.
GREEN
)
if
room
.
welcome
ygopro
.
stoc_send_chat
(
client
,
room
.
welcome
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
if
settings
.
modules
.
arena_mode
.
enabled
and
client
.
ip
!=
'::ffff:127.0.0.1'
#and not client.score_shown
if
settings
.
modules
.
arena_mode
.
enabled
and
!
client
.
is_local
#and not client.score_shown
request
url
:
settings
.
modules
.
arena_mode
.
get_score
+
encodeURIComponent
(
client
.
name
),
json
:
true
...
...
@@ -1426,7 +1428,7 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
ygopro
.
ctos_follow
'HS_TOOBSERVER'
,
true
,
(
buffer
,
info
,
client
,
server
)
->
room
=
ROOM_all
[
client
.
rid
]
return
unless
room
if
not
room
.
arena
or
client
.
i
p
==
"::ffff:127.0.0.1"
if
not
room
.
arena
or
client
.
i
s_local
return
false
for
player
in
room
.
players
if
player
==
client
...
...
@@ -1623,7 +1625,6 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)->
client
.
deck_saved
=
true
return
ygopro
.
ctos_follow
'SURRENDER'
,
true
,
(
buffer
,
info
,
client
,
server
)
->
room
=
ROOM_all
[
client
.
rid
]
return
unless
room
...
...
@@ -1903,7 +1904,7 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)->
cloud_replay_id
:
"R#"
+
room
.
cloud_replay_id
,
replay_filename
:
replay_filename
,
players
:
(
for
player
in
room
.
dueling_players
name
:
player
.
name
+
(
if
settings
.
modules
.
tournament_mode
.
show_ip
and
player
.
ip
!=
'::ffff:127.0.0.1'
then
(
" (IP: "
+
player
.
ip
.
slice
(
7
)
+
")"
)
else
""
)
+
(
if
settings
.
modules
.
tournament_mode
.
show_info
and
not
(
room
.
hostinfo
.
mode
==
2
and
player
.
pos
>
1
)
then
(
" (Score:"
+
room
.
scores
[
player
.
name
]
+
" LP:"
+
(
if
player
.
lp
?
then
player
.
lp
else
room
.
hostinfo
.
start_lp
)
+
")"
)
else
""
),
name
:
player
.
name
+
(
if
settings
.
modules
.
tournament_mode
.
show_ip
and
!
player
.
is_local
then
(
" (IP: "
+
player
.
ip
.
slice
(
7
)
+
")"
)
else
""
)
+
(
if
settings
.
modules
.
tournament_mode
.
show_info
and
not
(
room
.
hostinfo
.
mode
==
2
and
player
.
pos
>
1
)
then
(
" (Score:"
+
room
.
scores
[
player
.
name
]
+
" LP:"
+
(
if
player
.
lp
?
then
player
.
lp
else
room
.
hostinfo
.
start_lp
)
+
")"
)
else
""
),
winner
:
player
.
pos
==
room
.
winner
)
}
...
...
@@ -2001,7 +2002,7 @@ if settings.modules.http
needpass
:
(
room
.
name
.
indexOf
(
'$'
)
!=
-
1
).
toString
(),
users
:
(
for
player
in
room
.
players
when
player
.
pos
?
id
:
(
-
1
).
toString
(),
name
:
player
.
name
+
(
if
settings
.
modules
.
http
.
show_ip
and
pass_validated
and
player
.
ip
!=
'::ffff:127.0.0.1'
then
(
" (IP: "
+
player
.
ip
.
slice
(
7
)
+
")"
)
else
""
)
+
(
if
settings
.
modules
.
http
.
show_info
and
room
.
started
and
not
(
room
.
hostinfo
.
mode
==
2
and
player
.
pos
>
1
)
then
(
" (Score:"
+
room
.
scores
[
player
.
name
]
+
" LP:"
+
(
if
player
.
lp
?
then
player
.
lp
else
room
.
hostinfo
.
start_lp
)
+
")"
)
else
""
),
name
:
player
.
name
+
(
if
settings
.
modules
.
http
.
show_ip
and
pass_validated
and
!
player
.
is_local
then
(
" (IP: "
+
player
.
ip
.
slice
(
7
)
+
")"
)
else
""
)
+
(
if
settings
.
modules
.
http
.
show_info
and
room
.
started
and
not
(
room
.
hostinfo
.
mode
==
2
and
player
.
pos
>
1
)
then
(
" (Score:"
+
room
.
scores
[
player
.
name
]
+
" LP:"
+
(
if
player
.
lp
?
then
player
.
lp
else
room
.
hostinfo
.
start_lp
)
+
")"
)
else
""
),
pos
:
player
.
pos
),
istart
:
if
room
.
started
then
(
if
settings
.
modules
.
http
.
show_info
then
(
"Duel:"
+
room
.
duel_count
+
" "
+
(
if
room
.
changing_side
then
"Siding"
else
"Turn:"
+
(
if
room
.
turn
?
then
room
.
turn
else
0
)
+
(
if
room
.
death
then
"/"
+
(
if
room
.
death
>
0
then
room
.
death
-
1
else
"Death"
)
else
""
)))
else
'start'
)
else
'wait'
...
...
ygopro-server.js
View file @
0d34825e
...
...
@@ -840,7 +840,7 @@
Room
.
prototype
.
add_windbot
=
function
(
botdata
)
{
this
.
windbot
=
botdata
;
request
({
url
:
"
http://
127.0.0.1:
"
+
settings
.
modules
.
windbot
.
port
+
"
/?name=
"
+
(
encodeURIComponent
(
botdata
.
name
))
+
"
&deck=
"
+
(
encodeURIComponent
(
botdata
.
deck
))
+
"
&host=127.0.0.1
&port=
"
+
settings
.
port
+
"
&dialog=
"
+
(
encodeURIComponent
(
botdata
.
dialog
))
+
"
&version=
"
+
settings
.
version
+
"
&password=
"
+
(
encodeURIComponent
(
this
.
name
))
url
:
"
http://
"
+
settings
.
modules
.
windbot
.
server_ip
+
"
:
"
+
settings
.
modules
.
windbot
.
port
+
"
/?name=
"
+
(
encodeURIComponent
(
botdata
.
name
))
+
"
&deck=
"
+
(
encodeURIComponent
(
botdata
.
deck
))
+
"
&host=
"
+
settings
.
modules
.
windbot
.
my_ip
+
"
&port=
"
+
settings
.
port
+
"
&dialog=
"
+
(
encodeURIComponent
(
botdata
.
dialog
))
+
"
&version=
"
+
settings
.
version
+
"
&password=
"
+
(
encodeURIComponent
(
this
.
name
))
},
(
function
(
_this
)
{
return
function
(
error
,
response
,
body
)
{
if
(
error
)
{
...
...
@@ -930,8 +930,9 @@
net
.
createServer
(
function
(
client
)
{
var
connect_count
,
server
;
client
.
ip
=
client
.
remoteAddress
;
client
.
is_local
=
client
.
ip
.
includes
(
'
127.0.0.1
'
)
||
client
.
ip
.
includes
(
settings
.
modules
.
windbot
.
server_ip
);
connect_count
=
ROOM_connected_ip
[
client
.
ip
]
||
0
;
if
(
!
settings
.
modules
.
test_mode
.
no_connect_count_limit
&&
client
.
ip
!==
'
::ffff:127.0.0.1
'
)
{
if
(
!
settings
.
modules
.
test_mode
.
no_connect_count_limit
&&
!
client
.
is_local
)
{
connect_count
++
;
}
ROOM_connected_ip
[
client
.
ip
]
=
connect_count
;
...
...
@@ -1203,7 +1204,7 @@
struct
.
set
(
"
name
"
,
name
);
buffer
=
struct
.
buffer
;
client
.
name
=
name
;
if
(
!
settings
.
modules
.
i18n
.
auto_pick
||
client
.
i
p
===
"
::ffff:127.0.0.1
"
)
{
if
(
!
settings
.
modules
.
i18n
.
auto_pick
||
client
.
i
s_local
)
{
client
.
lang
=
settings
.
modules
.
i18n
[
"
default
"
];
}
else
{
geo
=
geoip
.
lookup
(
client
.
ip
);
...
...
@@ -1509,7 +1510,7 @@
if
(
room
.
welcome
)
{
ygopro
.
stoc_send_chat
(
client
,
room
.
welcome
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
if
(
settings
.
modules
.
arena_mode
.
enabled
&&
client
.
ip
!==
'
::ffff:127.0.0.1
'
)
{
if
(
settings
.
modules
.
arena_mode
.
enabled
&&
!
client
.
is_local
)
{
request
({
url
:
settings
.
modules
.
arena_mode
.
get_score
+
encodeURIComponent
(
client
.
name
),
json
:
true
...
...
@@ -1722,7 +1723,7 @@
if
(
!
room
)
{
return
;
}
if
(
!
room
.
arena
||
client
.
i
p
===
"
::ffff:127.0.0.1
"
)
{
if
(
!
room
.
arena
||
client
.
i
s_local
)
{
return
false
;
}
ref
=
room
.
players
;
...
...
@@ -2394,7 +2395,7 @@
for
(
k
=
0
,
len1
=
ref1
.
length
;
k
<
len1
;
k
++
)
{
player
=
ref1
[
k
];
results
.
push
({
name
:
player
.
name
+
(
settings
.
modules
.
tournament_mode
.
show_ip
&&
player
.
ip
!==
'
::ffff:127.0.0.1
'
?
"
(IP:
"
+
player
.
ip
.
slice
(
7
)
+
"
)
"
:
""
)
+
(
settings
.
modules
.
tournament_mode
.
show_info
&&
!
(
room
.
hostinfo
.
mode
===
2
&&
player
.
pos
>
1
)
?
"
(Score:
"
+
room
.
scores
[
player
.
name
]
+
"
LP:
"
+
(
player
.
lp
!=
null
?
player
.
lp
:
room
.
hostinfo
.
start_lp
)
+
"
)
"
:
""
),
name
:
player
.
name
+
(
settings
.
modules
.
tournament_mode
.
show_ip
&&
!
player
.
is_local
?
"
(IP:
"
+
player
.
ip
.
slice
(
7
)
+
"
)
"
:
""
)
+
(
settings
.
modules
.
tournament_mode
.
show_info
&&
!
(
room
.
hostinfo
.
mode
===
2
&&
player
.
pos
>
1
)
?
"
(Score:
"
+
room
.
scores
[
player
.
name
]
+
"
LP:
"
+
(
player
.
lp
!=
null
?
player
.
lp
:
room
.
hostinfo
.
start_lp
)
+
"
)
"
:
""
),
winner
:
player
.
pos
===
room
.
winner
});
}
...
...
@@ -2529,7 +2530,7 @@
if
(
player
.
pos
!=
null
)
{
results1
.
push
({
id
:
(
-
1
).
toString
(),
name
:
player
.
name
+
(
settings
.
modules
.
http
.
show_ip
&&
pass_validated
&&
player
.
ip
!==
'
::ffff:127.0.0.1
'
?
"
(IP:
"
+
player
.
ip
.
slice
(
7
)
+
"
)
"
:
""
)
+
(
settings
.
modules
.
http
.
show_info
&&
room
.
started
&&
!
(
room
.
hostinfo
.
mode
===
2
&&
player
.
pos
>
1
)
?
"
(Score:
"
+
room
.
scores
[
player
.
name
]
+
"
LP:
"
+
(
player
.
lp
!=
null
?
player
.
lp
:
room
.
hostinfo
.
start_lp
)
+
"
)
"
:
""
),
name
:
player
.
name
+
(
settings
.
modules
.
http
.
show_ip
&&
pass_validated
&&
!
player
.
is_local
?
"
(IP:
"
+
player
.
ip
.
slice
(
7
)
+
"
)
"
:
""
)
+
(
settings
.
modules
.
http
.
show_info
&&
room
.
started
&&
!
(
room
.
hostinfo
.
mode
===
2
&&
player
.
pos
>
1
)
?
"
(Score:
"
+
room
.
scores
[
player
.
name
]
+
"
LP:
"
+
(
player
.
lp
!=
null
?
player
.
lp
:
room
.
hostinfo
.
start_lp
)
+
"
)
"
:
""
),
pos
:
player
.
pos
});
}
...
...
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