Здравствуйте друзья,
У меня есть несколько вопросов об авторизации токена.
Сначала я делаю это в flussonic.conf
auth_backend main {
allow token Sometoken;
allow token Sometoken2;
allow ua “Mozilla/5.0 (Linux; Android 5.1.1) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Safari/537.36”;
backend http://magoware.apk/apiv2/token/flussonic/; }
stream Cinemax2HD {
url “1sturl” allow_subtitles=true;
url 2nd url allow_subtitles=true;
url 3rd url;
auth auth://main;
backup vod/error.mp4;
meta iptv “true”;
hds off;
rtmp off;
rtsp off;
dash off;
clients_timeout 600;
source_timeout 8;
}
когда я пытался воспроизвести некоторые каналы, я увидел это в журнале (LOG):
08:13:28.949 <0.12011.424> [Cinemax2HD] MINEIP UID:user_agent:Mozilla/5.0 (Linux; Android 5.1.1) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Safari/537.36)/IPADDRESS flu_session:723 Backend auth request “auth://main” ([{token,<<“0f0b1b5f576e82e4b5adfb591ad8ae7f7b722b93-SALT-1564045471-1564041871”>>}, {name,<<“Cinemax2HD”>>}, {ip,<<“MINEIP”>>}, {type,<<“mpegts”>>}, {pid,"<0.12011.424>"}],no_extra,[{media_request,mpegts_handler,request, [req,<<“Cinemax2HD”>>, #{auth => #{url => <<“auth://main”>>, url_orig => <<“auth://main”>>}, backup => <<“vod/error.mp4”>>,clients_timeout => 600, dash_off => true,hds_off => true, meta => #{iptv => <<“true”>>}, name => <<“Cinemax2HD”>>,position => 16,rtmp_off => true, rtsp_off => true,source_timeout => 8,static => true, urls => [#{allow_subtitles => <<“true”>>, url => <<"HTTPIN ">>}, #{allow_subtitles => <<“true”>>, url => <<“UDPIN”>>}, #{url => <<"UDPIN ">>}]}]}, {pid,<0.12011.424>}, {user_agent,<<“Mozilla/5.0 (Linux; Android 5.1.1) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Safari/537.36)”>>}, {host,<<“IPADDRESS”>>}, {qs,<<“token=0f0b1b5f576e82e4b5adfb591ad8ae7f7b722b93-SALT-1564045471-1564041871”>>}, {port,85}, {user_name,<<“Cinemax2HD”>>}, {stream_clients,1}, {stream_clients,1}]): Code: true, user_id: user_agent:Mozilla/5.0 (Linux; Android 5.1.1) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Safari/537.36)/MINEIP, time, 0ms
Там все ок? Потому что, когда я пытаюсь воспроизводить с VLC без TOKEN все начинается играть. Где я ошибаюсь?
Вот в бекенде конфиг (backend http://magoware.apk/apiv2/token/flussonic/;) :
“FLUSSONIC”: {
“TOKEN_KEY”: “testtoken”,
“SALT”: “salt”,
“PASSWORD”: “password”,
“WINDOW”: 3600
},
exports.flussonic_token_generator = function(req, res) {
var token_key = req.app.locals.streamtokens.FLUSSONIC.TOKEN_KEY; //server side only
var password = req.query.password || req.app.locals.streamtokens.FLUSSONIC.PASSWORD; //Can be sent as query parameter
var salt = req.query.salt || req.app.locals.streamtokens.FLUSSONIC.SALT; //Can be sent as query parametervar stream_name = req.params[0]; var ip = req.query.ip || req.ip.replace('::ffff:', ''); var starttime = req.query.starttime || Date.now()/1000|0; var endtime = req.query.endtime || (Date.now()/1000|0) + req.app.locals.streamtokens.FLUSSONIC.WINDOW;; var tohash = stream_name + ip + starttime + endtime + token_key + salt; var token = "?token="+mysha1(tohash)+ "-" + salt + "-" + endtime + "-" + starttime; var theresponse = new responses.OK(); theresponse.extra_data = token; res.send(theresponse);
};
exports.flussonic_token__remote = function(req, res) {
var stream_name = req.params.stream_name;
var token_url = req.query.tokenurl;
var password = ‘password’;
var salt = ‘salt’;
var ip = req.ip.replace(’::ffff:’, ‘’);
var starttime = Date.now();
var endtime = Date.now() + 1000;var queryparams = 'sing?' + 'password=' + password+'&name=' + stream_name + '&salt=' + salt + '&ip=' + ip + '&startime=' + starttime + '&endtime=' + endtime; request(token_url+queryparams, function (error, response, body) { var thisresponse = new responses.OK(); if(response.statusCode === 200) { thisresponse.extra_data = body; res.send(thisresponse); } else { res.send(thisresponse); } });
};