mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
refactor corrosion into interface service
This commit is contained in:
@@ -23,12 +23,15 @@ type networkController struct {
|
||||
state *State
|
||||
wgnet *network.WireGuardNetwork
|
||||
server *grpc.Server
|
||||
corrosion CorrosionService
|
||||
newMachinesCh <-chan *pb.MachineInfo
|
||||
// TODO: DNS server/resolver listening on the machine IP, e.g. 10.210.0.1:53. It can't listen on 127.0.X.X
|
||||
// like resolved does because it needs to be reachable from both the host and the containers.
|
||||
}
|
||||
|
||||
func newNetworkController(state *State, server *grpc.Server, newMachCh <-chan *pb.MachineInfo) (
|
||||
func newNetworkController(
|
||||
state *State, server *grpc.Server, corrosion CorrosionService, newMachCh <-chan *pb.MachineInfo,
|
||||
) (
|
||||
*networkController, error,
|
||||
) {
|
||||
slog.Info("Starting WireGuard network.")
|
||||
@@ -41,6 +44,7 @@ func newNetworkController(state *State, server *grpc.Server, newMachCh <-chan *p
|
||||
state: state,
|
||||
wgnet: wgnet,
|
||||
server: server,
|
||||
corrosion: corrosion,
|
||||
newMachinesCh: newMachCh,
|
||||
}, nil
|
||||
}
|
||||
@@ -51,6 +55,13 @@ func (nc *networkController) Run(ctx context.Context) error {
|
||||
}
|
||||
slog.Info("WireGuard network configured.")
|
||||
|
||||
if err := nc.corrosion.Configure(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := nc.corrosion.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
errGroup, ctx := errgroup.WithContext(ctx)
|
||||
|
||||
// Start the network API server. Assume the management IP can't be changed when the network is running.
|
||||
|
||||
Reference in New Issue
Block a user