Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
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
videolan
vlc
Commits
f4a73140
Commit
f4a73140
authored
May 12, 2015
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demux: adaptative: add tls
parent
0e86ff50
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
126 additions
and
2 deletions
+126
-2
modules/demux/adaptative/http/HTTPConnectionManager.cpp
modules/demux/adaptative/http/HTTPConnectionManager.cpp
+4
-2
modules/demux/adaptative/http/Sockets.cpp
modules/demux/adaptative/http/Sockets.cpp
+105
-0
modules/demux/adaptative/http/Sockets.hpp
modules/demux/adaptative/http/Sockets.hpp
+17
-0
No files found.
modules/demux/adaptative/http/HTTPConnectionManager.cpp
View file @
f4a73140
...
...
@@ -79,10 +79,12 @@ bool HTTPConnectionManager::connectChunk(Chunk *chunk)
HTTPConnection
*
conn
=
getConnectionForHost
(
chunk
->
getHostname
());
if
(
!
conn
)
{
Socket
*
socket
=
new
(
std
::
nothrow
)
Socket
();
const
bool
tls
=
(
chunk
->
getScheme
()
==
"https"
);
Socket
*
socket
=
tls
?
new
(
std
::
nothrow
)
TLSSocket
()
:
new
(
std
::
nothrow
)
Socket
();
if
(
!
socket
)
return
false
;
conn
=
new
(
std
::
nothrow
)
HTTPConnection
(
stream
,
socket
,
chunk
,
true
);
/* disable pipelined tls until we have ticket/resume session support */
conn
=
new
(
std
::
nothrow
)
HTTPConnection
(
stream
,
socket
,
chunk
,
!
tls
);
if
(
!
conn
)
{
delete
socket
;
...
...
modules/demux/adaptative/http/Sockets.cpp
View file @
f4a73140
...
...
@@ -96,3 +96,108 @@ bool Socket::send(vlc_object_t *stream, const void *buf, size_t size)
return
true
;
}
TLSSocket
::
TLSSocket
()
:
Socket
()
{
creds
=
NULL
;
tls
=
NULL
;
}
TLSSocket
::~
TLSSocket
()
{
disconnect
();
}
bool
TLSSocket
::
connect
(
vlc_object_t
*
stream
,
const
std
::
string
&
hostname
,
int
port
)
{
disconnect
();
if
(
!
Socket
::
connect
(
stream
,
hostname
,
port
))
return
false
;
creds
=
vlc_tls_ClientCreate
(
stream
);
if
(
!
creds
)
{
disconnect
();
return
false
;
}
tls
=
vlc_tls_ClientSessionCreate
(
creds
,
netfd
,
hostname
.
c_str
(),
"https"
,
NULL
,
NULL
);
if
(
!
tls
)
{
disconnect
();
return
false
;
}
return
true
;
}
bool
TLSSocket
::
connected
()
const
{
return
Socket
::
connected
()
&&
tls
;
}
ssize_t
TLSSocket
::
read
(
vlc_object_t
*
,
void
*
p_buffer
,
size_t
len
,
bool
)
{
ssize_t
size
;
size_t
totalread
=
0
;
do
{
size
=
tls_Recv
(
tls
,
(
uint8_t
*
)
p_buffer
+
totalread
,
len
-
totalread
);
/* only returns partial chunks */
if
(
size
>=
0
)
{
totalread
+=
(
size_t
)
size
;
}
else
if
(
errno
!=
EINTR
&&
errno
!=
EAGAIN
)
{
break
;
}
}
while
(
totalread
<
len
);
return
totalread
;
}
std
::
string
TLSSocket
::
readline
(
vlc_object_t
*
stream
)
{
std
::
string
ret
;
ret
.
reserve
(
256
);
char
c
[
2
]
=
{
0
,
0
};
ssize_t
size
=
TLSSocket
::
read
(
stream
,
c
,
1
,
true
);
while
(
size
>
0
)
{
ret
.
append
(
&
c
[
0
]
);
if
(
c
[
0
]
==
'\n'
)
break
;
size
=
TLSSocket
::
read
(
stream
,
c
,
1
,
true
);
}
return
ret
;
}
bool
TLSSocket
::
send
(
vlc_object_t
*
stream
,
const
void
*
buf
,
size_t
size
)
{
if
(
!
connected
())
return
false
;
if
(
size
==
0
)
return
true
;
ssize_t
ret
=
tls_Send
(
tls
,
buf
,
size
);
if
(
ret
<=
0
)
return
false
;
if
(
(
size_t
)
ret
<
size
)
send
(
stream
,
((
uint8_t
*
)
buf
)
+
ret
,
size
-
ret
);
return
true
;
}
void
TLSSocket
::
disconnect
()
{
if
(
tls
)
vlc_tls_SessionDelete
(
tls
);
if
(
creds
)
vlc_tls_Delete
(
creds
);
tls
=
NULL
;
creds
=
NULL
;
Socket
::
disconnect
();
}
modules/demux/adaptative/http/Sockets.hpp
View file @
f4a73140
...
...
@@ -25,6 +25,7 @@
#endif
#include <vlc_common.h>
#include <vlc_tls.h>
#include <string>
namespace
adaptative
...
...
@@ -47,6 +48,22 @@ namespace adaptative
int
netfd
;
};
class
TLSSocket
:
public
Socket
{
public:
TLSSocket
();
virtual
~
TLSSocket
();
virtual
bool
connect
(
vlc_object_t
*
,
const
std
::
string
&
,
int
port
=
443
);
virtual
bool
connected
()
const
;
virtual
bool
send
(
vlc_object_t
*
,
const
void
*
buf
,
size_t
size
);
virtual
ssize_t
read
(
vlc_object_t
*
,
void
*
p_buffer
,
size_t
len
,
bool
);
virtual
std
::
string
readline
(
vlc_object_t
*
);
virtual
void
disconnect
();
private:
vlc_tls_creds_t
*
creds
;
vlc_tls_t
*
tls
;
};
}
}
...
...
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