Commit dae63867 authored by nanahira's avatar nanahira

Merge branch 'master' into tcg_random

parents 1505e18f f6845f79
# ignore # ignore
package-lock.json
jsconfig.json jsconfig.json
coffeelint.json coffeelint.json
.vscode/ .vscode/
......
# Dockerfile for SRVPro
FROM node:stretch FROM node:stretch
RUN ssh-keygen -A # apt
RUN sed -i 's/deb.debian.org/ftp.cn.debian.org/g' /etc/apt/sources.list RUN apt update && \
RUN apt update env DEBIAN_FRONTEND=noninteractive apt install -y curl wget vim sudo git build-essential libssl1.0-dev libsqlite3-dev sqlite3 mono-complete p7zip-full redis-server
RUN apt install -y openssh-server locales curl git vim sudo cron build-essential premake4 libevent-dev libsqlite3-dev liblua5.3-dev mono-complete sqlite3 p7zip-full redis-server
RUN ln -s /usr/lib/x86_64-linux-gnu/liblua5.3.so /usr/lib/liblua.so RUN npm install -g pm2
RUN npm install pm2 coffeescript@1.12.7 -g
# libevent
# 系统源 WORKDIR /
#RUN sed -i 's/deb.debian.org/ftp.cn.debian.org/g' /etc/apt/sources.list RUN wget 'https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz' -O libevent-2.0.22-stable.tar.gz --no-check-certificate && \
#RUN apt update tar xf libevent-2.0.22-stable.tar.gz && \
cd libevent-2.0.22-stable/ && \
# ssh ./configure && \
RUN mkdir -p /var/run/sshd make && \
RUN mkdir /root/.ssh make install && \
RUN echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config cd .. && \
bash -c 'ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5;ln -s /usr/local/lib/libevent_pthreads-2.0.so.5 /usr/lib/libevent_pthreads-2.0.so.5;ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5;ln -s /usr/local/lib/libevent_pthreads-2.0.so.5 /usr/lib64/libevent_pthreads-2.0.so.5;exit 0'
# locale
RUN echo "zh_CN.UTF-8 UTF-8" > /etc/locale.gen && \ # srvpro
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ COPY . /ygopro-server
locale-gen && \ WORKDIR /ygopro-server
dpkg-reconfigure -f noninteractive locales tzdata && \ RUN npm ci && \
/usr/sbin/update-locale LANG=zh_CN.UTF-8 mkdir config decks replays logs && \
ENV LANG=zh_CN.UTF-8 cp data/default_config.json config/config.json
# declarations # ygopro
EXPOSE 22 RUN git clone --branch=server --recursive https://github.com/purerosefallen/ygopro /ygopro-server/ygopro
WORKDIR /ygopro-server/ygopro
RUN git submodule foreach git checkout master && \
wget -O - https://github.com/premake/premake-core/releases/download/v5.0.0-alpha13/premake-5.0.0-alpha13-linux.tar.gz | tar zfx - && \
./premake5 gmake && \
cd build && \
make config=release && \
cd .. && \
ln -s ./bin/release/ygopro . && \
strip ygopro && \
mkdir replay expansions
# windbot
RUN git clone https://github.com/purerosefallen/windbot /ygopro-server/windbot
WORKDIR /ygopro-server/windbot
RUN xbuild /property:Configuration=Release /property:TargetFrameworkVersion="v4.5" && \
ln -s ./bin/Release/WindBot.exe . && \
ln -s /ygopro-server/ygopro/cards.cdb .
# infos
WORKDIR /
RUN mkdir /redis
EXPOSE 7911 EXPOSE 7911
EXPOSE 7922 EXPOSE 7922
VOLUME /root VOLUME /ygopro-server/config
VOLUME /ygopro-server/ygopro/expansions
WORKDIR /root CMD [ "pm2-docker", "start", "/ygopro-server/data/pm2-docker.json" ]
COPY data/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
CMD [ "/entrypoint.sh" ]
{
"file": "./config/admin_user.json",
"permission_examples": {
"sudo": {
"get_rooms": true,
"duel_log": true,
"download_replay": true,
"clear_duel_log": true,
"deck_dashboard_read": true,
"deck_dashboard_write": true,
"shout": true,
"stop": true,
"change_settings": true,
"ban_user": true,
"kick_user": true,
"start_death": true,
"pre_dashboard": true,
"update_dashboard": true,
"vip": true
},
"judge": {
"get_rooms": true,
"duel_log": true,
"download_replay": true,
"deck_dashboard_read": true,
"deck_dashboard_write": true,
"shout": true,
"kick_user": true,
"start_death": true
},
"streamer": {
"get_rooms": true,
"duel_log": true,
"download_replay": true,
"deck_dashboard_read": true
}
},
"users": {
"root": {
"password": "Nanahira",
"enabled": true,
"permissions": "sudo"
}
}
}
...@@ -159,7 +159,6 @@ ...@@ -159,7 +159,6 @@
"show_ip": true, "show_ip": true,
"show_info": true, "show_info": true,
"log_save_path": "./config/", "log_save_path": "./config/",
"password": "Nanahira",
"port": 7212 "port": 7212
}, },
"test_mode": { "test_mode": {
...@@ -170,7 +169,6 @@ ...@@ -170,7 +169,6 @@
"pre_util": { "pre_util": {
"enabled": false, "enabled": false,
"port": 7944, "port": 7944,
"password": "123456",
"git_html_path": "../mercury233.github.io/", "git_html_path": "../mercury233.github.io/",
"html_path": "../mercury233.github.io/ygosrv233/", "html_path": "../mercury233.github.io/ygosrv233/",
"html_filename": "pre.html", "html_filename": "pre.html",
...@@ -263,7 +261,6 @@ ...@@ -263,7 +261,6 @@
"update_util": { "update_util": {
"enabled": false, "enabled": false,
"port": 7955, "port": 7955,
"password": "123456",
"git_html_path": "../ygo233-web/", "git_html_path": "../ygo233-web/",
"html_path": "../ygo233-web/", "html_path": "../ygo233-web/",
"cdb_path": "./ygopro/cards.cdb", "cdb_path": "./ygopro/cards.cdb",
...@@ -289,7 +286,6 @@ ...@@ -289,7 +286,6 @@
}, },
"http": { "http": {
"port": 7211, "port": 7211,
"password": "Nanahira",
"websocket_roomlist": false, "websocket_roomlist": false,
"public_roomlist": false, "public_roomlist": false,
"show_ip": true, "show_ip": true,
......
{
"file": "./config/admin_user.json",
"permission_examples": {
"sudo": {
"get_rooms": true,
"duel_log": true,
"download_replay": true,
"clear_duel_log": true,
"deck_dashboard_read": true,
"deck_dashboard_write": true,
"shout": true,
"stop": true,
"change_settings": true,
"ban_user": true,
"kick_user": true,
"start_death": true,
"pre_dashboard": true,
"update_dashboard": true,
"vip": true
},
"judge": {
"get_rooms": true,
"duel_log": true,
"download_replay": true,
"deck_dashboard_read": true,
"deck_dashboard_write": true,
"shout": true,
"kick_user": true,
"start_death": true
},
"streamer": {
"get_rooms": true,
"duel_log": true,
"download_replay": true,
"deck_dashboard_read": true
}
},
"users": {
"root": {
"password": "Nanahira",
"enabled": true,
"permissions": "sudo"
},
"judge": {
"password": "Clala",
"enabled": true,
"permissions": "judge"
},
"streamer": {
"password": "Aris",
"enabled": true,
"permissions": "streamer"
}
}
}
...@@ -162,7 +162,6 @@ ...@@ -162,7 +162,6 @@
"show_ip": true, "show_ip": true,
"show_info": true, "show_info": true,
"log_save_path": "./config/", "log_save_path": "./config/",
"password": "Nanahira",
"port": 1264 "port": 1264
}, },
"test_mode": { "test_mode": {
...@@ -173,7 +172,6 @@ ...@@ -173,7 +172,6 @@
"pre_util": { "pre_util": {
"enabled": false, "enabled": false,
"port": 7944, "port": 7944,
"password": "123456",
"git_html_path": "../mercury233.github.io/", "git_html_path": "../mercury233.github.io/",
"html_path": "../mercury233.github.io/ygosrv233/", "html_path": "../mercury233.github.io/ygosrv233/",
"html_filename": "pre.html", "html_filename": "pre.html",
...@@ -263,7 +261,6 @@ ...@@ -263,7 +261,6 @@
"update_util": { "update_util": {
"enabled": false, "enabled": false,
"port": 7955, "port": 7955,
"password": "123456",
"git_html_path": "../ygo233-web/", "git_html_path": "../ygo233-web/",
"html_path": "../ygo233-web/", "html_path": "../ygo233-web/",
"cdb_path": "./ygopro/cards.cdb", "cdb_path": "./ygopro/cards.cdb",
...@@ -289,7 +286,6 @@ ...@@ -289,7 +286,6 @@
}, },
"http": { "http": {
"port": 1263, "port": 1263,
"password": "Nanahira",
"websocket_roomlist": false, "websocket_roomlist": false,
"public_roomlist": true, "public_roomlist": true,
"show_ip": true, "show_ip": true,
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
"side_timeout": false, "side_timeout": false,
"tag_duel_surrender": true, "tag_duel_surrender": true,
"replay_delay": false, "replay_delay": false,
"hide_name": false,
"i18n": { "i18n": {
"auto_pick": false, "auto_pick": false,
"default": "zh-cn", "default": "zh-cn",
...@@ -161,6 +162,7 @@ ...@@ -161,6 +162,7 @@
"comment": "mode: athletic / entertain", "comment": "mode: athletic / entertain",
"accesskey": "233", "accesskey": "233",
"ready_time": 30, "ready_time": 30,
"check_permit": "https://api.mycard.moe/ygopro/match/permit",
"post_score": false, "post_score": false,
"get_score": false "get_score": false
}, },
......
#!/bin/bash
if [ -n "$authorized_keys" ] && [ ! -f /root/.ssh/authorized_keys ]; then mkdir /root/.ssh; printenv authorized_keys > /root/.ssh/authorized_keys; chmod 600 /root/.ssh/authorized_keys; fi
if [ -n "$password" ] && passwd --status | grep -q 'L'; then echo "root:$password" | chpasswd ; fi
unset authorized_keys
unset password
if [ -s /root/.pm2/dump.pm2 ]; then pm2 resurrect; fi
/usr/sbin/sshd -D
...@@ -190,6 +190,8 @@ ...@@ -190,6 +190,8 @@
"replay_hint_part1": "Sending the replay of the duel number ", "replay_hint_part1": "Sending the replay of the duel number ",
"replay_hint_part2": ".", "replay_hint_part2": ".",
"invalid_side_rule": "Illegal cards are contained in your side deck.", "invalid_side_rule": "Illegal cards are contained in your side deck.",
"arena_wait_hint": "If you opponent does not appear within 25 seconds, you may quit without any penalty.",
"arena_wait_timeout": "Your opponent did not appear, you may quit without any penalty.",
"athletic_arena_tip": "During an athletic match, a game quit behavior is regarded as a surrender." "athletic_arena_tip": "During an athletic match, a game quit behavior is regarded as a surrender."
}, },
"es-es": { "es-es": {
...@@ -527,6 +529,8 @@ ...@@ -527,6 +529,8 @@
"replay_hint_part1": "正在发送第", "replay_hint_part1": "正在发送第",
"replay_hint_part2": "局决斗的录像。", "replay_hint_part2": "局决斗的录像。",
"invalid_side_rule": "副卡组中包含不允许换入副卡组的卡。", "invalid_side_rule": "副卡组中包含不允许换入副卡组的卡。",
"arena_wait_hint": "若对手在25秒内不进入游戏,您退房时不会进行扣分。",
"arena_wait_timeout": "由于对手未能在30秒内进入游戏,此时您退出游戏不会扣分。",
"athletic_arena_tip": "在竞技匹配中,比赛开始前退出游戏也会视为投降。" "athletic_arena_tip": "在竞技匹配中,比赛开始前退出游戏也会视为投降。"
}, },
"ko-kr": { "ko-kr": {
......
{
"apps": [
{
"name": "ygopro-server",
"script": "/ygopro-server/ygopro-server.js",
"cwd": "/ygopro-server"
},
{
"name": "windbot",
"script": "/ygopro-server/windbot/WindBot.exe",
"cwd": "/ygopro-server/windbot/",
"args": "ServerMode=true ServerPort=2399",
"interpreter": "mono"
},
{
"name": "redis-server",
"script": "/usr/bin/redis-server",
"cwd": "/redis"
}
]
}
This diff is collapsed.
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
"geoip-country-lite": "latest", "geoip-country-lite": "latest",
"challonge": "latest", "challonge": "latest",
"pg": "^6.4.2", "pg": "^6.4.2",
"ws": "^6.0.0" "ws": "^1.1.1"
}, },
"license": "AGPL-3.0", "license": "AGPL-3.0",
"scripts": { "scripts": {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
TODO:带参数运行时执行对应操作后退出 TODO:带参数运行时执行对应操作后退出
*/ */
var http = require('http'); var http = require('http');
var https = require('https');
var sqlite3 = require('sqlite3').verbose(); var sqlite3 = require('sqlite3').verbose();
var fs = require('fs'); var fs = require('fs');
var execSync = require('child_process').execSync; var execSync = require('child_process').execSync;
...@@ -22,7 +23,8 @@ var auth = require('./ygopro-auth.js'); ...@@ -22,7 +23,8 @@ var auth = require('./ygopro-auth.js');
var constants = loadJSON('./data/constants.json'); var constants = loadJSON('./data/constants.json');
var settings = loadJSON('./config/config.json'); var settings = loadJSON('./config/config.json');
config=settings.modules.pre_util; config = settings.modules.pre_util;
ssl_config = settings.modules.http.ssl;
//全卡HTML列表 //全卡HTML列表
var cardHTMLs=[]; var cardHTMLs=[];
...@@ -405,7 +407,7 @@ var packDatas = function () { ...@@ -405,7 +407,7 @@ var packDatas = function () {
} }
//建立一个http服务器,接收API操作 //建立一个http服务器,接收API操作
http.createServer(function (req, res) { function requestListener(req, res) {
var u = url.parse(req.url, true); var u = url.parse(req.url, true);
if (!auth.auth(u.query.username, u.query.password, "pre_dashboard", "pre_dashboard")) { if (!auth.auth(u.query.username, u.query.password, "pre_dashboard", "pre_dashboard")) {
...@@ -465,4 +467,16 @@ http.createServer(function (req, res) { ...@@ -465,4 +467,16 @@ http.createServer(function (req, res) {
res.end("400"); res.end("400");
} }
}).listen(config.port); }
if (ssl_config.enabled) {
const ssl_cert = fs.readFileSync(ssl_config.cert);
const ssl_key = fs.readFileSync(ssl_config.key);
const options = {
cert: ssl_cert,
key: ssl_key
}
https.createServer(options, requestListener).listen(config.port);
} else {
http.createServer(requestListener).listen(config.port);
}
This diff is collapsed.
This diff is collapsed.
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
不带参数运行时,会建立一个服务器,调用API执行对应操作 不带参数运行时,会建立一个服务器,调用API执行对应操作
*/ */
var http = require('http'); var http = require('http');
var https = require('https');
var fs = require('fs'); var fs = require('fs');
var url = require('url'); var url = require('url');
var request = require('request'); var request = require('request');
...@@ -19,8 +20,9 @@ var loadJSON = require('load-json-file').sync; ...@@ -19,8 +20,9 @@ var loadJSON = require('load-json-file').sync;
var auth = require('./ygopro-auth.js'); var auth = require('./ygopro-auth.js');
var settings = loadJSON('./config/config.json'); var settings = loadJSON('./config/config.json');
config=settings.modules.tournament_mode; config = settings.modules.tournament_mode;
challonge_config=settings.modules.challonge; challonge_config = settings.modules.challonge;
ssl_config = settings.modules.http.ssl;
var challonge; var challonge;
if (challonge_config.enabled) { if (challonge_config.enabled) {
...@@ -214,7 +216,7 @@ var receiveDecks = function(files) { ...@@ -214,7 +216,7 @@ var receiveDecks = function(files) {
} }
//建立一个http服务器,接收API操作 //建立一个http服务器,接收API操作
http.createServer(function (req, res) { function requestListener(req, res) {
var u = url.parse(req.url, true); var u = url.parse(req.url, true);
/*if (u.query.password !== config.password) { /*if (u.query.password !== config.password) {
...@@ -315,4 +317,16 @@ http.createServer(function (req, res) { ...@@ -315,4 +317,16 @@ http.createServer(function (req, res) {
res.end("400"); res.end("400");
} }
}).listen(config.port); }
if (ssl_config.enabled) {
const ssl_cert = fs.readFileSync(ssl_config.cert);
const ssl_key = fs.readFileSync(ssl_config.key);
const options = {
cert: ssl_cert,
key: ssl_key
}
https.createServer(options, requestListener).listen(config.port);
} else {
http.createServer(requestListener).listen(config.port);
}
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
TODO:带参数运行时执行对应操作后退出 TODO:带参数运行时执行对应操作后退出
*/ */
var http = require('http'); var http = require('http');
var https = require('https');
var sqlite3 = require('sqlite3').verbose(); var sqlite3 = require('sqlite3').verbose();
var fs = require('fs'); var fs = require('fs');
var execSync = require('child_process').execSync; var execSync = require('child_process').execSync;
...@@ -23,7 +24,8 @@ var auth = require('./ygopro-auth.js'); ...@@ -23,7 +24,8 @@ var auth = require('./ygopro-auth.js');
var constants = loadJSON('./data/constants.json'); var constants = loadJSON('./data/constants.json');
var settings = loadJSON('./config/config.json'); var settings = loadJSON('./config/config.json');
config=settings.modules.update_util; config = settings.modules.update_util;
ssl_config = settings.modules.http.ssl;
//全卡名称列表 //全卡名称列表
var cardNames={}; var cardNames={};
...@@ -212,7 +214,7 @@ var pushHTMLs = function() { ...@@ -212,7 +214,7 @@ var pushHTMLs = function() {
//建立一个http服务器,接收API操作 //建立一个http服务器,接收API操作
http.createServer(function (req, res) { function requestListener(req, res) {
var u = url.parse(req.url, true); var u = url.parse(req.url, true);
if (!auth.auth(u.query.username, u.query.password, "update_dashboard", "update_dashboard")) { if (!auth.auth(u.query.username, u.query.password, "update_dashboard", "update_dashboard")) {
...@@ -275,4 +277,16 @@ http.createServer(function (req, res) { ...@@ -275,4 +277,16 @@ http.createServer(function (req, res) {
res.end("400"); res.end("400");
} }
}).listen(config.port); }
if (ssl_config.enabled) {
const ssl_cert = fs.readFileSync(ssl_config.cert);
const ssl_key = fs.readFileSync(ssl_config.key);
const options = {
cert: ssl_cert,
key: ssl_key
}
https.createServer(options, requestListener).listen(config.port);
} else {
http.createServer(requestListener).listen(config.port);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment