-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate config depending on IP range
- Loading branch information
1 parent
6991032
commit ff32436
Showing
5 changed files
with
72 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import os from 'os'; | ||
import { logs } from '../logs'; | ||
|
||
export function getDockerContainerIP(): string | null { | ||
const networkInterfaces = os.networkInterfaces(); | ||
|
||
// Docker typically uses eth0 as the first network interface for bridge networks | ||
const eth0 = networkInterfaces['eth0']; | ||
|
||
if (!eth0) { | ||
logs.error('Network interface eth0 not found.'); | ||
return null; | ||
} | ||
|
||
// Filter for IPv4 address | ||
const ipv4 = eth0.find(info => info.family === 'IPv4'); | ||
|
||
if (!ipv4) { | ||
console.error('IPv4 address for eth0 not found.'); | ||
return null; | ||
} | ||
|
||
return ipv4.address; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters