Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit e5f73c2

Browse files
committed
Add tor bool to GET config response
closes #563
1 parent f1a47dd commit e5f73c2

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

api/jsonapi.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,11 +867,28 @@ func (i *jsonAPIHandler) POSTSpendCoins(w http.ResponseWriter, r *http.Request)
867867
}
868868

869869
func (i *jsonAPIHandler) GETConfig(w http.ResponseWriter, r *http.Request) {
870+
type cfg struct {
871+
PeerId string `json:"peerID"`
872+
CryptoCurrency string `json:"cryptoCurrency"`
873+
Testnet bool `json:"testnet"`
874+
Tor bool `json:"tor"`
875+
}
876+
870877
testnet := false
871878
if i.node.Wallet.Params().Name != chaincfg.MainNetParams.Name {
872879
testnet = true
873880
}
874-
SanitizedResponse(w, fmt.Sprintf(`{"peerID": "%s", "cryptoCurrency": "%s", "testnet": %t}`, i.node.IpfsNode.Identity.Pretty(), strings.ToUpper(i.node.Wallet.CurrencyCode()), testnet))
881+
var usingTor bool
882+
if i.node.TorDialer != nil {
883+
usingTor = true
884+
}
885+
c := cfg{i.node.IpfsNode.Identity.Pretty(), strings.ToUpper(i.node.Wallet.CurrencyCode()), testnet, usingTor}
886+
ser, err := json.MarshalIndent(c, "", " ")
887+
if err != nil {
888+
ErrorResponse(w, http.StatusInternalServerError, err.Error())
889+
return
890+
}
891+
SanitizedResponse(w, string(ser))
875892
}
876893

877894
func (i *jsonAPIHandler) POSTSettings(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)