mirror of
https://github.com/nadoo/glider.git
synced 2025-02-23 17:35:40 +08:00
kcp: add some default settings to kcp conn (to improve the speed)
This commit is contained in:
parent
750862abdb
commit
c6a879dded
@ -162,12 +162,19 @@ func (s *KCP) ListenAndServe() {
|
||||
log.F("[kcp] listening on %s", s.addr)
|
||||
|
||||
for {
|
||||
c, err := l.Accept()
|
||||
c, err := l.AcceptKCP()
|
||||
if err != nil {
|
||||
log.F("[kcp] failed to accept: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
c.SetStreamMode(true)
|
||||
c.SetWriteDelay(false)
|
||||
c.SetNoDelay(0, 30, 2, 1)
|
||||
c.SetWindowSize(1024, 1024)
|
||||
c.SetMtu(1350)
|
||||
c.SetACKNoDelay(true)
|
||||
|
||||
go s.Serve(c)
|
||||
}
|
||||
}
|
||||
@ -197,6 +204,17 @@ func (s *KCP) Dial(network, addr string) (net.Conn, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c.SetStreamMode(true)
|
||||
c.SetWriteDelay(false)
|
||||
c.SetNoDelay(0, 30, 2, 1)
|
||||
c.SetWindowSize(1024, 1024)
|
||||
c.SetMtu(1350)
|
||||
c.SetACKNoDelay(true)
|
||||
|
||||
c.SetDSCP(0)
|
||||
c.SetReadBuffer(4194304)
|
||||
c.SetWriteBuffer(4194304)
|
||||
|
||||
return c, err
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ func clientHello() *bytes.Buffer {
|
||||
|
||||
// https://github.com/shadowsocks/simple-obfs/blob/7659eeccf473aa41eb294e92c32f8f60a8747325/src/obfs_tls.c#L57
|
||||
// Cipher Suites Length: 56
|
||||
buf.Write([]byte{0x00, 0x38})
|
||||
binary.Write(buf, binary.BigEndian, uint16(56))
|
||||
// Cipher Suites (28 suites)
|
||||
buf.Write([]byte{
|
||||
0xc0, 0x2c, 0xc0, 0x30, 0x00, 0x9f, 0xcc, 0xa9, 0xcc, 0xa8, 0xcc, 0xaa, 0xc0, 0x2b, 0xc0, 0x2f,
|
||||
|
Loading…
Reference in New Issue
Block a user