Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
77fadab1
Commit
77fadab1
authored
Jan 21, 2014
by
Lukasz Marek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavf/libssh: factorize create_ssh_session function
Signed-off-by:
Lukasz Marek
<
lukasz.m.luki@gmail.com
>
parent
bf5d73b0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
16 deletions
+26
-16
libssh.c
libavformat/libssh.c
+26
-16
No files found.
libavformat/libssh.c
View file @
77fadab1
...
...
@@ -38,6 +38,30 @@ typedef struct {
char
*
priv_key
;
}
LIBSSHContext
;
static
av_cold
int
libssh_create_ssh_session
(
LIBSSHContext
*
libssh
,
const
char
*
hostname
,
unsigned
int
port
)
{
static
const
int
verbosity
=
SSH_LOG_NOLOG
;
if
(
!
(
libssh
->
session
=
ssh_new
()))
{
av_log
(
libssh
,
AV_LOG_ERROR
,
"SSH session creation failed: %s
\n
"
,
ssh_get_error
(
libssh
->
session
));
return
AVERROR
(
ENOMEM
);
}
ssh_options_set
(
libssh
->
session
,
SSH_OPTIONS_HOST
,
hostname
);
ssh_options_set
(
libssh
->
session
,
SSH_OPTIONS_PORT
,
&
port
);
ssh_options_set
(
libssh
->
session
,
SSH_OPTIONS_LOG_VERBOSITY
,
&
verbosity
);
if
(
libssh
->
rw_timeout
>
0
)
{
long
timeout
=
libssh
->
rw_timeout
*
1000
;
ssh_options_set
(
libssh
->
session
,
SSH_OPTIONS_TIMEOUT_USEC
,
&
timeout
);
}
if
(
ssh_connect
(
libssh
->
session
)
!=
SSH_OK
)
{
av_log
(
libssh
,
AV_LOG_ERROR
,
"Connection failed: %s
\n
"
,
ssh_get_error
(
libssh
->
session
));
return
AVERROR
(
EIO
);
}
return
0
;
}
static
av_cold
int
libssh_authentication
(
LIBSSHContext
*
libssh
,
const
char
*
user
,
const
char
*
password
)
{
int
authorized
=
0
;
...
...
@@ -137,11 +161,9 @@ static int libssh_close(URLContext *h)
static
int
libssh_open
(
URLContext
*
h
,
const
char
*
url
,
int
flags
)
{
static
const
int
verbosity
=
SSH_LOG_NOLOG
;
LIBSSHContext
*
s
=
h
->
priv_data
;
char
proto
[
10
],
path
[
MAX_URL_SIZE
],
hostname
[
1024
],
credencials
[
1024
];
int
port
=
22
,
ret
;
long
timeout
=
s
->
rw_timeout
*
1000
;
const
char
*
user
=
NULL
,
*
pass
=
NULL
;
char
*
end
=
NULL
;
...
...
@@ -155,23 +177,11 @@ static int libssh_open(URLContext *h, const char *url, int flags)
if
(
port
<=
0
||
port
>
65535
)
port
=
22
;
if
(
!
(
s
->
session
=
ssh_new
()))
{
ret
=
AVERROR
(
ENOMEM
);
if
((
ret
=
libssh_create_ssh_session
(
s
,
hostname
,
port
))
<
0
)
goto
fail
;
}
user
=
av_strtok
(
credencials
,
":"
,
&
end
);
pass
=
av_strtok
(
end
,
":"
,
&
end
);
ssh_options_set
(
s
->
session
,
SSH_OPTIONS_HOST
,
hostname
);
ssh_options_set
(
s
->
session
,
SSH_OPTIONS_PORT
,
&
port
);
ssh_options_set
(
s
->
session
,
SSH_OPTIONS_LOG_VERBOSITY
,
&
verbosity
);
if
(
timeout
>
0
)
ssh_options_set
(
s
->
session
,
SSH_OPTIONS_TIMEOUT_USEC
,
&
timeout
);
if
(
ssh_connect
(
s
->
session
)
!=
SSH_OK
)
{
av_log
(
h
,
AV_LOG_ERROR
,
"Connection failed. %s
\n
"
,
ssh_get_error
(
s
->
session
));
ret
=
AVERROR
(
EIO
);
goto
fail
;
}
if
((
ret
=
libssh_authentication
(
s
,
user
,
pass
))
<
0
)
goto
fail
;
...
...
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