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

|

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

|

|
||||||
|
|
||||||
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".
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
### 3.New P2PApp
|
### 3.New P2PApp
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### 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.
|
||||||
|
|
||||||

|

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

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
|
After Width: | Height: | Size: 5.6 MiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 98 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 14 KiB |
@@ -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")
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||