Prechádzať zdrojové kódy

modify by hyb for Signature config

heyubin 7 rokov pred
rodič
commit
87b93311cf
3 zmenil súbory, kde vykonal 5 pridanie a 1 odobranie
  1. 2 0
      coinproxy.toml
  2. 2 0
      config.go
  3. 1 1
      httphandler.go

+ 2 - 0
coinproxy.toml

@@ -15,3 +15,5 @@ dbpath="/var/"
 
 [cointype]
 type=["BCC"]
+sigkey="coinsapi^&#@(*33"
+

+ 2 - 0
config.go

@@ -42,8 +42,10 @@ type databaseinfo struct {
 
 type cointype struct {
 	Type []string
+	Sigkey string
 }
 
+
 func coinInit() {
 	runtime.GOMAXPROCS(CPUNUM)
 	flag.PrintDefaults()

+ 1 - 1
httphandler.go

@@ -111,7 +111,7 @@ func commonFunc(w http.ResponseWriter, r *http.Request, js *simplejson.Json, bod
 func checkSignature(body []byte, timestamp, signature string) bool {
 
 	sha1Contain := sha1.New()
-	byteSha1 := append(body, append([]byte(timestamp), []byte("coinsapi^&#@(*33")...)...)
+	byteSha1 := append(body, append([]byte(timestamp), []byte(Gconfig.CoinType.Sigkey)...)...)
 	sha1Contain.Write(byteSha1)
 	localSig := hex.EncodeToString(sha1Contain.Sum(nil))
 	log.Debug("caculate local signature:%v", localSig)