Skip to content

Commit

Permalink
feat(route): support x grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Jul 12, 2024
1 parent 03021e5 commit af3aa02
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 24 deletions.
47 changes: 24 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">
<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>
<h1>WireGold</h1>
Wire Golang Guard = WireGold<br><br>
Expand Down Expand Up @@ -39,30 +39,31 @@ SubNet: 192.168.233.0/24
PrivateKey: 暲菉斂狧污爉窫擸紈卆帞蔩慈睠庮扝憚瞼縀
EndPoint: 0.0.0.0:56789
MTU: 1504
SpeedLoop: 4096
Mask: 0x1234567890abcdef
Peers:
-
IP: "192.168.233.2"
SubNet: 192.168.233.0/24
PublicKey: 徯萃嵾爻燸攗窍褃冔蒔犡緇袿屿組待族砇嘀
PresharedKey: 瀸敀爅崾嘊嵜紼樴稍毯攣矐訷蟷扛嬋庩崛昀
EndPoint: 1.2.3.4:56789
AllowedIPs: ["192.168.233.2/32"]
KeepAliveSeconds: 0
QueryList: ["192.168.233.3"]
MTU: 1400
MTURandomRange: 128
UseZstd: true
QuerySeconds: 10
AllowTrans: false
IP: "192.168.233.2"
SubNet: 192.168.233.0/24
PublicKey: 徯萃嵾爻燸攗窍褃冔蒔犡緇袿屿組待族砇嘀
PresharedKey: 瀸敀爅崾嘊嵜紼樴稍毯攣矐訷蟷扛嬋庩崛昀
EndPoint: 1.2.3.4:56789
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
QueryList: ["192.168.233.3"]
MTU: 1400
MTURandomRange: 128
UseZstd: true
QuerySeconds: 10
AllowTrans: true
-
IP: "192.168.233.3"
SubNet: 192.168.233.0/24
PublicKey: 牢喨粷詸衭譛浾蘹櫠砙杹蟫瑳叩刋橋経挵蘀
PresharedKey: 竅琚喫従痸告烈兇厕趭萨假蔛瀇譄施烸蝫瘀
EndPoint: ""
AllowedIPs: ["192.168.233.3/32"]
MTU: 752
KeepAliveSeconds: 0
AllowTrans: false
IP: "192.168.233.3"
SubNet: 192.168.233.0/24
PublicKey: 牢喨粷詸衭譛浾蘹櫠砙杹蟫瑳叩刋橋経挵蘀
PresharedKey: 竅琚喫従痸告烈兇厕趭萨假蔛瀇譄施烸蝫瘀
EndPoint: ""
AllowedIPs: ["192.168.233.3/32"]
MTU: 752
KeepAliveSeconds: 0
AllowTrans: false
```
10 changes: 10 additions & 0 deletions gold/link/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ func (m *Me) AddPeer(cfg *PeerConfig) (l *Link) {
if cfg.AllowedIPs != nil {
l.allowedips = make([]*net.IPNet, 0, len(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)
if err == nil {
l.allowedips = append(l.allowedips, cidr)
Expand Down
2 changes: 1 addition & 1 deletion gold/link/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (r *Router) SetItem(ip *net.IPNet, l *Link) {
if r.list[i].Contains(ip.IP) {
// 是同一个网络
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
break
}
Expand Down

0 comments on commit af3aa02

Please sign in to comment.