Skip to content

Commit

Permalink
Merge pull request #450 from bittorrent/feat/dashboard-login
Browse files Browse the repository at this point in the history
feat: ignore local cmd
  • Loading branch information
mengcody authored Aug 29, 2024
2 parents a6a26e7 + 880600e commit c337ccd
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions core/corehttp/corehttp_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package corehttp
import (
"errors"
"fmt"
"net/http"
"strings"
"time"

"github.com/bittorrent/go-btfs/core"
"github.com/bittorrent/go-btfs/core/commands"
"github.com/bittorrent/go-btfs/utils"
ds "github.com/ipfs/go-datastore"
"net/http"
"strings"
"time"
)

const defaultTwoStepDuration = 30 * time.Minute
Expand Down Expand Up @@ -112,13 +113,16 @@ func filterUrl(r *http.Request) bool {
return urls[r.URL.Path]
}

const defaultUserAgent = "Go-http-client/1.1"
const (
defaultUserAgent = "Go-http-client/1.1"
cmdUserAget = "go-btfs-cmds/http"
)

func filterLocalShellApi(r *http.Request) bool {
host := r.Host
ua := r.Header.Get("User-Agent")
// ua is not Go-http-client
if host == "127.0.0.1:5001" && ua == defaultUserAgent {
if host == "127.0.0.1:5001" && (ua == defaultUserAgent || ua == cmdUserAget) {
return true
}
return false
Expand Down

0 comments on commit c337ccd

Please sign in to comment.