mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-07-27 12:42:49 +02:00
Some CGo fixes.
This commit is contained in:
parent
1970dab13d
commit
33269cd29d
2 changed files with 9 additions and 9 deletions
|
@ -42,8 +42,8 @@ func NewEndpointFromString(s string) (*Endpoint, error) {
|
||||||
if strings.IndexRune(s, '-') > 0 || (strings.IndexRune(s, ':') < 0 && strings.IndexRune(s, '.') < 0) {
|
if strings.IndexRune(s, '-') > 0 || (strings.IndexRune(s, ':') < 0 && strings.IndexRune(s, '.') < 0) {
|
||||||
var ep Endpoint
|
var ep Endpoint
|
||||||
cs := C.CString(s)
|
cs := C.CString(s)
|
||||||
defer C.free(cs)
|
defer C.free(unsafe.Pointer(cs))
|
||||||
if C.ZT_Endpoint_fromString(cs) == nil {
|
if C.ZT_Endpoint_fromString(&ep.cep, cs) != 0 {
|
||||||
return nil, ErrInvalidParameter
|
return nil, ErrInvalidParameter
|
||||||
}
|
}
|
||||||
return &ep, nil
|
return &ep, nil
|
||||||
|
@ -115,7 +115,7 @@ func (ep *Endpoint) MAC() MAC {
|
||||||
|
|
||||||
func (ep *Endpoint) String() string {
|
func (ep *Endpoint) String() string {
|
||||||
var buf [4096]byte
|
var buf [4096]byte
|
||||||
cs := C.ZT_Endpoint_toString(&ep.cep,unsafe.Pointer(&buf[0]),4096)
|
cs := C.ZT_Endpoint_toString(&ep.cep, (*C.char)(unsafe.Pointer(&buf[0])), 4096)
|
||||||
if cs == nil {
|
if cs == nil {
|
||||||
return "0"
|
return "0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,8 @@ func NewLocatorFromString(s string) (*Locator, error) {
|
||||||
}
|
}
|
||||||
sb := []byte(s)
|
sb := []byte(s)
|
||||||
sb = append(sb, 0)
|
sb = append(sb, 0)
|
||||||
loc := C.ZT_Locator_fromString(unsafe.Pointer(&sb[0]))
|
loc := C.ZT_Locator_fromString((*C.char)(unsafe.Pointer(&sb[0])))
|
||||||
if uintptr(loc) == 0 {
|
if loc == nil {
|
||||||
return nil, ErrInvalidParameter
|
return nil, ErrInvalidParameter
|
||||||
}
|
}
|
||||||
goloc := new(Locator)
|
goloc := new(Locator)
|
||||||
|
@ -104,7 +104,7 @@ func (loc *Locator) GetInfo(id *Identity) (ts int64, fp *Fingerprint, eps []Endp
|
||||||
|
|
||||||
func (loc *Locator) String() string {
|
func (loc *Locator) String() string {
|
||||||
var buf [4096]byte
|
var buf [4096]byte
|
||||||
C.ZT_Locator_toString(loc.cl,unsafe.Pointer(&buf[0]),4096)
|
C.ZT_Locator_toString(loc.cl, (*C.char)(unsafe.Pointer(&buf[0])), 4096)
|
||||||
for i := range buf {
|
for i := range buf {
|
||||||
if buf[i] == 0 {
|
if buf[i] == 0 {
|
||||||
return string(buf[0:i])
|
return string(buf[0:i])
|
||||||
|
|
Loading…
Add table
Reference in a new issue