Skip to content

Commit a0af8c8

Browse files
committed
Add support for username + password auth
1 parent 37ecb00 commit a0af8c8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ var (
2222
version = flag.Bool("version", false, "Prints program version")
2323
networkAddress = flag.String("address", "localhost", "The address of the board")
2424
networkPort = flag.String("port", "80", "The board needs to be listening on this port")
25+
username = flag.String("username", "", "Username for authentication")
26+
password = flag.String("password", "", "Password for authentication")
2527
sketchPath = flag.String("sketch", "", "Sketch path")
2628
uploadEndpoint = flag.String("upload", "", "Upload endpoint")
2729
resetEndpoint = flag.String("reset", "", "Upload endpoint")
@@ -141,6 +143,10 @@ func main() {
141143
}
142144
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
143145

146+
if len(*username) > 0 && len(*password) != 0 {
147+
req.SetBasicAuth(*username, *password)
148+
}
149+
144150
resp, err := http.DefaultClient.Do(req)
145151
if err != nil {
146152
if *verbose {

0 commit comments

Comments
 (0)