Skip to content

Commit

Permalink
feat(config): add inner routing mark y
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Aug 17, 2024
1 parent 9871bde commit 1ba17fc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Peers:
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
AllowedIPs: ["192.168.233.2/32", "x192.168.233.3/32"] # accept packets from 192.168.233.3, but don not create route
KeepAliveSeconds: 0
QueryList: ["192.168.233.3"]
MTU: 1400
Expand All @@ -60,8 +60,9 @@ Peers:
PublicKey: 牢喨粷詸衭譛浾蘹櫠砙杹蟫瑳叩刋橋経挵蘀
PresharedKey: 竅琚喫従痸告烈兇厕趭萨假蔛瀇譄施烸蝫瘀
EndPoint: ""
AllowedIPs: ["192.168.233.3/32"]
AllowedIPs: ["192.168.233.3/32", "y192.168.66.1/32"] # add route to 192.168.66.1 into inner route table but do not add it to system one
MTU: 752
DoublePacket: true
KeepAliveSeconds: 0
AllowTrans: false
```
3 changes: 2 additions & 1 deletion gold/link/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ func (m *Me) AddPeer(cfg *PeerConfig) (l *Link) {
continue
}
noroute := ipnet[0] == 'x'
if noroute {
innerroute := ipnet[0] == 'y'
if noroute || innerroute {
ipnet = ipnet[1:]
if len(ipnet) == 0 {
continue
Expand Down
2 changes: 1 addition & 1 deletion upper/services/wg/wg.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (wg *WG) init(srcport, dstport uint16) {
}
for _, p := range wg.c.Peers {
for _, ip := range p.AllowedIPs {
if len(ip) == 0 || ip[0] == 'x' {
if len(ip) == 0 || ip[0] == 'x' || ip[0] == 'y' {
continue
}
ipnet, _, err := net.ParseCIDR(ip)
Expand Down

0 comments on commit 1ba17fc

Please sign in to comment.