Skip to content

Commit

Permalink
optimize: use segmention/encoding/json instead of std/json
Browse files Browse the repository at this point in the history
  • Loading branch information
nange committed Apr 29, 2024
1 parent bdecda2 commit 5e2f837
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/oschwald/geoip2-golang v1.9.0
github.com/refraction-networking/utls v1.6.4
github.com/samber/slog-formatter v1.0.0
github.com/segmentio/encoding v0.4.0
github.com/smallnest/ringbuffer v0.0.0-20230728150354-35801fa39d0e
github.com/stretchr/testify v1.9.0
github.com/txthinking/socks5 v0.0.0-20230325130024-4230056ae301
Expand Down Expand Up @@ -67,6 +68,7 @@ require (
github.com/quic-go/quic-go v0.42.0 // indirect
github.com/samber/lo v1.38.1 // indirect
github.com/samber/slog-multi v1.0.0 // indirect
github.com/segmentio/asm v1.1.3 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/txthinking/runnergroup v0.0.0-20210608031112-152c7c4432bf // indirect
github.com/zeebo/blake3 v0.2.3 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ github.com/samber/slog-formatter v1.0.0 h1:ULxHV+jNqi6aFP8xtzGHl2ejFRMl2+jI2UhCp
github.com/samber/slog-formatter v1.0.0/go.mod h1:c7pRfwhCfZQNzJz+XirmTveElxXln7M0Y8Pq781uxlo=
github.com/samber/slog-multi v1.0.0 h1:snvP/P5GLQ8TQh5WSqdRaxDANW8AAA3egwEoytLsqvc=
github.com/samber/slog-multi v1.0.0/go.mod h1:uLAvHpGqbYgX4FSL0p1ZwoLuveIAJvBECtE07XmYvFo=
github.com/segmentio/asm v1.1.3 h1:WM03sfUOENvvKexOLp+pCqgb/WDjsi7EK8gIsICtzhc=
github.com/segmentio/asm v1.1.3/go.mod h1:Ld3L4ZXGNcSLRg4JBsZ3//1+f/TjYl0Mzen/DQy1EJg=
github.com/segmentio/encoding v0.4.0 h1:MEBYvRqiUB2nfR2criEXWqwdY6HJOUrCn5hboVOVmy8=
github.com/segmentio/encoding v0.4.0/go.mod h1:/d03Cd8PoaDeceuhUUUQWjU0KhWjrmYrWPgtJHYZSnI=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog=
Expand Down
3 changes: 2 additions & 1 deletion httptunnel/local_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/nange/easyss/v2/log"
"github.com/nange/easyss/v2/util/bytespool"
"github.com/nange/easyss/v2/util/netpipe"
json2 "github.com/segmentio/encoding/json"
)

const (
Expand Down Expand Up @@ -209,7 +210,7 @@ func (l *LocalConn) Read(b []byte) (int, error) {
p := &pushPayload{}
_ = faker.FakeData(p)
p.Payload = base64.StdEncoding.EncodeToString(buf[:n])
payload, _ = json.Marshal(p)
payload, _ = json2.Marshal(p)
}

cn := copy(b, payload)
Expand Down
2 changes: 1 addition & 1 deletion httptunnel/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package httptunnel
import (
"crypto/tls"
"encoding/base64"
"encoding/json"
"errors"
"io"
"net"
Expand All @@ -18,6 +17,7 @@ import (
"github.com/nange/easyss/v2/log"
"github.com/nange/easyss/v2/util/bytespool"
"github.com/nange/easyss/v2/util/netpipe"
"github.com/segmentio/encoding/json"
)

const RelayBufferSize = cipherstream.MaxCipherRelaySize
Expand Down

0 comments on commit 5e2f837

Please sign in to comment.