Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
superconvert authored Jun 14, 2024
1 parent 321d72d commit 43b6df9
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 76 deletions.
3 changes: 3 additions & 0 deletions web manager/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ var path = require('path');
path.join(process.cwd(), 'config.json');
~~~

nodejs 版本建议用:
https://cdn.npmmirror.com/binaries/node/latest-v18.x/node-v18.20.1-x64.msi

# 编译运行

~~~shell
Expand Down
4 changes: 3 additions & 1 deletion web manager/src/cmd.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ set cwd=%cd%
echo %cd%

set one=%1
set pdir=%cwd%/../bin
set pname=smart_rtmpd.exe
set ppath=%cwd%/../bin/%pname%
set stopfail='stop service %pname% failed.'
set startfail='start service %pname% failed.'
set restartfail='restart service %pname% failed.'
set restorefail='restore service %pname% failed.'

cd %pdir%

rem ---------------------------------------------------------
if "%one%" == "start" (
call:start_service start
Expand Down Expand Up @@ -75,7 +78,6 @@ rem ------------------------------------------------
)
echo %ppath%
echo %one%
echo 'caiwenfeng'
start %ppath% %1
goto:eof

Expand Down
7 changes: 6 additions & 1 deletion web manager/src/cmd_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ function* req_smart_rtmpd(req_cmd, req_url, body=null) {
};
option['body'] = body;
}
logger.info("request smart_rtmpd - " + req_url);
return new Promise((resolve, reject) => {
request(option, (err, res, body) => {
var data = {
Expand All @@ -424,7 +425,11 @@ function* req_smart_rtmpd(req_cmd, req_url, body=null) {
data["msg"] = res.statusCode + "-" + res.statusMessage;
}
resolve(data);
logger.info("stream server respose(" + body + ")");
if (err) {
logger.info("smart_rtmpd respose failed(" + err + ")");
} else {
logger.info("smart_rtmpd respose success(" + body + ")");
}
});
});
};
Expand Down
21 changes: 1 addition & 20 deletions web manager/src/config.json
Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
{
"port":5000,
"restart":3000,
"binpath":"../bin/",
"jwt":{
"secret":"20120507",
"algorithm":"HS256",
"expires":"5m"
},
"media":{
"host":"127.0.0.1",
"port":8080,
"timeout":1000,
"config":"/api/config",
"stream":"/api/live",
"status":"/api/status",
"policy":"/api/policy",
"license":"/api/license"
}
}
{"port":5000,"restart":3000,"binpath":"../bin/","jwt":{"secret":"20120507","algorithm":"HS256","expires":"5m"},"media":{"host":"127.0.0.1","port":8282,"timeout":1000,"config":"/api/config","stream":"/api/live","status":"/api/status","policy":"/api/policy","license":"/api/license"}}
46 changes: 23 additions & 23 deletions web manager/src/package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"name": "web_admin",
"version": "1.0.0",
"description": "",
"main": "server.js",
"author": "",
"dependencies": {
"co": "^4.6.0",
"cors": "^2.8.5",
"crypto": "^1.0.1",
"diskinfo": "0.0.3",
"express": "^4.17.1",
"fs": "0.0.1-security",
"http": "0.0.1-security",
"jsonwebtoken": "^9.0.0",
"log4js": "^6.3.0",
"request": "^2.88.2",
"silly-datetime": "^0.1.2",
"sqlite3": "^5.0.2",
"thunkify": "^2.1.2",
"url": "^0.11.0"
}
}
{
"name": "web_admin",
"version": "1.0.0",
"description": "",
"main": "server.js",
"author": "",
"dependencies": {
"co": "^4.6.0",
"cors": "^2.8.5",
"crypto": "^1.0.1",
"diskinfo": "0.0.3",
"express": "^4.17.1",
"fs": "0.0.1-security",
"http": "0.0.1-security",
"jsonwebtoken": "^9.0.0",
"log4js": "^6.3.0",
"request": "^2.88.2",
"silly-datetime": "^0.1.2",
"sqlite3": "^5.0.2",
"thunkify": "^2.1.2",
"url": "^0.11.0"
}
}
62 changes: 31 additions & 31 deletions web manager/src/sql_utils.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'use strict';
'use strict';

/// Import sqlitedb.
const crypto = require('crypto');
const date = require('silly-datetime');
const log4js = require('./log_utils'); // 引入库
const log4js = require('./log_utils'); // 引入库
const config = require('./config');
const sqlitedb = require('./sql_db.js').sqlitedb;
const logger = log4js.getLogger('webserver'); // 获取指定的输出源
const logger = log4js.getLogger('webserver'); // 获取指定的输出源

var sqliteDB = new sqlitedb('./smart_web.db');

