mirror of
https://github.com/fatedier/frp.git
synced 2025-07-27 07:35:07 +00:00
lint by golangci-lint (#3080)
This commit is contained in:
@@ -22,8 +22,8 @@ type Artifacts struct {
|
||||
ResourceVersion string
|
||||
}
|
||||
|
||||
// CertGenerator is an interface to provision the serving certificate.
|
||||
type CertGenerator interface {
|
||||
// Generator is an interface to provision the serving certificate.
|
||||
type Generator interface {
|
||||
// Generate returns a Artifacts struct.
|
||||
Generate(CommonName string) (*Artifacts, error)
|
||||
// SetCA sets the PEM-encoded CA private key and CA cert for signing the generated serving cert.
|
||||
|
@@ -23,7 +23,7 @@ type SelfSignedCertGenerator struct {
|
||||
caCert []byte
|
||||
}
|
||||
|
||||
var _ CertGenerator = &SelfSignedCertGenerator{}
|
||||
var _ Generator = &SelfSignedCertGenerator{}
|
||||
|
||||
// SetCA sets the PEM-encoded CA private key and CA cert for signing the generated serving cert.
|
||||
func (cp *SelfSignedCertGenerator) SetCA(caKey, caCert []byte) {
|
||||
|
@@ -26,16 +26,17 @@ func unmarshalFromName(name string) (*nameBuilder, error) {
|
||||
builder.name = arrs[1]
|
||||
case 4:
|
||||
builder.name = arrs[1]
|
||||
if fromPort, err := strconv.Atoi(arrs[2]); err != nil {
|
||||
fromPort, err := strconv.Atoi(arrs[2])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error range port from")
|
||||
} else {
|
||||
builder.rangePortFrom = fromPort
|
||||
}
|
||||
if toPort, err := strconv.Atoi(arrs[3]); err != nil {
|
||||
builder.rangePortFrom = fromPort
|
||||
|
||||
toPort, err := strconv.Atoi(arrs[3])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error range port to")
|
||||
} else {
|
||||
builder.rangePortTo = toPort
|
||||
}
|
||||
builder.rangePortTo = toPort
|
||||
default:
|
||||
return nil, fmt.Errorf("error port name format")
|
||||
}
|
||||
|
@@ -12,9 +12,10 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
libdial "github.com/fatedier/golib/net/dial"
|
||||
|
||||
"github.com/fatedier/frp/test/e2e/pkg/rpc"
|
||||
"github.com/fatedier/frp/test/e2e/pkg/utils"
|
||||
libdial "github.com/fatedier/golib/net/dial"
|
||||
)
|
||||
|
||||
type Request struct {
|
||||
@@ -181,7 +182,7 @@ func (r *Request) Do() (*Response, error) {
|
||||
|
||||
defer conn.Close()
|
||||
if r.timeout > 0 {
|
||||
conn.SetDeadline(time.Now().Add(r.timeout))
|
||||
_ = conn.SetDeadline(time.Now().Add(r.timeout))
|
||||
}
|
||||
buf, err := r.sendRequestByConn(conn, r.body)
|
||||
if err != nil {
|
||||
@@ -199,7 +200,6 @@ type Response struct {
|
||||
func (r *Request) sendHTTPRequest(method, urlstr string, host string, headers map[string]string,
|
||||
proxy string, body []byte, tlsConfig *tls.Config,
|
||||
) (*Response, error) {
|
||||
|
||||
var inBody io.Reader
|
||||
if len(body) != 0 {
|
||||
inBody = bytes.NewReader(body)
|
||||
@@ -240,6 +240,7 @@ func (r *Request) sendHTTPRequest(method, urlstr string, host string, headers ma
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
ret := &Response{Code: resp.StatusCode, Header: resp.Header}
|
||||
buf, err := io.ReadAll(resp.Body)
|
||||
|
@@ -9,7 +9,10 @@ import (
|
||||
|
||||
func WriteBytes(w io.Writer, buf []byte) (int, error) {
|
||||
out := bytes.NewBuffer(nil)
|
||||
binary.Write(out, binary.BigEndian, int64(len(buf)))
|
||||
if err := binary.Write(out, binary.BigEndian, int64(len(buf))); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
out.Write(buf)
|
||||
return w.Write(out.Bytes())
|
||||
}
|
||||
|
Reference in New Issue
Block a user