diff --git a/OpenApi.yml b/OpenApi.yml index d348697..85ea4a3 100644 --- a/OpenApi.yml +++ b/OpenApi.yml @@ -314,6 +314,9 @@ components: type: string format: datetime example: "2021-03-07T21:56:34Z" + ip: + type: string + example: "172.0.0.3" RoomMount: type: object diff --git a/client/src/api/api.ts b/client/src/api/api.ts index c64e202..ff68199 100644 --- a/client/src/api/api.ts +++ b/client/src/api/api.ts @@ -272,6 +272,12 @@ export interface RoomEntry { * @memberof RoomEntry */ 'created'?: string; + /** + * + * @type {string} + * @memberof RoomEntry + */ + 'ip'?: string; } /** * diff --git a/internal/room/containers.go b/internal/room/containers.go index aa0f869..6795c14 100644 --- a/internal/room/containers.go +++ b/internal/room/containers.go @@ -12,6 +12,17 @@ import ( "m1k1o/neko_rooms/internal/types" ) +func GetIP(container dockerTypes.Container) (ip string) { + if container.NetworkSettings != nil { + for _, val := range container.NetworkSettings.Networks { + if val.IPAddress != "" { + return val.IPAddress + } + } + } + return "" +} + func (manager *RoomManagerCtx) containerToEntry(container dockerTypes.Container) (*types.RoomEntry, error) { labels, err := manager.extractLabels(container.Labels) if err != nil { @@ -28,6 +39,7 @@ func (manager *RoomManagerCtx) containerToEntry(container dockerTypes.Container) Running: container.State == "running", Status: container.Status, Created: time.Unix(container.Created, 0), + Ip: GetIP(container), }, nil } diff --git a/internal/types/room.go b/internal/types/room.go index 61e132f..470d5de 100644 --- a/internal/types/room.go +++ b/internal/types/room.go @@ -39,6 +39,7 @@ type RoomEntry struct { Running bool `json:"running"` Status string `json:"status"` Created time.Time `json:"created"` + Ip string `json:"ip"` } type MountType string