// --------------------------------------------
// 响应正确值到前端
// 响应正确值到前端
// --------------------------------------------
function succ_response(res, val) {
var data = {
Expand All @@ -25,7 +25,7 @@ function succ_response(res, val) {
}

// --------------------------------------------
// 响应错误的值到前端
// 响应错误的值到前端
// --------------------------------------------
function fail_response(res, msg, val) {
var data = {
Expand All @@ -39,7 +39,7 @@ function fail_response(res, msg, val) {
}

// ----------------------------------------------------------
// 创建表
// 创建表
// ----------------------------------------------------------
function create_table () {
/// create table.
Expand All @@ -50,15 +50,15 @@ function create_table () {
}

// ----------------------------------------------------------
// 加密密码
// 加密密码
// ----------------------------------------------------------
function crypt_passwd (password) {
var md5 = crypto.createHash('md5');
return md5.update(password).digest('hex');
}

// ----------------------------------------------------------
// 添加用户
// 添加用户
// ----------------------------------------------------------
function add_user (req, res) {

Expand Down Expand Up @@ -92,7 +92,7 @@ function add_user (req, res) {
}

// ----------------------------------------------------------
// 删除用户
// 删除用户
// ----------------------------------------------------------
function del_user (req, res) {
var userid = req.body["user"];
Expand All @@ -113,13 +113,13 @@ function del_user (req, res) {
}

// ----------------------------------------------------------
// 修改用户或密码
// 修改用户或密码
// ----------------------------------------------------------
function mdf_user (req, res) {

var user = req.body;
var updateSql = '';
// 更改信息
// 更改信息
if ( user['mobile'] || user['email'] ) {
updateSql = 'update user set mobile=\'' + user['mobile'] + '\', ' +
'email=\'' + user['email'] + '\', ' + 'nickname=\'' + user['nickname'] + '\' ';
Expand All @@ -136,7 +136,7 @@ function mdf_user (req, res) {
}
}

// 更改密码
// 更改密码
} else {
var querySql = 'select passwd from user where id=' + user['id'];
sqliteDB.query(querySql, query_data);
Expand Down Expand Up @@ -168,7 +168,7 @@ function mdf_user (req, res) {
}

// ----------------------------------------------------------
// 用户授权
// 用户授权
// ----------------------------------------------------------
function auth_user (req, res) {
var user = req.body;
Expand All @@ -186,7 +186,7 @@ function auth_user (req, res) {
}

// ----------------------------------------------------------
// 查询授权
// 查询授权
// ----------------------------------------------------------
function auth_query (req, res) {

Expand Down Expand Up @@ -216,7 +216,7 @@ function auth_query (req, res) {
}

// ----------------------------------------------------------
// 查找用户
// 查找用户
// ----------------------------------------------------------
function find_user (req, res) {
var kw = req.query['keyword'];
Expand All @@ -236,7 +236,7 @@ function find_user (req, res) {
}

// ----------------------------------------------------------
// 取消授权
// 取消授权
// ----------------------------------------------------------
function auth_del (req, res) {

Expand All @@ -256,27 +256,27 @@ function auth_del (req, res) {
}

// ----------------------------------------------------------
// 获取用户
// 获取用户
// ----------------------------------------------------------
exports.get_user = function (req, res) {

if ( req.query["cmd"] ) {
// 添加用户
// 添加用户
if ( req.query["cmd"] == "add" ) {
add_user ( req, res ) ;
// 删除用户
// 删除用户
} else if ( req.query["cmd"] == "del" ) {
del_user ( req, res ) ;
// 授权用户
// 授权用户
} else if ( req.query["cmd"] == "auth" ) {
auth_query ( req, res ) ;
// 查找用户
// 查找用户
} else if ( req.query["cmd"] == "find" ) {
find_user ( req, res ) ;
// 修改用户信息
// 修改用户信息
} else if ( req.query["cmd"] == "modify" ) {
mdf_user ( req, res ) ;
// 错误处理
// 错误处理
} else {
var data = {
"code": 1,
Expand All @@ -286,7 +286,7 @@ exports.get_user = function (req, res) {
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify(data));
}
// 分页用户列表
// 分页用户列表
} else {
var page = req.query['page'] - 1;
var limit = req.query['limit'];
Expand All @@ -306,29 +306,29 @@ exports.get_user = function (req, res) {
}

// ----------------------------------------------------------
// 设置用户
// 设置用户
// ----------------------------------------------------------
exports.set_user = function (req, res) {

if ( req.query["cmd"] ) {
// 添加用户
// 添加用户
if ( req.query["cmd"] == "add" ) {
add_user ( req, res ) ;
// 删除用
// 删除用
} else if ( req.query["cmd"] == "del" ) {
del_user ( req, res ) ;
} else if ( req.query["cmd"] == "auth" ) {
// 取消授权
// 取消授权
if ( req.query["id"] ) {
auth_del ( req, res ) ;
// 产生授权
// 产生授权
} else {
auth_user ( req, res ) ;
}
// 修改用户
// 修改用户
} else if ( req.query["cmd"] == "modify" ) {
mdf_user ( req, res ) ;
// 错误返回
// 错误返回
} else {
succ_response ( res, {} ) ;
}
Expand Down

0 comments on commit 43b6df9

Please sign in to comment.