Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
ba798c5e
Commit
ba798c5e
authored
Jun 20, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http proxy mostly working, need to implement http authentication
git-svn-id:
https://svn.musicpd.org/mpd/trunk@1588
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
6eb6c454
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
11 deletions
+45
-11
inputStream.h
src/inputStream.h
+2
-0
inputStream_http.c
src/inputStream_http.c
+41
-8
main.c
src/main.c
+2
-3
No files found.
src/inputStream.h
View file @
ba798c5e
...
@@ -49,6 +49,8 @@ struct _InputStream {
...
@@ -49,6 +49,8 @@ struct _InputStream {
char
*
metaTitle
;
char
*
metaTitle
;
};
};
void
initInputStream
();
int
isUrlSaneForInputStream
(
char
*
url
);
int
isUrlSaneForInputStream
(
char
*
url
);
/* if an error occurs for these 3 functions, then -1 is returned and errno
/* if an error occurs for these 3 functions, then -1 is returned and errno
...
...
src/inputStream_http.c
View file @
ba798c5e
...
@@ -60,6 +60,9 @@ typedef struct _InputStreemHTTPData {
...
@@ -60,6 +60,9 @@ typedef struct _InputStreemHTTPData {
int
icyMetaint
;
int
icyMetaint
;
int
prebuffer
;
int
prebuffer
;
int
icyOffset
;
int
icyOffset
;
char
*
proxyHost
;
int
proxyPort
;
char
*
proxyAuth
;
}
InputStreamHTTPData
;
}
InputStreamHTTPData
;
void
inputStream_initHttp
()
{
void
inputStream_initHttp
()
{
...
@@ -114,6 +117,20 @@ void inputStream_initHttp() {
...
@@ -114,6 +117,20 @@ void inputStream_initHttp() {
static
InputStreamHTTPData
*
newInputStreamHTTPData
()
{
static
InputStreamHTTPData
*
newInputStreamHTTPData
()
{
InputStreamHTTPData
*
ret
=
malloc
(
sizeof
(
InputStreamHTTPData
));
InputStreamHTTPData
*
ret
=
malloc
(
sizeof
(
InputStreamHTTPData
));
if
(
getConf
()[
CONF_HTTP_PROXY_HOST
])
{
ret
->
proxyHost
=
getConf
()[
CONF_HTTP_PROXY_HOST
];
DEBUG
(
__FILE__
": Proxy host %s
\n
"
,
ret
->
proxyHost
);
ret
->
proxyPort
=
atoi
(
getConf
()[
CONF_HTTP_PROXY_PORT
]);
DEBUG
(
__FILE__
": Proxy port %i
\n
"
,
ret
->
proxyPort
);
ret
->
proxyAuth
=
/*proxyAuthString(
getConf()[CONF_HTTP_PROXY_USER],
getConf()[CONF_HTTP_PROXY_PASSWORD])*/
NULL
;
}
else
{
ret
->
proxyHost
=
NULL
;
ret
->
proxyAuth
=
NULL
;
}
ret
->
host
=
NULL
;
ret
->
host
=
NULL
;
ret
->
path
=
NULL
;
ret
->
path
=
NULL
;
ret
->
port
=
80
;
ret
->
port
=
80
;
...
@@ -129,6 +146,7 @@ static InputStreamHTTPData * newInputStreamHTTPData() {
...
@@ -129,6 +146,7 @@ static InputStreamHTTPData * newInputStreamHTTPData() {
static
void
freeInputStreamHTTPData
(
InputStreamHTTPData
*
data
)
{
static
void
freeInputStreamHTTPData
(
InputStreamHTTPData
*
data
)
{
if
(
data
->
host
)
free
(
data
->
host
);
if
(
data
->
host
)
free
(
data
->
host
);
if
(
data
->
path
)
free
(
data
->
path
);
if
(
data
->
path
)
free
(
data
->
path
);
if
(
data
->
proxyAuth
)
free
(
data
->
proxyAuth
);
free
(
data
);
free
(
data
);
}
}
...
@@ -170,7 +188,8 @@ static int parseUrl(InputStreamHTTPData * data, char * url) {
...
@@ -170,7 +188,8 @@ static int parseUrl(InputStreamHTTPData * data, char * url) {
}
}
/* fetch the path */
/* fetch the path */
data
->
path
=
strdup
(
slash
?
slash
:
"/"
);
if
(
data
->
proxyHost
)
data
->
path
=
strdup
(
url
);
else
data
->
path
=
strdup
(
slash
?
slash
:
"/"
);
return
0
;
return
0
;
}
}
...
@@ -183,17 +202,29 @@ static int initHTTPConnection(InputStream * inStream) {
...
@@ -183,17 +202,29 @@ static int initHTTPConnection(InputStream * inStream) {
InputStreamHTTPData
*
data
=
(
InputStreamHTTPData
*
)
inStream
->
data
;
InputStreamHTTPData
*
data
=
(
InputStreamHTTPData
*
)
inStream
->
data
;
int
flags
;
int
flags
;
int
ret
;
int
ret
;
char
*
connHost
;
int
connPort
;
#ifdef HAVE_IPV6
#ifdef HAVE_IPV6
struct
sockaddr_in6
sin6
;
struct
sockaddr_in6
sin6
;
#endif
#endif
if
(
!
(
he
=
gethostbyname
(
data
->
host
)))
{
if
(
data
->
proxyHost
)
{
connHost
=
data
->
proxyHost
;
connPort
=
data
->
proxyPort
;
}
else
{
connHost
=
data
->
host
;
connPort
=
data
->
port
;
}
if
(
!
(
he
=
gethostbyname
(
connHost
)))
{
DEBUG
(
__FILE__
": failure to lookup host
\"
%s
\"\n
"
,
connHost
);
return
-
1
;
return
-
1
;
}
}
memset
(
&
sin
,
0
,
sizeof
(
struct
sockaddr_in
));
memset
(
&
sin
,
0
,
sizeof
(
struct
sockaddr_in
));
sin
.
sin_family
=
AF_INET
;
sin
.
sin_family
=
AF_INET
;
sin
.
sin_port
=
htons
(
data
->
p
ort
);
sin
.
sin_port
=
htons
(
connP
ort
);
#ifdef HAVE_IPV6
#ifdef HAVE_IPV6
memset
(
&
sin6
,
0
,
sizeof
(
struct
sockaddr_in6
));
memset
(
&
sin6
,
0
,
sizeof
(
struct
sockaddr_in6
));
sin6
.
sin6_family
=
AF_INET6
;
sin6
.
sin6_family
=
AF_INET6
;
...
@@ -231,6 +262,7 @@ static int initHTTPConnection(InputStream * inStream) {
...
@@ -231,6 +262,7 @@ static int initHTTPConnection(InputStream * inStream) {
ret
=
connect
(
data
->
sock
,
dest
,
destlen
);
ret
=
connect
(
data
->
sock
,
dest
,
destlen
);
if
(
ret
<
0
&&
errno
!=
EINPROGRESS
)
{
if
(
ret
<
0
&&
errno
!=
EINPROGRESS
)
{
DEBUG
(
__FILE__
": unable to connect: %s
\n
"
,
strerror
(
errno
));
close
(
data
->
sock
);
close
(
data
->
sock
);
return
-
1
;
return
-
1
;
}
}
...
@@ -265,6 +297,7 @@ static int finishHTTPInit(InputStream * inStream) {
...
@@ -265,6 +297,7 @@ static int finishHTTPInit(InputStream * inStream) {
if
(
ret
==
0
||
(
ret
<
0
&&
errno
==
EINTR
))
return
0
;
if
(
ret
==
0
||
(
ret
<
0
&&
errno
==
EINTR
))
return
0
;
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
DEBUG
(
__FILE__
": problem select'ing: %s
\n
"
,
strerror
(
errno
));
close
(
data
->
sock
);
close
(
data
->
sock
);
data
->
connState
=
HTTP_CONN_STATE_CLOSED
;
data
->
connState
=
HTTP_CONN_STATE_CLOSED
;
return
-
1
;
return
-
1
;
...
@@ -279,15 +312,15 @@ static int finishHTTPInit(InputStream * inStream) {
...
@@ -279,15 +312,15 @@ static int finishHTTPInit(InputStream * inStream) {
memset
(
request
,
0
,
2049
);
memset
(
request
,
0
,
2049
);
/* deal with ICY metadata later, for now its fucking up stuff! */
/* deal with ICY metadata later, for now its fucking up stuff! */
snprintf
(
request
,
2048
,
"GET %s HTTP/1.
1
\r\n
"
snprintf
(
request
,
2048
,
"GET %s HTTP/1.
0
\r\n
"
"Host: %s
\r\n
"
"Host: %s
\r\n
"
"Connection: close
\r\n
"
/*"Connection: close\r\n"*/
"User-Agent: %s/%s
\r\n
"
"User-Agent: %s/%s
\r\n
"
"Range: bytes=%ld-
\r\n
"
/*"Range: bytes=%ld-\r\n"*/
"Icy-Metadata:1
\r\n
"
"Icy-Metadata:1
\r\n
"
"
\r\n
"
,
"
\r\n
"
,
data
->
path
,
data
->
host
,
"httpTest"
,
"0.0.0"
,
data
->
path
,
data
->
host
,
"httpTest"
,
"0.0.0"
/*
,
inStream
->
offset
);
inStream->offset
*/
);
ret
=
write
(
data
->
sock
,
request
,
strlen
(
request
));
ret
=
write
(
data
->
sock
,
request
,
strlen
(
request
));
if
(
ret
!=
strlen
(
request
))
{
if
(
ret
!=
strlen
(
request
))
{
...
...
src/main.c
View file @
ba798c5e
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include "permission.h"
#include "permission.h"
#include "replayGain.h"
#include "replayGain.h"
#include "inputPlugin.h"
#include "inputPlugin.h"
#include "inputStream.h"
#include "../config.h"
#include "../config.h"
#include <stdio.h>
#include <stdio.h>
...
@@ -420,9 +421,6 @@ int main(int argc, char * argv[]) {
...
@@ -420,9 +421,6 @@ int main(int argc, char * argv[]) {
establishListen
(
&
options
);
establishListen
(
&
options
);
/*
* lose privileges as early as possible
*/
changeToUser
(
&
options
);
changeToUser
(
&
options
);
openLogFiles
(
&
options
,
&
out
,
&
err
);
openLogFiles
(
&
options
,
&
out
,
&
err
);
...
@@ -443,6 +441,7 @@ int main(int argc, char * argv[]) {
...
@@ -443,6 +441,7 @@ int main(int argc, char * argv[]) {
initPlayerData
();
initPlayerData
();
initVolume
();
initVolume
();
initInterfaces
();
initInterfaces
();
initInputStream
();
daemonize
(
&
options
);
daemonize
(
&
options
);
...
...
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