diff --git a/_gnutls.h b/_gnutls.h index bea1972..acfef48 100644 --- a/_gnutls.h +++ b/_gnutls.h @@ -18,8 +18,8 @@ extern int OnDataReadCallback(void *, char *, int); extern int OnDataWriteCallback(void *, char *, int); extern int OnDataTimeoutRead(void *, int); -struct session *init_client_session(); -struct session *init_server_session(); +struct session *init_gnutls_client_session(); +struct session *init_gnutls_server_session(); 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); diff --git a/gnutls.c b/gnutls.c index d8f4fe4..6dffda3 100644 --- a/gnutls.c +++ b/gnutls.c @@ -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, 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)); memset(sess, sizeof(struct session), 0); @@ -23,7 +23,7 @@ struct session *init_client_session() return sess; } -struct session *init_server_session() +struct session *init_gnutls_server_session() { struct session *sess = malloc(sizeof(struct session)); memset(sess, sizeof(struct session), 0); @@ -48,7 +48,7 @@ int _init_session(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_certificate_free_credentials(sess->xcred); free(sess); diff --git a/tls.go b/tls.go index 627a212..037147f 100644 --- a/tls.go +++ b/tls.go @@ -101,7 +101,7 @@ func Listen(network, addr string, cfg *Config) (net.Listener, error) { // NewServerConn create a server TLS Conn on c 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} n := C.size_t(uintptr(unsafe.Pointer(conn))) //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 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} n := C.size_t(uintptr(unsafe.Pointer(conn))) //log.Println("conn addr ", int(n))