Example #1
0
// SetBackend accepts a socket type and endpoint, and sends a message
// to the zactor thread telling it to set up a socket bound to the endpoint.
func (p *Proxy) SetBackend(sockType int, endpoint string) error {
	typeString := getStringType(sockType)

	rc := C.zstr_sendm(unsafe.Pointer(p.zactorT), C.CString("BACKEND"))
	if rc == -1 {
		return ErrActorCmd
	}

	rc = C.zstr_sendm(unsafe.Pointer(p.zactorT), C.CString(typeString))
	if rc == -1 {
		return ErrActorCmd
	}

	rc = C.zstr_send(unsafe.Pointer(p.zactorT), C.CString(endpoint))
	if rc == -1 {
		return ErrActorCmd
	}

	rc = C.zsock_wait(unsafe.Pointer(p.zactorT))
	if rc == -1 {
		return ErrActorCmd
	}

	return nil
}
Example #2
0
// SetBackend accepts a socket type and endpoint, and sends a message
// to the zactor thread telling it to set up a socket bound to the endpoint.
func (p *Proxy) SetBackend(sockType int, endpoint string) error {
	typeString := getStringType(sockType)

	cmd := C.CString("BACKEND")
	defer C.free(unsafe.Pointer(cmd))

	cTypeString := C.CString(typeString)
	defer C.free(unsafe.Pointer(cTypeString))

	cEndpoint := C.CString(endpoint)
	defer C.free(unsafe.Pointer(cEndpoint))

	rc := C.zstr_sendm(unsafe.Pointer(p.zactorT), cmd)
	if rc == -1 {
		return ErrActorCmd
	}

	rc = C.zstr_sendm(unsafe.Pointer(p.zactorT), cTypeString)
	if rc == -1 {
		return ErrActorCmd
	}

	rc = C.zstr_send(unsafe.Pointer(p.zactorT), cEndpoint)
	if rc == -1 {
		return ErrActorCmd
	}

	rc = C.zsock_wait(unsafe.Pointer(p.zactorT))
	if rc == -1 {
		return ErrActorCmd
	}

	return nil
}
Example #3
0
// Verbose sets the auth actor to log information to stdout.
func (a *Auth) Verbose() error {
	cmd := C.CString("VERBOSE")
	defer C.free(unsafe.Pointer(cmd))

	rc := C.zstr_send(unsafe.Pointer(a.zactorT), cmd)
	if rc == -1 {
		return ErrActorCmd
	}
	C.zsock_wait(unsafe.Pointer(a.zactorT))

	return nil
}
Example #4
0
// Curve sets auth method to curve
func (a *Auth) Curve(allowed string) error {
	cmd := C.CString("CURVE")
	defer C.free(unsafe.Pointer(cmd))

	cAllowed := C.CString(allowed)
	defer C.free(unsafe.Pointer(cAllowed))

	rc := C.zstr_sendm(unsafe.Pointer(a.zactorT), cmd)
	if rc == -1 {
		return ErrActorCmd
	}

	rc = C.zstr_send(unsafe.Pointer(a.zactorT), cAllowed)
	if rc == -1 {
		return ErrActorCmd
	}

	C.zsock_wait(unsafe.Pointer(a.zactorT))

	return nil
}
Example #5
0
// Allow removes a previous Deny
func (a *Auth) Allow(address string) error {
	cmd := C.CString("ALLOW")
	defer C.free(unsafe.Pointer(cmd))

	cAddress := C.CString(address)
	defer C.free(unsafe.Pointer(cAddress))

	rc := C.zstr_sendm(unsafe.Pointer(a.zactorT), cmd)
	if rc == -1 {
		return ErrActorCmd
	}

	rc = C.zstr_send(unsafe.Pointer(a.zactorT), cAddress)
	if rc == -1 {
		return ErrActorCmd
	}

	C.zsock_wait(unsafe.Pointer(a.zactorT))

	return nil
}
Example #6
0
// Plain sets auth method to plain
func (a *Auth) Plain(directory string) error {
	cmd := C.CString("PLAIN")
	defer C.free(unsafe.Pointer(cmd))

	cDirectory := C.CString(directory)
	defer C.free(unsafe.Pointer(cDirectory))

	rc := C.zstr_sendm(unsafe.Pointer(a.zactorT), cmd)
	if rc == -1 {
		return ErrActorCmd
	}

	rc = C.zstr_send(unsafe.Pointer(a.zactorT), cDirectory)
	if rc == -1 {
		return ErrActorCmd
	}

	C.zsock_wait(unsafe.Pointer(a.zactorT))

	return nil
}