Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
aa587a71
提交
aa587a71
authored
12月 12, 2015
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove Syslog stuff.
上级
d899c399
全部展开
显示空白字符变更
内嵌
并排
正在显示
23 个修改的文件
包含
105 行增加
和
182 行删除
+105
-182
.gitignore
.gitignore
+1
-0
Server.js
lib/Server.js
+13
-4
mediasoup-worker
worker/bin/mediasoup-worker
+0
-0
Logger.h
worker/include/Logger.h
+9
-78
DTLSRole.h
worker/include/RTC/DTLSRole.h
+3
-2
Settings.h
worker/include/Settings.h
+5
-19
common.h
worker/include/common.h
+6
-0
DepLibSRTP.cpp
worker/src/DepLibSRTP.cpp
+1
-1
DepUsrSCTP.cpp
worker/src/DepUsrSCTP.cpp
+1
-1
Logger.cpp
worker/src/Logger.cpp
+0
-12
Loop.cpp
worker/src/Loop.cpp
+3
-3
DTLSHandler.cpp
worker/src/RTC/DTLSHandler.cpp
+13
-18
ICEServer.cpp
worker/src/RTC/ICEServer.cpp
+1
-1
Peer.cpp
worker/src/RTC/Peer.cpp
+3
-3
SRTPSession.cpp
worker/src/RTC/SRTPSession.cpp
+1
-1
TCPServer.cpp
worker/src/RTC/TCPServer.cpp
+10
-10
Transport.cpp
worker/src/RTC/Transport.cpp
+5
-5
UDPSocket.cpp
worker/src/RTC/UDPSocket.cpp
+10
-10
Settings.cpp
worker/src/Settings.cpp
+0
-0
TCPConnection.cpp
worker/src/handles/TCPConnection.cpp
+5
-5
UDPSocket.cpp
worker/src/handles/UDPSocket.cpp
+4
-4
UnixStreamSocket.cpp
worker/src/handles/UnixStreamSocket.cpp
+4
-4
main.cpp
worker/src/main.cpp
+7
-1
没有找到文件。
.gitignore
浏览文件 @
aa587a71
...
@@ -5,3 +5,4 @@
...
@@ -5,3 +5,4 @@
/worker/cldoc/
/worker/cldoc/
/worker/mediasoup-tester.sh
/worker/mediasoup-tester.sh
/TODO
/TODO
/test.js
lib/Server.js
浏览文件 @
aa587a71
...
@@ -17,8 +17,8 @@ const WORKER_BIN_PATH = path.join(__dirname, '..', 'worker', 'bin', 'mediasoup-w
...
@@ -17,8 +17,8 @@ const WORKER_BIN_PATH = path.join(__dirname, '..', 'worker', 'bin', 'mediasoup-w
const
DEFAULT_NUM_WORKERS
=
Object
.
keys
(
os
.
cpus
()).
length
;
const
DEFAULT_NUM_WORKERS
=
Object
.
keys
(
os
.
cpus
()).
length
;
const
VALID_PARAMETERS
=
const
VALID_PARAMETERS
=
[
[
'logLevel'
,
'
useSyslog'
,
'syslogFacility'
,
'rtcListenIPv4'
,
'rtcListenIPv6
'
,
'logLevel'
,
'
rtcListenIPv4'
,
'rtcListenIPv6'
,
'rtcMinPort'
,
'rtcMaxPort
'
,
'
rtcMinPort'
,
'rtcMaxPort'
,
'
dtlsCertificateFile'
,
'dtlsPrivateKeyFile'
'dtlsCertificateFile'
,
'dtlsPrivateKeyFile'
];
];
var
servers
=
new
Set
();
var
servers
=
new
Set
();
...
@@ -67,12 +67,19 @@ class Server
...
@@ -67,12 +67,19 @@ class Server
// Create mediasoup-worker child processes
// Create mediasoup-worker child processes
for
(
let
i
=
1
;
i
<=
numWorkers
;
i
++
)
for
(
let
i
=
1
;
i
<=
numWorkers
;
i
++
)
{
{
let
workerId
=
serverId
+
'#'
+
i
;
let
worker
;
let
worker
;
let
workerId
=
serverId
+
'#'
+
i
;
let
spawnArgs
=
[
workerId
].
concat
(
parameters
);
let
spawnOptions
=
{
detached
:
false
,
stdio
:
[
'pipe'
,
'pipe'
,
'pipe'
,
'ipc'
]
};
debug
(
'constructor() | creating worker [workerId:%s]'
,
workerId
);
debug
(
'constructor() | creating worker [workerId:%s]'
,
workerId
);
worker
=
spawn
(
WORKER_BIN_PATH
,
[
workerId
].
concat
(
parameters
));
// Create the worker child process
worker
=
spawn
(
WORKER_BIN_PATH
,
spawnArgs
,
spawnOptions
);
// Store worker id within the worker process
// Store worker id within the worker process
worker
.
workerId
=
workerId
;
worker
.
workerId
=
workerId
;
...
@@ -102,6 +109,8 @@ class Server
...
@@ -102,6 +109,8 @@ class Server
worker
.
on
(
'exit'
,
(
code
,
signal
)
=>
worker
.
on
(
'exit'
,
(
code
,
signal
)
=>
{
{
debug
(
'worker process closed [workerId:%s, code:%s, signal:%s]'
,
worker
.
workerId
,
code
,
signal
);
debug
(
'worker process closed [workerId:%s, code:%s, signal:%s]'
,
worker
.
workerId
,
code
,
signal
);
this
.
_workers
.
delete
(
worker
.
workerId
);
});
});
worker
.
on
(
'error'
,
(
error
)
=>
worker
.
on
(
'error'
,
(
error
)
=>
...
...
worker/bin/mediasoup-worker
deleted
100755 → 0
浏览文件 @
d899c399
File deleted
worker/include/Logger.h
浏览文件 @
aa587a71
...
@@ -8,10 +8,6 @@
...
@@ -8,10 +8,6 @@
#include <cstring>
#include <cstring>
#include <cstdlib> // std::_Exit(), std::abort()
#include <cstdlib> // std::_Exit(), std::abort()
#include <uv.h>
#include <uv.h>
extern
"C"
{
#include <syslog.h>
}
/*
/*
* Logger facility.
* Logger facility.
...
@@ -24,10 +20,8 @@ extern "C"
...
@@ -24,10 +20,8 @@ extern "C"
* - MS_TRACE() Shows current file/line/class/function.
* - MS_TRACE() Shows current file/line/class/function.
* - MS_DEBUG(...)
* - MS_DEBUG(...)
* - MS_INFO(...)
* - MS_INFO(...)
* - MS_NOTICE(...)
* - MS_WARN(...)
* - MS_WARN(...)
* - MS_ERROR(...)
* - MS_ERROR(...)
* - MS_CRIT(...)
* - MS_ABORT(...)
* - MS_ABORT(...)
*
*
* Arguments to those macros (except MS_TRACE) have the same format as printf.
* Arguments to those macros (except MS_TRACE) have the same format as printf.
...
@@ -45,7 +39,7 @@ extern "C"
...
@@ -45,7 +39,7 @@ extern "C"
/*
/*
* This macro must point to a unsigned int function, method or variable that
* This macro must point to a unsigned int function, method or variable that
* returns the
Syslog
logging level.
* returns the logging level.
*/
*/
#define MS_GET_LOG_LEVEL Settings::configuration.logLevel
#define MS_GET_LOG_LEVEL Settings::configuration.logLevel
...
@@ -55,14 +49,11 @@ public:
...
@@ -55,14 +49,11 @@ public:
static
void
Init
(
const
std
::
string
id
);
static
void
Init
(
const
std
::
string
id
);
static
const
char
*
GetProcessName
();
static
const
char
*
GetProcessName
();
static
const
char
*
GetProcessMinName
();
static
const
char
*
GetProcessMinName
();
static
void
EnableSyslog
();
static
bool
IsSyslogEnabled
();
static
bool
HasDebugLevel
();
static
bool
HasDebugLevel
();
private
:
private
:
static
std
::
string
processName
;
static
std
::
string
processName
;
static
std
::
string
processMinName
;
static
std
::
string
processMinName
;
static
bool
isSyslogEnabled
;
};
};
/* Inline static methods. */
/* Inline static methods. */
...
@@ -79,16 +70,10 @@ const char* Logger::GetProcessMinName()
...
@@ -79,16 +70,10 @@ const char* Logger::GetProcessMinName()
return
Logger
::
processMinName
.
c_str
();
return
Logger
::
processMinName
.
c_str
();
}
}
inline
bool
Logger
::
IsSyslogEnabled
()
{
return
Logger
::
isSyslogEnabled
;
}
inline
inline
bool
Logger
::
HasDebugLevel
()
bool
Logger
::
HasDebugLevel
()
{
{
return
(
LOG
_DEBUG
==
MS_GET_LOG_LEVEL
);
return
(
MS_LOG_LEVEL
_DEBUG
==
MS_GET_LOG_LEVEL
);
}
}
// NOTE: Each file including Logger.h MUST define its own MS_CLASS macro.
// NOTE: Each file including Logger.h MUST define its own MS_CLASS macro.
...
@@ -105,53 +90,22 @@ bool Logger::HasDebugLevel()
...
@@ -105,53 +90,22 @@ bool Logger::HasDebugLevel()
#endif
#endif
#define _MS_TO_STDOUT() \
#define _MS_TO_STDOUT() \
if (!Logger::IsSyslogEnabled()) \
{ \
std::fprintf(stdout, _MS_LOG_STR "\n", _MS_LOG_ARG); \
std::fprintf(stdout, _MS_LOG_STR "\n", _MS_LOG_ARG); \
fflush(stdout); \
fflush(stdout);
}
#define _MS_TO_STDOUT_DESC(desc, ...) \
#define _MS_TO_STDOUT_DESC(desc, ...) \
if (!Logger::IsSyslogEnabled()) \
{ \
std::fprintf(stdout, _MS_LOG_STR_DESC desc "\n", _MS_LOG_ARG, ##__VA_ARGS__); \
std::fprintf(stdout, _MS_LOG_STR_DESC desc "\n", _MS_LOG_ARG, ##__VA_ARGS__); \
fflush(stdout); \
fflush(stdout); \
}
#define _MS_TO_STDERR_DESC(desc, ...) \
#define _MS_TO_STDERR_DESC(desc, ...) \
if (!Logger::IsSyslogEnabled()) \
{ \
std::fprintf(stderr, _MS_LOG_STR_DESC desc "\n", _MS_LOG_ARG, ##__VA_ARGS__); \
std::fprintf(stderr, _MS_LOG_STR_DESC desc "\n", _MS_LOG_ARG, ##__VA_ARGS__); \
fflush(stderr); \
fflush(stderr); \
}
#define _MS_TO_SYSLOG(severity, prefix) \
if (Logger::IsSyslogEnabled()) \
syslog(severity, prefix _MS_LOG_STR, _MS_LOG_ARG);
#define _MS_TO_SYSLOG_DESC(severity, prefix, desc, ...) \
if (Logger::IsSyslogEnabled()) \
syslog(severity, prefix _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__);
/*
* Log levels in syslog.h:
*
* LOG_EMERG 0 system is unusable
* LOG_ALERT 1 action must be taken immediately
* LOG_CRIT 2 critical conditions
* LOG_ERR 3 error conditions
* LOG_WARNING 4 warning conditions
* LOG_NOTICE 5 normal but significant condition
* LOG_INFO 6 informational
* LOG_DEBUG 7 debug-level messages
*/
#ifdef MS_DEVEL
#ifdef MS_DEVEL
#define MS_TRACE() \
#define MS_TRACE() \
do \
do \
{ \
{ \
_MS_TO_STDOUT(); \
_MS_TO_STDOUT(); \
_MS_TO_SYSLOG(LOG_DEBUG, "TRACE "); \
} \
} \
while (0)
while (0)
#else
#else
...
@@ -161,10 +115,9 @@ bool Logger::HasDebugLevel()
...
@@ -161,10 +115,9 @@ bool Logger::HasDebugLevel()
#define MS_DEBUG(desc, ...) \
#define MS_DEBUG(desc, ...) \
do \
do \
{ \
{ \
if (
LOG
_DEBUG == MS_GET_LOG_LEVEL) \
if (
MS_LOG_LEVEL
_DEBUG == MS_GET_LOG_LEVEL) \
{ \
{ \
_MS_TO_STDOUT_DESC(desc, ##__VA_ARGS__); \
_MS_TO_STDOUT_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_DEBUG, "DEBUG ", desc, ##__VA_ARGS__); \
} \
} \
} \
} \
while (0)
while (0)
...
@@ -172,21 +125,9 @@ bool Logger::HasDebugLevel()
...
@@ -172,21 +125,9 @@ bool Logger::HasDebugLevel()
#define MS_INFO(desc, ...) \
#define MS_INFO(desc, ...) \
do \
do \
{ \
{ \
if (LOG_INFO <= MS_GET_LOG_LEVEL) \
if (MS_LOG_LEVEL_INFO <= MS_GET_LOG_LEVEL) \
{ \
_MS_TO_STDOUT_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_INFO, "INFO ", desc, ##__VA_ARGS__); \
} \
} \
while (0)
#define MS_NOTICE(desc, ...) \
do \
{ \
if (LOG_NOTICE <= MS_GET_LOG_LEVEL) \
{ \
{ \
_MS_TO_STDOUT_DESC(desc, ##__VA_ARGS__); \
_MS_TO_STDOUT_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_NOTICE, "NOTICE ", desc, ##__VA_ARGS__); \
} \
} \
} \
} \
while (0)
while (0)
...
@@ -194,10 +135,9 @@ bool Logger::HasDebugLevel()
...
@@ -194,10 +135,9 @@ bool Logger::HasDebugLevel()
#define MS_WARN(desc, ...) \
#define MS_WARN(desc, ...) \
do \
do \
{ \
{ \
if (
LOG_WARNING
<= MS_GET_LOG_LEVEL) \
if (
MS_LOG_LEVEL_WARN
<= MS_GET_LOG_LEVEL) \
{ \
{ \
_MS_TO_STDERR_DESC(desc, ##__VA_ARGS__); \
_MS_TO_STDERR_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_WARNING, "WARN ", desc, ##__VA_ARGS__); \
} \
} \
} \
} \
while (0)
while (0)
...
@@ -206,22 +146,13 @@ bool Logger::HasDebugLevel()
...
@@ -206,22 +146,13 @@ bool Logger::HasDebugLevel()
do \
do \
{ \
{ \
_MS_TO_STDERR_DESC(desc, ##__VA_ARGS__); \
_MS_TO_STDERR_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_ERR, "ERROR ", desc, ##__VA_ARGS__); \
} \
while (0)
#define MS_CRIT(desc, ...) \
do \
{ \
_MS_TO_STDERR_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_ERR, "CRIT ", desc, ##__VA_ARGS__); \
} \
} \
while (0)
while (0)
#define MS_EXIT_SUCCESS(desc, ...) \
#define MS_EXIT_SUCCESS(desc, ...) \
do \
do \
{ \
{ \
MS_
NOTICE
("SUCCESS EXIT | " desc, ##__VA_ARGS__); \
MS_
INFO
("SUCCESS EXIT | " desc, ##__VA_ARGS__); \
std::_Exit(EXIT_SUCCESS); \
std::_Exit(EXIT_SUCCESS); \
} \
} \
while (0)
while (0)
...
@@ -229,7 +160,7 @@ bool Logger::HasDebugLevel()
...
@@ -229,7 +160,7 @@ bool Logger::HasDebugLevel()
#define MS_EXIT_FAILURE(desc, ...) \
#define MS_EXIT_FAILURE(desc, ...) \
do \
do \
{ \
{ \
MS_
CRIT
("FAILURE EXIT | " desc, ##__VA_ARGS__); \
MS_
ERROR
("FAILURE EXIT | " desc, ##__VA_ARGS__); \
std::_Exit(EXIT_FAILURE); \
std::_Exit(EXIT_FAILURE); \
} \
} \
while (0)
while (0)
...
@@ -237,7 +168,7 @@ bool Logger::HasDebugLevel()
...
@@ -237,7 +168,7 @@ bool Logger::HasDebugLevel()
#define MS_ABORT(desc, ...) \
#define MS_ABORT(desc, ...) \
do \
do \
{ \
{ \
MS_
CRIT
("ABORT | " desc, ##__VA_ARGS__); \
MS_
ERROR
("ABORT | " desc, ##__VA_ARGS__); \
std::abort(); \
std::abort(); \
} \
} \
while (0)
while (0)
...
...
worker/include/RTC/DTLSRole.h
浏览文件 @
aa587a71
#ifndef MS_RTC_DTLS_ROLE_H
#ifndef MS_RTC_DTLS_ROLE_H
#define MS_RTC_DTLS_ROLE_H
#define MS_RTC_DTLS_ROLE_H
namespace
RTC
{
namespace
RTC
{
enum
class
DTLSRole
enum
class
DTLSRole
{
{
NONE
=
0
,
NONE
=
0
,
SERVER
=
1
,
SERVER
=
1
,
CLIENT
CLIENT
};
};
}
// namespace RTC
}
#endif
#endif
worker/include/Settings.h
浏览文件 @
aa587a71
...
@@ -4,10 +4,6 @@
...
@@ -4,10 +4,6 @@
#include "common.h"
#include "common.h"
#include <map>
#include <map>
#include <string>
#include <string>
extern
"C"
{
#include <syslog.h>
}
class
Settings
class
Settings
{
{
...
@@ -15,23 +11,16 @@ public:
...
@@ -15,23 +11,16 @@ public:
// Struct holding the configuration.
// Struct holding the configuration.
struct
Configuration
struct
Configuration
{
{
unsigned
int
logLevel
{
LOG_DEBUG
};
unsigned
int
logLevel
{
MS_LOG_LEVEL_DEBUG
};
bool
useSyslog
{
false
};
std
::
string
rtcListenIPv4
;
unsigned
int
syslogFacility
{
LOG_USER
};
std
::
string
rtcListenIPv6
;
MS_PORT
rtcMinPort
{
10000
};
struct
MS_PORT
rtcMaxPort
{
59999
};
{
std
::
string
listenIPv4
;
std
::
string
listenIPv6
;
MS_PORT
minPort
{
10000
};
MS_PORT
maxPort
{
59999
};
std
::
string
dtlsCertificateFile
;
std
::
string
dtlsCertificateFile
;
std
::
string
dtlsPrivateKeyFile
;
std
::
string
dtlsPrivateKeyFile
;
// Private fields.
// Private fields.
bool
hasIPv4
{
false
};
bool
hasIPv4
{
false
};
bool
hasIPv6
{
false
};
bool
hasIPv6
{
false
};
}
RTC
;
};
};
public
:
public
:
...
@@ -41,7 +30,6 @@ public:
...
@@ -41,7 +30,6 @@ public:
private
:
private
:
static
void
SetDefaultRtcListenIP
(
int
requested_family
);
static
void
SetDefaultRtcListenIP
(
int
requested_family
);
static
void
SetLogLevel
(
std
::
string
&
level
);
static
void
SetLogLevel
(
std
::
string
&
level
);
static
void
SetSyslogFacility
(
std
::
string
&
facility
);
static
void
SetRtcListenIPv4
(
const
std
::
string
&
ip
);
static
void
SetRtcListenIPv4
(
const
std
::
string
&
ip
);
static
void
SetRtcListenIPv6
(
const
std
::
string
&
ip
);
static
void
SetRtcListenIPv6
(
const
std
::
string
&
ip
);
static
void
SetRtcPorts
();
static
void
SetRtcPorts
();
...
@@ -53,8 +41,6 @@ public:
...
@@ -53,8 +41,6 @@ public:
private
:
private
:
static
std
::
map
<
std
::
string
,
unsigned
int
>
string2LogLevel
;
static
std
::
map
<
std
::
string
,
unsigned
int
>
string2LogLevel
;
static
std
::
map
<
unsigned
int
,
std
::
string
>
logLevel2String
;
static
std
::
map
<
unsigned
int
,
std
::
string
>
logLevel2String
;
static
std
::
map
<
std
::
string
,
unsigned
int
>
string2SyslogFacility
;
static
std
::
map
<
unsigned
int
,
std
::
string
>
syslogFacility2String
;
};
};
#endif
#endif
worker/include/common.h
浏览文件 @
aa587a71
...
@@ -7,9 +7,15 @@
...
@@ -7,9 +7,15 @@
#include <netinet/in.h> // sockaddr_in, sockaddr_in6
#include <netinet/in.h> // sockaddr_in, sockaddr_in6
#include <arpa/inet.h> // htonl(), htons(), ntohl(), ntohs()
#include <arpa/inet.h> // htonl(), htons(), ntohl(), ntohs()
#define MS_APP_NAME "mediasoup"
#define MS_PROCESS_NAME "mediasoup-worker"
#define MS_PROCESS_NAME "mediasoup-worker"
#define MS_PROCESS_MIN_NAME "worker"
#define MS_PROCESS_MIN_NAME "worker"
#define MS_LOG_LEVEL_DEBUG 3
#define MS_LOG_LEVEL_INFO 2
#define MS_LOG_LEVEL_WARN 1
#define MS_LOG_LEVEL_ERROR 0
#define MS_BYTE uint8_t
#define MS_BYTE uint8_t
#define MS_2BYTES uint16_t
#define MS_2BYTES uint16_t
#define MS_4BYTES uint32_t
#define MS_4BYTES uint32_t
...
...
worker/src/DepLibSRTP.cpp
浏览文件 @
aa587a71
...
@@ -57,5 +57,5 @@ void DepLibSRTP::ClassDestroy()
...
@@ -57,5 +57,5 @@ void DepLibSRTP::ClassDestroy()
err
=
srtp_shutdown
();
err
=
srtp_shutdown
();
if
(
DepLibSRTP
::
IsError
(
err
))
if
(
DepLibSRTP
::
IsError
(
err
))
MS_
CRIT
(
"srtp_shutdown() failed: %s"
,
DepLibSRTP
::
GetErrorString
(
err
));
MS_
ERROR
(
"srtp_shutdown() failed: %s"
,
DepLibSRTP
::
GetErrorString
(
err
));
}
}
worker/src/DepUsrSCTP.cpp
浏览文件 @
aa587a71
...
@@ -25,5 +25,5 @@ void DepUsrSCTP::ClassDestroy()
...
@@ -25,5 +25,5 @@ void DepUsrSCTP::ClassDestroy()
// Free usrsctp.
// Free usrsctp.
err
=
usrsctp_finish
();
err
=
usrsctp_finish
();
if
(
err
)
if
(
err
)
MS_
CRIT
(
"usrsctp_finish() failed"
);
MS_
ERROR
(
"usrsctp_finish() failed"
);
}
}
worker/src/Logger.cpp
浏览文件 @
aa587a71
...
@@ -6,7 +6,6 @@
...
@@ -6,7 +6,6 @@
std
::
string
Logger
::
processName
;
std
::
string
Logger
::
processName
;
std
::
string
Logger
::
processMinName
;
std
::
string
Logger
::
processMinName
;
bool
Logger
::
isSyslogEnabled
=
false
;
/* Static methods. */
/* Static methods. */
...
@@ -17,14 +16,3 @@ void Logger::Init(const std::string id)
...
@@ -17,14 +16,3 @@ void Logger::Init(const std::string id)
MS_TRACE
();
MS_TRACE
();
}
}
void
Logger
::
EnableSyslog
()
{
MS_TRACE
();
MS_DEBUG
(
"logging to Syslog"
);
openlog
(
MS_PROCESS_NAME
,
(
LOG_PID
),
Settings
::
configuration
.
syslogFacility
);
Logger
::
isSyslogEnabled
=
true
;
}
worker/src/Loop.cpp
浏览文件 @
aa587a71
...
@@ -62,17 +62,17 @@ void Loop::onSignal(SignalsHandler* signalsHandler, int signum)
...
@@ -62,17 +62,17 @@ void Loop::onSignal(SignalsHandler* signalsHandler, int signum)
switch
(
signum
)
switch
(
signum
)
{
{
case
SIGINT
:
case
SIGINT
:
MS_
NOTICE
(
"signal INT received, exiting"
);
MS_
DEBUG
(
"signal INT received, exiting"
);
Close
();
Close
();
break
;
break
;
case
SIGTERM
:
case
SIGTERM
:
MS_
NOTICE
(
"signal TERM received, exiting"
);
MS_
DEBUG
(
"signal TERM received, exiting"
);
Close
();
Close
();
break
;
break
;
default
:
default
:
MS_
ERROR
(
"received a signal (with signum %d) for which there is no handling code"
,
signum
);
MS_
WARN
(
"received a signal (with signum %d) for which there is no handling code"
,
signum
);
}
}
}
}
...
...
worker/src/RTC/DTLSHandler.cpp
浏览文件 @
aa587a71
...
@@ -84,7 +84,7 @@ namespace RTC
...
@@ -84,7 +84,7 @@ namespace RTC
MS_TRACE
();
MS_TRACE
();
// Generate a X509 certificate and private key (unless PEM files are provided).
// Generate a X509 certificate and private key (unless PEM files are provided).
if
(
Settings
::
configuration
.
RTC
.
dtlsCertificateFile
.
empty
()
||
Settings
::
configuration
.
RTC
.
dtlsPrivateKeyFile
.
empty
())
if
(
Settings
::
configuration
.
dtlsCertificateFile
.
empty
()
||
Settings
::
configuration
.
dtlsPrivateKeyFile
.
empty
())
GenerateCertificateAndPrivateKey
();
GenerateCertificateAndPrivateKey
();
else
else
ReadCertificateAndPrivateKeyFromFiles
();
ReadCertificateAndPrivateKeyFromFiles
();
...
@@ -207,8 +207,8 @@ namespace RTC
...
@@ -207,8 +207,8 @@ namespace RTC
LOG_OPENSSL_ERROR
(
"X509_get_subject_name() failed"
);
LOG_OPENSSL_ERROR
(
"X509_get_subject_name() failed"
);
goto
error
;
goto
error
;
}
}
X509_NAME_add_entry_by_txt
(
cert_name
,
"O"
,
MBSTRING_ASC
,
(
unsigned
char
*
)
MS_
PROCESS
_NAME
,
-
1
,
-
1
,
0
);
X509_NAME_add_entry_by_txt
(
cert_name
,
"O"
,
MBSTRING_ASC
,
(
unsigned
char
*
)
MS_
APP
_NAME
,
-
1
,
-
1
,
0
);
X509_NAME_add_entry_by_txt
(
cert_name
,
"CN"
,
MBSTRING_ASC
,
(
unsigned
char
*
)
MS_
PROCESS
_NAME
,
-
1
,
-
1
,
0
);
X509_NAME_add_entry_by_txt
(
cert_name
,
"CN"
,
MBSTRING_ASC
,
(
unsigned
char
*
)
MS_
APP
_NAME
,
-
1
,
-
1
,
0
);
// It is self signed so set the issuer name to be the same as the subject.
// It is self signed so set the issuer name to be the same as the subject.
ret
=
X509_set_issuer_name
(
DTLSHandler
::
certificate
,
cert_name
);
ret
=
X509_set_issuer_name
(
DTLSHandler
::
certificate
,
cert_name
);
...
@@ -249,7 +249,7 @@ namespace RTC
...
@@ -249,7 +249,7 @@ namespace RTC
FILE
*
file
=
nullptr
;
FILE
*
file
=
nullptr
;
file
=
fopen
(
Settings
::
configuration
.
RTC
.
dtlsCertificateFile
.
c_str
(),
"r"
);
file
=
fopen
(
Settings
::
configuration
.
dtlsCertificateFile
.
c_str
(),
"r"
);
if
(
!
file
)
if
(
!
file
)
{
{
MS_ERROR
(
"error reading DTLS certificate file: %s"
,
std
::
strerror
(
errno
));
MS_ERROR
(
"error reading DTLS certificate file: %s"
,
std
::
strerror
(
errno
));
...
@@ -263,7 +263,7 @@ namespace RTC
...
@@ -263,7 +263,7 @@ namespace RTC
}
}
fclose
(
file
);
fclose
(
file
);
file
=
fopen
(
Settings
::
configuration
.
RTC
.
dtlsPrivateKeyFile
.
c_str
(),
"r"
);
file
=
fopen
(
Settings
::
configuration
.
dtlsPrivateKeyFile
.
c_str
(),
"r"
);
if
(
!
file
)
if
(
!
file
)
{
{
MS_ERROR
(
"error reading DTLS private key file: %s"
,
std
::
strerror
(
errno
));
MS_ERROR
(
"error reading DTLS private key file: %s"
,
std
::
strerror
(
errno
));
...
@@ -694,7 +694,7 @@ namespace RTC
...
@@ -694,7 +694,7 @@ namespace RTC
{
{
if
(
!
this
->
isConnected
)
if
(
!
this
->
isConnected
)
{
{
MS_
NOTICE
(
"ignoring application data received while DTLS not fully connected"
);
MS_
DEBUG
(
"ignoring application data received while DTLS not fully connected"
);
return
;
return
;
}
}
...
@@ -760,33 +760,28 @@ namespace RTC
...
@@ -760,33 +760,28 @@ namespace RTC
switch
(
err
)
switch
(
err
)
{
{
case
SSL_ERROR_NONE
:
case
SSL_ERROR_NONE
:
// MS_DEBUG("SSL status: SSL_ERROR_NONE");
break
;
break
;
case
SSL_ERROR_SSL
:
case
SSL_ERROR_SSL
:
// MS_NOTICE("SSL status: SSL_ERROR_SSL");
LOG_OPENSSL_ERROR
(
"SSL status: SSL_ERROR_SSL"
);
LOG_OPENSSL_ERROR
(
"SSL status: SSL_ERROR_SSL"
);
break
;
break
;
case
SSL_ERROR_WANT_READ
:
case
SSL_ERROR_WANT_READ
:
// MS_DEBUG("SSL status: SSL_ERROR_WANT_READ");
break
;
break
;
case
SSL_ERROR_WANT_WRITE
:
case
SSL_ERROR_WANT_WRITE
:
MS_DEBUG
(
"SSL status: SSL_ERROR_WANT_WRITE"
);
MS_DEBUG
(
"SSL status: SSL_ERROR_WANT_WRITE"
);
break
;
break
;
case
SSL_ERROR_WANT_X509_LOOKUP
:
case
SSL_ERROR_WANT_X509_LOOKUP
:
MS_
NOTICE
(
"SSL status: SSL_ERROR_WANT_X509_LOOKUP"
);
MS_
DEBUG
(
"SSL status: SSL_ERROR_WANT_X509_LOOKUP"
);
break
;
break
;
case
SSL_ERROR_SYSCALL
:
case
SSL_ERROR_SYSCALL
:
// MS_WARN("SSL status: SSL_ERROR_SYSCALL");
LOG_OPENSSL_ERROR
(
"SSL status: SSL_ERROR_SYSCALL"
);
LOG_OPENSSL_ERROR
(
"SSL status: SSL_ERROR_SYSCALL"
);
break
;
break
;
case
SSL_ERROR_ZERO_RETURN
:
case
SSL_ERROR_ZERO_RETURN
:
// MS_DEBUG("SSL status: SSL_ERROR_ZERO_RETURN");
break
;
break
;
case
SSL_ERROR_WANT_CONNECT
:
case
SSL_ERROR_WANT_CONNECT
:
MS_
WARN
(
"SSL status: SSL_ERROR_WANT_CONNECT"
);
MS_
DEBUG
(
"SSL status: SSL_ERROR_WANT_CONNECT"
);
break
;
break
;
case
SSL_ERROR_WANT_ACCEPT
:
case
SSL_ERROR_WANT_ACCEPT
:
MS_
WARN
(
"SSL status: SSL_ERROR_WANT_ACCEPT"
);
MS_
DEBUG
(
"SSL status: SSL_ERROR_WANT_ACCEPT"
);
break
;
break
;
}
}
...
@@ -822,7 +817,7 @@ namespace RTC
...
@@ -822,7 +817,7 @@ namespace RTC
}
}
else
else
{
{
MS_
NOTICE
(
"DTLS connection failed"
);
MS_
DEBUG
(
"DTLS connection failed"
);
// Notify to the listener.
// Notify to the listener.
this
->
listener
->
onDTLSFailed
(
this
);
this
->
listener
->
onDTLSFailed
(
this
);
...
@@ -949,7 +944,7 @@ namespace RTC
...
@@ -949,7 +944,7 @@ namespace RTC
}
}
else
else
{
{
MS_
NOTICE
(
"SRTP profile not negotiated"
);
MS_
DEBUG
(
"SRTP profile not negotiated"
);
}
}
}
}
...
@@ -1021,7 +1016,7 @@ namespace RTC
...
@@ -1021,7 +1016,7 @@ namespace RTC
if
(
this
->
remoteFingerprint
.
compare
(
hex_fingerprint
)
!=
0
)
if
(
this
->
remoteFingerprint
.
compare
(
hex_fingerprint
)
!=
0
)
{
{
MS_
NOTICE
(
"fingerprint in the remote certificate (%s) does not match the announced one (%s)"
,
hex_fingerprint
,
this
->
remoteFingerprint
.
c_str
());
MS_
DEBUG
(
"fingerprint in the remote certificate (%s) does not match the announced one (%s)"
,
hex_fingerprint
,
this
->
remoteFingerprint
.
c_str
());
return
false
;
return
false
;
}
}
...
@@ -1145,7 +1140,7 @@ namespace RTC
...
@@ -1145,7 +1140,7 @@ namespace RTC
else
if
(
where
&
SSL_CB_EXIT
)
else
if
(
where
&
SSL_CB_EXIT
)
{
{
if
(
ret
==
0
)
if
(
ret
==
0
)
MS_
NOTICE
(
"role: %s | failed in: %s"
,
role
,
SSL_state_string_long
(
this
->
ssl
));
MS_
DEBUG
(
"role: %s | failed in: %s"
,
role
,
SSL_state_string_long
(
this
->
ssl
));
else
if
(
ret
<
0
)
else
if
(
ret
<
0
)
MS_DEBUG
(
"role: %s | waiting for: %s"
,
role
,
SSL_state_string_long
(
this
->
ssl
));
MS_DEBUG
(
"role: %s | waiting for: %s"
,
role
,
SSL_state_string_long
(
this
->
ssl
));
}
}
...
...
worker/src/RTC/ICEServer.cpp
浏览文件 @
aa587a71
...
@@ -126,7 +126,7 @@ namespace RTC
...
@@ -126,7 +126,7 @@ namespace RTC
// The remote peer must be ICE controlling.
// The remote peer must be ICE controlling.
if
(
msg
->
GetIceControlled
())
if
(
msg
->
GetIceControlled
())
{
{
MS_
NOTICE
(
"peer indicates ICE-CONTROLLED in STUN Binding Request => 487"
);
MS_
DEBUG
(
"peer indicates ICE-CONTROLLED in STUN Binding Request => 487"
);
// Reply 487 (Role Conflict).
// Reply 487 (Role Conflict).
RTC
::
STUNMessage
*
response
=
msg
->
CreateErrorResponse
(
487
);
RTC
::
STUNMessage
*
response
=
msg
->
CreateErrorResponse
(
487
);
...
...
worker/src/RTC/Peer.cpp
浏览文件 @
aa587a71
...
@@ -36,7 +36,7 @@ namespace RTC
...
@@ -36,7 +36,7 @@ namespace RTC
{
{
RTC
::
UDPSocket
*
socket
=
RTC
::
UDPSocket
::
New
(
AF_INET
);
RTC
::
UDPSocket
*
socket
=
RTC
::
UDPSocket
::
New
(
AF_INET
);
this
->
transport
->
AddUDPSocket
(
socket
);
this
->
transport
->
AddUDPSocket
(
socket
);
MS_
NOTICE
(
"---- TEST: transport listens in IPv4 UDP '%s' : %u"
,
socket
->
GetLocalIP
().
c_str
(),
socket
->
GetLocalPort
());
MS_
INFO
(
"---- TEST: transport listens in IPv4 UDP '%s' : %u"
,
socket
->
GetLocalIP
().
c_str
(),
socket
->
GetLocalPort
());
}
}
catch
(
const
MediaSoupError
&
error
)
catch
(
const
MediaSoupError
&
error
)
{
{
...
@@ -47,7 +47,7 @@ namespace RTC
...
@@ -47,7 +47,7 @@ namespace RTC
{
{
RTC
::
TCPServer
*
server
=
RTC
::
TCPServer
::
New
(
AF_INET
);
RTC
::
TCPServer
*
server
=
RTC
::
TCPServer
::
New
(
AF_INET
);
this
->
transport
->
AddTCPServer
(
server
);
this
->
transport
->
AddTCPServer
(
server
);
MS_
NOTICE
(
"---- TEST: transport listens in IPv4 TCP '%s' : %u"
,
server
->
GetLocalIP
().
c_str
(),
server
->
GetLocalPort
());
MS_
INFO
(
"---- TEST: transport listens in IPv4 TCP '%s' : %u"
,
server
->
GetLocalIP
().
c_str
(),
server
->
GetLocalPort
());
}
}
catch
(
const
MediaSoupError
&
error
)
catch
(
const
MediaSoupError
&
error
)
{
{
...
@@ -112,4 +112,4 @@ namespace RTC
...
@@ -112,4 +112,4 @@ namespace RTC
this
->
listener
->
onRTCPPacket
(
this
,
packet
);
this
->
listener
->
onRTCPPacket
(
this
,
packet
);
}
}
}
// namespace RTC
}
worker/src/RTC/SRTPSession.cpp
浏览文件 @
aa587a71
...
@@ -51,7 +51,7 @@ namespace RTC
...
@@ -51,7 +51,7 @@ namespace RTC
break
;
break
;
}
}
MS_
NOTICE
(
"SSRC %llu: %s"
,
(
unsigned
long
long
)
data
->
stream
->
ssrc
,
event_desc
);
MS_
WARN
(
"SSRC %llu: %s"
,
(
unsigned
long
long
)
data
->
stream
->
ssrc
,
event_desc
);
}
}
/* Instance methods. */
/* Instance methods. */
...
...
worker/src/RTC/TCPServer.cpp
浏览文件 @
aa587a71
...
@@ -41,22 +41,22 @@ namespace RTC
...
@@ -41,22 +41,22 @@ namespace RTC
int
err
;
int
err
;
if
(
!
Settings
::
configuration
.
RTC
.
l
istenIPv4
.
empty
())
if
(
!
Settings
::
configuration
.
rtcL
istenIPv4
.
empty
())
{
{
err
=
uv_ip4_addr
(
Settings
::
configuration
.
RTC
.
l
istenIPv4
.
c_str
(),
0
,
(
struct
sockaddr_in
*
)
&
RTC
::
TCPServer
::
sockaddrStorageIPv4
);
err
=
uv_ip4_addr
(
Settings
::
configuration
.
rtcL
istenIPv4
.
c_str
(),
0
,
(
struct
sockaddr_in
*
)
&
RTC
::
TCPServer
::
sockaddrStorageIPv4
);
if
(
err
)
if
(
err
)
MS_ABORT
(
"uv_ipv4_addr() failed: %s"
,
uv_strerror
(
err
));
MS_ABORT
(
"uv_ipv4_addr() failed: %s"
,
uv_strerror
(
err
));
}
}
if
(
!
Settings
::
configuration
.
RTC
.
l
istenIPv6
.
empty
())
if
(
!
Settings
::
configuration
.
rtcL
istenIPv6
.
empty
())
{
{
err
=
uv_ip6_addr
(
Settings
::
configuration
.
RTC
.
l
istenIPv6
.
c_str
(),
0
,
(
struct
sockaddr_in6
*
)
&
RTC
::
TCPServer
::
sockaddrStorageIPv6
);
err
=
uv_ip6_addr
(
Settings
::
configuration
.
rtcL
istenIPv6
.
c_str
(),
0
,
(
struct
sockaddr_in6
*
)
&
RTC
::
TCPServer
::
sockaddrStorageIPv6
);
if
(
err
)
if
(
err
)
MS_ABORT
(
"uv_ipv6_addr() failed: %s"
,
uv_strerror
(
err
));
MS_ABORT
(
"uv_ipv6_addr() failed: %s"
,
uv_strerror
(
err
));
}
}
TCPServer
::
minPort
=
Settings
::
configuration
.
RTC
.
m
inPort
;
TCPServer
::
minPort
=
Settings
::
configuration
.
rtcM
inPort
;
TCPServer
::
maxPort
=
Settings
::
configuration
.
RTC
.
m
axPort
;
TCPServer
::
maxPort
=
Settings
::
configuration
.
rtcM
axPort
;
MS_PORT
i
=
RTC
::
TCPServer
::
minPort
;
MS_PORT
i
=
RTC
::
TCPServer
::
minPort
;
do
do
...
@@ -98,9 +98,9 @@ namespace RTC
...
@@ -98,9 +98,9 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
if
(
address_family
==
AF_INET
&&
!
Settings
::
configuration
.
RTC
.
hasIPv4
)
if
(
address_family
==
AF_INET
&&
!
Settings
::
configuration
.
hasIPv4
)
MS_THROW_ERROR
(
"IPv4 family not available for RTC"
);
MS_THROW_ERROR
(
"IPv4 family not available for RTC"
);
else
if
(
address_family
==
AF_INET6
&&
!
Settings
::
configuration
.
RTC
.
hasIPv6
)
else
if
(
address_family
==
AF_INET6
&&
!
Settings
::
configuration
.
hasIPv6
)
MS_THROW_ERROR
(
"IPv6 family not available for RTC"
);
MS_THROW_ERROR
(
"IPv6 family not available for RTC"
);
int
err
;
int
err
;
...
@@ -121,14 +121,14 @@ namespace RTC
...
@@ -121,14 +121,14 @@ namespace RTC
available_ports
=
&
RTC
::
TCPServer
::
availableIPv4Ports
;
available_ports
=
&
RTC
::
TCPServer
::
availableIPv4Ports
;
first_bind_addr
=
RTC
::
TCPServer
::
sockaddrStorageIPv4
;
first_bind_addr
=
RTC
::
TCPServer
::
sockaddrStorageIPv4
;
second_bind_addr
=
RTC
::
TCPServer
::
sockaddrStorageIPv4
;
second_bind_addr
=
RTC
::
TCPServer
::
sockaddrStorageIPv4
;
listenIP
=
Settings
::
configuration
.
RTC
.
l
istenIPv4
.
c_str
();
listenIP
=
Settings
::
configuration
.
rtcL
istenIPv4
.
c_str
();
break
;
break
;
case
AF_INET6
:
case
AF_INET6
:
available_ports
=
&
RTC
::
TCPServer
::
availableIPv6Ports
;
available_ports
=
&
RTC
::
TCPServer
::
availableIPv6Ports
;
first_bind_addr
=
RTC
::
TCPServer
::
sockaddrStorageIPv6
;
first_bind_addr
=
RTC
::
TCPServer
::
sockaddrStorageIPv6
;
second_bind_addr
=
RTC
::
TCPServer
::
sockaddrStorageIPv6
;
second_bind_addr
=
RTC
::
TCPServer
::
sockaddrStorageIPv6
;
listenIP
=
Settings
::
configuration
.
RTC
.
l
istenIPv6
.
c_str
();
listenIP
=
Settings
::
configuration
.
rtcL
istenIPv6
.
c_str
();
// Don't also bind into IPv4 when listening in IPv6.
// Don't also bind into IPv4 when listening in IPv6.
flags
|=
UV_TCP_IPV6ONLY
;
flags
|=
UV_TCP_IPV6ONLY
;
break
;
break
;
...
...
worker/src/RTC/Transport.cpp
浏览文件 @
aa587a71
...
@@ -427,7 +427,7 @@ namespace RTC
...
@@ -427,7 +427,7 @@ namespace RTC
RTC
::
RTPPacket
*
packet
=
RTC
::
RTPPacket
::
Parse
(
data
,
len
);
RTC
::
RTPPacket
*
packet
=
RTC
::
RTPPacket
::
Parse
(
data
,
len
);
if
(
!
packet
)
if
(
!
packet
)
{
{
MS_
NOTICE
(
"data received via %s is not a valid RTP packet"
,
TRANSPORT_NAME
(
source
));
MS_
DEBUG
(
"data received via %s is not a valid RTP packet"
,
TRANSPORT_NAME
(
source
));
return
;
return
;
}
}
// MS_DEBUG("valid RTP packet received via %s [ssrc: %llu | payload: %hu | size: %zu]",
// MS_DEBUG("valid RTP packet received via %s [ssrc: %llu | payload: %hu | size: %zu]",
...
@@ -460,7 +460,7 @@ namespace RTC
...
@@ -460,7 +460,7 @@ namespace RTC
if
(
!
this
->
srtpRecvSession
->
DecryptSRTCP
(
data
,
&
len
))
if
(
!
this
->
srtpRecvSession
->
DecryptSRTCP
(
data
,
&
len
))
{
{
MS_
WARN
(
"error decrypting SRTCP packet received via %s: %s"
,
TRANSPORT_NAME
(
source
),
this
->
srtpRecvSession
->
GetLastErrorDesc
());
MS_
DEBUG
(
"error decrypting SRTCP packet received via %s: %s"
,
TRANSPORT_NAME
(
source
),
this
->
srtpRecvSession
->
GetLastErrorDesc
());
return
;
return
;
}
}
}
}
...
@@ -468,7 +468,7 @@ namespace RTC
...
@@ -468,7 +468,7 @@ namespace RTC
RTC
::
RTCPPacket
*
packet
=
RTC
::
RTCPPacket
::
Parse
(
data
,
len
);
RTC
::
RTCPPacket
*
packet
=
RTC
::
RTCPPacket
::
Parse
(
data
,
len
);
if
(
!
packet
)
if
(
!
packet
)
{
{
MS_
NOTICE
(
"data received via %s is not a valid RTCP packet"
,
TRANSPORT_NAME
(
source
));
MS_
DEBUG
(
"data received via %s is not a valid RTCP packet"
,
TRANSPORT_NAME
(
source
));
return
;
return
;
}
}
// MS_DEBUG("valid RTCP packet received via %s", TRANSPORT_NAME(source));
// MS_DEBUG("valid RTCP packet received via %s", TRANSPORT_NAME(source));
...
@@ -598,7 +598,7 @@ namespace RTC
...
@@ -598,7 +598,7 @@ namespace RTC
if
(
!
this
->
sendingSource
)
if
(
!
this
->
sendingSource
)
{
{
MS_
ERROR
(
"no sending address set, cannot send DTLS packet"
);
MS_
WARN
(
"no sending address set, cannot send DTLS packet"
);
return
;
return
;
}
}
...
@@ -630,7 +630,7 @@ namespace RTC
...
@@ -630,7 +630,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
MS_
NOTICE
(
"DTLS failed"
);
MS_
DEBUG
(
"DTLS failed"
);
Reset
();
Reset
();
Dump
();
Dump
();
...
...
worker/src/RTC/UDPSocket.cpp
浏览文件 @
aa587a71
...
@@ -41,22 +41,22 @@ namespace RTC
...
@@ -41,22 +41,22 @@ namespace RTC
int
err
;
int
err
;
if
(
Settings
::
configuration
.
RTC
.
hasIPv4
)
if
(
Settings
::
configuration
.
hasIPv4
)
{
{
err
=
uv_ip4_addr
(
Settings
::
configuration
.
RTC
.
l
istenIPv4
.
c_str
(),
0
,
(
struct
sockaddr_in
*
)
&
RTC
::
UDPSocket
::
sockaddrStorageIPv4
);
err
=
uv_ip4_addr
(
Settings
::
configuration
.
rtcL
istenIPv4
.
c_str
(),
0
,
(
struct
sockaddr_in
*
)
&
RTC
::
UDPSocket
::
sockaddrStorageIPv4
);
if
(
err
)
if
(
err
)
MS_ABORT
(
"uv_ipv4_addr() failed: %s"
,
uv_strerror
(
err
));
MS_ABORT
(
"uv_ipv4_addr() failed: %s"
,
uv_strerror
(
err
));
}
}
if
(
Settings
::
configuration
.
RTC
.
hasIPv6
)
if
(
Settings
::
configuration
.
hasIPv6
)
{
{
err
=
uv_ip6_addr
(
Settings
::
configuration
.
RTC
.
l
istenIPv6
.
c_str
(),
0
,
(
struct
sockaddr_in6
*
)
&
RTC
::
UDPSocket
::
sockaddrStorageIPv6
);
err
=
uv_ip6_addr
(
Settings
::
configuration
.
rtcL
istenIPv6
.
c_str
(),
0
,
(
struct
sockaddr_in6
*
)
&
RTC
::
UDPSocket
::
sockaddrStorageIPv6
);
if
(
err
)
if
(
err
)
MS_ABORT
(
"uv_ipv6_addr() failed: %s"
,
uv_strerror
(
err
));
MS_ABORT
(
"uv_ipv6_addr() failed: %s"
,
uv_strerror
(
err
));
}
}
UDPSocket
::
minPort
=
Settings
::
configuration
.
RTC
.
m
inPort
;
UDPSocket
::
minPort
=
Settings
::
configuration
.
rtcM
inPort
;
UDPSocket
::
maxPort
=
Settings
::
configuration
.
RTC
.
m
axPort
;
UDPSocket
::
maxPort
=
Settings
::
configuration
.
rtcM
axPort
;
MS_PORT
i
=
RTC
::
UDPSocket
::
minPort
;
MS_PORT
i
=
RTC
::
UDPSocket
::
minPort
;
do
do
...
@@ -98,9 +98,9 @@ namespace RTC
...
@@ -98,9 +98,9 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
if
(
address_family
==
AF_INET
&&
!
Settings
::
configuration
.
RTC
.
hasIPv4
)
if
(
address_family
==
AF_INET
&&
!
Settings
::
configuration
.
hasIPv4
)
MS_THROW_ERROR
(
"IPv4 family not available for RTC"
);
MS_THROW_ERROR
(
"IPv4 family not available for RTC"
);
else
if
(
address_family
==
AF_INET6
&&
!
Settings
::
configuration
.
RTC
.
hasIPv6
)
else
if
(
address_family
==
AF_INET6
&&
!
Settings
::
configuration
.
hasIPv6
)
MS_THROW_ERROR
(
"IPv6 family not available for RTC"
);
MS_THROW_ERROR
(
"IPv6 family not available for RTC"
);
int
err
;
int
err
;
...
@@ -121,14 +121,14 @@ namespace RTC
...
@@ -121,14 +121,14 @@ namespace RTC
available_ports
=
&
RTC
::
UDPSocket
::
availableIPv4Ports
;
available_ports
=
&
RTC
::
UDPSocket
::
availableIPv4Ports
;
first_bind_addr
=
RTC
::
UDPSocket
::
sockaddrStorageIPv4
;
first_bind_addr
=
RTC
::
UDPSocket
::
sockaddrStorageIPv4
;
second_bind_addr
=
RTC
::
UDPSocket
::
sockaddrStorageIPv4
;
second_bind_addr
=
RTC
::
UDPSocket
::
sockaddrStorageIPv4
;
listenIP
=
Settings
::
configuration
.
RTC
.
l
istenIPv4
.
c_str
();
listenIP
=
Settings
::
configuration
.
rtcL
istenIPv4
.
c_str
();
break
;
break
;
case
AF_INET6
:
case
AF_INET6
:
available_ports
=
&
RTC
::
UDPSocket
::
availableIPv6Ports
;
available_ports
=
&
RTC
::
UDPSocket
::
availableIPv6Ports
;
first_bind_addr
=
RTC
::
UDPSocket
::
sockaddrStorageIPv6
;
first_bind_addr
=
RTC
::
UDPSocket
::
sockaddrStorageIPv6
;
second_bind_addr
=
RTC
::
UDPSocket
::
sockaddrStorageIPv6
;
second_bind_addr
=
RTC
::
UDPSocket
::
sockaddrStorageIPv6
;
listenIP
=
Settings
::
configuration
.
RTC
.
l
istenIPv6
.
c_str
();
listenIP
=
Settings
::
configuration
.
rtcL
istenIPv6
.
c_str
();
// Don't also bind into IPv4 when listening in IPv6.
// Don't also bind into IPv4 when listening in IPv6.
flags
|=
UV_UDP_IPV6ONLY
;
flags
|=
UV_UDP_IPV6ONLY
;
break
;
break
;
...
...
worker/src/Settings.cpp
浏览文件 @
aa587a71
差异被折叠。
点击展开。
worker/src/handles/TCPConnection.cpp
浏览文件 @
aa587a71
...
@@ -154,7 +154,7 @@ void TCPConnection::Write(const MS_BYTE* data, size_t len)
...
@@ -154,7 +154,7 @@ void TCPConnection::Write(const MS_BYTE* data, size_t len)
// Error. Should not happen.
// Error. Should not happen.
else
if
(
written
<
0
)
else
if
(
written
<
0
)
{
{
MS_
NOTICE
(
"uv_try_write() failed: %s | closing the connection"
,
uv_strerror
(
written
));
MS_
WARN
(
"uv_try_write() failed: %s | closing the connection"
,
uv_strerror
(
written
));
Close
();
Close
();
return
;
return
;
}
}
...
@@ -216,7 +216,7 @@ void TCPConnection::Write(const MS_BYTE* data1, size_t len1, const MS_BYTE* data
...
@@ -216,7 +216,7 @@ void TCPConnection::Write(const MS_BYTE* data1, size_t len1, const MS_BYTE* data
// Error. Should not happen.
// Error. Should not happen.
else
if
(
written
<
0
)
else
if
(
written
<
0
)
{
{
MS_
NOTICE
(
"uv_try_write() failed: %s | closing the connection"
,
uv_strerror
(
written
));
MS_
WARN
(
"uv_try_write() failed: %s | closing the connection"
,
uv_strerror
(
written
));
Close
();
Close
();
return
;
return
;
}
}
...
@@ -366,7 +366,7 @@ void TCPConnection::onUvRead(ssize_t nread, const uv_buf_t* buf)
...
@@ -366,7 +366,7 @@ void TCPConnection::onUvRead(ssize_t nread, const uv_buf_t* buf)
// Some error.
// Some error.
else
else
{
{
MS_
NOTICE
(
"read error: %s | closing the connection"
,
uv_strerror
(
nread
));
MS_
INFO
(
"read error: %s | closing the connection"
,
uv_strerror
(
nread
));
this
->
hasError
=
true
;
this
->
hasError
=
true
;
// Close server side of the connection.
// Close server side of the connection.
...
@@ -389,7 +389,7 @@ void TCPConnection::onUvWriteError(int error)
...
@@ -389,7 +389,7 @@ void TCPConnection::onUvWriteError(int error)
}
}
else
else
{
{
MS_
NOTICE
(
"write error: %s | closing the connection"
,
uv_strerror
(
error
));
MS_
INFO
(
"write error: %s | closing the connection"
,
uv_strerror
(
error
));
this
->
hasError
=
true
;
this
->
hasError
=
true
;
}
}
...
@@ -406,7 +406,7 @@ void TCPConnection::onUvShutdown(uv_shutdown_t* req, int status)
...
@@ -406,7 +406,7 @@ void TCPConnection::onUvShutdown(uv_shutdown_t* req, int status)
if
(
status
==
UV_EPIPE
||
status
==
UV_ENOTCONN
||
status
==
UV_ECANCELED
)
if
(
status
==
UV_EPIPE
||
status
==
UV_ENOTCONN
||
status
==
UV_ECANCELED
)
MS_DEBUG
(
"shutdown error: %s"
,
uv_strerror
(
status
));
MS_DEBUG
(
"shutdown error: %s"
,
uv_strerror
(
status
));
else
if
(
status
)
else
if
(
status
)
MS_
NOTICE
(
"shutdown error: %s"
,
uv_strerror
(
status
));
MS_
INFO
(
"shutdown error: %s"
,
uv_strerror
(
status
));
// Now do close the handle.
// Now do close the handle.
uv_close
((
uv_handle_t
*
)
this
->
uvHandle
,
(
uv_close_cb
)
on_close
);
uv_close
((
uv_handle_t
*
)
this
->
uvHandle
,
(
uv_close_cb
)
on_close
);
...
...
worker/src/handles/UDPSocket.cpp
浏览文件 @
aa587a71
...
@@ -192,7 +192,7 @@ void UDPSocket::Send(const MS_BYTE* data, size_t len, const struct sockaddr* add
...
@@ -192,7 +192,7 @@ void UDPSocket::Send(const MS_BYTE* data, size_t len, const struct sockaddr* add
// Error,
// Error,
else
if
(
sent
!=
UV_EAGAIN
)
else
if
(
sent
!=
UV_EAGAIN
)
{
{
MS_
ERROR
(
"uv_udp_try_send() failed: %s"
,
uv_strerror
(
sent
));
MS_
WARN
(
"uv_udp_try_send() failed: %s"
,
uv_strerror
(
sent
));
return
;
return
;
}
}
// Otherwise UV_EAGAIN was returned so cannot send data at first time. Use uv_udp_send().
// Otherwise UV_EAGAIN was returned so cannot send data at first time. Use uv_udp_send().
...
@@ -214,7 +214,7 @@ void UDPSocket::Send(const MS_BYTE* data, size_t len, const struct sockaddr* add
...
@@ -214,7 +214,7 @@ void UDPSocket::Send(const MS_BYTE* data, size_t len, const struct sockaddr* add
{
{
// NOTE: uv_udp_send() returns error if a wrong INET family is given
// NOTE: uv_udp_send() returns error if a wrong INET family is given
// (IPv6 destination on a IPv4 binded socket), so be ready.
// (IPv6 destination on a IPv4 binded socket), so be ready.
MS_
ERROR
(
"uv_udp_send() failed: %s"
,
uv_strerror
(
err
));
MS_
WARN
(
"uv_udp_send() failed: %s"
,
uv_strerror
(
err
));
// Delete the UvSendData struct (which includes the uv_req_t and the store char[]).
// Delete the UvSendData struct (which includes the uv_req_t and the store char[]).
std
::
free
(
send_data
);
std
::
free
(
send_data
);
...
@@ -344,7 +344,7 @@ void UDPSocket::onUvRecv(ssize_t nread, const uv_buf_t* buf, const struct sockad
...
@@ -344,7 +344,7 @@ void UDPSocket::onUvRecv(ssize_t nread, const uv_buf_t* buf, const struct sockad
// Some error.
// Some error.
else
else
{
{
MS_
NOTICE
(
"read error: %s"
,
uv_strerror
(
nread
));
MS_
INFO
(
"read error: %s"
,
uv_strerror
(
nread
));
}
}
}
}
...
@@ -356,7 +356,7 @@ void UDPSocket::onUvSendError(int error)
...
@@ -356,7 +356,7 @@ void UDPSocket::onUvSendError(int error)
if
(
this
->
isClosing
)
if
(
this
->
isClosing
)
return
;
return
;
MS_
NOTICE
(
"send error: %s"
,
uv_strerror
(
error
));
MS_
INFO
(
"send error: %s"
,
uv_strerror
(
error
));
}
}
inline
inline
...
...
worker/src/handles/UnixStreamSocket.cpp
浏览文件 @
aa587a71
...
@@ -144,7 +144,7 @@ void UnixStreamSocket::Write(const MS_BYTE* data, size_t len)
...
@@ -144,7 +144,7 @@ void UnixStreamSocket::Write(const MS_BYTE* data, size_t len)
// Error. Should not happen.
// Error. Should not happen.
else
if
(
written
<
0
)
else
if
(
written
<
0
)
{
{
MS_
NOTICE
(
"uv_try_write() failed: %s | closing the connection"
,
uv_strerror
(
written
));
MS_
WARN
(
"uv_try_write() failed: %s | closing the connection"
,
uv_strerror
(
written
));
Close
();
Close
();
return
;
return
;
}
}
...
@@ -257,7 +257,7 @@ void UnixStreamSocket::onUvRead(ssize_t nread, const uv_buf_t* buf)
...
@@ -257,7 +257,7 @@ void UnixStreamSocket::onUvRead(ssize_t nread, const uv_buf_t* buf)
// Some error.
// Some error.
else
else
{
{
MS_
NOTICE
(
"read error: %s | closing the pipe"
,
uv_strerror
(
nread
));
MS_
INFO
(
"read error: %s | closing the pipe"
,
uv_strerror
(
nread
));
this
->
hasError
=
true
;
this
->
hasError
=
true
;
// Close the socket.
// Close the socket.
...
@@ -280,7 +280,7 @@ void UnixStreamSocket::onUvWriteError(int error)
...
@@ -280,7 +280,7 @@ void UnixStreamSocket::onUvWriteError(int error)
}
}
else
else
{
{
MS_
NOTICE
(
"write error: %s | closing the pipe"
,
uv_strerror
(
error
));
MS_
INFO
(
"write error: %s | closing the pipe"
,
uv_strerror
(
error
));
this
->
hasError
=
true
;
this
->
hasError
=
true
;
}
}
...
@@ -297,7 +297,7 @@ void UnixStreamSocket::onUvShutdown(uv_shutdown_t* req, int status)
...
@@ -297,7 +297,7 @@ void UnixStreamSocket::onUvShutdown(uv_shutdown_t* req, int status)
if
(
status
==
UV_EPIPE
||
status
==
UV_ENOTCONN
||
status
==
UV_ECANCELED
)
if
(
status
==
UV_EPIPE
||
status
==
UV_ENOTCONN
||
status
==
UV_ECANCELED
)
MS_DEBUG
(
"shutdown error: %s"
,
uv_strerror
(
status
));
MS_DEBUG
(
"shutdown error: %s"
,
uv_strerror
(
status
));
else
if
(
status
)
else
if
(
status
)
MS_
NOTICE
(
"shutdown error: %s"
,
uv_strerror
(
status
));
MS_
INFO
(
"shutdown error: %s"
,
uv_strerror
(
status
));
// Now do close the handle.
// Now do close the handle.
uv_close
((
uv_handle_t
*
)
this
->
uvHandle
,
(
uv_close_cb
)
on_close
);
uv_close
((
uv_handle_t
*
)
this
->
uvHandle
,
(
uv_close_cb
)
on_close
);
...
...
worker/src/main.cpp
浏览文件 @
aa587a71
...
@@ -24,8 +24,14 @@ static void init();
...
@@ -24,8 +24,14 @@ static void init();
static
void
ignoreSignals
();
static
void
ignoreSignals
();
static
void
destroy
();
static
void
destroy
();
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[]
,
char
**
envp
)
{
{
char
**
env
;
for
(
env
=
envp
;
*
env
!=
0
;
env
++
)
{
// printf("%s\n", *env);
}
std
::
string
id
;
std
::
string
id
;
if
(
argc
==
1
)
if
(
argc
==
1
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论