Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
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
lvzhengyang
git2
Commits
b373e9a6
Commit
b373e9a6
authored
Sep 21, 2015
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: use proxy options struct in the stream config
parent
22e6aa0d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
16 deletions
+46
-16
include/git2/sys/stream.h
+2
-1
src/curl_stream.c
+8
-2
src/openssl_stream.c
+2
-2
src/stream.h
+2
-2
src/transports/http.c
+32
-9
No files found.
include/git2/sys/stream.h
View file @
b373e9a6
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
#include "git2/common.h"
#include "git2/common.h"
#include "git2/types.h"
#include "git2/types.h"
#include "git2/proxy.h"
GIT_BEGIN_DECL
GIT_BEGIN_DECL
...
@@ -32,7 +33,7 @@ typedef struct git_stream {
...
@@ -32,7 +33,7 @@ typedef struct git_stream {
int
proxy_support
;
int
proxy_support
;
int
(
*
connect
)(
struct
git_stream
*
);
int
(
*
connect
)(
struct
git_stream
*
);
int
(
*
certificate
)(
git_cert
**
,
struct
git_stream
*
);
int
(
*
certificate
)(
git_cert
**
,
struct
git_stream
*
);
int
(
*
set_proxy
)(
struct
git_stream
*
,
const
char
*
proxy_url
);
int
(
*
set_proxy
)(
struct
git_stream
*
,
const
git_proxy_options
*
proxy_opts
);
ssize_t
(
*
read
)(
struct
git_stream
*
,
void
*
,
size_t
);
ssize_t
(
*
read
)(
struct
git_stream
*
,
void
*
,
size_t
);
ssize_t
(
*
write
)(
struct
git_stream
*
,
const
char
*
,
size_t
,
int
);
ssize_t
(
*
write
)(
struct
git_stream
*
,
const
char
*
,
size_t
,
int
);
int
(
*
close
)(
struct
git_stream
*
);
int
(
*
close
)(
struct
git_stream
*
);
...
...
src/curl_stream.c
View file @
b373e9a6
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include "git2/transport.h"
#include "git2/transport.h"
#include "buffer.h"
#include "buffer.h"
#include "vector.h"
#include "vector.h"
#include "proxy.h"
typedef
struct
{
typedef
struct
{
git_stream
parent
;
git_stream
parent
;
...
@@ -21,6 +22,7 @@ typedef struct {
...
@@ -21,6 +22,7 @@ typedef struct {
char
curl_error
[
CURL_ERROR_SIZE
+
1
];
char
curl_error
[
CURL_ERROR_SIZE
+
1
];
git_cert_x509
cert_info
;
git_cert_x509
cert_info
;
git_strarray
cert_info_strings
;
git_strarray
cert_info_strings
;
git_proxy_options
proxy
;
}
curl_stream
;
}
curl_stream
;
static
int
seterr_curl
(
curl_stream
*
s
)
static
int
seterr_curl
(
curl_stream
*
s
)
...
@@ -95,12 +97,16 @@ static int curls_certificate(git_cert **out, git_stream *stream)
...
@@ -95,12 +97,16 @@ static int curls_certificate(git_cert **out, git_stream *stream)
return
0
;
return
0
;
}
}
static
int
curls_set_proxy
(
git_stream
*
stream
,
const
char
*
proxy_url
)
static
int
curls_set_proxy
(
git_stream
*
stream
,
const
git_proxy_options
*
proxy_opts
)
{
{
int
error
;
CURLcode
res
;
CURLcode
res
;
curl_stream
*
s
=
(
curl_stream
*
)
stream
;
curl_stream
*
s
=
(
curl_stream
*
)
stream
;
if
((
res
=
curl_easy_setopt
(
s
->
handle
,
CURLOPT_PROXY
,
proxy_url
))
!=
CURLE_OK
)
if
((
error
=
git_proxy_options_dup
(
&
s
->
proxy
,
proxy_opts
))
<
0
)
return
error
;
if
((
res
=
curl_easy_setopt
(
s
->
handle
,
CURLOPT_PROXY
,
s
->
proxy
.
url
))
!=
CURLE_OK
)
return
seterr_curl
(
s
);
return
seterr_curl
(
s
);
return
0
;
return
0
;
...
...
src/openssl_stream.c
View file @
b373e9a6
...
@@ -496,11 +496,11 @@ int openssl_certificate(git_cert **out, git_stream *stream)
...
@@ -496,11 +496,11 @@ int openssl_certificate(git_cert **out, git_stream *stream)
return
0
;
return
0
;
}
}
static
int
openssl_set_proxy
(
git_stream
*
stream
,
const
char
*
proxy_url
)
static
int
openssl_set_proxy
(
git_stream
*
stream
,
const
git_proxy_options
*
proxy_opts
)
{
{
openssl_stream
*
st
=
(
openssl_stream
*
)
stream
;
openssl_stream
*
st
=
(
openssl_stream
*
)
stream
;
return
git_stream_set_proxy
(
st
->
io
,
proxy_
url
);
return
git_stream_set_proxy
(
st
->
io
,
proxy_
opts
);
}
}
ssize_t
openssl_write
(
git_stream
*
stream
,
const
char
*
data
,
size_t
len
,
int
flags
)
ssize_t
openssl_write
(
git_stream
*
stream
,
const
char
*
data
,
size_t
len
,
int
flags
)
...
...
src/stream.h
View file @
b373e9a6
...
@@ -35,14 +35,14 @@ GIT_INLINE(int) git_stream_supports_proxy(git_stream *st)
...
@@ -35,14 +35,14 @@ GIT_INLINE(int) git_stream_supports_proxy(git_stream *st)
return
st
->
proxy_support
;
return
st
->
proxy_support
;
}
}
GIT_INLINE
(
int
)
git_stream_set_proxy
(
git_stream
*
st
,
const
char
*
proxy_url
)
GIT_INLINE
(
int
)
git_stream_set_proxy
(
git_stream
*
st
,
const
git_proxy_options
*
proxy_opts
)
{
{
if
(
!
st
->
proxy_support
)
{
if
(
!
st
->
proxy_support
)
{
giterr_set
(
GITERR_INVALID
,
"proxy not supported on this stream"
);
giterr_set
(
GITERR_INVALID
,
"proxy not supported on this stream"
);
return
-
1
;
return
-
1
;
}
}
return
st
->
set_proxy
(
st
,
proxy_
url
);
return
st
->
set_proxy
(
st
,
proxy_
opts
);
}
}
GIT_INLINE
(
ssize_t
)
git_stream_read
(
git_stream
*
st
,
void
*
data
,
size_t
len
)
GIT_INLINE
(
ssize_t
)
git_stream_read
(
git_stream
*
st
,
void
*
data
,
size_t
len
)
...
...
src/transports/http.c
View file @
b373e9a6
...
@@ -555,10 +555,40 @@ static int write_chunk(git_stream *io, const char *buffer, size_t len)
...
@@ -555,10 +555,40 @@ static int write_chunk(git_stream *io, const char *buffer, size_t len)
return
0
;
return
0
;
}
}
static
int
apply_proxy_config
(
http_subtransport
*
t
)
{
int
error
;
git_proxy_t
proxy_type
;
if
(
!
git_stream_supports_proxy
(
t
->
io
))
return
0
;
proxy_type
=
t
->
owner
->
proxy
.
type
;
if
(
proxy_type
==
GIT_PROXY_NONE
)
return
0
;
if
(
proxy_type
==
GIT_PROXY_AUTO
)
{
char
*
url
;
git_proxy_options
opts
=
GIT_PROXY_OPTIONS_INIT
;
if
((
error
=
git_remote__get_http_proxy
(
t
->
owner
->
owner
,
!!
t
->
connection_data
.
use_ssl
,
&
url
))
<
0
)
return
error
;
opts
.
type
=
GIT_PROXY_HTTP
;
opts
.
url
=
url
;
error
=
git_stream_set_proxy
(
t
->
io
,
&
opts
);
git__free
(
url
);
return
error
;
}
return
git_stream_set_proxy
(
t
->
io
,
&
t
->
owner
->
proxy
);
}
static
int
http_connect
(
http_subtransport
*
t
)
static
int
http_connect
(
http_subtransport
*
t
)
{
{
int
error
;
int
error
;
char
*
proxy_url
;
if
(
t
->
connected
&&
if
(
t
->
connected
&&
http_should_keep_alive
(
&
t
->
parser
)
&&
http_should_keep_alive
(
&
t
->
parser
)
&&
...
@@ -586,14 +616,7 @@ static int http_connect(http_subtransport *t)
...
@@ -586,14 +616,7 @@ static int http_connect(http_subtransport *t)
GITERR_CHECK_VERSION
(
t
->
io
,
GIT_STREAM_VERSION
,
"git_stream"
);
GITERR_CHECK_VERSION
(
t
->
io
,
GIT_STREAM_VERSION
,
"git_stream"
);
if
(
git_stream_supports_proxy
(
t
->
io
)
&&
apply_proxy_config
(
t
);
!
git_remote__get_http_proxy
(
t
->
owner
->
owner
,
!!
t
->
connection_data
.
use_ssl
,
&
proxy_url
))
{
error
=
git_stream_set_proxy
(
t
->
io
,
proxy_url
);
git__free
(
proxy_url
);
if
(
error
<
0
)
return
error
;
}
error
=
git_stream_connect
(
t
->
io
);
error
=
git_stream_connect
(
t
->
io
);
...
...
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