mirror of https://github.com/Dreamacro/clash.git
Chore: code adjustments
This commit is contained in:
parent
8f32e6a60f
commit
2dece02df6
|
@ -81,6 +81,9 @@ port: 7890
|
||||||
# port of SOCKS5
|
# port of SOCKS5
|
||||||
socks-port: 7891
|
socks-port: 7891
|
||||||
|
|
||||||
|
# (HTTP and SOCKS5 in one port)
|
||||||
|
# mixed-port: 7890
|
||||||
|
|
||||||
# redir port for Linux and macOS
|
# redir port for Linux and macOS
|
||||||
# redir-port: 7892
|
# redir-port: 7892
|
||||||
|
|
||||||
|
@ -394,4 +397,4 @@ https://clash.gitbook.io/
|
||||||
- [x] Redir proxy
|
- [x] Redir proxy
|
||||||
- [x] UDP support
|
- [x] UDP support
|
||||||
- [x] Connection manager
|
- [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 {
|
func (t *Trojan) WriteHeader(w io.Writer, command Command, socks5Addr []byte) error {
|
||||||
buf := bufPool.Get().(*bytes.Buffer)
|
buf := bufPool.Get().(*bytes.Buffer)
|
||||||
defer buf.Reset()
|
|
||||||
defer bufPool.Put(buf)
|
defer bufPool.Put(buf)
|
||||||
|
defer buf.Reset()
|
||||||
|
|
||||||
buf.Write(t.hexPassword)
|
buf.Write(t.hexPassword)
|
||||||
buf.Write(crlf)
|
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) {
|
func writePacket(w io.Writer, socks5Addr, payload []byte) (int, error) {
|
||||||
buf := bufPool.Get().(*bytes.Buffer)
|
buf := bufPool.Get().(*bytes.Buffer)
|
||||||
defer buf.Reset()
|
|
||||||
defer bufPool.Put(buf)
|
defer bufPool.Put(buf)
|
||||||
|
defer buf.Reset()
|
||||||
|
|
||||||
buf.Write(socks5Addr)
|
buf.Write(socks5Addr)
|
||||||
binary.Write(buf, binary.BigEndian, uint16(len(payload)))
|
binary.Write(buf, binary.BigEndian, uint16(len(payload)))
|
||||||
|
|
|
@ -23,8 +23,8 @@ const (
|
||||||
|
|
||||||
type NetWork int
|
type NetWork int
|
||||||
|
|
||||||
func (n *NetWork) String() string {
|
func (n NetWork) String() string {
|
||||||
if *n == TCP {
|
if n == TCP {
|
||||||
return "tcp"
|
return "tcp"
|
||||||
}
|
}
|
||||||
return "udp"
|
return "udp"
|
||||||
|
|
Loading…
Reference in New Issue