// 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 }
// 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 }
// 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 }
// 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 }
// 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 }
// 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 }