diff --git a/README.md b/README.md index 199d72c..8838398 100644 --- a/README.md +++ b/README.md @@ -36,35 +36,35 @@ Here's an example of remote work: connecting to an office Windows computer at ho ### 1.Register Go to register a new user - ![image](/doc/images/register.png) + ![image](/doc/images/register_en.png) ### 2.Install Download on local and remote computers and double-click to run, one-click installation - ![image](/doc/images/install.png) + ![image](/doc/images/install_en.png) By default, Windows will block programs that have not been signed by the Microsoft's certificate, and you can select "Run anyway". - ![image](/doc/images/win10warn.png) + ![image](/doc/images/win10warn_en.png) - ![image](/doc/images/stillrun.png) + ![image](/doc/images/stillrun_en.png) ### 3.New P2PApp -![image](/doc/images/devices.png) +![image](/doc/images/devices_en.png) -![image](/doc/images/newapp.png) +![image](/doc/images/newapp_en.png) -![image](/doc/images/newappedit.png) +![image](/doc/images/newappedit_en.png) ### 4.Use P2PApp You can see the P2P application you just created on the "MyHomePC" device, just connect to the "local listening port" shown in the figure below. -![image](/doc/images/p2pappok.png) +![image](/doc/images/p2pappok_en.png) On MyHomePC, press Win+R and enter MSTSC to open the remote desktop, input `127.0.0.1:23389 /admin` - ![image](/doc/images/mstscconnect.png) + ![image](/doc/images/mstscconnect_en.png) - ![image](/doc/images/afterconnect.png) + ![image](/doc/images/afterconnect_en.png) ## Usage diff --git a/common.go b/common.go index 9456081..fd9d397 100644 --- a/common.go +++ b/common.go @@ -7,8 +7,10 @@ import ( "crypto/tls" "encoding/json" "fmt" + "math/rand" "net" "net/http" + "os" "os/exec" "time" ) @@ -148,3 +150,11 @@ func execOutput(name string, args ...string) string { cmdGetOsName.Run() return cmdOut.String() } + +func defaultNodeName() string { + name, _ := os.Hostname() + for len(name) < 8 { + name = fmt.Sprintf("%s%d", name, rand.Int()%10) + } + return name +} diff --git a/config.go b/config.go index c69a24a..9af4b64 100644 --- a/config.go +++ b/config.go @@ -119,7 +119,6 @@ type NetworkConfig struct { User string localIP string ipv6 string - hostName string mac string os string publicIP string @@ -184,6 +183,10 @@ func parseParams() { gConf.Network.ServerHost = *serverHost } if gConf.Network.Node == "" { + if *node == "" { // config and param's node both empty + hostname := defaultNodeName() + node = &hostname + } gConf.Network.Node = *node } if *token != 0 { diff --git a/daemon.go b/daemon.go index 7e26d67..0bd0c87 100644 --- a/daemon.go +++ b/daemon.go @@ -132,11 +132,11 @@ func install() { logLevel := installFlag.Int("loglevel", 1, "0:debug 1:info 2:warn 3:error") installFlag.Parse(os.Args[2:]) if *node != "" && len(*node) < 8 { - gLog.Println(LevelERROR, "node name too short, it must >=8 charaters") + gLog.Println(LevelERROR, ErrNodeTooShort) os.Exit(9) } if *node == "" { // if node name not set. use os.Hostname - hostname, _ := os.Hostname() + hostname := defaultNodeName() node = &hostname } gConf.load() // load old config. otherwise will clear all apps diff --git a/doc/images/afterconnect_en.png b/doc/images/afterconnect_en.png new file mode 100644 index 0000000..d7634b3 Binary files /dev/null and b/doc/images/afterconnect_en.png differ diff --git a/doc/images/devices_en.png b/doc/images/devices_en.png new file mode 100644 index 0000000..6d4eeea Binary files /dev/null and b/doc/images/devices_en.png differ diff --git a/doc/images/install_en.png b/doc/images/install_en.png new file mode 100644 index 0000000..8185404 Binary files /dev/null and b/doc/images/install_en.png differ diff --git a/doc/images/mstscconnect_en.png b/doc/images/mstscconnect_en.png new file mode 100644 index 0000000..6a98365 Binary files /dev/null and b/doc/images/mstscconnect_en.png differ diff --git a/doc/images/newapp_en.png b/doc/images/newapp_en.png new file mode 100644 index 0000000..309e784 Binary files /dev/null and b/doc/images/newapp_en.png differ diff --git a/doc/images/newappedit_en.png b/doc/images/newappedit_en.png new file mode 100644 index 0000000..2b96883 Binary files /dev/null and b/doc/images/newappedit_en.png differ diff --git a/doc/images/p2pappok_en.png b/doc/images/p2pappok_en.png new file mode 100644 index 0000000..217638f Binary files /dev/null and b/doc/images/p2pappok_en.png differ diff --git a/doc/images/prototype.png b/doc/images/prototype.png index 6243829..a2cbf91 100644 Binary files a/doc/images/prototype.png and b/doc/images/prototype.png differ diff --git a/doc/images/register_en.png b/doc/images/register_en.png new file mode 100644 index 0000000..de5516e Binary files /dev/null and b/doc/images/register_en.png differ diff --git a/doc/images/stillrun_en.png b/doc/images/stillrun_en.png new file mode 100644 index 0000000..f2e138e Binary files /dev/null and b/doc/images/stillrun_en.png differ diff --git a/doc/images/win10warn_en.png b/doc/images/win10warn_en.png new file mode 100644 index 0000000..c5b1408 Binary files /dev/null and b/doc/images/win10warn_en.png differ diff --git a/errorcode.go b/errorcode.go index f588882..f97db46 100644 --- a/errorcode.go +++ b/errorcode.go @@ -8,6 +8,9 @@ import ( var ( // ErrorS2S string = "s2s is not supported" // ErrorHandshake string = "handshake error" - ErrorS2S = errors.New("s2s is not supported") - ErrorHandshake = errors.New("handshake error") + ErrorS2S = errors.New("s2s is not supported") + ErrorHandshake = errors.New("handshake error") + ErrorNewUser = errors.New("new user") + ErrorLogin = errors.New("user or password not correct") + ErrNodeTooShort = errors.New("node name too short, it must >=8 charaters") ) diff --git a/p2pnetwork.go b/p2pnetwork.go index 23d519c..236ef4f 100644 --- a/p2pnetwork.go +++ b/p2pnetwork.go @@ -10,7 +10,6 @@ import ( "math/rand" "net" "net/url" - "os" "strings" "sync" "time" @@ -361,11 +360,6 @@ func (pn *P2PNetwork) init() error { gLog.Println(LevelINFO, "init start") var err error for { - pn.config.hostName, err = os.Hostname() - if err != nil { - break - } - // detect nat type pn.config.publicIP, pn.config.natType, err = getNATType(pn.config.ServerHost, pn.config.UDPPort1, pn.config.UDPPort2) // TODO rm test s2s diff --git a/protocol.go b/protocol.go index b9531fa..ddf2d5e 100644 --- a/protocol.go +++ b/protocol.go @@ -10,7 +10,7 @@ import ( "time" ) -const OpenP2PVersion = "1.0.0" +const OpenP2PVersion = "1.1.0" const ProducnName string = "openp2p" type openP2PHeader struct {