Commit dae63867 authored by nanahira's avatar nanahira

Merge branch 'master' into tcg_random

parents 1505e18f f6845f79
# ignore
package-lock.json
jsconfig.json
coffeelint.json
.vscode/
......
# Dockerfile for SRVPro
FROM node:stretch
RUN ssh-keygen -A
RUN sed -i 's/deb.debian.org/ftp.cn.debian.org/g' /etc/apt/sources.list
RUN apt update
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 pm2 coffeescript@1.12.7 -g
# 系统源
#RUN sed -i 's/deb.debian.org/ftp.cn.debian.org/g' /etc/apt/sources.list
#RUN apt update
# ssh
RUN mkdir -p /var/run/sshd
RUN mkdir /root/.ssh
RUN echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
# locale
RUN echo "zh_CN.UTF-8 UTF-8" > /etc/locale.gen && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
locale-gen && \
dpkg-reconfigure -f noninteractive locales tzdata && \
/usr/sbin/update-locale LANG=zh_CN.UTF-8
ENV LANG=zh_CN.UTF-8
# declarations
EXPOSE 22
# apt
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 npm install -g pm2
# libevent
WORKDIR /
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 && \
tar xf libevent-2.0.22-stable.tar.gz && \
cd libevent-2.0.22-stable/ && \
./configure && \
make && \
make install && \
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'
# srvpro
COPY . /ygopro-server
WORKDIR /ygopro-server
RUN npm ci && \
mkdir config decks replays logs && \
cp data/default_config.json config/config.json
# ygopro
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 7922
VOLUME /root
VOLUME /ygopro-server/config
VOLUME /ygopro-server/ygopro/expansions
WORKDIR /root
COPY data/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
CMD [ "/entrypoint.sh" ]
CMD [ "pm2-docker", "start", "/ygopro-server/data/pm2-docker.json" ]
{
"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 @@
"show_ip": true,
"show_info": true,
"log_save_path": "./config/",
"password": "Nanahira",
"port": 7212
},
"test_mode": {
......@@ -170,7 +169,6 @@
"pre_util": {
"enabled": false,
"port": 7944,
"password": "123456",
"git_html_path": "../mercury233.github.io/",
"html_path": "../mercury233.github.io/ygosrv233/",
"html_filename": "pre.html",
......@@ -263,7 +261,6 @@
"update_util": {
"enabled": false,
"port": 7955,
"password": "123456",
"git_html_path": "../ygo233-web/",
"html_path": "../ygo233-web/",
"cdb_path": "./ygopro/cards.cdb",
......@@ -289,7 +286,6 @@
},
"http": {
"port": 7211,
"password": "Nanahira",
"websocket_roomlist": false,
"public_roomlist": false,
"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 @@
"show_ip": true,
"show_info": true,
"log_save_path": "./config/",
"password": "Nanahira",
"port": 1264
},
"test_mode": {
......@@ -173,7 +172,6 @@
"pre_util": {
"enabled": false,
"port": 7944,
"password": "123456",
"git_html_path": "../mercury233.github.io/",
"html_path": "../mercury233.github.io/ygosrv233/",
"html_filename": "pre.html",
......@@ -263,7 +261,6 @@
"update_util": {
"enabled": false,
"port": 7955,
"password": "123456",
"git_html_path": "../ygo233-web/",
"html_path": "../ygo233-web/",
"cdb_path": "./ygopro/cards.cdb",
......@@ -289,7 +286,6 @@
},
"http": {
"port": 1263,
"password": "Nanahira",
"websocket_roomlist": false,
"public_roomlist": true,
"show_ip": true,
......
......@@ -22,6 +22,7 @@
"side_timeout": false,
"tag_duel_surrender": true,
"replay_delay": false,
"hide_name": false,
"i18n": {
"auto_pick": false,
"default": "zh-cn",
......@@ -161,6 +162,7 @@
"comment": "mode: athletic / entertain",
"accesskey": "233",
"ready_time": 30,
"check_permit": "https://api.mycard.moe/ygopro/match/permit",
"post_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 @@
"replay_hint_part1": "Sending the replay of the duel number ",
"replay_hint_part2": ".",
"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."
},
"es-es": {
......@@ -527,6 +529,8 @@
"replay_hint_part1": "正在发送第",
"replay_hint_part2": "局决斗的录像。",
"invalid_side_rule": "副卡组中包含不允许换入副卡组的卡。",
"arena_wait_hint": "若对手在25秒内不进入游戏,您退房时不会进行扣分。",
"arena_wait_timeout": "由于对手未能在30秒内进入游戏,此时您退出游戏不会扣分。",
"athletic_arena_tip": "在竞技匹配中,比赛开始前退出游戏也会视为投降。"
},
"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 @@
"geoip-country-lite": "latest",
"challonge": "latest",
"pg": "^6.4.2",
"ws": "^6.0.0"
"ws": "^1.1.1"
},
"license": "AGPL-3.0",
"scripts": {
......
......@@ -8,6 +8,7 @@
TODO:带参数运行时执行对应操作后退出
*/
var http = require('http');
var https = require('https');
var sqlite3 = require('sqlite3').verbose();
var fs = require('fs');
var execSync = require('child_process').execSync;
......@@ -22,7 +23,8 @@ var auth = require('./ygopro-auth.js');
var constants = loadJSON('./data/constants.json');
var settings = loadJSON('./config/config.json');
config=settings.modules.pre_util;
config = settings.modules.pre_util;
ssl_config = settings.modules.http.ssl;
//全卡HTML列表
var cardHTMLs=[];
......@@ -405,7 +407,7 @@ var packDatas = function () {
}
//建立一个http服务器,接收API操作
http.createServer(function (req, res) {
function requestListener(req, res) {
var u = url.parse(req.url, true);
if (!auth.auth(u.query.username, u.query.password, "pre_dashboard", "pre_dashboard")) {
......@@ -465,4 +467,16 @@ http.createServer(function (req, res) {
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 @@
不带参数运行时,会建立一个服务器,调用API执行对应操作
*/
var http = require('http');
var https = require('https');
var fs = require('fs');
var url = require('url');
var request = require('request');
......@@ -19,8 +20,9 @@ var loadJSON = require('load-json-file').sync;
var auth = require('./ygopro-auth.js');
var settings = loadJSON('./config/config.json');
config=settings.modules.tournament_mode;
challonge_config=settings.modules.challonge;
config = settings.modules.tournament_mode;
challonge_config = settings.modules.challonge;
ssl_config = settings.modules.http.ssl;
var challonge;
if (challonge_config.enabled) {
......@@ -214,7 +216,7 @@ var receiveDecks = function(files) {
}
//建立一个http服务器,接收API操作
http.createServer(function (req, res) {
function requestListener(req, res) {
var u = url.parse(req.url, true);
/*if (u.query.password !== config.password) {
......@@ -315,4 +317,16 @@ http.createServer(function (req, res) {
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 @@
TODO:带参数运行时执行对应操作后退出
*/
var http = require('http');
var https = require('https');
var sqlite3 = require('sqlite3').verbose();
var fs = require('fs');
var execSync = require('child_process').execSync;
......@@ -23,7 +24,8 @@ var auth = require('./ygopro-auth.js');
var constants = loadJSON('./data/constants.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={};
......@@ -212,7 +214,7 @@ var pushHTMLs = function() {
//建立一个http服务器,接收API操作
http.createServer(function (req, res) {
function requestListener(req, res) {
var u = url.parse(req.url, true);
if (!auth.auth(u.query.username, u.query.password, "update_dashboard", "update_dashboard")) {
......@@ -275,4 +277,16 @@ http.createServer(function (req, res) {
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