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

View File

@@ -36,35 +36,35 @@ Here's an example of remote work: connecting to an office Windows computer at ho
### 1.Register
Go to <https://console.openp2p.cn> 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

View File

@@ -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
}

View File

@@ -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 {

View File

@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 MiB

BIN
doc/images/devices_en.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
doc/images/install_en.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
doc/images/newapp_en.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
doc/images/p2pappok_en.png Normal file

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

BIN
doc/images/register_en.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
doc/images/stillrun_en.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
doc/images/win10warn_en.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -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")
)

View File

@@ -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

View File

@@ -10,7 +10,7 @@ import (
"time"
)
const OpenP2PVersion = "1.0.0"
const OpenP2PVersion = "1.1.0"
const ProducnName string = "openp2p"
type openP2PHeader struct {