mirror of
https://github.com/sigcn/pg.git
synced 2025-10-05 15:26:52 +08:00
transfer project to SIGCN organization
This commit is contained in:
@@ -1,14 +1,14 @@
|
|||||||
# PeerGuard
|
# PeerGuard
|
||||||
|
|
||||||
Another p2p network library in Go. Committed to direct communication between devices.
|
Another p2p network library in Go. Committed to direct communication between devices.
|
||||||
[[简体中文]](https://github.com/rkonfj/peerguard/blob/main/README_zh_CN.md)
|
[[简体中文]](https://github.com/sigcn/pg/blob/main/README_zh_CN.md)
|
||||||
## Features
|
## Features
|
||||||
- Elegantly simple architecture (pgcli & pgmap & OpenID Connect)
|
- Elegantly simple architecture (pgcli & pgmap & OpenID Connect)
|
||||||
- NAT traversal with high success rate (STUN & UPnP & PortScan & BirthdayParadox)
|
- NAT traversal with high success rate (STUN & UPnP & PortScan & BirthdayParadox)
|
||||||
- Full support for IPv4/IPv6 dual stack
|
- Full support for IPv4/IPv6 dual stack
|
||||||
- Easy-to-use library (net.PacketConn)
|
- Easy-to-use library (net.PacketConn)
|
||||||
- **Transport layer security (curve25519 & chacha20poly1305 for end-to-end encryption)**
|
- **Transport layer security (curve25519 & chacha20poly1305 for end-to-end encryption)**
|
||||||
- [RDT](https://github.com/rkonfj/peerguard/tree/main/rdt) protocol for reliable data transfer
|
- [RDT](https://github.com/sigcn/pg/tree/main/rdt) protocol for reliable data transfer
|
||||||
- Cross-platform compatibility (linux/windows/macOS/iOS/android)
|
- Cross-platform compatibility (linux/windows/macOS/iOS/android)
|
||||||
|
|
||||||
## Get Started
|
## Get Started
|
||||||
@@ -58,7 +58,7 @@ $ pgcli admin secret --network "<email>" --duration 24h > psns.json
|
|||||||
sudo pgcli vpn -s wss://synf.in/pg -4 100.64.0.1/24 -f psns.json
|
sudo pgcli vpn -s wss://synf.in/pg -4 100.64.0.1/24 -f psns.json
|
||||||
```
|
```
|
||||||
## License
|
## License
|
||||||
[GNU General Public License v3.0](https://github.com/rkonfj/peerguard/blob/main/LICENSE)
|
[GNU General Public License v3.0](https://github.com/sigcn/pg/blob/main/LICENSE)
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
Contributions welcome! Have an improvement? Submit a pull request.
|
Contributions welcome! Have an improvement? Submit a pull request.
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
- 完全的 ipv4/ipv6 双栈支持
|
- 完全的 ipv4/ipv6 双栈支持
|
||||||
- 很容易入手的 API (针对开发者)
|
- 很容易入手的 API (针对开发者)
|
||||||
- 端到端加密
|
- 端到端加密
|
||||||
- 用于可靠数据传输的 [RDT](https://github.com/rkonfj/peerguard/tree/main/rdt) 协议
|
- 用于可靠数据传输的 [RDT](https://github.com/sigcn/pg/tree/main/rdt) 协议
|
||||||
- 跨平台
|
- 跨平台
|
||||||
|
|
||||||
## 快速开始
|
## 快速开始
|
||||||
@@ -44,7 +44,7 @@ $ pgmap -l 127.0.0.1:9987 --secret-key 5172554832d76672d1959a5ac63c5ab9 \
|
|||||||
--stun stun.miwifi.com:3478 --stun stunserver.stunprotocol.org:3478
|
--stun stun.miwifi.com:3478 --stun stunserver.stunprotocol.org:3478
|
||||||
```
|
```
|
||||||
>[!NOTE]
|
>[!NOTE]
|
||||||
>`pgmap`支持配置文件([查看所有配置项](https://github.com/rkonfj/peerguard/blob/main/peermap/config.go#L20))。另外,命令行参数会覆盖配置文件参数
|
>`pgmap`支持配置文件([查看所有配置项](https://github.com/sigcn/pg/blob/main/peermap/config.go#L20))。另外,命令行参数会覆盖配置文件参数
|
||||||
|
|
||||||
#### 2. 上 https 更安全
|
#### 2. 上 https 更安全
|
||||||
```sh
|
```sh
|
||||||
@@ -62,7 +62,7 @@ $ pgcli admin secret --network "<email>" --duration 24h > psns.json
|
|||||||
sudo pgcli vpn -s wss://synf.in/pg -4 100.64.0.1/24 -f psns.json
|
sudo pgcli vpn -s wss://synf.in/pg -4 100.64.0.1/24 -f psns.json
|
||||||
```
|
```
|
||||||
## 许可证
|
## 许可证
|
||||||
[GNU General Public License v3.0](https://github.com/rkonfj/peerguard/blob/main/LICENSE)
|
[GNU General Public License v3.0](https://github.com/sigcn/pg/blob/main/LICENSE)
|
||||||
|
|
||||||
## 参与贡献
|
## 参与贡献
|
||||||
非常欢迎参与项目的开发,如果有任何改善本项目的意图,请立即提交 PR
|
非常欢迎参与项目的开发,如果有任何改善本项目的意图,请立即提交 PR
|
||||||
|
@@ -6,7 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/peermap/exporter"
|
"github.com/sigcn/pg/peermap/exporter"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/peermap/exporter"
|
"github.com/sigcn/pg/peermap/exporter"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/peermap/exporter"
|
"github.com/sigcn/pg/peermap/exporter"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -5,8 +5,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/disco"
|
"github.com/sigcn/pg/disco"
|
||||||
"github.com/rkonfj/peerguard/peermap/auth"
|
"github.com/sigcn/pg/peermap/auth"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@ package curve25519
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/secure"
|
"github.com/sigcn/pg/secure"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -13,8 +13,8 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/fileshare"
|
|
||||||
"github.com/schollz/progressbar/v3"
|
"github.com/schollz/progressbar/v3"
|
||||||
|
"github.com/sigcn/pg/fileshare"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -4,11 +4,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/cmd/pgcli/admin"
|
"github.com/sigcn/pg/cmd/pgcli/admin"
|
||||||
"github.com/rkonfj/peerguard/cmd/pgcli/curve25519"
|
"github.com/sigcn/pg/cmd/pgcli/curve25519"
|
||||||
"github.com/rkonfj/peerguard/cmd/pgcli/download"
|
"github.com/sigcn/pg/cmd/pgcli/download"
|
||||||
"github.com/rkonfj/peerguard/cmd/pgcli/share"
|
"github.com/sigcn/pg/cmd/pgcli/share"
|
||||||
"github.com/rkonfj/peerguard/cmd/pgcli/vpn"
|
"github.com/sigcn/pg/cmd/pgcli/vpn"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -10,8 +10,8 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/fileshare"
|
|
||||||
"github.com/schollz/progressbar/v3"
|
"github.com/schollz/progressbar/v3"
|
||||||
|
"github.com/sigcn/pg/fileshare"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -18,12 +18,12 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/mdp/qrterminal/v3"
|
"github.com/mdp/qrterminal/v3"
|
||||||
"github.com/rkonfj/peerguard/disco"
|
"github.com/sigcn/pg/disco"
|
||||||
"github.com/rkonfj/peerguard/disco/tp"
|
"github.com/sigcn/pg/disco/tp"
|
||||||
"github.com/rkonfj/peerguard/p2p"
|
"github.com/sigcn/pg/p2p"
|
||||||
"github.com/rkonfj/peerguard/peermap/network"
|
"github.com/sigcn/pg/peermap/network"
|
||||||
"github.com/rkonfj/peerguard/vpn"
|
"github.com/sigcn/pg/vpn"
|
||||||
"github.com/rkonfj/peerguard/vpn/iface"
|
"github.com/sigcn/pg/vpn/iface"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@ import (
|
|||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/peermap"
|
"github.com/sigcn/pg/peermap"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
N "github.com/rkonfj/peerguard/net"
|
N "github.com/sigcn/pg/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@@ -11,7 +11,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/connmux"
|
"github.com/sigcn/pg/connmux"
|
||||||
)
|
)
|
||||||
|
|
||||||
type rwc struct {
|
type rwc struct {
|
||||||
|
@@ -9,7 +9,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/secure"
|
"github.com/sigcn/pg/secure"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ControlCode uint8
|
type ControlCode uint8
|
||||||
|
@@ -15,8 +15,8 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/disco"
|
"github.com/sigcn/pg/disco"
|
||||||
"github.com/rkonfj/peerguard/upnp"
|
"github.com/sigcn/pg/upnp"
|
||||||
"golang.org/x/time/rate"
|
"golang.org/x/time/rate"
|
||||||
"tailscale.com/net/stun"
|
"tailscale.com/net/stun"
|
||||||
)
|
)
|
||||||
|
@@ -17,7 +17,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/rkonfj/peerguard/disco"
|
"github.com/sigcn/pg/disco"
|
||||||
"golang.org/x/time/rate"
|
"golang.org/x/time/rate"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -7,8 +7,8 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/disco"
|
"github.com/sigcn/pg/disco"
|
||||||
"github.com/rkonfj/peerguard/p2p"
|
"github.com/sigcn/pg/p2p"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PublicNetwork struct {
|
type PublicNetwork struct {
|
||||||
|
@@ -13,8 +13,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/disco"
|
"github.com/sigcn/pg/disco"
|
||||||
"github.com/rkonfj/peerguard/rdt"
|
"github.com/sigcn/pg/rdt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FileHandle struct {
|
type FileHandle struct {
|
||||||
|
@@ -17,8 +17,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/disco"
|
"github.com/sigcn/pg/disco"
|
||||||
"github.com/rkonfj/peerguard/rdt"
|
"github.com/sigcn/pg/rdt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FileManager struct {
|
type FileManager struct {
|
||||||
|
2
go.mod
2
go.mod
@@ -1,4 +1,4 @@
|
|||||||
module github.com/rkonfj/peerguard
|
module github.com/sigcn/pg
|
||||||
|
|
||||||
go 1.22
|
go 1.22
|
||||||
|
|
||||||
|
@@ -5,9 +5,9 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/disco"
|
"github.com/sigcn/pg/disco"
|
||||||
"github.com/rkonfj/peerguard/secure"
|
"github.com/sigcn/pg/secure"
|
||||||
"github.com/rkonfj/peerguard/secure/chacha20poly1305"
|
"github.com/sigcn/pg/secure/chacha20poly1305"
|
||||||
)
|
)
|
||||||
|
|
||||||
var defaultSymmAlgo func(secure.ProvideSecretKey) secure.SymmAlgo = chacha20poly1305.New
|
var defaultSymmAlgo func(secure.ProvideSecretKey) secure.SymmAlgo = chacha20poly1305.New
|
||||||
|
10
p2p/conn.go
10
p2p/conn.go
@@ -11,11 +11,11 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/disco"
|
"github.com/sigcn/pg/disco"
|
||||||
"github.com/rkonfj/peerguard/disco/tp"
|
"github.com/sigcn/pg/disco/tp"
|
||||||
"github.com/rkonfj/peerguard/lru"
|
"github.com/sigcn/pg/lru"
|
||||||
N "github.com/rkonfj/peerguard/net"
|
N "github.com/sigcn/pg/net"
|
||||||
"github.com/rkonfj/peerguard/netlink"
|
"github.com/sigcn/pg/netlink"
|
||||||
"storj.io/common/base58"
|
"storj.io/common/base58"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/secure/aescbc"
|
"github.com/sigcn/pg/secure/aescbc"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@@ -9,7 +9,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/peermap/oidc"
|
"github.com/sigcn/pg/peermap/oidc"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -7,8 +7,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/secure"
|
"github.com/sigcn/pg/secure"
|
||||||
"github.com/rkonfj/peerguard/secure/aescbc"
|
"github.com/sigcn/pg/secure/aescbc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Authenticator struct {
|
type Authenticator struct {
|
||||||
|
@@ -10,7 +10,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/peermap/exporter/auth"
|
"github.com/sigcn/pg/peermap/exporter/auth"
|
||||||
)
|
)
|
||||||
|
|
||||||
type peermapTransport struct {
|
type peermapTransport struct {
|
||||||
|
@@ -9,7 +9,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/disco"
|
"github.com/sigcn/pg/disco"
|
||||||
"storj.io/common/base58"
|
"storj.io/common/base58"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/disco"
|
"github.com/sigcn/pg/disco"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@@ -20,11 +20,11 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/rkonfj/peerguard/disco"
|
"github.com/sigcn/pg/disco"
|
||||||
"github.com/rkonfj/peerguard/peermap/auth"
|
"github.com/sigcn/pg/peermap/auth"
|
||||||
"github.com/rkonfj/peerguard/peermap/exporter"
|
"github.com/sigcn/pg/peermap/exporter"
|
||||||
exporterauth "github.com/rkonfj/peerguard/peermap/exporter/auth"
|
exporterauth "github.com/sigcn/pg/peermap/exporter/auth"
|
||||||
"github.com/rkonfj/peerguard/peermap/oidc"
|
"github.com/sigcn/pg/peermap/oidc"
|
||||||
"golang.org/x/time/rate"
|
"golang.org/x/time/rate"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
N "github.com/rkonfj/peerguard/net"
|
N "github.com/sigcn/pg/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@@ -10,8 +10,8 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/lru"
|
"github.com/sigcn/pg/lru"
|
||||||
"github.com/rkonfj/peerguard/secure"
|
"github.com/sigcn/pg/secure"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PKCS7Padding(data []byte, blockSize int) []byte {
|
func PKCS7Padding(data []byte, blockSize int) []byte {
|
||||||
|
@@ -9,8 +9,8 @@ import (
|
|||||||
|
|
||||||
"golang.org/x/crypto/chacha20poly1305"
|
"golang.org/x/crypto/chacha20poly1305"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/lru"
|
"github.com/sigcn/pg/lru"
|
||||||
"github.com/rkonfj/peerguard/secure"
|
"github.com/sigcn/pg/secure"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ secure.SymmAlgo = (*Chacha20Poly1305)(nil)
|
var _ secure.SymmAlgo = (*Chacha20Poly1305)(nil)
|
||||||
|
@@ -7,8 +7,8 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/lru"
|
"github.com/sigcn/pg/lru"
|
||||||
"github.com/rkonfj/peerguard/netlink"
|
"github.com/sigcn/pg/netlink"
|
||||||
"golang.zx2c4.com/wireguard/tun"
|
"golang.zx2c4.com/wireguard/tun"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/lru"
|
"github.com/sigcn/pg/lru"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
"golang.zx2c4.com/wireguard/tun"
|
"golang.zx2c4.com/wireguard/tun"
|
||||||
)
|
)
|
||||||
|
@@ -10,8 +10,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/rkonfj/peerguard/netlink"
|
"github.com/sigcn/pg/netlink"
|
||||||
"github.com/rkonfj/peerguard/vpn/iface"
|
"github.com/sigcn/pg/vpn/iface"
|
||||||
"golang.org/x/net/ipv4"
|
"golang.org/x/net/ipv4"
|
||||||
"golang.org/x/net/ipv6"
|
"golang.org/x/net/ipv6"
|
||||||
"golang.zx2c4.com/wireguard/tun"
|
"golang.zx2c4.com/wireguard/tun"
|
||||||
|
Reference in New Issue
Block a user