Skip to content

Commit 4aaa12c

Browse files
author
Cheng Li
committed
fix getting outboundip of the machine
1 parent 7ff2759 commit 4aaa12c

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

framework/cmd/server/utils.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ func getTracerServerAddress(addr string) string {
2323
return trimPrefix(addr)
2424
}
2525
host = trimPrefix(host)
26+
2627
if host == "localhost" {
27-
return getHostIP()
28+
return GetOutboundIP().String()
2829
}
2930
return host
3031
}
3132

33+
// This does not give the outbound ip of this machine
3234
func getHostIP() string {
3335
consensus := externalip.DefaultConsensus(nil, nil)
3436
ip, err := consensus.ExternalIP()
@@ -37,3 +39,16 @@ func getHostIP() string {
3739
}
3840
return ip.String()
3941
}
42+
43+
// Get preferred outbound ip of this machine
44+
func GetOutboundIP() net.IP {
45+
conn, err := net.Dial("udp", "8.8.8.8:80")
46+
if err != nil {
47+
log.Fatal(err)
48+
}
49+
defer conn.Close()
50+
51+
localAddr := conn.LocalAddr().(*net.UDPAddr)
52+
53+
return localAddr.IP
54+
}

framework/register.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ func Register(framework dlframework.FrameworkManifest, a *assetfs.AssetFS) error
6868
if !check {
6969
log.WithField("frameworkVersion", frameworkVersion).
7070
WithField("model_framework_constraint", model.GetFramework().GetVersion()).
71-
Error("failed to satisfy framework constraints")
72-
return err
71+
Warning("failed to satisfy framework constraints")
72+
continue
7373
}
7474

7575
if model.GetHidden() {

0 commit comments

Comments
 (0)