| 88 | } |
| 89 | |
| 90 | func newConfigMaps( |
| 91 | logger slog.Logger, engine engineConfigurable, |
| 92 | nodeID tailcfg.NodeID, nodeKey key.NodePrivate, discoKey key.DiscoPublic, |
| 93 | matchDomain dnsname.FQDN, |
| 94 | ) *configMaps { |
| 95 | pubKey := nodeKey.Public() |
| 96 | c := &configMaps{ |
| 97 | phased: phased{Cond: *(sync.NewCond(&sync.Mutex{}))}, |
| 98 | logger: logger, |
| 99 | engine: engine, |
| 100 | hosts: make(map[dnsname.FQDN][]netip.Addr), |
| 101 | static: netmap.NetworkMap{ |
| 102 | SelfNode: &tailcfg.Node{ |
| 103 | ID: nodeID, |
| 104 | Key: pubKey, |
| 105 | DiscoKey: discoKey, |
| 106 | }, |
| 107 | NodeKey: pubKey, |
| 108 | PrivateKey: nodeKey, |
| 109 | PacketFilter: []filter.Match{{ |
| 110 | // Allow any protocol! |
| 111 | IPProto: []ipproto.Proto{ipproto.TCP, ipproto.UDP, ipproto.ICMPv4, ipproto.ICMPv6, ipproto.SCTP}, |
| 112 | // Allow traffic sourced from anywhere. |
| 113 | Srcs: []netip.Prefix{ |
| 114 | netip.PrefixFrom(netip.AddrFrom4([4]byte{}), 0), |
| 115 | netip.PrefixFrom(netip.AddrFrom16([16]byte{}), 0), |
| 116 | }, |
| 117 | // Allow traffic to route anywhere. |
| 118 | Dsts: []filter.NetPortRange{ |
| 119 | { |
| 120 | Net: netip.PrefixFrom(netip.AddrFrom4([4]byte{}), 0), |
| 121 | Ports: filter.PortRange{ |
| 122 | First: 0, |
| 123 | Last: 65535, |
| 124 | }, |
| 125 | }, |
| 126 | { |
| 127 | Net: netip.PrefixFrom(netip.AddrFrom16([16]byte{}), 0), |
| 128 | Ports: filter.PortRange{ |
| 129 | First: 0, |
| 130 | Last: 65535, |
| 131 | }, |
| 132 | }, |
| 133 | }, |
| 134 | Caps: []filter.CapMatch{}, |
| 135 | }}, |
| 136 | }, |
| 137 | peers: make(map[uuid.UUID]*peerLifecycle), |
| 138 | matchDomain: matchDomain, |
| 139 | clock: quartz.NewReal(), |
| 140 | } |
| 141 | go c.configLoop() |
| 142 | return c |
| 143 | } |
| 144 | |
| 145 | // configLoop waits for the config to be dirty, then reconfigures the engine. |
| 146 | // It is internal to configMaps |