forked from extern/smegmesh
Fixed routing issue
This commit is contained in:
parent
73db65660b
commit
4030d17b41
@ -29,7 +29,7 @@ func (d *DNSHandler) queryMesh(meshId, alias string) net.IP {
|
|||||||
|
|
||||||
err := d.client.Call("IpcHandler.Query", &ipc.QueryMesh{
|
err := d.client.Call("IpcHandler.Query", &ipc.QueryMesh{
|
||||||
MeshId: meshId,
|
MeshId: meshId,
|
||||||
Query: "[?alias == 'tim'] | [0]",
|
Query: fmt.Sprintf("[?alias == '%s'] | [0]", alias),
|
||||||
}, &reply)
|
}, &reply)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -61,7 +61,7 @@ func (c *MeshDOTConverter) graphNode(g *graph.Graph, node MeshNode, meshId strin
|
|||||||
|
|
||||||
self, _ := c.manager.GetSelf(meshId)
|
self, _ := c.manager.GetSelf(meshId)
|
||||||
|
|
||||||
if node.GetHostEndpoint() == self.GetHostEndpoint() {
|
if NodeEquals(self, node) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,20 +266,16 @@ func (s *MeshManagerImpl) AddSelf(params *AddSelfParams) error {
|
|||||||
params.WgPort = device.ListenPort
|
params.WgPort = device.ListenPort
|
||||||
}
|
}
|
||||||
|
|
||||||
pubKey, err := s.GetPublicKey(params.MeshId)
|
pubKey := s.HostParameters.PrivateKey.PublicKey()
|
||||||
|
|
||||||
if err != nil {
|
nodeIP, err := s.ipAllocator.GetIP(pubKey, params.MeshId)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
nodeIP, err := s.ipAllocator.GetIP(*pubKey, params.MeshId)
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
node := s.nodeFactory.Build(&MeshNodeFactoryParams{
|
node := s.nodeFactory.Build(&MeshNodeFactoryParams{
|
||||||
PublicKey: pubKey,
|
PublicKey: &pubKey,
|
||||||
NodeIP: nodeIP,
|
NodeIP: nodeIP,
|
||||||
WgPort: params.WgPort,
|
WgPort: params.WgPort,
|
||||||
Endpoint: params.Endpoint,
|
Endpoint: params.Endpoint,
|
||||||
|
@ -45,7 +45,7 @@ func (r *RouteManagerImpl) UpdateRoutes() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = mesh1.AddRoutes(self.GetHostEndpoint(), ipNet.String())
|
err = mesh1.AddRoutes(NodeID(self), ipNet.String())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -74,7 +74,7 @@ func (r *RouteManagerImpl) RemoveRoutes(meshId string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh1.RemoveRoutes(self.GetHostEndpoint(), ipNet.String())
|
mesh1.RemoveRoutes(NodeID(self), ipNet.String())
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ func (m *RouteManagerImpl) installRoutes(meshProvider MeshProvider) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, node := range mesh.GetNodes() {
|
for _, node := range mesh.GetNodes() {
|
||||||
if self.GetHostEndpoint() == node.GetHostEndpoint() {
|
if NodeEquals(self, node) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ type MeshNodeStub struct {
|
|||||||
|
|
||||||
// GetType implements MeshNode.
|
// GetType implements MeshNode.
|
||||||
func (*MeshNodeStub) GetType() conf.NodeType {
|
func (*MeshNodeStub) GetType() conf.NodeType {
|
||||||
return PEER
|
return conf.PEER_ROLE
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetServices implements MeshNode.
|
// GetServices implements MeshNode.
|
||||||
|
@ -10,13 +10,6 @@ import (
|
|||||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
// Data Exchanged Between Peers
|
|
||||||
PEER conf.NodeType = "peer"
|
|
||||||
// Data Exchanged Between Clients
|
|
||||||
CLIENT conf.NodeType = "client"
|
|
||||||
)
|
|
||||||
|
|
||||||
// MeshNode represents an implementation of a node in a mesh
|
// MeshNode represents an implementation of a node in a mesh
|
||||||
type MeshNode interface {
|
type MeshNode interface {
|
||||||
// GetHostEndpoint: gets the gRPC endpoint of the node
|
// GetHostEndpoint: gets the gRPC endpoint of the node
|
||||||
@ -45,7 +38,15 @@ type MeshNode interface {
|
|||||||
|
|
||||||
// NodeEquals: determines if two mesh nodes are equivalent to one another
|
// NodeEquals: determines if two mesh nodes are equivalent to one another
|
||||||
func NodeEquals(node1, node2 MeshNode) bool {
|
func NodeEquals(node1, node2 MeshNode) bool {
|
||||||
return node1.GetHostEndpoint() == node2.GetHostEndpoint()
|
key1, _ := node1.GetPublicKey()
|
||||||
|
key2, _ := node2.GetPublicKey()
|
||||||
|
|
||||||
|
return key1.String() == key2.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NodeID(node MeshNode) string {
|
||||||
|
key, _ := node.GetPublicKey()
|
||||||
|
return key.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
type MeshSnapshot interface {
|
type MeshSnapshot interface {
|
||||||
|
Loading…
Reference in New Issue
Block a user