Stun Server
Compliant with the latest RFCs including 5389, 5769, and 5780
discover the local host's own external IP address
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
server.h
Go to the documentation of this file.
1
/*
2
Copyright 2011 John Selbie
3
4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7
8
http://www.apache.org/licenses/LICENSE-2.0
9
10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16
17
18
#ifndef STUN_SERVER_H
19
#define STUN_SERVER_H
20
21
#include "
stunsocket.h
"
22
#include "
stunsocketthread.h
"
23
#include "
stunauth.h
"
24
#include "
messagehandler.h
"
25
26
27
28
29
class
CStunServerConfig
30
{
31
public
:
32
33
bool
fHasPP
;
// PP: Primary ip, Primary port
34
bool
fHasPA
;
// PA: Primary ip, Alternate port
35
bool
fHasAP
;
// AP: Alternate ip, Primary port
36
bool
fHasAA
;
// AA: Alternate ip, Alternate port
37
38
bool
fMultiThreadedMode
;
// if true, one thread for each socket
39
40
bool
fTCP
;
// if true, then use TCP instead of UDP
41
uint32_t
nMaxConnections
;
// only valid for TCP (on a per-thread basis)
42
43
CSocketAddress
addrPP
;
// address for PP
44
CSocketAddress
addrPA
;
// address for PA
45
CSocketAddress
addrAP
;
// address for AP
46
CSocketAddress
addrAA
;
// address for AA
47
48
CSocketAddress
addrPrimaryAdvertised
;
// public-IP for PP and PA (port is ignored)
49
CSocketAddress
addrAlternateAdvertised
;
// public-IP for AP and AA (port is ignored)
50
51
bool
fEnableDosProtection
;
// enable denial of service protection
52
53
CStunServerConfig
();
54
};
55
56
57
class
CStunServer
:
58
public
CBasicRefCount
,
59
public
CObjectFactory
<CStunServer>,
60
public
IRefCounted
61
{
62
private
:
63
CStunSocket
_arrSockets[4];
64
65
std::vector<CStunSocketThread*>
_threads
;
66
67
CStunServer
();
68
~
CStunServer
();
69
70
friend
class
CObjectFactory
<
CStunServer
>;
71
72
CRefCountedPtr<IStunAuth>
_spAuth
;
73
74
HRESULT
AddSocket(
TransportAddressSet
* pTSA,
SocketRole
role,
const
CSocketAddress
& addrListen,
const
CSocketAddress
& addrAdvertise);
75
76
public
:
77
78
HRESULT
Initialize(
const
CStunServerConfig
& config);
79
HRESULT
Shutdown();
80
81
HRESULT
Start();
82
HRESULT
Stop();
83
84
ADDREF_AND_RELEASE_IMPL
();
85
};
86
87
88
89
#endif
/* SERVER_H */
90
CStunServerConfig::fHasPP
bool fHasPP
Definition:
server.h:33
stunsocket.h
CStunServerConfig
Definition:
server.h:29
TransportAddressSet
Definition:
messagehandler.h:57
CStunServerConfig::fTCP
bool fTCP
Definition:
server.h:40
CStunServerConfig::addrAlternateAdvertised
CSocketAddress addrAlternateAdvertised
Definition:
server.h:49
ADDREF_AND_RELEASE_IMPL
#define ADDREF_AND_RELEASE_IMPL()
Definition:
refcountobject.h:49
CStunServerConfig::fHasAP
bool fHasAP
Definition:
server.h:35
CStunServer::_threads
std::vector< CStunSocketThread * > _threads
Definition:
server.h:65
CStunServer
Definition:
server.h:57
CStunServer::_spAuth
CRefCountedPtr< IStunAuth > _spAuth
Definition:
server.h:72
stunauth.h
CSocketAddress
Definition:
socketaddress.h:32
CStunServerConfig::addrPA
CSocketAddress addrPA
Definition:
server.h:44
CStunServerConfig::CStunServerConfig
CStunServerConfig()
Definition:
server.cpp:27
IRefCounted
Definition:
refcountobject.h:26
CStunServerConfig::addrAA
CSocketAddress addrAA
Definition:
server.h:46
SocketRole
SocketRole
Definition:
socketrole.h:22
HRESULT
int32_t HRESULT
Definition:
hresult.h:22
CStunServerConfig::fMultiThreadedMode
bool fMultiThreadedMode
Definition:
server.h:38
CRefCountedPtr< IStunAuth >
CStunServerConfig::fHasPA
bool fHasPA
Definition:
server.h:34
CStunSocket
Definition:
stunsocket.h:22
stunsocketthread.h
CStunServerConfig::nMaxConnections
uint32_t nMaxConnections
Definition:
server.h:41
messagehandler.h
CStunServerConfig::addrPrimaryAdvertised
CSocketAddress addrPrimaryAdvertised
Definition:
server.h:48
CStunServerConfig::fEnableDosProtection
bool fEnableDosProtection
Definition:
server.h:51
CObjectFactory
Definition:
objectfactory.h:25
CStunServerConfig::addrAP
CSocketAddress addrAP
Definition:
server.h:45
CBasicRefCount
Definition:
refcountobject.h:34
CStunServerConfig::addrPP
CSocketAddress addrPP
Definition:
server.h:43
CStunServerConfig::fHasAA
bool fHasAA
Definition:
server.h:36
server
server.h
Generated by
1.8.11