Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions programmer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"path/filepath"
"regexp"
"runtime"
"sort"
"strconv"
"strings"
"time"
Expand All @@ -25,12 +26,18 @@ import (
)

var compiling = false
var allowedSshBoards = []string{"arduino:avr:yun"}

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

func sshProgramAllowed(boardname string) bool {
sort.Strings(allowedSshBoards)
return sort.SearchStrings(allowedSshBoards, boardname) != len(allowedSshBoards)
}

type basicAuthData struct {
Username string `json:"username"`
Password string `json:"password"`
Expand Down Expand Up @@ -267,8 +274,8 @@ func spProgramRW(portname string, boardname string, filePath string, commandline

if extraInfo.Network {
err = spProgramNetwork(portname, boardname, filePath, extraInfo.Auth)
if err != nil {
// no http method available, try ssh upload
if err != nil && sshProgramAllowed(boardname) {
// http method failed, try ssh upload if allowed
err = spProgramSSHNetwork(portname, boardname, filePath, commandline, extraInfo.Auth)
}
} else {
Expand Down