mirror of
https://github.com/fumiama/WireGold.git
synced 2026-06-12 12:50:28 +08:00
feat(route): support x grammar
This commit is contained in:
47
README.md
47
README.md
@@ -1,6 +1,6 @@
|
|||||||
<div align="center">
|
<div align="center">
|
||||||
<a href="https://crypko.ai/crypko/G39ZPfer7g6rz/">
|
<a href="https://crypko.ai/crypko/G39ZPfer7g6rz/">
|
||||||
<img src=".github/Maria.png" width = "400" alt="WireGold-Maria">
|
<img src=".github/Maria.png" width = "400" alt="WireGold-Maria">
|
||||||
</a><br>
|
</a><br>
|
||||||
<h1>WireGold</h1>
|
<h1>WireGold</h1>
|
||||||
Wire Golang Guard = WireGold<br><br>
|
Wire Golang Guard = WireGold<br><br>
|
||||||
@@ -39,30 +39,31 @@ SubNet: 192.168.233.0/24
|
|||||||
PrivateKey: 暲菉斂狧污爉窫擸紈卆帞蔩慈睠庮扝憚瞼縀
|
PrivateKey: 暲菉斂狧污爉窫擸紈卆帞蔩慈睠庮扝憚瞼縀
|
||||||
EndPoint: 0.0.0.0:56789
|
EndPoint: 0.0.0.0:56789
|
||||||
MTU: 1504
|
MTU: 1504
|
||||||
|
SpeedLoop: 4096
|
||||||
Mask: 0x1234567890abcdef
|
Mask: 0x1234567890abcdef
|
||||||
Peers:
|
Peers:
|
||||||
-
|
-
|
||||||
IP: "192.168.233.2"
|
IP: "192.168.233.2"
|
||||||
SubNet: 192.168.233.0/24
|
SubNet: 192.168.233.0/24
|
||||||
PublicKey: 徯萃嵾爻燸攗窍褃冔蒔犡緇袿屿組待族砇嘀
|
PublicKey: 徯萃嵾爻燸攗窍褃冔蒔犡緇袿屿組待族砇嘀
|
||||||
PresharedKey: 瀸敀爅崾嘊嵜紼樴稍毯攣矐訷蟷扛嬋庩崛昀
|
PresharedKey: 瀸敀爅崾嘊嵜紼樴稍毯攣矐訷蟷扛嬋庩崛昀
|
||||||
EndPoint: 1.2.3.4:56789
|
EndPoint: 1.2.3.4:56789
|
||||||
AllowedIPs: ["192.168.233.2/32"]
|
AllowedIPs: ["192.168.233.2/32", "x192.168.233.3/32"] # allow trans to 192.168.233.3, but don not create route
|
||||||
KeepAliveSeconds: 0
|
KeepAliveSeconds: 0
|
||||||
QueryList: ["192.168.233.3"]
|
QueryList: ["192.168.233.3"]
|
||||||
MTU: 1400
|
MTU: 1400
|
||||||
MTURandomRange: 128
|
MTURandomRange: 128
|
||||||
UseZstd: true
|
UseZstd: true
|
||||||
QuerySeconds: 10
|
QuerySeconds: 10
|
||||||
AllowTrans: false
|
AllowTrans: true
|
||||||
-
|
-
|
||||||
IP: "192.168.233.3"
|
IP: "192.168.233.3"
|
||||||
SubNet: 192.168.233.0/24
|
SubNet: 192.168.233.0/24
|
||||||
PublicKey: 牢喨粷詸衭譛浾蘹櫠砙杹蟫瑳叩刋橋経挵蘀
|
PublicKey: 牢喨粷詸衭譛浾蘹櫠砙杹蟫瑳叩刋橋経挵蘀
|
||||||
PresharedKey: 竅琚喫従痸告烈兇厕趭萨假蔛瀇譄施烸蝫瘀
|
PresharedKey: 竅琚喫従痸告烈兇厕趭萨假蔛瀇譄施烸蝫瘀
|
||||||
EndPoint: ""
|
EndPoint: ""
|
||||||
AllowedIPs: ["192.168.233.3/32"]
|
AllowedIPs: ["192.168.233.3/32"]
|
||||||
MTU: 752
|
MTU: 752
|
||||||
KeepAliveSeconds: 0
|
KeepAliveSeconds: 0
|
||||||
AllowTrans: false
|
AllowTrans: false
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -81,6 +81,16 @@ func (m *Me) AddPeer(cfg *PeerConfig) (l *Link) {
|
|||||||
if cfg.AllowedIPs != nil {
|
if cfg.AllowedIPs != nil {
|
||||||
l.allowedips = make([]*net.IPNet, 0, len(cfg.AllowedIPs))
|
l.allowedips = make([]*net.IPNet, 0, len(cfg.AllowedIPs))
|
||||||
for _, ipnet := range cfg.AllowedIPs {
|
for _, ipnet := range cfg.AllowedIPs {
|
||||||
|
if len(ipnet) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
noroute := ipnet[0] == 'x'
|
||||||
|
if noroute {
|
||||||
|
ipnet = ipnet[1:]
|
||||||
|
if len(ipnet) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
_, cidr, err := net.ParseCIDR(ipnet)
|
_, cidr, err := net.ParseCIDR(ipnet)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
l.allowedips = append(l.allowedips, cidr)
|
l.allowedips = append(l.allowedips, cidr)
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ func (r *Router) SetItem(ip *net.IPNet, l *Link) {
|
|||||||
if r.list[i].Contains(ip.IP) {
|
if r.list[i].Contains(ip.IP) {
|
||||||
// 是同一个网络
|
// 是同一个网络
|
||||||
if ip.Mask.String() == r.list[i].Mask.String() {
|
if ip.Mask.String() == r.list[i].Mask.String() {
|
||||||
logrus.Infoln("[router] change link of item", r.list[i], "from", r.table[r.list[i].String()], "to", l)
|
logrus.Warnln("[router] change link of item", r.list[i], "from", r.table[r.list[i].String()], "to", l)
|
||||||
r.table[r.list[i].String()] = l
|
r.table[r.list[i].String()] = l
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user