Chore: code adjustments
This commit is contained in:
parent
3ec3934963
commit
aa217977bf
3 changed files with 8 additions and 5 deletions
|
@ -81,6 +81,9 @@ port: 7890
|
|||
# port of SOCKS5
|
||||
socks-port: 7891
|
||||
|
||||
# (HTTP and SOCKS5 in one port)
|
||||
# mixed-port: 7890
|
||||
|
||||
# redir port for Linux and macOS
|
||||
# redir-port: 7892
|
||||
|
||||
|
@ -394,4 +397,4 @@ https://clash.gitbook.io/
|
|||
- [x] Redir proxy
|
||||
- [x] UDP support
|
||||
- [x] Connection manager
|
||||
- [ ] Event API
|
||||
- ~~[ ] Event API~~
|
||||
|
|
|
@ -70,8 +70,8 @@ func (t *Trojan) StreamConn(conn net.Conn) (net.Conn, error) {
|
|||
|
||||
func (t *Trojan) WriteHeader(w io.Writer, command Command, socks5Addr []byte) error {
|
||||
buf := bufPool.Get().(*bytes.Buffer)
|
||||
defer buf.Reset()
|
||||
defer bufPool.Put(buf)
|
||||
defer buf.Reset()
|
||||
|
||||
buf.Write(t.hexPassword)
|
||||
buf.Write(crlf)
|
||||
|
@ -92,8 +92,8 @@ func (t *Trojan) PacketConn(conn net.Conn) net.PacketConn {
|
|||
|
||||
func writePacket(w io.Writer, socks5Addr, payload []byte) (int, error) {
|
||||
buf := bufPool.Get().(*bytes.Buffer)
|
||||
defer buf.Reset()
|
||||
defer bufPool.Put(buf)
|
||||
defer buf.Reset()
|
||||
|
||||
buf.Write(socks5Addr)
|
||||
binary.Write(buf, binary.BigEndian, uint16(len(payload)))
|
||||
|
|
|
@ -23,8 +23,8 @@ const (
|
|||
|
||||
type NetWork int
|
||||
|
||||
func (n *NetWork) String() string {
|
||||
if *n == TCP {
|
||||
func (n NetWork) String() string {
|
||||
if n == TCP {
|
||||
return "tcp"
|
||||
}
|
||||
return "udp"
|
||||
|
|
Loading…
Reference in a new issue