[agent-go] - 增加公网IP部分
This commit is contained in:
@@ -41,6 +41,7 @@ func INIT(octopusAgentConfigFileName string) chan bool {
|
||||
agentInfo := a_status.ReportAgentInfo()
|
||||
refreshAgentInfoByStatusInfo(agentInfo, agentServerInfo)
|
||||
|
||||
// 如果从在本机文件,那么会使用手动写入的环境变量 进行覆盖
|
||||
if utils.FileExistAndNotNull(AgentServerInfoLocalFilePath) {
|
||||
|
||||
// 获取系统的环境变量
|
||||
@@ -293,11 +294,22 @@ func refreshAgentInfoByStatusInfo(agentInfo *a_status.AgentInfo, agentServerInfo
|
||||
|
||||
func refreshAgentNetworkInfo(agentInfo *a_status.AgentInfo, agentServerInfo *a_agent.AgentServerInfo) {
|
||||
|
||||
// 测试网卡名称
|
||||
//testCases := []string{"ens33", "eno1", "enp0s3", "enp1s2", "eth0", "enp2s5", "enx1234567890ab", "ens1234567890ab", "enp1234567890ab", "enp1234567890ab", "enp1", "lo","","docker0", "virbr0", "veth0",}
|
||||
//for _, tc := range testCases {
|
||||
// fmt.Printf("Network interface '%s' is %s\n", tc, fmt.Sprintf("%v", isNetworkInterface(tc)))
|
||||
//}
|
||||
// 获取Agent的公网服务信息
|
||||
publicNetworkInfo := a_status.PublicNetworkInfo{}
|
||||
publicNetworkInfo.GetPublicNetworkInfo()
|
||||
|
||||
marshal, _ := json.Marshal(publicNetworkInfo)
|
||||
log.InfoF("refreshAgentNetworkInfo - public network info is %s", marshal)
|
||||
|
||||
if publicNetworkInfo.IP != "" {
|
||||
agentServerInfo.ServerIPPbV4 = publicNetworkInfo.IP
|
||||
agentServerInfo.Region = publicNetworkInfo.Region
|
||||
agentServerInfo.City = publicNetworkInfo.City
|
||||
agentServerInfo.Country = publicNetworkInfo.Country
|
||||
agentServerInfo.Location = publicNetworkInfo.Loc
|
||||
agentServerInfo.Organization = publicNetworkInfo.Org
|
||||
agentServerInfo.TimeZone = publicNetworkInfo.Timezone
|
||||
}
|
||||
|
||||
// inner ip v4 v6
|
||||
for _, networkInfo := range agentInfo.NetworkInfo {
|
||||
|
||||
Reference in New Issue
Block a user