1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/glib"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16// vtable for a #GDtlsClientConnection implementation.
17type DtlsClientConnectionInterface struct {
18 _ structs.HostLayout
19
20 GIface uintptr
21}
22
23func (x *DtlsClientConnectionInterface) GoPointer() uintptr {
24 return uintptr(unsafe.Pointer(x))
25}
26
27// `GDtlsClientConnection` is the client-side subclass of
28// [iface@Gio.DtlsConnection], representing a client-side DTLS connection.
29type DtlsClientConnection interface {
30 GoPointer() uintptr
31 SetGoPointer(uintptr)
32 GetAcceptedCas() *glib.List
33 GetServerIdentity() *SocketConnectableBase
34 GetValidationFlags() TlsCertificateFlags
35 SetServerIdentity(IdentityVar SocketConnectable)
36 SetValidationFlags(FlagsVar TlsCertificateFlags)
37}
38
39var xDtlsClientConnectionGLibType func() types.GType
40
41func DtlsClientConnectionGLibType() types.GType {
42 return xDtlsClientConnectionGLibType()
43}
44
45type DtlsClientConnectionBase struct {
46 Ptr uintptr
47}
48
49func (x *DtlsClientConnectionBase) GoPointer() uintptr {
50 if x == nil {
51 return 0
52 }
53 return x.Ptr
54}
55
56func (x *DtlsClientConnectionBase) SetGoPointer(ptr uintptr) {
57 x.Ptr = ptr
58}
59
60// Gets the list of distinguished names of the Certificate Authorities
61// that the server will accept certificates from. This will be set
62// during the TLS handshake if the server requests a certificate.
63// Otherwise, it will be %NULL.
64//
65// Each item in the list is a #GByteArray which contains the complete
66// subject DN of the certificate authority.
67func (x *DtlsClientConnectionBase) GetAcceptedCas() *glib.List {
68
69 cret := XGDtlsClientConnectionGetAcceptedCas(x.GoPointer())
70 return cret
71}
72
73// Gets @conn's expected server identity
74func (x *DtlsClientConnectionBase) GetServerIdentity() *SocketConnectableBase {
75 var cls *SocketConnectableBase
76
77 cret := XGDtlsClientConnectionGetServerIdentity(x.GoPointer())
78
79 if cret == 0 {
80 return nil
81 }
82 gobject.IncreaseRef(cret)
83 cls = &SocketConnectableBase{}
84 cls.Ptr = cret
85 return cls
86}
87
88// Gets @conn's validation flags
89//
90// This function does not work as originally designed and is impossible
91// to use correctly. See #GDtlsClientConnection:validation-flags for more
92// information.
93func (x *DtlsClientConnectionBase) GetValidationFlags() TlsCertificateFlags {
94
95 cret := XGDtlsClientConnectionGetValidationFlags(x.GoPointer())
96 return cret
97}
98
99// Sets @conn's expected server identity, which is used both to tell
100// servers on virtual hosts which certificate to present, and also
101// to let @conn know what name to look for in the certificate when
102// performing %G_TLS_CERTIFICATE_BAD_IDENTITY validation, if enabled.
103func (x *DtlsClientConnectionBase) SetServerIdentity(IdentityVar SocketConnectable) {
104
105 XGDtlsClientConnectionSetServerIdentity(x.GoPointer(), IdentityVar.GoPointer())
106
107}
108
109// Sets @conn's validation flags, to override the default set of
110// checks performed when validating a server certificate. By default,
111// %G_TLS_CERTIFICATE_VALIDATE_ALL is used.
112//
113// This function does not work as originally designed and is impossible
114// to use correctly. See #GDtlsClientConnection:validation-flags for more
115// information.
116func (x *DtlsClientConnectionBase) SetValidationFlags(FlagsVar TlsCertificateFlags) {
117
118 XGDtlsClientConnectionSetValidationFlags(x.GoPointer(), FlagsVar)
119
120}
121
122var XGDtlsClientConnectionGetAcceptedCas func(uintptr) *glib.List
123var XGDtlsClientConnectionGetServerIdentity func(uintptr) uintptr
124var XGDtlsClientConnectionGetValidationFlags func(uintptr) TlsCertificateFlags
125var XGDtlsClientConnectionSetServerIdentity func(uintptr, uintptr)
126var XGDtlsClientConnectionSetValidationFlags func(uintptr, TlsCertificateFlags)
127
128var xDtlsClientConnectionNew func(uintptr, uintptr, **glib.Error) uintptr
129
130// Creates a new #GDtlsClientConnection wrapping @base_socket which is
131// assumed to communicate with the server identified by @server_identity.
132func DtlsClientConnectionNew(BaseSocketVar DatagramBased, ServerIdentityVar SocketConnectable) (*DtlsClientConnectionBase, error) {
133 var cls *DtlsClientConnectionBase
134 var cerr *glib.Error
135
136 cret := xDtlsClientConnectionNew(BaseSocketVar.GoPointer(), ServerIdentityVar.GoPointer(), &cerr)
137
138 if cret == 0 {
139 return nil, cerr
140 }
141 cls = &DtlsClientConnectionBase{}
142 cls.Ptr = cret
143 if cerr == nil {
144 return cls, nil
145 }
146 return cls, cerr
147
148}
149
150func init() {
151 core.SetPackageName("GIO", "gio-2.0")
152 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
153 var libs []uintptr
154 for _, libPath := range core.GetPaths("GIO") {
155 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
156 if err != nil {
157 panic(err)
158 }
159 libs = append(libs, lib)
160 }
161
162 core.PuregoSafeRegister(&xDtlsClientConnectionNew, libs, "g_dtls_client_connection_new")
163
164 core.PuregoSafeRegister(&xDtlsClientConnectionGLibType, libs, "g_dtls_client_connection_get_type")
165
166 core.PuregoSafeRegister(&XGDtlsClientConnectionGetAcceptedCas, libs, "g_dtls_client_connection_get_accepted_cas")
167 core.PuregoSafeRegister(&XGDtlsClientConnectionGetServerIdentity, libs, "g_dtls_client_connection_get_server_identity")
168 core.PuregoSafeRegister(&XGDtlsClientConnectionGetValidationFlags, libs, "g_dtls_client_connection_get_validation_flags")
169 core.PuregoSafeRegister(&XGDtlsClientConnectionSetServerIdentity, libs, "g_dtls_client_connection_set_server_identity")
170 core.PuregoSafeRegister(&XGDtlsClientConnectionSetValidationFlags, libs, "g_dtls_client_connection_set_validation_flags")
171
172}