Skip to content

Commit

Permalink
install error
Browse files Browse the repository at this point in the history
  • Loading branch information
TenderIronh committed Dec 21, 2021
1 parent 2d6521b commit a528441
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
5 changes: 4 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 7 additions & 3 deletions daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
13 changes: 13 additions & 0 deletions errorcode.go
Original file line number Diff line number Diff line change
@@ -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")
)
11 changes: 1 addition & 10 deletions protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a528441

Please sign in to comment.