@@ -241,28 +241,29 @@ func GetMachine(id string) (*Machine, error) {
241241 case "CfgFile" :
242242 m .CfgFile = val
243243 m .BaseFolder = filepath .Dir (val )
244- case "Forwarding(0)" :
245- // Forwarding(0)="docker,tcp,127.0.0.1,5555,,"
246- vals := strings .Split (val , "," )
247- n , err := strconv .ParseUint (vals [3 ], 10 , 32 )
248- if err != nil {
249- return nil , err
250- }
251- m .DockerPort = uint (n )
252- case "Forwarding(1)" :
253- // Forwarding(1)="ssh,tcp,127.0.0.1,2222,,22"
254- vals := strings .Split (val , "," )
255- n , err := strconv .ParseUint (vals [3 ], 10 , 32 )
256- if err != nil {
257- return nil , err
258- }
259- m .SSHPort = uint (n )
260244 case "uartmode1" :
261245 // uartmode1="server,/home/sven/.boot2docker/boot2docker-vm.sock"
262246 vals := strings .Split (val , "," )
263247 if len (vals ) >= 2 {
264248 m .SerialFile = vals [1 ]
265249 }
250+ default :
251+ if strings .HasPrefix (key , "Forwarding(" ) {
252+ // "Forwarding(\d*)" are ordered by the name inside the val, not fixed order.
253+ // Forwarding(0)="docker,tcp,127.0.0.1,5555,,"
254+ // Forwarding(1)="ssh,tcp,127.0.0.1,2222,,22"
255+ vals := strings .Split (val , "," )
256+ n , err := strconv .ParseUint (vals [3 ], 10 , 32 )
257+ if err != nil {
258+ return nil , err
259+ }
260+ switch vals [0 ] {
261+ case "docker" :
262+ m .DockerPort = uint (n )
263+ case "ssh" :
264+ m .SSHPort = uint (n )
265+ }
266+ }
266267 }
267268 }
268269 if err := s .Err (); err != nil {
0 commit comments