Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
6c34b58e
Commit
6c34b58e
authored
Apr 12, 2013
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vlc_getProxyUrl: add function to retrieve proxy URL
parent
29209586
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
203 additions
and
0 deletions
+203
-0
include/vlc_network.h
include/vlc_network.h
+3
-0
src/Makefile.am
src/Makefile.am
+3
-0
src/libvlccore.sym
src/libvlccore.sym
+1
-0
src/posix/netconf.c
src/posix/netconf.c
+113
-0
src/win32/netconf.c
src/win32/netconf.c
+83
-0
No files found.
include/vlc_network.h
View file @
6c34b58e
...
...
@@ -373,6 +373,9 @@ static inline void net_SetPort (struct sockaddr *addr, uint16_t port)
break
;
}
}
VLC_API
char
*
vlc_getProxyUrl
(
const
char
*
);
# ifdef __cplusplus
}
# endif
...
...
src/Makefile.am
View file @
6c34b58e
...
...
@@ -269,6 +269,7 @@ SOURCES_libvlc_android = \
SOURCES_libvlc_linux
=
\
posix/dirs.c
\
posix/filesystem.c
\
posix/netconf.c
\
posix/plugin.c
\
posix/thread.c
\
posix/timer.c
\
...
...
@@ -281,6 +282,7 @@ SOURCES_libvlc_linux = \
SOURCES_libvlc_win32
=
\
win32/dirs.c
\
win32/filesystem.c
\
win32/netconf.c
\
win32/plugin.c
\
win32/thread.c
\
win32/specific.c
\
...
...
@@ -308,6 +310,7 @@ SOURCES_libvlc_os2 = \
SOURCES_libvlc_other
=
\
posix/dirs.c
\
posix/filesystem.c
\
posix/netconf.c
\
posix/thread.c
\
posix/timer.c
\
posix/plugin.c
\
...
...
src/libvlccore.sym
View file @
6c34b58e
...
...
@@ -506,6 +506,7 @@ vlc_fourcc_AreUVPlanesSwapped
vlc_GetActionId
vlc_getaddrinfo
vlc_getnameinfo
vlc_getProxyUrl
vlc_gettext
vlc_ngettext
vlc_iconv
...
...
src/posix/netconf.c
0 → 100644
View file @
6c34b58e
/*****************************************************************************
* netconf.c : Network configuration
*****************************************************************************
* Copyright (C) 2013 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <spawn.h>
#include <unistd.h>
extern
char
**
environ
;
#include <vlc_common.h>
#include <vlc_fs.h>
#include <vlc_network.h>
/**
* Determines the network proxy server to use (if any).
* @param url absolute URL for which to get the proxy server
* @return proxy URL, NULL if no proxy or error
*/
char
*
vlc_getProxyUrl
(
const
char
*
url
)
{
/* libproxy helper */
pid_t
pid
;
posix_spawn_file_actions_t
actions
;
posix_spawnattr_t
attr
;
char
*
argv
[
3
]
=
{
(
char
*
)
"proxy"
,
(
char
*
)
url
,
NULL
};
int
fd
[
2
];
if
(
vlc_pipe
(
fd
))
return
NULL
;
posix_spawn_file_actions_init
(
&
actions
);
posix_spawn_file_actions_addopen
(
&
actions
,
STDIN_FILENO
,
"/dev/null"
,
O_RDONLY
,
0644
);
posix_spawn_file_actions_adddup2
(
&
actions
,
fd
[
1
],
STDOUT_FILENO
);
posix_spawnattr_init
(
&
attr
);
{
sigset_t
set
;
sigemptyset
(
&
set
);
posix_spawnattr_setsigmask
(
&
attr
,
&
set
);
sigaddset
(
&
set
,
SIGPIPE
);
posix_spawnattr_setsigdefault
(
&
attr
,
&
set
);
posix_spawnattr_setflags
(
&
attr
,
POSIX_SPAWN_SETSIGDEF
|
POSIX_SPAWN_SETSIGMASK
);
}
if
(
posix_spawnp
(
&
pid
,
"proxy"
,
&
actions
,
&
attr
,
argv
,
environ
))
pid
=
-
1
;
posix_spawnattr_destroy
(
&
attr
);
posix_spawn_file_actions_destroy
(
&
actions
);
close
(
fd
[
1
]);
if
(
pid
!=
-
1
)
{
char
buf
[
1024
];
size_t
len
=
0
;
do
{
ssize_t
val
=
read
(
fd
[
0
],
buf
+
len
,
sizeof
(
buf
)
-
len
);
if
(
val
<=
0
)
break
;
}
while
(
len
<
sizeof
(
buf
));
close
(
fd
[
0
]);
while
(
waitpid
(
pid
,
&
(
int
){
0
},
0
)
==
-
1
);
if
(
len
>=
sizeof
(
buf
))
return
NULL
;
/* overflow */
if
(
len
>=
9
&&
!
strncasecmp
(
buf
,
"direct://"
,
9
))
return
NULL
;
if
(
len
>
0
)
return
strndup
(
buf
,
len
);
}
else
close
(
fd
[
0
]);
/* Fallback to environment variable */
char
*
var
=
getenv
(
"http_proxy"
);
if
(
var
!=
NULL
)
var
=
strdup
(
var
);
return
var
;
}
src/win32/netconf.c
0 → 100644
View file @
6c34b58e
/*****************************************************************************
* netconf.c : Network configuration
*****************************************************************************
* Copyright (C) 2001-2008 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h>
#include <windows.h>
#include <vlc_common.h>
#include <vlc_network.h>
char
*
vlc_getProxyUrl
(
const
char
*
url
)
{
char
*
proxy_url
=
NULL
;
#if 0
/* Try to get the proxy server address from Windows internet settings. */
HKEY h_key;
/* Open the key */
if( RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Microsoft"
"\\Windows\\CurrentVersion\\Internet Settings",
0, KEY_READ, &h_key ) == ERROR_SUCCESS )
return NULL;
DWORD len = sizeof( DWORD );
BYTE proxyEnable;
/* Get the proxy enable value */
if( RegQueryValueEx( h_key, "ProxyEnable", NULL, NULL,
&proxyEnable, &len ) != ERROR_SUCCESS
|| !proxyEnable )
goto out;
/* Proxy is enabled */
/* Get the proxy URL :
Proxy server value in the registry can be something like "address:port"
or "ftp=address1:port1;http=address2:port2 ..."
depending of the confirguration. */
unsigned char key[256];
len = sizeof( key );
if( RegQueryValueEx( h_key, "ProxyServer", NULL, NULL,
key, &len ) == ERROR_SUCCESS )
{
/* FIXME: This is lame. The string should be tokenized. */
#warning FIXME.
char *psz_proxy = strstr( (char *)key, "http=" );
if( psz_proxy != NULL )
{
psz_proxy += 5;
char *end = strchr( psz_proxy, ';' );
if( end != NULL )
*end = '\0';
}
else
psz_proxy = (char *)key;
proxy_url = strdup( psz_proxy );
}
out:
RegCloseKey( h_key );
#endif
return
proxy_url
;
}
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