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
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
nanahira
srvpro
Commits
12c122c5
Commit
12c122c5
authored
Feb 12, 2018
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add archive replays
parent
ddf53a58
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
3 deletions
+98
-3
config.json
config.json
+1
-0
ygopro-server.coffee
ygopro-server.coffee
+41
-0
ygopro-server.js
ygopro-server.js
+56
-3
No files found.
config.json
View file @
12c122c5
...
@@ -86,6 +86,7 @@
...
@@ -86,6 +86,7 @@
"deck_path"
:
"./decks/"
,
"deck_path"
:
"./decks/"
,
"replay_safe"
:
true
,
"replay_safe"
:
true
,
"replay_path"
:
"./replays/"
,
"replay_path"
:
"./replays/"
,
"replay_archive_tool"
:
"7z"
,
"show_ip"
:
false
,
"show_ip"
:
false
,
"show_info"
:
true
,
"show_info"
:
true
,
"duel_log"
:
[],
"duel_log"
:
[],
...
...
ygopro-server.coffee
View file @
12c122c5
...
@@ -1905,6 +1905,47 @@ if settings.modules.http
...
@@ -1905,6 +1905,47 @@ if settings.modules.http
duellog
=
JSON
.
stringify
settings
.
modules
.
tournament_mode
.
duel_log
,
null
,
2
duellog
=
JSON
.
stringify
settings
.
modules
.
tournament_mode
.
duel_log
,
null
,
2
response
.
end
(
addCallback
(
u
.
query
.
callback
,
duellog
))
response
.
end
(
addCallback
(
u
.
query
.
callback
,
duellog
))
else
if
u
.
pathname
==
'/api/archive.zip'
and
settings
.
modules
.
tournament_mode
.
enabled
if
!
(
u
.
query
.
pass
==
settings
.
modules
.
tournament_mode
.
password
)
response
.
writeHead
(
403
)
response
.
end
(
"Invalid password."
)
return
else
if
settings
.
modules
.
tournament_mode
.
duel_log
.
size
<=
0
response
.
writeHead
(
403
)
response
.
end
(
"Duel logs not found."
)
return
else
try
archive_name
=
moment
().
format
(
'YYYY-MM-DD HH:mm:ss'
)
+
".zip"
archive_args
=
[
"a"
,
"-mx0"
,
archive_name
]
for
replay
in
settings
.
modules
.
tournament_mode
.
duel_log
archive_args
.
push
(
replay
.
replay_filename
)
archive_process
=
spawn
settings
.
modules
.
tournament_mode
.
replay_archive_tool
,
archive_args
,
{
cwd
:
settings
.
modules
.
tournament_mode
.
replay_path
}
archive_process
.
on
'error'
,
(
err
)
=>
response
.
writeHead
(
403
)
response
.
end
(
"Failed packing replays. "
+
err
)
return
archive_process
.
on
'exit'
,
(
code
)
=>
fs
.
readFile
(
settings
.
modules
.
tournament_mode
.
replay_path
+
archive_name
,
(
error
,
buffer
)
->
if
error
response
.
writeHead
(
403
)
response
.
end
(
"Failed sending replays. "
+
error
)
return
else
response
.
writeHead
(
200
,
{
"Content-Type"
:
"application/octet-stream"
,
"Content-Disposition"
:
"attachment"
})
response
.
end
(
buffer
)
return
)
archive_process
.
stdout
.
setEncoding
'utf8'
archive_process
.
stdout
.
on
'data'
,
(
data
)
=>
log
.
info
"archive process: "
+
data
archive_process
.
stderr
.
setEncoding
'utf8'
archive_process
.
stderr
.
on
'data'
,
(
data
)
=>
log
.
warn
"archive error: "
+
data
catch
error
response
.
writeHead
(
403
)
response
.
end
(
"Failed reading replays. "
+
error
)
else
if
u
.
pathname
==
'/api/clearlog'
and
settings
.
modules
.
tournament_mode
.
enabled
else
if
u
.
pathname
==
'/api/clearlog'
and
settings
.
modules
.
tournament_mode
.
enabled
if
!
(
u
.
query
.
pass
==
settings
.
modules
.
tournament_mode
.
password
)
if
!
(
u
.
query
.
pass
==
settings
.
modules
.
tournament_mode
.
password
)
response
.
writeHead
(
200
)
response
.
writeHead
(
200
)
...
...
ygopro-server.js
View file @
12c122c5
...
@@ -2351,7 +2351,7 @@
...
@@ -2351,7 +2351,7 @@
return
callback
+
"
(
"
+
text
+
"
);
"
;
return
callback
+
"
(
"
+
text
+
"
);
"
;
};
};
requestListener
=
function
(
request
,
response
)
{
requestListener
=
function
(
request
,
response
)
{
var
duellog
,
filename
,
getpath
,
j
,
len
,
parseQueryString
,
pass_validated
,
player
,
room
,
roomsjson
,
u
;
var
archive_args
,
archive_name
,
archive_process
,
duellog
,
error
,
filename
,
getpath
,
j
,
k
,
len
,
len1
,
parseQueryString
,
pass_validated
,
player
,
ref
,
replay_file
,
room
,
roomsjson
,
u
;
parseQueryString
=
true
;
parseQueryString
=
true
;
u
=
url
.
parse
(
request
.
url
,
parseQueryString
);
u
=
url
.
parse
(
request
.
url
,
parseQueryString
);
pass_validated
=
u
.
query
.
pass
===
settings
.
modules
.
http
.
password
;
pass_validated
=
u
.
query
.
pass
===
settings
.
modules
.
http
.
password
;
...
@@ -2408,6 +2408,59 @@
...
@@ -2408,6 +2408,59 @@
duellog
=
JSON
.
stringify
(
settings
.
modules
.
tournament_mode
.
duel_log
,
null
,
2
);
duellog
=
JSON
.
stringify
(
settings
.
modules
.
tournament_mode
.
duel_log
,
null
,
2
);
response
.
end
(
addCallback
(
u
.
query
.
callback
,
duellog
));
response
.
end
(
addCallback
(
u
.
query
.
callback
,
duellog
));
}
}
}
else
if
(
u
.
pathname
===
'
/api/archive.zip
'
&&
settings
.
modules
.
tournament_mode
.
enabled
)
{
if
(
!
(
u
.
query
.
pass
===
settings
.
modules
.
tournament_mode
.
password
))
{
response
.
writeHead
(
403
);
response
.
end
(
"
Invalid password.
"
);
return
;
}
else
if
(
settings
.
modules
.
tournament_mode
.
duel_log
.
size
<=
0
)
{
response
.
writeHead
(
403
);
response
.
end
(
"
Duel logs not found.
"
);
return
;
}
else
{
try
{
archive_name
=
moment
().
format
(
'
YYYY-MM-DD HH:mm:ss
'
)
+
"
.zip
"
;
archive_args
=
[
"
a
"
,
"
-mx0
"
,
archive_name
];
ref
=
settings
.
modules
.
tournament_mode
.
duel_log
;
for
(
j
=
0
,
len
=
ref
.
length
;
j
<
len
;
j
++
)
{
replay
=
ref
[
j
];
archive_args
.
push
(
replay
.
replay_filename
);
}
archive_process
=
spawn
(
settings
.
modules
.
tournament_mode
.
replay_archive_tool
,
archive_args
,
{
cwd
:
settings
.
modules
.
tournament_mode
.
replay_path
});
archive_process
.
on
(
'
error
'
,
(
err
)
=>
{
response
.
writeHead
(
403
);
response
.
end
(
"
Failed packing replays.
"
+
err
);
});
archive_process
.
on
(
'
exit
'
,
(
code
)
=>
{
return
fs
.
readFile
(
settings
.
modules
.
tournament_mode
.
replay_path
+
archive_name
,
function
(
error
,
buffer
)
{
if
(
error
)
{
response
.
writeHead
(
403
);
response
.
end
(
"
Failed sending replays.
"
+
error
);
}
else
{
response
.
writeHead
(
200
,
{
"
Content-Type
"
:
"
application/octet-stream
"
,
"
Content-Disposition
"
:
"
attachment
"
});
response
.
end
(
buffer
);
}
});
});
archive_process
.
stdout
.
setEncoding
(
'
utf8
'
);
archive_process
.
stdout
.
on
(
'
data
'
,
function
(
data
)
{
return
log
.
info
(
"
archive process:
"
+
data
);
});
archive_process
.
stderr
.
setEncoding
(
'
utf8
'
);
archive_process
.
stderr
.
on
(
'
data
'
,
function
(
data
)
{
return
log
.
warn
(
"
archive error:
"
+
data
);
});
}
catch
(
error1
)
{
error
=
error1
;
response
.
writeHead
(
403
);
response
.
end
(
"
Failed reading replays.
"
+
error
);
}
}
}
else
if
(
u
.
pathname
===
'
/api/clearlog
'
&&
settings
.
modules
.
tournament_mode
.
enabled
)
{
}
else
if
(
u
.
pathname
===
'
/api/clearlog
'
&&
settings
.
modules
.
tournament_mode
.
enabled
)
{
if
(
!
(
u
.
query
.
pass
===
settings
.
modules
.
tournament_mode
.
password
))
{
if
(
!
(
u
.
query
.
pass
===
settings
.
modules
.
tournament_mode
.
password
))
{
response
.
writeHead
(
200
);
response
.
writeHead
(
200
);
...
@@ -2447,8 +2500,8 @@
...
@@ -2447,8 +2500,8 @@
return
;
return
;
}
}
if
(
u
.
query
.
shout
)
{
if
(
u
.
query
.
shout
)
{
for
(
j
=
0
,
len
=
ROOM_all
.
length
;
j
<
len
;
j
++
)
{
for
(
k
=
0
,
len1
=
ROOM_all
.
length
;
k
<
len1
;
k
++
)
{
room
=
ROOM_all
[
j
];
room
=
ROOM_all
[
k
];
if
(
room
&&
room
.
established
)
{
if
(
room
&&
room
.
established
)
{
ygopro
.
stoc_send_chat_to_room
(
room
,
u
.
query
.
shout
,
ygopro
.
constants
.
COLORS
.
YELLOW
);
ygopro
.
stoc_send_chat_to_room
(
room
,
u
.
query
.
shout
,
ygopro
.
constants
.
COLORS
.
YELLOW
);
}
}
...
...
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