This commit is contained in:
TenderIronh
2022-02-10 23:20:16 +08:00
parent 133fe046f8
commit b54fa2c6be
18 changed files with 32 additions and 22 deletions
+10 -10
View File
@@ -36,35 +36,35 @@ Here's an example of remote work: connecting to an office Windows computer at ho
### 1.Register ### 1.Register
Go to <https://console.openp2p.cn> register a new user Go to <https://console.openp2p.cn> register a new user
![image](/doc/images/register.png) ![image](/doc/images/register_en.png)
### 2.Install ### 2.Install
Download on local and remote computers and double-click to run, one-click installation 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". 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 ### 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 ### 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. 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` 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 ## Usage
+10
View File
@@ -7,8 +7,10 @@ import (
"crypto/tls" "crypto/tls"
"encoding/json" "encoding/json"
"fmt" "fmt"
"math/rand"
"net" "net"
"net/http" "net/http"
"os"
"os/exec" "os/exec"
"time" "time"
) )
@@ -148,3 +150,11 @@ func execOutput(name string, args ...string) string {
cmdGetOsName.Run() cmdGetOsName.Run()
return cmdOut.String() return cmdOut.String()
} }
func defaultNodeName() string {
name, _ := os.Hostname()
for len(name) < 8 {
name = fmt.Sprintf("%s%d", name, rand.Int()%10)
}
return name
}
+4 -1
View File
@@ -119,7 +119,6 @@ type NetworkConfig struct {
User string User string
localIP string localIP string
ipv6 string ipv6 string
hostName string
mac string mac string
os string os string
publicIP string publicIP string
@@ -184,6 +183,10 @@ func parseParams() {
gConf.Network.ServerHost = *serverHost gConf.Network.ServerHost = *serverHost
} }
if gConf.Network.Node == "" { if gConf.Network.Node == "" {
if *node == "" { // config and param's node both empty
hostname := defaultNodeName()
node = &hostname
}
gConf.Network.Node = *node gConf.Network.Node = *node
} }
if *token != 0 { if *token != 0 {
+2 -2
View File
@@ -132,11 +132,11 @@ func install() {
logLevel := installFlag.Int("loglevel", 1, "0:debug 1:info 2:warn 3:error") logLevel := installFlag.Int("loglevel", 1, "0:debug 1:info 2:warn 3:error")
installFlag.Parse(os.Args[2:]) installFlag.Parse(os.Args[2:])
if *node != "" && len(*node) < 8 { if *node != "" && len(*node) < 8 {
gLog.Println(LevelERROR, "node name too short, it must >=8 charaters") gLog.Println(LevelERROR, ErrNodeTooShort)
os.Exit(9) os.Exit(9)
} }
if *node == "" { // if node name not set. use os.Hostname if *node == "" { // if node name not set. use os.Hostname
hostname, _ := os.Hostname() hostname := defaultNodeName()
node = &hostname node = &hostname
} }
gConf.load() // load old config. otherwise will clear all apps gConf.load() // load old config. otherwise will clear all apps
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

+5 -2
View File
@@ -8,6 +8,9 @@ import (
var ( var (
// ErrorS2S string = "s2s is not supported" // ErrorS2S string = "s2s is not supported"
// ErrorHandshake string = "handshake error" // ErrorHandshake string = "handshake error"
ErrorS2S = errors.New("s2s is not supported") ErrorS2S = errors.New("s2s is not supported")
ErrorHandshake = errors.New("handshake error") 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")
) )
-6
View File
@@ -10,7 +10,6 @@ import (
"math/rand" "math/rand"
"net" "net"
"net/url" "net/url"
"os"
"strings" "strings"
"sync" "sync"
"time" "time"
@@ -361,11 +360,6 @@ func (pn *P2PNetwork) init() error {
gLog.Println(LevelINFO, "init start") gLog.Println(LevelINFO, "init start")
var err error var err error
for { for {
pn.config.hostName, err = os.Hostname()
if err != nil {
break
}
// detect nat type // detect nat type
pn.config.publicIP, pn.config.natType, err = getNATType(pn.config.ServerHost, pn.config.UDPPort1, pn.config.UDPPort2) pn.config.publicIP, pn.config.natType, err = getNATType(pn.config.ServerHost, pn.config.UDPPort1, pn.config.UDPPort2)
// TODO rm test s2s // TODO rm test s2s
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"time" "time"
) )
const OpenP2PVersion = "1.0.0" const OpenP2PVersion = "1.1.0"
const ProducnName string = "openp2p" const ProducnName string = "openp2p"
type openP2PHeader struct { type openP2PHeader struct {