change function name

master
fangdingjun 6 years ago
parent bba44e0f99
commit 387719e6f0

@ -18,8 +18,8 @@ extern int OnDataReadCallback(void *, char *, int);
extern int OnDataWriteCallback(void *, char *, int); extern int OnDataWriteCallback(void *, char *, int);
extern int OnDataTimeoutRead(void *, int); extern int OnDataTimeoutRead(void *, int);
struct session *init_client_session(); struct session *init_gnutls_client_session();
struct session *init_server_session(); struct session *init_gnutls_server_session();
int pull_timeout_function(gnutls_transport_ptr_t ptr, unsigned int ms); int pull_timeout_function(gnutls_transport_ptr_t ptr, unsigned int ms);
ssize_t pull_function(gnutls_transport_ptr_t ptr, void *data, size_t len); ssize_t pull_function(gnutls_transport_ptr_t ptr, void *data, size_t len);

@ -12,7 +12,7 @@ int cert_select_callback(gnutls_session_t sess, const gnutls_datum_t *req_ca_dn,
int pk_algos_length, gnutls_pcert_st **pcert, int pk_algos_length, gnutls_pcert_st **pcert,
unsigned int *pcert_length, gnutls_privkey_t *pkey); unsigned int *pcert_length, gnutls_privkey_t *pkey);
struct session *init_client_session() struct session *init_gnutls_client_session()
{ {
struct session *sess = malloc(sizeof(struct session)); struct session *sess = malloc(sizeof(struct session));
memset(sess, sizeof(struct session), 0); memset(sess, sizeof(struct session), 0);
@ -23,7 +23,7 @@ struct session *init_client_session()
return sess; return sess;
} }
struct session *init_server_session() struct session *init_gnutls_server_session()
{ {
struct session *sess = malloc(sizeof(struct session)); struct session *sess = malloc(sizeof(struct session));
memset(sess, sizeof(struct session), 0); memset(sess, sizeof(struct session), 0);
@ -48,7 +48,7 @@ int _init_session(struct session *sess)
void session_destroy(struct session *sess) void session_destroy(struct session *sess)
{ {
gnutls_bye(sess->session, GNUTLS_SHUT_RDWR); gnutls_bye(sess->session, GNUTLS_SHUT_WR);
gnutls_deinit(sess->session); gnutls_deinit(sess->session);
gnutls_certificate_free_credentials(sess->xcred); gnutls_certificate_free_credentials(sess->xcred);
free(sess); free(sess);

@ -101,7 +101,7 @@ func Listen(network, addr string, cfg *Config) (net.Listener, error) {
// NewServerConn create a server TLS Conn on c // NewServerConn create a server TLS Conn on c
func NewServerConn(c net.Conn, cfg *Config) (*Conn, error) { func NewServerConn(c net.Conn, cfg *Config) (*Conn, error) {
var sess = C.init_server_session() var sess = C.init_gnutls_server_session()
conn := &Conn{c: c, sess: sess, cfg: cfg} conn := &Conn{c: c, sess: sess, cfg: cfg}
n := C.size_t(uintptr(unsafe.Pointer(conn))) n := C.size_t(uintptr(unsafe.Pointer(conn)))
//log.Println("conn addr ", int(n)) //log.Println("conn addr ", int(n))
@ -118,7 +118,7 @@ func NewServerConn(c net.Conn, cfg *Config) (*Conn, error) {
// NewClientConn create a client TLS Conn on c // NewClientConn create a client TLS Conn on c
func NewClientConn(c net.Conn, cfg *Config) (*Conn, error) { func NewClientConn(c net.Conn, cfg *Config) (*Conn, error) {
var sess = C.init_client_session() var sess = C.init_gnutls_client_session()
conn := &Conn{c: c, sess: sess, cfg: cfg} conn := &Conn{c: c, sess: sess, cfg: cfg}
n := C.size_t(uintptr(unsafe.Pointer(conn))) n := C.size_t(uintptr(unsafe.Pointer(conn)))
//log.Println("conn addr ", int(n)) //log.Println("conn addr ", int(n))

Loading…
Cancel
Save