|
7 | 7 | "fmt"
|
8 | 8 | "net"
|
9 | 9 | "net/http"
|
| 10 | +"net/netip" |
10 | 11 | "strings"
|
11 | 12 | "sync"
|
12 | 13 | "time"
|
@@ -143,10 +144,27 @@ func NewPGCoord(ctx context.Context, logger slog.Logger, ps pubsub.Pubsub, store
|
143 | 144 | returnc,nil
|
144 | 145 | }
|
145 | 146 |
|
| 147 | +// This is copied from codersdk because importing it here would cause an import |
| 148 | +// cycle. This is just temporary until wsconncache is phased out. |
| 149 | +varlegacyAgentIP=netip.MustParseAddr("fd7a:115c:a1e0:49d6:b259:b7ac:b1b2:48f4") |
| 150 | + |
146 | 151 | func (c*pgCoord)ServeMultiAgent(id uuid.UUID) agpl.MultiAgentConn {
|
147 | 152 | ma:= (&agpl.MultiAgent{
|
148 |
| -ID:id, |
149 |
| -AgentIsLegacyFunc:func(agentID uuid.UUID)bool {returntrue }, |
| 153 | +ID:id, |
| 154 | +AgentIsLegacyFunc:func(agentID uuid.UUID)bool { |
| 155 | +ifn:=c.Node(agentID);n==nil { |
| 156 | +// If we don't have the node at all assume it's legacy for |
| 157 | +// safety. |
| 158 | +returntrue |
| 159 | +}elseiflen(n.Addresses)>0&&n.Addresses[0].Addr()==legacyAgentIP { |
| 160 | +// An agent is determined to be "legacy" if it's first IP is the |
| 161 | +// legacy IP. Agents with only the legacy IP aren't compatible |
| 162 | +// with single_tailnet and must be routed through wsconncache. |
| 163 | +returntrue |
| 164 | +}else { |
| 165 | +returnfalse |
| 166 | +} |
| 167 | +}, |
150 | 168 | OnSubscribe:func(enq agpl.Queue,agent uuid.UUID) (*agpl.Node,error) {
|
151 | 169 | err:=c.addSubscription(enq,agent)
|
152 | 170 | returnc.Node(agent),err
|
|