|
@@ -32,16 +32,16 @@ func GetServerWGConf() (models.IntClient, error) {
|
|
|
|
|
|
func InstallNetclient() error {
|
|
|
|
|
|
- netclientPath := ncutils.GetNetclientPathSpecific()
|
|
|
+ netclientPath := ncutils.GetNetclientPath()
|
|
|
if !FileExists(netclientPath + "netclient") {
|
|
|
var err error
|
|
|
if ncutils.IsWindows() {
|
|
|
- _, err = copy(".\\netclient\\netclient", netclientPath+"netclient")
|
|
|
+ _, err = copy(".\\netclient\\netclient", netclientPath+"\\netclient")
|
|
|
} else {
|
|
|
- _, err = copy("./netclient/netclient", netclientPath+"netclient")
|
|
|
+ _, err = copy("./netclient/netclient", netclientPath+"/netclient")
|
|
|
}
|
|
|
if err != nil {
|
|
|
- log.Println("could not create " + netclientPath + "netclient")
|
|
|
+ log.Println("could not create " + netclientPath + "/netclient")
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
@@ -86,13 +86,13 @@ func copy(src, dst string) (int64, error) {
|
|
|
}
|
|
|
|
|
|
func RemoveNetwork(network string) (bool, error) {
|
|
|
- netclientPath := ncutils.GetNetclientPathSpecific()
|
|
|
- _, err := os.Stat(netclientPath + "netclient")
|
|
|
+ netclientPath := ncutils.GetNetclientPath()
|
|
|
+ _, err := os.Stat(netclientPath + "/netclient")
|
|
|
if err != nil {
|
|
|
- log.Println("could not find " + netclientPath + "netclient")
|
|
|
+ log.Println("could not find " + netclientPath + "/netclient")
|
|
|
return false, err
|
|
|
}
|
|
|
- _, err = ncutils.RunCmd(netclientPath+"netclient leave -n "+network, true)
|
|
|
+ _, err = ncutils.RunCmd(netclientPath+"/netclient leave -n "+network, true)
|
|
|
if err == nil {
|
|
|
log.Println("Server removed from network " + network)
|
|
|
}
|
|
@@ -102,22 +102,21 @@ func RemoveNetwork(network string) (bool, error) {
|
|
|
|
|
|
func InitServerNetclient() error {
|
|
|
netclientDir := ncutils.GetNetclientPath()
|
|
|
- netclientPath := ncutils.GetNetclientPathSpecific()
|
|
|
- _, err := os.Stat(netclientDir)
|
|
|
+ _, err := os.Stat(netclientDir+"/config")
|
|
|
if os.IsNotExist(err) {
|
|
|
- os.Mkdir(netclientDir, 744)
|
|
|
+ os.MkdirAll(netclientDir+"/config", 744)
|
|
|
} else if err != nil {
|
|
|
log.Println("could not find or create", netclientDir)
|
|
|
return err
|
|
|
}
|
|
|
- _, err = os.Stat(netclientPath + "netclient")
|
|
|
+ _, err = os.Stat(netclientDir + "/netclient")
|
|
|
if os.IsNotExist(err) {
|
|
|
err = InstallNetclient()
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
- err = os.Chmod(netclientPath+"netclient", 0755)
|
|
|
+ err = os.Chmod(netclientDir+"/netclient", 0755)
|
|
|
if err != nil {
|
|
|
log.Println("could not change netclient binary permissions")
|
|
|
return err
|
|
@@ -128,8 +127,8 @@ func InitServerNetclient() error {
|
|
|
func HandleContainedClient() error {
|
|
|
log.SetFlags(log.Flags() &^ (log.Llongfile | log.Lshortfile))
|
|
|
|
|
|
- netclientPath := ncutils.GetNetclientPathSpecific()
|
|
|
- checkinCMD := exec.Command(netclientPath+"netclient", "checkin", "-n", "all")
|
|
|
+ netclientPath := ncutils.GetNetclientPath()
|
|
|
+ checkinCMD := exec.Command(netclientPath+"/netclient", "checkin", "-n", "all")
|
|
|
if servercfg.GetVerbose() >= 2 {
|
|
|
checkinCMD.Stdout = os.Stdout
|
|
|
}
|
|
@@ -158,7 +157,7 @@ func AddNetwork(network string) (bool, error) {
|
|
|
log.Println("could not get public IP.")
|
|
|
return false, err
|
|
|
}
|
|
|
- netclientPath := ncutils.GetNetclientPathSpecific()
|
|
|
+ netclientPath := ncutils.GetNetclientPath()
|
|
|
|
|
|
token, err := functions.CreateServerToken(network)
|
|
|
if err != nil {
|
|
@@ -169,9 +168,9 @@ func AddNetwork(network string) (bool, error) {
|
|
|
functions.PrintUserLog(models.NODE_SERVER_NAME, "executing network join: "+netclientPath+"netclient "+"join "+"-t "+token+" -name "+models.NODE_SERVER_NAME+" -endpoint "+pubip, 0)
|
|
|
var joinCMD *exec.Cmd
|
|
|
if servercfg.IsClientMode() == "contained" {
|
|
|
- joinCMD = exec.Command(netclientPath+"netclient", "join", "-t", token, "-name", models.NODE_SERVER_NAME, "-endpoint", pubip, "-daemon", "off", "-dnson", "no")
|
|
|
+ joinCMD = exec.Command(netclientPath+"/netclient", "join", "-t", token, "-name", models.NODE_SERVER_NAME, "-endpoint", pubip, "-daemon", "off", "-dnson", "no")
|
|
|
} else {
|
|
|
- joinCMD = exec.Command(netclientPath+"netclient", "join", "-t", token, "-name", models.NODE_SERVER_NAME, "-endpoint", pubip)
|
|
|
+ joinCMD = exec.Command(netclientPath+"/netclient", "join", "-t", token, "-name", models.NODE_SERVER_NAME, "-endpoint", pubip)
|
|
|
}
|
|
|
joinCMD.Stdout = os.Stdout
|
|
|
joinCMD.Stderr = os.Stderr
|