Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pistache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
pistache
Commits
3e716b45
Unverified
Commit
3e716b45
authored
Feb 09, 2020
by
Dennis Jenkins
Committed by
GitHub
Feb 09, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #699 from hyperxor/improve_peer_secured_api
Improve Peer SSL API and remove unnecessary code
parents
e0c7c07a
f3c4cf78
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
26 deletions
+19
-26
include/pistache/peer.h
include/pistache/peer.h
+3
-3
src/common/peer.cc
src/common/peer.cc
+10
-9
src/common/transport.cc
src/common/transport.cc
+0
-7
src/server/listener.cc
src/server/listener.cc
+6
-7
No files found.
include/pistache/peer.h
View file @
3e716b45
...
...
@@ -39,13 +39,13 @@ public:
~
Peer
();
static
std
::
shared_ptr
<
Peer
>
Create
(
Fd
fd
,
const
Address
&
addr
);
static
std
::
shared_ptr
<
Peer
>
CreateSSL
(
Fd
fd
,
const
Address
&
addr
,
void
*
ssl
);
const
Address
&
address
()
const
;
const
std
::
string
&
hostname
();
Fd
fd
()
const
;
void
associateSSL
(
void
*
ssl
);
void
*
ssl
(
void
)
const
;
void
*
ssl
()
const
;
void
putData
(
std
::
string
name
,
std
::
shared_ptr
<
Pistache
::
Http
::
Private
::
ParserBase
>
data
);
...
...
@@ -57,7 +57,7 @@ public:
Async
::
Promise
<
ssize_t
>
send
(
const
RawBuffer
&
buffer
,
int
flags
=
0
);
protected:
Peer
(
Fd
fd
,
const
Address
&
addr
);
Peer
(
Fd
fd
,
const
Address
&
addr
,
void
*
ssl
);
private:
void
associateTransport
(
Transport
*
transport
);
...
...
src/common/peer.cc
View file @
3e716b45
...
...
@@ -21,21 +21,26 @@ namespace Tcp {
namespace
{
struct
ConcretePeer
:
Peer
{
ConcretePeer
()
=
default
;
ConcretePeer
(
Fd
fd
,
const
Address
&
addr
)
:
Peer
(
fd
,
addr
)
{}
ConcretePeer
(
Fd
fd
,
const
Address
&
addr
,
void
*
ssl
)
:
Peer
(
fd
,
addr
,
ssl
)
{}
};
}
// namespace
Peer
::
Peer
(
Fd
fd
,
const
Address
&
addr
)
:
fd_
(
fd
),
addr
(
addr
)
{}
Peer
::
Peer
(
Fd
fd
,
const
Address
&
addr
,
void
*
ssl
)
:
fd_
(
fd
),
addr
(
addr
),
ssl_
(
ssl
)
{}
Peer
::~
Peer
()
{
#ifdef PISTACHE_USE_SSL
if
(
ssl_
)
SSL_free
(
(
SSL
*
)
ssl_
);
SSL_free
(
static_cast
<
SSL
*>
(
ssl_
)
);
#endif
/* PISTACHE_USE_SSL */
}
std
::
shared_ptr
<
Peer
>
Peer
::
Create
(
Fd
fd
,
const
Address
&
addr
)
{
return
std
::
make_shared
<
ConcretePeer
>
(
fd
,
addr
);
return
std
::
make_shared
<
ConcretePeer
>
(
fd
,
addr
,
nullptr
);
}
std
::
shared_ptr
<
Peer
>
Peer
::
CreateSSL
(
Fd
fd
,
const
Address
&
addr
,
void
*
ssl
)
{
return
std
::
make_shared
<
ConcretePeer
>
(
fd
,
addr
,
ssl
);
}
const
Address
&
Peer
::
address
()
const
{
return
addr
;
}
...
...
@@ -60,11 +65,7 @@ const std::string &Peer::hostname() {
return
hostname_
;
}
#ifdef PISTACHE_USE_SSL
void
Peer
::
associateSSL
(
void
*
ssl
)
{
ssl_
=
ssl
;
}
void
*
Peer
::
ssl
(
void
)
const
{
return
ssl_
;
}
#endif
/* PISTACHE_USE_SSL */
void
*
Peer
::
ssl
()
const
{
return
ssl_
;
}
int
Peer
::
fd
()
const
{
if
(
fd_
==
-
1
)
{
...
...
src/common/transport.cc
View file @
3e716b45
...
...
@@ -165,13 +165,6 @@ void Transport::handlePeerDisconnection(const std::shared_ptr<Peer> &peer) {
if
(
it
==
std
::
end
(
peers
))
throw
std
::
runtime_error
(
"Could not find peer to erase"
);
#ifdef PISTACHE_USE_SSL
if
(
peer
->
ssl
()
!=
NULL
)
{
SSL_free
((
SSL
*
)
peer
->
ssl
());
peer
->
associateSSL
(
NULL
);
}
#endif
/* PISTACHE_USE_SSL */
peers
.
erase
(
it
->
first
);
{
...
...
src/server/listener.cc
View file @
3e716b45
...
...
@@ -335,13 +335,12 @@ void Listener::handleNewConnection() {
make_non_blocking
(
client_fd
);
auto
peer
=
Peer
::
Create
(
client_fd
,
Address
::
fromUnix
(
&
peer_addr
));
#ifdef PISTACHE_USE_SSL
if
(
this
->
useSSL_
)
peer
->
associateSSL
(
ssl
);
#endif
/* PISTACHE_USE_SSL */
std
::
shared_ptr
<
Peer
>
peer
;
if
(
this
->
useSSL_
)
{
peer
=
Peer
::
CreateSSL
(
client_fd
,
Address
::
fromUnix
(
&
peer_addr
),
ssl
);
}
else
{
peer
=
Peer
::
Create
(
client_fd
,
Address
::
fromUnix
(
&
peer_addr
));
}
dispatchPeer
(
peer
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment