Skip to content

Commit

Permalink
rewrite the path under FASTRTPS_DEFAULT_PROFILES_FILE and CYCLONEDDS_…
Browse files Browse the repository at this point in the history
…URI only if it contains husarnet substring
  • Loading branch information
DominikN committed Feb 3, 2023
1 parent ba08d79 commit d57fd0b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ func main_loop() {
cyclonedds_uri, ok := os.LookupEnv("CYCLONEDDS_URI")
if ok {
fmt.Println("CYCLONEDDS_URI:", cyclonedds_uri)
output_xml_path = strings.Split(cyclonedds_uri, "file://")[1]
if strings.Contains(cyclonedds_uri, "husarnet") {
output_xml_path = strings.Split(cyclonedds_uri, "file://")[1]
}
}
}

Expand Down Expand Up @@ -163,8 +165,11 @@ func main_loop() {
fastrtps_default_profiles_file, ok := os.LookupEnv("FASTRTPS_DEFAULT_PROFILES_FILE")
if ok {
fmt.Println("FASTRTPS_DEFAULT_PROFILES_FILE:", fastrtps_default_profiles_file)
output_xml_path = fastrtps_default_profiles_file
if strings.Contains(fastrtps_default_profiles_file, "husarnet") {
output_xml_path = fastrtps_default_profiles_file
}
}

}

// Create necessary directories
Expand All @@ -176,6 +181,7 @@ func main_loop() {
}

ioutil.WriteFile(output_xml_path, []byte(output_xml), 0644)
fmt.Printf("DDS config saved here: \"%s\"", output_xml_path)
} else {
fmt.Println("no hnet0 interface")
os.Exit(1)
Expand Down

0 comments on commit d57fd0b

Please sign in to comment.