Skip to content

Commit c0aaea8

Browse files
committed
Use array to track allowed SSH boards
Signed-off-by: Sandeep Mistry <s.mistry@arduino.cc>
1 parent 34abb68 commit c0aaea8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

programmer.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"path/filepath"
1414
"regexp"
1515
"runtime"
16+
"sort"
1617
"strconv"
1718
"strings"
1819
"time"
@@ -25,12 +26,18 @@ import (
2526
)
2627

2728
var compiling = false
29+
var allowedSshBoards = []string{"arduino:avr:yun"}
2830

2931
func colonToUnderscore(input string) string {
3032
output := strings.Replace(input, ":", "_", -1)
3133
return output
3234
}
3335

36+
func sshProgramAllowed(boardname string) bool {
37+
sort.Strings(allowedSshBoards)
38+
return sort.SearchStrings(allowedSshBoards, boardname) != len(allowedSshBoards)
39+
}
40+
3441
type basicAuthData struct {
3542
Username string `json:"username"`
3643
Password string `json:"password"`
@@ -267,7 +274,7 @@ func spProgramRW(portname string, boardname string, filePath string, commandline
267274

268275
if extraInfo.Network {
269276
err = spProgramNetwork(portname, boardname, filePath, extraInfo.Auth)
270-
if err != nil && boardname == "arduino:avr:yun" {
277+
if err != nil && sshProgramAllowed(boardname) {
271278
// http method failed, try ssh upload (Yun only)
272279
err = spProgramSSHNetwork(portname, boardname, filePath, commandline, extraInfo.Auth)
273280
}

0 commit comments

Comments
 (0)