MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / GetConnectionsList

Function GetConnectionsList

pkg/remote/conncontroller/conncontroller.go:1200–1238  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1198}
1199
1200func GetConnectionsList() ([]string, error) {
1201 existing := GetAllConnStatus()
1202 var currentlyRunning []string
1203 var hasConnected []string
1204
1205 // populate all lists
1206 for _, stat := range existing {
1207 if stat.Connected {
1208 currentlyRunning = append(currentlyRunning, stat.Connection)
1209 }
1210
1211 if stat.HasConnected {
1212 hasConnected = append(hasConnected, stat.Connection)
1213 }
1214 }
1215
1216 fromInternal := GetConnectionsFromInternalConfig()
1217
1218 fromConfig, err := GetConnectionsFromConfig()
1219 if err != nil {
1220 // this is not a fatal error. do not return
1221 log.Printf("warning: no connections from ssh config found: %v", err)
1222 }
1223
1224 // sort into one final list and remove duplicates
1225 alreadyUsed := make(map[string]struct{})
1226 var connList []string
1227
1228 for _, subList := range [][]string{currentlyRunning, hasConnected, fromInternal, fromConfig} {
1229 for _, pattern := range subList {
1230 if _, used := alreadyUsed[pattern]; !used {
1231 connList = append(connList, pattern)
1232 alreadyUsed[pattern] = struct{}{}
1233 }
1234 }
1235 }
1236
1237 return connList, nil
1238}
1239
1240func GetConnectionsFromInternalConfig() []string {
1241 var internalNames []string

Callers 1

ConnListCommandMethod · 0.92

Calls 3

GetConnectionsFromConfigFunction · 0.85
GetAllConnStatusFunction · 0.70

Tested by

no test coverage detected