package main

import "C"
import (
	"virjar.com/majora-go/client"
	"virjar.com/majora-go/model"
)

//export NewDefClient
func NewDefClient(asyn C.int, account *C.char) {
	conf := model.NewDefMajoraConf()

	newAccount := C.GoString(account)

	if len(newAccount) > 0 {
		conf.Extra.Account = newAccount
	}

	cli := client.NewCli(conf)

	if int(asyn) > 0 {
		go cli.StartUp()
	} else {
		cli.StartUp()
	}
}

//export NewClientWithNatServer
func NewClientWithNatServer(addr *C.char, clientID *C.char, asyn C.int, account *C.char) {
	conf := model.NewDefMajoraConf()

	newAddr := C.GoString(addr)
	newClientID := C.GoString(clientID)
	newAccount := C.GoString(account)
	if len(newAddr) > 0 {
		conf.TunnelAddr = newAddr
	}
	if len(newClientID) > 0 {
		conf.ClientID = newClientID
	}

	if len(newAccount) > 0 {
		conf.Extra.Account = newAccount
	}
	cli := client.NewCli(conf)
	if int(asyn) > 0 {
		go cli.StartUp()
	} else {
		cli.StartUp()
	}
}

func main() {}
