mirror of
https://github.com/openziti/desktop-edge-win.git
synced 2026-10-14 16:50:03 +00:00
@@ -7,15 +7,33 @@ void libuv_stopper(uv_async_t *a) {
|
||||
uv_stop(a->loop);
|
||||
}
|
||||
|
||||
void setLogOut(intptr_t h) {
|
||||
int fd = _open_osfhandle(h, _O_APPEND | _O_RDONLY);
|
||||
|
||||
if (fd == -1) {
|
||||
fprintf(stderr, "failed to get fd from handle: %d\n", errno);
|
||||
fflush(stderr);
|
||||
return;
|
||||
}
|
||||
|
||||
FILE *f = _fdopen(fd, "a+");
|
||||
if (f == NULL) {
|
||||
fprintf(stderr, "setLogOut: %d\n", errno);
|
||||
fflush(stderr);
|
||||
return;
|
||||
}
|
||||
|
||||
ziti_set_log(f);
|
||||
}
|
||||
|
||||
void libuv_init(libuv_ctx *lctx) {
|
||||
init_debug();
|
||||
lctx->l = uv_default_loop();
|
||||
uv_async_init(lctx->l, &lctx->stopper, libuv_stopper);
|
||||
}
|
||||
|
||||
void libuv_runner(void *arg) {
|
||||
init_debug();
|
||||
ZITI_LOG(INFO, "starting event loop");
|
||||
fflush(stdout);
|
||||
uv_loop_t *l = arg;
|
||||
uv_run(l, UV_RUN_DEFAULT);
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"os"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
@@ -28,7 +29,12 @@ func init() {
|
||||
C.libuv_init(_impl.libuvCtx)
|
||||
}
|
||||
|
||||
func SetLog(f *os.File) {
|
||||
C.setLogOut(C.intptr_t(f.Fd()))
|
||||
}
|
||||
|
||||
func Start() {
|
||||
|
||||
v := C.NF_get_version()
|
||||
log.Infof("starting ziti-sdk-c %s(%s)[%s]", C.GoString(v.version), C.GoString(v.revision), C.GoString(v.build_date))
|
||||
|
||||
|
||||
@@ -23,4 +23,6 @@ void libuv_runner(void *arg);
|
||||
void libuv_run(libuv_ctx *lctx);
|
||||
void libuv_stop(libuv_ctx *lctx);
|
||||
|
||||
void setLogOut(intptr_t h);
|
||||
|
||||
extern const char** all_configs;
|
||||
@@ -96,6 +96,12 @@ func main() {
|
||||
fmt.Println("running")
|
||||
cziti.DnsInit(ipv4ip, 24)
|
||||
|
||||
logFile, err := os.OpenFile("cziti.log", os.O_RDWR | os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cziti.SetLog(logFile)
|
||||
|
||||
cziti.Start()
|
||||
_, err = cziti.HookupTun(tunDevice, dns)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user