install error

This commit is contained in:
TenderIronh
2021-12-21 14:41:07 +08:00
parent 2d6521be43
commit a528441342
4 changed files with 25 additions and 14 deletions

View File

@@ -48,7 +48,10 @@ func (c *Config) add(app AppConfig) {
func (c *Config) save() {
data, _ := json.MarshalIndent(c, "", "")
ioutil.WriteFile("config.json", data, 0644)
err := ioutil.WriteFile("config.json", data, 0644)
if err != nil {
gLog.Println(LevelERROR, "save config.json error:", err)
}
}
func (c *Config) load() error {

View File

@@ -148,11 +148,15 @@ func install() {
config.SrcPort = *srcPort
config.Protocol = *protocol
gConf.add(config)
os.Chdir(defaultInstallPath)
os.MkdirAll(defaultInstallPath, 0775)
err := os.Chdir(defaultInstallPath)
if err != nil {
gLog.Println(LevelERROR, "cd error:", err)
}
gConf.save()
// copy files
os.MkdirAll(defaultInstallPath, 0775)
targetPath := filepath.Join(defaultInstallPath, defaultBinName)
binPath, _ := os.Executable()
src, errFiles := os.Open(binPath) // can not use args[0], on Windows call openp2p is ok(=openp2p.exe)
@@ -180,7 +184,7 @@ func install() {
// args := []string{""}
gLog.Println(LevelINFO, "targetPath:", targetPath)
err := d.Control("install", targetPath, []string{"-d", "-f"})
err = d.Control("install", targetPath, []string{"-d", "-f"})
if err != nil {
gLog.Println(LevelERROR, "install system service error:", err)
} else {

13
errorcode.go Normal file
View File

@@ -0,0 +1,13 @@
package main
import (
"errors"
)
// error message
var (
// ErrorS2S string = "s2s is not supported"
// ErrorHandshake string = "handshake error"
ErrorS2S = errors.New("s2s is not supported")
ErrorHandshake = errors.New("handshake error")
)

View File

@@ -4,14 +4,13 @@ import (
"bytes"
"encoding/binary"
"encoding/json"
"errors"
"hash/crc64"
"math/big"
"net"
"time"
)
const OpenP2PVersion = "0.97.0"
const OpenP2PVersion = "0.97.1"
const ProducnName string = "openp2p"
type openP2PHeader struct {
@@ -131,14 +130,6 @@ const (
NatTestTimeout = time.Second * 10
)
// error message
var (
// ErrorS2S string = "s2s is not supported"
// ErrorHandshake string = "handshake error"
ErrorS2S = errors.New("s2s is not supported")
ErrorHandshake = errors.New("handshake error")
)
// NATNone has public ip
const (
NATNone = 0