Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

sockopts_lowat.go 650B

1234567891011121314151617181920
  1. //go:build linux || darwin
  2. package network
  3. import (
  4. "syscall"
  5. "golang.org/x/sys/unix"
  6. )
  7. // setNotSentLowat sets TCP_NOTSENT_LOWAT which limits the amount of
  8. // unsent data queued in the kernel write buffer. Once unsent data drops
  9. // below this threshold the socket becomes writable again, applying
  10. // back-pressure to the relay loop instead of piling up data in kernel
  11. // buffers. This reduces per-connection memory and bufferbloat.
  12. func setNotSentLowat(conn syscall.RawConn) {
  13. conn.Control(func(fd uintptr) { //nolint: errcheck
  14. unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_NOTSENT_LOWAT, tcpNotSentLowat) //nolint: errcheck
  15. })
  16. }