@@ -40,19 +40,90 @@ typedef struct git_stream {
4040 void (* free )(struct git_stream * );
4141} git_stream ;
4242
43- typedef int (* git_stream_cb )(git_stream * * out , const char * host , const char * port );
43+ typedef struct {
44+ /** The `version` field should be set to `GIT_STREAM_VERSION`. */
45+ int version ;
46+
47+ /**
48+ * Called to create a new connection to a given host.
49+ *
50+ * @param out The created stream
51+ * @param host The hostname to connect to; may be a hostname or
52+ * IP address
53+ * @param port The port to connect to; may be a port number or
54+ * service name
55+ * @return 0 or an error code
56+ */
57+ int (* init )(git_stream * * out , const char * host , const char * port );
58+
59+ /**
60+ * Called to create a new connection on top of the given stream. If
61+ * this is a TLS stream, then this function may be used to proxy a
62+ * TLS stream over an HTTP CONNECT session. If this is unset, then
63+ * HTTP CONNECT proxies will not be supported.
64+ *
65+ * @param out The created stream
66+ * @param in An existing stream to add TLS to
67+ * @param host The hostname that the stream is connected to,
68+ * for certificate validation
69+ * @return 0 or an error code
70+ */
71+ int (* wrap )(git_stream * * out , git_stream * in , const char * host );
72+ } git_stream_registration ;
4473
4574/**
46- * Register a TLS stream constructor for the library to use
75+ * The type of stream to register.
76+ */
77+ typedef enum {
78+ /** A standard (non-TLS) socket. */
79+ GIT_STREAM_STANDARD = 1 ,
80+
81+ /** A TLS-encrypted socket. */
82+ GIT_STREAM_TLS = 2 ,
83+ } git_stream_t ;
84+
85+ /**
86+ * Register stream constructors for the library to use
87+ *
88+ * If a registration structure is already set, it will be overwritten.
89+ * Pass `NULL` in order to deregister the current constructor and return
90+ * to the system defaults.
4791 *
48- * If a constructor is already set, it will be overwritten. Pass
49- * `NULL` in order to deregister the current constructor.
92+ * The type parameter may be a bitwise AND of types.
5093 *
51- * @param ctor the constructor to use
94+ * @param type the type or types of stream to register
95+ * @param registration the registration data
5296 * @return 0 or an error code
5397 */
98+ GIT_EXTERN (int ) git_stream_register (
99+ git_stream_t type , git_stream_registration * registration );
100+
101+ /** @name Deprecated TLS Stream Registration Functions
102+ *
103+ * These typedefs and functions are retained for backward compatibility.
104+ * The newer versions of these functions and structures should be preferred
105+ * in all new code.
106+ */
107+
108+ /**@{*/
109+
110+ /**
111+ * @deprecated Provide a git_stream_registration to git_stream_register
112+ * @see git_stream_registration
113+ */
114+ typedef int (* git_stream_cb )(git_stream * * out , const char * host , const char * port );
115+
116+ /**
117+ * Register a TLS stream constructor for the library to use. This stream
118+ * will not support HTTP CONNECT proxies.
119+ *
120+ * @deprecated Provide a git_stream_registration to git_stream_register
121+ * @see git_stream_register
122+ */
54123GIT_EXTERN (int ) git_stream_register_tls (git_stream_cb ctor );
55124
125+ /**@}*/
126+
56127GIT_END_DECL
57128
58129#endif
0 commit comments