Commit 6ee9a569 authored by wang's avatar wang

cronet

parent ea8525b9
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"compress/flate" "compress/flate"
"compress/gzip" "compress/gzip"
"crypto/rand" "crypto/rand"
"encoding/base64"
"encoding/binary" "encoding/binary"
"errors" "errors"
"github.com/andybalholm/brotli" "github.com/andybalholm/brotli"
...@@ -69,7 +70,16 @@ func (c *Client) Start() error { ...@@ -69,7 +70,16 @@ func (c *Client) Start() error {
} else if strings.ToUpper(c.Item.Method) == http.MethodOptions { } else if strings.ToUpper(c.Item.Method) == http.MethodOptions {
req, err = http.NewRequest(http.MethodOptions, c.Item.Url, nil) req, err = http.NewRequest(http.MethodOptions, c.Item.Url, nil)
} else { } else {
req, err = http.NewRequest(http.MethodPost, c.Item.Url, strings.NewReader(c.Item.Data)) if c.Item.IsBinary {
bys, err := base64.StdEncoding.DecodeString(c.Item.Data)
if err != nil {
return err
}
req, err = http.NewRequest(http.MethodPost, c.Item.Url, bytes.NewReader(bys))
} else {
req, err = http.NewRequest(http.MethodPost, c.Item.Url, strings.NewReader(c.Item.Data))
}
} }
if err != nil { if err != nil {
logrus.Error("url初始化失败 ", err.Error()) logrus.Error("url初始化失败 ", err.Error())
......
...@@ -18,6 +18,7 @@ type ForwardItem struct { ...@@ -18,6 +18,7 @@ type ForwardItem struct {
Verify bool `json:"verify,omitempty"` Verify bool `json:"verify,omitempty"`
Debug bool `json:"debug"` Debug bool `json:"debug"`
RandomTls bool `json:"random_tls"` RandomTls bool `json:"random_tls"`
IsBinary bool `json:"is_binary"`
} }
func ForwardIOS(c *gin.Context) { func ForwardIOS(c *gin.Context) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment