forked from SagerNet/cronet-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquic_hint.go
52 lines (41 loc) · 1.13 KB
/
quic_hint.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package cronet
// #include <stdlib.h>
// #include <stdbool.h>
// #include <cronet_c.h>
import "C"
import (
"unsafe"
)
// QuicHint hint that |host| supports QUIC.
type QuicHint struct {
ptr C.Cronet_QuicHintPtr
}
func NewQuicHint() QuicHint {
return QuicHint{C.Cronet_QuicHint_Create()}
}
func (h QuicHint) Destroy() {
C.Cronet_QuicHint_Destroy(h.ptr)
}
// SetHost set name of the host that supports QUIC.
func (h QuicHint) SetHost(host string) {
cHost := C.CString(host)
C.Cronet_QuicHint_host_set(h.ptr, cHost)
C.free(unsafe.Pointer(cHost))
}
func (h QuicHint) Host() string {
return C.GoString(C.Cronet_QuicHint_host_get(h.ptr))
}
// SetPort set port of the server that supports QUIC.
func (h QuicHint) SetPort(port int32) {
C.Cronet_QuicHint_port_set(h.ptr, C.int32_t(port))
}
func (h QuicHint) Port() int32 {
return int32(C.Cronet_QuicHint_port_get(h.ptr))
}
// SetAlternatePort set alternate port to use for QUIC
func (h QuicHint) SetAlternatePort(port int32) {
C.Cronet_QuicHint_alternate_port_set(h.ptr, C.int32_t(port))
}
func (h QuicHint) AlternatePort() int32 {
return int32(C.Cronet_QuicHint_alternate_port_get(h.ptr))
}