mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
feat(dns): configure and store public IP when adding new machine
This commit is contained in:
@@ -538,9 +538,9 @@ func (m *Machine) InitCluster(ctx context.Context, req *pb.InitClusterRequest) (
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "list routable IPs: %v", err)
|
||||
}
|
||||
publicIP, err := network.GetPublicIP()
|
||||
publicIP, pubIPErr := network.GetPublicIP()
|
||||
// Ignore the error if failed to get the public IP using API services.
|
||||
if err == nil {
|
||||
if pubIPErr == nil {
|
||||
ips = append(ips, publicIP)
|
||||
}
|
||||
endpoints := make([]*pb.IPPort, len(ips))
|
||||
@@ -560,7 +560,7 @@ func (m *Machine) InitCluster(ctx context.Context, req *pb.InitClusterRequest) (
|
||||
}
|
||||
if req.GetPublicIp() != nil {
|
||||
addReq.PublicIp = req.GetPublicIp()
|
||||
} else if req.GetPublicIpAuto() {
|
||||
} else if req.GetPublicIpAuto() && pubIPErr == nil {
|
||||
addReq.PublicIp = pb.NewIP(publicIP)
|
||||
}
|
||||
|
||||
@@ -690,7 +690,7 @@ func (m *Machine) Token(_ context.Context, _ *emptypb.Empty) (*pb.TokenResponse,
|
||||
endpoints[i] = netip.AddrPortFrom(ip, network.WireGuardPort)
|
||||
}
|
||||
|
||||
token := NewToken(m.state.Network.PublicKey, endpoints)
|
||||
token := NewToken(m.state.Network.PublicKey, publicIP, endpoints)
|
||||
tokenStr, err := token.String()
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
|
||||
Reference in New Issue
Block a user