@@ -13,6 +13,7 @@ import (
13
13
"path/filepath"
14
14
"regexp"
15
15
"runtime"
16
+ "sort"
16
17
"strconv"
17
18
"strings"
18
19
"time"
@@ -25,12 +26,18 @@ import (
25
26
)
26
27
27
28
var compiling = false
29
+ var allowedSshBoards = []string {"arduino:avr:yun" }
28
30
29
31
func colonToUnderscore (input string ) string {
30
32
output := strings .Replace (input , ":" , "_" , - 1 )
31
33
return output
32
34
}
33
35
36
+ func sshProgramAllowed (boardname string ) bool {
37
+ sort .Strings (allowedSshBoards )
38
+ return sort .SearchStrings (allowedSshBoards , boardname ) != len (allowedSshBoards )
39
+ }
40
+
34
41
type basicAuthData struct {
35
42
Username string `json:"username"`
36
43
Password string `json:"password"`
@@ -267,8 +274,8 @@ func spProgramRW(portname string, boardname string, filePath string, commandline
267
274
268
275
if extraInfo .Network {
269
276
err = spProgramNetwork (portname , boardname , filePath , extraInfo .Auth )
270
- if err != nil && boardname == "arduino:avr:yun" {
271
- // http method failed, try ssh upload (Yun only)
277
+ if err != nil && sshProgramAllowed ( boardname ) {
278
+ // http method failed, try ssh upload if allowed
272
279
err = spProgramSSHNetwork (portname , boardname , filePath , commandline , extraInfo .Auth )
273
280
}
274
281
} else {
0 commit comments